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

Status table 'scroll to' malfunctions with hidden sides #4029

Open
Konrad22 opened this issue Apr 17, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@Konrad22
Copy link
Contributor

commented Apr 17, 2019

(I'm talking about this thing in the status table.)
Using 'scroll to' for side 2 does nothing and using 'scroll to' for side n > 2 scrolls to side n - 1.
HttT-The Sceptre of Fire-Auto-Save1.gz

@jostephd jostephd added Campaign and removed Engine labels May 7, 2019

@jostephd

This comment has been minimized.

Copy link
Member

commented May 7, 2019

Probably because of this part:

{VARIABLE_OP side_kill rand "2..3"}
{ERASE_CASTLE $side_kill Uu}
[kill]
side=$side_kill
[/kill]
[modify_side]
side=$side_kill
hidden=yes
[/modify_side]
{CLEAR_VARIABLE side_kill}

I can reproduce it in S1 with:

diff --git a/data/campaigns/Heir_To_The_Throne/scenarios/01_The_Elves_Besieged.cfg b/data/campaigns/Heir_To_The_Throne/scenarios/01_The_Elves_Besieged.cfg
index 805f25cc679..34c018280bb 100644
--- a/data/campaigns/Heir_To_The_Throne/scenarios/01_The_Elves_Besieged.cfg
+++ b/data/campaigns/Heir_To_The_Throne/scenarios/01_The_Elves_Besieged.cfg
@@ -25,6 +25,10 @@
 
     [event]
         name=prestart
+        [modify_side]
+            side=5
+            hidden=yes
+        [/modify_side]
         {VARIABLE besieged_enemies_killed 0}
         {NEED_DELFADOR (x,y=19,23)}
         [objectives]

@jostephd jostephd added Engine and removed Campaign labels May 7, 2019

@jostephd jostephd changed the title HttT - S17, 'scroll to' seems to be malfunctionating Status table 'scroll to' malfunctions with hidden sides May 7, 2019

@jostephd

This comment has been minimized.

Copy link
Member

commented May 7, 2019

Okay, it's pretty simple.

wesnoth/src/menu_events.cpp

Lines 162 to 164 in 74c1f20

int selected_index;
if(gui2::dialogs::game_stats::execute(board(), gui_->viewing_team(), selected_index)) {

game_stats(const display_context& board, const int viewing_team, int& selected_index);

selected_index_ = find_widget<listbox>(&window, list_id, false).get_selected_row();

gui_->scroll_to_leader(teams()[selected_index].side());

selected_index is passed by reference. game_stats sets it to a row index into the table, but menu_events interprets it as an index into the teams() vector, which doesn't work because the row index doesn't count hidden teams. The easiest fix is probably to make game_stats return a reference to the team. (Note that "Scroll To" is the "OK" button of that dialog.)

@jostephd jostephd added this to the 1.14.9 milestone May 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.