Skip to content

Conversation

CommandMC
Copy link
Collaborator

Invoking a method on one of the game managers was always a little verbose: Every method took not just its own parameters, but also parameters describing the game's state (effectively that's only an AppName right now, but that may change for other store providers). Instead, there's now one Game class instance for every distinct game in the user's library

In practice, code changes in the following way:
Before:

gameManagerMap[runner].foo(appName, arg1)
gameManagerMap[runner].bar(appName)
gameManagerMap[runner].baz(appName, arg1, arg2)

After:

const game = libraryManagerMap[runner].getGame(appName)
// NOTE: `game` could potentially be passed as a parameter instead of `appName` and `runner`, making the above line unnecessary
game.foo(arg1)
game.bar()
game.baz(arg1, arg2)

As I mentioned in #4889, I plan on offloading a lot of GameInfo properties into individual methods (so there's not as much a burden on game managers to provide everything in getGameInfo all at once). Increasing the amount of method calls quickly leads to our before approach (the current code) becoming unreadable due to there being so much duplicate work.

Requires #4889


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@CommandMC CommandMC requested a review from a team August 21, 2025 21:29
@CommandMC CommandMC self-assigned this Aug 21, 2025
@CommandMC CommandMC added the pr:ready-for-review Feature-complete, ready for the grind! :P label Aug 21, 2025
@CommandMC CommandMC requested review from Etaash-mathamsetty, Nocccer, arielj, biliesilva, flavioislima and imLinguin and removed request for a team August 21, 2025 21:29
Copy link
Collaborator

@arielj arielj left a comment

Choose a reason for hiding this comment

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

I like this to remove a lot of boilerplate, I left a comment to hopefully remove more

const { appName, runner } = currentElement.params
const { folder_name } = gameManagerMap[runner].getGameInfo(appName)
const { folder_name } = libraryManagerMap[runner]
.getGame(appName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we can have a helper getGame(runner, appName), because we do this libraryManagerMap[runner].getGame(appName) a looooot

that would also help decoupling how we get the store manager throughout the app, we wouldn't need to "know" that there's a libraryManagerMap hash

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that we do this a lot, but I'd like to resolve this a little differently (possibly in future PRs):

  • For everything in the Backend, pass around the Game instead of appName, runner
  • For calls from Frontend to Backend, I was thinking that we add something like a special "type" to our IPC wrappers that, if passed from FE to BE, automatically does the equivalent of getGame(appName, runner) and passes that Game to the actual listener/handler. Call it a GameHandle maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:ready-for-review Feature-complete, ready for the grind! :P

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants