Skip to content

Commit

Permalink
Merge pull request #7 from HubertLipinski/feature/controller-support
Browse files Browse the repository at this point in the history
feat: Controller support
  • Loading branch information
HubertLipinski authored Sep 19, 2024
2 parents 854387a + 7808811 commit 0190f35
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ QOL Inventory mod for Core Keeper.

This mod provides a better experience when moving items from hotbar, inventory and chest storages.

<img src="https://i.imgur.com/BK5eDXM.gif" width="66%" height="66%" />
<img src="img/demo.gif" width="75%" alt="demonstration"/>

---

## Usage

Press `LShift` and click on item you want to move. The selected item will be moved to next available inventory/hotbar or chest slot.
Press `ModifierKey` and click on item you want to move. The selected item will be moved to next available inventory/hotbar or chest slot.

### ModifierKey
- Keyboard: ``LShift``
- Controller: ``R2 / Right trigger``

> **Default ``ModifierKey`` can be changed in the settings menu.**
>
> ![img.png](img/settings.png)
<br/>

---

## Feedback

If You have any feedback or You have found a bug, feel free to create an [issue.](https://github.com/HubertLipinski/ShiftClick/issues/new/choose)
If You have any feedback, or You have found a bug, feel free to create an [issue.](https://github.com/HubertLipinski/ShiftClick/issues/new/choose)


4 changes: 3 additions & 1 deletion ShiftClick.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"Unity.Physics.Hybrid",
"Unity.Properties",
"Unity.Transforms",
"PugMod.SDK"
"PugMod.SDK",
"CoreLib",
"CoreLib.RewiredExtension"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
24 changes: 21 additions & 3 deletions ShiftClick.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
using System.Linq;
using CoreLib;
using CoreLib.RewiredExtension;
using PugMod;
using Rewired;
using UnityEngine;
using System.Linq;

public class ShiftClick : IMod
{
private const string Version = "1.2.0";
private const string Name = "ShiftClick";
private const string Author = "Trolxu";

private const string KeyBindName = "ShiftClickModifier";
private const string KeyBindDescription = "[ShitClick] Key modifier";

private readonly ObjectType[] _ignoredItemTypes =
{
ObjectType.Helm,
Expand All @@ -19,11 +29,15 @@ public class ShiftClick : IMod

public void EarlyInit()
{
Debug.Log($"[{Name}]: Version: {Version}, Author: {Author}");
CoreLibMod.LoadModules(typeof(RewiredExtensionModule));
RewiredExtensionModule.AddKeybind(KeyBindName, KeyBindDescription, KeyboardKeyCode.LeftShift);
RewiredExtensionModule.SetDefaultControllerBinding(KeyBindName, GamepadTemplate.elementId_rightTrigger);
}

public void Init()
{
Debug.Log("[ShiftClick] initialized!");
Debug.Log($"[{Name}]: initialized!");
}

public void ModObjectLoaded(Object obj)
Expand All @@ -40,8 +54,12 @@ public void Update()
return;

PlayerController player = Manager.main.player;
PlayerInput input = Manager.input.singleplayerInputModule;

bool modifierKeyHeldDown = input.IsButtonCurrentlyDown((PlayerInput.InputType)RewiredExtensionModule.GetKeybindId(KeyBindName));
bool interactedWithUI = input.rewiredPlayer.GetButtonDown((int)PlayerInput.InputType.UI_INTERACT);

if (Input.GetKey(KeyCode.LeftShift) && Input.GetKeyDown(KeyCode.Mouse0))
if (modifierKeyHeldDown && interactedWithUI)
{
HandleInventoryChange(player);
}
Expand Down
Binary file added img/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0190f35

Please sign in to comment.