Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename sbw_secret->sbw_announce, announce level in central message #2064

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base/all-all/sbardef.lmp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@
"y": 52,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -1908,7 +1908,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -2201,7 +2201,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down
2 changes: 1 addition & 1 deletion base/all-all/sbhuddef.lmp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"y": 52,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down
6 changes: 3 additions & 3 deletions base/extras.wad/sbardef.lmp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@
"y": 52,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -1908,7 +1908,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -2201,7 +2201,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down
6 changes: 3 additions & 3 deletions base/id1.wad/sbardef.lmp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@
"y": 52,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -1908,7 +1908,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down Expand Up @@ -2201,7 +2201,7 @@
"y": 68,
"alignment": 1,
"tranmap": null,
"translation": "CRGOLD",
"translation": null,
"type": 8,
"font": "Console",
"duration": 2.5,
Expand Down
2 changes: 1 addition & 1 deletion src/st_sbardef.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static boolean ParseSbarElemType(json_t *json, sbarelementtype_t type,
switch (widget->type)
{
case sbw_message:
case sbw_secret:
case sbw_announce:
widget->duration =
JS_GetNumberValue(json, "duration") * TICRATE;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/st_sbardef.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ typedef enum
sbw_speed,

sbw_message,
sbw_secret,
sbw_announce,
sbw_chat,
sbw_title,
} sbarwidgettype_t;
Expand Down
28 changes: 21 additions & 7 deletions src/st_widgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ static void UpdateMessage(sbe_widget_t *widget, player_t *player)
}
}

static void UpdateSecretMessage(sbe_widget_t *widget, player_t *player)
static char announce_string[HU_MAXLINELENGTH];

static void UpdateAnnounceMessage(sbe_widget_t *widget, player_t *player)
{
ST_ClearLines(widget);

Expand All @@ -142,9 +144,15 @@ static void UpdateSecretMessage(sbe_widget_t *widget, player_t *player)
return;
}

static char string[80];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The level title won't be displayed if hud_secret_message == 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 85bc7ef

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

As it is now, the "secret revealed" message immediately overrides the map announcement if the player starts the map in a sector tagged as secret. Is this intended? Could we show both messages on two lines probably?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is now, the "secret revealed" message immediately overrides the map announcement if the player starts the map in a sector tagged as secret. Is this intended?

Yes, it's intended. For me, the secret message is more important than the level title, but we can change the priority if you prefer. By the way, what is this map?

Could we show both messages on two lines probably?

It won't look good.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, what is this map?

A copy of MAP01 with the starting sector tagged as secret. 😁

I have seen a map like this in the wild, but couldn't remember which it was.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, why do we clear the line and add the string again during each tic for this widget? The strings aren't going to change anyway.

Copy link
Collaborator Author

@rfomin rfomin Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings can change, e.g. if the player enters a secret sector while the map announce is still on. Note that no strings are copied every tic, only pointers.
I check if lines array is not empty in widget drawing function.
We can check if (string[0] == '/0'), but this code is more complicated and there is no performance benefit - no strings are copied anyway.

static char string[HU_MAXLINELENGTH];

if (player->secretmessage)
if (announce_string[0])
{
widget->duration_left = widget->duration;
M_StringCopy(string, announce_string, sizeof(string));
announce_string[0] = '\0';
}
else if (player->secretmessage)
{
widget->duration_left = widget->duration;
M_StringCopy(string, player->secretmessage, sizeof(string));
Expand Down Expand Up @@ -570,12 +578,18 @@ void ST_ResetTitle(void)
M_snprintf(title_string, sizeof(title_string), "\x1b%c%s" ORIG_S,
'0' + hudcolor_titl, string);

announce_string[0] = '\0';
if (hud_map_announce && leveltime == 0)
{
if (gamemapinfo && U_CheckField(gamemapinfo->author))
displaymsg("%s by %s", string, gamemapinfo->author);
{
M_snprintf(announce_string, sizeof(announce_string), "%s by %s",
string, gamemapinfo->author);
}
else
displaymsg("%s", string);
{
M_snprintf(announce_string, sizeof(announce_string), "%s", string);
}
}
}

Expand Down Expand Up @@ -1082,8 +1096,8 @@ void ST_UpdateWidget(sbarelem_t *elem, player_t *player)
case sbw_chat:
UpdateChat(widget);
break;
case sbw_secret:
UpdateSecretMessage(widget, player);
case sbw_announce:
UpdateAnnounceMessage(widget, player);
break;
case sbw_title:
UpdateTitle(widget);
Expand Down