hedgewars/hwengine.pas
changeset 2630 079ef82eac75
parent 2603 abed6070a669
child 2633 9eb131794a6e
equal deleted inserted replaced
2629:be70fd3458c0 2630:079ef82eac75
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 {$IFNDEF FPC}
       
    20 {$ERROR Only Free Pascal supported!}
       
    21 {$ENDIF}
       
    22 
       
    23 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    24 
    20 
    25 program hwengine;
    21 program hwengine;
    26 uses
    22 uses	SDLh in 'SDLh.pas',
    27 	SDLh in 'SDLh.pas',
       
    28 {$IFDEF GLES11}
    23 {$IFDEF GLES11}
    29 	gles11,
    24 	gles11,
    30 {$ELSE}
    25 {$ELSE}
    31 	GL,
    26 	GL,
    32 {$ENDIF}
    27 {$ENDIF}
   312 			movedbybuttons:= false;
   307 			movedbybuttons:= false;
   313                         uKeys.isAttacking:= false;
   308                         uKeys.isAttacking:= false;
   314 		end;
   309 		end;
   315 {$ENDIF}
   310 {$ENDIF}
   316 {$IFDEF IPHONEOS}
   311 {$IFDEF IPHONEOS}
   317 		SDL_JOYAXISMOTION: begin
   312 (*		SDL_JOYAXISMOTION: begin
   318                 {* axis 0 = left and right;
   313                 {* axis 0 = left and right;
   319                    axis 1 = up and down;
   314                    axis 1 = up and down;
   320                    axis 2 = back and forth; *}
   315                    axis 2 = back and forth; *}
   321 
   316 
   322                         WriteLnToConsole('*********************************************       accelerometer');
   317                         WriteLnToConsole('*********************************************       accelerometer');
   323 			
   318 			
   324 			tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0);
   319 			tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick,≤ 0);
   325 
   320 
   326                         if (CurrentTeam <> nil) then
   321                         if (CurrentTeam <> nil) then
   327                         begin
   322                         begin
   328 {$IFDEF DEBUGFILE}
   323 {$IFDEF DEBUGFILE}
   329 				AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue));
   324 				AddFileLog('Joystick: 0; Axis: 0; Value: ' + inttostr(tiltValue));
   341 						uKeys.isWalking:= true;
   336 						uKeys.isWalking:= true;
   342                                         end
   337                                         end
   343                                         else
   338                                         else
   344                                                 if (tiltValue  > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false;  
   339                                                 if (tiltValue  > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false;  
   345                         end;
   340                         end;
   346                 end;
   341                 end;*)
   347 {$ELSE}
   342 {$ELSE}
   348 		SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true;
   343 		SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true;
   349 		SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true;
   344 		SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true;
   350 		SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
   345 		SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
   351 		SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
   346 		SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
   390 {$IFDEF DEBUGFILE}
   385 {$IFDEF DEBUGFILE}
   391     i: LongInt;
   386     i: LongInt;
   392 {$ENDIF}
   387 {$ENDIF}
   393     p: TPathType;
   388     p: TPathType;
   394 begin
   389 begin
   395 {$IFDEF DEBUGFILE}
       
   396 AddFileLog('Prefix: "' + PathPrefix +'"');
       
   397 for i:= 0 to ParamCount do
       
   398     AddFileLog(inttostr(i) + ': ' + ParamStr(i));
       
   399 {$ENDIF}
       
   400 
   390 
   401 case ParamCount of
   391 case ParamCount of
   402  17: begin
   392  17: begin
   403      val(ParamStr(2), cScreenWidth);
   393      val(ParamStr(2), cScreenWidth);
   404      val(ParamStr(3), cScreenHeight);
   394      val(ParamStr(3), cScreenHeight);
   423          if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   413          if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   424      end;
   414      end;
   425 {$IFDEF IPHONEOS}
   415 {$IFDEF IPHONEOS}
   426   0: begin
   416   0: begin
   427         PathPrefix:= 'hedgewars/Data';
   417         PathPrefix:= 'hedgewars/Data';
   428 		recordFileName:= 'hedgewars/save.hws';
   418         recordFileName:= 'hedgewars/save.hws';
   429 		val('320', cScreenWidth);
   419         val('320', cScreenWidth);
   430 		val('480', cScreenHeight);
   420         val('480', cScreenHeight);
   431 		cInitWidth:= cScreenWidth;
   421         cInitWidth:= cScreenWidth;
   432 		cInitHeight:= cScreenHeight;
   422         cInitHeight:= cScreenHeight;
   433 		cBitsStr:= '32';
   423         cBitsStr:= '32';
   434 		val(cBitsStr, cBits);
   424         val(cBitsStr, cBits);
   435 		val('100', cInitVolume);
   425         val('100', cInitVolume);
   436 		isMusicEnabled:= false;
   426         isMusicEnabled:= false;
   437 		isSoundEnabled:= false;
   427         isSoundEnabled:= false;
   438 		cLocaleFName:= 'en.txt';
   428         cLocaleFName:= 'en.txt';
   439 		cFullScreen:= true; //T or F is is the same here
   429         cFullScreen:= true; //T or F is is the same here
   440 		cAltDamage:= false;
   430         cAltDamage:= false;
   441 		cShowFPS:= true;
   431         cShowFPS:= true;
   442 		val('8', cTimerInterval);
   432         val('8', cTimerInterval);
   443 		cReducedQuality:= false;
   433         cReducedQuality:= false;
   444 
   434 
   445         for p:= Succ(Low(TPathType)) to High(TPathType) do
   435         for p:= Succ(Low(TPathType)) to High(TPathType) do
   446 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   436                 if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   447      end;
   437      end;
   448 {$ENDIF}
   438 {$ENDIF}
   449   3: begin
   439   3: begin
   450      val(ParamStr(2), ipcPort);
   440      val(ParamStr(2), ipcPort);
   451      GameType:= gmtLandPreview;
   441      GameType:= gmtLandPreview;
   455 		PathPrefix:= ParamStr(1);
   445 		PathPrefix:= ParamStr(1);
   456 		recordFileName:= ParamStr(2);
   446 		recordFileName:= ParamStr(2);
   457 
   447 
   458 		for p:= Succ(Low(TPathType)) to High(TPathType) do
   448 		for p:= Succ(Low(TPathType)) to High(TPathType) do
   459 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   449 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   460 	end;
   450      end;
   461   6: begin
   451   6: begin
   462 		PathPrefix:= ParamStr(1);
   452 		PathPrefix:= ParamStr(1);
   463 		recordFileName:= ParamStr(2);
   453 		recordFileName:= ParamStr(2);
   464 
   454 
   465 		if ParamStr(3) = '--set-video'	then
   455 		if ParamStr(3) = '--set-video'	then
   543 		for p:= Succ(Low(TPathType)) to High(TPathType) do
   533 		for p:= Succ(Low(TPathType)) to High(TPathType) do
   544 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   534 			if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]
   545 	end;
   535 	end;
   546 	else DisplayUsage;
   536 	else DisplayUsage;
   547 	end;
   537 	end;
       
   538 
       
   539 {$IFDEF DEBUGFILE}
       
   540 AddFileLog('Prefix: "' + PathPrefix +'"');
       
   541 for i:= 0 to ParamCount do
       
   542 	AddFileLog(inttostr(i) + ': ' + ParamStr(i));
       
   543 {$IFDEF IPHONEOS}
       
   544 WriteLnToConsole('Saving debug file at: ' + get_documents_path());
       
   545 {$ENDIF}
       
   546 {$ENDIF}
   548 end;
   547 end;
   549 
   548 
   550 /////////////////////////
   549 /////////////////////////
   551 procedure ShowMainWindow;
   550 procedure ShowMainWindow;
   552 begin
   551 begin