Skip to content

Commit

Permalink
Implemented Undo/Redo.
Browse files Browse the repository at this point in the history
  • Loading branch information
trippsc2 committed Mar 29, 2020
1 parent 1401605 commit 6ac5a37
Show file tree
Hide file tree
Showing 34 changed files with 1,208 additions and 234 deletions.
6 changes: 3 additions & 3 deletions OpenTracker.Setup/OpenTracker.Setup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:OpenTracker"
"ProductCode" = "8:{20E7EBC1-65BD-460F-BDF5-E79044503EB1}"
"PackageCode" = "8:{C80117F4-F719-453B-B059-B0DA3FD3F4BF}"
"ProductCode" = "8:{69BC09D7-A658-4CB4-A62C-53432514C370}"
"PackageCode" = "8:{F3B764AD-9DCE-48AA-A136-6058A7DB0D66}"
"UpgradeCode" = "8:{C98C2121-B4C5-473A-9B86-5407FEFFE8F1}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:0.4.0"
"ProductVersion" = "8:0.5.0"
"Manufacturer" = "8:OpenTracker"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
Expand Down
25 changes: 25 additions & 0 deletions OpenTracker/Actions/AddItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class AddItem : IUndoable
{
private readonly Item _item;

public AddItem(Item item)
{
_item = item;
}

public void Execute()
{
_item.Change(1);
}

public void Undo()
{
_item.Change(-1);
}
}
}
29 changes: 29 additions & 0 deletions OpenTracker/Actions/ChangeBoss.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class ChangeBoss : IUndoable
{
private readonly BossSection _bossSection;
private readonly Boss _boss;
private Boss _previousBoss;

public ChangeBoss(BossSection bossSection, Boss boss)
{
_bossSection = bossSection;
_boss = boss;
}

public void Execute()
{
_previousBoss = _bossSection.Boss;
_bossSection.Boss = _boss;
}

public void Undo()
{
_bossSection.Boss = _previousBoss;
}
}
}
29 changes: 29 additions & 0 deletions OpenTracker/Actions/ChangeBossShuffle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class ChangeBossShuffle : IUndoable
{
private readonly Mode _mode;
private readonly bool _bossShuffle;
private bool _previousBossShuffle;

public ChangeBossShuffle(Mode mode, bool bossShuffle)
{
_mode = mode;
_bossShuffle = bossShuffle;
}

public void Execute()
{
_previousBossShuffle = _mode.BossShuffle.Value;
_mode.BossShuffle = _bossShuffle;
}

public void Undo()
{
_mode.BossShuffle = _previousBossShuffle;
}
}
}
30 changes: 30 additions & 0 deletions OpenTracker/Actions/ChangeDungeonItemShuffle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;
using OpenTracker.Models.Enums;

namespace OpenTracker.Actions
{
public class ChangeDungeonItemShuffle : IUndoable
{
private readonly Mode _mode;
private readonly DungeonItemShuffle _dungeonItemShuffle;
private DungeonItemShuffle _previousDungeonItemShuffle;

public ChangeDungeonItemShuffle(Mode mode, DungeonItemShuffle dungeonItemShuffle)
{
_mode = mode;
_dungeonItemShuffle = dungeonItemShuffle;
}

public void Execute()
{
_previousDungeonItemShuffle = _mode.DungeonItemShuffle.Value;
_mode.DungeonItemShuffle = _dungeonItemShuffle;
}

public void Undo()
{
_mode.DungeonItemShuffle = _previousDungeonItemShuffle;
}
}
}
29 changes: 29 additions & 0 deletions OpenTracker/Actions/ChangeEnemyShuffle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class ChangeEnemyShuffle : IUndoable
{
private readonly Mode _mode;
private readonly bool _enemyShuffle;
private bool _previousEnemyShuffle;

public ChangeEnemyShuffle(Mode mode, bool enemyShuffle)
{
_mode = mode;
_enemyShuffle = enemyShuffle;
}

public void Execute()
{
_previousEnemyShuffle = _mode.EnemyShuffle.Value;
_mode.EnemyShuffle = _enemyShuffle;
}

public void Undo()
{
_mode.EnemyShuffle = _previousEnemyShuffle;
}
}
}
29 changes: 29 additions & 0 deletions OpenTracker/Actions/ChangeEntranceShuffle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class ChangeEntranceShuffle : IUndoable
{
private readonly Mode _mode;
private readonly bool _entranceShuffle;
private bool _previousEntranceShuffle;

public ChangeEntranceShuffle(Mode mode, bool entranceShuffle)
{
_mode = mode;
_entranceShuffle = entranceShuffle;
}

public void Execute()
{
_previousEntranceShuffle = _mode.EntranceShuffle.Value;
_mode.EntranceShuffle = _entranceShuffle;
}

public void Undo()
{
_mode.EntranceShuffle = _previousEntranceShuffle;
}
}
}
35 changes: 35 additions & 0 deletions OpenTracker/Actions/ChangeItemPlacement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;
using OpenTracker.Models.Enums;

namespace OpenTracker.Actions
{
public class ChangeItemPlacement : IUndoable
{
private readonly Mode _mode;
private readonly ItemPlacement _itemPlacement;
private ItemPlacement _previousItemPlacement;

public ChangeItemPlacement(Mode mode, ItemPlacement itemPlacement)
{
_mode = mode;
_itemPlacement = itemPlacement;
}

public void Execute()
{
_previousItemPlacement = _mode.ItemPlacement.Value;
_mode.ItemPlacement = _itemPlacement;
}

public void Undo()
{
_mode.ItemPlacement = _previousItemPlacement;
}

public bool Validate(ItemPlacement itemPlacement)
{
return _itemPlacement == itemPlacement;
}
}
}
29 changes: 29 additions & 0 deletions OpenTracker/Actions/ChangePrize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;

namespace OpenTracker.Actions
{
public class ChangePrize : IUndoable
{
private readonly BossSection _prizeSection;
private readonly Item _item;
private Item _previousItem;

public ChangePrize(BossSection prizeSection, Item item)
{
_prizeSection = prizeSection;
_item = item;
}

public void Execute()
{
_previousItem = _prizeSection.Prize;
_prizeSection.Prize = _item;
}

public void Undo()
{
_prizeSection.Prize = _previousItem;
}
}
}
30 changes: 30 additions & 0 deletions OpenTracker/Actions/ChangeWorldState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using OpenTracker.Interfaces;
using OpenTracker.Models;
using OpenTracker.Models.Enums;

namespace OpenTracker.Actions
{
public class ChangeWorldState : IUndoable
{
private readonly Mode _mode;
private readonly WorldState _worldState;
private WorldState _previousWorldState;

public ChangeWorldState(Mode mode, WorldState worldState)
{
_mode = mode;
_worldState = worldState;
}

public void Execute()
{
_previousWorldState = _mode.WorldState.Value;
_mode.WorldState = _worldState;
}

public void Undo()
{
_mode.WorldState = _previousWorldState;
}
}
}
Loading

0 comments on commit 6ac5a37

Please sign in to comment.