# HG changeset patch # User unc0rr # Date 1290356085 -10800 # Node ID 54a78ec6aac436783dd53378257c81ae1cdc0cfb # Parent 9cb6990af584ecb28fb6f230f67f6ba4c00a9488 Remove uChat dependency from uCommands diff -r 9cb6990af584 -r 54a78ec6aac4 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Sun Nov 21 19:07:43 2010 +0300 +++ b/hedgewars/CCHandlers.inc Sun Nov 21 19:14:45 2010 +0300 @@ -38,16 +38,7 @@ GameState:= gsExit end else - begin - GameState:= gsChat; - KeyPressChat(27); - KeyPressChat(47); - KeyPressChat(116); - KeyPressChat(101); - KeyPressChat(97); - KeyPressChat(109); - KeyPressChat(32) - end + ParseCommand('chat team', true); end; procedure chCheckProto(var s: shortstring); @@ -339,27 +330,6 @@ perfExt_NewTurnBeginning(); end; -procedure chSay(var s: shortstring); -begin -SendIPC('s' + s); - -if copy(s, 1, 4) = '/me ' then - s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) -else - s:= #1 + UserNick + ': ' + s; - -AddChatString(s) -end; - -procedure chTeamSay(var s: shortstring); -begin -SendIPC('b' + s); - -s:= #4 + '[Team] ' + UserNick + ': ' + s; - -AddChatString(s) -end; - procedure chTimer(var s: shortstring); begin if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; @@ -592,16 +562,4 @@ ZoomValue:= cDefaultZoomLevel; end; -procedure chChat(var s: shortstring); -begin - s:= s; // avoid compiler hint - GameState:= gsChat; - KeyPressChat(27) -end; -procedure chHistory(var s: shortstring); -begin - s:= s; // avoid compiler hint - uChat.showAll:= not uChat.showAll -end; - diff -r 9cb6990af584 -r 54a78ec6aac4 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sun Nov 21 19:07:43 2010 +0300 +++ b/hedgewars/uChat.pas Sun Nov 21 19:14:45 2010 +0300 @@ -34,7 +34,7 @@ showAll: boolean; implementation -uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender; +uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; const MaxStrIndex = 27; @@ -308,8 +308,58 @@ end end; +procedure chSay(var s: shortstring); +begin + SendIPC('s' + s); + + if copy(s, 1, 4) = '/me ' then + s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) + else + s:= #1 + UserNick + ': ' + s; + + AddChatString(s) +end; + +procedure chTeamSay(var s: shortstring); +begin + SendIPC('b' + s); + + s:= #4 + '[Team] ' + UserNick + ': ' + s; + + AddChatString(s) +end; + +procedure chHistory(var s: shortstring); +begin + s:= s; // avoid compiler hint + uChat.showAll:= not uChat.showAll +end; + +procedure chChat(var s: shortstring); +begin + s:= s; // avoid compiler hint + GameState:= gsChat; + if length(s) = 0 then + KeyPressChat(27) + else + begin + KeyPressChat(27); + KeyPressChat(47); + KeyPressChat(116); + KeyPressChat(101); + KeyPressChat(97); + KeyPressChat(109); + KeyPressChat(32) + end +end; + procedure initModule; begin + RegisterVariable('say', vtCommand, @chSay, true); + RegisterVariable('team', vtCommand, @chTeamSay, true); + RegisterVariable('history', vtCommand, @chHistory, true ); + RegisterVariable('chat', vtCommand, @chChat, true ); + lastStr:= 0; visibleCount:= 0; showAll:= false; diff -r 9cb6990af584 -r 54a78ec6aac4 hedgewars/uCommands.pas --- a/hedgewars/uCommands.pas Sun Nov 21 19:07:43 2010 +0300 +++ b/hedgewars/uCommands.pas Sun Nov 21 19:14:45 2010 +0300 @@ -17,7 +17,7 @@ implementation uses Types, uConsts, uIO, uMobile, - uRandom, uChat, SDLh, uScript, uTypes, + uRandom, SDLh, uScript, uTypes, uVariables, uConsole, uUtils; type PVariable = ^TVariable; @@ -163,10 +163,6 @@ RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); - RegisterVariable('history' , vtCommand, @chHistory , true ); - RegisterVariable('chat' , vtCommand, @chChat , true ); - RegisterVariable('say' , vtCommand, @chSay , true ); - RegisterVariable('team' , vtCommand, @chTeamSay , true ); RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); RegisterVariable('+precise', vtCommand, @chPrecise_p , false); RegisterVariable('-precise', vtCommand, @chPrecise_m , false);