Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
78 changes: 49 additions & 29 deletions code/hud/hudsquadmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void hud_squadmsg_start()
Num_menu_items = -1; // reset the menu items
First_menu_item = 0;
Selected_menu_item = First_menu_item; // make first menu item a selected object
Display_selector = false;
Display_selector = Always_show_selected_item_in_comms_gauge;

Squad_msg_mode = SM_MODE_TYPE_SELECT; // start off at the base state
Msg_mode_timestamp = _timestamp(DEFAULT_MSG_TIMEOUT); // initialize our timer to bogus value
Expand Down Expand Up @@ -495,27 +495,37 @@ void hud_squadmsg_selection_move_down() {
//Check if comms menu is up
if (Player->flags & PLAYER_FLAGS_MSG_MODE)
{
//move down
++Selected_menu_item;
Display_selector = true;

//play scrolling sound and reset the comms window timeout timer, so the window doesn't disappear while we select our item
gamesnd_play_iface(InterfaceSounds::SCROLL);
Msg_mode_timestamp = _timestamp(DEFAULT_MSG_TIMEOUT);

//Move to next page if we went outside of current one
if (Selected_menu_item == MAX_MENU_DISPLAY
&& (First_menu_item + MAX_MENU_DISPLAY < Num_menu_items))
//move down, skipping over any hidden items (such as using Hide_main_rearm_items_in_comms_gauge).
//bound it by the item count to ensure it does not loop forever.
for (int i = 0; i < Num_menu_items; i++)
{
hud_squadmsg_page_down();
Selected_menu_item = 0;
}
//move down
++Selected_menu_item;

//Select the first menu item if we went outside items range, so we can loop around
if (First_menu_item + Selected_menu_item >= Num_menu_items)
{
First_menu_item = 0;
Selected_menu_item = First_menu_item;
//Move to next page if we went outside of current one
if (Selected_menu_item == MAX_MENU_DISPLAY
&& (First_menu_item + MAX_MENU_DISPLAY < Num_menu_items))
{
hud_squadmsg_page_down();
Selected_menu_item = 0;
}

//Select the first menu item if we went outside items range, so we can loop around
if (First_menu_item + Selected_menu_item >= Num_menu_items)
{
First_menu_item = 0;
Selected_menu_item = First_menu_item;
}

//stop once we land on a visible item
if (MsgItems[First_menu_item + Selected_menu_item].active >= 0)
break;
}
}
}
Expand All @@ -525,29 +535,39 @@ void hud_squadmsg_selection_move_up() {
//Check if comms menu is up
if (Player->flags & PLAYER_FLAGS_MSG_MODE)
{
//move up
--Selected_menu_item;
Display_selector = true;

//play scrolling sound and reset the comms window timeout timer, so the window doesn't disappear while we select our item
gamesnd_play_iface(InterfaceSounds::SCROLL);
Msg_mode_timestamp = _timestamp(DEFAULT_MSG_TIMEOUT);

//Move to previous page if it exists
if (Selected_menu_item < 0 && First_menu_item > 0)
//move down, skipping over any hidden items (such as using Hide_main_rearm_items_in_comms_gauge).
//bound it by the item count to ensure it does not loop forever.
for (int i = 0; i < Num_menu_items; i++)
{
hud_squadmsg_page_up();
Selected_menu_item = MAX_MENU_DISPLAY - 1; //if we're moving to previous page in the first place, we assume it was already populated to the max
}
//move up
--Selected_menu_item;

//Select the last menu item if we went outside items range, so we can loop around
else if (Selected_menu_item < 0)
{
//Assuming MAX_MENU_DISPLAY = 10, set First_menu_item to the nearest lower multiple of 10
//So if we have 85 items in comms menu, looping back from 1st page to last would set First_menu_item to 80
//exactly like pageUp/pageDown does
First_menu_item = ((Num_menu_items - 1) / MAX_MENU_DISPLAY) * MAX_MENU_DISPLAY;
Selected_menu_item = Num_menu_items - 1 - First_menu_item;
//Move to previous page if it exists
if (Selected_menu_item < 0 && First_menu_item > 0)
{
hud_squadmsg_page_up();
Selected_menu_item = MAX_MENU_DISPLAY - 1; //if we're moving to previous page in the first place, we assume it was already populated to the max
}

//Select the last menu item if we went outside items range, so we can loop around
else if (Selected_menu_item < 0)
{
//Assuming MAX_MENU_DISPLAY = 10, set First_menu_item to the nearest lower multiple of 10
//So if we have 85 items in comms menu, looping back from 1st page to last would set First_menu_item to 80
//exactly like pageUp/pageDown does
First_menu_item = ((Num_menu_items - 1) / MAX_MENU_DISPLAY) * MAX_MENU_DISPLAY;
Selected_menu_item = Num_menu_items - 1 - First_menu_item;
}

//stop once we land on a visible item
if (MsgItems[First_menu_item + Selected_menu_item].active >= 0)
break;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions code/mod_table/mod_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ bool Use_new_scanning_behavior;
bool Lua_API_returns_nil_instead_of_invalid_object;
bool Dont_show_callsigns_in_escort_list;
bool Hide_main_rearm_items_in_comms_gauge;
bool Always_show_selected_item_in_comms_gauge;
bool Fix_scripted_velocity;
color Overhead_line_colors[MAX_SHIP_SECONDARY_BANKS];
bool Preload_briefing_icon_models;
Expand Down Expand Up @@ -499,6 +500,10 @@ void parse_mod_table(const char *filename)
stuff_boolean(&Hide_main_rearm_items_in_comms_gauge);
}

if (optional_string("$Always show selected item in Comms Gauge:")) {
stuff_boolean(&Always_show_selected_item_in_comms_gauge);
}

optional_string("#SEXP SETTINGS");

if (optional_string("$Loop SEXPs Then Arguments:")) {
Expand Down Expand Up @@ -1941,6 +1946,7 @@ void mod_table_reset()
Use_new_scanning_behavior = false;
Lua_API_returns_nil_instead_of_invalid_object = false;
Dont_show_callsigns_in_escort_list = false;
Always_show_selected_item_in_comms_gauge = false;
Hide_main_rearm_items_in_comms_gauge = false;
Fix_scripted_velocity = false;
// These colors were taken from missionscreencommon.cpp line 591 which
Expand Down
1 change: 1 addition & 0 deletions code/mod_table/mod_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ extern bool Use_new_scanning_behavior;
extern bool Lua_API_returns_nil_instead_of_invalid_object;
extern bool Dont_show_callsigns_in_escort_list;
extern bool Hide_main_rearm_items_in_comms_gauge;
extern bool Always_show_selected_item_in_comms_gauge;
extern bool Fix_scripted_velocity;
extern color Overhead_line_colors[MAX_SHIP_SECONDARY_BANKS];
extern bool Preload_briefing_icon_models;
Expand Down