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

GameScope: Refactor GSARR indexing #1028

Merged
merged 2 commits into from
Jan 27, 2024
Merged

Conversation

sonic2kk
Copy link
Owner

This PR refactors how we parse and index GSARR in GameScopeGui. Previously we were hardcoding each index, and this was brittle. When we added a new element, everything had to get shifted down by one. This PR uses a "relative positioning" system, where everything indexed relative to the index of the heading above it. We calculate heading positions using a hardcoded number of elements per section.

If we want to add a new element to, say, the HDR section, we can do it much more simply now. All we have to do is bump GSHDROPTSLEN by 1, and then add the element in. To position the element we can calculate its index based on its number in the section (i.e. if it's the 5th section, then it'll be GSFILTERINGHEADING + 5). If a new element is inserted into the middle of a section, we only need to re-organise the indexes in that section and not the whole list. Instead of changing all 60+ lines for how we parse the GameScope variables out of GSARR, we only need to change a few lines. At worst if something went at the top of the section, we would only need to update the indexes for the variables in that section (as well as the variable tracking the length of the section, since this is used to position the other headings).

It is much easier to format things this way, and having the variable tracking the length of each section is also a good way for us to check our work and make sure each section is the correct and expected length.


In testing, this seems to work with existing and fresh GameScope configurations. Everything is parsed correctly from existing configs, even complex ones like GAMESCOPE_ARGS="-w 1920 -h 1080 -W 3840 -H 2160 -r 144 -f --force-grab-cursor -s 7 -F fsr -S stretch -m 3 --fsr-sharpness 8 -C 5 --rt --". I will do more testing though and if this works fine, I will bump the version and merge.

@sonic2kk
Copy link
Owner Author

This seems to work fine. I think we can merge this as-is after a version bump. Tried a couple of games (Cookie Clicker, NieR:Automata) and they work. The new Mouse Sensitivity option also still works.

@sonic2kk
Copy link
Owner Author

sonic2kk commented Jan 27, 2024

ShellCheck is green and version is bumped, works in testing as noted, this is ready to merge!

Let us hope it doesn't result in disaster 😅

@sonic2kk sonic2kk merged commit 3affaf7 into master Jan 27, 2024
@sonic2kk sonic2kk deleted the gamescope-gsarr-refactor branch January 27, 2024 05:17
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.

None yet

1 participant