# HG changeset patch # User unc0rr # Date 1252608653 0 # Node ID d62b1f2249826ddcfd0f1480e4c033952b5b720a # Parent 66fcb4d62a53b7787dc08f644ebbb0d596108e8d - Implement zoom reset - Implement mouse wheel events processing - Increase zooming speed twice - Bind zoom to mouse wheel, zoom reset to middle mouse button - Some formatting changes (yes, I'm evil :D ) diff -r 66fcb4d62a53 -r d62b1f224982 QTfrontend/binds.cpp --- a/QTfrontend/binds.cpp Thu Sep 10 15:35:34 2009 +0000 +++ b/QTfrontend/binds.cpp Thu Sep 10 18:50:53 2009 +0000 @@ -52,8 +52,9 @@ {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), false}, {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), false}, {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), false}, - {"zoomin", "[", QT_TRANSLATE_NOOP("binds", "zoom in"), false}, - {"zoomout", "]", QT_TRANSLATE_NOOP("binds", "zoom out"), false}, + {"zoomin", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom in"), false}, + {"zoomout", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom out"), false}, + {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), false}, {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), false}, {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), false}, {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), false}, diff -r 66fcb4d62a53 -r d62b1f224982 QTfrontend/binds.h --- a/QTfrontend/binds.h Thu Sep 10 15:35:34 2009 +0000 +++ b/QTfrontend/binds.h Thu Sep 10 18:50:53 2009 +0000 @@ -21,7 +21,7 @@ #include -#define BINDS_NUMBER 38 +#define BINDS_NUMBER 39 struct BindAction { diff -r 66fcb4d62a53 -r d62b1f224982 QTfrontend/sdlkeys.h --- a/QTfrontend/sdlkeys.h Thu Sep 10 15:35:34 2009 +0000 +++ b/QTfrontend/sdlkeys.h Thu Sep 10 18:50:53 2009 +0000 @@ -21,6 +21,8 @@ {"mousel", "mousel"}, {"mousem", "mousem"}, {"mouser", "mouser"}, + {"wheelup", "wheelup"}, + {"wheeldown", "wheeldown"}, {"backspace", "backspace"}, {"tab", "tab"}, {"clear", "clear"}, diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/CCHandlers.inc Thu Sep 10 18:50:53 2009 +0000 @@ -690,6 +690,11 @@ if ZoomValue > 1.0 then ZoomValue:= ZoomValue - 0.25; end; +procedure chZoomReset(var s: shortstring); +begin +ZoomValue:= 2.0 +end; + procedure chChat(var s: shortstring); begin GameState:= gsChat; diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/SDLh.pas Thu Sep 10 18:50:53 2009 +0000 @@ -48,197 +48,211 @@ (* SDL *) const {$IFDEF WIN32} - SDLLibName = 'SDL.dll'; - {$ENDIF} - {$IFDEF UNIX} - {$IFDEF DARWIN} - SDLLibName = 'SDL'; - {$ELSE} - SDLLibName = 'libSDL.so'; - {$ENDIF} - {$ENDIF} - SDL_SWSURFACE = $00000000; - SDL_HWSURFACE = $00000001; - SDL_SRCALPHA = $00010000; - SDL_INIT_VIDEO = $00000020; - SDL_INIT_AUDIO = $00000010; + SDLLibName = 'SDL.dll'; + {$ENDIF} + {$IFDEF UNIX} + {$IFDEF DARWIN} + SDLLibName = 'SDL'; + {$ELSE} + SDLLibName = 'libSDL.so'; + {$ENDIF} + {$ENDIF} + SDL_SWSURFACE = $00000000; + SDL_HWSURFACE = $00000001; + SDL_SRCALPHA = $00010000; + SDL_INIT_VIDEO = $00000020; + SDL_INIT_AUDIO = $00000010; {$IFDEF SDL13} - SDL_ASYNCBLIT = $08000000; - SDL_ANYFORMAT = $10000000; - SDL_HWPALETTE = $00200000; - SDL_DOUBLEBUF = $00400000; - SDL_FULLSCREEN = $00800000; - SDL_HWACCEL = $08000000; - SDL_SRCCOLORKEY = $00020000; - SDL_RLEACCEL = $08000000; - SDL_NOFRAME = $02000000; - SDL_OPENGL = $04000000; - SDL_RESIZABLE = $01000000; + SDL_ASYNCBLIT = $08000000; + SDL_ANYFORMAT = $10000000; + SDL_HWPALETTE = $00200000; + SDL_DOUBLEBUF = $00400000; + SDL_FULLSCREEN = $00800000; + SDL_HWACCEL = $08000000; + SDL_SRCCOLORKEY = $00020000; + SDL_RLEACCEL = $08000000; + SDL_NOFRAME = $02000000; + SDL_OPENGL = $04000000; + SDL_RESIZABLE = $01000000; {$ELSE} - SDL_ASYNCBLIT = $00000004; - SDL_ANYFORMAT = $00100000; - SDL_HWPALETTE = $20000000; - SDL_DOUBLEBUF = $40000000; - SDL_FULLSCREEN = $80000000; - SDL_HWACCEL = $00000100; - SDL_SRCCOLORKEY = $00001000; - SDL_RLEACCEL = $00004000; - SDL_NOFRAME = $00000020; - SDL_OPENGL = $00000002; - SDL_RESIZABLE = $00000010; + SDL_ASYNCBLIT = $00000004; + SDL_ANYFORMAT = $00100000; + SDL_HWPALETTE = $20000000; + SDL_DOUBLEBUF = $40000000; + SDL_FULLSCREEN = $80000000; + SDL_HWACCEL = $00000100; + SDL_SRCCOLORKEY = $00001000; + SDL_RLEACCEL = $00004000; + SDL_NOFRAME = $00000020; + SDL_OPENGL = $00000002; + SDL_RESIZABLE = $00000010; {$ENDIF} - SDL_NOEVENT = 0; - SDL_ACTIVEEVENT = 1; - SDL_KEYDOWN = 2; - SDL_KEYUP = 3; - SDL_QUITEV = 12; - SDL_VIDEORESIZE = 16; + SDL_NOEVENT = 0; + SDL_ACTIVEEVENT = 1; + SDL_KEYDOWN = 2; + SDL_KEYUP = 3; + SDL_MOUSEBUTTONDOWN = 5; + SDL_MOUSEBUTTONUP = 6; + SDL_QUITEV = 12; + SDL_VIDEORESIZE = 16; {$IFDEF SDL13} - SDL_MOUSEMOTION = 5; + SDL_MOUSEMOTION = 5; {$ENDIF} - SDL_APPINPUTFOCUS = 2; + SDL_APPINPUTFOCUS = 2; + SDL_BUTTON_WHEELDUP = 4; + SDL_BUTTON_WHEELDOWN = 5; - RMask = $000000FF; - GMask = $0000FF00; - BMask = $00FF0000; - AMask = $FF000000; + RMask = $000000FF; + GMask = $0000FF00; + BMask = $00FF0000; + AMask = $FF000000; type PSDL_Rect = ^TSDL_Rect; - TSDL_Rect = record - {$IFDEF SDL13} - x, y, w, h: LongInt; - {$ELSE} - x, y: SmallInt; - w, h: Word; - {$ENDIF} - end; + TSDL_Rect = record + {$IFDEF SDL13} + x, y, w, h: LongInt; + {$ELSE} + x, y: SmallInt; + w, h: Word; + {$ENDIF} + end; - TPoint = record - X: LongInt; - Y: LongInt; - end; + TPoint = record + X: LongInt; + Y: LongInt; + end; - PSDL_PixelFormat = ^TSDL_PixelFormat; - TSDL_PixelFormat = record - palette: Pointer; - BitsPerPixel : Byte; - BytesPerPixel: Byte; - Rloss : Byte; - Gloss : Byte; - Bloss : Byte; - Aloss : Byte; - Rshift: Byte; - Gshift: Byte; - Bshift: Byte; - Ashift: Byte; - RMask : Longword; - GMask : Longword; - BMask : Longword; - AMask : Longword; - colorkey: Longword; - alpha : Byte; - end; + PSDL_PixelFormat = ^TSDL_PixelFormat; + TSDL_PixelFormat = record + palette: Pointer; + BitsPerPixel : Byte; + BytesPerPixel: Byte; + Rloss : Byte; + Gloss : Byte; + Bloss : Byte; + Aloss : Byte; + Rshift: Byte; + Gshift: Byte; + Bshift: Byte; + Ashift: Byte; + RMask : Longword; + GMask : Longword; + BMask : Longword; + AMask : Longword; + colorkey: Longword; + alpha : Byte; + end; - PSDL_Surface = ^TSDL_Surface; - TSDL_Surface = record - flags : Longword; - format: PSDL_PixelFormat; - w, h : LongInt; - pitch : Word; - pixels: Pointer; - offset: LongInt; - end; + PSDL_Surface = ^TSDL_Surface; + TSDL_Surface = record + flags : Longword; + format: PSDL_PixelFormat; + w, h : LongInt; + pitch : Word; + pixels: Pointer; + offset: LongInt; + end; - PSDL_Color = ^TSDL_Color; - TSDL_Color = record - case byte of - 0: (r: Byte; - g: Byte; - b: Byte; - unused: Byte; - ); - 1: (value: Longword); - end; + PSDL_Color = ^TSDL_Color; + TSDL_Color = record + case byte of + 0: (r: Byte; + g: Byte; + b: Byte; + unused: Byte; + ); + 1: (value: Longword); + end; - PSDL_RWops = ^TSDL_RWops; - TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; - TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; - TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; - TClose = function( context: PSDL_RWops ): LongInt; cdecl; + PSDL_RWops = ^TSDL_RWops; + TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; + TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; + TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; + TClose = function( context: PSDL_RWops ): LongInt; cdecl; - TStdio = record - autoclose: LongInt; - fp: pointer; - end; + TStdio = record + autoclose: LongInt; + fp: pointer; + end; + + TMem = record + base: PByte; + here: PByte; + stop: PByte; + end; - TMem = record - base: PByte; - here: PByte; - stop: PByte; - end; - - TUnknown = record - data1: Pointer; - end; + TUnknown = record + data1: Pointer; + end; - TSDL_RWops = record - seek: TSeek; - read: TRead; - write: TWrite; - close: TClose; - type_: Longword; - case Byte of - 0: (stdio: TStdio); - 1: (mem: TMem); - 2: (unknown: TUnknown); - end; + TSDL_RWops = record + seek: TSeek; + read: TRead; + write: TWrite; + close: TClose; + type_: Longword; + case Byte of + 0: (stdio: TStdio); + 1: (mem: TMem); + 2: (unknown: TUnknown); + end; + + TSDL_KeySym = record + scancode: Byte; + sym: Longword; + modifier: Longword; + unicode: Word; + end; - TSDL_KeySym = record - scancode: Byte; - sym: Longword; - modifier: Longword; - unicode: Word; - end; + TSDL_ActiveEvent = record + type_: byte; + gain: byte; + state: byte; + end; - TSDL_ActiveEvent = record - type_: byte; - gain: byte; - state: byte; - end; + TSDL_KeyboardEvent = record + type_: Byte; + which: Byte; + state: Byte; + keysym: TSDL_KeySym; + end; - TSDL_KeyboardEvent = record - type_: Byte; - which: Byte; - state: Byte; - keysym: TSDL_KeySym; - end; + TSDL_MouseButtonEvent = record + _type, + which, + button, + state: byte; + x, y: word; + end; - TSDL_GLattr = ( SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_RETAINED_BACKING, - SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION ); + TSDL_GLattr = ( + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION + ); {$IFDEF SDL13} TSDL_MouseMotionEvent = record @@ -268,6 +282,8 @@ SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent); SDL_QUITEV: (quit: TSDL_QuitEvent); SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); {$IFDEF SDL13} SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); {$ENDIF} diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/hwengine.pas Thu Sep 10 18:50:53 2009 +0000 @@ -176,6 +176,8 @@ SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then cHasFocus:= event.active.gain = 1; //SDL_VIDEORESIZE: Resize(max(event.resize.w, 600), max(event.resize.h, 450)); + SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; + SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true; SDL_QUITEV: isTerminated:= true end; CurrTime:= SDL_GetTicks; diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/uConsole.pas --- a/hedgewars/uConsole.pas Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/uConsole.pas Thu Sep 10 18:50:53 2009 +0000 @@ -260,6 +260,7 @@ RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); +RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); RegisterVariable('skip' , vtCommand, @chSkip , false); RegisterVariable('history' , vtCommand, @chHistory , true ); RegisterVariable('chat' , vtCommand, @chChat , true ); diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/uKeys.pas Thu Sep 10 18:50:53 2009 +0000 @@ -33,6 +33,8 @@ procedure SetDefaultBinds; var KbdKeyPressed: boolean; + wheelUp: boolean = false; + wheelDown: boolean = false; implementation uses SDLh, uTeams, uConsole, uMisc, uStore; @@ -70,7 +72,7 @@ i := SDL_GetMouseState(nil, nil); {$ENDIF} - +// mouse buttons {$IFDEF DARWIN} pkbd^[1]:= ((i and 1) and not (pkbd^[306] or pkbd^[305])); pkbd^[3]:= ((i and 1) and (pkbd^[306] or pkbd^[305])) or (i and 4); @@ -80,7 +82,13 @@ {$ENDIF} pkbd^[2]:= ((i shr 1) and 1); +// mouse wheels (see event loop in project file) +pkbd^[4]:= ord(wheelDown); +pkbd^[5]:= ord(wheelUp); +wheelUp:= false; +wheelDown:= false; +// now process strokes for i:= 1 to cKeyMaxIndex do if CurrentBinds[i][0] <> #0 then begin @@ -121,9 +129,13 @@ KeyNames[1]:= 'mousel'; KeyNames[2]:= 'mousem'; KeyNames[3]:= 'mouser'; -for i:= 4 to cKeyMaxIndex do +KeyNames[4]:= 'wheelup'; +KeyNames[5]:= 'wheeldown'; + +for i:= 6 to cKeyMaxIndex do begin s:= SDL_GetKeyName(i); + //addfilelog(inttostr(i) + ' ' + s); if s = 'unknown key' then KeyNames[i]:= '' else begin for t:= 1 to Length(s) do @@ -132,17 +144,18 @@ end; end; -DefaultBinds[ 27]:= 'quit'; // esc -DefaultBinds[ 48]:= '+volup'; // 0 -DefaultBinds[ 57]:= '+voldown'; // 9 -DefaultBinds[ 96]:= 'history'; // ` -DefaultBinds[ 99]:= 'capture'; // c -DefaultBinds[104]:= 'findhh'; // h -DefaultBinds[112]:= 'pause'; // p -DefaultBinds[115]:= '+speedup'; // s -DefaultBinds[116]:= 'chat'; // t -DefaultBinds[121]:= 'confirm'; // y -DefaultBinds[127]:= 'rotmask'; // canc +DefaultBinds[ 27]:= 'quit'; +DefaultBinds[ 96]:= 'history'; +DefaultBinds[127]:= 'rotmask'; + +DefaultBinds[KeyNameToCode('0')]:= '+volup'; +DefaultBinds[KeyNameToCode('9')]:= '+voldown'; +DefaultBinds[KeyNameToCode('c')]:= 'capture'; +DefaultBinds[KeyNameToCode('h')]:= 'findhh'; +DefaultBinds[KeyNameToCode('p')]:= 'pause'; +DefaultBinds[KeyNameToCode('s')]:= '+speedup'; +DefaultBinds[KeyNameToCode('t')]:= 'chat'; +DefaultBinds[KeyNameToCode('y')]:= 'confirm'; DefaultBinds[KeyNameToCode('f12')]:= 'fullscr'; diff -r 66fcb4d62a53 -r d62b1f224982 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Thu Sep 10 15:35:34 2009 +0000 +++ b/hedgewars/uWorld.pas Thu Sep 10 18:50:53 2009 +0000 @@ -134,27 +134,27 @@ g:= 0; while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do begin - if (Ammo^[i, t].AmmoType <> amNothing) then - begin - l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; + if (Ammo^[i, t].AmmoType <> amNothing) then + begin + l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; - if l >= 0 then - begin - DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l); - end else - DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); + if l >= 0 then + begin + DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); + DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l); + end else + DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if (Slot = i) - and (CursorPoint.X >= x + g * 33 + 35) - and (CursorPoint.X < x + g * 33 + 68) then - begin - if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); - Pos:= t; - end; - inc(g) - end; - inc(t) + if (Slot = i) + and (CursorPoint.X >= x + g * 33 + 35) + and (CursorPoint.X < x + g * 33 + 68) then + begin + if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); + Pos:= t; + end; + inc(g) + end; + inc(t) end end; dec(y, 1); @@ -298,12 +298,12 @@ begin if ZoomValue < zoom then begin - zoom:= zoom - 0.001 * Lag; + zoom:= zoom - 0.002 * Lag; if ZoomValue > zoom then zoom:= ZoomValue end else if ZoomValue > zoom then begin - zoom:= zoom + 0.001 * Lag; + zoom:= zoom + 0.002 * Lag; if ZoomValue < zoom then zoom:= ZoomValue end;