diff --git a/dread_editor/level_data_sr.py b/dread_editor/level_data_sr.py index 7abe338..a0a1684 100644 --- a/dread_editor/level_data_sr.py +++ b/dread_editor/level_data_sr.py @@ -101,14 +101,13 @@ def open_actor_link(self, link: str): print(actor) self.visible_actors[(layer_name, actor.sName)] = True - def render_actor_context_menu(self, layer_name: str, actor): + def render_actor_context_menu(self, layer_index: int, actor): if self.copy_actor_name is None: self.copy_actor_name = f"{actor.sName}_Copy" if imgui.button("Duplicate Actor"): new_actor = copy.deepcopy(actor) - new_actor.sName = self.copy_actor_name - self.add_new_actor(layer_name, new_actor) + self.add_new_actor(layer_index, new_actor, self.copy_actor_name) imgui.close_current_popup() self.copy_actor_name = None @@ -121,18 +120,20 @@ def render_actor_context_menu(self, layer_name: str, actor): imgui.text("Position:") imgui.same_line() - changed_x, x = imgui.slider_float("##actor-context-position-x", actor.vPos[0], + changed_x, x = imgui.slider_float("##actor-context-position-x", actor.x, self.display_borders["left"], self.display_borders["right"]) imgui.same_line() - changed_y, y = imgui.slider_float("##actor-context-position-y", actor.vPos[1], + changed_y, y = imgui.slider_float("##actor-context-position-y", actor.y, self.display_borders["top"], self.display_borders["bottom"]) - if changed_x or changed_y: - actor.vPos = (x, y, actor.vPos[2]) + if changed_x: + actor.x = x + if changed_y: + actor.y = y - def add_new_actor(self, layer_name: str, actor): + def add_new_actor(self, layer_index: int, actor, actor_name: str): if actor is not None: - self.bmsld.actors_for_layer(layer_name)[actor.sName] = actor - self.visible_actors[(layer_name, actor.sName)] = True + self.bmsld.raw.actors[layer_index][actor_name] = actor + self.visible_actors[(str(layer_index), actor_name)] = True def render_window(self, current_scale): imgui.set_next_window_size(900 * current_scale, 300 * current_scale, imgui.FIRST_USE_EVER) @@ -168,7 +169,7 @@ def color_for_layer(name: str): if imgui_util.colored_tree_node(layer_name, color_for_layer(layer_name)): actors = self.bmsld.raw.actors[int(layer_name)] - for actor_name, actor in actors.items(): + for actor_name, actor in sorted(actors.items(), key=lambda it: it[0]): key = (layer_name, actor_name) if not self.actor_filter.passes(actor): continue @@ -188,7 +189,7 @@ def do_item(): highlighted_actors_in_list.add(key) if imgui.begin_popup_context_item(): - self.render_actor_context_menu(layer_name, actor) + self.render_actor_context_menu(layer_index, actor) imgui.end_popup() imgui.tree_pop() @@ -339,9 +340,9 @@ def draw_visible_actors(self, current_scale: float): with imgui_util.with_child("##ActorGroups", 0, 300 * current_scale, imgui.WINDOW_ALWAYS_VERTICAL_SCROLLBAR): - for group_name in sorted(self.bmsld.all_actor_groups()): + for group_name, group in sorted(self.bmsld.all_actor_groups()): changed, present = imgui.checkbox(f"{group_name} ##actor_group.{group_name}", - self.bmsld.is_actor_in_group(group_name, actor_name, layer_name)) + self.bmsld.is_actor_in_group(group_name, actor_name)) # if changed: # if present: # self.bmsld.add_actor_to_group(group_name, actor_name, layer_name) diff --git a/dread_editor/main_loop.py b/dread_editor/main_loop.py index 3471779..76adb5e 100644 --- a/dread_editor/main_loop.py +++ b/dread_editor/main_loop.py @@ -223,11 +223,13 @@ def load_romfs(path: Path): if imgui.menu_item("Select extracted Metroid Dread root")[0]: f = prompt_file(directory=True) if f: + current_level_data = None current_game = Game.DREAD load_romfs(Path(f)) if imgui.menu_item("Select extracted Samus Returns root")[0]: f = prompt_file(directory=True) if f: + current_level_data = None current_game = Game.SAMUS_RETURNS load_romfs(Path(f)) @@ -250,7 +252,7 @@ def load_romfs(path: Path): f = prompt_file(directory=True) if f: - pkg_editor.save_modifications(Path(f), OutputFormat.PKG) + pkg_editor.save_modifications(Path(f), OutputFormat.PKG, finalize_editor=False) imgui.end_menu() diff --git a/requirements.txt b/requirements.txt index 9b9d218..72dcfe7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ construct==2.10.68 -glfw==2.5.9 -imgui==1.4.1 -mercury-engine-data-structures==0.22.0 -PyOpenGL==3.1.6 +glfw==2.6.2 +imgui==2.0.0 +mercury-engine-data-structures==0.24.0 +PyOpenGL==3.1.7 diff --git a/setup.cfg b/setup.cfg index 3e318d6..e77fe4b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,12 +18,12 @@ classifiers = [options] packages = find: install_requires = - mercury-engine-data-structures>=0.16.0 + mercury-engine-data-structures>=0.24.0 imgui[glfw] include_package_data = True zip_safe = False -python_requires = >=3.9 +python_requires = >=3.11 [options.packages.find] exclude =