172 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
172 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); |
173 {$ENDIF} |
173 {$ENDIF} |
174 getLongIntParameter:= tmpInt; |
174 getLongIntParameter:= tmpInt; |
175 end; |
175 end; |
176 |
176 |
177 function getStringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
177 function getstringParameter(str:shortstring; var paramIndex:LongInt; var wrongParameter:Boolean): shortstring; |
178 begin |
178 begin |
179 inc(paramIndex); |
179 inc(paramIndex); |
180 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
180 wrongParameter:= (str='') or (Copy(str,1,2) = '--'); |
181 if wrongParameter then |
181 if wrongParameter then |
182 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
182 WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); |
183 getStringParameter:= str; |
183 getstringParameter:= str; |
184 end; |
184 end; |
185 |
185 |
186 procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt); forward; |
186 procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); forward; |
187 |
187 |
188 function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; |
188 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean; |
189 const videoArray: array [0..4] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
189 const videoArray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth'); |
190 audioArray: array [0..2] of String = ('--volume','--nomusic','--nosound'); |
190 audioArray: array [0..2] of string = ('--volume','--nomusic','--nosound'); |
191 otherArray: array [0..2] of String = ('--locale','--fullscreen','--showfps'); |
191 otherArray: array [0..2] of string = ('--locale','--fullscreen','--showfps'); |
192 mediaArray: array [0..9] of String = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
192 mediaArray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen'); |
193 allArray: array [0..17] of String = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags'); |
193 allArray: array [0..17] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags'); |
194 reallyAll: array [0..34] of shortstring = ( |
194 reallyAll: array [0..34] of shortstring = ( |
195 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
195 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width', |
196 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
196 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', |
197 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
197 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', |
198 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
198 {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', |
206 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
206 //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, |
207 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
207 // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki |
208 |
208 |
209 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
209 while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); |
210 case cmdIndex of |
210 case cmdIndex of |
211 {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
211 {--prefix} 0 : PathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
212 {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); |
212 {--user-prefix} 1 : UserPathPrefix := getstringParameter (arg, paramIndex, parseParameter); |
213 {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); |
213 {--locale} 2 : cLocaleFName := getstringParameter (arg, paramIndex, parseParameter); |
214 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
214 {--fullscreen-width} 3 : cFullscreenWidth := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth); |
215 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
215 {--fullscreen-height} 4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight); |
216 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
216 {--width} 5 : cWindowedWidth := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth); |
217 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
217 {--height} 6 : cWindowedHeight := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight); |
218 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
218 {--frame-interval} 7 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); |
223 {--showfps} 12 : cShowFPS := true; |
223 {--showfps} 12 : cShowFPS := true; |
224 {--altdmg} 13 : cAltDamage := true; |
224 {--altdmg} 13 : cAltDamage := true; |
225 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
225 {--low-quality} 14 : cReducedQuality := $FFFFFFFF xor rqLowRes; |
226 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
226 {--raw-quality} 15 : cReducedQuality := getLongIntParameter(arg, paramIndex, parseParameter); |
227 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
227 {--stereo} 16 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); |
228 {--nick} 17 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); |
228 {--nick} 17 : UserNick := parseNick( getstringParameter(arg, paramIndex, parseParameter) ); |
229 {deprecated options} |
229 {deprecated options} |
230 {--depth} 18 : setDepth(paramIndex); |
230 {--depth} 18 : setDepth(paramIndex); |
231 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
231 {--set-video} 19 : parseClassicParameter(videoArray,5,paramIndex); |
232 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
232 {--set-audio} 20 : parseClassicParameter(audioArray,3,paramIndex); |
233 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
233 {--set-other} 21 : parseClassicParameter(otherArray,3,paramIndex); |
258 end; |
258 end; |
259 end; |
259 end; |
260 end; |
260 end; |
261 end; |
261 end; |
262 |
262 |
263 procedure parseClassicParameter(cmdArray: array of String; size:LongInt; var paramIndex:LongInt); |
263 procedure parseClassicParameter(cmdArray: array of string; size:LongInt; var paramIndex:LongInt); |
264 var index, tmpInt: LongInt; |
264 var index, tmpInt: LongInt; |
265 isBool, isValid: Boolean; |
265 isBool, isValid: Boolean; |
266 cmd, arg, newSyntax: String; |
266 cmd, arg, newSyntax: string; |
267 begin |
267 begin |
268 WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); |
268 WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); |
269 WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); |
269 WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); |
270 WriteLn(stdout, ' Run `hwegine --help` to learn it!'); |
270 WriteLn(stdout, ' Run `hwegine --help` to learn it!'); |
271 WriteLn(stdout, ''); |
271 WriteLn(stdout, ''); |