Skip to content

Commit

Permalink
Fix some relative paths in file extracting
Browse files Browse the repository at this point in the history
Also add warning so users know the BEE2 might freeze while copying over
materials/models/instances
  • Loading branch information
TeamSpen210 committed May 22, 2015
1 parent 75dcad8 commit 03aecd7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/gameMan.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
# The source and desination locations of resources that must be copied
# into the game folder.
CACHE_LOC = [
('inst_cache/', 'sdk_content/maps/instances/BEE2'),
('source_cache/', 'BEE2/'),
('packrat/', 'bin/bee2'),
('../inst_cache/', 'sdk_content/maps/instances/BEE2'),
('../source_cache/', 'BEE2/'),
('../packrat/', 'bin/bee2'),
]

# The line we inject to add our BEE2 folder into the game search path.
Expand Down Expand Up @@ -142,7 +142,7 @@ def edit_gameinfo(self, add_line=False):
with open(info_path) as file:
data = list(file)

for line_num, line in reversed(enumerate(data)):
for line_num, line in reversed(list(enumerate(data))):
clean_line = utils.clean_line(line)
if add_line:
if clean_line == GAMEINFO_LINE:
Expand Down Expand Up @@ -181,13 +181,23 @@ def edit_gameinfo(self, add_line=False):
for name, file, ext in FILES_TO_BACKUP:
item_path = self.abs_path(file + ext)
backup_path = self.abs_path(file + '_original' + ext)
if os.path.isfile(backup_path):
old_version = self.abs_path(file + '_styles' + ext)
if os.path.isfile(old_version):
print("Restoring Stylechanger version of " + name + "!")
shutil.copy(old_version, item_path)
elif os.path.isfile(backup_path):
print("Restoring original " + name + "!")
shutil.move(backup_path, item_path)
self.clear_cache()

def refresh_cache(self):
"""Copy over the resource files into this game."""
messagebox.showinfo(
message='Now copying over resources. The BEE2 may be non-responsive'
' for a few seconds',
parent=TK_ROOT,
title='BEE2 - Exporting',
)
for source, dest in CACHE_LOC:
dest = self.abs_path(dest)
print('Copying to "' + dest + '" ...', end='')
Expand All @@ -199,7 +209,7 @@ def refresh_cache(self):
shutil.copytree(source, dest)
print(' Done!')
print('Copying PakRat...', end='')
shutil.copy('pakrat.jar', self.abs_path('bin/bee2/pakrat.jar'))
shutil.copy('../pakrat.jar', self.abs_path('bin/bee2/pakrat.jar'))
print(' Done!')

def clear_cache(self):
Expand All @@ -209,7 +219,7 @@ def clear_cache(self):
shutil.rmtree(self.abs_path(dest))
except (IOError, shutil.Error):
pass
shutil.rmtree(self.abs_path('bin/bee2/'))
shutil.rmtree(self.abs_path('bin/bee2/'), ignore_errors=True)

def export(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/query_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class StringDialog(simpledialog._QueryString):
def body(self, master):
super().body(master)
self.iconbitmap('BEE2.ico')
self.iconbitmap('../BEE2.ico')


def ask_string(title, prompt, **kargs):
Expand Down

0 comments on commit 03aecd7

Please sign in to comment.