Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Refactoring and cleaning up UI Code
Browse files Browse the repository at this point in the history
  • Loading branch information
seiggy committed Jul 14, 2015
1 parent bc1ed83 commit 7146557
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 145 deletions.
4 changes: 2 additions & 2 deletions TLM/TLM/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
}

if (ToolsModifierControl.toolController.CurrentTool != LoadingExtension.Instance.TrafficLightTool &&
LoadingExtension.Instance.UI.isVisible())
LoadingExtension.Instance.UI.IsVisible())
{
LoadingExtension.Instance.UI.Close();
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public override void OnReleased()
if (ToolMode != TrafficManagerMode.None)
{
ToolMode = TrafficManagerMode.None;
UITrafficManager.uistate = UITrafficManager.UIState.None;
UITrafficManager.UIState = UIState.None;
DestroyTool();
}
}
Expand Down
1 change: 1 addition & 0 deletions TLM/TLM/TLM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Compile Include="Traffic\TrafficSegment.cs" />
<Compile Include="Traffic\VehicleType.cs" />
<Compile Include="UI\UIBase.cs" />
<Compile Include="UI\UIState.cs" />
<Compile Include="UI\UITimedLights.cs" />
<Compile Include="UI\UITrafficManager.cs" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions TLM/TLM/UI/UIBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace TrafficManager.UI
{
public class UIBase : UICustomControl
{
private bool _uiShown = false;
private bool _uiShown;

public UIBase()
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public UIBase()
button.eventClick += ButtonClick;
}

private void ButtonClick(UIComponent component, UIMouseEventParameter eventParam)
private void ButtonClick(UIComponent uiComponent, UIMouseEventParameter eventParam)
{
if (!_uiShown)
{
Expand All @@ -58,7 +58,7 @@ private void ButtonClick(UIComponent component, UIMouseEventParameter eventParam
}
}

public bool isVisible()
public bool IsVisible()
{
return _uiShown;
}
Expand All @@ -82,10 +82,10 @@ public void Close()

if (trafficManager != null)
{
UIView.Destroy(trafficManager);
Destroy(trafficManager);
}

UITrafficManager.uistate = UITrafficManager.UIState.None;
UITrafficManager.UIState = UIState.None;
TrafficLightTool.SetToolMode(ToolMode.None);
LoadingExtension.Instance.SetToolMode(TrafficManagerMode.None);

Expand Down
15 changes: 15 additions & 0 deletions TLM/TLM/UI/UIState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace TrafficManager.UI
{
public enum UIState
{
None,
SwitchTrafficLight,
AddStopSign,
ManualSwitch,
TimedControlNodes,
TimedControlLights,
LaneChange,
LaneRestrictions,
Crosswalk
}
}
16 changes: 8 additions & 8 deletions TLM/TLM/UI/UITimedLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ namespace TrafficManager.UI
{
class UITimedLights : UIPanel
{
public static TrafficLightTool trafficLightTool;
public static TrafficLightTool TrafficLightTool;

public override void Start()
{
trafficLightTool = LoadingExtension.Instance.TrafficLightTool;
TrafficLightTool = LoadingExtension.Instance.TrafficLightTool;
//this makes the panel "visible", I don't know what sprites are available, but found this value to work
this.backgroundSprite = "GenericPanel";
this.color = new Color32(75, 75, 135, 255);
this.width = 800;
this.height = 400;
this.relativePosition = new Vector3(10.48f, 80f);
backgroundSprite = "GenericPanel";
color = new Color32(75, 75, 135, 255);
width = 800;
height = 400;
relativePosition = new Vector3(10.48f, 80f);

UILabel l = this.AddUIComponent<UILabel>();
var l = AddUIComponent<UILabel>();
l.text = "Timed Scripts";
l.relativePosition = new Vector3(65.0f, 5.0f);
}
Expand Down
Loading

0 comments on commit 7146557

Please sign in to comment.