Skip to content

Commit

Permalink
group InputAction sections by Plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rune580 committed Jan 13, 2024
1 parent ec69719 commit 6f332db
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
53 changes: 29 additions & 24 deletions LethalCompanyInputUtils/Components/RemapContainerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,38 +140,43 @@ private void GenerateApiSections()
{
if (bindsList is null || sectionList is null)
return;

var pluginGroupedActions = LcInputActionApi.InputActions.GroupBy(lc => lc.Plugin.Name);

foreach (var lcInputActions in LcInputActionApi.InputActions)
foreach (var pluginActions in pluginGroupedActions)
{
if (lcInputActions.Loaded)
continue;

bindsList.AddSection(lcInputActions.Plugin.Name);
sectionList.AddSection(lcInputActions.Plugin.Name);
bindsList.AddSection(pluginActions.Key);
sectionList.AddSection(pluginActions.Key);

foreach (var actionRef in lcInputActions.ActionRefs)
foreach (var lcInputAction in pluginActions)
{
var controlName = actionRef.action.bindings.First().name;
var kbmKey = new RemappableKey
if (lcInputAction.Loaded)
continue;

foreach (var actionRef in lcInputAction.ActionRefs)
{
ControlName = controlName,
currentInput = actionRef,
rebindingIndex = 0,
gamepadOnly = false
};
var controlName = actionRef.action.bindings.First().name;
var kbmKey = new RemappableKey
{
ControlName = controlName,
currentInput = actionRef,
rebindingIndex = 0,
gamepadOnly = false
};

var gamepadKey = new RemappableKey
{
ControlName = controlName,
currentInput = actionRef,
rebindingIndex = 1,
gamepadOnly = true
};
var gamepadKey = new RemappableKey
{
ControlName = controlName,
currentInput = actionRef,
rebindingIndex = 1,
gamepadOnly = true
};

bindsList.AddBinds(kbmKey, gamepadKey);
}
bindsList.AddBinds(kbmKey, gamepadKey);
}

lcInputActions.Loaded = true;
lcInputAction.Loaded = true;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions LethalCompanyInputUtils/LcInputActionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class LcInputActionApi

internal static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values;

// Try and find any controls that were manually injected into the UI.
internal static void LoadIntoUI(KepRemapPanel panel)
{
AdjustSizeAndPos(panel);
Expand Down

0 comments on commit 6f332db

Please sign in to comment.