From 5866a8f5f9e0c81265ed7578b3c4c5f7abd3eb39 Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Sat, 4 Dec 2021 13:46:37 +0100 Subject: [PATCH 1/7] version 9.2 is live --- README.md | 4 ++-- version.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c0b29713..e378ba86 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![GitHub](https://img.shields.io/github/license/AnnoDesigner/anno-designer)](https://github.com/AnnoDesigner/anno-designer/blob/master/LICENSE) [![version](https://img.shields.io/badge/latest--version-9.1-blue)](https://github.com/AnnoDesigner/anno-designer/releases/tag/AnnoDesignerv9.1) [![presets version](https://img.shields.io/badge/presets--version-3.12-blue)](https://github.com/AnnoDesigner/anno-designer/releases/tag/Presetsv3.12) [![Discord](https://img.shields.io/discord/571011757317947406?label=help%2Fdiscord)](https://discord.gg/JJpHWRB) +[![GitHub](https://img.shields.io/github/license/AnnoDesigner/anno-designer)](https://github.com/AnnoDesigner/anno-designer/blob/master/LICENSE) [![version](https://img.shields.io/badge/latest--version-9.2-blue)](https://github.com/AnnoDesigner/anno-designer/releases/tag/AnnoDesignerv9.2) [![presets version](https://img.shields.io/badge/presets--version-3.12-blue)](https://github.com/AnnoDesigner/anno-designer/releases/tag/Presetsv3.12) [![Discord](https://img.shields.io/discord/571011757317947406?label=help%2Fdiscord)](https://discord.gg/JJpHWRB) # Anno Designer A building layout designer for Ubisoft's Anno-series @@ -7,7 +7,7 @@ This is a fork of the project created by JcBernack - https://github.com/JcBernac ## Latest Releases -### [Anno Designer 9.1](https://github.com/AnnoDesigner/anno-designer/releases/tag/AnnoDesignerv9.1) +### [Anno Designer 9.2](https://github.com/AnnoDesigner/anno-designer/releases/tag/AnnoDesignerv9.2) #### [Latest Presets file release](https://github.com/AnnoDesigner/anno-designer/releases/tag/Presetsv3.12) The presets update can be downloaded automatically by the application. diff --git a/version.txt b/version.txt index 7af44b6c..964fadb2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -9.1 \ No newline at end of file +9.2 \ No newline at end of file From 72f54dda87eabc064f6cc1fed628f1d18f7563b0 Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 6 Dec 2021 09:04:51 +0100 Subject: [PATCH 2/7] rename variables --- AnnoDesigner/AnnoCanvas.xaml.cs | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/AnnoDesigner/AnnoCanvas.xaml.cs b/AnnoDesigner/AnnoCanvas.xaml.cs index 6120bd8e..fcd2f76c 100644 --- a/AnnoDesigner/AnnoCanvas.xaml.cs +++ b/AnnoDesigner/AnnoCanvas.xaml.cs @@ -572,16 +572,16 @@ public double LinePenThickness /// private readonly SolidColorBrush _debugBrushLight; - private bool debugModeIsEnabled = false; - private readonly bool debugShowObjectPositions = true; - private readonly bool debugShowQuadTreeViz = true; - private readonly bool debugShowSelectionRectCoordinates = true; - private readonly bool debugShowSelectionCollisionRect = true; - private readonly bool debugShowViewportRectCoordinates = true; - private readonly bool debugShowScrollableRectCoordinates = true; - private readonly bool debugShowLayoutRectCoordinates = true; - private readonly bool debugShowMouseGridCoordinates = true; - private readonly bool debugShowObjectCount = true; + private bool _debugModeIsEnabled = false; + private readonly bool _debugShowObjectPositions = true; + private readonly bool _debugShowQuadTreeViz = true; + private readonly bool _debugShowSelectionRectCoordinates = true; + private readonly bool _debugShowSelectionCollisionRect = true; + private readonly bool _debugShowViewportRectCoordinates = true; + private readonly bool _debugShowScrollableRectCoordinates = true; + private readonly bool _debugShowLayoutRectCoordinates = true; + private readonly bool _debugShowMouseGridCoordinates = true; + private readonly bool _debugShowObjectCount = true; #endregion #endif @@ -1103,10 +1103,10 @@ protected override void OnRender(DrawingContext drawingContext) #region Draw debug information #if DEBUG - if (debugModeIsEnabled) + if (_debugModeIsEnabled) { drawingContext.PushTransform(_viewportTransform); - if (debugShowQuadTreeViz) + if (_debugShowQuadTreeViz) { var brush = Brushes.Transparent; var pen = _penCache.GetPen(_debugBrushDark, 2); @@ -1116,7 +1116,7 @@ protected override void OnRender(DrawingContext drawingContext) } } - if (debugShowSelectionCollisionRect) + if (_debugShowSelectionCollisionRect) { var color = _debugBrushLight.Color; color.A = 0x08; @@ -1130,7 +1130,7 @@ protected override void OnRender(DrawingContext drawingContext) drawingContext.Pop(); var debugText = new List(3); - if (debugShowViewportRectCoordinates) + if (_debugShowViewportRectCoordinates) { //The first time this is called, App.DpiScale is still 0 which causes this code to throw an error if (App.DpiScale.PixelsPerDip != 0) @@ -1148,7 +1148,7 @@ protected override void OnRender(DrawingContext drawingContext) } } - if (debugShowScrollableRectCoordinates) + if (_debugShowScrollableRectCoordinates) { //The first time this is called, App.DpiScale is still 0 which causes this code to throw an error if (App.DpiScale.PixelsPerDip != 0) @@ -1166,7 +1166,7 @@ protected override void OnRender(DrawingContext drawingContext) } } - if (debugShowLayoutRectCoordinates) + if (_debugShowLayoutRectCoordinates) { //The first time this is called, App.DpiScale is still 0 which causes this code to throw an error if (App.DpiScale.PixelsPerDip != 0) @@ -1184,7 +1184,7 @@ protected override void OnRender(DrawingContext drawingContext) } } - if (debugShowObjectCount) + if (_debugShowObjectCount) { //The first time this is called, App.DpiScale is still 0 which causes this code to throw an error if (App.DpiScale.PixelsPerDip != 0) @@ -1203,7 +1203,7 @@ protected override void OnRender(DrawingContext drawingContext) drawingContext.DrawText(debugText[i], new Point(5, (i * 15) + 5)); } - if (debugShowMouseGridCoordinates) + if (_debugShowMouseGridCoordinates) { //The first time this is called, App.DpiScale is still 0 which causes this code to throw an error if (App.DpiScale.PixelsPerDip != 0) @@ -1227,7 +1227,7 @@ protected override void OnRender(DrawingContext drawingContext) //draw selection rect coords last so they draw over the top of everything else if (CurrentMode == MouseMode.SelectionRect) { - if (debugShowSelectionRectCoordinates) + if (_debugShowSelectionRectCoordinates) { var rect = _coordinateHelper.ScreenToGrid(_selectionRect, _gridSize); var top = rect.Top; @@ -1480,7 +1480,7 @@ private void RenderObjectList(DrawingContext drawingContext, List drawingContext.DrawText(text, textLocation); } #if DEBUG - if (debugModeIsEnabled && debugShowObjectPositions) + if (_debugModeIsEnabled && _debugShowObjectPositions) { var text = new FormattedText(obj.Position.ToString(), Thread.CurrentThread.CurrentCulture, FlowDirection.LeftToRight, TYPEFACE, 12, _debugBrushLight, @@ -2466,7 +2466,7 @@ protected override void OnKeyDown(KeyEventArgs e) #if DEBUG if (e.Key == Key.D && Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift)) { - debugModeIsEnabled = !debugModeIsEnabled; + _debugModeIsEnabled = !_debugModeIsEnabled; e.Handled = true; } #endif From ed7f2ae1951e38666bfb12a501ea2ada9804d8da Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 6 Dec 2021 09:32:46 +0100 Subject: [PATCH 3/7] - enable debug mode when compiling in RELEASE mode - add hotkey for enabling debug mode - add localization for hotkey --- AnnoDesigner/AnnoCanvas.xaml.cs | 31 ++++++++++++----------- AnnoDesigner/Localization/Localization.cs | 18 ++++++++----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/AnnoDesigner/AnnoCanvas.xaml.cs b/AnnoDesigner/AnnoCanvas.xaml.cs index fcd2f76c..1c34ebe6 100644 --- a/AnnoDesigner/AnnoCanvas.xaml.cs +++ b/AnnoDesigner/AnnoCanvas.xaml.cs @@ -53,6 +53,7 @@ public partial class AnnoCanvas : UserControl, IAnnoCanvas, IHotkeySource, IScro public const string DELETE_OBJECT_UNDER_CURSOR_LOCALIZATION_KEY = "DeleteObjectUnderCursor"; public const string UNDO_LOCALIZATION_KEY = "Undo"; public const string REDO_LOCALIZATION_KEY = "Redo"; + public const string ENABLE_DEBUG_MODE_LOCALIZATION_KEY = "EnableDebugMode"; public event EventHandler StatisticsUpdated; public event EventHandler ColorsInLayoutUpdated; @@ -560,7 +561,6 @@ public double LinePenThickness #endregion -#if DEBUG #region Debug options /// @@ -584,7 +584,6 @@ public double LinePenThickness private readonly bool _debugShowObjectCount = true; #endregion -#endif #region Constructor /// @@ -645,6 +644,7 @@ public AnnoCanvas(BuildingPresets presetsToUse, deleteObjectUnderCursorCommand = new RelayCommand(ExecuteDeleteObjectUnderCursor); undoCommand = new RelayCommand(ExecuteUndo); redoCommand = new RelayCommand(ExecuteRedo); + enableDebugModeCommand = new RelayCommand(ExecuteEnableDebugMode); //Set up default keybindings @@ -680,6 +680,9 @@ public AnnoCanvas(BuildingPresets presetsToUse, var redoBinding = new InputBinding(redoCommand, new PolyGesture(Key.Y, ModifierKeys.Control)); redoHotkey = new Hotkey(REDO_LOCALIZATION_KEY, redoBinding, REDO_LOCALIZATION_KEY); + var enableDebugModeBinding = new InputBinding(enableDebugModeCommand, new PolyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)); + enableDebugModeHotkey = new Hotkey(ENABLE_DEBUG_MODE_LOCALIZATION_KEY, enableDebugModeBinding, ENABLE_DEBUG_MODE_LOCALIZATION_KEY); + //We specifically do not add the `InputBinding`s to the `InputBindingCollection` of `AnnoCanvas`, as if we did that, //`InputBinding.Gesture.Matches()` would be fired for *every* event - MouseWheel, MouseDown, KeyUp, KeyDown, MouseMove etc //which we don't want, as it produces a noticeable performance impact. @@ -698,10 +701,8 @@ public AnnoCanvas(BuildingPresets presetsToUse, color = Colors.LawnGreen; color.A = 32; _influencedBrush = _brushCache.GetSolidBrush(color); -#if DEBUG _debugBrushLight = Brushes.Blue; _debugBrushDark = Brushes.DarkBlue; -#endif sw.Stop(); logger.Trace($"init variables took: {sw.ElapsedMilliseconds}ms"); @@ -1102,7 +1103,6 @@ protected override void OnRender(DrawingContext drawingContext) #region Draw debug information -#if DEBUG if (_debugModeIsEnabled) { drawingContext.PushTransform(_viewportTransform); @@ -1247,7 +1247,6 @@ protected override void OnRender(DrawingContext drawingContext) } } } -#endif #endregion @@ -1479,7 +1478,7 @@ private void RenderObjectList(DrawingContext drawingContext, List drawingContext.DrawText(text, textLocation); } -#if DEBUG + if (_debugModeIsEnabled && _debugShowObjectPositions) { var text = new FormattedText(obj.Position.ToString(), Thread.CurrentThread.CurrentCulture, FlowDirection.LeftToRight, @@ -1496,7 +1495,6 @@ private void RenderObjectList(DrawingContext drawingContext, List drawingContext.DrawText(text, textLocation); } -#endif } } @@ -2463,13 +2461,7 @@ protected override void OnKeyDown(KeyEventArgs e) //When an InputBinding is added to the InputBindingsCollection, the `Matches` method is fired for every event - KeyUp, //KeyDown, MouseUp, MouseMove, MouseWheel etc. HotkeyCommandManager.HandleCommand(e); -#if DEBUG - if (e.Key == Key.D && Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift)) - { - _debugModeIsEnabled = !_debugModeIsEnabled; - e.Handled = true; - } -#endif + if (e.Handled) { InvalidateVisual(); @@ -2709,6 +2701,7 @@ public void RegisterHotkeys(HotkeyCommandManager manager) manager.AddHotkey(deleteObjectUnderCursorHotkey); manager.AddHotkey(undoHotkey); manager.AddHotkey(redoHotkey); + manager.AddHotkey(enableDebugModeHotkey); } #endregion @@ -3036,6 +3029,14 @@ private void ExecuteRedo(object param) StatisticsUpdated?.Invoke(this, UpdateStatisticsEventArgs.All); } + private readonly Hotkey enableDebugModeHotkey; + private readonly ICommand enableDebugModeCommand; + private void ExecuteEnableDebugMode(object param) + { + _debugModeIsEnabled = !_debugModeIsEnabled; + ForceRendering(); + } + #endregion #region Helper methods diff --git a/AnnoDesigner/Localization/Localization.cs b/AnnoDesigner/Localization/Localization.cs index c17e1c3f..4bb18e0d 100644 --- a/AnnoDesigner/Localization/Localization.cs +++ b/AnnoDesigner/Localization/Localization.cs @@ -250,7 +250,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Show Panorama", ["GeneralPreferencesRecentFilesSettings"] = "Recent Files Settings", ["GeneralPreferencesMaxRecentFiles"] = "Maximum Recent Files", - ["Clear"] = "Clear" + ["Clear"] = "Clear", + ["EnableDebugMode"] = "Enable Debug Mode" }, ["ger"] = new Dictionary() { @@ -448,7 +449,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Panorama zeigen", ["GeneralPreferencesRecentFilesSettings"] = "Zuletzt geöffnete Dateien", ["GeneralPreferencesMaxRecentFiles"] = "maximale Anzahl Dateien", - ["Clear"] = "Leeren" + ["Clear"] = "Leeren", + ["EnableDebugMode"] = "Debugmodus aktivieren" }, ["fra"] = new Dictionary() { @@ -646,7 +648,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Montrer panorama", ["GeneralPreferencesRecentFilesSettings"] = "Fichiers récents", ["GeneralPreferencesMaxRecentFiles"] = "Nombre maximal de fichiers", - ["Clear"] = "Supprimer" + ["Clear"] = "Supprimer", + ["EnableDebugMode"] = "Activer le mode débogage" }, ["esp"] = new Dictionary() { @@ -844,7 +847,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Mostrar panorama", ["GeneralPreferencesRecentFilesSettings"] = "Archivos recientes", ["GeneralPreferencesMaxRecentFiles"] = "Número máximo de archivos", - ["Clear"] = "Eliminar" + ["Clear"] = "Eliminar", + ["EnableDebugMode"] = "Activar el modo de depuración" }, ["pol"] = new Dictionary() { @@ -1042,7 +1046,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Pokaż panoramę", ["GeneralPreferencesRecentFilesSettings"] = "Ostatnie akta", ["GeneralPreferencesMaxRecentFiles"] = "Maksymalna liczba plików", - ["Clear"] = "Skreślić" + ["Clear"] = "Skreślić", + ["EnableDebugMode"] = "Włącz tryb debugowania" }, ["rus"] = new Dictionary() { @@ -1240,7 +1245,8 @@ public static void Init(ICommons commons) ["ShowPanorama"] = "Показать панораму", ["GeneralPreferencesRecentFilesSettings"] = "Последние Файлы", ["GeneralPreferencesMaxRecentFiles"] = "Максимальное количество файлов", - ["Clear"] = "Удалить" + ["Clear"] = "Удалить", + ["EnableDebugMode"] = "Включить режим отладки" }, }; From ef2a6ac8b4a62bd0ab9075037dd342c937763d7d Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 6 Dec 2021 09:48:25 +0100 Subject: [PATCH 4/7] add documentation --- doc/Enable_DebugMode.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 doc/Enable_DebugMode.md diff --git a/doc/Enable_DebugMode.md b/doc/Enable_DebugMode.md new file mode 100644 index 00000000..351f2df0 --- /dev/null +++ b/doc/Enable_DebugMode.md @@ -0,0 +1,20 @@ +# Enable `DebugMode` + +## General information + +For further investigation of issues, it is possible to activate a `DebugMode`. + +## How to enable/disable + +The default Hotkey to enable/disable `DebugMode` is `CTRL + Shift + D`.
+You can change the Hotkey via `Tools -> Preferences -> Manage Keybindings` menu. + +## Supported features of + +- display coordinates of current Viewport +- display coordinates of current scrollable area +- display coordinates and bounding box of current layout +- display helper lines of `QuadTree` +- display coordinates of objects (on each object) +- display count of placed objects +- display coordinates of mouse cursor (on mouse cursor) From e7094278a4791d7adc9de5d9daa575676bf4da99 Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 6 Dec 2021 09:51:45 +0100 Subject: [PATCH 5/7] - fix release mode - update documentation --- AnnoDesigner.Core/DataStructures/QuadTree.cs | 2 -- doc/Enable_DebugMode.md | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/AnnoDesigner.Core/DataStructures/QuadTree.cs b/AnnoDesigner.Core/DataStructures/QuadTree.cs index ab12863d..4bb2b11d 100644 --- a/AnnoDesigner.Core/DataStructures/QuadTree.cs +++ b/AnnoDesigner.Core/DataStructures/QuadTree.cs @@ -546,7 +546,6 @@ public void AddRange(IEnumerable collection) } } -#if DEBUG /// /// Retrieves a list of Rects that make up the Quadrants in this QuadTree. /// Used when debugging to draw the QuadTree quadrants to a canvas. @@ -556,6 +555,5 @@ public IEnumerable GetQuadrantRects() { return root.GetQuadrantRects(); } -#endif } } diff --git a/doc/Enable_DebugMode.md b/doc/Enable_DebugMode.md index 351f2df0..f5f53fd0 100644 --- a/doc/Enable_DebugMode.md +++ b/doc/Enable_DebugMode.md @@ -14,6 +14,7 @@ You can change the Hotkey via `Tools -> Preferences -> Manage Keybindings` menu. - display coordinates of current Viewport - display coordinates of current scrollable area - display coordinates and bounding box of current layout +- display collision rectangle of current selection - display helper lines of `QuadTree` - display coordinates of objects (on each object) - display count of placed objects From c422d762658d534260bade002920715d628f308b Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 6 Dec 2021 09:53:01 +0100 Subject: [PATCH 6/7] fix RELEASE mode --- AnnoDesigner.Core/DataStructures/QuadTree.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/AnnoDesigner.Core/DataStructures/QuadTree.cs b/AnnoDesigner.Core/DataStructures/QuadTree.cs index 4bb2b11d..0c6d10cb 100644 --- a/AnnoDesigner.Core/DataStructures/QuadTree.cs +++ b/AnnoDesigner.Core/DataStructures/QuadTree.cs @@ -335,7 +335,6 @@ public Quadrant GetContainingQuadrant(Rect bounds) return null; } -#if DEBUG /// /// Retrieves a list of Rects that make up this quadrant and the quadrants beneath it. /// Used when debugging to draw quadrants to a canvas. @@ -377,7 +376,6 @@ public IEnumerable GetQuadrantRects() } } } -#endif } /// From 1cfd4754678fe44a51005d9cb7ca7a5eae055deb Mon Sep 17 00:00:00 2001 From: FroggieFrog Date: Mon, 17 Jan 2022 08:55:53 +0100 Subject: [PATCH 7/7] fix documentation --- doc/Enable_DebugMode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Enable_DebugMode.md b/doc/Enable_DebugMode.md index f5f53fd0..e099635d 100644 --- a/doc/Enable_DebugMode.md +++ b/doc/Enable_DebugMode.md @@ -9,7 +9,7 @@ For further investigation of issues, it is possible to activate a `DebugMode`. The default Hotkey to enable/disable `DebugMode` is `CTRL + Shift + D`.
You can change the Hotkey via `Tools -> Preferences -> Manage Keybindings` menu. -## Supported features of +## Supported features of `DebugMode` - display coordinates of current Viewport - display coordinates of current scrollable area