Skip to content

Commit

Permalink
fix editor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aimoonchen committed Jan 20, 2024
1 parent 4f981ec commit d9b7f89
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
3 changes: 3 additions & 0 deletions tools/editor/pkg/tools.editor/prefab_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,9 @@ function m:find_patch_index(node_idx)
end

function m:pacth_remove(eid)
if not self.current_prefab then
return true
end
local name = hierarchy:get_node_info(eid).template.tag[1]
self.current_prefab.tag[name] = nil
self:update_tag_list()
Expand Down
2 changes: 1 addition & 1 deletion tools/editor/pkg/tools.editor/widget/base_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local math3d = require "math3d"
local uiproperty = require "widget.uiproperty"
local hierarchy = require "hierarchy_edit"
local BaseView = {}
local render_layer_name = {"foreground", "opacity", "background", "translucent", "decal_stage", "ui_stage"}
local render_layer_name = {"foreground", "opacity", "background", "translucent", "decal", "ui"}
function BaseView:_init()
if self.inited then
return
Expand Down
18 changes: 10 additions & 8 deletions tools/editor/pkg/tools.editor/widget/project_setting_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local ps = {
}

local function read_file(p)
local f <close> = assert(io.open(p:string()))
local f <close> = assert(io.open(p))
return f:read "a"
end

Expand Down Expand Up @@ -266,14 +266,16 @@ function ps.show(open_popup)
if BeginPopupModal(ps.id, default_win_flags) then
if BeginTabBar("PS_Bar", default_tab_flags) then
if BeginTabItem "ProjectSetting" then
local p = global_data.project_root / "settings"

local s = project_settings[p:string()]
if s == nil then
s = datalist.parse(read_file(p))
project_settings[p:string()] = s
if global_data.project_root then
local p = global_data.project_root / "settings"
-- local p = "/pkg/ant.settings/default/graphic_settings.ant"
local s = project_settings[p]
if s == nil then
s = datalist.parse(read_file(p))
project_settings[p] = s
end
setting_ui(s)
end
setting_ui(s)
EndTabItem()
end
EndTabBar()
Expand Down
59 changes: 32 additions & 27 deletions tools/editor/pkg/tools.editor/widget/scene_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,36 @@ local function as_main_camera_mode()
return mq.camera_ref == sv.camera_ref
end

local function can_delete(eid)
local info = hierarchy:get_node_info(eid)
-- TODO: cant't remove root node : Scene
if (info.template.tag and info.template.tag[1] == "Scene") then
return false
end
local can_delete = true
if as_main_camera_mode() then
local e <close> = world:entity(eid, "camera?in")
if e.camera then
can_delete = false
else
local children = hierarchy:get_node(eid).children
if #children > 0 then
--TODO: for camera
local ce <close> = world:entity(children[1].eid, "camera?in")
if ce.camera then
can_delete = false
end
end
end
end
return can_delete
end

local function node_context_menu(eid)
if gizmo.target_eid ~= eid then return end
if gizmo.target_eid ~= eid then
return
end

if ImGui.BeginPopupContextItem(tostring(eid)) then
local current_lock = hierarchy:is_locked(eid)
local tpl = hierarchy:get_node_info(eid)
Expand All @@ -50,25 +78,9 @@ local function node_context_menu(eid)
if ImGui.MenuItem(current_visible and faicons.ICON_FA_EYE.." Hide" or faicons.ICON_FA_EYE_SLASH.." Show") then
world:pub { "HierarchyEvent", "visible", hierarchy:get_node(eid), not current_visible }
end
ImGui.Separator()
if ImGui.MenuItem(faicons.ICON_FA_TRASH.." Delete", "Delete") then
local can_delete = true
if as_main_camera_mode() then
local e <close> = world:entity(eid, "camera?in")
if e.camera then
can_delete = false
else
local children = hierarchy:get_node(eid).children
if #children > 0 then
--TODO: for camera
local ce <close> = world:entity(children[1].eid, "camera?in")
if ce.camera then
can_delete = false
end
end
end
end
if can_delete then
if can_delete(eid) then
ImGui.Separator()
if ImGui.MenuItem(faicons.ICON_FA_TRASH.." Delete", "Delete") then
world:pub { "HierarchyEvent", "delete", eid }
end
end
Expand All @@ -83,13 +95,6 @@ local function node_context_menu(eid)
if ImGui.MenuItem("NoParent") then
world:pub { "EntityEvent", "parent", eid }
end
ImGui.Separator()
if ImGui.MenuItem("SRT Animation") then
world:pub { "CreateAnimation", "srt", eid }
end
if ImGui.MenuItem("MTL Animation") then
world:pub { "CreateAnimation", "mtl", eid }
end
ImGui.EndPopup()
end
end
Expand Down

0 comments on commit d9b7f89

Please sign in to comment.