hedgewars/hwengine.dpr
changeset 2008 fc2fb5c938c3
parent 2006 587636c8344e
child 2015 d2848d723690
equal deleted inserted replaced
2007:159d14fe4e93 2008:fc2fb5c938c3
    25 // Mark all Pascal procedures/functions that you wish to call from C/C++/Objective-C code using
    25 // Mark all Pascal procedures/functions that you wish to call from C/C++/Objective-C code using
    26 // "cdecl; export;" (see the fpclogo.pas unit for an example), and then add C-declarations for
    26 // "cdecl; export;" (see the fpclogo.pas unit for an example), and then add C-declarations for
    27 // these procedures/functions to the PascalImports.h file (also in the "Pascal Sources" group)
    27 // these procedures/functions to the PascalImports.h file (also in the "Pascal Sources" group)
    28 // to make these functions available in the C/C++/Objective-C source files
    28 // to make these functions available in the C/C++/Objective-C source files
    29 // (add "#include PascalImports.h" near the top of these files if it is not there yet)
    29 // (add "#include PascalImports.h" near the top of these files if it is not there yet)
    30 //Library PascalLibrary;
    30 
    31 program hwengine;
    31 program hwengine;
    32 uses
    32 uses
    33 	SDLh in 'SDLh.pas',
    33 	SDLh in 'SDLh.pas',
    34 {$IFDEF IPHONE}
    34 {$IFDEF IPHONE}
    35 	gles11,
    35 	gles11,
    62 	uAmmos in 'uAmmos.pas',
    62 	uAmmos in 'uAmmos.pas',
    63 	uSHA in 'uSHA.pas',
    63 	uSHA in 'uSHA.pas',
    64 	uFloat in 'uFloat.pas',
    64 	uFloat in 'uFloat.pas',
    65 	uStats in 'uStats.pas',
    65 	uStats in 'uStats.pas',
    66 	uChat in 'uChat.pas',
    66 	uChat in 'uChat.pas',
    67 	uLandTexture;
    67 	uLandTexture in 'uLandTexture.pas';
    68 
    68 
    69 {$INCLUDE options.inc}
    69 {$INCLUDE options.inc}
    70 
    70 
    71 // also: GSHandlers.inc
    71 // also: GSHandlers.inc
    72 //       CCHandlers.inc
    72 //       CCHandlers.inc
   184    end else SDL_Delay(1);
   184    end else SDL_Delay(1);
   185 IPCCheckSock
   185 IPCCheckSock
   186 until isTerminated
   186 until isTerminated
   187 end;
   187 end;
   188 
   188 
       
   189 /////////////////////
       
   190 procedure DisplayUsage;
       
   191 begin
       
   192 	WriteLn('Wrong argument format: correct configurations is');
       
   193 	WriteLn();
       
   194 	WriteLn('  hwengine <path to data folder> <path to replay file> [option]');
       
   195 	WriteLn();
       
   196 	WriteLn('where [option] must be specified either as');
       
   197 	WriteLn(' --set-video [screen height] [screen width] [color dept]');
       
   198 	WriteLn(' --set-audio [volume] [enable music] [enable sounds]');
       
   199 	WriteLn(' --set-other [language file] [full screen] [show FPS]');
       
   200 	WriteLn(' --set-multimedia [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]');
       
   201 	WriteLn(' --set-everything [screen height] [screen width] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]');
       
   202 	WriteLn();
       
   203 	WriteLn('Read documentation online at http://www.hedgewars.org/ for more information');
       
   204 end;
       
   205 
   189 ////////////////////
   206 ////////////////////
   190 procedure GetParams;
   207 procedure GetParams;
   191 var
   208 var
   192 {$IFDEF DEBUGFILE}
   209 {$IFDEF DEBUGFILE}
   193     i: LongInt;
   210     i: LongInt;
   226   3: begin
   243   3: begin
   227      val(ParamStr(2), ipcPort);
   244      val(ParamStr(2), ipcPort);
   228      GameType:= gmtLandPreview;
   245      GameType:= gmtLandPreview;
   229      if ParamStr(3) <> 'landpreview' then OutError(errmsgShouldntRun, true);
   246      if ParamStr(3) <> 'landpreview' then OutError(errmsgShouldntRun, true);
   230      end;
   247      end;
   231  14: begin
   248   2: begin
   232      PathPrefix:= ParamStr(1);
   249 		PathPrefix:= ParamStr(1);
   233      recordFileName:= ParamStr(2);
   250 		recordFileName:= ParamStr(2);
   234      val(ParamStr(3), cScreenWidth);
   251 	 
   235      val(ParamStr(4), cScreenHeight);
   252 		for p:= Succ(Low(TPathType)) to High(TPathType) do
   236      cInitWidth:= cScreenWidth;
   253 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   237      cInitHeight:= cScreenHeight;
   254 	end;
   238      cBitsStr:= ParamStr(5);
   255   6: begin
   239      val(cBitsStr, cBits);
   256 		PathPrefix:= ParamStr(1);
   240      cFullScreen:= ParamStr(6) = '1';
   257 		recordFileName:= ParamStr(2);
   241      isSoundEnabled:= ParamStr(7) = '1';
   258 	 
   242      cLocaleFName:= ParamStr(8);
   259 		if ParamStr(3) = '--set-video'	then
   243      val(ParamStr(9), cInitVolume);
   260 		begin
   244      val(ParamStr(10), cTimerInterval);
   261 			val(ParamStr(4), cScreenWidth);
   245      cShowFPS:= ParamStr(11) = '1';
   262 			val(ParamStr(5), cScreenHeight);
   246      cAltDamage:= ParamStr(12) = '1';
   263 			cInitWidth:= cScreenWidth;
   247      isMusicEnabled:= ParamStr(13) = '1';
   264 			cInitHeight:= cScreenHeight;
   248      cReducedQuality:= ParamStr(14) = '1';
   265 			cBitsStr:= ParamStr(6);
   249      for p:= Succ(Low(TPathType)) to High(TPathType) do
   266 			val(cBitsStr, cBits);
   250          if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   267 		end
   251      end;
   268 		else
   252    else
   269 		begin
   253    OutError(errmsgShouldntRun, true)
   270 			if ParamStr(3) = '--set-audio' then
   254    end
   271 			begin
       
   272 				val(ParamStr(4), cInitVolume);
       
   273 				isMusicEnabled:= ParamStr(5) = '1';
       
   274 				isSoundEnabled:= ParamStr(6) = '1';
       
   275 			end
       
   276 			else
       
   277 			begin
       
   278 				if ParamStr(3) = '--set-other' then
       
   279 				begin
       
   280 					cLocaleFName:= ParamStr(4);
       
   281 					cFullScreen:= ParamStr(5) = '1';
       
   282 					cShowFPS:= ParamStr(6) = '1';
       
   283 				end
       
   284 				else DisplayUsage;
       
   285 			end
       
   286 		end;
       
   287 		
       
   288 		for p:= Succ(Low(TPathType)) to High(TPathType) do
       
   289 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
       
   290 	end;
       
   291  11: begin
       
   292 		PathPrefix:= ParamStr(1);
       
   293 		recordFileName:= ParamStr(2);
       
   294 	
       
   295 		if ParamStr(3) = '--set-multimedia' then
       
   296 		begin
       
   297 			val(ParamStr(4), cScreenWidth);
       
   298 			val(ParamStr(5), cScreenHeight);
       
   299 			cInitWidth:= cScreenWidth;
       
   300 			cInitHeight:= cScreenHeight;
       
   301 			cBitsStr:= ParamStr(6);
       
   302 			val(cBitsStr, cBits);
       
   303 			val(ParamStr(7), cInitVolume);
       
   304 			isMusicEnabled:= ParamStr(8) = '1';
       
   305 			isSoundEnabled:= ParamStr(9) = '1';
       
   306 			cLocaleFName:= ParamStr(10);
       
   307 			cFullScreen:= ParamStr(11) = '1';
       
   308 		end
       
   309 		else DisplayUsage;
       
   310 		
       
   311 		for p:= Succ(Low(TPathType)) to High(TPathType) do
       
   312 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
       
   313 	end;
       
   314  15: begin
       
   315 		if ParamStr(3) = '--set-everything' then
       
   316 		begin
       
   317 			val(ParamStr(4), cScreenWidth);
       
   318 			val(ParamStr(5), cScreenHeight);
       
   319 			cInitWidth:= cScreenWidth;
       
   320 			cInitHeight:= cScreenHeight;
       
   321 			cBitsStr:= ParamStr(6);
       
   322 			val(cBitsStr, cBits);
       
   323 			val(ParamStr(7), cInitVolume);
       
   324 			isMusicEnabled:= ParamStr(8) = '1';
       
   325 			isSoundEnabled:= ParamStr(9) = '1';
       
   326 			cLocaleFName:= ParamStr(10);
       
   327 			cFullScreen:= ParamStr(11) = '1';
       
   328 			cAltDamage:= ParamStr(12) = '1';
       
   329 			cShowFPS:= ParamStr(13) = '1';
       
   330 			val(ParamStr(14), cTimerInterval);
       
   331 			cReducedQuality:= ParamStr(15) = '1';
       
   332 		end
       
   333 		else DisplayUsage;
       
   334 		
       
   335 		for p:= Succ(Low(TPathType)) to High(TPathType) do
       
   336 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
       
   337 	end;
       
   338 	else DisplayUsage;
       
   339 	end;
   255 end;
   340 end;
   256 
   341 
   257 procedure ShowMainWindow;
   342 procedure ShowMainWindow;
   258 begin
   343 begin
   259 if cFullScreen then ParseCommand('fullscr 1', true)
   344 if cFullScreen then ParseCommand('fullscr 1', true)
   334 
   419 
   335 begin
   420 begin
   336 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine');
   421 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine');
   337 GetParams;
   422 GetParams;
   338 Randomize;
   423 Randomize;
   339 { /home/nemo/games/bin/hwengine /home/nemo/games/hedgewars/Data ~/.hedgewars/Saves/2009-03-22_19-54.hws_24 480 320 32 0 1 en.txt 128 33 0 1 1 0}
   424 
   340 if GameType = gmtLandPreview then GenLandPreview
   425 if GameType = gmtLandPreview then GenLandPreview
   341                              else Game
   426                              else Game
   342 end.
   427 end.
       
   428