Skip to content

Commit

Permalink
Merge pull request #9 from 2439905184/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
2439905184 authored Aug 27, 2022
2 parents 59d5e74 + a102b4c commit 9b3ce49
Show file tree
Hide file tree
Showing 12 changed files with 805 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
test/
test/
*.zip
674 changes: 674 additions & 0 deletions License

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions Main.nim
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import std/os
#import wNim
import std/asyncdispatch
import download


var params = commandLineParams()

if params[0] == "init":
Expand All @@ -19,14 +19,22 @@ if params[0] == "install_game":
var version = params[1]
install_game(version)

if params[0] == "install_jre":
if params[0] == "download_jre":
var version = params[1]
download_jre(version)
resolve_jre(version)

if params[0] == "install_jre":
var version = params[1]
install_jre(version)

if params[0] == "run":
var version = params[1]
setCurrentDir("jre/11/jre-11.0.16.1/bin")
var success = execShellCmd("java.exe -jar D:/work/myTerasologyLauncher/dist/games/" & version & "/libs/Terasology.jar")
if success == 0:
echo "游戏启动失败或者进程已结束!"
if version == "v5.2.0":
# setCurrentDir("jre/11/offical-java11/jre/bin")
discard execShellCmd("cd run &java.cmd")
#discard execShellCmd("java.exe -jar " & "../../../..games/" & version & "/Terasology.jar")
# setCurrentDir("jre/11/jre-11.0.16.1/bin")
# var success = execShellCmd("java.exe -jar D:/work/myTerasologyLauncher/dist/games/" & version & "/libs/Terasology.jar")
# var success = execShellCmd("java.exe -jar " & "../../../../games/" & version & "/libs/Terasology.jar")
# if success == 0:
# echo "游戏启动失败或者进程已结束!"
1 change: 1 addition & 0 deletions Unpacker/.build/cmdline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
60 changes: 60 additions & 0 deletions Unpacker/.build/default.Manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="Unpacker.exe"/>
<description>Unpacker</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!--
可任选以下配置之一指定一个进程权限:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
requireAdministrator 为管理员权限,
highestAvailable 为可以获取到的最高权限,
asInvoker 为默认值,即调用进程当前权限,一般不需要显式指定,指定后会禁用虚拟化。
虚拟化指Vista以后系统禁止写 Program File目录,启用虚拟化则重定向到%localappdata%\VirtualStore目录,
而注册表 HKEY_LOCAL_MACHINE\Software 则重定向到HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\Software
-->
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
2 changes: 2 additions & 0 deletions Unpacker/.build/default.init.aardio
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//发布前触发
import ide;
6 changes: 6 additions & 0 deletions Unpacker/.build/default.main.aardio
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//此触发器在生成EXE以后执行
import ide;
import fsys;

//获取生成的EXE文件路径
var publishFile = ide.getPublishPath();
5 changes: 5 additions & 0 deletions Unpacker/default.aproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="Unpacker" libEmbed="true" icon="..." ui="console" output="Unpacker.exe" CompanyName="单位名称" FileDescription="Unpacker" LegalCopyright="Copyright (C) 作者 2022" ProductName="Unpacker" InternalName="Unpacker" FileVersion="0.0.0.1" ProductVersion="0.0.0.1" publishDir="/dist/" dstrip="false">
<file name="main.aardio" path="main.aardio" comment="启动程序代码"/>
<folder name="资源文件" path="res" embed="true"/>
</project>
20 changes: 20 additions & 0 deletions Unpacker/lib/config.aardio
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//config 配置文件
import fsys.config;
config = fsys.config("/config/");
//config = fsys.config( io.appData("/软件作者/应用程序名/") );

//不需要序列化的配置名字前请添加下划线
namespace config {
__appName = "应用程序名";
__appVersion = "1.0.0.01";
__appDescription = "这是一个测试程序";
__website = "http://www.aardio.com/";
}

/**intellisense(config)
__appName = 应用程序名
__appVersion = 应用程序内部版本号
__appDescription = 程序说明
__website = 官方网站
? = 配置文件名,\n读写配置并序列化为一个表对象,\n表的成员值可以是支持序列化的普通变量,支持table对象\n配置文件在首次使用时自动加载,退出程序时自动保存\n!fsys_table.
end intellisense**/
9 changes: 9 additions & 0 deletions Unpacker/main.aardio
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import console;
import zlib;
import zlib.unzip;

console.setTitle("Unpacker");

console.dump(_ARGV)
zlib.unzip.extract(_ARGV[1],_ARGV[2])
//console.pause()
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nim c -d:ssl -d:zippy -d:release --outdir:dist Main.nim
nim c -d:ssl -d:release --outdir:dist Main.nim
rem nim c -d:ssl -d:release --outdir:dist download.nim
rem nim c -d:release --outdir:dist nvidia.nim
16 changes: 10 additions & 6 deletions download.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import std/[asyncdispatch, httpclient]
import std/json
import std/os
import zippy/ziparchives

type
DownloadInfo* = object # 存储下载信息
Expand All @@ -11,20 +10,25 @@ type
tag_name*, name*, published_at*: string
downloadInfos*: seq[DownloadInfo]

proc onProgressChanged(total, progress, speed: BiggestInt) =
echo("Downloaded ", progress, " of ", total)
echo("Current rate: ", speed div 1000, "kb/s")

proc download_jre*(version:string) =
# 此处直接使用官方启动器的jre11版本
if version == "11":
var client = newHttpClient()
echo "开始下载jre11 请稍等..."
client.onProgressChanged = onProgressChanged
var content = client.getContent("https://download.bell-sw.com/java/11.0.16.1+1/bellsoft-jre11.0.16.1+1-windows-amd64.zip")
writefile("download/jre11.zip", content)
echo "下载完成"

proc resolve_jre*(version:string) =
proc install_jre*(version:string) =
var zip = "download/jre" & version & ".zip"
var outDir = "jre/" & version
echo "解压中..."
extractAll(zip, outDir)
discard execShellCmd("Unpacker.exe " & zip & " " & outDir)
echo "安装完成"

proc async_get(url: string): Future[string] {.async.} =
Expand All @@ -51,20 +55,20 @@ proc get_release_datas*(): seq[ReleaseData] =
return release_datas

# 此处使用github加速代理服务 如果下载失败,请打开浏览器手动下载, https://ghproxy.com/

proc download_game*(version:string) =
var url_first = "https://ghproxy.com/"
var url = url_first & "https://github.com/MovingBlocks/Terasology/releases/download/" & version & "/TerasologyOmega.zip"
echo "正在下载请稍后..."
echo url
var client = newHttpClient()
client.onProgressChanged = onProgressChanged
var content = client.getContent(url)
var file = "download/" & version & "/TerasologyOmega.zip"
writefile(file, content)

proc install_game*(version:string) =
echo "开始安装游戏: " & version
echo "调用aardio的外部解压器!"
var zip = "download/" & version & "/TerasologyOmega.zip"
var outDir = "games/" & version
extractAll(zip, outDir)
var result = execShellCmd("Unpacker.exe " & zip & " " & outDir)
echo "游戏安装完成: " & version

0 comments on commit 9b3ce49

Please sign in to comment.