147 prevFocusState: boolean; |
147 prevFocusState: boolean; |
148 begin |
148 begin |
149 PrevTime:= SDL_GetTicks; |
149 PrevTime:= SDL_GetTicks; |
150 while isTerminated = false do |
150 while isTerminated = false do |
151 begin |
151 begin |
152 |
152 SDL_PumpEvents(); |
153 while SDL_PollEvent(@event) <> 0 do |
153 {$IFDEF SDL13} |
|
154 while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT) > 0 do |
|
155 {$ELSE} |
|
156 while SDL_PeepEvents(@event, 1, SDL_GETEVENT, SDL_ALLEVENTS) > 0 do |
|
157 {$ENDIF} |
154 begin |
158 begin |
155 case event.type_ of |
159 case event.type_ of |
156 SDL_KEYDOWN: if GameState = gsChat then |
160 SDL_KEYDOWN: if GameState = gsChat then |
157 {$IFDEF SDL13} |
161 {$IFDEF SDL13} |
158 // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3 |
162 // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3 |
174 cHasFocus:= event.active.gain = 1; |
178 cHasFocus:= event.active.gain = 1; |
175 if prevFocusState xor cHasFocus then |
179 if prevFocusState xor cHasFocus then |
176 onFocusStateChanged() |
180 onFocusStateChanged() |
177 end; |
181 end; |
178 SDL_VIDEORESIZE: begin |
182 SDL_VIDEORESIZE: begin |
179 // using lower values causes widget overlap and video issues |
183 // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts |
180 if event.resize.w > cMinScreenWidth then cScreenWidth:= event.resize.w |
184 // Change by sheepluva: |
181 else cScreenWidth:= cMinScreenWidth; |
185 // Let's only use even numbers for custom width/height since I ran into scaling issues with odd width values. |
182 if event.resize.h > cMinScreenHeight then cScreenHeight:= event.resize.h |
186 // Maybe just fixes the symptom not the actual cause(?), I'm too tired to find out :P |
183 else cScreenHeight:= cMinScreenHeight; |
187 cNewScreenWidth:= max(2 * (event.resize.w div 2), cMinScreenWidth); |
184 ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true); |
188 cNewScreenHeight:= max(2 * (event.resize.h div 2), cMinScreenHeight); |
185 WriteLnToConsole('window resize'); |
189 cScreenResizeDelay:= RealTicks+500; |
186 InitCameraBorders(); |
|
187 end; |
190 end; |
188 {$ENDIF} |
191 {$ENDIF} |
189 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
192 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); |
190 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
193 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); |
191 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
194 SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); |
192 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
195 SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); |
193 SDL_QUITEV: isTerminated:= true |
196 SDL_QUITEV: isTerminated:= true |
194 end; //end case event.type_ of |
197 end; //end case event.type_ of |
195 end; //end while SDL_PollEvent(@event) <> 0 do |
198 end; //end while SDL_PollEvent(@event) <> 0 do |
|
199 if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks) and ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then |
|
200 begin |
|
201 cScreenResizeDelay:= 0; |
|
202 cScreenWidth:= cNewScreenWidth; |
|
203 cScreenHeight:= cNewScreenHeight; |
|
204 |
|
205 ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true); |
|
206 WriteLnToConsole('window resize: ' + IntToStr(cScreenWidth) + ' x ' + IntToStr(cScreenHeight)); |
|
207 ScriptOnScreenResize(); |
|
208 InitCameraBorders() |
|
209 end; |
196 |
210 |
197 if isTerminated = false then |
211 if isTerminated = false then |
198 begin |
212 begin |
199 CurrTime:= SDL_GetTicks; |
213 CurrTime:= SDL_GetTicks; |
200 if PrevTime + longword(cTimerInterval) <= CurrTime then |
214 if PrevTime + longword(cTimerInterval) <= CurrTime then |
238 cAltDamage:= gameArgs[8] = '1'; |
252 cAltDamage:= gameArgs[8] = '1'; |
239 val(gameArgs[9], rotationQt); |
253 val(gameArgs[9], rotationQt); |
240 recordFileName:= gameArgs[10]; |
254 recordFileName:= gameArgs[10]; |
241 cStereoMode:= smNone; |
255 cStereoMode:= smNone; |
242 {$ENDIF} |
256 {$ENDIF} |
243 cMinScreenWidth:= cScreenWidth; |
257 cMinScreenWidth:= min(cScreenWidth, cMinScreenWidth); |
244 cMinScreenHeight:= cScreenHeight; |
258 cMinScreenHeight:= min(cScreenHeight, cMinScreenHeight); |
245 cOrigScreenWidth:= cScreenWidth; |
259 cOrigScreenWidth:= cScreenWidth; |
246 cOrigScreenHeight:= cScreenHeight; |
260 cOrigScreenHeight:= cScreenHeight; |
247 if 480 < cMinScreenWidth then cMinScreenWidth:= 480; |
|
248 if 320 < cMinScreenHeight then cMinScreenHeight:= 320; |
|
249 |
261 |
250 initEverything(true); |
262 initEverything(true); |
251 |
263 |
252 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); |
264 WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); |
253 AddFileLog('Prefix: "' + PathPrefix +'"'); |
265 AddFileLog('Prefix: "' + PathPrefix +'"'); |