Skip to content

Commit

Permalink
Shortcut from Activated to Deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
Craxy authored and Craxy committed Apr 3, 2015
1 parent defa780 commit fe13920
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum State
Deactivated,
Activated,
HiddenToActivated,
ActivatedToHidden,
}

public enum Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ protected override void OnInitialized()
return Command.ActivateOtherTool;
}

if (KeyHelper.IsToolKeyPressed())
{
return Command.PressShortcut;
}

if (_selectedIndexChanged)
{
return Command.ClickToolModeTab;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Craxy.CitiesSkylines.ToggleTrafficLights.Utils;

namespace Craxy.CitiesSkylines.ToggleTrafficLights.Game.UI.StateMachine.States
{
public class ActivatedToHiddenState : StateBase
{
#region Overrides of StateBase

public override State State
{
get { return State.ActivatedToHidden; }
}

public override void OnEntry()
{
base.OnEntry();

CloseRoadPanel();
}

public override void OnExit()
{
base.OnExit();
}

public override void OnUpdate()
{
base.OnUpdate();

CloseRoadPanel();
}

public override Command? CheckCommand()
{
if (RoadsPanel != null && !RoadsPanel.isVisible)
{
return Command.HideRoadsPanel;
}

return null;
}

#endregion

private void CloseRoadPanel()
{
if (RoadsPanel != null && RoadsPanel.isVisible)
{
CitiesHelper.ClickOnRoadsButton();
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ public TrafficLightsMachine()
new Transition(State.Deactivated, Command.HideRoadsPanel, State.Hidden),
new Transition(State.Deactivated, Command.PressShortcut, State.Activated),
new Transition(State.Deactivated, Command.ClickToolButton, State.Activated),
new Transition(State.Activated, Command.PressShortcut, State.Hidden),
new Transition(State.Activated, Command.HideRoadsPanel, State.Hidden),
new Transition(State.Activated, Command.ClickToolModeTab, State.Deactivated),
new Transition(State.Activated, Command.ActivateOtherTool, State.Deactivated),
new Transition(State.Activated, Command.PressShortcut, State.ActivatedToHidden),
new Transition(State.ActivatedToHidden, Command.HideRoadsPanel, State.Hidden),
};
States = new List<IState>
{
new HiddenState(),
new Deactivated(),
new ActivatedState(),
new HiddenToActivatedState(),
new ActivatedToHiddenState(),
};
}

Expand Down
1 change: 1 addition & 0 deletions src/ToggleTrafficLights/ToggleTrafficLights.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="Game\UI\KeyHelper.cs" />
<Compile Include="Game\UI\StateMachine\StateMachine.cs" />
<Compile Include="Game\UI\StateMachine\States\ActivatedState.cs" />
<Compile Include="Game\UI\StateMachine\States\ActivatedToHiddenState.cs" />
<Compile Include="Game\UI\StateMachine\States\ButtonStateBase.cs" />
<Compile Include="Game\UI\StateMachine\States\DeactivatedState.cs" />
<Compile Include="Game\UI\StateMachine\States\HiddenState.cs" />
Expand Down

0 comments on commit fe13920

Please sign in to comment.