Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6876


Ignore:
Timestamp:
May 10, 2010, 3:18:14 PM (14 years ago)
Author:
smerkli
Message:

Scrolling chat now works, discovered delete-button bug, fixing it now.

Location:
code/branches/chat2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/chat2/data/gui/layouts/ChatBox-inputonly.layout

    r6870 r6876  
    88        <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox-inputonly/input" >
    99            <Property Name="Text" Value="" />
     10            <Property Name="Font" Value="Monofur-10" />
    1011            <Property Name="AlwaysOnTop" Value="True" />
    11             <Property Name="MaxTextLength" Value="1073741823" />
     12            <Property Name="MaxTextLength" Value="12981298" />
    1213            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    1314            <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0,5},{0.98,0},{0,30}}" />
  • code/branches/chat2/data/gui/layouts/ChatBox.layout

    r6870 r6876  
    1313            <Property Name="UnifiedAreaRect" Value="{{0.01,0},{0.03,0},{0.6,0},{0.69375,0}}" />
    1414            <Window Type="MenuWidgets/Listbox" Name="orxonox/ChatBox/history" >
     15                <Property Name="Font" Value="Monofur-10" />
    1516                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    1617                <Property Name="UnifiedAreaRect" Value="{{0.02,0},{0.078,0},{0.98,0},{1,-30}}" />
     
    1819            <Window Type="MenuWidgets/Editbox" Name="orxonox/ChatBox/input" >
    1920                <Property Name="Text" Value="" />
     21                <Property Name="Font" Value="Monofur-10" />
    2022                <Property Name="MaxTextLength" Value="1073741823" />
    2123                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
  • code/branches/chat2/data/gui/schemes/OrxonoxGUIScheme.scheme

    r6746 r6876  
    66    <Font Name="BlueHighway-10" Filename="bluehighway-10.font" />
    77    <Font Name="BlueHighway-8"  Filename="bluehighway-8.font"  />
     8    <Font Name="Monofur-10"     Filename="Monofur-10.font" />
    89</GUIScheme>
  • code/branches/chat2/src/orxonox/ChatInputHandler.cc

    r6870 r6876  
    4444  /* singleton */
    4545  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
     46
     47  /* add commands to console */
    4648  SetConsoleCommandAlias( ChatInputHandler, activate_static, "startchat",
    4749    true );
     
    4951    "startchat_small", true );
    5052
    51 
    5253  /* constructor */
    5354  ChatInputHandler::ChatInputHandler()
     
    5859    /* create necessary objects */
    5960    this->inpbuf = new InputBuffer();
     61    this->disp_offset = 0;
    6062    assert( this->inpbuf != NULL );
    6163
     
    133135    InputManager::getInstance().leaveState("chatinput");
    134136
    135     /* MARK add un-spawning of chat widget stuff here. */
     137    /* un-spawning of chat widget stuff */
    136138    GUIManager::getInstance().hideGUI( "ChatBox" );
    137139    GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
    138140  }
    139141
     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
    140158  /* callbacks for InputBuffer */
    141159  void ChatInputHandler::inputChanged()
     
    143161    /* update the cursor and the window */
    144162    std::string raw = this->inpbuf->get();
     163    int cursorpos = this->inpbuf->getCursorPosition();
    145164   
    146165    /* get string before cursor */
    147     std::string left = raw.substr( 0, this->inpbuf->getCursorPosition() );
     166    std::string left = raw.substr( 0, cursorpos );
    148167
    149168    /* see if there's a string after the cursor */
    150169    std::string right = "";
    151170    if( raw.length() >= left.length()+1 )
    152       right = raw.substr( this->inpbuf->getCursorPosition() );
     171      right = raw.substr( cursorpos );
    153172     
    154173    /* 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;
    157191  }
    158192
  • code/branches/chat2/src/orxonox/ChatInputHandler.h

    r6870 r6876  
    6262       */
    6363      InputBuffer *inpbuf;
     64      int disp_offset, width;
    6465
    6566      /** input state */
     
    6869      /** setup input buffer, the constructor calls this */
    6970      void configureInputBuffer();
     71
     72      /** adjust display offset depending on cursor position */
     73      void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
    7074
    7175      /* singleton pointer */
Note: See TracChangeset for help on using the changeset viewer.