Add gamePath setting, add variable support to config
This commit is contained in:
parent
974fe83ad3
commit
93eec0f129
@ -8,6 +8,9 @@ jvmArguments=["-Xms128M","-Xmx800M"]
|
|||||||
# Enable/disable console.
|
# Enable/disable console.
|
||||||
console=1
|
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.
|
# Override the OS name. Choose windows, linux or macos, if the detection doesn't work right.
|
||||||
osName=
|
osName=
|
||||||
|
|
||||||
|
@ -32,9 +32,17 @@ def readJsonFile(file):
|
|||||||
def main():
|
def main():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(os.path.splitext(s)[0] + ".ini")
|
config.read(os.path.splitext(s)[0] + ".ini")
|
||||||
os.environ["appdata"] = p(sp,"appdata")
|
|
||||||
|
|
||||||
lv = config["default"]
|
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"] == "":
|
if lv["osName"] == "":
|
||||||
lv["osName"] = platform.system().lower()
|
lv["osName"] = platform.system().lower()
|
||||||
if lv["osName"] == "darwin": lv["osName"] = "macos"
|
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 "version" in lv: lv["version"] = input("Version ID: ")
|
||||||
if not "name" in lv: lv["name"] = input("Player name: ")
|
if not "name" in lv: lv["name"] = input("Player name: ")
|
||||||
|
|
||||||
gamePath = p(os.environ["appdata"],".minecraft")
|
versionPath = p(lv["gamePath"],"versions",lv["version"])
|
||||||
versionPath = p(gamePath,"versions",lv["version"])
|
libraryPath = p(lv["gamePath"],"libraries")
|
||||||
libraryPath = p(gamePath,"libraries")
|
nativesPath = p(lv["gamePath"],"natives")
|
||||||
nativesPath = p(gamePath,"natives")
|
|
||||||
nativesOutPath = p(versionPath,"natives-" +lv["osName"])
|
nativesOutPath = p(versionPath,"natives-" +lv["osName"])
|
||||||
assetsPath = p(gamePath,"assets")
|
assetsPath = p(lv["gamePath"],"assets")
|
||||||
|
|
||||||
print("Extracting natives...")
|
print("Extracting natives...")
|
||||||
clientJson = readJsonFile(p(versionPath,lv["version"] + ".json"))
|
clientJson = readJsonFile(p(versionPath,lv["version"] + ".json"))
|
||||||
@ -84,7 +91,7 @@ def main():
|
|||||||
launcherVariables = {}
|
launcherVariables = {}
|
||||||
launcherVariables["auth_player_name"] = lv["name"]
|
launcherVariables["auth_player_name"] = lv["name"]
|
||||||
launcherVariables["version_name"] = lv["version"]
|
launcherVariables["version_name"] = lv["version"]
|
||||||
launcherVariables["game_directory"] = gamePath
|
launcherVariables["game_directory"] = lv["gamePath"]
|
||||||
launcherVariables["assets_root"] = assetsPath
|
launcherVariables["assets_root"] = assetsPath
|
||||||
launcherVariables["assets_index_name"] = clientJson["assets"]
|
launcherVariables["assets_index_name"] = clientJson["assets"]
|
||||||
launcherVariables["auth_access_token"] = "-"
|
launcherVariables["auth_access_token"] = "-"
|
||||||
|
Loading…
Reference in New Issue
Block a user