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

Feat/view event and names #5974

Merged
merged 7 commits into from
Nov 22, 2024

Conversation

mwerle
Copy link
Contributor

@mwerle mwerle commented Nov 18, 2024

This PR is a proposal to be discussed prior to merge.

The first couple of commits fix a few outstanding compiler warnings (gcc/Linux).

The next commit merges PiGuiView into View, as suggested by @Web-eWorks. I moved this commit ahead as it is preparatory work for the next commit, and could be used as-is even without the actual features of this PR.

The first "real" commit sanitized the various view names, both between all the views, as well as between the C++ side and the Lua side. Perhaps there is a good reason to have a different name between the Lua and the C++ side, but if there is, it escapes me. Personally I find the proposed naming to be much more self-documenting as well as easier to find and it reduces overloading of some of the strings which were used in multiple places with different meanings.

C++:

  • "sector-view" -> "SectorView"
  • "system-view" -> "SystemView"
  • new: "DeathView"
  • new: "SettingsView"

Lua:

  • "world", -> WorldView
  • "space_station", -> StationView
  • "info", -> InfoView
  • "sector", -> SectorView
  • "system", -> SystemView
  • "death", -> DeathView
  • "settings" -> SettingsView

This is the only change which I think needs discussing as I'm not sure if this change is valid/wanted. (I think it makes sense, but I may not have all the relevant background information..)

Following this renaming, I added "previous" and "new" view names to the onViewChanged event.

Finally, the new onViewChanged parameters are used in the "radar" module to improve the way the input frame is added and removed, as previously discussed here : #5958 (comment)

Reorder initializers in constructor to fix compiler warning.
A distance variable was not initialized which led to a compiler warning.
In a worst-case scenario, this could also lead to indeterminate behaviour
when calculating distances to a bound.
@sturnclaw
Copy link
Member

sturnclaw commented Nov 19, 2024

No complaints here - this is a generally good change, my only nitpick is that we don't actually have a SettingsView and that name isn't used anywhere.

You could take it one step further in fact, and merge all of PiGuiView into the View class - PiGuiView was only separate for incremental migration of screens which used the legacy Old/NewUI systems (circa 2020) and is not intended as a permanent thing.

Remove an unused variable in CityOnPlanet.
Merge the functionality from PiGuiView into the base-class View and
remove the now obsolete PiGuiView.

This is in preparation of refactoring the View names and simplifying how
the Lua side accesses Views.
@mwerle mwerle force-pushed the feat/view_event_and_names branch from cea0b81 to a35da43 Compare November 19, 2024 08:10
@mwerle
Copy link
Contributor Author

mwerle commented Nov 19, 2024

No complaints here - this is a generally good change, my only nitpick is that we don't actually have a SettingsView and that name isn't used anywhere.

Hmm, literally replaced what was there to match the new naming - perhaps it was a leftover from previous refactors.. I should've checked a bit closer.

Ok, killed PiGuiView and cleaned up the commits a little bit. "Works for me" but YMMV..

@mwerle mwerle marked this pull request as ready for review November 19, 2024 08:13
Make all string representations of the views follow the same pattern, and
give views which did not have a name a name.

Following this, use that string representation in the Lua side as well
instead of using a separate string. This allows for unique and easy
referencing of views across the entire codebsae using 'grep' or
Visual Studio Code's search function.

This also allowed for some simplification of getting/setting views.
Use the new 'onViewChanged' event parameters to only add/remove the radar
input frame if the view changes to/from "WorldView".
@mwerle mwerle force-pushed the feat/view_event_and_names branch from a35da43 to 68b5b4c Compare November 19, 2024 08:21
@sturnclaw sturnclaw self-requested a review November 21, 2024 07:50
Copy link
Member

@sturnclaw sturnclaw left a comment

Choose a reason for hiding this comment

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

Good work, thanks for tackling this! I'm glad to reduce the bug surface when it comes to identifying views between C++ and Lua. Overall it looks good and I don't see any fixup commits in the commit list, so this is getting merged!

@sturnclaw sturnclaw merged commit e2bf87f into pioneerspacesim:master Nov 22, 2024
4 checks passed
@mwerle mwerle deleted the feat/view_event_and_names branch November 23, 2024 23:35
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.

2 participants