private void RefreshMapActionUI(IMapAction lastAction) { activeMap.IsModified = true; if (lastAction is MapActionResize) { SetImage(null); RenderMap(); //UpdateMinimap(true, true); } if (lastAction is MapActionPasteTile || lastAction is MapActionPastePass) { Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y]; RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y, tile == null || tile.TileNumber == 0); pnlImage.Invalidate(); UpdateMinimap(true, false); } else if (lastAction is MapActionPasteObject) { Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y]; for (int i = 0; i < 12; i++) { if (lastAction.Tile.Y - i >= 0) { RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y - i, tile == null || tile.ObjectNumber == 0); } } pnlImage.Invalidate(); UpdateMinimap(true, false); } }
private void AddMapAction(IMapAction mapAction) { if (mapUndoActions.Count > 1000) { for (int i = 0; i < 100; i++) { mapUndoActions.RemoveFirst(); } } mapUndoActions.AddLast(mapAction); mapRedoActions.Clear(); }
private void redoToolStripMenuItem_Click(object sender, EventArgs e) { if (mapRedoActions.Count == 0) { return; } IMapAction lastAction = mapRedoActions.Last.Value; mapRedoActions.RemoveLast(); mapUndoActions.AddLast(lastAction); // to be able to undo what has been redone lastAction.Redo(activeMap); RefreshMapActionUI(lastAction); }
private void redoToolStripMenuItem_Click(object sender, EventArgs e) { if (mapRedoActions.Count == 0) { return; } IMapAction lastAction = mapRedoActions.Last.Value; mapRedoActions.RemoveLast(); mapUndoActions.AddLast(lastAction); // to be able to undo what has been redone lastAction.Redo(activeMap); activeMap.IsModified = changeSinceRender = true; pnlImage.Image = activeMap.GetRenderedMap(showTiles, showObjects); Invalidate(); }
public bool IsMapActionSelected(IMapAction mapAction) => SelectedMapAction == mapAction;
private void RefreshMapActionUI(IMapAction lastAction) { activeMap.IsModified = true; if (lastAction is MapActionResize) { SetImage(null); RenderMap(); //UpdateMinimap(true, true); } if (lastAction is MapActionPasteTile || lastAction is MapActionPastePass) { Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y]; RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y, tile == null || tile.TileNumber == 0); pnlImage.Invalidate(); UpdateMinimap(true, false); } else if (lastAction is MapActionPasteObject) { Map.Tile tile = activeMap[lastAction.Tile.X, lastAction.Tile.Y]; for (int i = 0; i < 12; i++) { if (lastAction.Tile.Y - i >= 0) RenderSingleMapTile(lastAction.Tile.X, lastAction.Tile.Y - i, tile == null || tile.ObjectNumber == 0); } pnlImage.Invalidate(); UpdateMinimap(true, false); } }
private void AddMapAction(IMapAction mapAction) { if (mapUndoActions.Count > 1000) for (int i = 0; i < 100; i++) mapUndoActions.RemoveFirst(); mapUndoActions.AddLast(mapAction); mapRedoActions.Clear(); }
public SelectMapAction_GameAction(GameActionSelector.MapActionSelector selector, IMapAction mapAction, ViewValues iconValues) { IconValues = iconValues; Clicked += () => { if (mapAction == null) { return; } selector.Select(mapAction); }; }
/// <summary> /// This method allows a map action to be applied to the current transaction. /// </summary> public void PerformMapTransaction(IMapAction mapAction, GameMap map) { mapAction.Execute(map); TransactionPerformed(this, new TransactionEventArgs(mapAction)); }
private void Add(IMapAction <TSource, TTarget> mapAction) { _maps.Add(mapAction); }
public TransactionEventArgs(IMapAction actionPerformed) { ActionPerformed = actionPerformed; }
public void UnperformMapTransaction(IMapAction mapAction) { mapAction.UnExecute(_gameMap); TransactionUnperformed(this, new TransactionEventArgs(mapAction)); }
/// <summary> /// This method allows a map action to be applied to the current transaction. /// </summary> public void PerformMapTransactionNoEvent(IMapAction mapAction) { mapAction.Execute(_gameMap); }
public void Clear() => SelectedMapAction = null;
/// <summary> /// Adds a map action to the manager /// </summary> /// <param name="mapAction"></param> public void AddTransaction(IMapAction mapAction) { _undo.Push(mapAction); _redo.Clear(); }
public void Select(IMapAction mapAction) { SelectedMapAction = mapAction; }
public SelectMapAction_GameAction CreateSelectAction(GameController gameController, IMapAction mapAction) { if (gameController.MapActionSelector == null) { throw new ArgumentNullException($"{nameof(gameController)}'s {nameof(GameActionSelector)} is null"); } SelectMapAction_GameAction tabItemAction = new SelectMapAction_GameAction(gameController.MapActionSelector, mapAction, mapAction.IconValues); return(tabItemAction); }