Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1121e4c67 |
@@ -21,4 +21,8 @@ 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;
|
||||
}
|
||||
@@ -20,6 +20,9 @@ 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 override bool ShouldLoad(EnumAppSide forSide) => forSide is EnumAppSide.Client;
|
||||
|
||||
public override void StartClientSide(ICoreClientAPI api)
|
||||
@@ -35,6 +38,24 @@ public class ChestPreviewModSystem : ModSystem
|
||||
|
||||
worldBillboardRenderer = new WorldBillboardRenderer(api, config, cardRenderer);
|
||||
api.Event.RegisterRenderer(worldBillboardRenderer, EnumRenderStage.AfterOIT, "chestpreview-world-billboard-preview");
|
||||
|
||||
api.Input.SetHotKeyHandler(
|
||||
hotkeyCode: PREVIEW_CONTAINERS_HOTKEY_CODE,
|
||||
keycomb =>
|
||||
{
|
||||
if (!config.TogglePreview) return false;
|
||||
this.PreviewToggleState = !this.PreviewToggleState;
|
||||
return true;
|
||||
});
|
||||
|
||||
api.Input.SetHotKeyHandler(
|
||||
hotkeyCode: PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE,
|
||||
keycomb =>
|
||||
{
|
||||
if (!config.TogglePreviewNearby) return false;
|
||||
this.PreviewNearbyToggleState = !this.PreviewNearbyToggleState;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
|
||||
@@ -24,6 +24,7 @@ internal partial class PreviewTargetProvider(ICoreClientAPI api, Config config)
|
||||
private readonly Config config = config;
|
||||
private readonly List<BlockEntity> nearbyContainerEntities = [];
|
||||
private float nearbyScanAccumulator;
|
||||
private Lazy<ChestPreviewModSystem> coreModSystem = new Lazy<ChestPreviewModSystem>(() => api.ModLoader.GetModSystem<ChestPreviewModSystem>());
|
||||
|
||||
public void CollectTargets(float deltaTime, List<PreviewTarget> targets)
|
||||
{
|
||||
@@ -83,13 +84,39 @@ internal partial class PreviewTargetProvider(ICoreClientAPI api, Config config)
|
||||
|
||||
private string GetActiveMode()
|
||||
{
|
||||
if (IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE))
|
||||
if (IsPreviewContainersNearbyActive())
|
||||
return PreviewModes.ON_NEARBY_CONTAINERS;
|
||||
|
||||
if (config.HoldKey && !IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_HOTKEY_CODE))
|
||||
return PreviewModes.NONE;
|
||||
return IsPreviewContainersActive() ? PreviewModes.Normalize(config.Mode) : PreviewModes.NONE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsHotkeyHeld(string hotkeyCode)
|
||||
|
||||
@@ -95,6 +95,20 @@
|
||||
"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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -10,5 +10,7 @@
|
||||
"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-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."
|
||||
}
|
||||
Reference in New Issue
Block a user