hedgewars/hwengine.pas
changeset 2671 7e0f88013fe8
parent 2669 4eec706e86b0
child 2674 2fce032f2f95
equal deleted inserted replaced
2670:1b327b7515ed 2671:7e0f88013fe8
   159     CurrTime: Longword;
   159     CurrTime: Longword;
   160     event: TSDL_Event;
   160     event: TSDL_Event;
   161 {$IFDEF TOUCHINPUT}
   161 {$IFDEF TOUCHINPUT}
   162 type TDirection = (nodir, left, right);
   162 type TDirection = (nodir, left, right);
   163 var x, y, dx, dy, mouseState: LongInt;
   163 var x, y, dx, dy, mouseState: LongInt;
   164     tiltValue: LongInt;
   164 //    tiltValue: LongInt;
   165     direction: TDirection = nodir;
   165     direction: TDirection = nodir;
   166     movedbybuttons: boolean = false;
   166     movedbybuttons: boolean = false;
   167 {$ENDIF}
   167 {$ENDIF}
   168 begin
   168 begin
   169 PrevTime:= SDL_GetTicks;
   169 PrevTime:= SDL_GetTicks;
   192 {$IFDEF TOUCHINPUT}
   192 {$IFDEF TOUCHINPUT}
   193                 SDL_MOUSEMOTION: begin
   193                 SDL_MOUSEMOTION: begin
   194 {$IFDEF DEBUGFILE}
   194 {$IFDEF DEBUGFILE}
   195                         AddFileLog('*********************************************       motion');
   195                         AddFileLog('*********************************************       motion');
   196 {$ENDIF}
   196 {$ENDIF}
   197                         mouseState:= SDL_GetMouseState(0, @x, @y);
   197 						SDL_SelectMouse(event.motion.which);
   198                         SDL_GetRelativeMouseState(0, @dx, @dy);
   198                         mouseState:= SDL_GetMouseState(@x, @y);
       
   199                         SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
   199                         
   200                         
   200                         direction:= nodir;
   201                         direction:= nodir;
   201 
   202 
   202                         if boolean(mouseState) then
   203                         if boolean(mouseState) then
   203                         begin
   204                         begin
   229         {*MoveCamera is in uWord.pas -- conflicts with other commands*}
   230         {*MoveCamera is in uWord.pas -- conflicts with other commands*}
   230                 SDL_MOUSEBUTTONDOWN: begin
   231                 SDL_MOUSEBUTTONDOWN: begin
   231 {$IFDEF DEBUGFILE}
   232 {$IFDEF DEBUGFILE}
   232                         AddFileLog('*********************************************       touch down');
   233                         AddFileLog('*********************************************       touch down');
   233 {$ENDIF}
   234 {$ENDIF}
   234                         mouseState:= SDL_GetMouseState(0, @x, @y);                       
   235 						SDL_SelectMouse(event.motion.which);
   235 
   236                         mouseState:= SDL_GetMouseState(@x, @y);
       
   237                         SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
   236                         {* attack *}
   238                         {* attack *}
   237                         if (x > 50) and (x <= 270) and (y <= 50) then
   239                         if (x > 50) and (x <= 270) and (y <= 50) then
   238                         begin
   240                         begin
   239                                 WriteLnToConsole('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
   241                                 WriteLnToConsole('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y));
   240                                 uKeys.spaceKey:= true;
   242                                 uKeys.spaceKey:= true;
   267                 SDL_MOUSEBUTTONUP: begin
   269                 SDL_MOUSEBUTTONUP: begin
   268 {$IFDEF DEBUGFILE}
   270 {$IFDEF DEBUGFILE}
   269                         AddFileLog('*********************************************       touch up');
   271                         AddFileLog('*********************************************       touch up');
   270 {$ENDIF}
   272 {$ENDIF}
   271 
   273 
   272                         mouseState:= SDL_GetMouseState(0, @x, @y);
   274 						SDL_SelectMouse(event.motion.which);
   273                         uKeys.leftClick:= true;
   275                         mouseState:= SDL_GetMouseState(@x, @y);
       
   276                         SDL_GetRelativeMouseState(event.motion.which, @dx, @dy);
       
   277 						uKeys.leftClick:= true;
   274 
   278 
   275                         {* open ammo menu *}
   279                         {* open ammo menu *}
   276                         if (y > 430) and (x > 270) then
   280                         if (y > 430) and (x > 270) then
   277                         begin
   281                         begin
   278 {$IFDEF DEBUGFILE}
   282 {$IFDEF DEBUGFILE}
   397      cBitsStr:= ParamStr(4);
   401      cBitsStr:= ParamStr(4);
   398      val(cBitsStr, cBits);
   402      val(cBitsStr, cBits);
   399      val(ParamStr(5), ipcPort);
   403      val(ParamStr(5), ipcPort);
   400      cFullScreen:= ParamStr(6) = '1';
   404      cFullScreen:= ParamStr(6) = '1';
   401      isSoundEnabled:= ParamStr(7) = '1';
   405      isSoundEnabled:= ParamStr(7) = '1';
   402      isSoundHardware:= ParamStr(8) = '1';
   406      cVSyncInUse:= ParamStr(8) = '1';
   403      cLocaleFName:= ParamStr(9);
   407      cLocaleFName:= ParamStr(9);
   404      val(ParamStr(10), cInitVolume);
   408      val(ParamStr(10), cInitVolume);
   405      val(ParamStr(11), cTimerInterval);
   409      val(ParamStr(11), cTimerInterval);
   406      PathPrefix:= ParamStr(12);
   410      PathPrefix:= ParamStr(12);
   407      cShowFPS:= ParamStr(13) = '1';
   411      cShowFPS:= ParamStr(13) = '1';
   562 SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_JOYSTICK) >= 0, true);
   566 SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_JOYSTICK) >= 0, true);
   563 WriteLnToConsole(msgOK);
   567 WriteLnToConsole(msgOK);
   564 
   568 
   565 SDL_EnableUNICODE(1);
   569 SDL_EnableUNICODE(1);
   566 
   570 
   567 WriteToConsole('Init SDL_image... ');
       
   568 SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true);
       
   569 WriteLnToConsole(msgOK);
       
   570 
       
   571 WriteToConsole('Init SDL_ttf... ');
   571 WriteToConsole('Init SDL_ttf... ');
   572 SDLTry(TTF_Init <> -1, true);
   572 SDLTry(TTF_Init <> -1, true);
   573 WriteLnToConsole(msgOK);
   573 WriteLnToConsole(msgOK);
   574 
   574 
   575 ShowMainWindow;
   575 ShowMainWindow;
       
   576 
       
   577 AddProgress;
   576 
   578 
   577 ControllerInit; // has to happen before InitKbdKeyTable to map keys
   579 ControllerInit; // has to happen before InitKbdKeyTable to map keys
   578 InitKbdKeyTable;
   580 InitKbdKeyTable;
   579 
   581 
   580 if recordFileName = '' then InitIPC;
   582 if recordFileName = '' then InitIPC;
   595 InitTeams;
   597 InitTeams;
   596 AssignStores;
   598 AssignStores;
   597 
   599 
   598 if isSoundEnabled then
   600 if isSoundEnabled then
   599 	InitSound;
   601 	InitSound;
   600 
       
   601 StoreInit;
       
   602 
   602 
   603 isDeveloperMode:= false;
   603 isDeveloperMode:= false;
   604 
   604 
   605 TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
   605 TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true);
   606 
   606