Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Fix some parts of SR editor
  • Loading branch information
ThanatosGit committed Sep 12, 2023
1 parent f33017b commit 7c47c33
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
27 changes: 14 additions & 13 deletions dread_editor/level_data_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -341,7 +342,7 @@ def draw_visible_actors(self, current_scale: float):
imgui.WINDOW_ALWAYS_VERTICAL_SCROLLBAR):
for group_name 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)
Expand Down
4 changes: 3 additions & 1 deletion dread_editor/main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 7c47c33

Please sign in to comment.