Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 15 additions & 23 deletions Intersect.Editor/Forms/DockingElements/frmMapEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Intersect.Logging;
using Microsoft.Xna.Framework.Graphics;
using WeifenLuo.WinFormsUI.Docking;
using Timer = System.Windows.Forms.Timer;

namespace Intersect.Editor.Forms.DockingElements;

Expand All @@ -36,9 +35,6 @@ public partial class FrmMapEditor : DockContent

private bool mMapChanged;

// MapGrid Cursor
private Timer cursorUpdateTimer;

public struct IconInfo
{
public bool FIcon;
Expand Down Expand Up @@ -68,11 +64,13 @@ public FrmMapEditor()
InitializeComponent();
Icon = Program.Icon;
picMap.MouseLeave += (_sender, _args) => tooltipMapAttribute?.Hide();
// Initialize cursor timer
cursorUpdateTimer = new Timer();
cursorUpdateTimer.Interval = 200;
cursorUpdateTimer.Tick += CursorUpdateTimer_Tick;
cursorUpdateTimer.Start();

Globals.ToolChanged += Globals_ToolChanged;
}

private void Globals_ToolChanged(object? sender, EventArgs e)
{
SetCursorSpriteInGrid();
}

private void InitLocalization()
Expand Down Expand Up @@ -2348,30 +2346,24 @@ private void pnlMapContainer_Resize(object sender, EventArgs e)

private void picMap_MouseEnter(object sender, EventArgs e)
{
if (!Globals.MapEditorWindow.DockPanel.Focused && Globals.CurrentEditor == -1)
if (Globals.EditingLight != null || Globals.CurrentEditor != -1)
{
RemoveSpriteCursorInGrid();
return;
}

if (!Globals.MapEditorWindow.DockPanel.Focused)
{
Globals.MapEditorWindow.DockPanel.Focus();
}

RemoveSpriteCursorInGrid();
SetCursorSpriteInGrid();
}

private void picMap_MouseLeave(object sender, EventArgs e)
{
RemoveSpriteCursorInGrid();
}

private void CursorUpdateTimer_Tick(object sender, EventArgs e)
{
if (Globals.EditingLight != null || Globals.CurrentEditor != -1 ||
!Globals.MapEditorWindow.DockPanel.Focused)
{
return;
}

SetCursorSpriteInGrid();
}

private void SetCursorSpriteInGrid()
{
if (!Preferences.EnableCursorSprites)
Expand Down
17 changes: 16 additions & 1 deletion Intersect.Editor/General/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ public static partial class Globals

public static TilesetBase CurrentTileset = null;

public static EditingTool CurrentTool = EditingTool.Brush;
public static EditingTool _currentTool = EditingTool.Brush;

public static event EventHandler<EventArgs> ToolChanged;
public static EditingTool CurrentTool
{
get { return _currentTool; }
set
{
_currentTool = value;
OnToolChanged(new EventArgs());
}
}
static void OnToolChanged(EventArgs e)
{
ToolChanged?.Invoke(null, e);
}

public static int CurSelH;

Expand Down
Loading