-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.nim
97 lines (80 loc) · 2.36 KB
/
Main.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import std/os
#import wNim
#import std/asyncdispatch
import std/strutils
import std/json
import system/io
import DownloadManager
import GameManager
import Help
var params = commandLineParams()
const OK = 0
const Failed = 1
const OfficalStablePath = "/games/OEMGA/STABLE/"
if len(params) == 0:
echo "错误,未输入参数!请输入help获取帮助!"
if params[0] == "help":
show_help()
if params[0] == "init":
createDir("download")
createDir("games")
createDir("jre")
createDir("cache")
write_proxy(proxy_ghproxy)
if params[0] == "change_proxy":
var proxy = params[1]
var result = change_proxy(proxy)
if not result: echo "不存在此在线代理!"
if params[0] == "download_game":
var version = params[1]
createDir("download/" & version)
download_game(version)
if params[0] == "install_game":
var version = params[1]
install_game(version)
if params[0] == "download_jre":
var version = params[1]
download_jre(version)
if params[0] == "install_jre":
var version = params[1]
install_jre(version)
proc cant_run() =
echo "此版本无法启动!"
# 在这里启动游戏
proc run(p_version:string) =
setCurrentDir("games/" & p_version & "/libs")
discard execShellCmd("Terasology.jar")
if params[0] == "run":
#var use_javaw = false
var version = params[1]
if version == "v5.2.0": cant_run()
if version == "v4.3.0": cant_run()
if version == "v4.2.0": cant_run()
if version == "v3.2.0": run(version)
if version == "v3.0.0": run(version)
if version == "v2.0.0": run(version)
if version == "v1.6.0": run(version)
if version == "v1.3.0": run(version)
if params[0] == "list_installed":
list_installed()
if params[0] == "uninstall_game":
var version = params[1]
uninstall_game(version)
if params[0] == "remove_download":
var p_type = params[1]
var p_version = params[2]
remove_download(p_type, p_version)
if params[0] == "install_offical":
var version = params[1]
if fileExists("offical.json"):
var json = parseJson(readFile("offical.json"))
var rootDir = json["launcher"].getStr()
var targetDir = rootDir & OfficalStablePath & version.split("v")[1]
echo "开始缓存"
echo "要解压到:" & targetDir
if unpack(version) == OK:
echo "准备安装"
copyDir("cache/" & version, targetDir)
removeDir("cache/" & version)
else:
echo "解压到缓存目录失败!"