Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5093 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Aug 21, 2005, 11:17:50 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: inputLine is working.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/event/event.h

    r5039 r5093  
    22 * @file event.h
    33 * an abstract event
     4 *
     5 * @todo remove HUGE class-overhead. This could also be a struct
    46*/
    57
  • trunk/src/lib/event/event_handler.cc

    r4873 r5093  
    8989  this->keyMapper->loadKeyBindings(iniParser);
    9090}
    91 
    92 
    93 /**
    94  *  set the state of the event handler
    95  * @param state: to which the event handler shall change
    96 */
    97 void EventHandler::setState(elState state)
    98 {
    99   this->state = state;
    100 }
    101 
    10291
    10392/**
  • trunk/src/lib/event/event_handler.h

    r5039 r5093  
    2626  void init(IniParser* iniParser);
    2727
    28   void setState(elState state);
     28  /** @param state: to which the event handler shall change */
     29  inline void setState(elState state) { this->state = state; };
     30  /** @returns the current state */
     31  inline elState getState() const { return this->state; };
    2932
    3033  void subscribe(EventListener* el, elState state, int eventType);
  • trunk/src/util/loading/game_loader.cc

    r4885 r5093  
    7878
    7979  this->eventHandler = EventHandler::getInstance();
    80   this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_PAUSE);
     80  this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_PAUSE);
    8181  this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_QUIT);
    82   this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_NEXT_WORLD);
    83   this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_PREVIOUS_WORLD);
     82  this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_NEXT_WORLD);
     83  this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_PREVIOUS_WORLD);
    8484}
    8585
  • trunk/src/util/shell.cc

    r5092 r5093  
    2020#include "text_engine.h"
    2121#include "list.h"
    22 
     22#include "graphics_engine.h"
     23#include "event_handler.h"
     24
     25#include "debug.h"
    2326#include <stdarg.h>
    2427#include <stdio.h>
     
    4346  this->setBufferSize(100);
    4447  this->setBufferDisplaySize(10);
    45   this->setAbsCoor2D(2, 400);
     48  this->setAbsCoor2D(2, GraphicsEngine::getInstance()->getResolutionY());
    4649  this->setAbsDir2D(0);
    4750
    4851  this->inputLineText = TextEngine::getInstance()->createText("fonts/earth.ttf", 10, TEXT_DYNAMIC, 255, 0, 0);
    4952  this->inputLineText->setText(NULL);
     53  this->inputLine = new char[1];
     54  this->inputLine[0] = '\0';
     55
     56  EventHandler::getInstance()->subscribe(this, ES_GAME, SDLK_BACKQUOTE);
     57
     58  EventHandler* evh = EventHandler::getInstance();
     59  for (int i = 1; i < EV_NUMBER; i++)
     60    EventHandler::getInstance()->subscribe(this, ES_SHELL, i);
    5061}
    5162
     
    6172    delete this->bufferText[i];
    6273  delete this->bufferText;
     74
    6375  delete this->inputLineText;
    64 
     76  delete this->inputLine;
    6577
    6678  Shell::singletonRef = NULL;
     
    243255  delete this->inputLine;
    244256  this->inputLine = addCharLine;
     257  this->inputLineText->setText(inputLine);
    245258}
    246259
     
    256269  delete this->inputLine;
    257270  this->inputLine = addCharLine;
     271  this->inputLineText->setText(inputLine);
    258272}
    259273
     
    264278void Shell::removeCharacters(unsigned int characterCount)
    265279{
     280  if (strlen(this->inputLine) == 0)
     281    return;
     282
    266283  if (characterCount > strlen(this->inputLine))
    267284    characterCount = strlen(this->inputLine);
     
    270287
    271288  strncpy(removeCharLine, this->inputLine, strlen(inputLine)-characterCount);
     289  removeCharLine[strlen(inputLine)-characterCount] = '\0';
    272290  delete this->inputLine;
    273291  this->inputLine = removeCharLine;
    274 }
    275 
     292  this->inputLineText->setText(inputLine);
     293}
     294
     295#include "key_names.h"
    276296/**
    277297 * listens for some event
     
    280300void Shell::process(const Event &event)
    281301{
    282 //  if (event.type)
    283 
     302  if (event.bPressed)
     303  {
     304    PRINTF(4)("Shell received command %s\n", SDLKToKeyname(event.type));
     305    if (event.type == SDLK_BACKQUOTE)
     306    {
     307      if (EventHandler::getInstance()->getState() == ES_GAME)
     308        EventHandler::getInstance()->setState(ES_SHELL);
     309      else
     310        EventHandler::getInstance()->setState(ES_GAME);
     311    }
     312
     313    else if (event.type == SDLK_TAB)
     314      this->autoComplete();
     315    else if (event.type == SDLK_BACKSPACE)
     316      this->removeCharacters(1);
     317    else if (event.type < 127)
     318      this->addCharacter(event.type);
     319  }
    284320}
    285321
     
    306342bool Shell::autoComplete()
    307343{
    308 
     344  PRINTF(3)("AutoCompletion not implemented yet\n");
    309345}
    310346
Note: See TracChangeset for help on using the changeset viewer.