mirror of
https://github.com/mleem97/gregWiki.git
synced 2026-04-11 03:29:19 +02:00
update: docs to new architecture
This commit is contained in:
@@ -5,7 +5,7 @@ sidebar_label: FMF.HexLabelMod
|
||||
|
||||
<!-- markdownlint-disable MD060 -->
|
||||
|
||||
[`gregModHexLabelMod`](https://github.com/mleem97/gregModHexLabelMod) (assembly `FMF.HexLabelMod.dll`)
|
||||
[`gregModHexLabelMod`](https://github.com/mleem97/gregModHexLabelMod) — pure Lua mod powered by gregCore
|
||||
|
||||
## Release
|
||||
|
||||
@@ -16,36 +16,64 @@ sidebar_label: FMF.HexLabelMod
|
||||
|
||||
## Purpose
|
||||
|
||||
Standalone MelonLoader mod for **Data Center** that overlays the hex color code of each `CableSpinner` and `Rack` directly in-world, so you can identify cable and rack colors at a glance without opening any menu.
|
||||
Overlays the hex color code (`#RRGGBB`) of each `CableSpinner` and `Rack` directly in-world in **Data Center**, so you can identify cable and rack colors at a glance. Includes an IMGUI HUD (top-right) with crosshair-aimed color detection and a full hex viewer (F2).
|
||||
|
||||
Rewritten from the former root `HexLabelMod` for the FrikaModdingFramework workflow, now running fully standalone.
|
||||
## Architecture (v00.02+)
|
||||
|
||||
Since v00.02, HexLabel is a **pure Lua mod**. The C# assembly (`FMF.HexLabelMod.dll`) is a thin MelonLoader bootstrap that provides metadata only. All mod logic lives in `lua/hexlabel/main.lua` and uses the `greg.*` API provided by gregCore's Lua runtime.
|
||||
|
||||
### gregCore APIs used
|
||||
|
||||
| API | Purpose |
|
||||
|-----|---------|
|
||||
| `greg.unity.find("CableSpinner")` | Find all spinner objects in scene |
|
||||
| `greg.unity.find("Rack")` | Find all rack objects in scene |
|
||||
| `greg.unity.get_string(h, "rgbColor")` | Read spinner color property |
|
||||
| `greg.unity.material_hex(h, "_BaseColor")` | Read material hex color |
|
||||
| `greg.unity.instantiate(h, parent)` | Clone source TMPro label for spinner |
|
||||
| `greg.unity.tmpro_set(...)` | Configure cloned TMPro label text/size/color |
|
||||
| `greg.unity.create_gameobject(name, parent)` | Create rack label container |
|
||||
| `greg.unity.add_component(h, "TextMesh")` | Add world-space TextMesh to rack |
|
||||
| `greg.unity.textmesh_set(...)` | Configure rack label |
|
||||
| `greg.unity.raycast(...)` / `camera_ray()` | HUD crosshair aim detection |
|
||||
| `greg.unity.get_parent_component(h, type)` | Resolve aimed object type |
|
||||
| `greg.hook.after(hookName, fn)` | Hook CableSpinner.Start for instant labeling |
|
||||
| `greg.config.load(path)` | Load `hexposition.cfg` |
|
||||
| `greg.input.key_pressed("F2")` | Toggle hex viewer |
|
||||
| `greg.gui.*` | IMGUI HUD and viewer window |
|
||||
| `greg.io.read_head(path, n)` | Steam log scanning for startup gating |
|
||||
|
||||
### Project structure
|
||||
|
||||
```text
|
||||
gregMod.HexLabelMod/
|
||||
├── lua/hexlabel/main.lua ← All mod logic (pure Lua, ~300 lines)
|
||||
├── Main.cs ← Thin C# bootstrap (metadata only)
|
||||
├── FMF.HexLabelMod.csproj ← Build config
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
| Dependency | Notes |
|
||||
| --- | --- |
|
||||
| [MelonLoader](https://melonwiki.xyz/) | With generated IL2CPP assemblies |
|
||||
|
||||
This mod runs standalone and does **not** require FMF runtime APIs.
|
||||
| **gregCore** | Provides Lua runtime and `greg.*` API |
|
||||
|
||||
## Installation
|
||||
|
||||
1. **Recommended:** Subscribe on the [Steam Workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=3701404621), or download `FMF.HexLabelMod.dll` from the [latest GitHub release](https://github.com/mleem97/gregModHexLabelMod/releases/latest).
|
||||
2. If you use a manual DLL, drop `FMF.HexLabelMod.dll` into your `Mods/` folder.
|
||||
3. Launch the game — the config file is created automatically on first run at:
|
||||
|
||||
```text
|
||||
UserData/hexposition.cfg
|
||||
```
|
||||
1. Ensure **gregCore** is installed and up to date.
|
||||
2. Copy `lua/hexlabel/` to `Mods/ScriptMods/lua/hexlabel/`.
|
||||
3. Optionally place `FMF.HexLabelMod.dll` in `Mods/` (for MelonLoader metadata).
|
||||
4. Launch the game — the config file is created automatically on first run.
|
||||
|
||||
## Configuration
|
||||
|
||||
Edit `UserData/hexposition.cfg` to adjust label positioning and font sizes. The file is auto-generated with defaults on first launch and regenerated if any keys are missing.
|
||||
Edit `UserData/hexposition.cfg` to adjust label positioning and font sizes. The file is auto-generated with defaults on first launch.
|
||||
|
||||
```ini
|
||||
# Hex Label Position Config
|
||||
# File: UserData/hexposition.cfg
|
||||
# Edit values, then restart game.
|
||||
|
||||
# Spinner (UI text near cable spool)
|
||||
spinner_offset_x=0
|
||||
@@ -79,32 +107,24 @@ rack_scale=1
|
||||
| `rack_character_size` | float | `0.05` | Character size for the world-space `TextMesh` label |
|
||||
| `rack_scale` | float | `1` | Uniform world-space scale of the rack label object |
|
||||
|
||||
## Live Reload *(restricted)*
|
||||
|
||||
Pressing **Ctrl+F1** toggles live config reload (6-second interval), allowing you to tune label positions without restarting the game. This feature is restricted to a specific Steam account and will silently do nothing for all other users.
|
||||
|
||||
## Build
|
||||
|
||||
```powershell
|
||||
dotnet build .\gregModHexLabelMod\FMF.HexLabelMod.csproj
|
||||
```
|
||||
|
||||
Output lands in the standard MelonLoader `Mods/` folder as configured in the `.csproj`.
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Startup** — The mod defers full initialization until MelonLoader's `Latest.log` confirms the Steam runtime is ready (SteamID or Steam marker detected).
|
||||
2. **Spinner labels** — Every `CableSpinner` gets a cloned `TextMeshProUGUI` label injected into its UI hierarchy, displaying the resolved hex code in white. Color is read from `rgbColor`, then from the `_BaseColor`/`_Color` material property as fallback.
|
||||
3. **Rack labels** — Every `Rack` gets a world-space `TextMesh` label positioned at its back-right-bottom corner, facing away from the rack front.
|
||||
4. **Scan loop** — Active spinners and racks are re-checked every 1.5 seconds to catch newly spawned objects.
|
||||
5. **Harmony patch** — `CableSpinner.Start` is patched to inject the label immediately on spawn, before the first scan cycle runs.
|
||||
1. **Startup** — The Lua script defers initialization until MelonLoader's `Latest.log` confirms the Steam runtime is ready (scans via `greg.io.read_head`).
|
||||
2. **Spinner labels** — For each `CableSpinner`, the script clones the source `TextMeshProUGUI` label via `greg.unity.instantiate()` and configures it with the resolved hex code using `greg.unity.tmpro_set()`.
|
||||
3. **Rack labels** — For each `Rack`, a new `TextMesh` component is created via `greg.unity.create_gameobject()` + `greg.unity.add_component()` and positioned at the rack.
|
||||
4. **Scan loop** — Active spinners and racks are re-checked every 1.5 seconds; deep refresh every 10 seconds.
|
||||
5. **Harmony hook** — `greg.hook.after()` subscribes to `CableSpinner.Start` to label new spinners immediately on spawn.
|
||||
6. **HUD** — IMGUI overlay drawn via `greg.gui.*` in `on_gui()`, showing crosshair-aimed hex color detected via `greg.unity.raycast()`.
|
||||
7. **Hex viewer** — F2 toggles a full-screen color list collected from scene CableSpinners.
|
||||
|
||||
## Notes
|
||||
## Migration from v00.01
|
||||
|
||||
- Original gameplay behavior is unaffected.
|
||||
- Source lives in the split repo [`gregModHexLabelMod`](https://github.com/mleem97/gregModHexLabelMod), not under a legacy `mods/` tree.
|
||||
- The config file is fully rewritten if any expected keys are missing (for example, after an update adds new keys).
|
||||
- FMF assembly presence is no longer required as a startup gate.
|
||||
If upgrading from the standalone C# version:
|
||||
|
||||
1. Remove the old `FMF.HexLabelMod.dll` (or keep it — the new version is just a bootstrap stub).
|
||||
2. Install gregCore.
|
||||
3. Deploy `lua/hexlabel/main.lua` to `Mods/ScriptMods/lua/hexlabel/`.
|
||||
4. Your `hexposition.cfg` is fully compatible.
|
||||
|
||||
## Sources
|
||||
|
||||
|
||||
Reference in New Issue
Block a user