Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<Compile Include="UI\Helpers\SliderOption.cs" />
<Compile Include="UI\Helpers\OptionButtonBase.cs" />
<Compile Include="UI\Helpers\UrlButton.cs" />
<Compile Include="UI\LegacySubToolMixin.cs" />
<Compile Include="UI\Textures\RoadSignTheme.cs" />
<Compile Include="UI\MainMenu\RoutingDetectorButton.cs" />
<Compile Include="UI\SubTools\RoutingDetector\Connection.cs" />
Expand Down
60 changes: 32 additions & 28 deletions TLM/TLM/UI/LegacySubTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public LegacySubTool(TrafficManagerTool mainTool) {
uiTransparencyUnbsubscriber_ = ModUI.Instance.Events.UiOpacity.Subscribe(this);
}

protected TrafficManagerTool MainTool { get; }
protected GUILayoutOption[] EmptyOptionsArray = new GUILayoutOption[0];
internal TrafficManagerTool MainTool { get; }
protected static GUILayoutOption[] EmptyOptionsArray = new GUILayoutOption[0];

private Texture2D WindowTexture {
get {
Expand All @@ -32,34 +32,33 @@ private Texture2D WindowTexture {

private Texture2D windowTexture_;

protected GUIStyle WindowStyle =>
internal GUIStyle WindowStyle =>
// ReSharper disable once ConvertToNullCoalescingCompoundAssignment
windowStyle_ ??
(windowStyle_
= new GUIStyle {
normal = {
background = WindowTexture,
textColor = Color.white,
},
alignment = TextAnchor.UpperCenter,
fontSize = 20,
border = {
left = 4,
top = 41,
right = 4,
bottom = 8,
},
overflow = {
bottom = 0,
top = 0,
right = 12,
left = 12,
},
contentOffset = new Vector2(0, -44),
padding = {
top = 55,
},
});
(windowStyle_ = new GUIStyle {
normal = {
background = WindowTexture,
textColor = Color.white,
},
alignment = TextAnchor.UpperCenter,
fontSize = 20,
border = {
left = 4,
top = 41,
right = 4,
bottom = 8,
},
overflow = {
bottom = 0,
top = 0,
right = 12,
left = 12,
},
contentOffset = new Vector2(0, -44),
padding = {
top = 55,
},
});

private GUIStyle windowStyle_;

Expand Down Expand Up @@ -185,6 +184,11 @@ public virtual void RenderOverlayForOtherTools(RenderManager.CameraInfo cameraIn
public virtual void ShowGUIOverlay(ToolMode toolMode, bool viewOnly) { }

public virtual bool IsCursorInPanel() {
return IsCursorInPanel_();
}

/// <summary>Check whether cursor is in the main menu or debug menu area.</summary>
internal static bool IsCursorInPanel_() {
return ModUI.Instance.GetMenu().containsMouse
#if DEBUG
|| ModUI.Instance.GetDebugMenu().containsMouse
Expand Down
83 changes: 83 additions & 0 deletions TLM/TLM/UI/LegacySubToolMixin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
namespace TrafficManager.UI {
using System;
using ColossalFramework.UI;
using TrafficManager.U;
using UnityEngine;

[Obsolete("Used in legacy GUI for migration to new subtool base clas")]
public class LegacySubToolMixin {
[Obsolete("Used in legacy GUI")]
internal static GUILayoutOption[] LegacyEmptyOptionsArray = new GUILayoutOption[0];

[Obsolete("Used in legacy GUI")]
protected void LegacyDragWindow(ref Rect window) {
Vector2 resolution = UIView.GetAView().GetScreenResolution();
window.x = Mathf.Clamp(window.x, 0, UIScaler.MaxWidth - window.width);
window.y = Mathf.Clamp(window.y, 0, UIScaler.MaxHeight - window.height);

bool primaryMouseDown = Input.GetMouseButton(0);
if (primaryMouseDown) {
GUI.DragWindow();
}
}

[Obsolete("Used in legacy GUI")]
private Texture2D LegacyWindowTexture {
get {
if (legacyWindowTexture_ == null) {
legacyWindowTexture_ = TextureUtil.AdjustAlpha(
Textures.MainMenu.WindowBackground,
TrafficManagerTool.GetWindowAlpha());
}

return legacyWindowTexture_;
}
}

[Obsolete("Used in legacy GUI")]
private Texture2D legacyWindowTexture_;

[Obsolete("Used in legacy GUI")]
private GUIStyle legacyWindowStyle_;

[Obsolete("Used in legacy GUI")]
internal GUIStyle LegacyWindowStyle =>
// ReSharper disable once ConvertToNullCoalescingCompoundAssignment
legacyWindowStyle_ ??
(legacyWindowStyle_ = new GUIStyle {
normal = {
background = LegacyWindowTexture,
textColor = Color.white,
},
alignment = TextAnchor.UpperCenter,
fontSize = 20,
border = {
left = 4,
top = 41,
right = 4,
bottom = 8,
},
overflow = {
bottom = 0,
top = 0,
right = 12,
left = 12,
},
contentOffset = new Vector2(0, -44),
padding = {
top = 55,
},
});


/// <summary>Check whether cursor is in the main menu or debug menu area.</summary>
[Obsolete("Member of legacy subtool")]
internal static bool LegacyIsCursorInPanel() {
return ModUI.Instance.GetMenu().containsMouse
#if DEBUG
|| ModUI.Instance.GetDebugMenu().containsMouse
#endif
;
}
}
}
4 changes: 2 additions & 2 deletions TLM/TLM/UI/SubTools/TTL/TTLToolMode.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace TrafficManager.UI.SubTools {
internal enum TTLToolMode {
namespace TrafficManager.UI.SubTools.TTL {
internal enum TtlToolMode {
/// <summary>Timed traffic light submode.</summary>
SelectNode,

Expand Down
Loading