Changeset 6876 for code/branches/chat2
- Timestamp:
- May 10, 2010, 3:18:14 PM (15 years ago)
- Location:
- code/branches/chat2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout
r6870 r6876 8 8 <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox-inputonly/input" > 9 9 <Property Name="Text" Value="" /> 10 <Property Name="Font" Value="Monofur-10" /> 10 11 <Property Name="AlwaysOnTop" Value="True" /> 11 <Property Name="MaxTextLength" Value="1 073741823" />12 <Property Name="MaxTextLength" Value="12981298" /> 12 13 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 13 14 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0,5},{0.98,0},{0,30}}" /> -
code/branches/chat2/data/gui/layouts/ChatBox.layout
r6870 r6876 13 13 <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.03,0},{0.6,0},{0.69375,0}}" /> 14 14 <Window Type="MenuWidgets/Listbox" Name="orxonox/ChatBox/history" > 15 <Property Name="Font" Value="Monofur-10" /> 15 16 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 16 17 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.078,0},{0.98,0},{1,-30}}" /> … … 18 19 <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox/input" > 19 20 <Property Name="Text" Value="" /> 21 <Property Name="Font" Value="Monofur-10" /> 20 22 <Property Name="MaxTextLength" Value="1073741823" /> 21 23 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> -
code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme
r6746 r6876 6 6 <Font Name="BlueHighway-10" Filename="bluehighway-10.font" /> 7 7 <Font Name="BlueHighway-8" Filename="bluehighway-8.font" /> 8 <Font Name="Monofur-10" Filename="Monofur-10.font" /> 8 9 </GUIScheme> -
code/branches/chat2/src/orxonox/ChatInputHandler.cc
r6870 r6876 44 44 /* singleton */ 45 45 ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false ); 46 47 /* add commands to console */ 46 48 SetConsoleCommandAlias( ChatInputHandler, activate_static, "startchat", 47 49 true ); … … 49 51 "startchat_small", true ); 50 52 51 52 53 /* constructor */ 53 54 ChatInputHandler::ChatInputHandler() … … 58 59 /* create necessary objects */ 59 60 this->inpbuf = new InputBuffer(); 61 this->disp_offset = 0; 60 62 assert( this->inpbuf != NULL ); 61 63 … … 133 135 InputManager::getInstance().leaveState("chatinput"); 134 136 135 /* MARK add un-spawning of chat widget stuff here.*/137 /* un-spawning of chat widget stuff */ 136 138 GUIManager::getInstance().hideGUI( "ChatBox" ); 137 139 GUIManager::getInstance().hideGUI( "ChatBox-inputonly" ); 138 140 } 139 141 142 void ChatInputHandler::sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen ) 143 { 144 /* already start offsetting 5 characters before end */ 145 if( cursorpos+5 > maxlen ) 146 { 147 /* always stay 5 characters ahead of end, looks better */ 148 ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0; 149 150 /* enforce visibility of cursor */ 151 (disp_offset > cursorpos ) ? disp_offset = 0 : 1; 152 } 153 154 /* make sure we don't die at substr */ 155 if( inplen <= disp_offset ) disp_offset = 0; 156 } 157 140 158 /* callbacks for InputBuffer */ 141 159 void ChatInputHandler::inputChanged() … … 143 161 /* update the cursor and the window */ 144 162 std::string raw = this->inpbuf->get(); 163 int cursorpos = this->inpbuf->getCursorPosition(); 145 164 146 165 /* get string before cursor */ 147 std::string left = raw.substr( 0, this->inpbuf->getCursorPosition());166 std::string left = raw.substr( 0, cursorpos ); 148 167 149 168 /* see if there's a string after the cursor */ 150 169 std::string right = ""; 151 170 if( raw.length() >= left.length()+1 ) 152 right = raw.substr( this->inpbuf->getCursorPosition());171 right = raw.substr( cursorpos ); 153 172 154 173 /* set the text */ 155 this->input->setProperty( "Text", left + "|" + right ); 156 this->inputonly->setProperty( "Text", left + "|" + right ); 174 std::string assembled = "$ " + left + "|" + right; 175 176 /* adjust curser position - magic number 5 for font width */ 177 sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 178 cursorpos, assembled.length() ); 179 this->input->setProperty( "Text", assembled.substr( disp_offset ) ); 180 181 /* reset display offset */ 182 disp_offset = 0; 183 184 /* adjust curser position - magic number 5 for font width */ 185 sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 186 cursorpos, assembled.length() ); 187 this->inputonly->setProperty( "Text", assembled.substr( disp_offset) ); 188 189 /* reset display offset */ 190 disp_offset = 0; 157 191 } 158 192 -
code/branches/chat2/src/orxonox/ChatInputHandler.h
r6870 r6876 62 62 */ 63 63 InputBuffer *inpbuf; 64 int disp_offset, width; 64 65 65 66 /** input state */ … … 68 69 /** setup input buffer, the constructor calls this */ 69 70 void configureInputBuffer(); 71 72 /** adjust display offset depending on cursor position */ 73 void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen ); 70 74 71 75 /* singleton pointer */
Note: See TracChangeset
for help on using the changeset viewer.