Map: per-track industry labels rendered via Dear ImGui on both the popout and in-game overlay. Three zoom stages - per-track labels, merged same-name clusters, and one-per-industry labels at wider zoom. Settings: font size (min/max with zoom scaling), leader lines, parallel rotation, collision spread, utility track filters (repair/diesel/loader/interchange), zoom thresholds per category. C# runs a world-space AABB solver at rebuild so offsets are rotation-invariant; native runs a per-frame screen-space fine-tuning pass and draws leader lines. Mesh LOD: new module skeleton with 4-level LOD group injected on HandleModelsLoaded - three progressive renderer cull tiers (sorted by bounds volume) plus a 12-tri proxy box at max distance. lodBias-corrected distance-to-screenHeight conversion. Debounced live refresh on settings change. Disabled by default.
92 lines
5 KiB
C#
92 lines
5 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace S3.Modules.Popout;
|
|
|
|
// Flat settings block for the Map Popout module (own file: S3.popout.json).
|
|
// Hotkey is stored as flat primitives rather than a UMM KeyBinding so JsonUtility
|
|
// round-trips it reliably (no nested custom-class serialization).
|
|
// customTheme is a [Serializable] struct — JsonUtility inlines value-type structs
|
|
// correctly (unlike nested classes, which Mono silently drops).
|
|
[Serializable]
|
|
public class PopoutSettings
|
|
{
|
|
public bool enabled = false;
|
|
|
|
// UMM modifier bitmask: 1=Shift, 2=Ctrl, 4=Alt. Default: F9, no modifier.
|
|
public int hotkeyModifiers = 0;
|
|
public int hotkeyKeyCode = (int)KeyCode.F9;
|
|
|
|
// When true, dragging the map cancels follow modes (MapEnhancer follow +
|
|
// follow-player) so the drag takes over — like grab-to-pan in Google Maps.
|
|
public bool panDisablesFollow = true;
|
|
|
|
// Active theme index (0-4 = named preset, 5 = Custom).
|
|
// See MapTheme enum in MapThemes.cs.
|
|
public int mapTheme = 0;
|
|
|
|
// In-game overlay chrome (window + toolbar + compass) alpha [0.1, 1.0].
|
|
public float overlayAlpha = 1.0f;
|
|
|
|
// In-game overlay map image alpha [0.0, 1.0]. Independent of chrome alpha.
|
|
public float overlayMapAlpha = 1.0f;
|
|
|
|
// Map camera clear-colour opacity [0.0, 1.0]. At 0 the void/sky areas of the
|
|
// map are transparent, letting the game world show through in empty regions.
|
|
public float overlayMapBgAlpha = 1.0f;
|
|
|
|
// When true, right-clicking anywhere on the map image recenters on the player.
|
|
public bool rightClickRecenter = true;
|
|
|
|
// --- Icon culling ---
|
|
// When the map is zoomed out past iconCullingThreshold (NormalizedScale 0=close, 1=far),
|
|
// non-locomotive car icons are hidden to reduce Canvas draw calls.
|
|
public bool iconCullingEnabled = true;
|
|
public float iconCullingThreshold = 0.40f;
|
|
// When culling is active, hide MU trailing units (locos with another loco on their A-end).
|
|
public bool hideMuLocos = true;
|
|
// Scale multiplier applied to visible loco icons when culling is active.
|
|
public float locoBoostedScale = 1.5f;
|
|
// Show a blinking red dot on the map at the rear end of each train (EOTD).
|
|
public bool eotdEnabled = true;
|
|
// Hide the EOTD when car icons are visible (i.e. zoom is inside the cull threshold).
|
|
public bool eotdOnlyWhenCulled = true;
|
|
// Dot size: 1 (tiny) to 10 (large). Applied as orthographicSize * value * 0.002.
|
|
public float eotdSizeScale = 8f;
|
|
|
|
// Track name labels — shown on the map at each industry track, hidden when zoomed out.
|
|
public bool trackLabelsEnabled = true;
|
|
public float trackLabelFontSize = 12f; // px; range 8-32
|
|
public float trackLabelLineThickness = 1.5f; // px; range 1-4
|
|
public float trackLabelZoomLimit = 200f; // orthographicSize beyond which labels hide
|
|
public bool trackLeaderLinesEnabled = true; // draw lines from label to each track anchor
|
|
public bool trackCollisionEnabled = true; // spread overlapping labels apart
|
|
public bool trackLabelParallel = false; // rotate labels parallel to their track
|
|
public bool trackLabelMergeEnabled = true; // merge same-name nearby spans into one label
|
|
public float trackLabelMergeZoom = 150f; // auto-merge when orthographicSize exceeds this
|
|
public float trackIndustryLabelZoom = 200f; // Stage 3: show industry labels beyond this zoom
|
|
// Utility track filters — per-type visibility toggle + shared zoom limit.
|
|
// Interchange tracks are also name-normalized (strip " to <Business>" suffix).
|
|
public bool trackUtilityRepairEnabled = true;
|
|
public bool trackUtilityDieselEnabled = true;
|
|
public bool trackUtilityLoaderEnabled = true;
|
|
public bool trackUtilityInterchangeEnabled = true;
|
|
public float trackUtilityZoomLimit = 200f; // utility tracks hide before this zoom
|
|
public float trackAllLabelsZoomLimit = 8000f; // all labels (incl. industry) hide beyond this zoom
|
|
public bool trackLabelAvoidTrack = false; // push labels perpendicular so they don't cover track lines
|
|
public float trackLabelFontSizeMin = 10f; // smallest pixel size (at zoom limit); auto-scales between this and trackLabelFontSize
|
|
|
|
// Custom theme colors — edited live in the Settings color picker.
|
|
// Initialized to S3 Dark so first-launch looks reasonable before the user tunes it.
|
|
public MapThemeData customTheme = new MapThemeData {
|
|
wBgR=0.12f, wBgG=0.12f, wBgB=0.12f, wBgA=1.00f,
|
|
accR=0.26f, accG=0.59f, accB=0.98f, accA=1.00f,
|
|
txtR=1.00f, txtG=1.00f, txtB=1.00f, txtA=1.00f,
|
|
popR=0.08f, popG=0.08f, popB=0.08f, popA=0.94f,
|
|
mapR=1.00f, mapG=1.00f, mapB=1.00f, mapA=1.00f,
|
|
cmpR=0.086f,cmpG=0.086f,cmpB=0.086f,cmpA=0.784f,
|
|
nNR=0.804f, nNG=0.196f, nNB=0.196f, nNA=1.00f,
|
|
nSR=0.804f, nSG=0.804f, nSB=0.804f, nSA=0.863f,
|
|
mapBgR=0.082f,mapBgG=0.122f,mapBgB=0.157f,mapBgA=1.00f,
|
|
};
|
|
}
|