Small bugfixes

This commit is contained in:
Dummerle 2020-12-14 20:25:02 +01:00
parent 2c266675b8
commit 90f2ab5e90

View file

@ -362,8 +362,11 @@ class LegendaryCLI:
if '%' in save_path or '{' in save_path: if '%' in save_path or '{' in save_path:
logger.warning('Path contains unprocessed variables, Do you want to import them automatically') logger.warning('Path contains unprocessed variables')
if get_boolean_choice("Path contains variables, Do you want to import it automatically"): if get_boolean_choice("Path contains variables, Do you want to import it automatically"):
# Import automatically
# find Wineprefix
if igame.app_name in self.core.lgd.config.sections() and "wine_prefix" in self.core.lgd.config[ if igame.app_name in self.core.lgd.config.sections() and "wine_prefix" in self.core.lgd.config[
igame.app_name]: igame.app_name]:
wine_prefix = self.core.lgd.config.get(igame.app_name, "wine_prefix") wine_prefix = self.core.lgd.config.get(igame.app_name, "wine_prefix")
@ -375,27 +378,30 @@ class LegendaryCLI:
if len(save_path.split("%")) > 3: if len(save_path.split("%")) > 3:
logger.warning("Path has more than two Variables. It is not supported yet") logger.warning("Path has more than two Variables. It is not supported yet")
return return
# Environment variable
var = save_path.split("%")[1] var = save_path.split("%")[1]
if var == "APPDATA": if var == "APPDATA":
for i in open(os.path.join(wine_prefix, "user.reg")): with open(os.path.join(wine_prefix, "user.reg")) as reg_file:
if i.startswith("\"AppData\"="): for i in reg_file:
appdata_path = i.split("=")[1] if i.startswith("\"AppData\"="):
appdata_path = appdata_path.replace("\\\\", "/").replace("C:", "").replace("\"","").replace("\n", "") appdata_path = i.split("=")[1]
break appdata_path = appdata_path.replace("\\\\", "/").replace("C:", "").replace("\"",
"").replace(
"\n", "")
break
else: else:
logger.error("No Appdata found in user.reg") logger.error("No Appdata found in user.reg")
return return
else: else:
logger.warning(f"Variable {var} not supported") logger.warning(f"Variable {var} not supported")
return return
save_path = save_path.split("%")[2] save_path = save_path.split("%")[2]
save_path = wine_prefix + "/drive_c" + appdata_path + save_path save_path = wine_prefix + "/drive_c" + appdata_path + save_path
# idk. this doesn't work # this doesn't work. Idk
# save_path = os.path.join(wine_prefix, "drive_c", appdata_path, save_path) # save_path = os.path.join(wine_prefix, "drive_c", appdata_path, save_path)
logger.info("Savepath: " + save_path) logger.info("Savepath: " + save_path)