hedgewars/ArgParsers.pas
branchqmlfrontend
changeset 10424 4be6cd55f1cf
parent 10416 1c301054694d
child 11071 3851ce4f2061
equal deleted inserted replaced
10422:4cf23d4c7624 10424:4be6cd55f1cf
   202 const videoarray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
   202 const videoarray: array [0..4] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth');
   203       audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound');
   203       audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound');
   204       otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
   204       otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
   205       mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
   205       mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
   206       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');
   206       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');
   207       reallyAll: array[0..34] of shortstring = (
   207       reallyAll: array[0..32] of shortstring = (
   208                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   208                 '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   209                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   209                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   210                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   210                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   211   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   211   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   212   {internal}    '--internal', '--recorder', '--landpreview',
   212   {internal}    '--internal', '--recorder', '--landpreview',
   213   {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
   213   {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
   219     //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above,
   219     //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above,
   220     //      the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki
   220     //      the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki
   221 
   221 
   222     while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex);
   222     while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex);
   223     case cmdIndex of
   223     case cmdIndex of
   224         {--prefix}               0 : PathPrefix        := getstringParameter (arg, paramIndex, parseParameter);
   224         {--locale}               0 : cLocaleFName      := getstringParameter (arg, paramIndex, parseParameter);
   225         {--user-prefix}          1 : UserPathPrefix    := getstringParameter (arg, paramIndex, parseParameter);
   225         {--fullscreen-width}     1 : cFullscreenWidth  := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth);
   226         {--locale}               2 : cLocaleFName      := getstringParameter (arg, paramIndex, parseParameter);
   226         {--fullscreen-height}    2 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight);
   227         {--fullscreen-width}     3 : cFullscreenWidth  := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenWidth);
   227         {--width}                3 : cWindowedWidth    := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth);
   228         {--fullscreen-height}    4 : cFullscreenHeight := max(getLongIntParameter(arg, paramIndex, parseParameter), cMinScreenHeight);
   228         {--height}               4 : cWindowedHeight   := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight);
   229         {--width}                5 : cWindowedWidth    := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenWidth);
   229         {--frame-interval}       5 : cTimerInterval    := getLongIntParameter(arg, paramIndex, parseParameter);
   230         {--height}               6 : cWindowedHeight   := max(2 * (getLongIntParameter(arg, paramIndex, parseParameter) div 2), cMinScreenHeight);
   230         {--volume}               6 : SetVolume          ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) );
   231         {--frame-interval}       7 : cTimerInterval    := getLongIntParameter(arg, paramIndex, parseParameter);
   231         {--nomusic}              7 : SetMusic           ( false );
   232         {--volume}               8 : SetVolume          ( max(getLongIntParameter(arg, paramIndex, parseParameter), 0) );
   232         {--nosound}              8 : SetSound           ( false );
   233         {--nomusic}              9 : SetMusic           ( false );
   233         {--fullscreen}           9 : cFullScreen       := true;
   234         {--nosound}             10 : SetSound           ( false );
   234         {--showfps}             10 : cShowFPS          := true;
   235         {--fullscreen}          11 : cFullScreen       := true;
   235         {--altdmg}              11 : cAltDamage        := true;
   236         {--showfps}             12 : cShowFPS          := true;
   236         {--low-quality}         12 : cReducedQuality   := $FFFFFFFF xor rqLowRes;
   237         {--altdmg}              13 : cAltDamage        := true;
   237         {--raw-quality}         13 : cReducedQuality   := getLongIntParameter(arg, paramIndex, parseParameter);
   238         {--low-quality}         14 : cReducedQuality   := $FFFFFFFF xor rqLowRes;
   238         {--stereo}              14 : setStereoMode      ( getLongIntParameter(arg, paramIndex, parseParameter) );
   239         {--raw-quality}         15 : cReducedQuality   := getLongIntParameter(arg, paramIndex, parseParameter);
   239         {--nick}                15 : UserNick          := parseNick( getstringParameter(arg, paramIndex, parseParameter) );
   240         {--stereo}              16 : setStereoMode      ( getLongIntParameter(arg, paramIndex, parseParameter) );
       
   241         {--nick}                17 : UserNick          := parseNick( getstringParameter(arg, paramIndex, parseParameter) );
       
   242         {deprecated options}
   240         {deprecated options}
   243         {--depth}               18 : setDepth(paramIndex);
   241         {--depth}               16 : setDepth(paramIndex);
   244         {--set-video}           19 : parseClassicParameter(videoarray,5,paramIndex);
   242         {--set-video}           17 : parseClassicParameter(videoarray,5,paramIndex);
   245         {--set-audio}           20 : parseClassicParameter(audioarray,3,paramIndex);
   243         {--set-audio}           18 : parseClassicParameter(audioarray,3,paramIndex);
   246         {--set-other}           21 : parseClassicParameter(otherarray,3,paramIndex);
   244         {--set-other}           19 : parseClassicParameter(otherarray,3,paramIndex);
   247         {--set-multimedia}      22 : parseClassicParameter(mediaarray,10,paramIndex);
   245         {--set-multimedia}      20 : parseClassicParameter(mediaarray,10,paramIndex);
   248         {--set-everything}      23 : parseClassicParameter(allarray,14,paramIndex);
   246         {--set-everything}      21 : parseClassicParameter(allarray,14,paramIndex);
   249         {"internal" options}
   247         {"internal" options}
   250         {--internal}            24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF};
   248         {--internal}            22 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF};
   251         {--recorder}            25 : startVideoRecording(paramIndex);
   249         {--recorder}            23 : startVideoRecording(paramIndex);
   252         {--landpreview}         26 : GameType := gmtLandPreview;
   250         {--landpreview}         24 : GameType := gmtLandPreview;
   253         {anything else}
   251         {anything else}
   254         {--stats-only}          27 : statsOnlyGame();
   252         {--stats-only}          25 : statsOnlyGame();
   255         {--gci}                 28 : GciEasterEgg();
   253         {--gci}                 26 : GciEasterEgg();
   256         {--help}                29 : DisplayUsage();
   254         {--help}                27 : DisplayUsage();
   257         {--no-teamtag}          30 : cTagsMask := cTagsMask and (not htTeamName);
   255         {--no-teamtag}          28 : cTagsMask := cTagsMask and (not htTeamName);
   258         {--no-hogtag}           31 : cTagsMask := cTagsMask and (not htName);
   256         {--no-hogtag}           29 : cTagsMask := cTagsMask and (not htName);
   259         {--no-healthtag}        32 : cTagsMask := cTagsMask and (not htHealth);
   257         {--no-healthtag}        30 : cTagsMask := cTagsMask and (not htHealth);
   260         {--translucent-tags}    33 : cTagsMask := cTagsMask or htTransparent;
   258         {--translucent-tags}    31 : cTagsMask := cTagsMask or htTransparent;
   261         {--lua-test}            34: begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
   259         {--lua-test}            32: begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
   262     else
   260     else
   263         begin
   261         begin
   264         //Assume the first "non parameter" is the replay file, anything else is invalid
   262         //Assume the first "non parameter" is the replay file, anything else is invalid
   265         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   263         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   266             recordFileName := cmd
   264             recordFileName := cmd
   352 begin
   350 begin
   353     if ParamCount > 0 then
   351     if ParamCount > 0 then
   354         begin
   352         begin
   355         isInternal:= (ParamStr(1) = '--internal');
   353         isInternal:= (ParamStr(1) = '--internal');
   356 
   354 
   357         UserPathPrefix := _S'.';
       
   358         PathPrefix     := cDefaultPathPrefix;
       
   359         recordFileName := '';
   355         recordFileName := '';
   360         parseCommandLine();
   356         parseCommandLine();
   361 
   357 
   362         if (isInternal) and (ParamCount<=1) then
   358         if (isInternal) and (ParamCount<=1) then
   363             begin
   359             begin