Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6916


Ignore:
Timestamp:
May 17, 2010, 3:50:30 PM (15 years ago)
Author:
smerkli
Message:

added some comments, made reasonable-length lines - ready to merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/chat2/src/orxonox/ChatInputHandler.cc

    r6910 r6916  
    6969    configureInputBuffer();
    7070
    71     this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
     71    this->inputState = InputManager::getInstance().createInputState(
     72      "chatinput", false, false, InputStatePriority::Dynamic );
    7273    this->inputState->setKeyHandler(this->inpbuf);
    7374  }
     
    8081
    8182    /* add a line */
    82     this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
    83     this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
     83    this->inpbuf->registerListener(this, &ChatInputHandler::addline,
     84      '\r',   false);
     85    this->inpbuf->registerListener(this, &ChatInputHandler::addline,
     86      '\n',   false);
    8487
    8588    /* backspace */
    86     this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
    87     //this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
     89    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       
     90      '\b',   true);
     91
     92    /* NOTE this doesn't work on my debian linux box, it makes backspace get
     93     * registered also when delete is pressed
     94     */
     95    //this->inpbuf->registerListener(this, &ChatInputHandler::backspace,
     96      //'\177', true);
    8897
    8998    /* exit the chatinputhandler thingy (tbd) */
    90     this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
     99    this->inpbuf->registerListener(this, &ChatInputHandler::exit, 
     100      '\033', true); // escape
    91101
    92102    /* delete character */
    93     this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
     103    this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, 
     104      KeyCode::Delete);
    94105
    95106    /* cursor movement */
    96     this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
    97     this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
    98     this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
    99     this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
     107    this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,
     108      KeyCode::Right);
     109    this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,
     110      KeyCode::Left);
     111    this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,     
     112      KeyCode::End);
     113    this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,     
     114      KeyCode::Home);
    100115
    101116    /* GET WINDOW POINTERS */
    102     input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
    103     inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
     117    input = CEGUI::WindowManager::getSingleton().getWindow(
     118      "orxonox/ChatBox/input" );
     119    inputonly = CEGUI::WindowManager::getSingleton().getWindow(
     120      "orxonox/ChatBox-inputonly/input" );
    104121
    105122    /* get pointer to the history window */
    106     CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
     123    CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow(
     124      "orxonox/ChatBox/history" );
    107125
    108126    /* cast it to a listbox */
     
    171189    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
    172190    this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
    173     this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
     191    this->lb_history->ensureItemIsVisible(
     192      dynamic_cast<CEGUI::ListboxItem*>(toadd) );
    174193
    175194    /* f) make sure the history handles it */
     
    214233    std::string assembled = "$ " + left + "|" + right;
    215234
     235    /* decide what to do based on the active view */
    216236    if( this->fullchat )
    217237    {
    218238      /* adjust curser position - magic number 5 for font width */
    219       sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6),
    220         cursorpos, assembled.length() );
     239      sub_adjust_dispoffset(
     240        (this->input->getUnclippedInnerRect().getWidth()/6), cursorpos,
     241        assembled.length() );
    221242      this->input->setProperty( "Text", assembled.substr( disp_offset ) );
    222243    }
     
    224245    {
    225246      /* adjust curser position - magic number 5 for font width */
    226       sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6),
    227         cursorpos, assembled.length() );
     247      sub_adjust_dispoffset(
     248        (this->inputonly->getUnclippedInnerRect().getWidth()/6), cursorpos,
     249        assembled.length() );
    228250      this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
    229251    }
     
    239261    std::string msgtosend = this->inpbuf->get();
    240262
     263    /* if someone pressed return and nothing was put in,
     264     * just close the window
     265     */
    241266    if( msgtosend.length() == 0 )
    242267    { this->deactivate();
Note: See TracChangeset for help on using the changeset viewer.