Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
yituodab committed May 26, 2024
1 parent 42cdef1 commit ef1cbc4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
Empty file added .github/workflows/build.yml
Empty file.
55 changes: 30 additions & 25 deletions Launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import subprocess
minecraft_directory = ".minecraft"
forge_version = '1.18.2-40.2.0'

if not os.path.exists(r"C:\Program Files\wangzhimeng"):
os.mkdir(r"C:\Program Files\wangzhimeng")
option_dir = r"C:\Program Files\wangzhimeng"
if not os.path.exists(r"C:\Program Files\wangzhimeng\user"):
files = open(r"C:\Program Files\wangzhimeng\user", "w+")
home = os.environ.get('USERPROFILE')
if not os.path.exists(home+r"\.config\wangzhimeng"):
os.mkdir(home+r"\.config")
os.mkdir(home+r"\.config\wangzhimeng")
option_dir = home+r"\.config\wangzhimeng"
if not os.path.exists(home+r"\.config\wangzhimeng\user"):
files = open(home+r"\.config\wangzhimeng\user", "w+")
files.close()
current_max = 0
def set_status(status: str):
Expand All @@ -29,8 +30,11 @@ def set_max(new_max: int):
"setMax": set_max
}
runtime_version = "java-runtime-beta"
FILE = open(option_dir+r"\install", 'r')
LINE = FILE.readlines()
if os.path.exists(option_dir+r"\install"):
FILE = open(option_dir+r"\install", 'r')
LINE = FILE.readlines()
else:
LINE = minecraft_directory
mcdir = LINE[0]
runtime = minecraft_launcher_lib.runtime.get_executable_path(runtime_version, mcdir)
if runtime == 'None':
Expand All @@ -46,6 +50,8 @@ def launcher(player: str):
options = minecraft_launcher_lib.utils.generate_test_options()
options['username'] = player
options['executablePath'] = runtime
options["launcherName"] = 'WZM'
options["launcherVersion"] = "114514"
print('检查游戏完整性...',end='')
minecraft_launcher_lib.install.install_minecraft_version('1.18.2', mcdir, callback)
if os.path.exists(mcdir+r'\versions\1.18.2-forge-40.2.0'):
Expand All @@ -62,15 +68,15 @@ def install():
if Dir == '':
print('安装中...',end='')
minecraft_launcher_lib.install.install_minecraft_version("1.18.2", minecraft_directory, callback=callback)
file = open(option_dir+r"install", "a+")
file = open(option_dir+r"\install", "a+")
file.write(minecraft_directory)
file.close()


else:
print('安装中...',end='')
minecraft_launcher_lib.install.install_minecraft_version("1.18.2", Dir,callback=callback)
file = open(option_dir+r"install", "a+")
file = open(option_dir+r"\install", "a+")
file.write(Dir)
file.close()

Expand All @@ -80,6 +86,7 @@ def info():
print('输入1:启动minecraft')
print(r'输入2:下载forge/服务器模组依赖')
print('输入3:更改用户')
print('输入4:更改安装目录')
print('输入0:退出')
if os.path.exists(option_dir+r"\install"):
print('已安装!')
Expand All @@ -90,7 +97,7 @@ def info():
put = input('已安装?(是/否):')
if put == '是':
Put = input("安装目录?:")
file = open(option_dir+r"install", "a+")
file = open(option_dir+r"\install", "a+")
file.write(Put)
file.close()
cls()
Expand All @@ -102,11 +109,7 @@ def info():

#主要部分
def body():
with open(option_dir+r"\install", "r") as file:
# 读取文件内容
global MCDIR
MCDIR = file.read()
print('安装目录:'+MCDIR)
print('安装目录:'+mcdir)

with open(option_dir+r"\user", "r") as file:
# 读取文件内容
Expand Down Expand Up @@ -148,15 +151,17 @@ def body():
if INput == 1:
with open(option_dir+r"\user", "r") as file:
# 读取文件内容
content = file.read()
if content == '':
content = 'unknown'
print('当前用户:'+content)
with open(option_dir+r"\install", "r") as file:
# 读取文件内容
content = file.read()
print('安装目录:'+content)
launcher(content)
player = file.read()
if player == '':
player = 'unknown'
print('当前用户:'+player)
print('安装目录:'+mcdir)
launcher(player)
cls()
body()
if INput == 4:
PUT = input('安装目录?')
open(option_dir+r'\install','w+').write(PUT)
cls()
body()
body()

0 comments on commit ef1cbc4

Please sign in to comment.