187 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
185 //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); |
188 {$IFDEF IPHONEOS} |
186 {$IFDEF IPHONEOS} |
189 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
187 {*MoveCamera is in uWord.pas -- conflicts with other commands*} |
190 {*Keys are in uKeys.pas*} |
188 {*Keys are in uKeys.pas*} |
191 SDL_MOUSEBUTTONDOWN: begin |
189 SDL_MOUSEBUTTONDOWN: begin |
192 AddFileLog('********************************************* touch down'); |
190 AddFileLog('********************************************* touch down'); |
193 |
191 |
194 mouseState:= SDL_GetMouseState(0, @x, @y); |
192 SDL_GetMouseState(0, @x, @y); |
195 |
193 |
196 if x <= 50 then |
194 {* zoom slider *} |
|
195 if (x <= 50) and (y <= 430) then |
197 begin |
196 begin |
198 {$IFDEF DEBUGFILE} |
197 {$IFDEF DEBUGFILE} |
199 AddFileLog('Wheel -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
198 AddFileLog('Wheel -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
200 {$ENDIF} |
199 {$ENDIF} |
201 {* sliding *} |
200 if oldy_zoom = -1 then oldy_zoom:= y |
202 if oldy - y > 0 then uKeys.wheelUp:= true |
201 else |
203 else uKeys.wheelDown:= true; |
202 begin |
204 {* update value only if movement is consistent *} |
203 if oldy_zoom - y > 10 then uKeys.wheelUp:= true |
205 // if (y > oldy - 10 ) or (y > oldy + 10 ) then oldy:= y |
204 else if oldy_zoom -y < -10 then uKeys.wheelDown:= true; |
206 // oldy:= y; |
205 {* update value only if movement is consistent *} |
207 end; |
206 if (y > oldy_zoom + 20 ) or (y < oldy_zoom - 20 ) then oldy_zoom:= y |
208 |
207 end; |
209 {* keys *} |
208 end; |
210 {* if (x > 50) then |
209 {* reset zoom *} |
211 begin |
210 if (x <= 50) and (y > 430) then |
212 AddFileLog('Arrow Key -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
211 begin |
213 |
212 {$IFDEF DEBUGFILE} |
214 if (y <= 50) and (x > 135) and (x <= 185) then uKeys.upKey:= true; |
213 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
215 if (y > 430) and (x > 135) and (x <= 185) then uKeys.downKey:= true; |
214 {$ENDIF} |
216 if (x > 270) and (y > 215) and (y > 265) then uKeys.rightClick:= true; |
215 uKeys.middleClick:= true; |
217 if (x <= 100) and (y > 215) and (y > 265) then uKeys.leftClick:= true; |
216 end; |
218 end;*} |
217 {* aim slider *} |
219 |
218 if (x > 230) and (y <= 430) then |
|
219 begin |
|
220 {$IFDEF DEBUGFILE} |
|
221 AddFileLog('Up&Down -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
222 {$ENDIF} |
|
223 if oldy_aim = -1 then oldy_aim:= y |
|
224 else |
|
225 begin |
|
226 if oldy_aim - y > 10 then uKeys.upKey:= true |
|
227 else if oldy_aim -y < -10 then uKeys.downKey:= true; |
|
228 {* update value only if movement is consistent *} |
|
229 if (y > oldy_aim + 20 ) or (y < oldy_aim - 20 ) then oldy_aim:= y |
|
230 end; |
|
231 end; |
|
232 {* reset zoom *} |
|
233 if (x <= 50) and (y > 430) then |
|
234 begin |
|
235 {$IFDEF DEBUGFILE} |
|
236 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
237 {$ENDIF} |
|
238 uKeys.middleClick:= true; |
|
239 end; |
|
240 {* long jump *} |
220 if (y > 430) and (x > 50) and (x <= 135) then |
241 if (y > 430) and (x > 50) and (x <= 135) then |
221 begin |
242 begin |
222 {$IFDEF DEBUGFILE} |
243 {$IFDEF DEBUGFILE} |
223 AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
244 AddFileLog('Enter -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
224 {$ENDIF} |
245 {$ENDIF} |
225 uKeys.enterKey:=true; |
246 uKeys.enterKey:= true; |
226 end; |
247 end; |
|
248 {* high jump *} |
227 if (y > 430) and (x > 185) and (x <= 270) then |
249 if (y > 430) and (x > 185) and (x <= 270) then |
228 begin |
250 begin |
229 {$IFDEF DEBUGFILE} |
251 {$IFDEF DEBUGFILE} |
230 AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
252 AddFileLog('Backspace -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
231 {$ENDIF} |
253 {$ENDIF} |
232 uKeys.backspaceKey:=true; |
254 uKeys.backspaceKey:= true; |
233 |
255 |
234 end; |
256 end; |
|
257 {* attack *} |
235 if (y <= 50) and (x > 50) and (x <= 270) then |
258 if (y <= 50) and (x > 50) and (x <= 270) then |
236 begin |
259 begin |
237 {$IFDEF DEBUGFILE} |
260 {$IFDEF DEBUGFILE} |
238 AddFileLog('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
261 AddFileLog('Space DOWN -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
239 {$ENDIF} |
262 {$ENDIF} |
240 uKeys.spaceKey:= true; |
263 uKeys.spaceKey:= true; |
241 uKeys.isAttacking:= true; |
264 uKeys.isAttacking:= true; |
242 end |
265 end |
243 else |
266 else |
244 begin |
267 begin |
245 AddFileLog('Space UP -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
268 AddFileLog('Space UP -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
246 uKeys.isAttacking:= false; |
269 uKeys.isAttacking:= false; |
247 end; |
270 end; |
248 end; |
271 end; |
249 SDL_MOUSEBUTTONUP: begin |
272 SDL_MOUSEBUTTONUP: begin |
250 AddFileLog('********************************************* touch up'); |
273 AddFileLog('********************************************* touch up'); |
251 |
274 |
252 if bShowAmmoMenu = true then ParseCommand('/put', true); |
275 if bShowAmmoMenu = true then uKeys.leftClick:= true; |
253 |
276 |
254 mouseState:= SDL_GetMouseState(0, @x, @y); |
277 SDL_GetMouseState(0, @x, @y); |
255 {* open ammo menu *} |
278 {* open ammo menu *} |
256 if (y > 430) and (x > 270) then |
279 if (y > 430) and (x > 270) then |
257 begin |
280 begin |
258 {$IFDEF DEBUGFILE} |
281 {$IFDEF DEBUGFILE} |
259 AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
282 AddFileLog('Right Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y) ); |
260 {$ENDIF} |
283 {$ENDIF} |
261 uKeys.rightClick:= true; |
284 uKeys.rightClick:= true; |
262 end; |
285 end; |
263 {* reset zoom *} |
|
264 if (x > 270) and (y <= 50) then |
|
265 begin |
|
266 {$IFDEF DEBUGFILE} |
|
267 AddFileLog('Middle Click -- x: ' + inttostr(x) + ' y: ' + inttostr(y)); |
|
268 {$ENDIF} |
|
269 uKeys.middleClick:= true; |
|
270 end; |
|
271 end; |
286 end; |
272 SDL_JOYAXIS: begin |
287 SDL_JOYAXIS: begin |
273 {axis 2 = back and forth; axis 1 = up and down; axis 0 = left and right} |
288 {* axis 0 = left and right; |
274 //AddFileLog('which: ' + inttostr(event.jaxis.which) + ' axis: ' + inttostr(event.jaxis.axis) + ' value: ' + inttostr(event.jaxis.value)); |
289 axis 1 = up and down; |
|
290 axis 2 = back and forth; *} |
275 if (event.jaxis.axis = 0) and (CurrentTeam <> nil) then |
291 if (event.jaxis.axis = 0) and (CurrentTeam <> nil) then |
276 begin |
292 begin |
277 if (modulo(event.jaxis.value) > (oldJoy + 400)) or (modulo(event.jaxis.value) < (oldJoy - 400)) then |
293 if event.jaxis.value > 1500 then |
278 begin |
294 begin |
279 if event.jaxis.value > 1500 then |
295 uKeys.rightKey:= true; |
280 begin |
296 uKeys.isWalking:= true; |
281 if dir <> right then ParseCommand('-left', true); |
297 end |
282 ParseCommand('+right', true); |
298 else |
283 dir:= right; |
299 if event.jaxis.value <= -1500 then |
|
300 begin |
|
301 uKeys.leftKey:= true; |
|
302 uKeys.isWalking:= true; |
284 end |
303 end |
285 else |
304 else |
286 if event.jaxis.value <= -1500 then |
305 if (event.jaxis.value > -1500) and (event.jaxis.value <= 1500) then uKeys.isWalking:= false; |
287 begin |
306 {$IFDEF DEBUGFILE} |
288 if dir <> left then ParseCommand('-right', true); |
307 AddFileLog('Joystick value: ' + inttostr(event.jaxis.value)); |
289 ParseCommand('+left', true); |
308 {$ENDIF} |
290 dir:= left; |
|
291 end |
|
292 else |
|
293 if (event.jaxis.value > 0) and (event.jaxis.value <= 1500) then ParseCommand('-right', true) |
|
294 else |
|
295 if (event.jaxis.value <= 0) and (event.jaxis.value > -1500) then ParseCommand('-left', true); |
|
296 {$IFDEF DEBUGFILE} |
|
297 AddFileLog('Joystick value: ' + inttostr(event.jaxis.value) + ' oldJoy: ' + inttostr(oldJoy)); |
|
298 {$ENDIF} |
|
299 oldJoy:= modulo(event.jaxis.value); |
|
300 end; |
|
301 end; |
309 end; |
302 |
310 |
303 end; |
311 end; |
304 |
312 |
305 {$ELSE} |
313 {$ELSE} |