Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
342dd31
basic auto timed traffic lights
kianzarrin Nov 10, 2019
330287c
added Traffic lights with the following untested features:
kianzarrin Nov 10, 2019
3befa27
Completed Timed traffic lights with all the edge cases.
kianzarrin Nov 11, 2019
b958903
merged with master
kianzarrin Nov 11, 2019
3bd5230
Polished and documented the code
kianzarrin Nov 17, 2019
0aed330
deleted uncessary file that I accidentially added
kianzarrin Nov 17, 2019
39a3af7
Added keybind tooltip
kianzarrin Nov 19, 2019
44fc16f
removed commented out debug code.
kianzarrin Nov 22, 2019
ad8d267
auto start TL
kianzarrin Nov 23, 2019
7ebf411
Merge branch 'master' of https://github.com/krzychu124/Cities-Skyline…
kianzarrin Nov 23, 2019
0429efe
added translations.
kianzarrin Nov 26, 2019
75ca063
translation update - new Auto TL keys, Turkish translation added
krzychu124 Nov 26, 2019
406b10c
Merge branch 'master' into Timed_Traffic_Light
kianzarrin Nov 27, 2019
fa9d1d5
resolved conflict my choosing all translation files from master
kianzarrin Nov 27, 2019
6938092
added error message for train tracks not supported.
kianzarrin Dec 3, 2019
a0c8ba0
added LHT logic
kianzarrin Dec 4, 2019
0b0f79d
Merge remote-tracking branch 'initial/master' into Timed_Traffic_Light
kianzarrin Dec 4, 2019
f16835f
LHT logic
kianzarrin Dec 4, 2019
18563f5
Merge remote-tracking branch 'initial/master' into Timed_Traffic_Light
kianzarrin Dec 15, 2019
3fe8ed5
Merge branch 'master' into Timed_Traffic_Light
kianzarrin Dec 15, 2019
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 @@ -267,6 +267,7 @@
<Compile Include="State\Flags.cs" />
<Compile Include="UI\TransportDemandViewMode.cs" />
<Compile Include="UI\UITransportDemand.cs" />
<Compile Include="Util\AutoTimedTrafficLights.cs" />
<Compile Include="Util\Caching\CameraTransformValue.cs" />
<Compile Include="Util\Caching\GenericArrayCache.cs" />
<Compile Include="Util\FloatUtil.cs" />
Expand Down
4 changes: 2 additions & 2 deletions TLM/TLM/UI/MainMenu/TimedTrafficLightsButton.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace TrafficManager.UI.MainMenu {
namespace TrafficManager.UI.MainMenu {
using State;

public class TimedTrafficLightsButton : MenuToolModeButton {
protected override ToolMode ToolMode => ToolMode.TimedLightsSelectNode;

protected override ButtonFunction Function => ButtonFunction.TimedTrafficLights;

public override string Tooltip => Translation.Menu.Get("Tooltip:Timed traffic lights");
public override string Tooltip => Translation.Menu.Get("Tooltip:Timed traffic lights") + "\n" + Translation.Menu.Get("Tooltip.Keybinds:Quick setup");

public override bool Visible => Options.timedLightsEnabled;
}
Expand Down
38 changes: 35 additions & 3 deletions TLM/TLM/UI/SubTools/TimedTrafficLightsTool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace TrafficManager.UI.SubTools {
namespace TrafficManager.UI.SubTools {
using TrafficManager.Util;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -99,9 +100,37 @@ public override void OnSecondaryClickOverlay() {
}

public override void OnPrimaryClickOverlay() {
if (HoveredNodeId <= 0 || nodeSelectionLocked) {
if (HoveredNodeId <= 0 || nodeSelectionLocked || !Flags.MayHaveTrafficLight(HoveredNodeId)) {
return;
}
bool ctrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
if(ctrlDown) {
AutoTimedTrafficLights.ErrorResult res = AutoTimedTrafficLights.Setup(HoveredNodeId);
if (res != AutoTimedTrafficLights.ErrorResult.Success) {
string message;
switch (res) {
case AutoTimedTrafficLights.ErrorResult.NoJunction:
message = "Dialog.Text:This is not a junction";
break;
case AutoTimedTrafficLights.ErrorResult.NoNeed:
message = "Dialog.Text:There is no need";
break;
case AutoTimedTrafficLights.ErrorResult.TTLExists:
message = "Dialog.Text:Timed traffic lights already exists";
break;
default: //Unreachable code
message = $"error = {res}";
break;
}
message = Translation.TrafficLights.Get("Dialog.Text:Default timed traffic lights not createed because : ") +
Translation.TrafficLights.Get(message);
MainTool.ShowError(message);
return;
}
RefreshCurrentTimedNodeIds(HoveredNodeId);
MainTool.SetToolMode(ToolMode.TimedLightsShowLights);
}


TrafficLightSimulationManager tlsMan = TrafficLightSimulationManager.Instance;

Expand Down Expand Up @@ -249,7 +278,10 @@ public override void OnToolGUI(Event e) {

switch (MainTool.GetToolMode()) {
case ToolMode.TimedLightsSelectNode: {
GuiTimedTrafficLightsNode();
bool ctrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
if (!ctrlDown) {
GuiTimedTrafficLightsNode();
}
break;
}

Expand Down
Loading