Changeset 6846
- Timestamp:
- May 3, 2010, 4:46:00 PM (15 years ago)
- Location:
- code/branches/chat2
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat2/data/gui/layouts/ChatBox.layout
r6837 r6846 8 8 <Window Type="MenuWidgets/FrameWindow" Name="/ChatBox" > 9 9 <Property Name="Text" Value="Chat" /> 10 <Property Name="TitlebarFont" Value="Commonwealth-10" />11 10 <Property Name="InheritsAlpha" Value="False" /> 12 11 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 13 12 <Property Name="TitlebarEnabled" Value="True" /> 14 13 <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.03,0},{0.6,0},{0.69375,0}}" /> 15 <Window Type="MenuWidgets/Listbox" Name=" /ChatBox/List" >14 <Window Type="MenuWidgets/Listbox" Name="orxonox/ChatBox/history" > 16 15 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 17 16 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.078,0},{0.98,0},{1,-30}}" /> 18 17 </Window> 19 <!--<Window Type="MenuWidgets/Editbox" Name="/ChatBox/Text" >--> 20 <!--<Property Name="Text" Value="Error: you did not register any font or none were valid" />--> 21 <!--<Property Name="MaxTextLength" Value="1073741823" />--> 22 <!--<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />--> 23 <!--<Property Name="UnifiedAreaRect" Value="{{0.02,0},{1,-30},{0.98,0},{1,-5}}" />--> 24 <!--</Window>--> 25 <Window Type="MenuWidgets/StaticText" Name="/ChatBox/Text" > 26 <Property Name="Text" Value="History" /> 27 <Property Name="HorzFormatting" Value="RightAligned" /> 18 <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox/input" > 19 <Property Name="Text" Value="" /> 20 <Property Name="MaxTextLength" Value="1073741823" /> 28 21 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" /> 29 22 <Property Name="UnifiedAreaRect" Value="{{0.02,0},{1,-30},{0.98,0},{1,-5}}" /> 30 23 </Window> 31 24 </Window> 32 <!--<Window Type="MenuWidgets/Editbox" Name="/ChatBox/History" >-->33 <!--<Property Name="Text" Value="5" />-->34 <!--<Property Name="MaxTextLength" Value="1073741823" />-->35 <!--<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />-->36 <!--<Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.03,0},{0.81,0},{0.1,0}}" />-->37 <!--</Window>-->38 <Window Type="MenuWidgets/StaticText" Name="/ChatBox/History" >39 <Property Name="Text" Value="5" />40 <Property Name="HorzFormatting" Value="RightAligned" />41 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />42 <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.03,0},{0.81,0},{0.1,0}}" />43 </Window>44 <Window Type="MenuWidgets/StaticText" Name="/ChatBox/HistoryLabel" >45 <Property Name="Text" Value="History size:" />46 <Property Name="HorzFormatting" Value="RightAligned" />47 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />48 <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.03,0},{0.77,0},{0.1,0}}" />49 </Window>50 <Window Type="MenuWidgets/StaticText" Name="/ChatBox/FonSizeLabel" >51 <Property Name="Font" Value="Commonwealth-10" />52 <Property Name="Text" Value="Font size:" />53 <Property Name="HorzFormatting" Value="RightAligned" />54 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />55 <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.1,0},{0.77,0},{0.17,0}}" />56 </Window>57 <Window Type="MenuWidgets/Spinner" Name="/ChatBox/FontSize" >58 <Property Name="Text" Value="10" />59 <Property Name="StepSize" Value="1" />60 <Property Name="CurrentValue" Value="10" />61 <Property Name="MaximumValue" Value="72" />62 <Property Name="MinimumValue" Value="-32768" />63 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />64 <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.1,0},{0.83,0},{0.17,0}}" />65 </Window>66 <Window Type="MenuWidgets/StaticText" Name="/ChatBox/FontNameLabel" >67 <Property Name="Font" Value="Commonwealth-10" />68 <Property Name="Text" Value="Font name:" />69 <Property Name="HorzFormatting" Value="RightAligned" />70 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />71 <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.17,0},{0.77,0},{0.24,0}}" />72 </Window>73 <Window Type="MenuWidgets/Combobox" Name="/ChatBox/FontName" >74 <Property Name="Text" Value="ChatBoxFont" />75 <Property Name="ReadOnly" Value="True" />76 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />77 <Property Name="UnifiedAreaRect" Value="{{0.77,0},{0.17,0},{0.99,0},{0.45,0}}" />78 <Property Name="MaxEditTextLength" Value="1073741823" />79 </Window>80 25 </Window> 81 26 </GUILayout> -
code/branches/chat2/src/orxonox/ChatHistory.cc
r6836 r6846 80 80 std::string text; 81 81 82 COUT(0) << "Meow.\n";82 //COUT(0) << "Meow.\n"; 83 83 84 84 #ifndef CHATTEST -
code/branches/chat2/src/orxonox/ChatInputHandler.cc
r6837 r6846 31 31 #include "core/ConsoleCommand.h" 32 32 #include "core/CoreIncludes.h" 33 #include "core/GUIManager.h" 34 #include "core/CorePrereqs.h" 35 #include <CEGUIWindow.h> 36 #include <CEGUI/elements/CEGUIListbox.h> 37 #include <CEGUI/elements/CEGUIListboxItem.h> 38 #include <CEGUI/elements/CEGUIListboxTextItem.h> 39 #include <CEGUIWindowManager.h> 33 40 #include <string> 34 41 … … 40 47 true ); 41 48 49 42 50 /* constructor */ 43 51 ChatInputHandler::ChatInputHandler() … … 48 56 /* create necessary objects */ 49 57 this->inpbuf = new InputBuffer(); 58 assert( this->inpbuf != NULL ); 59 60 /* MARK add generation of ChatBox thingy here */ 61 GUIManager::getInstance().loadGUI( "ChatBox" ); 50 62 51 63 /* configure the input buffer */ … … 62 74 void ChatInputHandler::configureInputBuffer() 63 75 { 64 76 /* input has changed */ 65 77 this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true); 66 67 78 79 /* add a line */ 68 80 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false); 69 81 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false); 70 82 71 83 /* backspace */ 72 84 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true); 73 85 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true); 74 86 75 87 /* exit the chatinputhandler thingy (tbd) */ 76 88 this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape 77 89 78 90 /* delete character */ 79 91 this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete); 80 92 81 93 /* cursor movement */ 82 94 this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right); 83 95 this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left); 84 96 this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End); 85 97 this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home); 98 99 /* get window pointers */ 100 input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" ); 101 CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" ); 102 lb_history = dynamic_cast<CEGUI::Listbox*>(history); 103 104 /* assert wee */ 105 assert( lb_history ); 86 106 } 87 107 … … 94 114 { 95 115 /* start listening */ 96 COUT(0) << "chatinput activated." << std::endl;116 //COUT(0) << "chatinput activated." << std::endl; 97 117 InputManager::getInstance().enterState("chatinput"); 118 119 /* MARK add spawning of chat widget stuff here.*/ 120 GUIManager::getInstance().showGUI( "ChatBox" ); 98 121 } 99 122 … … 102 125 /* stop listening */ 103 126 InputManager::getInstance().leaveState("chatinput"); 104 } 105 106 127 128 /* MARK add un-spawning of chat widget stuff here. */ 129 GUIManager::getInstance().hideGUI( "ChatBox" ); 130 } 107 131 108 132 /* callbacks for InputBuffer */ 109 133 void ChatInputHandler::inputChanged() 110 134 { 111 135 /* update the cursor and the window */ 136 std::string raw = this->inpbuf->get(); 137 138 /* get string before cursor */ 139 std::string left = raw.substr( 0, this->inpbuf->getCursorPosition() ); 140 141 /* see if there's a string after the cursor */ 142 std::string right = ""; 143 if( raw.length() >= left.length()+1 ) 144 right = raw.substr( this->inpbuf->getCursorPosition() ); 145 146 /* set the text */ 147 this->input->setProperty( "Text", left + "|" + right ); 112 148 } 113 149 114 150 void ChatInputHandler::addline() 115 151 { 116 /* MARK MARK */117 118 152 /* actually do send what was input */ 119 153 /* a) get the string out of the inputbuffer */ 120 154 std::string msgtosend = this->inpbuf->get(); 121 155 156 if( msgtosend.length() == 0 ) 157 { this->deactivate(); 158 return; 159 } 160 122 161 /* b) clear the input buffer */ 123 162 if (this->inpbuf->getSize() > 0) … … 129 168 /* d) stop listening to input */ 130 169 this->deactivate(); 170 171 /* e) create item and add to history */ 172 CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( msgtosend ); 173 this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 174 this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 175 176 /* f) make sure the history handles it */ 177 this->lb_history->handleUpdatedItemData(); 131 178 } 132 179 133 180 void ChatInputHandler::backspace() 134 { 135 this->inpbuf->removeBehindCursor(); 136 } 181 { this->inpbuf->removeBehindCursor(); } 137 182 138 183 void ChatInputHandler::deleteChar() 139 { 140 this->inpbuf->removeAtCursor(); 141 } 184 { this->inpbuf->removeAtCursor(); } 142 185 143 186 void ChatInputHandler::cursorRight() 144 { 145 this->inpbuf->increaseCursor(); 146 } 187 { this->inpbuf->increaseCursor(); } 147 188 148 189 void ChatInputHandler::cursorLeft() 149 { 150 this->inpbuf->decreaseCursor(); 151 } 190 { this->inpbuf->decreaseCursor(); } 152 191 153 192 void ChatInputHandler::cursorEnd() 154 { 155 this->inpbuf->setCursorToEnd(); 156 } 193 { this->inpbuf->setCursorToEnd(); } 157 194 158 195 void ChatInputHandler::cursorHome() 159 { 160 this->inpbuf->setCursorToBegin(); 161 } 196 { this->inpbuf->setCursorToBegin(); } 162 197 163 198 void ChatInputHandler::exit() 164 { 165 166 } 199 { } 167 200 168 201 } -
code/branches/chat2/src/orxonox/ChatInputHandler.h
r6836 r6846 36 36 #include <iostream> 37 37 #include <cassert> 38 #include <CEGUIForwardRefs.h> 38 39 39 40 /* project includes */ … … 71 72 static ChatInputHandler* singletonPtr_s; 72 73 74 /* cegui stuff */ 75 CEGUI::Window *input; 76 CEGUI::Listbox *lb_history; 77 73 78 public: 74 79 /** constructor */
Note: See TracChangeset
for help on using the changeset viewer.