Skip to content

Commit

Permalink
Stop losing room name's nullability.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaythebusinessgoose authored and gmjosack committed Dec 18, 2023
1 parent 68df7ae commit 5d42e8b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/modlunky2/ui/levels/vanilla_levels/levels_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def duplicate(self):
item_index = self.index(item_iid)
parent_index = self.index(parent_iid)
new_room = self.on_duplicate_room(parent_index, item_index)
self.insert(parent_iid, "end", text=new_room.name)
self.insert(parent_iid, "end", text=new_room.name or "room")

def copy(self):
item_iid = self.selection()[0]
Expand All @@ -109,7 +109,7 @@ def paste(self):
item_index = self.index(parent_iid)
item_iid = parent_iid
new_room = self.on_paste_room(item_index)
self.insert(item_iid, "end", text=new_room.name)
self.insert(item_iid, "end", text=new_room.name or "room")

def delete_selected(self):
item_iid = self.selection()[0]
Expand Down Expand Up @@ -145,7 +145,7 @@ def add_room(self):
return

new_room = self.on_add_room(self.index(parent))
self.insert(parent, "end", text=new_room.name)
self.insert(parent, "end", text=new_room.name or "room")

def rename_dialog(self):
item_iid = self.selection()[0]
Expand Down Expand Up @@ -211,7 +211,7 @@ def set_rooms(self, rooms):
room_display_name += " // " + room.comment
entry = self.insert("", "end", text=room_display_name)
for layout in room.rooms:
self.insert(entry, "end", text=layout.name)
self.insert(entry, "end", text=layout.name or "room")

def get_selected_room(self):
selection = self.selection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ def set_current_template(self, template, map_index, row, column):
self.configure_reverse_rooms_container()
self.template_combobox.set(template.template.name)
self.room_combobox["values"] = [
room.name or "room " + (index + 1)
room.name or "room " + str(index + 1)
for index, room in enumerate(template.template.rooms)
] + ["Create New"]
self.room_combobox.set(
template.room_chunk.name or "room " + (template.room_index + 1)
template.room_chunk.name or "room " + str(template.room_index + 1)
)
self.room_combobox.current(template.room_index)
self.template_container.grid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,6 @@ def changes_made(self):
def convert_from_chunk(self, chunk):
settings = list(map(lambda setting: setting, chunk.settings))

i = 0

def map_layer(layer):
return list(map(lambda line: list(map(lambda tile: tile, line)), layer))

Expand All @@ -681,13 +679,10 @@ def map_layer(layer):
["0" for _ in range(len(row))] for row in foreground_tiles
]

room_name = "room"
comment = str(chunk.comment).lstrip("/ ").strip()
if comment:
room_name = comment

return RoomInstance(
str(room_name), settings, foreground_tiles, background_tiles
comment, settings, foreground_tiles, background_tiles
)

def convert_to_chunk(self, room_instance):
Expand Down Expand Up @@ -1186,7 +1181,7 @@ def map_layer(layer):
return [[t for t in row] for row in layer]

new_room = RoomInstance(
room_instance.name + " COPY",
(room_instance.name or "room") + " COPY",
new_settings,
map_layer(room_instance.front),
map_layer(room_instance.back),
Expand Down

0 comments on commit 5d42e8b

Please sign in to comment.