-
Notifications
You must be signed in to change notification settings - Fork 452
/
make.ps1
105 lines (86 loc) · 2.61 KB
/
make.ps1
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
98
99
100
101
102
103
104
105
if($args[0] -eq "clean"){
rm src/maps/*.lua
return
}elseif($args[0] -eq "reset"){
rm $env:AppData\LOVE\Hawkthorne\*.json
rm src/maps/*.lua
rm bin/
return
}
Write-Host "Running make.ps1..."
$check = Test-Path -PathType Container bin
if($check -eq $false){
New-Item 'bin' -type Directory
}
$webclient = New-Object System.Net.WebClient
$lovedir = "bin\love-0.10.1-win32\"
$check = Test-Path "bin\love-0.10.1-win32\love.exe"
#add love to the path if necessary
$foundlove = $env:Path.Contains($lovedir)
if($foundlove -eq $false){
$env:Path += ";"+$lovedir
}
if($check -eq $false){
$filename = (Get-Location).Path + "\bin\love-0.10.1-win32.zip"
$check = Test-Path $filename
if($check -eq $false){
Write-Host "Downloading love2d..."
$url = "https://github.com/love2d/love/releases/download/0.10.1/love-0.10.1-win32.zip"
try {
$webclient.DownloadFile($url,$filename)
} catch {
Write-Error "Failed to download love2d..."
Write-Error $_
Exit
}
}
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace($filename)
$destination = $shell_app.namespace((Get-Location).Path + "\bin\")
$destination.Copyhere($zip_file.items())
}
$tmx = "bin\tmx2lua.exe"
$check = Test-Path $tmx
if($check -eq $false){
$filename = (Get-Location).Path + "\bin\tmx2lua.windows32.zip"
$check = Test-Path $filename
if($check -eq $false){
Write-Host "Downloading tmx2lua..."
$url = "http://hawkthorne.github.io/tmx2lua/downloads/tmx2lua.windows32.zip"
try {
$webclient.DownloadFile($url,$filename)
} catch {
Write-Error "Failed to download tmx2lua..."
Write-Error $_
Exit
}
}
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace($filename)
$destination = $shell_app.namespace((Get-Location).Path + "\bin")
$destination.Copyhere($zip_file.items())
}
$fileEntries = [IO.Directory]::GetFiles((Get-Location).Path + "\src\maps");
foreach($fileName in $fileEntries)
{
$lua = $filename.split(".")[0] + ".lua"
$exists = Test-Path $lua
$older = $true
if($exists -eq $true) {
$older = (Get-Item $filename).LastWriteTime -gt (Get-Item $lua).LastWriteTime
}
if($older -eq $true) {
.\bin\tmx2lua.exe $filename $lua
}
}
if($args[0] -eq "run"){
Write-Host "Running Journey to the Center of Hawkthorne..."
if($args.Length -ne 1){
.\bin\love-0.10.1-win32\love.exe src $args[1..($args.Length-1)]
}else{
.\bin\love-0.10.1-win32\love.exe src
}
}elseif($args[0] -eq "test"){
Write-Host "Testing Journey to the Center of Hawkthorne..."
.\bin\love-0.10.1-win32\love.exe src --test --console
}