Game Development Community

enabling certain keyboard commands while in chat mode

by kcpdad · in Torque Game Engine · 08/06/2010 (1:54 pm) · 0 replies

FYI -
I needed to enable the arrow keyboard commands while the player was in chat mode instead of their default function, in stock tge 1.5.2 the up and down are used to recall previous chat input history. It was simply a matter of commenting out the following lines in engineguicontrolsguiTextEditCtrl.cc starting at line 783.
/*
         case KEY_UP:
         {
            if(mHistoryDirty)
            {
               updateHistory(&mTextBuffer, false);
               mHistoryDirty = false;
            }

            mHistoryIndex--;
            
            if(mHistoryIndex >= 0 && mHistoryIndex <= mHistoryLast)
               setText(mHistoryBuf[mHistoryIndex]);
            else if(mHistoryIndex < 0)
               mHistoryIndex = 0;
            
            return true;
         }

         case KEY_DOWN:
            if(mHistoryDirty)
            {
               updateHistory(&mTextBuffer, false);
               mHistoryDirty = false;
            }
            mHistoryIndex++;
            if(mHistoryIndex > mHistoryLast)
            {
               mHistoryIndex = mHistoryLast + 1;
               setText("");
            }
            else
               setText(mHistoryBuf[mHistoryIndex]);
            return true;

         case KEY_LEFT:
            mBlockStart = 0;
            mBlockEnd = 0;
            if (mCursorPos > 0)
            {
                mCursorPos--;
            }
            return true;

         case KEY_RIGHT:
            mBlockStart = 0;
            mBlockEnd = 0;
            if (mCursorPos < stringLen)
            {
                mCursorPos++;
            }
            return true;
        */
When a arrow key is entered while in chat mode execution will fall through the switch statement and the keystroke will be passed onto the engine for normal processing. In my case these keys are used for movement so the user can continue to chat and move at the same time.

I'll probably enable the history feature using some other keystrokes at some point.

About the author

Hobbyist working on a tank game when time allows. Play the prototype at => http://www.sytrept.com/60tons/