hedgewars/ArgParsers.inc
changeset 3678 00428183300f
child 3708 64e059b6f9c5
equal deleted inserted replaced
3676:fa29572fa56a 3678:00428183300f
       
     1 
       
     2 procedure internalSetGameTypeLandPreviewFromParameters();
       
     3 begin
       
     4     val(ParamStr(2), ipcPort);
       
     5     GameType:= gmtLandPreview;
       
     6     if ParamStr(3) <> 'landpreview' then
       
     7         GameType:= gmtSyntax;
       
     8 end;
       
     9 
       
    10 procedure internalStartGameWithParameters();
       
    11 begin
       
    12     val(ParamStr(2), cScreenWidth);
       
    13     val(ParamStr(3), cScreenHeight);
       
    14     cBitsStr:= ParamStr(4);
       
    15     val(cBitsStr, cBits);
       
    16     val(ParamStr(5), ipcPort);
       
    17     cFullScreen:= ParamStr(6) = '1';
       
    18     isSoundEnabled:= ParamStr(7) = '1';
       
    19     //cVSyncInUse:= ParamStr(8) = '1';      //merged with rqFlags
       
    20     //cWeaponTooltips:= ParamStr(9) = '1';  //merged with rqFlags
       
    21     cLocaleFName:= ParamStr(10);
       
    22     val(ParamStr(11), cInitVolume);
       
    23     val(ParamStr(12), cTimerInterval);
       
    24     PathPrefix:= ParamStr(13);
       
    25     cShowFPS:= ParamStr(14) = '1';
       
    26     cAltDamage:= ParamStr(15) = '1';
       
    27     UserNick:= DecodeBase64(ParamStr(16));
       
    28     isMusicEnabled:= ParamStr(17) = '1';
       
    29 
       
    30     if (ParamStr(18) = '1') then        //HACK - always disable rqLowRes as it is a game breaker
       
    31         cReducedQuality:= $FFFFFFFF xor rqLowRes
       
    32     else
       
    33         val(ParamStr(18), cReducedQuality);
       
    34     
       
    35     if (ParamStr(8) = '0') then         //HACK - ifcVSyncInUse not true, disable it
       
    36         cReducedQuality:= cReducedQuality xor rqDesyncVBlank;
       
    37     if (ParamStr(9) = '0') then         //HACK - if cWeaponTooltips not true, disable it
       
    38         cReducedQuality:= cReducedQuality xor rqTooltipsOff;
       
    39 end;
       
    40 
       
    41 procedure setVideo(screenWidth: LongInt; screenHeight: LongInt; bitsStr: LongInt);
       
    42 begin
       
    43     cScreenWidth:= screenWidth;
       
    44     cScreenHeight:= screenHeight;
       
    45     cBits:= bitsStr;
       
    46 end;
       
    47 
       
    48 procedure setVideoWithParameters(screenWidthParam: string; screenHeightParam: string; bitsParam: string);
       
    49 var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt: LongInt;
       
    50 begin
       
    51     val(screenWidthParam, screenWidthAsInt);
       
    52     val(screenHeightParam, screenHeightAsInt);
       
    53     cBitsStr:= bitsParam;
       
    54     val(cBitsStr, bitsStrAsInt);
       
    55     setVideo(screenWidthAsInt,screenHeightAsInt,bitsStrAsInt);
       
    56 end;
       
    57 
       
    58 procedure setOtherOptions(languageFile: string; fullScreen: boolean);
       
    59 begin
       
    60     cLocaleFName:= languageFile;
       
    61     cFullScreen:= fullScreen;
       
    62 end;
       
    63 
       
    64 procedure setShowFPS(showFPS: boolean);
       
    65 begin
       
    66     cShowFPS:= showFPS;
       
    67 end;
       
    68 
       
    69 procedure setOtherOptionsWithParameters(languageFileParam: string; fullScreenParam: string; showFPSParam: string);
       
    70 var fullScreen, showFPS: boolean;
       
    71 begin
       
    72     fullScreen:= fullScreenParam = '1';
       
    73     showFPS:= showFPSParam = '1';
       
    74     setOtherOptions(languageFileParam,fullScreen);
       
    75     setShowFPS(showFPS);
       
    76 end;
       
    77 
       
    78 procedure setAudio(initialVolume: LongInt; musicEnabled: boolean; soundEnabled: boolean);
       
    79 begin
       
    80     cInitVolume:= initialVolume;
       
    81     isMusicEnabled:= musicEnabled;
       
    82     isSoundEnabled:= soundEnabled; 
       
    83 end;
       
    84 
       
    85 procedure setAudioWithParameters(initialVolumeParam: string; musicEnabledParam: string; soundEnabledParam: string);
       
    86 var initialVolumeAsInt: LongInt;
       
    87     musicEnabled, soundEnabled: boolean;
       
    88 begin
       
    89     val(initialVolumeParam, initialVolumeAsInt);
       
    90     musicEnabled:= musicEnabledParam = '1';
       
    91     soundEnabled:= soundEnabledParam = '1';
       
    92     setAudio(initialVolumeAsInt,musicEnabled, soundEnabled);
       
    93 end;
       
    94 
       
    95 procedure setMultimediaOptionsWithParameters(screenWidthParam, screenHeightParam, bitsParam: string;
       
    96                                              initialVolumeParam, musicEnabledParam, soundEnabledParam: string;
       
    97                                              languageFileParam, fullScreenParam: string);
       
    98 begin
       
    99     setVideoWithParameters(screenWidthParam,screenHeightParam, bitsParam);
       
   100     setAudioWithParameters(initialVolumeParam,musicEnabledParam,soundEnabledParam);
       
   101     setOtherOptions(languageFileParam,fullScreenParam = '1');
       
   102 end;
       
   103 
       
   104 procedure setAltDamageTimerValueAndQuality(altDamage: boolean; timeIterval: LongInt; reducedQuality: boolean);
       
   105 begin
       
   106     cAltDamage:= altDamage;
       
   107     cTimerInterval:= timeIterval;
       
   108     if (reducedQuality) then        //HACK
       
   109         cReducedQuality:= $FFFFFFFF xor rqLowRes
       
   110 end;
       
   111 
       
   112 procedure setAllOptionsWithParameters(screenWidthParam:string; screenHeightParam:string; bitsParam:string;
       
   113                                       initialVolumeParam:string; musicEnabledParam:string; soundEnabledParam:string;
       
   114                                       languageFileParam:string; fullScreenParam:string; showFPSParam:string; 
       
   115                                       altDamageParam:string; timeItervalParam:string; reducedQualityParam: string);
       
   116 var showFPS, altDamage, reducedQuality: boolean;
       
   117     timeIterval: LongInt;
       
   118 begin
       
   119     setMultimediaOptionsWithParameters(screenWidthParam,screenHeightParam, bitsParam,
       
   120                                        initialVolumeParam,musicEnabledParam,soundEnabledParam,
       
   121                                        languageFileParam,fullScreenParam);                       
       
   122     showFPS := showFPSParam = '1';
       
   123     setShowFPS(showFPS);
       
   124     
       
   125     altDamage:= altDamageParam = '1';
       
   126     val(timeItervalParam, timeIterval);
       
   127     reducedQuality:= reducedQualityParam = '1';
       
   128     setAltDamageTimerValueAndQuality(altDamage,timeIterval,reducedQuality);    
       
   129 end;
       
   130 
       
   131 procedure playReplayFileWithParameters();
       
   132 var paramIndex: LongInt;
       
   133     wrongParameter: boolean;
       
   134 begin
       
   135     PathPrefix:= ParamStr(1);
       
   136     recordFileName:= ParamStr(2);
       
   137     paramIndex:= 3;
       
   138     wrongParameter:= false;
       
   139     while (paramIndex <= ParamCount) and not wrongParameter do
       
   140     begin
       
   141         //--set-video [screen width] [screen height] [color dept]
       
   142         if(ParamStr(paramIndex) = '--set-video') then
       
   143         begin
       
   144 	    if(ParamCount-paramIndex < 3) then
       
   145 	    begin
       
   146 	        wrongParameter:= true;
       
   147 	        GameType:= gmtSyntax;
       
   148 	    end;
       
   149 	    setVideoWithParameters(ParamStr(paramIndex+1), ParamStr(paramIndex+2), ParamStr(paramIndex+3));
       
   150 	    paramIndex:= paramIndex + 4;
       
   151         end 
       
   152         else 
       
   153         //--set-audio [volume] [enable music] [enable sounds]
       
   154         if(ParamStr(paramIndex) = '--set-audio') then
       
   155         begin
       
   156     	    if(ParamCount-paramIndex < 3) then
       
   157 	    begin
       
   158 	        wrongParameter := true;
       
   159 	        GameType:= gmtSyntax;
       
   160 	    end;
       
   161 	    setAudioWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3));
       
   162 	    paramIndex:= paramIndex + 4;
       
   163         end 
       
   164         else 
       
   165         // --set-other [language file] [full screen] [show FPS]
       
   166         if(ParamStr(paramIndex) = '--set-other') then
       
   167         begin
       
   168             if(ParamCount-paramIndex < 3) then
       
   169             begin
       
   170                 wrongParameter:= true;
       
   171                 GameType:= gmtSyntax;
       
   172 	    end;
       
   173 	    setOtherOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3));
       
   174 	    paramIndex:= paramIndex + 4;
       
   175 	end 
       
   176 	else 
       
   177 	//--set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]
       
   178 	if(ParamStr(paramIndex) = '--set-multimedia') then
       
   179 	begin
       
   180 	    if(ParamCount-paramIndex < 8) then
       
   181 	    begin
       
   182 	        wrongParameter:= true;
       
   183 	        GameType:= gmtSyntax;
       
   184 	    end;
       
   185 	    setMultimediaOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3),
       
   186 		   			       ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6),
       
   187 					       ParamStr(paramIndex+7),ParamStr(paramIndex+8));
       
   188 	    paramIndex:= paramIndex + 9;
       
   189         end 
       
   190         else
       
   191         //--set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]
       
   192         if(ParamStr(paramIndex) = '--set-everything') then
       
   193         begin
       
   194 	    if(ParamCount-paramIndex < 12) then
       
   195 	    begin
       
   196 	        wrongParameter:= true;
       
   197 	        GameType:= gmtSyntax;
       
   198 	    end;
       
   199 	    setAllOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3),
       
   200 				        ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6),
       
   201 				        ParamStr(paramIndex+7),ParamStr(paramIndex+8),ParamStr(paramIndex+9),
       
   202 				        ParamStr(paramIndex+10),ParamStr(paramIndex+11),ParamStr(paramIndex+12));
       
   203 	    paramIndex:= paramIndex + 13;
       
   204         end 
       
   205         else
       
   206         begin
       
   207 	    wrongParameter:= true;
       
   208 	    GameType:= gmtSyntax;
       
   209         end;
       
   210     end;
       
   211 end;
       
   212