Skip to content

Commit

Permalink
Right click function on spawn buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercd committed Jul 27, 2024
1 parent d7370a1 commit 0851f47
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 1 deletion.
15 changes: 15 additions & 0 deletions component-explorer/spawn_stuff/creatures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -212,6 +222,11 @@ return function()
end
end

if imgui.BeginPopupContextItem() then
popup_contents(c)
imgui.EndPopup()
end

imgui.PopID()
end
end
Expand Down
15 changes: 15 additions & 0 deletions component-explorer/spawn_stuff/items.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions component-explorer/spawn_stuff/materials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -177,6 +187,11 @@ return function()
end
end

if imgui.BeginPopupContextItem() then
popup_contents(mat)
imgui.EndPopup()
end

imgui.PopID()
end
end
Expand Down
15 changes: 15 additions & 0 deletions component-explorer/spawn_stuff/perks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion component-explorer/spawn_stuff/props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions component-explorer/spawn_stuff/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0851f47

Please sign in to comment.