aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2019-05-28 02:19:20 +0200
committerJoseph-Eugene Winzer2019-05-28 02:24:43 +0200
commit8c4af9f175460a8cb0a2c70e417e1f6e1ff182a9 (patch)
treefc4704f58baaf0f29a542db91925ef5314b81e6b
parent38e04455fc75f65b78b998cd609a55710ceb7f3b (diff)
downloadscummvm-rg350-8c4af9f175460a8cb0a2c70e417e1f6e1ff182a9.tar.gz
scummvm-rg350-8c4af9f175460a8cb0a2c70e417e1f6e1ff182a9.tar.bz2
scummvm-rg350-8c4af9f175460a8cb0a2c70e417e1f6e1ff182a9.zip
SUPERNOVA: Adds text reader to view text files
-rw-r--r--engines/supernova/state.cpp4
-rw-r--r--engines/supernova/state.h1
-rw-r--r--engines/supernova/supernova.cpp77
-rw-r--r--engines/supernova/supernova.h1
4 files changed, 82 insertions, 1 deletions
diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp
index 6981004314..2a1c9fbbaf 100644
--- a/engines/supernova/state.cpp
+++ b/engines/supernova/state.cpp
@@ -585,10 +585,12 @@ void GameManager::processInput(Common::KeyState &state) {
_vm->showHelpScreen();
break;
case Common::KEYCODE_F2:
- // show game doc
+ // show game manual
+ _vm->showTextReader("msn.doc");
break;
case Common::KEYCODE_F3:
// show game info
+ _vm->showTextReader("msn.inf");
break;
case Common::KEYCODE_F4:
_vm->setTextSpeed();
diff --git a/engines/supernova/state.h b/engines/supernova/state.h
index c1712b4149..6b9d463dd5 100644
--- a/engines/supernova/state.h
+++ b/engines/supernova/state.h
@@ -23,6 +23,7 @@
#ifndef SUPERNOVA_STATE_H
#define SUPERNOVA_STATE_H
+#include "common/error.h"
#include "common/events.h"
#include "common/rect.h"
#include "common/keyboard.h"
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 3386c653b5..c64755e4af 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -434,6 +434,83 @@ void SupernovaEngine::showHelpScreen() {
_gm->animationOn();
}
+Common::Error SupernovaEngine::showTextReader(const char *filename) {
+ Common::File file;
+
+ if (!file.open(filename)) {
+ GUIErrorMessageFormat(_("Unable to find '%s' in game folder."), filename);
+ return Common::kReadingFailed;
+ }
+ Common::SeekableReadStream *stream = file.readStream(file.size());
+ int linesInFile = 0;
+ while (!stream->eos()) {
+ stream->readLine();
+ ++linesInFile;
+ }
+ --linesInFile;
+ stream->seek(0);
+ stream->clearErr();
+
+ if (_screen->isMessageShown())
+ _screen->removeMessage();
+ _gm->animationOff();
+ _gm->saveTime();
+ paletteFadeOut();
+ g_system->fillScreen(kColorWhite35);
+ for (int y = 6; y < (200 - kFontHeight); y += (kFontHeight + 2)) {
+ Common::String line = stream->readLine();
+ if (stream->eos())
+ break;
+ _screen->renderText(line, 6, y, kColorWhite99);
+ }
+ paletteFadeIn();
+
+ const int linesPerPage = 19;
+ int lineNumber = 0;
+ bool exitReader = false;
+ do {
+ stream->seek(0);
+ stream->clearErr();
+ for (int i = 0; i < lineNumber; ++i)
+ stream->readLine();
+ g_system->fillScreen(kColorWhite35);
+ for (int y = 6; y < (_screen->getScreenHeight() - kFontHeight); y += (kFontHeight + 2)) {
+ Common::String line = stream->readLine();
+ if (stream->eos())
+ break;
+ _screen->renderText(line, 6, y, kColorWhite99);
+ }
+ _gm->getKeyInput();
+ switch (_gm->_key.keycode) {
+ case Common::KEYCODE_ESCAPE:
+ exitReader = true;
+ break;
+ case Common::KEYCODE_UP:
+ lineNumber = lineNumber > 0 ? lineNumber - 1 : 0;
+ break;
+ case Common::KEYCODE_DOWN:
+ lineNumber = lineNumber < linesInFile - (linesPerPage + 1) ? lineNumber + 1
+ : linesInFile - linesPerPage;
+ break;
+ case Common::KEYCODE_PAGEUP:
+ lineNumber = lineNumber > linesPerPage ? lineNumber - linesPerPage : 0;
+ break;
+ case Common::KEYCODE_PAGEDOWN:
+ lineNumber = lineNumber < linesInFile - (linesPerPage * 2) ? lineNumber + linesPerPage
+ : linesInFile - linesPerPage;
+ break;
+ default:
+ break;
+ }
+ } while (!exitReader && !shouldQuit());
+
+ paletteFadeOut();
+ _gm->loadTime();
+ _gm->animationOn();
+
+ return Common::kNoError;
+}
+
bool SupernovaEngine::quitGameDialog() {
bool quit = false;
diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h
index cb516c92c9..94f07ee3bc 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -96,6 +96,7 @@ public:
const Common::String &getGameString(int idx) const;
void setGameString(int idx, const Common::String &string);
void showHelpScreen();
+ Common::Error showTextReader(const char *filename);
// forwarding calls
void playSound(AudioId sample);