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
Tile inspector element type #13134
Tile inspector element type #13134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rebase and do two things:
- Drop the merge commit
- Fold the other commits into a single one, named:
Close #12444: Refactor TILE_INSPECTOR_PAGE to use strong enum
Here's a page explaiing it: https://github.com/OpenRCT2/OpenRCT2/wiki/Rebase-and-Sync-fork-with-OpenRCT2
You'll also need to fix the formatting issues pointed out by the CI
This would go in contrast to every other window. I don't think we should make this change. |
The i.e. in Cheats.cpp it is used to get the value from a lookup table, which contains only four entries, TileInspectorPage containing 10. This seems to be a reoccurring pattern in OpenRCT2, since there are a lot of union types already defined in Window_internal.h I assume this is what @duncanspumpkin meant - please correct me if I am wrong. |
The problem is that every window type has its own number of pages/tabs. If we use an enum class for each of them we will need a union of every window type page type. This would be annoying to use. Alternatively we could make a generic enum class for pages 1-X and have aliases that translate a page specific name to an enum class page number. But then it's not really giving us anything useful protection wise. I think we need to ask ourselves what are we trying to achieve and what does the final product look like. What do we want developers not to do and what do we want them to do. Off the top of my head we want to reduce macro usage to reduce name pollution. Reduce enum usage to reduce name pollution and allow for strong typing. Reduce code duplication. Prevent setting pages that don't exist. We have talked for a while about moving windows to individual classes and that will give us more tools to tackle this sort of thing but we still need to think about what the end goal should be. |
Pages could be lists of widgets in a vector stored with the window. Page indices or IDs are not needed, if you want to access a specific page, a pointer to the item in the vector could be used instead (which can be stored separately for better naming, of course). |
Some thoughts:
This is from a first time contributor to this project, so I am very much aware that all of this has been talked about by people who have much more knowledge about this project already and I just could not find it. |
Currently the big unions in window_internal are for accessing variables that should be private variables of the window if it was turned into class. In general writing to the page variable is done only from the specific window. Reading of the page value is also generally from the specific window but is at times also read in other locations. I'm not really suggesting anything here just writing down thoughts. |
Well we do need a consensus or a general direction at some point for the PR to be merged/closed ahahah |
First of all, sorry for getting back to this after a while.
I'm very convinced about that too. The union will look ugly, but decoupling will be nice when we have windows split up. I'm ok with merging this, are you @duncanspumpkin ? (If so, we'll need merge conflicts to be resolved @amdoku ) |
okay but please keep in mind this is not the end goal |
Decoupling is not the end goal? I thought ultimately we wanted a polymorphic window infra |
I meant that the union we have isn't the end goal. |
I know (?), for me it's a means to an end, we get a big ugly union but then we slowly move the corresponding variable to its actual window class. |
No problem. Discussions take time. I'll try to find time around new years eve. |
should fix #12444
introduced a convenience method to typesafe convert from the enum class to the underlying integer type, as the enum is used quite a lot as a lookup value for tables.