aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-11 11:16:00 +0100
committerEugene Sandulenko2016-01-11 11:16:00 +0100
commit5b374c6f55885f61215bada85a57feb293ea0c8d (patch)
treeef0f2f9147255b4be01c3dd1eb245caf8e9fbd66 /engines/wage
parent165066107f9667039a7035b8820fb3f2665c26bf (diff)
downloadscummvm-rg350-5b374c6f55885f61215bada85a57feb293ea0c8d.tar.gz
scummvm-rg350-5b374c6f55885f61215bada85a57feb293ea0c8d.tar.bz2
scummvm-rg350-5b374c6f55885f61215bada85a57feb293ea0c8d.zip
WAGE: Moved menu rendering into separate file
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/gui.cpp55
-rw-r--r--engines/wage/gui.h21
-rw-r--r--engines/wage/menu.cpp97
-rw-r--r--engines/wage/menu.h68
-rw-r--r--engines/wage/module.mk1
5 files changed, 187 insertions, 55 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7cabe6ddd0..e38d0249bf 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -54,21 +54,12 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/menu.h"
#include "wage/gui.h"
#include "wage/world.h"
namespace Wage {
-enum {
- kMenuHeight = 20,
- kMenuPadding = 6,
- kMenuItemHeight = 20,
- kBorderWidth = 17,
- kDesktopArc = 7,
- kComponentsPadding = 10,
- kCursorHeight = 12
-};
-
static const byte palette[] = {
0, 0, 0, // Black
0x80, 0x80, 0x80, // Gray
@@ -77,7 +68,6 @@ static const byte palette[] = {
};
static byte checkersPattern[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa };
-static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static const byte macCursorArrow[] = {
2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -171,12 +161,15 @@ Gui::Gui(WageEngine *engine) {
loadFonts();
g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 200000, this, "wageCursor");
+
+ _menu = new Menu(this);
}
Gui::~Gui() {
_screen.free();
_console.free();
g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
+ delete _menu;
}
const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
@@ -204,10 +197,6 @@ const Graphics::Font *Gui::getConsoleFont() {
return getFont(fontName, Graphics::FontManager::kConsoleFont);
}
-const Graphics::Font *Gui::getMenuFont() {
- return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
const Graphics::Font *Gui::getTitleFont() {
return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
@@ -292,7 +281,7 @@ void Gui::draw() {
paintBorder(&_screen, _consoleTextArea, kWindowConsole);
if (_menuDirty)
- renderMenu();
+ _menu->render();
_sceneDirty = false;
_consoleDirty = false;
@@ -598,40 +587,6 @@ void Gui::mouseMove(int x, int y) {
}
}
-static const char *menuItems[] = {
- "\xf0", "File", "Edit", "Commands", "Weapons", 0
-};
-
-void Gui::renderMenu() {
- Common::Rect r(0, 0, _screen.w - 1, kMenuHeight - 1);
- Patterns p;
- p.push_back(fillPattern);
-
- Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, p, 1);
- r.top = 7;
- Design::drawFilledRect(&_screen, r, kColorWhite, p, 1);
- r.top = kMenuHeight - 1;
- Design::drawFilledRect(&_screen, r, kColorBlack, p, 1);
-
- const Graphics::Font *font = getMenuFont();
- int y = _builtInFonts ? 3 : 2;
- int x = 18;
-
- for (int i = 0; menuItems[i]; i++) {
- const char *s = menuItems[i];
-
- if (i == 0 && _builtInFonts)
- s = "\xa9"; // (c) Symbol as the most resembling apple
-
- int w = font->getStringWidth(s);
- font->drawString(&_screen, s, x, y, w, kColorBlack);
-
- x += w + 13;
- }
-
- g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
-}
-
Designed *Gui::getClickTarget(int x, int y) {
if (_sceneArea.contains(x, y)) {
if (!_sceneIsActive) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 3c5660b4f2..7e91479b07 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -56,11 +56,23 @@
namespace Wage {
+class Menu;
+
enum WindowType {
kWindowScene,
kWindowConsole
};
+enum {
+ kMenuHeight = 20,
+ kMenuPadding = 6,
+ kMenuItemHeight = 20,
+ kBorderWidth = 17,
+ kDesktopArc = 7,
+ kComponentsPadding = 10,
+ kCursorHeight = 12
+};
+
class Gui {
public:
Gui(WageEngine *engine);
@@ -73,6 +85,7 @@ public:
Designed *getClickTarget(int x, int y);
void drawInput();
void setSceneDirty() { _sceneDirty = true; }
+ const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
private:
void paintBorder(Graphics::Surface *g, Common::Rect &r, WindowType windowType);
@@ -80,12 +93,9 @@ private:
void drawBox(Graphics::Surface *g, int x, int y, int w, int h);
void fillRect(Graphics::Surface *g, int x, int y, int w, int h);
void loadFonts();
- void renderMenu();
void flowText(Common::String &str);
const Graphics::Font *getConsoleFont();
- const Graphics::Font *getMenuFont();
const Graphics::Font *getTitleFont();
- const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
public:
Graphics::Surface _screen;
@@ -94,9 +104,12 @@ public:
Common::Rect _consoleTextArea;
bool _cursorOff;
+ bool _builtInFonts;
+
private:
WageEngine *_engine;
Graphics::Surface _console;
+ Menu *_menu;
Scene *_scene;
bool _sceneDirty;
bool _consoleDirty;
@@ -110,8 +123,6 @@ private:
uint _consoleNumLines;
bool _consoleFullRedraw;
- bool _builtInFonts;
-
Common::Rect _sceneArea;
bool _sceneIsActive;
bool _cursorIsArrow;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
new file mode 100644
index 0000000000..c89ec83372
--- /dev/null
+++ b/engines/wage/menu.cpp
@@ -0,0 +1,97 @@
+/* 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.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include "common/system.h"
+
+#include "wage/wage.h"
+#include "wage/design.h"
+#include "wage/gui.h"
+#include "wage/menu.h"
+
+namespace Wage {
+
+static const char *menuItems[] = {
+ "\xf0", "File", "Edit", "Commands", "Weapons", 0
+};
+
+static byte fillPattern[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+const Graphics::Font *Menu::getMenuFont() {
+ return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
+void Menu::render() {
+ Common::Rect r(0, 0, _gui->_screen.w - 1, kMenuHeight - 1);
+ Patterns p;
+ p.push_back(fillPattern);
+
+ Design::drawFilledRoundRect(&_gui->_screen, r, kDesktopArc, kColorWhite, p, 1);
+ r.top = 7;
+ Design::drawFilledRect(&_gui->_screen, r, kColorWhite, p, 1);
+ r.top = kMenuHeight - 1;
+ Design::drawFilledRect(&_gui->_screen, r, kColorBlack, p, 1);
+
+ const Graphics::Font *font = getMenuFont();
+ int y = _gui->_builtInFonts ? 3 : 2;
+ int x = 18;
+
+ for (int i = 0; menuItems[i]; i++) {
+ const char *s = menuItems[i];
+
+ if (i == 0 && _gui->_builtInFonts)
+ s = "\xa9"; // (c) Symbol as the most resembling apple
+
+ int w = font->getStringWidth(s);
+ font->drawString(&_gui->_screen, s, x, y, w, kColorBlack);
+
+ x += w + 13;
+ }
+
+ g_system->copyRectToScreen(_gui->_screen.getPixels(), _gui->_screen.pitch, 0, 0, _gui->_screen.w, kMenuHeight);
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
new file mode 100644
index 0000000000..9831814ccb
--- /dev/null
+++ b/engines/wage/menu.h
@@ -0,0 +1,68 @@
+/* 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.
+ *
+ * MIT License:
+ *
+ * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef WAGE_MENU_H
+#define WAGE_MENU_H
+
+namespace Wage {
+
+class Menu {
+public:
+ Menu(Gui *gui) : _gui(gui) {}
+
+ void render();
+
+private:
+ Gui *_gui;
+
+private:
+ const Graphics::Font *getMenuFont();
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index 8229d1745c..798e5b5254 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
detection.o \
entities.o \
gui.o \
+ menu.o \
randomhat.o \
script.o \
util.o \