Skip to content

Commit

Permalink
<fix> fix show error appended file(s) or directory(s) in pack game fi…
Browse files Browse the repository at this point in the history
…les function
  • Loading branch information
anonymousException committed Apr 24, 2024
1 parent 14255ea commit 9e37eb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pack_game_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def on_append_button_clicked(self):
if path.endswith('.exe'):
dir = os.path.dirname(path)
game_dir = dir + '/game'
game_dir = game_dir.replace('\\', '/')
game_dir = game_dir.strip('/').strip('\\')
item_list = []
for row in range(self.model.rowCount()):
item = self.model.item(row).data()
Expand All @@ -173,20 +175,23 @@ def on_append_button_clicked(self):
select_dirs = self.selectDirsText.toPlainText().split('\n')
for i in select_files:
i = i.replace('file:///', '')
i = i.replace('\\', '/')
i = i.strip('/').strip('\\')
if len(i) > 0 and os.path.isfile(i):
if i not in item_list:
basename = i[len(game_dir):].strip('/').strip('\\')
basename = i[len(game_dir) + 1:]
item = QStandardItem(f'{basename}')
item.setToolTip(i)
item.setData(i)
self.model.appendRow(item)
item_list.append(item)
for i in select_dirs:
i = i.replace('file:///', '')
i = i.replace('\\', '/')
i = i.strip('/').strip('\\')
if len(i) > 0 and os.path.isdir(i):
if i not in item_list:
dir_name = os.path.dirname(i)
basename = dir_name[len(game_dir):].strip('/').strip('\\')
basename = i[len(game_dir) + 1:]
item = QStandardItem(f'{basename}')
item.setToolTip(i)
item.setData(i)
Expand Down

0 comments on commit 9e37eb1

Please sign in to comment.