From dc7a20ccc3a48a2070418cfc430b2f389480c681 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Fri, 19 Nov 2004 20:30:26 +0000 Subject: ops, commited before older version svn-id: r15836 --- gui/walkthrough.cpp | 22 +++++++++++++++++----- gui/walkthrough.h | 6 ++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gui/walkthrough.cpp b/gui/walkthrough.cpp index 706f729f9e..82c3e4bdfc 100644 --- a/gui/walkthrough.cpp +++ b/gui/walkthrough.cpp @@ -38,7 +38,8 @@ extern const Graphics::NewFont g_consolefont; WalkthroughDialog::WalkthroughDialog(float widthPercent, float heightPercent) : Dialog(0, 0, 1, 1), - _initialized(false), _widthPercent(widthPercent), _heightPercent(heightPercent) { + _initialized(false), _widthPercent(widthPercent), _heightPercent(heightPercent) { + _gameName[0] = 0; } WalkthroughDialog::~WalkthroughDialog() { @@ -57,11 +58,11 @@ static int getNextWordLength(byte *src, int maxLength) { return l; } -bool WalkthroughDialog::loadWalkthroughText(const char *gameName) { +bool WalkthroughDialog::loadWalkthroughText() { char filename[MAX_PATH]; File file; - sprintf(filename, "%s.wkt", gameName); + sprintf(filename, "%s.wkt", _gameName); file.open(filename); if (!file.isOpen()) return false; @@ -70,6 +71,8 @@ bool WalkthroughDialog::loadWalkthroughText(const char *gameName) { file.read(buffer, bufferSize); file.close(); + _linesArray.clear(); + int currentLinePos = 0; byte *currentBuffer = buffer; byte *lineBuffer = (byte *)malloc(_lineWidth + 1); @@ -117,7 +120,14 @@ bool WalkthroughDialog::loadWalkthroughText(const char *gameName) { return true; } -void WalkthroughDialog::create(const char *gameName) { +void WalkthroughDialog::setGameName(const char *gameName) { + strcpy(_gameName, gameName); +} + +void WalkthroughDialog::create() { + if (_initialized) + destroy(); + // Setup basic layout/dialog size reflowLayout(); @@ -128,7 +138,9 @@ void WalkthroughDialog::create(const char *gameName) { _currentPos = 0; _scrollLine = _linesPerPage - 1; - loadWalkthroughText(gameName); + _linesArray.clear(); + + loadWalkthroughText(); _initialized = true; } diff --git a/gui/walkthrough.h b/gui/walkthrough.h index 2162156ba6..380f350529 100644 --- a/gui/walkthrough.h +++ b/gui/walkthrough.h @@ -51,17 +51,19 @@ private: EntryList _linesArray; ScrollBarWidget *_scrollBar; + char _gameName[30]; float _widthPercent, _heightPercent; + bool loadWalkthroughText(); void reflowLayout(); - bool loadWalkthroughText(const char *gameName); public: WalkthroughDialog(float widthPercent, float heightPercent); ~WalkthroughDialog(); - void create(const char *gameName); + void setGameName(const char *gameName); + void create(); void destroy(); void open(); void drawDialog(); -- cgit v1.2.3