diff options
author | uruk | 2013-07-27 21:36:07 +0200 |
---|---|---|
committer | uruk | 2013-07-27 21:36:07 +0200 |
commit | eec48fa42e83f7bf364d61c8d2d687ad2a758830 (patch) | |
tree | 344bf61c5d94f36a601ef9f556b8762006178b76 | |
parent | 341bf679c00ae2de0f3350b1ec95d4b02b246093 (diff) | |
download | scummvm-rg350-eec48fa42e83f7bf364d61c8d2d687ad2a758830.tar.gz scummvm-rg350-eec48fa42e83f7bf364d61c8d2d687ad2a758830.tar.bz2 scummvm-rg350-eec48fa42e83f7bf364d61c8d2d687ad2a758830.zip |
AVALANCHE: Introduce new class: Parser. Update rest of the code accordingly.
-rw-r--r-- | engines/avalanche/avalanche.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/avalanche.h | 2 | ||||
-rw-r--r-- | engines/avalanche/avalot.cpp | 27 | ||||
-rw-r--r-- | engines/avalanche/basher2.cpp | 29 | ||||
-rw-r--r-- | engines/avalanche/basher2.h | 2 | ||||
-rw-r--r-- | engines/avalanche/gyro2.h | 5 | ||||
-rw-r--r-- | engines/avalanche/module.mk | 1 | ||||
-rw-r--r-- | engines/avalanche/parser.cpp | 82 | ||||
-rw-r--r-- | engines/avalanche/parser.h | 57 |
9 files changed, 151 insertions, 56 deletions
diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index 919481679c..09695cd236 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -57,6 +57,7 @@ AvalancheEngine::~AvalancheEngine() { delete _rnd; delete _graphics; + delete _parser; delete _avalot; delete _gyro; @@ -79,6 +80,7 @@ AvalancheEngine::~AvalancheEngine() { Common::ErrorCode AvalancheEngine::initialize() { _graphics = new Graphics(this); + _parser = new Parser(this); _avalot = new Avalot(this); _gyro = new Gyro(this); diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index f43b6a7a06..a2b7ab6ae8 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -31,6 +31,7 @@ #include "avalanche/console.h" #include "avalanche/graphics.h" +#include "avalanche/parser.h" #include "avalanche/avalot.h" #include "avalanche/gyro2.h" @@ -66,6 +67,7 @@ static const int kSavegameVersion = 1; class AvalancheEngine : public Engine { public: Graphics *_graphics; + Parser *_parser; Avalot *_avalot; Gyro *_gyro; diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index d7dcff9677..ceaf754601 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -89,8 +89,8 @@ void Avalot::setup() { _vm->_lucerna->load_digits(); _vm->_gyro->cheat = false; _vm->_gyro->cp = 0; - _vm->_gyro->curpos = 0; - _vm->_gyro->quote = true; + _vm->_parser->inputTextPos = 0; + _vm->_parser->quote = true; _vm->_gyro->ledstatus = 177; _vm->_gyro->defaultled = 2; /* TSkellern:=0; { Replace with a more local variable sometime }*/ @@ -173,27 +173,8 @@ void Avalot::handleKeyDown(const Common::Event &event) { break; } - if ((32 <= event.kbd.ascii) && (event.kbd.ascii <= 128) && (event.kbd.ascii != 47)) { - byte inChar = event.kbd.ascii; - if (_vm->_dropdown->ddm_o.menunow) { - _vm->_dropdown->parsekey(inChar, _vm->_enhanced->extd); - } else { - if (_vm->_gyro->inputText.size() < 76) { - if ((inChar == '"') || (inChar == '`')) { - if (_vm->_gyro->quote) - inChar = '`'; - else - inChar = '"'; - _vm->_gyro->quote = !_vm->_gyro->quote; // quote - unquote - } - - _vm->_gyro->inputText.insertChar(inChar, _vm->_gyro->curpos); - _vm->_gyro->curpos++; - _vm->_basher->plottext(); - } else - _vm->_gyro->blip(); - } - } + if ((32 <= event.kbd.ascii) && (event.kbd.ascii <= 128) && (event.kbd.ascii != 47)) + _vm->_parser->handleInputText(event); } diff --git a/engines/avalanche/basher2.cpp b/engines/avalanche/basher2.cpp index 007c0b5e67..c91b3af751 100644 --- a/engines/avalanche/basher2.cpp +++ b/engines/avalanche/basher2.cpp @@ -78,29 +78,6 @@ void Basher::init() { #endif } -void Basher::plottext() { - if (_vm->_gyro->mouse_near_text()) - _vm->_gyro->super_off(); - - cursor_off(); - - _vm->_graphics->drawBar(24, 161, 640, 169, black); // Black out the line of the text. - - // Draw the text. Similar to chalk(), but here we don't have to bother with the color of the characters. - for (byte i = 0; i < _vm->_gyro->inputText.size(); i++) - for (byte j = 0; j < 8; j++) { - byte pixel = _vm->_gyro->characters[_vm->_gyro->inputText[i]][j]; - for (byte bit = 0; bit < 8; bit++) { - byte pixelBit = (pixel >> bit) & 1; - if (pixelBit != 0) - *_vm->_graphics->getPixel(24 + i * 8 + 7 - bit, 161 + j) = white; - } - } - - cursor_on(); - _vm->_gyro->super_on(); -} - void Basher::wipetext() { warning("STUB: Basher::wipetext()"); } @@ -202,10 +179,10 @@ void Basher::filename_edit() { void Basher::normal_edit() { entering_filename = false; - /*if (!_vm->_gyro->current.empty()) - _vm->_gyro->current.clear();*/ left_margin = 1; - _vm->_gyro->curpos = 0; + if (!_vm->_parser->inputText.empty()) + _vm->_parser->inputText.clear(); + _vm->_parser->inputTextPos = 0; } } // End of namespace Avalanche. diff --git a/engines/avalanche/basher2.h b/engines/avalanche/basher2.h index 476a6d35f7..3459144cd4 100644 --- a/engines/avalanche/basher2.h +++ b/engines/avalanche/basher2.h @@ -51,8 +51,6 @@ public: void init(); - void plottext(); - void keyboard_link(); void cursor_on(); diff --git a/engines/avalanche/gyro2.h b/engines/avalanche/gyro2.h index 3eee0772b7..27a184eb1e 100644 --- a/engines/avalanche/gyro2.h +++ b/engines/avalanche/gyro2.h @@ -479,10 +479,6 @@ public: - - - Common::String inputText; - byte curpos; bool cursoron; /* previous:^previoustype;*/ Common::String last; @@ -548,7 +544,6 @@ public: byte cp, ledstatus, defaultled; raw characters; - bool quote; /* 66 or 99 next? */ bool alive; char buffer[2000]; uint16 bufsize; diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk index 306df15513..e2dd67d6ba 100644 --- a/engines/avalanche/module.mk +++ b/engines/avalanche/module.mk @@ -3,6 +3,7 @@ MODULE := engines/avalanche MODULE_OBJS = \ avalanche.o \ graphics.o \ + parser.o\ avalot.o \ console.o \ detection.o \ diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp new file mode 100644 index 0000000000..d8cd37a236 --- /dev/null +++ b/engines/avalanche/parser.cpp @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on the original source code of Lord Avalot d'Argent version 1.3. + * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. + */ + +#include "avalanche/avalanche.h" +#include "avalanche/parser.h" + +namespace Avalanche { + +Parser::Parser(AvalancheEngine *vm) { + _vm = vm; +} + +void Parser::handleInputText(const Common::Event &event) { + byte inChar = event.kbd.ascii; + if (_vm->_dropdown->ddm_o.menunow) { + _vm->_dropdown->parsekey(inChar, _vm->_enhanced->extd); + } else { + if (inputText.size() < 76) { + if ((inChar == '"') || (inChar == '`')) { + if (quote) + inChar = '`'; + else + inChar = '"'; + quote = !quote; // quote - unquote + } + + inputText.insertChar(inChar, inputTextPos); + inputTextPos++; + plotText(); + } else + _vm->_gyro->blip(); + } +} + +void Parser::plotText() { + if (_vm->_gyro->mouse_near_text()) + _vm->_gyro->super_off(); + + _vm->_basher->cursor_off(); + + _vm->_graphics->drawBar(24, 161, 640, 169, black); // Black out the line of the text. + + // Draw the text. Similar to chalk(), but here we don't have to bother with the color of the characters. + for (byte i = 0; i < _vm->_parser->inputText.size(); i++) + for (byte j = 0; j < 8; j++) { + byte pixel = _vm->_gyro->characters[_vm->_parser->inputText[i]][j]; + for (byte bit = 0; bit < 8; bit++) { + byte pixelBit = (pixel >> bit) & 1; + if (pixelBit != 0) + *_vm->_graphics->getPixel(24 + i * 8 + 7 - bit, 161 + j) = white; + } + } + + _vm->_basher->cursor_on(); + _vm->_gyro->super_on(); +} + +} // End of namespace Avalanche diff --git a/engines/avalanche/parser.h b/engines/avalanche/parser.h new file mode 100644 index 0000000000..da6ef6eabc --- /dev/null +++ b/engines/avalanche/parser.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This code is based on the original source code of Lord Avalot d'Argent version 1.3. + * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman. + */ + +#ifndef PARSER_H +#define PARSER_H + +#include "common/events.h" + +namespace Avalanche { +class AvalancheEngine; + +class Parser { +public: + Common::String inputText; + byte inputTextPos; + bool quote; // 66 or 99 next? + + + + Parser(AvalancheEngine *vm); + + void handleInputText(const Common::Event &event); + + void plotText(); + +private: + AvalancheEngine *_vm; + +}; + +} // End of namespace Avalanche + +#endif // PARSER_H |