author | koda |
Wed, 19 Dec 2012 18:23:29 +0100 | |
changeset 8313 | 31d6613989a6 |
parent 8309 | edcfb5e43245 |
child 8325 | ecd51650d5d8 |
permissions | -rw-r--r-- |
4976 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
6700 | 3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
4976 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
18 |
|
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
19 |
|
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
20 |
procedure internalStartGameWithParameters(); |
4004
b1c2c2f6fc5e
update branch with latest head, most likely breaking water color in stereo mode
koda
parents:
3858
diff
changeset
|
21 |
var tmp: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
22 |
begin |
5239 | 23 |
UserPathPrefix:= ParamStr(1); |
7151 | 24 |
cScreenWidth:= StrToInt(ParamStr(2)); |
25 |
cScreenHeight:= StrToInt(ParamStr(3)); |
|
8309 | 26 |
//cBits:= StrToInt(ParamStr(4)); |
7151 | 27 |
ipcPort:= StrToInt(ParamStr(5)); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
28 |
cFullScreen:= ParamStr(6) = '1'; |
7021
0c75512a8920
adjust the scope of a few uSound variables and functions
koda
parents:
6982
diff
changeset
|
29 |
SetSound(ParamStr(7) = '1'); |
0c75512a8920
adjust the scope of a few uSound variables and functions
koda
parents:
6982
diff
changeset
|
30 |
SetMusic(ParamStr(8) = '1'); |
7151 | 31 |
SetVolume(StrToInt(ParamStr(9))); |
32 |
cTimerInterval:= StrToInt(ParamStr(10)); |
|
3709 | 33 |
PathPrefix:= ParamStr(11); |
34 |
cShowFPS:= ParamStr(12) = '1'; |
|
35 |
cAltDamage:= ParamStr(13) = '1'; |
|
36 |
UserNick:= DecodeBase64(ParamStr(14)); |
|
7151 | 37 |
cReducedQuality:= StrToInt(ParamStr(15)); |
38 |
tmp:= StrToInt(ParamStr(16)); |
|
6982 | 39 |
GrayScale:= false; |
8221 | 40 |
{$IFDEF USE_S3D_RENDERING} |
41 |
if (tmp > 9) and (tmp < 16) then |
|
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
42 |
begin |
8221 | 43 |
// set the gray anaglyph rendering |
6982 | 44 |
GrayScale:= true; |
5441
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
45 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) |
39962b855540
Add grayscale option for 3d, helps with colour clashing
nemo
parents:
5239
diff
changeset
|
46 |
end |
8221 | 47 |
else if tmp <= 9 then |
48 |
// set the fullcolor anaglyph |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6426
diff
changeset
|
49 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) |
8221 | 50 |
else |
51 |
// any other mode |
|
6580
6155187bf599
A partial reformatting of the pascal code to have consistent syntax. Things that are still inconsistent.
lovelacer
parents:
6426
diff
changeset
|
52 |
cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); |
8221 | 53 |
{$ELSE} |
54 |
cStereoMode:= smNone; |
|
55 |
{$ENDIF} |
|
4004
b1c2c2f6fc5e
update branch with latest head, most likely breaking water color in stereo mode
koda
parents:
3858
diff
changeset
|
56 |
cLocaleFName:= ParamStr(17); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
57 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
58 |
|
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
59 |
{$IFDEF USE_VIDEO_RECORDING} |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
60 |
procedure internalStartVideoRecordingWithParameters(); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
61 |
begin |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
62 |
internalStartGameWithParameters(); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
63 |
GameType:= gmtRecord; |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7306
diff
changeset
|
64 |
cVideoFramerateNum:= StrToInt(ParamStr(18)); |
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7306
diff
changeset
|
65 |
cVideoFramerateDen:= StrToInt(ParamStr(19)); |
7306
3cff5c769509
Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
66 |
RecPrefix:= ParamStr(20); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
67 |
cAVFormat:= ParamStr(21); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
68 |
cVideoCodec:= ParamStr(22); |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
69 |
cVideoQuality:= StrToInt(ParamStr(23)); |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7306
diff
changeset
|
70 |
cAudioCodec:= ParamStr(24); |
7198
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
71 |
end; |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
72 |
{$ENDIF} |
5debd5fe526e
1. Add IFDEFs for video recording
Stepan777 <stepik-777@mail.ru>
parents:
7180
diff
changeset
|
73 |
|
8150 | 74 |
procedure DisplayUsage; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
75 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
76 |
WriteLn(stdout, 'Usage: hwengine <path to replay file> [options]'); |
8150 | 77 |
WriteLn(stdout, ''); |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
78 |
WriteLn(stdout, 'where [options] can be any of the following:'); |
8307 | 79 |
WriteLn(stdout, ' --prefix [path to folder]'); |
80 |
WriteLn(stdout, ' --user-prefix [path to folder]'); |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
81 |
WriteLn(stdout, ' --locale [name of language file]'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
82 |
WriteLn(stdout, ' --width [screen width in pixels]'); |
8150 | 83 |
WriteLn(stdout, ' --height [screen height in pixels]'); |
84 |
WriteLn(stdout, ' --volume [sound level]'); |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
85 |
WriteLn(stdout, ' --frame-interval [milliseconds]'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
86 |
WriteLn(stdout, ' --raw-quality [flags]'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
87 |
WriteLn(stdout, ' --low-quality'); |
8150 | 88 |
WriteLn(stdout, ' --nomusic'); |
89 |
WriteLn(stdout, ' --nosound'); |
|
90 |
WriteLn(stdout, ' --fullscreen'); |
|
91 |
WriteLn(stdout, ' --showfps'); |
|
92 |
WriteLn(stdout, ' --altdmg'); |
|
93 |
WriteLn(stdout, ' --stats-only'); |
|
94 |
WriteLn(stdout, ' --help'); |
|
95 |
WriteLn(stdout, ''); |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
96 |
WriteLn(stdout, 'For more detailed help and examples go to:'); |
8150 | 97 |
WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions'); |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
98 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
99 |
|
8150 | 100 |
function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; |
101 |
var tmpInt, c: LongInt; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
102 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
103 |
inc(paramIndex); |
8150 | 104 |
val(str, tmpInt, c); |
105 |
wrongParameter:= c <> 0; |
|
106 |
if wrongParameter then |
|
107 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
|
108 |
getLongIntParameter:= tmpInt; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
109 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
110 |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
111 |
function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
112 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
113 |
inc(paramIndex); |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
114 |
wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
115 |
if wrongParameter then |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
116 |
WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
8150 | 117 |
getStringParameter:= str; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
118 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
119 |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
120 |
|
8150 | 121 |
procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward; |
122 |
||
123 |
function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
|
124 |
const videoArray: Array [1..3] of String = ('--width','--height','--depth'); |
|
125 |
const audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); |
|
126 |
const otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); |
|
127 |
const mediaArray: Array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen'); |
|
128 |
const allArray: Array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--time','--lowquality'); |
|
8307 | 129 |
const reallyAll: array[0..22] of shortstring = ( |
130 |
'--prefix', '--user-prefix', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
131 |
'--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
132 |
{deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
133 |
'--stats-only', '--gci', '--help'); |
8197 | 134 |
var cmdIndex: byte; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
135 |
begin |
8150 | 136 |
parseParameter:= false; |
8197 | 137 |
cmdIndex:= 0; |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
138 |
|
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
139 |
//NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
140 |
// the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
141 |
|
8197 | 142 |
while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
143 |
case cmdIndex of |
|
8307 | 144 |
{--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
145 |
{--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
|
146 |
{--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
|
147 |
{--width} 3 : cScreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); |
|
148 |
{--height} 4 : cScreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); |
|
149 |
{--frame-interval} 5 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
|
150 |
{--volume} 6 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
|
151 |
{--nomusic} 7 : SetMusic ( false ); |
|
152 |
{--nosound} 8 : SetSound ( false ); |
|
153 |
{--fullscreen} 9 : cFullScreen := true; |
|
154 |
{--showfps} 10 : cShowFPS := true; |
|
155 |
{--altdmg} 11 : cAltDamage := true; |
|
156 |
{--low-quality} 12 : cReducedQuality:= $FFFFFFFF xor rqLowRes; |
|
157 |
{--raw-quality} 13 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter); |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
158 |
{deprecated options} |
8309 | 159 |
{--depth} 14 : {do nothing}; |
8307 | 160 |
{--set-video} 15 : parseClassicParameter(videoArray,3,paramIndex); |
161 |
{--set-audio} 16 : parseClassicParameter(audioArray,3,paramIndex); |
|
162 |
{--set-other} 17 : parseClassicParameter(otherArray,3,paramIndex); |
|
163 |
{--set-multimedia} 18 : parseClassicParameter(mediaArray,8,paramIndex); |
|
164 |
{--set-everything} 19 : parseClassicParameter(allArray,12,paramIndex); |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
165 |
{anything else} |
8307 | 166 |
{--stats-only} 20 : begin |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
167 |
cOnlyStats:= true; |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
168 |
cReducedQuality:= $FFFFFFFF xor rqLowRes; |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
169 |
SetSound(false); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
170 |
end; |
8307 | 171 |
{--gci} 21 : begin // We had to make up all this saved space some how... \\ |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
172 |
WriteLn(stdout, ' '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
173 |
WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
174 |
WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
175 |
WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
176 |
WriteLn(stdout, ' \/\\\ /\\\\\\\ /\\\ \/\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
177 |
WriteLn(stdout, ' \/\\\ \/////\\\ \/\\\ \/\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
178 |
WriteLn(stdout, ' \/\\\ \/\\\ \//\\\ \/\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
179 |
WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
180 |
WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
181 |
WriteLn(stdout, ' \///////////// \///////// \/////////// '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
182 |
WriteLn(stdout, ' '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
183 |
WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
184 |
WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
185 |
WriteLn(stdout, ' '); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
186 |
end; |
8307 | 187 |
{--help} 22 : begin |
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
188 |
DisplayUsage(); |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
189 |
GameType:= gmtSyntax; |
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
190 |
end; |
8150 | 191 |
else |
192 |
begin |
|
8307 | 193 |
//Asusme the first "non parameter" is the replay file, anything else is invalid |
194 |
if recordFileName = '' then |
|
195 |
recordFileName := cmd |
|
196 |
else |
|
197 |
begin |
|
198 |
WriteLn(stderr, 'ERROR: '+cmd+' is not a valid argument'); |
|
199 |
parseParameter:= true; |
|
200 |
end; |
|
201 |
end; |
|
8150 | 202 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
203 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
204 |
|
8150 | 205 |
procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); |
206 |
var index, tmpInt: LongInt; |
|
207 |
isBool: Boolean; |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
208 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
209 |
WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
210 |
WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
211 |
WriteLn(stdout, ' Run `hwegine --help` to learn it!'); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
212 |
WriteLn(stdout, ''); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
213 |
|
8150 | 214 |
index:= 0; |
215 |
tmpInt:= 1; |
|
216 |
while (index < size) do |
|
217 |
begin |
|
218 |
paramIndex:= paramIndex+1; |
|
8197 | 219 |
// check if the parameter is a boolean one |
220 |
isBool:= (cmdArray[index] = '--nomusic') |
|
221 |
or (cmdArray[index] = '--nosound') |
|
222 |
or (cmdArray[index] = '--fullscreen') |
|
223 |
or (cmdArray[index] = '--showfps') |
|
224 |
or (cmdArray[index] = '--altdmg') |
|
8302
a7934cd12469
improve engine cmd line parsing and its documentation
RowanD
parents:
8221
diff
changeset
|
225 |
or (cmdArray[index] = '--low-quality'); |
8150 | 226 |
if (not isBool) or ((ParamStr(paramIndex)='1') and (cmdArray[index]<>'--nomusic') and (cmdArray[index]<>'--nosound')) then |
227 |
parseParameter(cmdArray[index], ParamStr(paramIndex), tmpInt); |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
228 |
inc(index); |
8150 | 229 |
end; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
230 |
end; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
231 |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
232 |
procedure playReplayFileWithParameters; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
233 |
var paramIndex: LongInt; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
234 |
wrongParameter: boolean; |
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
235 |
begin |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
236 |
paramIndex:= 1; |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
237 |
wrongParameter:= false; |
8150 | 238 |
while (paramIndex <= ParamCount) do |
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
239 |
begin |
8150 | 240 |
if parseParameter( ParamStr(paramIndex), ParamStr(paramIndex+1), paramIndex) then |
241 |
wrongParameter:= true; |
|
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
242 |
inc(paramIndex); |
8150 | 243 |
end; |
244 |
if wrongParameter = true then |
|
245 |
begin |
|
246 |
WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); |
|
247 |
GameType:= gmtSyntax; |
|
248 |
end |
|
3678
00428183300f
patch by lucass (polished by me) - command line parsing is now much more flexible
koda
parents:
diff
changeset
|
249 |
end; |
8308
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
250 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
251 |
procedure GetParams; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
252 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
253 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
254 |
tmpInt:=0; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
255 |
while (tmpInt <= ParamCount) do |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
256 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
257 |
WriteLn(stdout,inttostr(tmpInt) + ': ' + ParamStr(tmpInt)); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
258 |
inc(tmpInt); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
259 |
end; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
260 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
261 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
262 |
if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
263 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
264 |
PathPrefix := ParamStr(1); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
265 |
ipcPort := StrToInt(ParamStr(2)); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
266 |
GameType := gmtLandPreview; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
267 |
exit; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
268 |
end; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
269 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
270 |
//TODO: prepend something so that we can use a cDefaultParamNum of parameters |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
271 |
if ParamCount = cDefaultParamNum then |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
272 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
273 |
internalStartGameWithParameters(); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
274 |
exit; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
275 |
end |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
276 |
{$IFDEF USE_VIDEO_RECORDING} |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
277 |
else if ParamCount = cVideorecParamNum then |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
278 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
279 |
internalStartVideoRecordingWithParameters(); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
280 |
exit; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
281 |
end |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
282 |
{$ENDIF}; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
283 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
284 |
UserPathPrefix := '.'; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
285 |
PathPrefix := cDefaultPathPrefix; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
286 |
recordFileName := ''; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
287 |
playReplayFileWithParameters(); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
288 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
289 |
if (recordFileName = '') then |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
290 |
begin |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
291 |
DisplayUsage(); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
292 |
GameType:= gmtSyntax; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
293 |
end; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
294 |
(* |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
295 |
WriteLn(stdout,'PathPrefix: ' + PathPrefix); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
296 |
WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
297 |
WriteLn(stdout,'recordFilename: ' + recordFilename); |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
298 |
*) |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
299 |
end; |
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
300 |
|
cdf83bdf7b27
move GetParams in ArgParser, print a warning when using a deprecated command, pascalisation of +1s
koda
parents:
8307
diff
changeset
|
301 |