You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the lists next to each of the 6 large pie charts in the Population Menu generate a row for each item, regardless of how many are visible at once, which can cause lag spikes when the lists have many items.
Solution
In PopulationMenu.gdscript, only generate at most as many rows as are visible at once, using GUIListBox's set_fixed(item_count, item_height) and get_fixed_visible_items() functions to find the number of rows to generate, and connecting its scroll_index_changed signal to a function that updates the rows' contents based on the current scroll level.
This will also require changes in MenuSingleton.hpp and PopulationMenu.cpp, replacing get_population_menu_distribution_info with a function that returns just the visible row data for a single distribution (similar to get_population_menu_pop_rows) and adding a function to get the total number of rows for a single distribution (similar to get_population_menu_pop_row_count).
It may be useful to create an enum with values for the 6 distributions to use for arguments that choose which distribution's rows or total row count you want to get. You can make enums accesible to GDScript by registering the type with VARIANT_ENUM_CAST at the bottom of MenuSingleton.hpp and registering the individual values with BIND_ENUM_CONSTANT in MenuSingleton.cpp's _bind_methods function.
Problem
Currently the lists next to each of the 6 large pie charts in the Population Menu generate a row for each item, regardless of how many are visible at once, which can cause lag spikes when the lists have many items.
Solution
In PopulationMenu.gdscript, only generate at most as many rows as are visible at once, using
GUIListBox
'sset_fixed(item_count, item_height)
andget_fixed_visible_items()
functions to find the number of rows to generate, and connecting itsscroll_index_changed
signal to a function that updates the rows' contents based on the current scroll level.This will also require changes in MenuSingleton.hpp and PopulationMenu.cpp, replacing
get_population_menu_distribution_info
with a function that returns just the visible row data for a single distribution (similar toget_population_menu_pop_rows
) and adding a function to get the total number of rows for a single distribution (similar toget_population_menu_pop_row_count
).It may be useful to create an enum with values for the 6 distributions to use for arguments that choose which distribution's rows or total row count you want to get. You can make enums accesible to GDScript by registering the type with
VARIANT_ENUM_CAST
at the bottom of MenuSingleton.hpp and registering the individual values withBIND_ENUM_CONSTANT
in MenuSingleton.cpp's_bind_methods
function.SearchPanel.gdscript (and it's corresponding C++ code in MenuSingleton.hpp and MenuSingleton.cpp) provides a similar example for limiting the number of search result rows generated.
The text was updated successfully, but these errors were encountered: