hedgewars/hwengine.pas
branchflibqtfrontend
changeset 8363 0b4ac686fc44
parent 8304 620560c89284
parent 8354 c25bee85d6f8
--- a/hedgewars/hwengine.pas	Tue Dec 18 20:48:37 2012 +0400
+++ b/hedgewars/hwengine.pas	Fri Jan 04 21:44:40 2013 +0400
@@ -38,12 +38,13 @@
      {$IFDEF ANDROID}, GLUnit{$ENDIF}
      ;
 
+var isInternal: Boolean;
 
 {$IFDEF HWLIBRARY}
 procedure preInitEverything();
 procedure initEverything(complete:boolean);
 procedure freeEverything(complete:boolean);
-procedure Game(gameArgs: PPChar); cdecl; export;
+procedure Game(argc: LongInt; argv: PPChar); cdecl; export;
 procedure GenLandPreview(port: Longint); cdecl; export;
 
 implementation
@@ -53,6 +54,8 @@
 procedure freeEverything(complete:boolean); forward;
 {$ENDIF}
 
+{$INCLUDE "ArgParsers.inc"}
+
 ///////////////////////////////////////////////////////////////////////////////
 function DoTimer(Lag: LongInt): boolean;
 var s: shortstring;
@@ -261,18 +264,24 @@
             end; //end case event.type_ of
         end; //end while SDL_PollEvent(@event) <> 0 do
 
+        if (CursorMovementX <> 0) or (CursorMovementY <> 0) then
+            handlePositionUpdate(CursorMovementX * cameraKeyboardSpeed, CursorMovementY * cameraKeyboardSpeed);
+
         if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks) and
            ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then
         begin
             cScreenResizeDelay:= 0;
-            cScreenWidth:= cNewScreenWidth;
-            cScreenHeight:= cNewScreenHeight;
+            cWindowedWidth:= cNewScreenWidth;
+            cWindowedHeight:= cNewScreenHeight;
+            cScreenWidth:= cWindowedWidth;
+            cScreenHeight:= cWindowedHeight;
 
             ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true);
             WriteLnToConsole('window resize: ' + IntToStr(cScreenWidth) + ' x ' + IntToStr(cScreenHeight));
             ScriptOnScreenResize();
             InitCameraBorders();
             InitTouchInterface();
+            SendIPC('W' + IntToStr(cScreenWidth) + 'x' + IntToStr(cScreenHeight));
         end;
 
         CurrTime:= SDL_GetTicks();
@@ -320,29 +329,16 @@
 {$ENDIF}
 
 ///////////////////////////////////////////////////////////////////////////////
-procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF};
+procedure Game{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar); cdecl; export{$ENDIF};
 var p: TPathType;
     s: shortstring;
     i: LongInt;
 begin
 {$IFDEF HWLIBRARY}
     preInitEverything();
-    cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF};
-    ipcPort:= StrToInt(gameArgs[0]);
-    cScreenWidth:= StrToInt(gameArgs[1]);
-    cScreenHeight:= StrToInt(gameArgs[2]);
-    cReducedQuality:= StrToInt(gameArgs[3]);
-    cLocaleFName:= gameArgs[4];
-    UserNick:= gameArgs[5];
-    SetSound(gameArgs[6] = '1');
-    SetMusic(gameArgs[7] = '1');
-    cAltDamage:= gameArgs[8] = '1';
-    PathPrefix:= gameArgs[9];
-    UserPathPrefix:= '../Documents';
-    recordFileName:= gameArgs[10];
+    parseCommandLine(argc, argv);
 {$ENDIF}
     initEverything(true);
-
     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
     AddFileLog('Prefix: "' + PathPrefix +'"');
     AddFileLog('UserPrefix: "' + UserPathPrefix +'"');
@@ -544,68 +540,6 @@
 {$IFNDEF HWLIBRARY}
 
 ///////////////////////////////////////////////////////////////////////////////
-{$INCLUDE "ArgParsers.inc"}
-
-procedure GetParams;
-var startIndex,tmpInt: LongInt;
-    debug: string;
-begin
-    (*
-    tmpInt:=0;
-    while (tmpInt <= ParamCount) do
-        begin
-        WriteLn(stdout,inttostr(tmpInt) + ': ' + ParamStr(tmpInt));
-        inc(tmpInt);
-        end;
-    *)
-
-    if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then
-    begin
-        PathPrefix := ParamStr(1);
-        ipcPort    := StrToInt(ParamStr(2));
-        GameType   := gmtLandPreview;
-        exit;
-    end;
-
-    //TODO: prepend something so that we can use a cDefaultParamNum of parameters
-    if ParamCount = cDefaultParamNum then
-    begin
-        internalStartGameWithParameters();
-        exit;
-    end
-{$IFDEF USE_VIDEO_RECORDING}
-    else if ParamCount = cVideorecParamNum then
-    begin
-        internalStartVideoRecordingWithParameters();
-        exit;
-    end
-{$ENDIF};
-
-    if (ParamCount < 2) then
-        begin
-        DisplayUsage();
-        GameType:= gmtSyntax;
-        end
-    else
-        begin
-        if (ParamCount >= 2) then
-            begin
-            UserPathPrefix := '.';
-            PathPrefix     := ParamStr(1);
-            recordFileName := ParamStr(2);
-            startIndex     := 3;
-            end;
-
-        playReplayFileWithParameters(startIndex);
-        end;
-    (*
-    WriteLn(stdout,recordFilename);
-    WriteLn(stdout,PathPrefix);
-    WriteLn(stdout,UserPathPrefix);
-    *)
-end;
-
-///////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////// m a i n ///////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
 begin
@@ -614,9 +548,8 @@
 
     if GameType = gmtLandPreview then
         GenLandPreview()
-    else if GameType = gmtSyntax then
-        //Exit cleanly
-    else Game();
+    else if GameType <> gmtSyntax then
+        Game();
 
     // return 1 when engine is not called correctly
     halt(LongInt(GameType = gmtSyntax));