Skip to content

Commit

Permalink
cursor clicking through UI fix
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Dec 17, 2023
1 parent c90a061 commit 30aa84a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Murder.Editor/CustomEditors/WorldAssetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected override void InitializeStage(Stage stage, Guid guid)

public override IEntity? SelectedEntity => _world is null ? null : _openedEntity;

float _entitiesEditorSize = 100;
float _entitiesEditorSize = 300;
float _entitiesPickerSize = 200;
float _entityInspectorSize = -1;

Expand Down Expand Up @@ -109,7 +109,7 @@ public override void DrawEditor()
{
ImGui.BeginChild("world_tab_container", new System.Numerics.Vector2(-1, -1), ImGuiChildFlags.None, ImGuiWindowFlags.NoResize);

ImGuiHelpers.DrawSplitter("##splitter_world_tab_1", true, 8, ref _entitiesEditorSize, 100);
ImGuiHelpers.DrawSplitter("##splitter_world_tab_1", true, 8, ref _entitiesEditorSize, 200);

// == Entities editor ==
ImGui.BeginChild("Entities Editor", new Vector2(-1, _entitiesEditorSize), ImGuiChildFlags.None);
Expand Down
6 changes: 5 additions & 1 deletion src/Murder.Editor/Stage/Stage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ public void Draw(Rectangle? rectToDrawStage = null)
ImGui.InvisibleButton("map_canvas", ImGui.GetContentRegionAvail() - new Vector2(0, 5));
if (ImGui.IsItemHovered())
{
Architect.Input.MouseConsumed = false;
EditorHook.UsingGui = false;
}
else
{
EditorHook.UsingGui = true;
}

Vector2 topLeft = rectToDrawStage?.TopLeft ?? ImGui.GetItemRectMin();
Expand Down
2 changes: 1 addition & 1 deletion src/Murder.Editor/Systems/GenericSelectorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void DrawGuiImpl(World world, ImmutableArray<Entity> entities)
public void Update(World world, ImmutableArray<Entity> entities, bool clearOnlyWhenSelectedNewEntity = false)
{
EditorHook hook = world.GetUnique<EditorComponent>().EditorHook;
if (hook.UsingCursor)
if (hook.UsingCursor || hook.UsingGui)
// Someone else is using our cursor, let's wait out turn.
{
_startedGroupInWorld = null;
Expand Down
9 changes: 9 additions & 0 deletions src/Murder.Editor/Systems/TileEditorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Murder.Editor.Components;
using Murder.Editor.EditorCore;
using Murder.Editor.Services;
using Murder.Editor.Utilities;
using Murder.Services;
using Murder.Utilities;
using System.Numerics;
Expand All @@ -35,6 +36,14 @@ public void Draw(RenderContext render, Context context)
return;
}

EditorHook hook = context.World.GetUnique<EditorComponent>().EditorHook;
if (hook.UsingCursor || hook.UsingGui)
// Someone else is using our cursor, let's wait out turn.
{
return;
}


// Whether the cursor if within or interacting with any of the rooms.
bool isCursorWithin = false;
foreach (Entity e in context.Entities)
Expand Down
1 change: 1 addition & 0 deletions src/Murder.Editor/Utilities/Stage/EditorHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum ShowQuadTree
Pathfind
}

public bool UsingGui = false;
public bool UsingCursor = false;
public bool IsPopupOpen = false;

Expand Down

0 comments on commit 30aa84a

Please sign in to comment.