Compare commits
5 Commits
v1.1.0
...
option-tog
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1121e4c67 | ||
| 79c6ed928a | |||
| b912a664e7 | |||
| b23345b273 | |||
| 1e20533f10 |
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"total": 73071,
|
"total": 75390,
|
||||||
"sessions": [
|
"sessions": [
|
||||||
{
|
{
|
||||||
"begin": "2026-03-11T23:50:47+01:00",
|
"begin": "2026-03-11T23:50:47+01:00",
|
||||||
@@ -70,6 +70,11 @@
|
|||||||
"begin": "2026-03-15T21:00:39+01:00",
|
"begin": "2026-03-15T21:00:39+01:00",
|
||||||
"end": "2026-03-15T23:04:35+01:00",
|
"end": "2026-03-15T23:04:35+01:00",
|
||||||
"duration": 7435
|
"duration": 7435
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "2026-03-28T03:48:55+01:00",
|
||||||
|
"end": "2026-03-28T04:27:34+01:00",
|
||||||
|
"duration": 2319
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ public sealed class Config
|
|||||||
|
|
||||||
public bool HoldKey { get; set; } = true;
|
public bool HoldKey { get; set; } = true;
|
||||||
|
|
||||||
|
public bool BillboardIgnoreFront { get; set; } = false;
|
||||||
|
|
||||||
public int BillboardColumnsPerBlock { get; set; } = 4;
|
public int BillboardColumnsPerBlock { get; set; } = 4;
|
||||||
|
|
||||||
public int ColumnsUnderCursor { get; set; } = 10;
|
public int ColumnsUnderCursor { get; set; } = 10;
|
||||||
@@ -19,4 +21,8 @@ public sealed class Config
|
|||||||
public string BlacklistedContainers { get; set; } = "";
|
public string BlacklistedContainers { get; set; } = "";
|
||||||
|
|
||||||
public bool GroundStorageOnlyContainers { get; set; } = true;
|
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 StorageHoverHudRenderer? storageHoverHudRenderer;
|
||||||
private WorldBillboardRenderer? worldBillboardRenderer;
|
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 bool ShouldLoad(EnumAppSide forSide) => forSide is EnumAppSide.Client;
|
||||||
|
|
||||||
public override void StartClientSide(ICoreClientAPI api)
|
public override void StartClientSide(ICoreClientAPI api)
|
||||||
@@ -35,6 +38,24 @@ public class ChestPreviewModSystem : ModSystem
|
|||||||
|
|
||||||
worldBillboardRenderer = new WorldBillboardRenderer(api, config, cardRenderer);
|
worldBillboardRenderer = new WorldBillboardRenderer(api, config, cardRenderer);
|
||||||
api.Event.RegisterRenderer(worldBillboardRenderer, EnumRenderStage.AfterOIT, "chestpreview-world-billboard-preview");
|
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()
|
public override void Dispose()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ internal partial class PreviewTargetProvider(ICoreClientAPI api, Config config)
|
|||||||
private readonly Config config = config;
|
private readonly Config config = config;
|
||||||
private readonly List<BlockEntity> nearbyContainerEntities = [];
|
private readonly List<BlockEntity> nearbyContainerEntities = [];
|
||||||
private float nearbyScanAccumulator;
|
private float nearbyScanAccumulator;
|
||||||
|
private Lazy<ChestPreviewModSystem> coreModSystem = new Lazy<ChestPreviewModSystem>(() => api.ModLoader.GetModSystem<ChestPreviewModSystem>());
|
||||||
|
|
||||||
public void CollectTargets(float deltaTime, List<PreviewTarget> targets)
|
public void CollectTargets(float deltaTime, List<PreviewTarget> targets)
|
||||||
{
|
{
|
||||||
@@ -83,13 +84,39 @@ internal partial class PreviewTargetProvider(ICoreClientAPI api, Config config)
|
|||||||
|
|
||||||
private string GetActiveMode()
|
private string GetActiveMode()
|
||||||
{
|
{
|
||||||
if (IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_NEARBY_HOTKEY_CODE))
|
if (IsPreviewContainersNearbyActive())
|
||||||
return PreviewModes.ON_NEARBY_CONTAINERS;
|
return PreviewModes.ON_NEARBY_CONTAINERS;
|
||||||
|
|
||||||
if (config.HoldKey && !IsHotkeyHeld(ChestPreviewModSystem.PREVIEW_CONTAINERS_HOTKEY_CODE))
|
return IsPreviewContainersActive() ? PreviewModes.Normalize(config.Mode) : PreviewModes.NONE;
|
||||||
return 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)
|
private bool IsHotkeyHeld(string hotkeyCode)
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ using Vintagestory.GameContent;
|
|||||||
|
|
||||||
namespace ChestPreview.Rendering;
|
namespace ChestPreview.Rendering;
|
||||||
|
|
||||||
internal class WorldBillboardPresenter(ICoreClientAPI api)
|
internal class WorldBillboardPresenter(ICoreClientAPI api, Config config)
|
||||||
{
|
{
|
||||||
private const int multiblock_scan_radius = 2;
|
private const int multiblock_scan_radius = 2;
|
||||||
private static readonly float front_face_offset = 0.05f;
|
private static readonly float front_face_offset = 0.05f;
|
||||||
|
|
||||||
private readonly ICoreClientAPI api = api;
|
private readonly ICoreClientAPI api = api;
|
||||||
|
private readonly Config config = config;
|
||||||
private readonly List<BillboardTarget> frameBillboards = [];
|
private readonly List<BillboardTarget> frameBillboards = [];
|
||||||
|
|
||||||
public IReadOnlyList<BillboardTarget> FrameBillboards => frameBillboards;
|
public IReadOnlyList<BillboardTarget> FrameBillboards => frameBillboards;
|
||||||
@@ -162,7 +163,7 @@ internal class WorldBillboardPresenter(ICoreClientAPI api)
|
|||||||
right = new Vec3f(1f, 0f, 0f);
|
right = new Vec3f(1f, 0f, 0f);
|
||||||
up = new Vec3f(0f, 1f, 0f);
|
up = new Vec3f(0f, 1f, 0f);
|
||||||
|
|
||||||
if (TryGetMeshAngle(blockEntity, out float meshAngleRadians))
|
if (!config.BillboardIgnoreFront && TryGetMeshAngle(blockEntity, out float meshAngleRadians))
|
||||||
{
|
{
|
||||||
// MeshAngle is around Y axis in radians.
|
// MeshAngle is around Y axis in radians.
|
||||||
forward = new Vec3f(MathF.Sin(meshAngleRadians), 0f, MathF.Cos(meshAngleRadians));
|
forward = new Vec3f(MathF.Sin(meshAngleRadians), 0f, MathF.Cos(meshAngleRadians));
|
||||||
@@ -171,7 +172,7 @@ internal class WorldBillboardPresenter(ICoreClientAPI api)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryGetBlockSideFacing(block, out forward))
|
if (!config.BillboardIgnoreFront && TryGetBlockSideFacing(block, out forward))
|
||||||
{
|
{
|
||||||
BuildBasisFromForward(forward, out right, out up);
|
BuildBasisFromForward(forward, out right, out up);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ internal class WorldBillboardRenderer(ICoreClientAPI api, Config config, CardRen
|
|||||||
private readonly List<PreviewTarget> frameTargets = [];
|
private readonly List<PreviewTarget> frameTargets = [];
|
||||||
private readonly CardRenderer cardRenderer = cardRenderer;
|
private readonly CardRenderer cardRenderer = cardRenderer;
|
||||||
private readonly PreviewTargetProvider targetProvider = new(api, config);
|
private readonly PreviewTargetProvider targetProvider = new(api, config);
|
||||||
private readonly WorldBillboardPresenter worldBillboardPresenter = new(api);
|
private readonly WorldBillboardPresenter worldBillboardPresenter = new(api, config);
|
||||||
private readonly MeshRef quadMeshRef = api.Render.UploadMesh(
|
private readonly MeshRef quadMeshRef = api.Render.UploadMesh(
|
||||||
QuadMeshUtil.GetCustomQuadModelData(
|
QuadMeshUtil.GetCustomQuadModelData(
|
||||||
1f,
|
1f,
|
||||||
|
|||||||
@@ -27,6 +27,13 @@
|
|||||||
"default": true,
|
"default": true,
|
||||||
"clientSide": true
|
"clientSide": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"code": "BillboardIgnoreFront",
|
||||||
|
"comment": "config-desc-BillboardIgnoreFront",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"clientSide": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"code": "BillboardColumnsPerBlock",
|
"code": "BillboardColumnsPerBlock",
|
||||||
"comment": "config-desc-BillboardColumnsPerBlock",
|
"comment": "config-desc-BillboardColumnsPerBlock",
|
||||||
@@ -88,6 +95,20 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"clientSide": 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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,14 @@
|
|||||||
"hotkey-preview-containers-nearby": "Preview containers nearby",
|
"hotkey-preview-containers-nearby": "Preview containers nearby",
|
||||||
"config-desc-Mode": "Preview mode. Valid values: None, UnderCursor, OnHoveredContainer, OnNearbyContainers.",
|
"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-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-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.",
|
"config-desc-ColumnsUnderCursor": "Columns in the UnderCursor mode.",
|
||||||
"config-desc-PreviewNearbyRadius": "Radius for \"Preview containers nearby\".",
|
"config-desc-PreviewNearbyRadius": "Radius for \"Preview containers nearby\".",
|
||||||
"config-desc-WhitelistedContainersOnly": "If true, only container codes in WhitelistedContainers are handled.",
|
"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-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-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."
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
"OrekiWoof"
|
"OrekiWoof"
|
||||||
],
|
],
|
||||||
"description": "see containers' contents without having to open them",
|
"description": "see containers' contents without having to open them",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"game": "1.21.0"
|
"game": "1.21.0"
|
||||||
},
|
},
|
||||||
|
|||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 OrekiWoof
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
Reference in New Issue
Block a user