hedgewars/hwengine.dpr
changeset 1120 eb5a9f86f9c6
parent 1097 06b15817b8a0
child 1121 d595dc56b4f3
equal deleted inserted replaced
1119:be9700b424b2 1120:eb5a9f86f9c6
   130 TTF_Quit;
   130 TTF_Quit;
   131 SDL_Quit;
   131 SDL_Quit;
   132 halt
   132 halt
   133 end;
   133 end;
   134 
   134 
       
   135 ////////////////////////////////
       
   136 procedure Resize(w, h: LongInt);
       
   137 begin
       
   138 cScreenWidth:= w;
       
   139 cScreenHeight:= h;
       
   140 if cFullScreen then
       
   141 	ParseCommand('/fullscr 1', true)
       
   142 else
       
   143 	ParseCommand('/fullscr 0', true);
       
   144 end;
       
   145 
   135 ///////////////////
   146 ///////////////////
   136 procedure MainLoop;
   147 procedure MainLoop;
   137 var PrevTime,
   148 var PrevTime,
   138     CurrTime: Longword;
   149     CurrTime: Longword;
   139     event: TSDL_Event;
   150     event: TSDL_Event;
   140 begin
   151 begin
   141 PrevTime:= SDL_GetTicks;
   152 PrevTime:= SDL_GetTicks;
   142 repeat
   153 repeat
   143 while SDL_PollEvent(@event) <> 0 do
   154 while SDL_PollEvent(@event) <> 0 do
   144       case event.type_ of
   155 	case event.type_ of
   145            SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode);
   156 		SDL_KEYDOWN: if GameState = gsChat then KeyPressChat(event.key.keysym.unicode);
   146            SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
   157 		SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
   147                                cHasFocus:= event.active.gain = 1;
   158 				cHasFocus:= event.active.gain = 1;
   148            SDL_QUITEV: isTerminated:= true
   159 		SDL_VIDEORESIZE: Resize(max(event.resize.w, 320), max(event.resize.h, 240));
   149            end;
   160 		SDL_QUITEV: isTerminated:= true
       
   161 		end;
   150 CurrTime:= SDL_GetTicks;
   162 CurrTime:= SDL_GetTicks;
   151 if PrevTime + cTimerInterval <= CurrTime then
   163 if PrevTime + cTimerInterval <= CurrTime then
   152    begin
   164    begin
   153    DoTimer(CurrTime - PrevTime);
   165    DoTimer(CurrTime - PrevTime);
   154    PrevTime:= CurrTime
   166    PrevTime:= CurrTime