Skip to content

Commit dcb1feb

Browse files
committed
Handle remapped button patch reversion and button release action separately.
We were previously using the `downButtons` to undo the patch, but since the logic had been (intentionally) changed to apply the patch even when not starting a continuous-activation cycle (i.e. due to `!Context.IsPlayerFree`), the patch wasn't always getting undone when the button was released. The new logic checks both states separately, and undoes the patch if the button is physically up, regardless of whether it was tracked. Also adds a custom activation action to end fishing, which seems to help with a few hard-to-identify edge cases where the default `pressToolButton` logic behaves oddly, either failing to clear the menu or doing a duplicate cast or "catching" the wrong fish/item.
1 parent 149b46c commit dcb1feb

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

StarControl/Menus/InventoryMenuItem.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ ItemActivationType activationType
7171
}
7272
who.CurrentToolIndex = who.Items.IndexOf(tool);
7373
}
74-
if (tool is not MeleeWeapon)
74+
if (tool is FishingRod rod && rod.fishCaught)
75+
{
76+
rod.doneHoldingFish(who);
77+
return ItemActivationResult.Used;
78+
}
79+
else if (tool is not MeleeWeapon)
7580
{
7681
who.FireTool();
7782
}

StarControl/Menus/RemappingController.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,22 @@ public void Update(TimeSpan elapsed, bool isMenuActive)
6666
{
6767
var controllerButton = button.TryGetController(out var cb) ? cb : default;
6868
var buttonState = inputHelper.GetState(button);
69-
if (downButtons.Contains(button))
69+
var wasButtonDown = downButtons.Contains(button);
70+
var wasPatched = InputPatches.ToolUseButton == controllerButton;
71+
if (wasButtonDown || wasPatched)
7072
{
71-
if (
73+
var isButtonUp =
7274
!inputHelper.IsSuppressed(button)
73-
&& buttonState is SButtonState.Released or SButtonState.None
74-
)
75+
&& buttonState is SButtonState.Released or SButtonState.None;
76+
// We have to release the simulated tool button as soon as the remapped button
77+
// is released, because some tools won't allow release until *after* they detect
78+
// that the tool button is released.
79+
if (wasPatched && isButtonUp)
80+
{
81+
InputPatches.ToolUseButton = null;
82+
}
83+
if (wasButtonDown && isButtonUp)
7584
{
76-
// We have to release the simulated tool button as soon as the remapped button
77-
// is released, because some tools won't allow release until *after* they detect
78-
// that the tool button is released.
79-
if (InputPatches.ToolUseButton == controllerButton)
80-
{
81-
InputPatches.ToolUseButton = null;
82-
}
8385
if (item.EndActivation())
8486
{
8587
downButtons.Remove(button);

0 commit comments

Comments
 (0)