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

UnitTable: show a summary when no unit is selected #12832

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sulai
Copy link
Contributor

@sulai sulai commented Jan 19, 2025

Changes

  • When nothing is selected, show idle and waiting units, together with the cycle buttons
  • allows to start cycling anytime with the arrow buttons and the shortcuts ,.
  • Refactor UnitTable to have separate Presenters for units, cities, spies and no selection.
  • at the cost of making private tables internal in order to populate them from the Presenters

grafik

…s any time. Refactor UnitTable to have separate Presenters for units, cities, spies and no selection.
@sulai
Copy link
Contributor Author

sulai commented Jan 19, 2025

UnitTable mixes logic, UI and data, which is not ideal, but it also handled all different entities in one class. I separated out the Presenters for units, cities, spies and non-selection, so it is easier to extend and work with now. It's not perfect though, because it still mixes logic, UI and data, but I didn't want to rewrite everything at the risk of breaking things.

@yairm210
Copy link
Owner

Separating "presenters" -> Fantastic 👍🏿
I don't like the with{} and let{} but as a temporary measure for separation I'm fine with it

@sulai
Copy link
Contributor Author

sulai commented Jan 19, 2025

I checked the occurrences of with(unitTable) { }, I use them because unitTable is referenced almost every line:

Most instances look like this without with {}
grafik

I could replace it with unitTable.apply { } though if you like?

selectedUnitIsSwapping = false
selectedUnitIsConnectingRoad = false
}
var shouldUpdate = false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yairm210 do you think we could remove shouldUpdate, which was previously called selectedUnitHasChanged?

The in-code comment says:

// This is so that not on every update(), we will update the unit table.
// Most of the time it's the same unit with the same stats so why waste precious time?

This mechanism has almost no effect (anymore), because UnitTable.update() isn't called frequently. It would make the code a bit more concise, even though it currently also works with shouldUpdate in place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants