Skip to content

Commit c181eb7

Browse files
committed
Implement slot toggle for gamepad
1 parent be8b3f2 commit c181eb7

4 files changed

Lines changed: 41 additions & 4 deletions

File tree

scripts/UI/InventoryGridData.reds

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class InventoryGridDataView extends BackpackDataView {
4141
this.m_viewManager.SetCollapsed(state);
4242
}
4343
44+
public func ToggleCollapsed() {
45+
this.m_viewManager.ToggleCollapsed();
46+
}
47+
4448
public func ToggleCollapsed(slotID: TweakDBID) {
4549
this.m_viewManager.ToggleCollapsed(slotID);
4650
}

scripts/UI/WardrobeScreen.reds

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ public class WardrobeScreenController extends inkPuppetPreviewGameController {
408408
}
409409
}
410410
411+
protected final func ShowGridButtonHints() {
412+
if this.m_player.PlayerLastUsedPad() && !this.m_isCursorOverManager && !this.m_isCursorOverPreview {
413+
this.m_buttonHints.AddButtonHint(n"world_map_menu_zoom_to_mappin", GetLocalizedText("LocKey#17809"));
414+
} else {
415+
this.m_buttonHints.RemoveButtonHint(n"world_map_menu_zoom_to_mappin");
416+
}
417+
}
418+
411419
protected cb func OnInventoryGridSlotClick(evt: ref<InventoryGridSlotClick>) {
412420
if evt.action.IsAction(n"click") {
413421
this.PlaySound(n"Button", n"OnPress");
@@ -516,6 +524,13 @@ public class WardrobeScreenController extends inkPuppetPreviewGameController {
516524
517525
evt.Consume();
518526
}
527+
528+
if !this.m_isCursorOverManager && !this.m_isCursorOverPreview
529+
&& this.m_player.PlayerLastUsedPad() && evt.IsAction(n"world_map_menu_zoom_to_mappin") {
530+
this.m_inventoryGridDataView.ToggleCollapsed();
531+
this.m_inventoryGridDataView.UpdateView();
532+
this.QueueScrollPositionRestore();
533+
}
519534
}
520535
521536
protected cb func OnGlobalHold(evt: ref<inkPointerEvent>) -> Bool {
@@ -528,6 +543,8 @@ public class WardrobeScreenController extends inkPuppetPreviewGameController {
528543
if evt.IsAction(n"right_stick_x") || evt.IsAction(n"right_stick_y") {
529544
this.m_inventoryScrollController.SetEnabled(!this.m_isCursorOverManager && !this.m_isCursorOverPreview);
530545
}
546+
547+
this.ShowGridButtonHints();
531548
}
532549
533550
protected cb func OnGlobalRelative(evt: ref<inkPointerEvent>) -> Bool {
@@ -538,6 +555,10 @@ public class WardrobeScreenController extends inkPuppetPreviewGameController {
538555
if this.m_isPreviewMouseHold && evt.IsAction(n"mouse_x") {
539556
this.RotatePreview(evt.GetAxisData(), 1.0, true);
540557
}
558+
559+
if evt.IsAction(n"mouse_x") || evt.IsAction(n"mouse_y") {
560+
this.ShowGridButtonHints();
561+
}
541562
}
542563
543564
protected func RotatePreview(offset: Float, speed: Float, opt clamp: Bool) {

scripts/ViewManager.reds

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public class ViewManager extends ScriptableSystem {
1717
this.m_state.SetCollapsed(slotID, state);
1818
}
1919
20-
public func ToggleCollapsed(slotID: TweakDBID) {
21-
this.m_state.ToggleCollapsed(slotID);
22-
}
23-
2420
public func SetCollapsed(state: Bool) {
2521
if state {
2622
let outfitSystem = OutfitSystem.GetInstance(this.GetGameInstance());
@@ -30,6 +26,18 @@ public class ViewManager extends ScriptableSystem {
3026
}
3127
}
3228
29+
public func ToggleCollapsed(slotID: TweakDBID) {
30+
this.m_state.ToggleCollapsed(slotID);
31+
}
32+
33+
public func ToggleCollapsed() {
34+
let outfitSystem = OutfitSystem.GetInstance(this.GetGameInstance());
35+
let outfitSlots = outfitSystem.GetOutfitSlots();
36+
let collapsedSlots = this.m_state.GetCollapsed();
37+
38+
this.SetCollapsed(ArraySize(outfitSlots) != ArraySize(collapsedSlots));
39+
}
40+
3341
public static func GetInstance(game: GameInstance) -> ref<ViewManager> {
3442
return GameInstance.GetScriptableSystemsContainer(game).Get(n"EquipmentEx.ViewManager") as ViewManager;
3543
}

scripts/ViewState.reds

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ module EquipmentEx
33
class ViewState {
44
private persistent let m_collapsedSlots: array<TweakDBID>;
55
6+
public func GetCollapsed() -> array<TweakDBID> {
7+
return this.m_collapsedSlots;
8+
}
9+
610
public func IsCollapsed(slotID: TweakDBID) -> Bool {
711
return ArrayContains(this.m_collapsedSlots, slotID);
812
}

0 commit comments

Comments
 (0)