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

split out main menu code from studio #1813

Merged
merged 7 commits into from
Jan 22, 2022
Merged

Conversation

joshgoebel
Copy link
Collaborator

@joshgoebel joshgoebel commented Jan 16, 2022

This is the very beginning of my work to try and split the codebase up into smaller, more modular pieces. It follows our discussion about privacy and studio not having full access to core (even internally), etc... it seems to then follow that the menu menu shouldn't have full access to the huge impl struct that is essentially our entire application (that currently resides in studio)... also studio has tended to be a bit of a "catch all" file, so pulling out functionality into separate files would be good thing on it's own I feel.

This removes all menu menu related code from studio. It leaves all state management code in studio (impl.mode)... the things that main menu still needs access to:

  • tic_mem (pointer passed in init)
  • config (pointer passed in init) - this would not be necessary if we moved rwConfig to studio and just allowed access to that for consumers. We could also have headers for different privilege levels... so that you'd only include writes_config.h for things that needed r/w access to the config, etc.
  • menu, game_menu (pointers passed in init)
  • impl.gamepads (still extern impl for now)

For impl.gamepads we could copy a pointer as well or add an API for that... The mem access feels like something we could hide behind an API in the future (it's only used to get script: menu and for the menu callback), but I was trying to take things one step at a time.

Splitting out studio_impl.h was necessary to avoid a circular dependency in the header files.

The code in main_menu.c is 99% cut and paste from studio with just glue needed at the edges (initMainMenu, etc.) and to make the references to our internal state rather than the global studio impl object.


Commits:

  • slightly nicer start up stages
  • fewer allocations is better
  • Separate main menu from studio
  • isolate menu menu from studio a bit more
  • it is main menu really, not game menu

@joshgoebel joshgoebel marked this pull request as ready for review January 16, 2022 16:26
src/system/sdl/main.c Outdated Show resolved Hide resolved
src/studio/screens/main_menu.c Outdated Show resolved Hide resolved
@nesbox
Copy link
Owner

nesbox commented Jan 21, 2022

Can we merge your PR or are you going to make some other changes?

@joshgoebel
Copy link
Collaborator Author

Can we merge your PR or are you going to make some other changes?

It's good to go I think. I can make more PRs. Small PRs are good I think.

@nesbox nesbox merged commit 5cd503b into nesbox:main Jan 22, 2022
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