hotkeys for toggles / simplify toggling mechanics
This commit is contained in:
22
.timetracker
22
.timetracker
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"total": 78654,
|
||||
"total": 85508,
|
||||
"sessions": [
|
||||
{
|
||||
"begin": "2026-03-11T23:50:47+01:00",
|
||||
@@ -115,6 +115,26 @@
|
||||
"begin": "2026-05-22T19:13:27+02:00",
|
||||
"end": "2026-05-22T19:21:36+02:00",
|
||||
"duration": 489
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T19:22:06+02:00",
|
||||
"end": "2026-05-22T19:47:51+02:00",
|
||||
"duration": 1545
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T20:11:03+02:00",
|
||||
"end": "2026-05-22T20:42:49+02:00",
|
||||
"duration": 1906
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-23T00:13:03+02:00",
|
||||
"end": "2026-05-23T00:33:04+02:00",
|
||||
"duration": 1201
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-23T00:34:04+02:00",
|
||||
"end": "2026-05-23T01:10:47+02:00",
|
||||
"duration": 2202
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,8 +4,6 @@ public sealed class Config
|
||||
{
|
||||
public string Mode { get; set; } = PreviewModes.UNDER_CURSOR;
|
||||
|
||||
public bool HoldKey { get; set; } = true;
|
||||
|
||||
public bool BillboardIgnoreFront { get; set; } = false;
|
||||
|
||||
public int BillboardColumnsPerBlock { get; set; } = 4;
|
||||
@@ -21,8 +19,4 @@ public sealed class Config
|
||||
public string BlacklistedContainers { get; set; } = "";
|
||||
|
||||
public bool GroundStorageOnlyContainers { get; set; } = true;
|
||||
|
||||
public bool TogglePreview { get; set; } = false;
|
||||
|
||||
public bool TogglePreviewNearby { get; set; } = false;
|
||||
}
|
||||
@@ -13,6 +13,8 @@ public class ChestPreviewModSystem : ModSystem
|
||||
internal const string CONFIGLIB_DOMAIN = "chestpreview";
|
||||
internal const string PREVIEW_CONTAINERS_HOTKEY_CODE = "chestpreview-preview-containers";
|
||||
internal const string PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE = "chestpreview-preview-containers-nearby";
|
||||
internal const string TOGGLE_PREVIEW_CONTAINERS_HOTKEY_CODE = "chestpreview-preview-containers-toggle";
|
||||
internal const string TOGGLE_PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE = "chestpreview-preview-containers-nearby-toggle";
|
||||
|
||||
private Config config = new();
|
||||
private CardRenderer? cardRenderer;
|
||||
@@ -20,8 +22,8 @@ public class ChestPreviewModSystem : ModSystem
|
||||
private StorageHoverHudRenderer? storageHoverHudRenderer;
|
||||
private WorldBillboardRenderer? worldBillboardRenderer;
|
||||
|
||||
public bool PreviewNearbyToggleState { get; private set; } = false;
|
||||
public bool PreviewToggleState { get; private set; } = false;
|
||||
public bool PreviewNearbyToggleActive { get; private set; } = false;
|
||||
public bool PreviewToggleActive { get; private set; } = false;
|
||||
|
||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide is EnumAppSide.Client;
|
||||
|
||||
@@ -40,20 +42,18 @@ public class ChestPreviewModSystem : ModSystem
|
||||
api.Event.RegisterRenderer(worldBillboardRenderer, EnumRenderStage.AfterOIT, "chestpreview-world-billboard-preview");
|
||||
|
||||
api.Input.SetHotKeyHandler(
|
||||
hotkeyCode: PREVIEW_CONTAINERS_HOTKEY_CODE,
|
||||
hotkeyCode: TOGGLE_PREVIEW_CONTAINERS_HOTKEY_CODE,
|
||||
keycomb =>
|
||||
{
|
||||
if (!config.TogglePreview) return false;
|
||||
this.PreviewToggleState = !this.PreviewToggleState;
|
||||
PreviewToggleActive = !PreviewToggleActive;
|
||||
return true;
|
||||
});
|
||||
|
||||
api.Input.SetHotKeyHandler(
|
||||
hotkeyCode: PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE,
|
||||
hotkeyCode: TOGGLE_PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE,
|
||||
keycomb =>
|
||||
{
|
||||
if (!config.TogglePreviewNearby) return false;
|
||||
this.PreviewNearbyToggleState = !this.PreviewNearbyToggleState;
|
||||
PreviewNearbyToggleActive = !PreviewNearbyToggleActive;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -128,5 +128,23 @@ public class ChestPreviewModSystem : ModSystem
|
||||
altPressed: false,
|
||||
ctrlPressed: true,
|
||||
shiftPressed: false);
|
||||
|
||||
api.Input.RegisterHotKey(
|
||||
hotkeyCode: TOGGLE_PREVIEW_CONTAINERS_HOTKEY_CODE,
|
||||
name: Lang.Get("chestpreview:hotkey-preview-container-toggle"),
|
||||
key: GlKeys.Unknown,
|
||||
type: HotkeyType.HelpAndOverlays,
|
||||
altPressed: false,
|
||||
ctrlPressed: false,
|
||||
shiftPressed: false);
|
||||
|
||||
api.Input.RegisterHotKey(
|
||||
hotkeyCode: TOGGLE_PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE,
|
||||
name: Lang.Get("chestpreview:hotkey-preview-containers-nearby-toggle"),
|
||||
key: GlKeys.Unknown,
|
||||
type: HotkeyType.HelpAndOverlays,
|
||||
altPressed: false,
|
||||
ctrlPressed: false,
|
||||
shiftPressed: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,39 +84,16 @@ internal partial class PreviewTargetProvider(ICoreClientAPI api, Config config)
|
||||
|
||||
private string GetActiveMode()
|
||||
{
|
||||
if (IsPreviewContainersNearbyActive())
|
||||
var previewKeyHeld = IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_HOTKEY_CODE);
|
||||
var previewNearbyKeyHeld = IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE);
|
||||
|
||||
if (coreModSystem.Value.PreviewNearbyToggleActive || previewNearbyKeyHeld)
|
||||
return PreviewModes.ON_NEARBY_CONTAINERS;
|
||||
|
||||
return IsPreviewContainersActive() ? PreviewModes.Normalize(config.Mode) : PreviewModes.NONE;
|
||||
}
|
||||
if (coreModSystem.Value.PreviewToggleActive || previewKeyHeld)
|
||||
return PreviewModes.Normalize(config.Mode);
|
||||
|
||||
private bool IsPreviewContainersNearbyActive()
|
||||
{
|
||||
if (config.TogglePreviewNearby)
|
||||
{
|
||||
return coreModSystem.Value.PreviewNearbyToggleState;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPreviewContainersActive()
|
||||
{
|
||||
if (config.TogglePreview)
|
||||
{
|
||||
return coreModSystem.Value.PreviewToggleState;
|
||||
}
|
||||
else if (config.HoldKey)
|
||||
{
|
||||
return IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_HOTKEY_CODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Always
|
||||
return true;
|
||||
}
|
||||
return PreviewModes.NONE;
|
||||
}
|
||||
|
||||
private bool IsHotkeyHeld(string hotkeyCode)
|
||||
|
||||
@@ -20,13 +20,6 @@
|
||||
],
|
||||
"clientSide": true
|
||||
},
|
||||
{
|
||||
"code": "HoldKey",
|
||||
"comment": "config-desc-HoldKey",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"clientSide": true
|
||||
},
|
||||
{
|
||||
"code": "BillboardIgnoreFront",
|
||||
"comment": "config-desc-BillboardIgnoreFront",
|
||||
@@ -95,20 +88,6 @@
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"clientSide": true
|
||||
},
|
||||
{
|
||||
"code": "TogglePreview",
|
||||
"comment": "config-desc-TogglePreview",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"clientSide": true
|
||||
},
|
||||
{
|
||||
"code": "TogglePreviewNearby",
|
||||
"comment": "config-desc-TogglePreviewNearby",
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"clientSide": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"hotkey-preview-container": "Preview container",
|
||||
"hotkey-preview-containers-nearby": "Preview containers nearby",
|
||||
"hotkey-preview-container-toggle": "Toggle preview container",
|
||||
"hotkey-preview-containers-nearby-toggle": "Toggle preview on containers nearby",
|
||||
"config-desc-Mode": "Preview mode. Valid values: None, UnderCursor, OnHoveredContainer, OnNearbyContainers.",
|
||||
"config-desc-HoldKey": "Previews only show while the \"Preview containers\" key is held.",
|
||||
"config-desc-BillboardIgnoreFront": "With this set to false, in-world previews show on the front side of containers. By setting this to true, the previews show on the side determined to be most visible.",
|
||||
"config-desc-BillboardColumnsPerBlock": "Columns per block width used for world billboards. For containers 2 blocks wide it's doubled.",
|
||||
"config-desc-ColumnsUnderCursor": "Columns in the UnderCursor mode.",
|
||||
@@ -10,7 +11,5 @@
|
||||
"config-desc-WhitelistedContainersOnly": "If true, only container codes in WhitelistedContainers are handled.",
|
||||
"config-desc-GroundStorageOnlyContainers": "If true, groundstorage previews only appear when the stored item has its own inventory (for example bags/backpacks).",
|
||||
"config-desc-WhitelistedContainers": "Allowed container codes, separated by comma, semicolon, or spaces. No effectif WhitelistedContainersOnly==false.",
|
||||
"config-desc-BlacklistedContainers": "Blocked container codes, separated by comma, semicolon, or spaces.",
|
||||
"config-desc-TogglePreview": "If true, \"Preview container\" is toggled on/off with the key instead of being held. HoldKey will be ignored.",
|
||||
"config-desc-TogglePreviewNearby": "If true, \"Preview containers nearby\" is toggled on/off with the key instead of being held. Note: Toggle may not work with modifier-only key combinations (e.g. Ctrl+Shift). You might need to reassign the hotkey."
|
||||
"config-desc-BlacklistedContainers": "Blocked container codes, separated by comma, semicolon, or spaces."
|
||||
}
|
||||
Reference in New Issue
Block a user