Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 20, 2008, 7:49:26 PM (16 years ago)
Author:
rgrieder
Message:

merged input branch into gui test branch (was about time)
svn save (it's still a mess and CMLs haven't been updated)
I'll have to create a special project to create the tolua_bind files for tolua itself anyway..

Location:
code/branches/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui

  • code/branches/gui/src/core/Shell.cc

    r1540 r1638  
    3434#include "ConsoleCommand.h"
    3535#include "input/InputInterfaces.h"
     36#include "input/SimpleInputState.h"
     37#include "input/InputManager.h"
    3638
    3739#define SHELL_UPDATE_LISTENERS(function) \
     
    5759        this->clearLines();
    5860
    59         this->inputBuffer_ = 0;
    60         this->setInputBuffer(new InputBuffer());
     61        this->inputBuffer_ = new InputBuffer();
     62        this->configureInputBuffer();
     63        InputManager::createSimpleInputState("console", 40)->setKeyHandler(this->inputBuffer_);
    6164
    6265        this->outputBuffer_.registerListener(this);
    6366
    6467        this->setConfigValues();
     68    }
     69
     70    Shell::~Shell()
     71    {
     72        SimpleInputState * inputState = dynamic_cast<SimpleInputState*>(InputManager::getState("console"));
     73        if (inputState)
     74        {
     75            inputState->removeAndDestroyAllHandlers();
     76            InputManager::destroyState("console");
     77        }
    6578    }
    6679
     
    97110    }
    98111
    99     void Shell::setInputBuffer(InputBuffer* buffer)
    100     {
    101         if (this->inputBuffer_)
    102         {
    103             this->inputBuffer_->unregisterListener(this);
    104             // TODO: may be very dangerous. InputManager already deletes InputBuffer instance!!!
    105             delete this->inputBuffer_;
    106         }
    107 
    108         this->inputBuffer_ = buffer;
     112    void Shell::configureInputBuffer()
     113    {
    109114        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
    110115        this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
Note: See TracChangeset for help on using the changeset viewer.