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