-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Nautilus compatibility for GameInput keybinds #2663
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
Open
JackNytely
wants to merge
9
commits into
SubnauticaNitrox:master
Choose a base branch
from
JackNytely:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bf6c7f9
feat: Nautilus compatibility for GameInput keybinds
JackNytely 18e71aa
Fix Release build: copy dependencies to lib/ instead of moving
JackNytely e589582
Merge remote-tracking branch 'upstream/master'
JackNytely 743bbf5
Simplified reflection use in GameInputSystem_Initialize_Patch
Measurity cb6d14f
fix: stop extending Enum.GetValues(GameInput.Button) to avoid duplica…
JackNytely 4098923
Merge branch 'master' of https://github.com/JackNytely/Nitrox
JackNytely ed1ba8f
Merge remote-tracking branch 'upstream/master'
JackNytely 3b956de
Fix server shutdown hanging and keybind rebinding being non-functional
JackNytely 1eb300b
STAGE
JackNytely File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,21 +87,13 @@ | |
| Condition="!Exists('$(OutputDirectory)')" | ||
| ContinueOnError="WarnAndContinue" /> | ||
|
|
||
| <!-- Copy in debug because some systems break when they don't use our assembly resolve to look inside lib folder --> | ||
| <!-- Copy (don't Move) so dependencies stay in output root. Some code paths load assemblies before/when AssemblyResolve runs or from contexts that don't use it (e.g. Release vs Debug), causing empty UI or missing types when DLLs are only in lib/. --> | ||
| <Copy SourceFiles="@(FilesToMove)" | ||
| DestinationFolder="$(OutputDirectory)" | ||
| OverwriteReadOnlyFiles="True" | ||
| SkipUnchangedFiles="True" | ||
| Retries="3" | ||
| RetryDelayMilliseconds="100" | ||
| Condition="'$(Configuration)' == 'Debug'" | ||
| ContinueOnError="ErrorAndContinue" /> | ||
|
|
||
| <!-- Move every matching files to OutputDirectory --> | ||
| <Move SourceFiles="@(FilesToMove)" | ||
| DestinationFolder="$(OutputDirectory)" | ||
| OverwriteReadOnlyFiles="True" | ||
| Condition="'$(Configuration)' == 'Release'" | ||
| ContinueOnError="ErrorAndContinue" /> | ||
|
Comment on lines
+90
to
97
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intended behavior. Avalonia doesn't use our |
||
| </Target> | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,25 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
| using NitroxClient.MonoBehaviours.Gui.Input; | ||
|
|
||
| namespace NitroxPatcher.Patches.Persistent; | ||
|
|
||
| /// <summary> | ||
| /// Specific patch for GameInput.Button enum to return also our own values. | ||
| /// Patch for GameInput.Button enum. Nitrox buttons are not added here to avoid duplicate keybinds in the input settings: | ||
| /// the game builds the binding list from both Enum.GetValues(GameInput.Button) and GameInput.AllActions when they differ. | ||
| /// We extend AllActions in GameInputSystem_Initialize_Patch instead, so the binding UI gets Nitrox keys from that single source. | ||
| /// </summary> | ||
| public partial class Enum_GetValues_Patch : NitroxPatch, IPersistentPatch | ||
| { | ||
| private static readonly MethodInfo TARGET_METHOD = Reflect.Method(() => Enum.GetValues(default)); | ||
|
|
||
| public static void Postfix(Type enumType, ref Array __result) | ||
| { | ||
| // Intentionally do not extend __result with Nitrox buttons. They are added via GameInput.AllActions | ||
| // in GameInputSystem_Initialize_Patch so the settings UI shows each keybind once. | ||
| if (enumType != typeof(GameInput.Button)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| GameInput.Button[] result = | ||
| [ | ||
| .. __result.Cast<GameInput.Button>(), | ||
| .. Enumerable.Range(KeyBindingManager.NITROX_BASE_ID, KeyBindingManager.KeyBindings.Count).Cast<GameInput.Button>() | ||
| ]; | ||
|
|
||
| __result = result; | ||
| // Leave __result unchanged (original enum values only). | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Thanks for improving this code. Added in #2674 in case your PR stays unmerged for a while.