public static void Stop() { manager.Destroy(); PlayerManager.CarChanged -= CarChangeCheck; SGLib.Destroy(); DestroySteamerWaterLevelBacklight(); }
public static void Init() { _ = new SGLib(); manager = new GameObject().AddComponent <SGManager>(); PlayerManager.CarChanged += CarChangeCheck; steamerCabLightsOn = new List <string>(); SetSuperGauges(); }
public static void Destroy() { SuperGauges.SetSuperGauges(true); Instance = null; }
private static void SetSuperGauge(GameObject prefab, bool restoreDefaults = false) { var trainCar = prefab.GetComponent <TrainCar>(); if (trainCar.carType != TrainCarType.LocoShunter && trainCar.carType != TrainCarType.LocoSteamHeavy && trainCar.carType != TrainCarType.LocoDiesel) { return; } switch (trainCar.carType) { case TrainCarType.LocoShunter: SGLib.ReloadShunterTextures(); if (PlayerManager.LastLoco != null) { if (PlayerManager.LastLoco.carType == TrainCarType.LocoShunter) { if (!restoreDefaults) { CarChangeCheck(PlayerManager.LastLoco); } if (restoreDefaults) { RestoreShunterDefaults(PlayerManager.LastLoco); } } } break; case TrainCarType.LocoSteamHeavy: SGLib.ReloadSteamerTextures(); if (PlayerManager.LastLoco != null) { if (PlayerManager.LastLoco.carType == TrainCarType.LocoSteamHeavy) { if (!restoreDefaults) { CarChangeCheck(PlayerManager.LastLoco); } if (restoreDefaults) { RestoreSteamerDefaults(PlayerManager.LastLoco); } } } break; case TrainCarType.LocoDiesel: SGLib.ReloadDieselTextures(); if (PlayerManager.LastLoco != null) { if (PlayerManager.LastLoco.carType == TrainCarType.LocoDiesel) { if (!restoreDefaults) { CarChangeCheck(PlayerManager.LastLoco); } if (restoreDefaults) { RestoreDieselDefaults(PlayerManager.LastLoco); } } } break; default: Debug.LogWarning("Failed to set SuperGauges!"); break; } }
static void OnGUI(UnityModManager.ModEntry modEntry) { if (boxStyle == null) { boxStyle = new GUIStyle(GUI.skin.box); boxStyle.normal.background = new Texture2D(1, 1); boxStyle.normal.background.SetPixel(0, 0, Color.gray); boxStyle.normal.background.Apply(); boxStyle.margin = new RectOffset(4, 4, 4, 4); } if (SGLib.Instance == null) { GUILayout.BeginHorizontal(); GUILayout.Label("<b><color=yellow>Waiting for initialization</color></b>", new GUIStyle(GUI.skin.label) { richText = true }, GUILayout.Width(149)); int x = DateTime.Now.Second % 3; GUILayout.Label(x == 0 ? "<b><color=yellow>.</color></b>" : x == 1 ? "<b><color=yellow>..</color></b>" : "<b><color=yellow>...</color></b>", new GUIStyle(GUI.skin.label) { richText = true }); GUILayout.EndHorizontal(); return; } GUILayout.BeginHorizontal(); bool LocoShunterTRUE = GUILayout.Toggle(settings.LocoShunterTRUE, "", GUILayout.Width(20)); if (settings.LocoShunterTRUE != LocoShunterTRUE) { settings.LocoShunterTRUE = LocoShunterTRUE; SuperGauges.SetSuperGauges(!LocoShunterTRUE, TrainCarType.LocoShunter); } GUILayout.Label("Shunter", GUILayout.Width(80)); if (settings.LocoShunterTRUE) { if (GUILayout.Button("<size=24>\u25BD</size>", new GUIStyle(GUI.skin.button) { richText = true, padding = new RectOffset(0, 0, -6, 0) }, GUILayout.Width(18), GUILayout.Height(18))) { optionsMenu = optionsMenu == "" ? "shunter" : optionsMenu == "shunter" ? "" : "shunter"; } } GUILayout.EndHorizontal(); if (settings.LocoShunterTRUE && optionsMenu == "shunter") { GUILayout.BeginVertical(GUILayout.MinHeight(150)); scrollShunter = GUILayout.BeginScrollView(scrollShunter); GUILayout.BeginHorizontal(); dirsShunter = Directory.GetDirectories(SGLib.TexPath_LocoShunter); foreach (var d in dirsShunter) { string n = Path.GetFileName(d); GUI.color = settings.currentLocoShunterDirName == n ? Color.green : Color.white; GUILayout.BeginVertical(boxStyle, GUILayout.Width(100)); GUI.color = Color.white; if (GUILayout.Button("", GUIStyle.none, GUILayout.Width(100), GUILayout.Height(120))) { settings.currentLocoShunterDirName = Path.GetFileName(d); SGLib.ReloadShunterTextures(); SuperGauges.SetSuperGauges(); return; } var rect = GUILayoutUtility.GetLastRect(); rect.height -= 20; if (File.Exists(d + "/thmb.jpg")) { ImageConversion.LoadImage(thmb, File.ReadAllBytes(d + "/thmb.jpg")); GUI.DrawTexture(rect, thmb); } rect.y += 100; rect.height -= 80; GUI.Label(rect, $"<b>{n}</b>", new GUIStyle(GUI.skin.label) { richText = true, alignment = TextAnchor.MiddleCenter, margin = new RectOffset(0, 0, 0, 0) }); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } GUILayout.BeginHorizontal(); bool LocoSteamerHeavyTRUE = GUILayout.Toggle(settings.LocoSteamerHeavyTRUE, "", GUILayout.Width(20)); if (settings.LocoSteamerHeavyTRUE != LocoSteamerHeavyTRUE) { settings.LocoSteamerHeavyTRUE = LocoSteamerHeavyTRUE; SuperGauges.SetSuperGauges(!LocoSteamerHeavyTRUE, TrainCarType.LocoSteamHeavy); } GUILayout.Label("Steamer", GUILayout.Width(80)); if (settings.LocoSteamerHeavyTRUE) { if (GUILayout.Button("<size=24>\u25BD</size>", new GUIStyle(GUI.skin.button) { richText = true, padding = new RectOffset(0, 0, -6, 0) }, GUILayout.Width(18), GUILayout.Height(18))) { optionsMenu = optionsMenu == "" ? "steamer" : optionsMenu == "steamer" ? "" : "steamer"; } } GUILayout.EndHorizontal(); if (settings.LocoSteamerHeavyTRUE && optionsMenu == "steamer") { GUILayout.BeginVertical(GUILayout.MinHeight(150)); scrollSteamer = GUILayout.BeginScrollView(scrollSteamer); GUILayout.BeginHorizontal(); dirsSteamer = Directory.GetDirectories(SGLib.TexPath_LocoSteamHeavy); foreach (var d in dirsSteamer) { string n = Path.GetFileName(d); GUI.color = settings.currentLocoSteamerDirName == n ? Color.green : Color.white; GUILayout.BeginVertical(boxStyle, GUILayout.Width(100)); GUI.color = Color.white; if (GUILayout.Button("", GUIStyle.none, GUILayout.Width(100), GUILayout.Height(120))) { settings.currentLocoSteamerDirName = Path.GetFileName(d); SGLib.ReloadSteamerTextures(); SuperGauges.SetSuperGauges(); return; } var rect = GUILayoutUtility.GetLastRect(); rect.height -= 20; if (File.Exists(d + "/thmb.jpg")) { ImageConversion.LoadImage(thmb, File.ReadAllBytes(d + "/thmb.jpg")); GUI.DrawTexture(rect, thmb); } rect.y += 100; rect.height -= 80; GUI.Label(rect, $"<b>{n}</b>", new GUIStyle(GUI.skin.label) { richText = true, alignment = TextAnchor.MiddleCenter, margin = new RectOffset(0, 0, 0, 0) }); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } GUILayout.BeginHorizontal(); bool LocoDieselTRUE = GUILayout.Toggle(settings.LocoDieselTRUE, "", GUILayout.Width(20)); if (settings.LocoDieselTRUE != LocoDieselTRUE) { settings.LocoDieselTRUE = LocoDieselTRUE; SuperGauges.SetSuperGauges(!LocoDieselTRUE, TrainCarType.LocoDiesel); } GUILayout.Label("Diesel", GUILayout.Width(80)); if (settings.LocoDieselTRUE) { if (GUILayout.Button("<size=24>\u25BD</size>", new GUIStyle(GUI.skin.button) { richText = true, padding = new RectOffset(0, 0, -6, 0) }, GUILayout.Width(18), GUILayout.Height(18))) { optionsMenu = optionsMenu == "" ? "diesel" : optionsMenu == "diesel" ? "" : "diesel"; } } GUILayout.EndHorizontal(); if (settings.LocoDieselTRUE && optionsMenu == "diesel") { GUILayout.BeginVertical(GUILayout.MinHeight(150)); scrollDiesel = GUILayout.BeginScrollView(scrollDiesel); GUILayout.BeginHorizontal(); dirsDiesel = Directory.GetDirectories(SGLib.TexPath_LocoDiesel); foreach (var d in dirsDiesel) { string n = Path.GetFileName(d); GUI.color = settings.currentLocoDieselDirName == n ? Color.green : Color.white; GUILayout.BeginVertical(boxStyle, GUILayout.Width(100)); GUI.color = Color.white; if (GUILayout.Button("", GUIStyle.none, GUILayout.Width(100), GUILayout.Height(120))) { settings.currentLocoDieselDirName = Path.GetFileName(d); SGLib.ReloadDieselTextures(); SuperGauges.SetSuperGauges(); return; } var rect = GUILayoutUtility.GetLastRect(); rect.height -= 20; if (File.Exists(d + "/thmb.jpg")) { ImageConversion.LoadImage(thmb, File.ReadAllBytes(d + "/thmb.jpg")); GUI.DrawTexture(rect, thmb); } rect.y += 100; rect.height -= 80; GUI.Label(rect, $"<b>{n}</b>", new GUIStyle(GUI.skin.label) { richText = true, alignment = TextAnchor.MiddleCenter, margin = new RectOffset(0, 0, 0, 0) }); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } }