hedgewars/ArgParsers.pas
branchqmlfrontend
changeset 10416 1c301054694d
parent 10404 1baaab44a0b2
child 10424 4be6cd55f1cf
equal deleted inserted replaced
10414:50bcefec5bf6 10416:1c301054694d
   119     SetSound(false);
   119     SetSound(false);
   120     SetMusic(false);
   120     SetMusic(false);
   121     SetVolume(0);
   121     SetVolume(0);
   122 end;
   122 end;
   123 
   123 
   124 procedure setIpcPort(port: LongInt; var wrongParameter:Boolean);
       
   125 begin
       
   126     if isInternal then
       
   127         ipcPort := port
       
   128     else
       
   129         begin
       
   130         WriteLn(stderr, 'ERROR: use of --port is not allowed');
       
   131         wrongParameter := true;
       
   132         end
       
   133 end;
       
   134 
       
   135 function parseNick(nick: shortstring): shortstring;
   124 function parseNick(nick: shortstring): shortstring;
   136 begin
   125 begin
   137     if isInternal then
   126     if isInternal then
   138         parseNick:= DecodeBase64(nick)
   127         parseNick:= DecodeBase64(nick)
   139     else
   128     else
   213 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');
   214       audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound');
   203       audioarray: array [0..2] of string = ('--volume','--nomusic','--nosound');
   215       otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
   204       otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
   216       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');
   217       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');
   218       reallyAll: array[0..35] of shortstring = (
   207       reallyAll: array[0..34] of shortstring = (
   219                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   208                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
   220                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   209                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
   221                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   210                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   222   {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',
   223   {internal}    '--internal', '--port', '--recorder', '--landpreview',
   212   {internal}    '--internal', '--recorder', '--landpreview',
   224   {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');
   225 var cmdIndex: byte;
   214 var cmdIndex: byte;
   226 begin
   215 begin
   227     parseParameter:= false;
   216     parseParameter:= false;
   228     cmdIndex:= 0;
   217     cmdIndex:= 0;
   257         {--set-other}           21 : parseClassicParameter(otherarray,3,paramIndex);
   246         {--set-other}           21 : parseClassicParameter(otherarray,3,paramIndex);
   258         {--set-multimedia}      22 : parseClassicParameter(mediaarray,10,paramIndex);
   247         {--set-multimedia}      22 : parseClassicParameter(mediaarray,10,paramIndex);
   259         {--set-everything}      23 : parseClassicParameter(allarray,14,paramIndex);
   248         {--set-everything}      23 : parseClassicParameter(allarray,14,paramIndex);
   260         {"internal" options}
   249         {"internal" options}
   261         {--internal}            24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF};
   250         {--internal}            24 : {$IFDEF HWLIBRARY}isInternal:= true{$ENDIF};
   262         {--port}                25 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter );
   251         {--recorder}            25 : startVideoRecording(paramIndex);
   263         {--recorder}            26 : startVideoRecording(paramIndex);
   252         {--landpreview}         26 : GameType := gmtLandPreview;
   264         {--landpreview}         27 : GameType := gmtLandPreview;
       
   265         {anything else}
   253         {anything else}
   266         {--stats-only}          28 : statsOnlyGame();
   254         {--stats-only}          27 : statsOnlyGame();
   267         {--gci}                 29 : GciEasterEgg();
   255         {--gci}                 28 : GciEasterEgg();
   268         {--help}                30 : DisplayUsage();
   256         {--help}                29 : DisplayUsage();
   269         {--no-teamtag}          31 : cTagsMask := cTagsMask and (not htTeamName);
   257         {--no-teamtag}          30 : cTagsMask := cTagsMask and (not htTeamName);
   270         {--no-hogtag}           32 : cTagsMask := cTagsMask and (not htName);
   258         {--no-hogtag}           31 : cTagsMask := cTagsMask and (not htName);
   271         {--no-healthtag}        33 : cTagsMask := cTagsMask and (not htHealth);
   259         {--no-healthtag}        32 : cTagsMask := cTagsMask and (not htHealth);
   272         {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent;
   260         {--translucent-tags}    33 : cTagsMask := cTagsMask or htTransparent;
   273         {--lua-test}            35 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
   261         {--lua-test}            34: begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
   274     else
   262     else
   275         begin
   263         begin
   276         //Assume the first "non parameter" is the replay file, anything else is invalid
   264         //Assume the first "non parameter" is the replay file, anything else is invalid
   277         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   265         if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then
   278             recordFileName := cmd
   266             recordFileName := cmd