Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
CtInfo: Add Button to Mark Compat Tool as Global #336
base: main
Are you sure you want to change the base?
CtInfo: Add Button to Mark Compat Tool as Global #336
Changes from 7 commits
83537b1
6e8cbdf
5236d50
98dc0ec
cbd2318
03cd5c3
b2ded73
5aad7b8
618083e
5b0793a
6fd4d26
9f7c1c2
02fd807
24061ce
05fb631
08849b7
922f9cf
c1fa092
6394f9b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I wonder if we should disable the button after clicking because there currently is no visual feedback of the event.
That could be as simple as
self.btnMarkGlobal.setEnabled(false)
. We would need to add another check in the constructor so that the user won't click the button if it is already global.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.
Oh that's a good idea!
There's no reason to click this button again after marking a tool as global, at least not in the context of the currently open dialog.
An edge case could be opening two ctinfo dialogs at once, say GE-Proton9-7 and Luxtorpeda (just to have distinct examples). This is extremely unlikely to ever happen and could be alleviated with other behaviour, it's not a reason against implementing this button disabling but an outline of a potential problem scenario (although again, I really don't think anyone would do this if they weren't trying to break something)
A big way to alleviate this being a problem is the confirmation dialog noted earlier, because it would vastly reduce the likelihood of accidentally setting a tool as global.
There's also the possibility of closing the dialog which could be seen as expected since it's on the bottom row of the dialog buttons, but perhaps also not.
Disabling the button makes sense to me, I'll add it when I get home. I'm not sure if we want to close dialogs after a tool is marked as global, it might be a little jarring.
I also had a thought, I don't remember what happens if a tool is marked as global and then the game list is refreshed. If we get the "tool is global" text like if the user closed and re-opened the dialog, maybe the button also gets hidden, which I think is good too.
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.
Oh, actually it seems like we don't hide the Mark Global button when the games list is refreshed.
We check if we should display the Mark Global button when loading the ctinfo dialog with
self.ui.btnMarkGlobal.setVisible(self.is_mark_global_available)
, perhaps we should also call this inupdate_game_list_ui
?I'm thinking we should rework the logic like this:
btnMarkGlobal.setVisible
call fromsetup_ui
.setup_ui
callsupdate_game_list
(updates launcher-specific UI elements) which in turn callsupdate_game_list_ui
(handles generic non-launcher-specific UI elements)update_game_list_ui
we can call check if the Mark Global button should be displayed usingself.ui.btnMarkGlobal.setVisible(self.is_mark_global_available)
(since we may want to display this for other launchers, andis_mark_global_available
will handle checking if Mark Global is available for the current launcher anyway)a. Right now the logic is only set if the current launcher is Steam, but with the recent refactor, we can call this generically and call this regardless of our current launcher, because
is_mark_global_available
is responsible for checking if the current launcher supports this actionself.ui.btnMarkGlobal.clicked.connect
action to connect the button logic fromupdate_game_list
toupdate_game_list_ui
a. Similar to above, this is also nested in a Steam-specific launcher check, but calling it from
update_game_list_ui
means we can connect this action regardless of launcher. Then the only thing we need to care about is ifis_mark_global_available
is True or False, and we don't need to care about knowing whether or not the launcher should support it, that's taken care of by the call tois_mark_global_available
.set_launcher_global_tool
to return a success booleanset_launcher_global_tool
to actually updateis_mark_global_available
, like this:self.is_mark_global_available = set_launcher_global_tool(self.install_loc, self.ctool)
. We could I guess hardcodeself.is_mark_global_available = False
but that would assumeset_launcher_global_tool
will always succeed. Ifset_launcher_global_tool
fails, this approach means we will update the value correctly.a. We could simply leave
set_launcher_global_tool
unchanged and instead make another call like this:self.is_mark_global_available = is_mark_global_available(self.install_loc, self.ctool)
to achieve the same thing. The approach here is more stylistic preference, although I think personally makingset_launcher_global_tool
return a success boolean is a bit cleaner.is_mark_global_available
and our existing call tobtn_refresh_games_clicked
will handle running all the checks again for whether or not the Mark Global button should be displayed, using the same refactored logic described above that we would use when the dialog opens.Basically we move the logic to set whether the button is visible or not into
update_game_list_ui
, meaning we will update it regardless of launcher, becauseis_mark_global_available
performs a launcher check for us. Then when we mark a tool as global, we update the value ofself.is_mark_global_available
. Finally our existing call to refresh the game list elements means we will pick up any changes tois_mark_global_available
and show/hide the button.The reason showing and hiding may be better is because we show/hide the button when the dialog opens.
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.
The reference to
self.ctool
is updated when the refresh button is clicked. This meansself.ctool.is_global
is stillFalse
. So when the tool is marked as global, or when the refresh button is generally clicked (i.e. if the global Steam compat tool was updated externally while the CtInfo dialog was open, and the refresh button was pressed after that) the dialog does not updated to reflect that the tool is global.So if GE-Proton9-7's CtInfo dialog is open, and the global compat tool in
config.vdf
is updated to be GE-Proton9-7, pressing the refresh button will not show/hide the Mark Global button, and it will not update the game list to display "Tool is Global".However, it does update the compat tool list on the Main Menu to display
(global)
because the compat tool name!And re-opening the dialog of course works as expected.
I'm not sure how to fix this one, it is a bit of an edge-case and at worst something we can update in a later PR.