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

Add standalone GameRunningModal #868

Merged
merged 1 commit into from
Nov 22, 2022
Merged

Conversation

anttimaki
Copy link
Collaborator

The modal was originally built in the navigation menu since that's where the games are launched from, but decoupling these two will hopefully make it easier to customize the NavigationMenu in different views and mod manager variants.

Since the modal and the NavigationMenu are no longer a direct parent- child relation, the status of modal visibity is stored in Vuex store. A separate store module was created for this purpose - the idea is that in the future it could be used to manage more modals than just the one it currently does.

isSteamGame = this.activeGame.activePlatform.storePlatform === StorePlatform.STEAM;

close() {
this.$store.commit('closeModals');
Copy link
Owner

Choose a reason for hiding this comment

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

Nit but can we rename this event to closeGameRunningModal
Feels like we shouldn't be closing all in one go and instead should close whichever has the priority overlay. (Thinking errors vs game running modals sharing the same event)

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, on the hindsight closing all modals at once doesn't sound that appealing. Renamed the commit name.


@Component
export default class GameRunningModal extends Vue {
activeGame = GameManager.activeGame;
Copy link
Owner

Choose a reason for hiding this comment

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

Does this change whenever the game is changed via settings?
As far as I'm aware it didn't and that's why binds are in created hooks instead, could be wrong though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does change, since the modal gets recreated/remounted every time the user travels to GameSelectionScreen and returns to Manager screen, and when it's created the value of activeGame has already been updated by other components. If we ever change it so the game can be reselected directly from the Manager screen, we probably need to rethink this as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also decouple the component entirely from the GameManager and simply pass in the active game name as a prop to the component. I'd feel most comfortable with that solution as there's less coupling that way.

isGameRunningModalOpen: boolean;
}

export default {
Copy link
Owner

Choose a reason for hiding this comment

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

Potentially nicer to be under `/src/store/modules/ModalsModule.ts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to subdir.

@anttimaki
Copy link
Collaborator Author

Btw should something be done about the Codacy code analysis failing? It says

It seems like the branch navigation-menu-refactor is not being analyzed. To review this pull request enable the branch in the repository settings.

Would this issue get automatically resolved once the earlier PR in the chain is merged and this points to develop branch?

@anttimaki anttimaki requested a review from ebkr November 21, 2022 11:02
Base automatically changed from navigation-menu-refactor to develop November 22, 2022 12:04
@ebkr ebkr closed this Nov 22, 2022
@MythicManiac MythicManiac reopened this Nov 22, 2022
Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

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

Seems good overall, but spotted a bug

await launch(this.activeGame, this.contextProfile!, mode);
} catch (error) {
if (error instanceof R2Error) {
this.gameRunning = false;
this.$store.commit("closeModals");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be calling closeGameRunningModal now that it was renamed


@Component
export default class GameRunningModal extends Vue {
activeGame = GameManager.activeGame;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also decouple the component entirely from the GameManager and simply pass in the active game name as a prop to the component. I'd feel most comfortable with that solution as there's less coupling that way.

The modal was originally built in the navigation menu since that's
where the games are launched from, but decoupling these two will
hopefully make it easier to customize the NavigationMenu in different
views and mod manager variants.

Since the modal and the NavigationMenu are no longer a direct parent-
child relation, the status of modal visibity is stored in Vuex store.
A separate store module was created for this purpose - the idea is that
in the future it could be used to manage more modals than just the one
it currently does.
Copy link
Collaborator

@MythicManiac MythicManiac left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@anttimaki anttimaki merged commit c38a44b into develop Nov 22, 2022
@MythicManiac MythicManiac deleted the standalone-game-running-modal branch November 22, 2022 12:48
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