forked from OrekiWoof/ChestPreview
Compare commits
2 Commits
b1121e4c67
...
option-tog
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e835998390 | ||
| 8bf4735da7 |
42
.timetracker
42
.timetracker
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"total": 75390,
|
||||
"total": 78654,
|
||||
"sessions": [
|
||||
{
|
||||
"begin": "2026-03-11T23:50:47+01:00",
|
||||
@@ -75,6 +75,46 @@
|
||||
"begin": "2026-03-28T03:48:55+01:00",
|
||||
"end": "2026-03-28T04:27:34+01:00",
|
||||
"duration": 2319
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T17:40:18+02:00",
|
||||
"end": "2026-05-22T18:03:45+02:00",
|
||||
"duration": 1406
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T18:30:12+02:00",
|
||||
"end": "2026-05-22T18:34:35+02:00",
|
||||
"duration": 262
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T18:34:49+02:00",
|
||||
"end": "2026-05-22T18:38:39+02:00",
|
||||
"duration": 229
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T18:38:55+02:00",
|
||||
"end": "2026-05-22T18:39:22+02:00",
|
||||
"duration": 27
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T18:58:35+02:00",
|
||||
"end": "2026-05-22T19:03:47+02:00",
|
||||
"duration": 311
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T19:03:52+02:00",
|
||||
"end": "2026-05-22T19:05:29+02:00",
|
||||
"duration": 96
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T19:05:33+02:00",
|
||||
"end": "2026-05-22T19:12:57+02:00",
|
||||
"duration": 444
|
||||
},
|
||||
{
|
||||
"begin": "2026-05-22T19:13:27+02:00",
|
||||
"end": "2026-05-22T19:21:36+02:00",
|
||||
"duration": 489
|
||||
}
|
||||
]
|
||||
}
|
||||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@@ -4,9 +4,9 @@
|
||||
{
|
||||
"label": "check env",
|
||||
"type": "shell",
|
||||
"command": "[ -n \"$VINTAGE_STORY\" ] || { echo 'ERROR: VINTAGE_STORY is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA\" ] || { echo 'ERROR: VINTAGE_STORY_DATA is not set'; exit 1; }",
|
||||
"command": "if [ \"${input:buildConfig}\" = \"Version22\" ]; then [ -n \"$VINTAGE_STORY_22\" ] || { echo 'ERROR: VINTAGE_STORY_22 is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA_22\" ] || { echo 'ERROR: VINTAGE_STORY_DATA_22 is not set'; exit 1; }; else [ -n \"$VINTAGE_STORY_21\" ] || { echo 'ERROR: VINTAGE_STORY_21 is not set'; exit 1; }; [ -n \"$VINTAGE_STORY_DATA_21\" ] || { echo 'ERROR: VINTAGE_STORY_DATA_21 is not set'; exit 1; }; fi",
|
||||
"windows": {
|
||||
"command": "if (-not $env:VINTAGE_STORY) { Write-Host 'ERROR: VINTAGE_STORY is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA) { Write-Host 'ERROR: VINTAGE_STORY_DATA is not set'; exit 1 }"
|
||||
"command": "if ('${input:buildConfig}' -eq 'Version22') { if (-not $env:VINTAGE_STORY_22) { Write-Host 'ERROR: VINTAGE_STORY_22 is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA_22) { Write-Host 'ERROR: VINTAGE_STORY_DATA_22 is not set'; exit 1 } } else { if (-not $env:VINTAGE_STORY_21) { Write-Host 'ERROR: VINTAGE_STORY_21 is not set'; exit 1 }; if (-not $env:VINTAGE_STORY_DATA_21) { Write-Host 'ERROR: VINTAGE_STORY_DATA_21 is not set'; exit 1 } }"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<OutputPath>bin\$(Configuration)\Mods\mod</OutputPath>
|
||||
<Nullable>enable</Nullable>
|
||||
<Configurations>Debug;Release;Version22</Configurations>
|
||||
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
|
||||
<VINTAGE_STORY_DATA>$(VINTAGE_STORY_DATA_21)</VINTAGE_STORY_DATA>
|
||||
<VS_CONFIGLIB Condition="'$(VS_CONFIGLIB)' == ''">$([System.Environment]::GetEnvironmentVariable('VS_CONFIGLIB'))</VS_CONFIGLIB>
|
||||
<ConfigLibAvailable Condition="'$(VS_CONFIGLIB)' != '' and Exists('$(VS_CONFIGLIB)')">true</ConfigLibAvailable>
|
||||
<DefineConstants Condition="'$(ConfigLibAvailable)' == 'true'">$(DefineConstants);CONFIGLIB</DefineConstants>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -90,11 +90,25 @@
|
||||
"clientSide": true
|
||||
},
|
||||
{
|
||||
"code": "GroundStorageOnlyContainers",
|
||||
"comment": "config-desc-GroundStorageOnlyContainers",
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"clientSide": true
|
||||
"code": "GroundStorageOnlyContainers",
|
||||
"comment": "config-desc-GroundStorageOnlyContainers",
|
||||
"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."
|
||||
}
|
||||
@@ -4,10 +4,15 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
|
||||
<Configurations>Debug;Release;Version22</Configurations>
|
||||
<VINTAGE_STORY>$(VINTAGE_STORY_21)</VINTAGE_STORY>
|
||||
<VS_CONFIGLIB Condition="'$(VS_CONFIGLIB)' == ''">$([System.Environment]::GetEnvironmentVariable('VS_CONFIGLIB'))</VS_CONFIGLIB>
|
||||
<ConfigLibAvailable Condition="'$(VS_CONFIGLIB)' != '' and Exists('$(VS_CONFIGLIB)')">true</ConfigLibAvailable>
|
||||
<DefineConstants Condition="'$(ConfigLibAvailable)' == 'true'">$(DefineConstants);CONFIGLIB</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Version22'">
|
||||
<VINTAGE_STORY>$(VINTAGE_STORY_22)</VINTAGE_STORY>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cake.Frosting" Version="5.0.0" />
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
### Required env vars
|
||||
|
||||
- `VINTAGE_STORY`: path to the 1.21 game install (on Windows default is %appdata%/VintageStory)
|
||||
- `VINTAGE_STORY_DATA`: path to the 1.21 game data directory (on Windows default is %appdata%/VintageStoryData)
|
||||
- `VINTAGE_STORY_21`: path to the 1.21 game install (on Windows default is %appdata%/VintageStory)
|
||||
- `VINTAGE_STORY_DATA_21`: path to the 1.21 game data directory (on Windows default is %appdata%/VintageStoryData)
|
||||
- `VINTAGE_STORY_22`: for 1.22 (`Version22` configuration)
|
||||
- `VINTAGE_STORY_DATA_22`: for 1.22 (`Version22` configuration)
|
||||
- `VS_CONFIGLIB`: path to `configlib.dll`. If not set, will compile with a warning and without configlib support
|
||||
|
||||
Reference in New Issue
Block a user