Add gamePath setting, add variable support to config

This commit is contained in:
Fierelier 2021-03-28 03:28:03 +02:00
parent 974fe83ad3
commit 93eec0f129
2 changed files with 17 additions and 7 deletions

View File

@ -8,6 +8,9 @@ jvmArguments=["-Xms128M","-Xmx800M"]
# Enable/disable console.
console=1
# Where is the game located?
gamePath=$+sp$
# Override the OS name. Choose windows, linux or macos, if the detection doesn't work right.
osName=

View File

@ -32,9 +32,17 @@ def readJsonFile(file):
def main():
config = configparser.ConfigParser()
config.read(os.path.splitext(s)[0] + ".ini")
os.environ["appdata"] = p(sp,"appdata")
lv = config["default"]
for var in lv:
glbs = globals()
for glb in glbs:
lv[var] = lv[var].replace("$+" +glb+ "$",str(glbs[glb]))
lcs = locals()
for lc in lcs:
lv[var] = lv[var].replace("$" +lc+ "$",str(lcs[lc]))
if lv["osName"] == "":
lv["osName"] = platform.system().lower()
if lv["osName"] == "darwin": lv["osName"] = "macos"
@ -54,12 +62,11 @@ def main():
if not "version" in lv: lv["version"] = input("Version ID: ")
if not "name" in lv: lv["name"] = input("Player name: ")
gamePath = p(os.environ["appdata"],".minecraft")
versionPath = p(gamePath,"versions",lv["version"])
libraryPath = p(gamePath,"libraries")
nativesPath = p(gamePath,"natives")
versionPath = p(lv["gamePath"],"versions",lv["version"])
libraryPath = p(lv["gamePath"],"libraries")
nativesPath = p(lv["gamePath"],"natives")
nativesOutPath = p(versionPath,"natives-" +lv["osName"])
assetsPath = p(gamePath,"assets")
assetsPath = p(lv["gamePath"],"assets")
print("Extracting natives...")
clientJson = readJsonFile(p(versionPath,lv["version"] + ".json"))
@ -84,7 +91,7 @@ def main():
launcherVariables = {}
launcherVariables["auth_player_name"] = lv["name"]
launcherVariables["version_name"] = lv["version"]
launcherVariables["game_directory"] = gamePath
launcherVariables["game_directory"] = lv["gamePath"]
launcherVariables["assets_root"] = assetsPath
launcherVariables["assets_index_name"] = clientJson["assets"]
launcherVariables["auth_access_token"] = "-"