[Orxonox-commit 2160] r6876 - in code/branches/chat2: data/gui/layouts data/gui/schemes src/orxonox
smerkli at orxonox.net
smerkli at orxonox.net
Mon May 10 15:18:14 CEST 2010
Author: smerkli
Date: 2010-05-10 15:18:14 +0200 (Mon, 10 May 2010)
New Revision: 6876
Modified:
code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout
code/branches/chat2/data/gui/layouts/ChatBox.layout
code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme
code/branches/chat2/src/orxonox/ChatInputHandler.cc
code/branches/chat2/src/orxonox/ChatInputHandler.h
Log:
Scrolling chat now works, discovered delete-button bug, fixing it now.
Modified: code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout
===================================================================
--- code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout 2010-05-10 13:02:52 UTC (rev 6875)
+++ code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout 2010-05-10 13:18:14 UTC (rev 6876)
@@ -7,8 +7,9 @@
<Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
<Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox-inputonly/input" >
<Property Name="Text" Value="" />
+ <Property Name="Font" Value="Monofur-10" />
<Property Name="AlwaysOnTop" Value="True" />
- <Property Name="MaxTextLength" Value="1073741823" />
+ <Property Name="MaxTextLength" Value="12981298" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.02,0},{0,5},{0.98,0},{0,30}}" />
</Window>
Modified: code/branches/chat2/data/gui/layouts/ChatBox.layout
===================================================================
--- code/branches/chat2/data/gui/layouts/ChatBox.layout 2010-05-10 13:02:52 UTC (rev 6875)
+++ code/branches/chat2/data/gui/layouts/ChatBox.layout 2010-05-10 13:18:14 UTC (rev 6876)
@@ -12,11 +12,13 @@
<Property Name="TitlebarEnabled" Value="True" />
<Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.03,0},{0.6,0},{0.69375,0}}" />
<Window Type="MenuWidgets/Listbox" Name="orxonox/ChatBox/history" >
+ <Property Name="Font" Value="Monofur-10" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.078,0},{0.98,0},{1,-30}}" />
</Window>
<Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox/input" >
<Property Name="Text" Value="" />
+ <Property Name="Font" Value="Monofur-10" />
<Property Name="MaxTextLength" Value="1073741823" />
<Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
<Property Name="UnifiedAreaRect" Value="{{0.02,0},{1,-30},{0.98,0},{1,-5}}" />
Modified: code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme
===================================================================
--- code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme 2010-05-10 13:02:52 UTC (rev 6875)
+++ code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme 2010-05-10 13:18:14 UTC (rev 6876)
@@ -5,4 +5,5 @@
<Font Name="BlueHighway-12" Filename="bluehighway-12.font" />
<Font Name="BlueHighway-10" Filename="bluehighway-10.font" />
<Font Name="BlueHighway-8" Filename="bluehighway-8.font" />
+ <Font Name="Monofur-10" Filename="Monofur-10.font" />
</GUIScheme>
Modified: code/branches/chat2/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.cc 2010-05-10 13:02:52 UTC (rev 6875)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.cc 2010-05-10 13:18:14 UTC (rev 6876)
@@ -43,12 +43,13 @@
{
/* singleton */
ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
+
+ /* add commands to console */
SetConsoleCommandAlias( ChatInputHandler, activate_static, "startchat",
true );
SetConsoleCommandAlias( ChatInputHandler, activate_small_static,
"startchat_small", true );
-
/* constructor */
ChatInputHandler::ChatInputHandler()
{
@@ -57,6 +58,7 @@
/* create necessary objects */
this->inpbuf = new InputBuffer();
+ this->disp_offset = 0;
assert( this->inpbuf != NULL );
/* generate chatbox ui and chatbox-inputonly ui */
@@ -132,28 +134,60 @@
/* stop listening */
InputManager::getInstance().leaveState("chatinput");
- /* MARK add un-spawning of chat widget stuff here. */
+ /* un-spawning of chat widget stuff */
GUIManager::getInstance().hideGUI( "ChatBox" );
GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
}
+ void ChatInputHandler::sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen )
+ {
+ /* already start offsetting 5 characters before end */
+ if( cursorpos+5 > maxlen )
+ {
+ /* always stay 5 characters ahead of end, looks better */
+ ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
+
+ /* enforce visibility of cursor */
+ (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
+ }
+
+ /* make sure we don't die at substr */
+ if( inplen <= disp_offset ) disp_offset = 0;
+ }
+
/* callbacks for InputBuffer */
void ChatInputHandler::inputChanged()
{
/* update the cursor and the window */
std::string raw = this->inpbuf->get();
+ int cursorpos = this->inpbuf->getCursorPosition();
/* get string before cursor */
- std::string left = raw.substr( 0, this->inpbuf->getCursorPosition() );
+ std::string left = raw.substr( 0, cursorpos );
/* see if there's a string after the cursor */
std::string right = "";
if( raw.length() >= left.length()+1 )
- right = raw.substr( this->inpbuf->getCursorPosition() );
+ right = raw.substr( cursorpos );
/* set the text */
- this->input->setProperty( "Text", left + "|" + right );
- this->inputonly->setProperty( "Text", left + "|" + right );
+ std::string assembled = "$ " + left + "|" + right;
+
+ /* adjust curser position - magic number 5 for font width */
+ sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6),
+ cursorpos, assembled.length() );
+ this->input->setProperty( "Text", assembled.substr( disp_offset ) );
+
+ /* reset display offset */
+ disp_offset = 0;
+
+ /* adjust curser position - magic number 5 for font width */
+ sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6),
+ cursorpos, assembled.length() );
+ this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
+
+ /* reset display offset */
+ disp_offset = 0;
}
void ChatInputHandler::addline()
Modified: code/branches/chat2/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.h 2010-05-10 13:02:52 UTC (rev 6875)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.h 2010-05-10 13:18:14 UTC (rev 6876)
@@ -61,6 +61,7 @@
* keyboard
*/
InputBuffer *inpbuf;
+ int disp_offset, width;
/** input state */
InputState *inputState;
@@ -68,6 +69,9 @@
/** setup input buffer, the constructor calls this */
void configureInputBuffer();
+ /** adjust display offset depending on cursor position */
+ void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
+
/* singleton pointer */
static ChatInputHandler* singletonPtr_s;
More information about the Orxonox-commit
mailing list