From 0851f47d1aa3c03c19163a5f8125468207b4bf20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dexter=20Castor=20D=C3=B6pping?= Date: Sat, 27 Jul 2024 20:09:40 +0200 Subject: [PATCH] Right click function on spawn buttons --- component-explorer/spawn_stuff/creatures.lua | 15 +++++++++++++ component-explorer/spawn_stuff/items.lua | 15 +++++++++++++ component-explorer/spawn_stuff/materials.lua | 15 +++++++++++++ component-explorer/spawn_stuff/perks.lua | 15 +++++++++++++ component-explorer/spawn_stuff/props.lua | 22 +++++++++++++++++++- component-explorer/spawn_stuff/spells.lua | 15 +++++++++++++ 6 files changed, 96 insertions(+), 1 deletion(-) diff --git a/component-explorer/spawn_stuff/creatures.lua b/component-explorer/spawn_stuff/creatures.lua index 47f8aaf..3071aa6 100644 --- a/component-explorer/spawn_stuff/creatures.lua +++ b/component-explorer/spawn_stuff/creatures.lua @@ -71,6 +71,16 @@ local function get_unique_attrs(attr) return ret end +local function popup_contents(c) + if imgui.MenuItem("Copy file path") then + imgui.SetClipboardText(c.file) + end + + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(c.display_name) + end +end + local unique_herds = get_unique_attrs("herd") local unique_origins = get_unique_attrs("origin") @@ -212,6 +222,11 @@ return function() end end + if imgui.BeginPopupContextItem() then + popup_contents(c) + imgui.EndPopup() + end + imgui.PopID() end end diff --git a/component-explorer/spawn_stuff/items.lua b/component-explorer/spawn_stuff/items.lua index 47f0134..1ab43d8 100644 --- a/component-explorer/spawn_stuff/items.lua +++ b/component-explorer/spawn_stuff/items.lua @@ -60,6 +60,16 @@ end local unique_origins = get_unique_attrs("origin") +local function popup_contents(item) + if imgui.MenuItem("Copy file path") then + imgui.SetClipboardText(item.file) + end + + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(item.display_name) + end +end + local filter_search = "" ---@type string? local filter_origin = nil @@ -143,6 +153,11 @@ return function() EntityLoad(c.file, cursor.pos()) end + if imgui.BeginPopupContextItem() then + popup_contents(c) + imgui.EndPopup() + end + imgui.PopID() end end diff --git a/component-explorer/spawn_stuff/materials.lua b/component-explorer/spawn_stuff/materials.lua index beda120..959142c 100644 --- a/component-explorer/spawn_stuff/materials.lua +++ b/component-explorer/spawn_stuff/materials.lua @@ -50,6 +50,16 @@ local function container_matinv_size(entity) return 1000 end +local function popup_contents(mat) + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(mat.name) + end + + if imgui.MenuItem("Copy display name") then + imgui.SetClipboardText(mat.display_name) + end +end + local filter_search = "" ---@type string? local filter_origin = nil @@ -177,6 +187,11 @@ return function() end end + if imgui.BeginPopupContextItem() then + popup_contents(mat) + imgui.EndPopup() + end + imgui.PopID() end end diff --git a/component-explorer/spawn_stuff/perks.lua b/component-explorer/spawn_stuff/perks.lua index 857458e..dd1fdea 100644 --- a/component-explorer/spawn_stuff/perks.lua +++ b/component-explorer/spawn_stuff/perks.lua @@ -49,6 +49,16 @@ local function player_equip_perk(perk) end end +local function popup_contents(p) + if imgui.MenuItem("Copy perk.id") then + imgui.SetClipboardText(p.id) + end + + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(p.display_name) + end +end + local filter_search = "" ---@type string? @@ -167,6 +177,11 @@ return function() if imgui.SmallButton("Equip") then player_equip_perk(perk) end end + if imgui.BeginPopupContextItem() then + popup_contents(perk) + imgui.EndPopup() + end + imgui.PopID() end end diff --git a/component-explorer/spawn_stuff/props.lua b/component-explorer/spawn_stuff/props.lua index e27a2a8..82fd0b3 100644 --- a/component-explorer/spawn_stuff/props.lua +++ b/component-explorer/spawn_stuff/props.lua @@ -32,6 +32,20 @@ local function get_unique_attrs(attr) return ret end +local function popup_contents(c) + if imgui.MenuItem("Copy file path") then + imgui.SetClipboardText(c.file) + end + + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(c.name) + end + + if c.material ~= "" and imgui.MenuItem("Copy material") then + imgui.SetClipboardText(c.material) + end +end + local unique_origins = get_unique_attrs("origin") local filter_search = "" @@ -153,7 +167,13 @@ return function() end imgui.TableNextColumn() - if imgui.SmallButton("Spawn") then + local do_spawn = imgui.SmallButton("Spawn") + if imgui.BeginPopupContextItem() then + popup_contents(c) + imgui.EndPopup() + end + + if do_spawn then local spawned_prop = EntityLoad(c.file, cursor.pos()) if imgui.IsKeyDown(imgui.Key.LeftShift) then diff --git a/component-explorer/spawn_stuff/spells.lua b/component-explorer/spawn_stuff/spells.lua index b42a56c..6454bb0 100644 --- a/component-explorer/spawn_stuff/spells.lua +++ b/component-explorer/spawn_stuff/spells.lua @@ -33,6 +33,16 @@ local function get_unique_attrs(attr) end local unique_origins = get_unique_attrs("origin") +local function popup_contents(action) + if imgui.MenuItem("Copy action.id") then + imgui.SetClipboardText(action.id) + end + + if imgui.MenuItem("Copy name") then + imgui.SetClipboardText(action.display_name) + end +end + local filter_search = "" ---@type string? local filter_origin = nil @@ -169,6 +179,11 @@ return function() CreateItemActionEntity(action.id, x, y) end + if imgui.BeginPopupContextItem() then + popup_contents(action) + imgui.EndPopup() + end + imgui.PopID() end end