# HG changeset patch # User unc0rr # Date 1211663449 0 # Node ID 4e0c3ad89483c968b7b9ac270acd06a8feb0810d # Parent 42c5cc87cbd121df96acac4e549b7f3445252d49 - 't' key for entering chat message - gsChat state for entering message - Simplify logic in ProcessKbd diff -r 42c5cc87cbd1 -r 4e0c3ad89483 QTfrontend/binds.cpp --- a/QTfrontend/binds.cpp Sat May 24 18:37:04 2008 +0000 +++ b/QTfrontend/binds.cpp Sat May 24 21:10:49 2008 +0000 @@ -45,6 +45,7 @@ {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), false}, {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), false}, {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), true}, + {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), false}, {"pause", "p", QT_TRANSLATE_NOOP("binds", "pause"), false}, {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), false}, {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), false}, diff -r 42c5cc87cbd1 -r 4e0c3ad89483 QTfrontend/binds.h --- a/QTfrontend/binds.h Sat May 24 18:37:04 2008 +0000 +++ b/QTfrontend/binds.h Sat May 24 21:10:49 2008 +0000 @@ -21,7 +21,7 @@ #include -#define BINDS_NUMBER 32 +#define BINDS_NUMBER 33 struct BindAction { diff -r 42c5cc87cbd1 -r 4e0c3ad89483 hedgewars/hwengine.dpr --- a/hedgewars/hwengine.dpr Sat May 24 18:37:04 2008 +0000 +++ b/hedgewars/hwengine.dpr Sat May 24 21:10:49 2008 +0000 @@ -99,7 +99,7 @@ FinishProgress; GameState:= gsGame end; - gsGame : begin + gsGame: begin ProcessKbd; DoGameTick(Lag); ProcessVisualGears(Lag); @@ -111,7 +111,12 @@ DrawWorld(Lag, SDLPrimSurface); DrawConsole(SDLPrimSurface); end; - gsExit : begin + gsChat: begin + DoGameTick(Lag); + ProcessVisualGears(Lag); + DrawWorld(Lag, SDLPrimSurface); + end; + gsExit: begin OnDestroy; end; end; diff -r 42c5cc87cbd1 -r 4e0c3ad89483 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sat May 24 18:37:04 2008 +0000 +++ b/hedgewars/uChat.pas Sat May 24 21:10:49 2008 +0000 @@ -25,7 +25,7 @@ procedure KeyPressChat(Key: Longword); implementation -uses uMisc, uStore, uConsts, SDLh; +uses uMisc, uStore, uConsts, SDLh, uConsole; const MaxStrIndex = 7; @@ -69,7 +69,7 @@ SDL_FreeSurface(strSurface); - +cl.s:= str; cl.Time:= RealTicks + 7500; cl.Tex:= Surface2Tex(resSurface); SDL_FreeSurface(resSurface) @@ -100,7 +100,11 @@ inc(t) end; -visibleCount:= cnt +visibleCount:= cnt; + +if (GameState = gsChat) + and (InputStr.Tex <> nil) then + DrawTexture(11, visibleCount * 16 + 10 + cConsoleYAdd, InputStr.Tex); end; procedure KeyPressChat(Key: Longword); @@ -116,8 +120,12 @@ SetLine(InputStr, InputStr.s) end; 13,271: begin - AddChatString(InputStr.s); - SetLine(InputStr, ''); + if Length(InputStr.s) > 0 then + begin + AddChatString(InputStr.s); + ParseCommand('/say ' + InputStr.s, true); + SetLine(InputStr, ''); + end; GameState:= gsGame end else diff -r 42c5cc87cbd1 -r 4e0c3ad89483 hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Sat May 24 18:37:04 2008 +0000 +++ b/hedgewars/uKeys.pas Sat May 24 21:10:49 2008 +0000 @@ -67,22 +67,19 @@ pkbd^[2]:= ((i shr 1) and 1); pkbd^[3]:= ((i shr 2) and 1); for i:= 1 to cKeyMaxIndex do - if CurrentBinds[i][0] <> #0 then - begin - if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true; - if CurrentBinds[i][1] = '+' then - begin - if (pkbd^[i] <> 0)and(tkbd[i] = 0) then ParseCommand(CurrentBinds[i], Trusted) else - if (pkbd^[i] = 0)and(tkbd[i] <> 0) then - begin - s:= CurrentBinds[i]; - s[1]:= '-'; - ParseCommand(s, Trusted) - end; - end else - if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted); - tkbd[i]:= pkbd^[i] - end +if CurrentBinds[i][0] <> #0 then + begin + if (i > 3) and (pkbd^[i] <> 0) then KbdKeyPressed:= true; + if (tkbd[i] = 0) and (pkbd^[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted) + else if (CurrentBinds[i][1] = '+') + and (pkbd^[i] = 0)and(tkbd[i] <> 0) then + begin + s:= CurrentBinds[i]; + s[1]:= '-'; + ParseCommand(s, Trusted) + end; + tkbd[i]:= pkbd^[i] + end end; procedure ResetKbd;