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

Population Menu - Distribution Lists Optimisation #260

Open
Hop311 opened this issue Sep 4, 2024 · 0 comments
Open

Population Menu - Distribution Lists Optimisation #260

Hop311 opened this issue Sep 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Hop311
Copy link
Contributor

Hop311 commented Sep 4, 2024

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'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.

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.

@Hop311 Hop311 changed the title Population menu Population Menu - Distribution Lists Optimisation Sep 4, 2024
@Hop311 Hop311 added the enhancement New feature or request label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant