Skip to content

Commit 68cdcc5

Browse files
authored
Main menu and tool code refactoring (#656)
* Refactoring LinearToolButton into a more generic skinnable button * Renamed BaseUI and menu button classes and moved some generic files into U/ * Get properties in UButton are now abstract functions * Replaced graphics loading for UIMainButton with new Atlas code * Skinnable BaseUButton and generalized with MainMenuButton * ButtonSkin allows overriding background * Main menu is scaled to screen size fraction * LoadingExtension.ModUi is now a singleton ModUI accessible via ModUI.Instance * Fixed main button to always 50px. Added min scale for main panel button 40px * UI scale slider affects mainmenu panel now * Toned down button textures; added v11 to 11 in main button; Review notes satisfied * MenuLayout class responsible for menu row breaking and sizing
1 parent 26f416f commit 68cdcc5

File tree

95 files changed

+1456
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1456
-853
lines changed

TLM/CSUtil.CameraControl

TLM/OptionsFramework

TLM/TLM/Custom/AI/CustomRoadBaseAI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void CustomClickNodeButton(ushort nodeId, ref NetNode data, int index) {
2020
data.m_flags |= NetNode.Flags.CustomTrafficLights;*/
2121

2222
// NON-STOCK CODE START
23-
ToggleTrafficLightsTool toggleTool = (ToggleTrafficLightsTool)UIBase
23+
ToggleTrafficLightsTool toggleTool = (ToggleTrafficLightsTool)ModUI
2424
.GetTrafficManagerTool(true)
2525
.GetSubTool(ToolMode.SwitchTrafficLight);
2626
toggleTool.ToggleTrafficLight(nodeId, ref data, false);

TLM/TLM/LoadingExtension.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ public class ManualHarmonyPatch {
7373
/// </summary>
7474
public static Translation TranslationDatabase = new Translation();
7575

76-
public static UIBase BaseUI { get; private set; }
77-
7876
public static UITransportDemand TransportDemandUI { get; private set; }
7977

8078
public static List<ICustomManager> RegisteredManagers { get; private set; }
@@ -368,10 +366,10 @@ void Destroy<T>() where T : MonoBehaviour {
368366
}
369367

370368
Log.Info("Removing Controls from UI.");
371-
if (BaseUI != null) {
372-
BaseUI.Close(); // Hide the UI ASAP
373-
Object.Destroy(BaseUI);
374-
BaseUI = null;
369+
if (ModUI.Instance != null) {
370+
ModUI.Instance.Close(); // Hide the UI ASAP
371+
Object.Destroy(ModUI.Instance);
372+
ModUI.SetSingletonInstance(null);
375373
Log._Debug("removed UIBase instance.");
376374
}
377375

@@ -544,9 +542,10 @@ public override void OnLevelLoaded(LoadMode mode) {
544542
}
545543

546544
Log.Info("Adding Controls to UI.");
547-
if (BaseUI == null) {
545+
if (ModUI.Instance == null) {
548546
Log._Debug("Adding UIBase instance.");
549-
BaseUI = ToolsModifierControl.toolController.gameObject.AddComponent<UIBase>();
547+
ModUI.SetSingletonInstance(
548+
ToolsModifierControl.toolController.gameObject.AddComponent<ModUI>());
550549
}
551550

552551
// Init transport demand UI

TLM/TLM/RedirectionFramework

12.6 KB
2.67 KB
2.79 KB
7.55 KB
6.84 KB

0 commit comments

Comments
 (0)