hedgewars/hwengine.pas
changeset 6415 af2047bb4f70
parent 6341 ccc0a58e123d
child 6580 6155187bf599
equal deleted inserted replaced
6414:8474b7fa84d6 6415:af2047bb4f70
    29 program hwengine;
    29 program hwengine;
    30 {$ENDIF}
    30 {$ENDIF}
    31 
    31 
    32 uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
    32 uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
    33      uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions,
    33      uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions,
    34      sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted;
    34      sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
       
    35      {$IFDEF SDL13}, uTouch{$ENDIF}{$IFDEF ANDROID}, GLUnit{$ENDIF};
    35 
    36 
    36 {$IFDEF HWLIBRARY}
    37 {$IFDEF HWLIBRARY}
    37 procedure initEverything(complete:boolean);
    38 procedure initEverything(complete:boolean);
    38 procedure freeEverything(complete:boolean);
    39 procedure freeEverything(complete:boolean);
    39 procedure Game(gameArgs: PPChar); cdecl; export;
    40 procedure Game(gameArgs: PPChar); cdecl; export;
       
    41 procedure GenLandPreview(port: Longint); cdecl; export;
    40 
    42 
    41 implementation
    43 implementation
    42 {$ELSE}
    44 {$ELSE}
    43 procedure OnDestroy; forward;
    45 procedure OnDestroy; forward;
    44 procedure initEverything(complete:boolean); forward;
    46 procedure initEverything(complete:boolean); forward;
   185                         cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth);
   187                         cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth);
   186                         cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight);
   188                         cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight);
   187                         cScreenResizeDelay:= RealTicks+500;
   189                         cScreenResizeDelay:= RealTicks+500;
   188                         *)
   190                         *)
   189                         end;
   191                         end;
       
   192                 SDL_FINGERMOTION: onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId);
       
   193                 SDL_FINGERDOWN: onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
       
   194                 SDL_FINGERUP: onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId);
   190 {$ELSE}
   195 {$ELSE}
   191                 SDL_KEYDOWN: if GameState = gsChat then
   196                 SDL_KEYDOWN: if GameState = gsChat then
   192                     KeyPressChat(event.key.keysym.unicode);
   197                     KeyPressChat(event.key.keysym.unicode);
   193                 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true;
   198                 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true;
   194                 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true;
   199                 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true;
   252 begin
   257 begin
   253 {$IFDEF HWLIBRARY}
   258 {$IFDEF HWLIBRARY}
   254     cBits:= 32;
   259     cBits:= 32;
   255     cFullScreen:= false;
   260     cFullScreen:= false;
   256     cTimerInterval:= 8;
   261     cTimerInterval:= 8;
   257     PathPrefix:= 'Data';
       
   258     UserPathPrefix:= '../Documents';
       
   259     cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
   262     cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
   260     val(gameArgs[0], ipcPort);
   263     val(gameArgs[0], ipcPort);
   261     val(gameArgs[1], cScreenWidth);
   264     val(gameArgs[1], cScreenWidth);
   262     val(gameArgs[2], cScreenHeight);
   265     val(gameArgs[2], cScreenHeight);
   263     val(gameArgs[3], cReducedQuality);
   266     val(gameArgs[3], cReducedQuality);
   266     else cLocale := Copy(cLocaleFName,1,2);
   269     else cLocale := Copy(cLocaleFName,1,2);
   267     UserNick:= gameArgs[5];
   270     UserNick:= gameArgs[5];
   268     isSoundEnabled:= gameArgs[6] = '1';
   271     isSoundEnabled:= gameArgs[6] = '1';
   269     isMusicEnabled:= gameArgs[7] = '1';
   272     isMusicEnabled:= gameArgs[7] = '1';
   270     cAltDamage:= gameArgs[8] = '1';
   273     cAltDamage:= gameArgs[8] = '1';
   271     val(gameArgs[9], rotationQt);
   274     PathPrefix:= gameArgs[9];
       
   275     UserPathPrefix:= '../Documents';
   272     recordFileName:= gameArgs[10];
   276     recordFileName:= gameArgs[10];
   273     cStereoMode:= smNone;
   277     cStereoMode:= smNone;
   274 {$ENDIF}
   278 {$ENDIF}
   275     cMinScreenWidth:= min(cScreenWidth, cMinScreenWidth);
   279     cMinScreenWidth:= min(cScreenWidth, cMinScreenWidth);
   276     cMinScreenHeight:= min(cScreenHeight, cMinScreenHeight);
   280     cMinScreenHeight:= min(cScreenHeight, cMinScreenHeight);
   277     cOrigScreenWidth:= cScreenWidth;
   281     cOrigScreenWidth:= cScreenWidth;
   278     cOrigScreenHeight:= cScreenHeight;
   282     cOrigScreenHeight:= cScreenHeight;
   279 
   283 
   280     initEverything(true);
   284     initEverything(true);
   281 
       
   282     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
   285     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
   283     AddFileLog('Prefix: "' + PathPrefix +'"');
   286     AddFileLog('Prefix: "' + PathPrefix +'"');
   284     AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
   287     AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
   285     for i:= 0 to ParamCount do
   288     for i:= 0 to ParamCount do
   286         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   289         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
   382 
   385 
   383     uIO.initModule;
   386     uIO.initModule;
   384 
   387 
   385     if complete then
   388     if complete then
   386     begin
   389     begin
       
   390 {$IFDEF ANDROID}GLUnit.init;{$ENDIF}
       
   391 {$IFDEF SDL13}uTouch.initModule;{$ENDIF}
   387         uAI.initModule;
   392         uAI.initModule;
   388         //uAIActions does not need initialization
   393         //uAIActions does not need initialization
   389         //uAIAmmoTests does not need initialization
   394         //uAIAmmoTests does not need initialization
   390         uAIMisc.initModule;
   395         uAIMisc.initModule;
   391         uAmmos.initModule;
   396         uAmmos.initModule;