X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_console.pas;h=6f02743bb8f73df2221dee5749139db5d82dcdee;hb=5c79a5c27e9330bdb53075734ea29efc38de10a6;hp=21616113c92c9571a8a44e6e088c6203c81552c9;hpb=d92a9e2807dda8a533def35afa801ed975920885;p=d2df-sdl.git diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 2161611..6f02743 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -48,6 +48,7 @@ procedure g_Console_Clear; function g_Console_CommandBlacklisted (C: AnsiString): Boolean; procedure g_Console_ReadConfig (filename: String); procedure g_Console_WriteConfig (filename: String); +procedure g_Console_WriteGameConfig; function g_Console_Interactive: Boolean; function g_Console_Action (action: Integer): Boolean; @@ -77,6 +78,7 @@ var gChatTeam: Boolean = false; gAllowConsoleMessages: Boolean = true; gJustChatted: Boolean = false; // ÷òîáû àäìèí â èíòåðå ÷àòÿñü íå ïðîìàòûâàë ñòàòèñòèêó + gParsingBinds: Boolean = false; // íå ïåðåñîõðàíÿòü êîíôèã âî âðåìÿ ïàðñèíãà gPlayerAction: Array [0..1, 0..LAST_ACTION] of Boolean; // [player, action] implementation @@ -243,24 +245,6 @@ end; procedure intVarHandler (me: PCommand; p: SSArray); - procedure binaryFlag (var flag: Boolean; msg: AnsiString); - begin - if (Length(p) > 2) then - begin - conwritefln('too many arguments to ''%s''', [p[0]]); - end - else - begin - case conGetBoolArg(p, 1) of - -1: begin end; - 0: if not me.cheat or conIsCheatsEnabled then flag := false else begin conwriteln('not available'); exit; end; - 1: if not me.cheat or conIsCheatsEnabled then flag := true else begin conwriteln('not available'); exit; end; - 666: if not me.cheat or conIsCheatsEnabled then flag := not flag else begin conwriteln('not available'); exit; end; - end; - if (Length(msg) = 0) then msg := p[0] else msg += ':'; - if flag then conwritefln('%s tan', [msg]) else conwritefln('%s ona', [msg]); - end; - end; begin if (Length(p) <> 2) then begin @@ -702,8 +686,13 @@ begin 'hidekeyboard': g_Touch_ShowKeyboard(False); 'togglemenu': + if gConsoleShow then + begin + g_Console_Switch; + menu_toggled := True + end + else begin - // this is HACK KeyPress(VK_ESCAPE); menu_toggled := True end; @@ -714,13 +703,15 @@ begin end; 'togglechat': begin - g_Console_Chat_Switch; + if not gConsoleShow and (g_ActiveWindow = nil) then + g_Console_Chat_Switch; gSkipFirstChar := not g_Console_Interactive() end; 'toggleteamchat': if gGameSettings.GameMode in [GM_TDM, GM_CTF] then begin - g_Console_Chat_Switch(True); + if not gConsoleShow and (g_ActiveWindow = nil) then + g_Console_Chat_Switch(True); gSkipFirstChar := not g_Console_Interactive() end; end @@ -844,7 +835,6 @@ begin AddCommand('p2_name', GameCVars); AddCommand('p1_color', GameCVars); AddCommand('p2_color', GameCVars); - AddCommand('r_showtime', GameCVars); AddCommand('r_showscore', GameCVars); AddCommand('r_showlives', GameCVars); AddCommand('r_showstat', GameCVars); @@ -966,9 +956,11 @@ begin WhitelistCommand('g_scorelimit'); WhitelistCommand('g_timelimit'); + gParsingBinds := True; g_Console_ResetBinds; g_Console_ReadConfig(GameDir + '/dfconfig.cfg'); g_Console_ReadConfig(GameDir + '/autoexec.cfg'); + gParsingBinds := False; g_Console_Add(Format(_lc[I_CONSOLE_WELCOME], [GAME_VERSION])); g_Console_Add(''); @@ -1378,6 +1370,7 @@ begin if g_Console_MatchBind(K, 'togglemenu') then begin + menu_toggled := True; if gChatShow then g_Console_Chat_Switch else if gConsoleShow then @@ -1661,8 +1654,9 @@ begin if key > 0 then begin gInputBinds[key].down := ParseAlias(down); - gInputBinds[key].up := ParseAlias(up) - end + gInputBinds[key].up := ParseAlias(up); + end; + g_Console_WriteGameConfig(); end; function g_Console_MatchBind (key: Integer; down: AnsiString; up: AnsiString = ''): Boolean; @@ -1721,11 +1715,14 @@ end; procedure g_Console_ProcessBind (key: Integer; down: Boolean); var i: Integer; begin - if (not g_GUIGrabInput) and (not gChatShow) and (not gConsoleShow) and (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then + if (not g_GUIGrabInput) and (key >= 0) and (key < e_MaxInputKeys) and ((gInputBinds[key].down <> nil) or (gInputBinds[key].up <> nil)) then begin if down then - for i := 0 to High(gInputBinds[key].down) do - g_Console_Process(gInputBinds[key].down[i], True) + begin + if not gChatShow then + for i := 0 to High(gInputBinds[key].down) do + g_Console_Process(gInputBinds[key].down[i], True); + end else for i := 0 to High(gInputBinds[key].up) do g_Console_Process(gInputBinds[key].up[i], True) @@ -1787,8 +1784,7 @@ begin g_Console_BindKey(e_JoyButtonToKey(i, 10), 'togglemenu'); end; - // HACK: VK_ESCAPE always used as togglemenu, so don't touch it! - // VK_CONSOLE + g_Console_BindKey(VK_ESCAPE, 'togglemenu'); g_Console_BindKey(VK_LSTRAFE, '+moveleft; +strafe', '-moveleft; -strafe'); g_Console_BindKey(VK_RSTRAFE, '+moveright; +strafe', '-moveright; -strafe'); g_Console_BindKey(VK_LEFT, '+moveleft', '-moveleft'); @@ -1839,10 +1835,10 @@ begin while (i <= len) and (s[i] <= ' ') do inc(i); (* skip comments *) if (i <= len) and ((s[i] <> '#') and ((i + 1 > len) or (s[i] <> '/') or (s[i + 1] <> '/'))) then - g_Console_Process(s, True) + g_Console_Process(s, True); end end; - CloseFile(f) + CloseFile(f); end end; @@ -1878,5 +1874,11 @@ begin CloseFile(f) end; +procedure g_Console_WriteGameConfig; +begin + if gParsingBinds then + Exit; + g_Console_WriteConfig(GameDir + '/dfconfig.cfg'); +end; end.