[Scummvm-cvs-logs] scummvm master -> 5f301b24002fffb3e8e05061a92ae2e0ee3a92ec

sev- sev at scummvm.org
Thu Apr 28 19:02:55 CEST 2016


This automated email contains information about 16 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
137d6b9727 WAGE: More Menu class decoupling from the engine
bbd107825f WAGE: Decoupled Window class too
c31e59b10c WAGE: Moved font loading to WM. wage.dat is now classicmacfonts.dat
608a74bb81 WAGE: Renamed create_wage.sh into generic create_classicmacfonts.sh
367946f83b WAGE: Renamed menu.* to macmenu.*
6998182b1f WAGE: Moved pattern and palette to WM
b5335ed9d4 WAGE: Moved cursor management to WM
5fbac749e2 WAGE: Moved patterns to WindowManager
5fb5d7a814 WAGE: Reduce header dependency
6c610e7a18 WAGE: Move rest of console-related functionality to gui-console.cpp
3027433b66 WAGE: Moved game-specific menu creation to gui.cpp
72b8f3a1c7 WAGE: Implemented menu commands as callback
859cd9d1f9 WAGE: Removed dependency of Menu on Wage::Design
8b41a50766 WAGE: Compose MacMenu instead of screen copying.
7fd850c745 WAGE: Remove yet another indirect reference to WAGE engine in WM
5f301b2400 SCUMM HE: Stubs for moonbase logic ops


Commit: 137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9
    https://github.com/scummvm/scummvm/commit/137d6b97276b3bde1a1c13eecd8f0ebe580cb7d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T09:59:35+02:00

Commit Message:
WAGE: More Menu class decoupling from the engine

Changed paths:
    engines/wage/gui.cpp
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h
    engines/wage/menu.cpp
    engines/wage/menu.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 1feed36..a3705dd 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -186,7 +186,7 @@ Gui::Gui(WageEngine *engine) {
 
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
-	_menu = _wm.addMenu(this);
+	_menu = _wm.addMenu(_builtInFonts, this);
 
 	_sceneWindow = _wm.addWindow(false, false);
 	_sceneWindow->setCallback(sceneWindowCallback, this);
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index b204d1b..1defdaa 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -100,8 +100,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
     return w;
 }
 
-Menu *MacWindowManager::addMenu(Gui *g) {
-	_menu = new Menu(_lastId, _screen->getBounds(), g);
+Menu *MacWindowManager::addMenu(bool builtInFonts, Gui *g) {
+	_menu = new Menu(_lastId, _screen->getBounds(), builtInFonts, g);
 
 	_windows.push_back(_menu);
 
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 91d426e..95b1dff 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -61,7 +61,7 @@ public:
 	void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
 
 	MacWindow *addWindow(bool scrollable, bool resizable);
-	Menu *addMenu(Gui *gui);
+	Menu *addMenu(bool builtInFonts, Gui *gui);
 	void setActive(int id);
 
 	void setFullRefresh(bool redraw) { _fullRefresh = true; }
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 2b84858..17a7d68 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -104,12 +104,13 @@ struct MenuData {
 	{ 0, NULL,			0, 0, false }
 };
 
-Menu::Menu(int id, const Common::Rect &bounds, Gui *gui) : BaseMacWindow(id), _gui(gui) {
+Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui)
+		: BaseMacWindow(id), _gui(gui), _builtInFonts(builtInFonts) {
 	_font = getMenuFont();
 
 	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
 
-	MenuItem *about = new MenuItem(_gui->_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
+	MenuItem *about = new MenuItem(_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
 	_items.push_back(about);
 	_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
 
@@ -149,7 +150,7 @@ Menu::Menu(int id, const Common::Rect &bounds, Gui *gui) : BaseMacWindow(id), _g
 			_items[i]->bbox.left = x - kMenuLeftMargin;
 			_items[i]->bbox.top = y;
 			_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
-			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_gui->_builtInFonts ? 3 : 2);
+			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_builtInFonts ? 3 : 2);
 		}
 
 		calcMenuBounds(_items[i]);
@@ -298,7 +299,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
 	*res = 0;
 
 	if (item->shortcut != 0)
-		sprintf(res, "%s%c%c", prefix, (_gui->_builtInFonts ? '^' : '\x11'), item->shortcut);
+		sprintf(res, "%s%c%c", prefix, (_builtInFonts ? '^' : '\x11'), item->shortcut);
 
 	return res;
 }
@@ -368,7 +369,7 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 				renderSubmenu(it);
 		}
 
-		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_gui->_builtInFonts ? 2 : 1), it->bbox.width(), color);
+		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_builtInFonts ? 2 : 1), it->bbox.width(), color);
 	}
 
 	g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
@@ -397,7 +398,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 		int color = kColorBlack;
 		if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
 			color = kColorWhite;
-			Common::Rect trect(r->left, y - (_gui->_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
+			Common::Rect trect(r->left, y - (_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
 
 			Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
 		}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 40d52ea..374c9ed 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -92,7 +92,7 @@ enum {
 
 class Menu : public BaseMacWindow {
 public:
-	Menu(int id, const Common::Rect &bounds, Gui *gui);
+	Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui);
 	~Menu();
 
 	bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
@@ -141,6 +141,8 @@ private:
 
 	int _activeItem;
 	int _activeSubItem;
+
+	bool _builtInFonts;
 };
 
 } // End of namespace Wage


Commit: bbd107825f7673788ea43b7093e7855daded553b
    https://github.com/scummvm/scummvm/commit/bbd107825f7673788ea43b7093e7855daded553b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T10:22:13+02:00

Commit Message:
WAGE: Decoupled Window class too

Changed paths:
    engines/wage/gui.cpp
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h
    engines/wage/menu.cpp
    engines/wage/menu.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index a3705dd..92b936f 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -183,10 +183,11 @@ Gui::Gui(WageEngine *engine) {
 		_patterns.push_back(fillPatterns[i]);
 
 	loadFonts();
+	_wm.setBuiltInFonts(_builtInFonts);
 
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
-	_menu = _wm.addMenu(_builtInFonts, this);
+	_menu = _wm.addMenu(this);
 
 	_sceneWindow = _wm.addWindow(false, false);
 	_sceneWindow->setCallback(sceneWindowCallback, this);
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 36b27a3..199bbdc 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -54,7 +54,7 @@
 
 namespace Wage {
 
-BaseMacWindow::BaseMacWindow(int id) : _id(id) {
+BaseMacWindow::BaseMacWindow(int id, MacWindowManager *wm) : _id(id), _wm(wm) {
 	_callback = 0;
 	_dataPtr = 0;
 
@@ -63,8 +63,8 @@ BaseMacWindow::BaseMacWindow(int id) : _id(id) {
 	_type = kWindowUnknown;
 }
 
-MacWindow::MacWindow(int id, bool scrollable, bool resizable) :
-		BaseMacWindow(id), _scrollable(scrollable), _resizable(resizable) {
+MacWindow::MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm) :
+		BaseMacWindow(id, wm), _scrollable(scrollable), _resizable(resizable) {
 	_active = false;
 	_borderIsDirty = true;
 
@@ -149,10 +149,6 @@ const Graphics::Font *MacWindow::getTitleFont() {
 	return ((WageEngine *)g_engine)->_gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
 }
 
-bool MacWindow::builtInFonts() {
-	return ((WageEngine *)g_engine)->_gui->builtInFonts();
-}
-
 #define ARROW_W 12
 #define ARROW_H 6
 const int arrowPixels[ARROW_H][ARROW_W] = {
@@ -248,7 +244,7 @@ void MacWindow::drawBorder() {
 
 	if (drawTitle) {
 		const Graphics::Font *font = getTitleFont();
-		int yOff = builtInFonts() ? 3 : 1;
+		int yOff = _wm->hasBuiltInFonts() ? 3 : 1;
 
 		int w = font->getStringWidth(_title) + 10;
 		int maxWidth = width - size * 2 - 7;
@@ -329,7 +325,7 @@ bool MacWindow::processEvent(Common::Event &event) {
 			_draggedX = event.mouse.x;
 			_draggedY = event.mouse.y;
 
-			((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true);
+			_wm->setFullRefresh(true);
 		}
 
 		if (_beingResized) {
@@ -339,7 +335,7 @@ bool MacWindow::processEvent(Common::Event &event) {
 			_draggedX = event.mouse.x;
 			_draggedY = event.mouse.y;
 
-			((WageEngine *)g_engine)->_gui->_wm.setFullRefresh(true);
+			_wm->setFullRefresh(true);
 			(*_callback)(click, event, _dataPtr);
 		}
 		break;
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 797e2f9..4b2f71e 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -52,6 +52,8 @@
 
 namespace Wage {
 
+class MacWindowManager;
+
 enum WindowType {
 	kWindowUnknown,
 	kWindowWindow,
@@ -74,7 +76,7 @@ enum WindowClick {
 
 class BaseMacWindow {
 public:
-	BaseMacWindow(int id);
+	BaseMacWindow(int id, MacWindowManager *wm);
 	virtual ~BaseMacWindow() {}
 
 	const Common::Rect &getDimensions() { return _dims; }
@@ -102,11 +104,13 @@ protected:
 
 	bool (*_callback)(WindowClick, Common::Event &, void *);
 	void *_dataPtr;
+
+	MacWindowManager *_wm;
 };
 
 class MacWindow : public BaseMacWindow {
 public:
-	MacWindow(int id, bool scrollable, bool resizable);
+	MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm);
 	virtual ~MacWindow();
 	void move(int x, int y);
 	void resize(int w, int h);
@@ -127,7 +131,6 @@ private:
 	void drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h);
 	void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color = kColorBlack);
 	const Graphics::Font *getTitleFont();
-	bool builtInFonts();
 	void updateInnerDims();
 	WindowClick isInBorder(int x, int y);
 
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 1defdaa..b3cd15e 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -78,6 +78,8 @@ MacWindowManager::MacWindowManager() {
 
 	_fullRefresh = true;
 
+	_builtInFonts = true;
+
 	for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
 		_patterns.push_back(fillPatterns[i]);
 }
@@ -88,7 +90,7 @@ MacWindowManager::~MacWindowManager() {
 }
 
 MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
-    MacWindow *w = new MacWindow(_lastId, scrollable, resizable);
+    MacWindow *w = new MacWindow(_lastId, scrollable, resizable, this);
 
     _windows.push_back(w);
     _windowStack.push_back(w);
@@ -100,8 +102,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
     return w;
 }
 
-Menu *MacWindowManager::addMenu(bool builtInFonts, Gui *g) {
-	_menu = new Menu(_lastId, _screen->getBounds(), builtInFonts, g);
+Menu *MacWindowManager::addMenu(Gui *g) {
+	_menu = new Menu(_lastId, _screen->getBounds(), this, g);
 
 	_windows.push_back(_menu);
 
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 95b1dff..c99120f 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -59,9 +59,11 @@ public:
 	~MacWindowManager();
 
 	void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
+	void setBuiltInFonts(bool builtInFonts) { _builtInFonts = builtInFonts; }
+	bool hasBuiltInFonts() { return _builtInFonts; }
 
 	MacWindow *addWindow(bool scrollable, bool resizable);
-	Menu *addMenu(bool builtInFonts, Gui *gui);
+	Menu *addMenu(Gui *gui);
 	void setActive(int id);
 
 	void setFullRefresh(bool redraw) { _fullRefresh = true; }
@@ -89,6 +91,8 @@ private:
 	Patterns _patterns;
 
 	Menu *_menu;
+
+	bool _builtInFonts;
 };
 
 } // End of namespace Wage
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 17a7d68..e21adae 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -104,13 +104,13 @@ struct MenuData {
 	{ 0, NULL,			0, 0, false }
 };
 
-Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui)
-		: BaseMacWindow(id), _gui(gui), _builtInFonts(builtInFonts) {
+Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
+		: BaseMacWindow(id, wm), _gui(gui) {
 	_font = getMenuFont();
 
 	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
 
-	MenuItem *about = new MenuItem(_builtInFonts ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
+	MenuItem *about = new MenuItem(_wm->hasBuiltInFonts() ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
 	_items.push_back(about);
 	_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
 
@@ -150,7 +150,7 @@ Menu::Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui)
 			_items[i]->bbox.left = x - kMenuLeftMargin;
 			_items[i]->bbox.top = y;
 			_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
-			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_builtInFonts ? 3 : 2);
+			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_wm->hasBuiltInFonts() ? 3 : 2);
 		}
 
 		calcMenuBounds(_items[i]);
@@ -299,7 +299,7 @@ const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
 	*res = 0;
 
 	if (item->shortcut != 0)
-		sprintf(res, "%s%c%c", prefix, (_builtInFonts ? '^' : '\x11'), item->shortcut);
+		sprintf(res, "%s%c%c", prefix, (_wm->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
 
 	return res;
 }
@@ -369,7 +369,7 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 				renderSubmenu(it);
 		}
 
-		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_builtInFonts ? 2 : 1), it->bbox.width(), color);
+		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color);
 	}
 
 	g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
@@ -398,7 +398,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 		int color = kColorBlack;
 		if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
 			color = kColorWhite;
-			Common::Rect trect(r->left, y - (_builtInFonts ? 1 : 0), r->right, y + _font->getFontHeight());
+			Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
 
 			Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
 		}
@@ -535,7 +535,7 @@ bool Menu::mouseRelease(int x, int y) {
 		_activeItem = -1;
 		_activeSubItem = -1;
 
-		_gui->_wm.setFullRefresh(true);
+		_wm->setFullRefresh(true);
 
 		return true;
 	}
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
index 374c9ed..7e8e9d9 100644
--- a/engines/wage/menu.h
+++ b/engines/wage/menu.h
@@ -92,7 +92,7 @@ enum {
 
 class Menu : public BaseMacWindow {
 public:
-	Menu(int id, const Common::Rect &bounds, bool builtInFonts, Gui *gui);
+	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
 	~Menu();
 
 	bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
@@ -141,8 +141,6 @@ private:
 
 	int _activeItem;
 	int _activeSubItem;
-
-	bool _builtInFonts;
 };
 
 } // End of namespace Wage


Commit: c31e59b10cf51bc06ab8c2a75d4f084a4e671fc2
    https://github.com/scummvm/scummvm/commit/c31e59b10cf51bc06ab8c2a75d4f084a4e671fc2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T11:14:13+02:00

Commit Message:
WAGE: Moved font loading to WM. wage.dat is now classicmacfonts.dat

Changed paths:
    engines/wage/dialog.cpp
    engines/wage/gui-console.cpp
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macwindow.cpp
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h
    engines/wage/menu.cpp



diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 263570b..5495409 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -88,7 +88,7 @@ Dialog::~Dialog() {
 }
 
 const Graphics::Font *Dialog::getDialogFont() {
-	return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+	return _gui->_wm.getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
 }
 
 void Dialog::paint() {
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index e037368..0609b4f 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -68,7 +68,7 @@ const Graphics::Font *Gui::getConsoleFont() {
 
 	snprintf(fontName, 128, "%s-%d", scene->getFontName(), scene->_fontSize);
 
-	return getFont(fontName, Graphics::FontManager::kConsoleFont);
+	return _wm.getFont(fontName, Graphics::FontManager::kConsoleFont);
 }
 
 void Gui::clearOutput() {
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 92b936f..7752f2d 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,9 +46,8 @@
  */
 
 #include "common/timer.h"
-#include "common/unzip.h"
+#include "common/system.h"
 #include "graphics/cursorman.h"
-#include "graphics/fonts/bdf.h"
 #include "graphics/palette.h"
 #include "graphics/primitives.h"
 
@@ -159,7 +158,6 @@ Gui::Gui(WageEngine *engine) {
 	_scrollPos = 0;
 	_consoleLineHeight = 8; // Dummy value which makes sense
 	_consoleNumLines = 24; // Dummy value
-	_builtInFonts = false;
 
 	_cursorX = 0;
 	_cursorY = 0;
@@ -182,9 +180,6 @@ Gui::Gui(WageEngine *engine) {
 	for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
 		_patterns.push_back(fillPatterns[i]);
 
-	loadFonts();
-	_wm.setBuiltInFonts(_builtInFonts);
-
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
 	_menu = _wm.addMenu(this);
@@ -209,26 +204,6 @@ void Gui::undrawCursor() {
 	_cursorOff = false;
 }
 
-const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
-	const Graphics::Font *font = 0;
-
-	if (!_builtInFonts) {
-		font = FontMan.getFontByName(name);
-
-		if (!font)
-			warning("Cannot load font %s", name);
-	}
-
-	if (_builtInFonts || !font)
-		font = FontMan.getFontByUsage(fallback);
-
-	return font;
-}
-
-const Graphics::Font *Gui::getTitleFont() {
-	return getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
 void Gui::draw() {
 	if (_engine->_isGameOver) {
 		_wm.draw();
@@ -419,50 +394,6 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
 	return false;
 }
 
-void Gui::loadFonts() {
-	Common::Archive *dat;
-
-	dat = Common::makeZipArchive("wage.dat");
-
-	if (!dat) {
-		warning("Could not find wage.dat. Falling back to built-in fonts");
-		_builtInFonts = true;
-
-		return;
-	}
-
-	Common::ArchiveMemberList list;
-	dat->listMembers(list);
-
-	for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
-		Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
-
-		Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
-
-		delete stream;
-
-		Common::String fontName = (*it)->getName();
-
-		// Trim the .bdf extension
-		for (int i = fontName.size() - 1; i >= 0; --i) {
-			if (fontName[i] == '.') {
-				while ((uint)i < fontName.size()) {
-					fontName.deleteLastChar();
-				}
-				break;
-			}
-		}
-
-		FontMan.assignFontToName(fontName, font);
-
-		debug(2, " %s", fontName.c_str());
-	}
-
-	_builtInFonts = false;
-
-	delete dat;
-}
-
 void Gui::regenCommandsMenu() {
 	_menu->regenCommandsMenu();
 }
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index d0af24c..9b1995c 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -93,7 +93,6 @@ public:
 
 	void drawInput();
 	void setSceneDirty() { _sceneDirty = true; }
-	const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
 	void regenCommandsMenu();
 	void regenWeaponsMenu();
 	void pushArrowCursor();
@@ -108,8 +107,6 @@ public:
 	void disableAllMenus();
 	void enableNewGameMenus();
 
-	bool builtInFonts() { return _builtInFonts; }
-
 	bool processSceneEvents(WindowClick click, Common::Event &event);
 	bool processConsoleEvents(WindowClick click, Common::Event &event);
 
@@ -120,7 +117,6 @@ private:
 	void drawConsole();
 	void undrawCursor();
 	void renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r);
-	void loadFonts();
 	void flowText(Common::String &str);
 	const Graphics::Font *getConsoleFont();
 	const Graphics::Font *getTitleFont();
@@ -134,7 +130,6 @@ public:
 	int _cursorX, _cursorY;
 	bool _cursorState;
 
-	bool _builtInFonts;
 	WageEngine *_engine;
 
 	Patterns _patterns;
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 199bbdc..c46def6 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -81,6 +81,10 @@ MacWindow::MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *
 MacWindow::~MacWindow() {
 }
 
+const Graphics::Font *MacWindow::getTitleFont() {
+	return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
 void MacWindow::setActive(bool active) {
 	if (active == _active)
 		return;
@@ -145,10 +149,6 @@ bool MacWindow::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 	return true;
 }
 
-const Graphics::Font *MacWindow::getTitleFont() {
-	return ((WageEngine *)g_engine)->_gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
 #define ARROW_W 12
 #define ARROW_H 6
 const int arrowPixels[ARROW_H][ARROW_W] = {
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index b3cd15e..402350d 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -48,8 +48,10 @@
 #include "common/array.h"
 #include "common/events.h"
 #include "common/list.h"
+#include "common/unzip.h"
 #include "common/system.h"
 
+#include "graphics/fonts/bdf.h"
 #include "graphics/managed_surface.h"
 
 #include "wage/wage.h"
@@ -82,6 +84,8 @@ MacWindowManager::MacWindowManager() {
 
 	for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
 		_patterns.push_back(fillPatterns[i]);
+
+	loadFonts();
 }
 
 MacWindowManager::~MacWindowManager() {
@@ -185,4 +189,67 @@ bool MacWindowManager::processEvent(Common::Event &event) {
     return false;
 }
 
+//////////////////////
+// Font stuff
+//////////////////////
+void MacWindowManager::loadFonts() {
+	Common::Archive *dat;
+
+	dat = Common::makeZipArchive("classicmacfonts.dat");
+
+	if (!dat) {
+		warning("Could not find classicmacfonts.dat. Falling back to built-in fonts");
+		_builtInFonts = true;
+
+		return;
+	}
+
+	Common::ArchiveMemberList list;
+	dat->listMembers(list);
+
+	for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) {
+		Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName());
+
+		Graphics::BdfFont *font = Graphics::BdfFont::loadFont(*stream);
+
+		delete stream;
+
+		Common::String fontName = (*it)->getName();
+
+		// Trim the .bdf extension
+		for (int i = fontName.size() - 1; i >= 0; --i) {
+			if (fontName[i] == '.') {
+				while ((uint)i < fontName.size()) {
+					fontName.deleteLastChar();
+				}
+				break;
+			}
+		}
+
+		FontMan.assignFontToName(fontName, font);
+
+		debug(2, " %s", fontName.c_str());
+	}
+
+	_builtInFonts = false;
+
+	delete dat;
+}
+
+const Graphics::Font *MacWindowManager::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
+	const Graphics::Font *font = 0;
+
+	if (!_builtInFonts) {
+		font = FontMan.getFontByName(name);
+
+		if (!font)
+			warning("Cannot load font %s", name);
+	}
+
+	if (_builtInFonts || !font)
+		font = FontMan.getFontByUsage(fallback);
+
+	return font;
+}
+
 } // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index c99120f..1c0b5c0 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -59,8 +59,8 @@ public:
 	~MacWindowManager();
 
 	void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
-	void setBuiltInFonts(bool builtInFonts) { _builtInFonts = builtInFonts; }
 	bool hasBuiltInFonts() { return _builtInFonts; }
+	const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
 
 	MacWindow *addWindow(bool scrollable, bool resizable);
 	Menu *addMenu(Gui *gui);
@@ -76,6 +76,7 @@ public:
 
 private:
 	void drawDesktop();
+	void loadFonts();
 
 private:
 	Graphics::ManagedSurface *_screen;
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index e21adae..6a677fd 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -291,7 +291,7 @@ void Menu::createWeaponsMenu(MenuItem *menu) {
 }
 
 const Graphics::Font *Menu::getMenuFont() {
-	return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+	return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
 }
 
 const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {


Commit: 608a74bb81e52171fde5c976c8e49da668f1b55c
    https://github.com/scummvm/scummvm/commit/608a74bb81e52171fde5c976c8e49da668f1b55c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T11:16:09+02:00

Commit Message:
WAGE: Renamed create_wage.sh into generic create_classicmacfonts.sh

Changed paths:
  A devtools/create_classicmacfonts.sh
  R devtools/create_wage/create_wage.sh



diff --git a/devtools/create_classicmacfonts.sh b/devtools/create_classicmacfonts.sh
new file mode 100755
index 0000000..6942d07
--- /dev/null
+++ b/devtools/create_classicmacfonts.sh
@@ -0,0 +1,119 @@
+#!/bin/bash
+#
+# This script downloads System 7.0.1 image from Apple and extracts fonts
+# from it. Mac only, unfortunately.
+#
+# On Windows you perhaps can perform the extraction manually with use of
+# HFV Explorer: https://web.archive.org/web/20011202005455/http://gamma.nic.fi/~lpesonen/HFVExplorer/
+#
+# More information could be found in the vMac documentation: http://www.gryphel.com/c/image/
+#
+# Alternatively you may use vMac instructions for extracting these disk images:
+#   http://www.gryphel.com/c/minivmac/recipes/sys7inst/
+#
+# Based on instructions posted at
+# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
+
+echo_n() {
+	printf "$@"
+}
+
+if test `uname` != "Darwin"; then
+	echo This script is Mac OS X-only
+	exit
+fi
+
+echo_n "Downloading System 7.0.1 image..."
+if test ! -f System_7.0.1.smi.bin; then
+	curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
+fi
+
+if test ! -f System_7.0.1.smi.bin; then
+	echo "Cannot download System_7.0.1.smi.bin"
+	exit
+fi
+
+echo done
+
+echo_n "Mounting System 7.0.1 image..."
+
+macbinary decode System_7.0.1.smi.bin
+hdiutil convert -quiet System\ 7.0.1.smi -format UDRO -o sys7.dmg
+hdiutil attach -quiet sys7.dmg
+
+if test ! -f /Volumes/7.0.1\ \(1440k.images\)/Fonts.image; then
+	echo "Failed to attach sys7.dmg"
+	exit
+fi
+
+echo done
+
+echo_n "Mounting Fonts disk image..."
+
+hdiutil convert -quiet /Volumes/7.0.1\ \(1440k.images\)/Fonts.image -format UDRO -o fonts.dmg
+hdiutil detach -quiet `hdiutil info|grep "/Volumes/7.0.1 (1440k.images)"|cut -f 1`
+hdiutil attach -quiet fonts.dmg
+
+if test ! -f /Volumes/Fonts/Chicago; then
+	echo "Failed to attach fonts.dmg"
+	exit
+fi
+
+echo done
+
+echo_n "Copying fonts..."
+
+for i in Athens Cairo Chicago Courier Geneva Helvetica London "Los Angeles" Monaco "New York" Palatino "San Francisco" Symbol Times Venice
+do
+	echo $i
+	macbinary encode "/Volumes/Fonts/$i" -o "$i.bin" -n
+done
+
+echo ...Done
+
+hdiutil detach -quiet `hdiutil info|grep "/Volumes/Fonts"|cut -f 1`
+
+if test ! -f fondu_src-060102.tgz; then
+	echo_n "Getting fondu_src-060102.tgz..."
+	curl -s http://fondu.sourceforge.net/fondu_src-060102.tgz -o fondu_src-060102.tgz
+	tar xf fondu_src-060102.tgz
+fi
+
+if test ! -d fondu-060102; then
+	echo "Failed to download fondu_src-060102.tgz"
+	exit
+fi
+
+echo done
+
+if test ! -x fondu-060102/fondu; then
+	echo_n "Compiling fondu..."
+	cd fondu-060102
+	./configure >configure.log 2>&1 && make 2>&1 >make.log
+	cd ..
+fi
+
+if test ! -x fondu-060102/fondu; then
+	echo "Failed to build fondu. See configure.log and make.log"
+	exit
+else
+	rm -f configure.log make.log
+fi
+
+echo done
+
+echo_n "Converting fonts..."
+fondu-060102/fondu -force *.bin
+echo done
+
+zip -9 classicmacfonts *.bdf
+mv classicmacfonts.zip classicmacfonts.dat
+
+echo_n "Cleaning up..."
+rm *.bdf
+rm *.ttf
+rm *.bin
+rm *.dmg
+echo done
+
+ls -l classicmacfonts.dat
diff --git a/devtools/create_wage/create_wage.sh b/devtools/create_wage/create_wage.sh
deleted file mode 100755
index 5e8fe35..0000000
--- a/devtools/create_wage/create_wage.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-#
-# This script downloads System 7.0.1 image from Apple and extracts fonts
-# from it. Mac only, unfortunately.
-#
-# On Windows you perhaps can perform the extraction manually with use of
-# HFV Explorer: https://web.archive.org/web/20011202005455/http://gamma.nic.fi/~lpesonen/HFVExplorer/
-#
-# More information could be found in the vMac documentation: http://www.gryphel.com/c/image/
-#
-# Alternatively you may use vMac instructions for extracting these disk images:
-#   http://www.gryphel.com/c/minivmac/recipes/sys7inst/
-#
-# Based on instructions posted at
-# http://apple.stackexchange.com/questions/58243/can-i-get-the-original-mac-font-chicago-on-a-mountain-lion-mac
-
-echo_n() {
-	printf "$@"
-}
-
-if test `uname` != "Darwin"; then
-	echo This script is Mac OS X-only
-	exit
-fi
-
-echo_n "Downloading System 7.0.1 image..."
-if test ! -f System_7.0.1.smi.bin; then
-	curl -s http://download.info.apple.com/Apple_Support_Area/Apple_Software_Updates/English-North_American/Macintosh/System/Older_System/System_7.0.x/System_7.0.1.smi.bin -o System_7.0.1.smi.bin
-fi
-
-if test ! -f System_7.0.1.smi.bin; then
-	echo "Cannot download System_7.0.1.smi.bin"
-	exit
-fi
-
-echo done
-
-echo_n "Mounting System 7.0.1 image..."
-
-macbinary decode System_7.0.1.smi.bin
-hdiutil convert -quiet System\ 7.0.1.smi -format UDRO -o sys7.dmg
-hdiutil attach -quiet sys7.dmg
-
-if test ! -f /Volumes/7.0.1\ \(1440k.images\)/Fonts.image; then
-	echo "Failed to attach sys7.dmg"
-	exit
-fi
-
-echo done
-
-echo_n "Mounting Fonts disk image..."
-
-hdiutil convert -quiet /Volumes/7.0.1\ \(1440k.images\)/Fonts.image -format UDRO -o fonts.dmg
-hdiutil detach -quiet `hdiutil info|grep "/Volumes/7.0.1 (1440k.images)"|cut -f 1`
-hdiutil attach -quiet fonts.dmg
-
-if test ! -f /Volumes/Fonts/Chicago; then
-	echo "Failed to attach fonts.dmg"
-	exit
-fi
-
-echo done
-
-echo_n "Copying fonts..."
-
-for i in Athens Cairo Chicago Courier Geneva Helvetica London "Los Angeles" Monaco "New York" Palatino "San Francisco" Symbol Times Venice
-do
-	echo $i
-	macbinary encode "/Volumes/Fonts/$i" -o "$i.bin" -n
-done
-
-echo ...Done
-
-hdiutil detach -quiet `hdiutil info|grep "/Volumes/Fonts"|cut -f 1`
-
-if test ! -f fondu_src-060102.tgz; then
-	echo_n "Getting fondu_src-060102.tgz..."
-	curl -s http://fondu.sourceforge.net/fondu_src-060102.tgz -o fondu_src-060102.tgz
-	tar xf fondu_src-060102.tgz
-fi
-
-if test ! -d fondu-060102; then
-	echo "Failed to download fondu_src-060102.tgz"
-	exit
-fi
-
-echo done
-
-if test ! -x fondu-060102/fondu; then
-	echo_n "Compiling fondu..."
-	cd fondu-060102
-	./configure >configure.log 2>&1 && make 2>&1 >make.log
-	cd ..
-fi
-
-if test ! -x fondu-060102/fondu; then
-	echo "Failed to build fondu. See configure.log and make.log"
-	exit
-else
-	rm -f configure.log make.log
-fi
-
-echo done
-
-echo_n "Converting fonts..."
-fondu-060102/fondu -force *.bin
-echo done
-
-zip -9 wage *.bdf
-mv wage.zip wage.dat
-
-echo_n "Cleaning up..."
-rm *.bdf
-rm *.ttf
-rm *.bin
-rm *.dmg
-echo done
-
-ls -l wage.dat


Commit: 367946f83b5688490bb40c54bb884df4dac3c11e
    https://github.com/scummvm/scummvm/commit/367946f83b5688490bb40c54bb884df4dac3c11e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T11:19:02+02:00

Commit Message:
WAGE: Renamed menu.* to macmenu.*

Changed paths:
  A engines/wage/macmenu.cpp
  A engines/wage/macmenu.h
  R engines/wage/menu.cpp
  R engines/wage/menu.h
    engines/wage/gui-console.cpp
    engines/wage/gui.cpp
    engines/wage/macwindowmanager.cpp
    engines/wage/module.mk



diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 0609b4f..9c89c27 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -56,7 +56,7 @@
 #include "wage/design.h"
 #include "wage/entities.h"
 #include "wage/macwindow.h"
-#include "wage/menu.h"
+#include "wage/macmenu.h"
 #include "wage/gui.h"
 #include "wage/world.h"
 
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 7752f2d..e3e7ccf 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -57,7 +57,7 @@
 #include "wage/gui.h"
 #include "wage/macwindow.h"
 #include "wage/macwindowmanager.h"
-#include "wage/menu.h"
+#include "wage/macmenu.h"
 #include "wage/world.h"
 
 namespace Wage {
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
new file mode 100644
index 0000000..8dee8eb
--- /dev/null
+++ b/engines/wage/macmenu.cpp
@@ -0,0 +1,614 @@
+/* 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 "common/keyboard.h"
+
+#include "wage/wage.h"
+#include "wage/entities.h"
+#include "wage/design.h"
+#include "wage/gui.h"
+#include "wage/macmenu.h"
+#include "wage/world.h"
+
+namespace Wage {
+
+struct MenuSubItem {
+	Common::String text;
+	int action;
+	int style;
+	char shortcut;
+	bool enabled;
+	Common::Rect bbox;
+
+	MenuSubItem(const char *t, int a, int s = 0, char sh = 0, bool e = true) : text(t), action(a), style(s), shortcut(sh), enabled(e) {}
+};
+
+typedef Common::Array<MenuSubItem *> SubItemArray;
+
+struct MenuItem {
+	Common::String name;
+	SubItemArray subitems;
+	Common::Rect bbox;
+	Common::Rect subbbox;
+
+	MenuItem(const char *n) : name(n) {}
+};
+
+struct MenuData {
+	int menunum;
+	const char *title;
+	int action;
+	byte shortcut;
+	bool enabled;
+} static const menuSubItems[] = {
+	{ kMenuFile, "New",			kMenuActionNew, 0, false },
+	{ kMenuFile, "Open...",		kMenuActionOpen, 0, false },
+	{ kMenuFile, "Close",		kMenuActionClose, 0, true },
+	{ kMenuFile, "Save",		kMenuActionSave, 0, false },
+	{ kMenuFile, "Save as...",	kMenuActionSaveAs, 0, true },
+	{ kMenuFile, "Revert",		kMenuActionRevert, 0, false },
+	{ kMenuFile, "Quit",		kMenuActionQuit, 0, true },
+
+	{ kMenuEdit, "Undo",		kMenuActionUndo, 'Z', false },
+	{ kMenuEdit, NULL,			0, 0, false },
+	{ kMenuEdit, "Cut",			kMenuActionCut, 'K', false },
+	{ kMenuEdit, "Copy",		kMenuActionCopy, 'C', false },
+	{ kMenuEdit, "Paste",		kMenuActionPaste, 'V', false },
+	{ kMenuEdit, "Clear",		kMenuActionClear, 'B', false },
+
+	{ 0, NULL,			0, 0, false }
+};
+
+Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
+		: BaseMacWindow(id, wm), _gui(gui) {
+	_font = getMenuFont();
+
+	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
+
+	MenuItem *about = new MenuItem(_wm->hasBuiltInFonts() ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
+	_items.push_back(about);
+	_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
+
+	MenuItem *file = new MenuItem("File");
+	_items.push_back(file);
+
+	MenuItem *edit = new MenuItem("Edit");
+	_items.push_back(edit);
+
+	for (int i = 0; menuSubItems[i].menunum; i++) {
+		const MenuData *m = &menuSubItems[i];
+
+		_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
+	}
+
+	_commands = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
+	_items.push_back(_commands);
+	regenCommandsMenu();
+
+	_weapons = NULL;
+
+	if (!_gui->_engine->_world->_weaponMenuDisabled) {
+		_weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
+		_items.push_back(_weapons);
+
+		regenWeaponsMenu();
+	}
+
+	// Calculate menu dimensions
+	int y = 1;
+	int x = 18;
+
+	for (uint i = 0; i < _items.size(); i++) {
+		int w = _font->getStringWidth(_items[i]->name);
+
+		if (_items[i]->bbox.bottom == 0) {
+			_items[i]->bbox.left = x - kMenuLeftMargin;
+			_items[i]->bbox.top = y;
+			_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
+			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_wm->hasBuiltInFonts() ? 3 : 2);
+		}
+
+		calcMenuBounds(_items[i]);
+
+		x += w + kMenuSpacing;
+	}
+
+	_bbox.left = 0;
+	_bbox.top = 0;
+	_bbox.right = _screen.w - 1;
+	_bbox.bottom = kMenuHeight - 1;
+
+	_menuActivated = false;
+	_activeItem = -1;
+	_activeSubItem = -1;
+
+	_screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
+	_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
+}
+
+Menu::~Menu() {
+	for (uint i = 0; i < _items.size(); i++) {
+		for (uint j = 0; j < _items[i]->subitems.size(); j++)
+			delete _items[i]->subitems[j];
+		delete _items[i];
+	}
+}
+
+void Menu::regenCommandsMenu() {
+	for (uint j = 0; j < _commands->subitems.size(); j++)
+		delete _commands->subitems[j];
+
+	_commands->subitems.clear();
+
+	createCommandsMenu(_commands);
+	calcMenuBounds(_commands);
+}
+
+void Menu::createCommandsMenu(MenuItem *menu) {
+	Common::String string(_gui->_engine->_world->_commandsMenu);
+
+	Common::String item;
+
+	for (uint i = 0; i < string.size(); i++) {
+		while(i < string.size() && string[i] != ';') // Read token
+			item += string[i++];
+
+		if (item == "(-") {
+			menu->subitems.push_back(new MenuSubItem(NULL, 0));
+		} else {
+			bool enabled = true;
+			int style = 0;
+			char shortcut = 0;
+			const char *shortPtr = strrchr(item.c_str(), '/');
+			if (shortPtr != NULL) {
+				if (strlen(shortPtr) >= 2) {
+					shortcut = shortPtr[1];
+					item.deleteChar(shortPtr - item.c_str());
+					item.deleteChar(shortPtr - item.c_str());
+				} else {
+					error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortPtr, item.c_str(), string.c_str());
+				}
+			}
+
+			while (item.size() >= 2 && item[item.size() - 2] == '<') {
+				char c = item.lastChar();
+				if (c == 'B') {
+					style |= kFontStyleBold;
+				} else if (c == 'I') {
+					style |= kFontStyleItalic;
+				} else if (c == 'U') {
+					style |= kFontStyleUnderline;
+				} else if (c == 'O') {
+					style |= kFontStyleOutline;
+				} else if (c == 'S') {
+					style |= kFontStyleShadow;
+				} else if (c == 'C') {
+					style |= kFontStyleCondensed;
+				} else if (c == 'E') {
+					style |= kFontStyleExtended;
+				}
+				item.deleteLastChar();
+				item.deleteLastChar();
+			}
+
+			Common::String tmpitem(item);
+			tmpitem.trim();
+			if (tmpitem[0] == '(') {
+				enabled = false;
+
+				for (uint j = 0; j < item.size(); j++)
+					if (item[j] == '(') {
+						item.deleteChar(j);
+						break;
+					}
+			}
+
+			menu->subitems.push_back(new MenuSubItem(item.c_str(), kMenuActionCommand, style, shortcut, enabled));
+		}
+
+		item.clear();
+	}
+}
+
+void Menu::regenWeaponsMenu() {
+	if (_gui->_engine->_world->_weaponMenuDisabled)
+		return;
+
+	for (uint j = 0; j < _weapons->subitems.size(); j++)
+		delete _weapons->subitems[j];
+
+	_weapons->subitems.clear();
+
+	createWeaponsMenu(_weapons);
+	calcMenuBounds(_weapons);
+}
+
+void Menu::createWeaponsMenu(MenuItem *menu) {
+	Chr *player = _gui->_engine->_world->_player;
+	ObjArray *weapons = player->getWeapons(true);
+
+	for (uint i = 0; i < weapons->size(); i++) {
+		Obj *obj = (*weapons)[i];
+		if (obj->_type == Obj::REGULAR_WEAPON ||
+			obj->_type == Obj::THROW_WEAPON ||
+			obj->_type == Obj::MAGICAL_OBJECT) {
+			Common::String command(obj->_operativeVerb);
+			command += " ";
+			command += obj->_name;
+
+			menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
+		}
+	}
+	delete weapons;
+
+	if (menu->subitems.empty())
+		menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
+}
+
+const Graphics::Font *Menu::getMenuFont() {
+	return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
+}
+
+const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
+	static char res[20];
+	*res = 0;
+
+	if (item->shortcut != 0)
+		sprintf(res, "%s%c%c", prefix, (_wm->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
+
+	return res;
+}
+
+int Menu::calculateMenuWidth(MenuItem *menu) {
+	int maxWidth = 0;
+	for (uint i = 0; i < menu->subitems.size(); i++) {
+		MenuSubItem *item = menu->subitems[i];
+		if (!item->text.empty()) {
+			Common::String text(item->text);
+			Common::String acceleratorText(getAcceleratorString(item, "  "));
+			if (!acceleratorText.empty()) {
+				text += acceleratorText;
+			}
+
+			int width = _font->getStringWidth(text);
+			if (width > maxWidth) {
+				maxWidth = width;
+			}
+		}
+	}
+	return maxWidth;
+}
+
+void Menu::calcMenuBounds(MenuItem *menu) {
+	// TODO: cache maxWidth
+	int maxWidth = calculateMenuWidth(menu);
+	int x1 = menu->bbox.left - 1;
+	int y1 = menu->bbox.bottom + 1;
+	int x2 = x1 + maxWidth + kMenuDropdownPadding * 2 - 4;
+	int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight + 2;
+
+	menu->subbbox.left = x1;
+	menu->subbbox.top = y1;
+	menu->subbbox.right = x2;
+	menu->subbbox.bottom = y2;
+}
+
+bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
+	Common::Rect r(_bbox);
+
+	if (!_contentIsDirty)
+		return false;
+
+	_contentIsDirty = true;
+
+	Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
+	r.top = 7;
+	Design::drawFilledRect(&_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
+	r.top = kMenuHeight - 1;
+	Design::drawFilledRect(&_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);
+
+	for (uint i = 0; i < _items.size(); i++) {
+		int color = kColorBlack;
+		MenuItem *it = _items[i];
+
+		if ((uint)_activeItem == i) {
+			Common::Rect hbox = it->bbox;
+
+			hbox.left -= 1;
+			hbox.right += 2;
+
+			Design::drawFilledRect(&_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid);
+			color = kColorWhite;
+
+			if (!it->subitems.empty())
+				renderSubmenu(it);
+		}
+
+		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color);
+	}
+
+	g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
+
+	return true;
+}
+
+void Menu::renderSubmenu(MenuItem *menu) {
+	Common::Rect *r = &menu->subbbox;
+
+	if (r->width() == 0 || r->height() == 0)
+		return;
+
+	Design::drawFilledRect(&_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid);
+	Design::drawRect(&_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+	Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+	Design::drawHLine(&_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+
+	int x = r->left + kMenuDropdownPadding;
+	int y = r->top + 1;
+	for (uint i = 0; i < menu->subitems.size(); i++) {
+		Common::String text(menu->subitems[i]->text);
+		Common::String acceleratorText(getAcceleratorString(menu->subitems[i], ""));
+		int accelX = r->right - 25;
+
+		int color = kColorBlack;
+		if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
+			color = kColorWhite;
+			Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
+
+			Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
+		}
+
+		if (!text.empty()) {
+			Graphics::ManagedSurface *s = &_screen;
+			int tx = x, ty = y;
+
+			if (!menu->subitems[i]->enabled) {
+				s = &_tempSurface;
+				tx = 0;
+				ty = 0;
+				accelX -= x;
+
+				_tempSurface.clear(kColorGreen);
+			}
+
+			_font->drawString(s, text, tx, ty, r->width(), color);
+
+			if (!acceleratorText.empty())
+				_font->drawString(s, acceleratorText, accelX, ty, r->width(), color);
+
+			if (!menu->subitems[i]->enabled) {
+				// I am lazy to extend drawString() with plotProc as a parameter, so
+				// fake it here
+				for (int ii = 0; ii < _tempSurface.h; ii++) {
+					const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
+					byte *dst = (byte *)_screen.getBasePtr(x, y+ii);
+					byte pat = _gui->_patterns[kPatternCheckers2 - 1][ii % 8];
+					for (int j = 0; j < r->width(); j++) {
+						if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
+							*dst = *src;
+						src++;
+						dst++;
+					}
+				}
+			}
+		} else { // Delimiter
+			Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
+		}
+
+		y += kMenuDropdownItemHeight;
+	}
+
+	g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
+}
+
+bool Menu::processEvent(Common::Event &event) {
+	switch (event.type) {
+	case Common::EVENT_KEYDOWN:
+		return keyEvent(event);
+	case Common::EVENT_LBUTTONDOWN:
+		return mouseClick(event.mouse.x, event.mouse.y);
+	case Common::EVENT_LBUTTONUP:
+		return mouseRelease(event.mouse.x, event.mouse.y);
+	case Common::EVENT_MOUSEMOVE:
+		return mouseMove(event.mouse.x, event.mouse.y);
+	default:
+		return false;
+	}
+}
+
+bool Menu::keyEvent(Common::Event &event) {
+	if (event.type != Common::EVENT_KEYDOWN)
+		return false;
+
+	if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
+		if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
+			return processMenuShortCut(event.kbd.flags, event.kbd.ascii);
+		}
+	}
+
+	return false;
+}
+
+bool Menu::mouseClick(int x, int y) {
+	if (_bbox.contains(x, y)) {
+		if (!_menuActivated)
+			_screenCopy.copyFrom(_gui->_screen);
+
+		for (uint i = 0; i < _items.size(); i++)
+			if (_items[i]->bbox.contains(x, y)) {
+			  if ((uint)_activeItem == i)
+					return false;
+
+				if (_activeItem != -1) { // Restore background
+					Common::Rect r(_items[_activeItem]->subbbox);
+					r.right += 3;
+					r.bottom += 3;
+
+					_screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
+					g_system->copyRectToScreen(_screen.getBasePtr(r.left, r.top), _screen.pitch, r.left, r.top, r.width(), r.height());
+				}
+
+				_activeItem = i;
+				_activeSubItem = -1;
+				_menuActivated = true;
+
+				return true;
+			}
+	} else if (_menuActivated && _items[_activeItem]->subbbox.contains(x, y)) {
+		MenuItem *it = _items[_activeItem];
+		int numSubItem = (y - it->subbbox.top) / kMenuDropdownItemHeight;
+
+		if (numSubItem != _activeSubItem) {
+			_activeSubItem = numSubItem;
+
+			renderSubmenu(_items[_activeItem]);
+		}
+	} else if (_menuActivated && _activeItem != -1) {
+		_activeSubItem = -1;
+
+		renderSubmenu(_items[_activeItem]);
+	}
+
+	return false;
+}
+
+bool Menu::mouseMove(int x, int y) {
+	if (_menuActivated)
+		if (mouseClick(x, y))
+			return true;
+
+	return false;
+}
+
+bool Menu::mouseRelease(int x, int y) {
+	if (_menuActivated) {
+		_menuActivated = false;
+
+		if (_activeItem != -1 && _activeSubItem != -1 && _items[_activeItem]->subitems[_activeSubItem]->enabled)
+			executeCommand(_items[_activeItem]->subitems[_activeSubItem]);
+
+		_activeItem = -1;
+		_activeSubItem = -1;
+
+		_wm->setFullRefresh(true);
+
+		return true;
+	}
+
+	return false;
+}
+
+void Menu::executeCommand(MenuSubItem *subitem) {
+	switch(subitem->action) {
+	case kMenuActionAbout:
+	case kMenuActionNew:
+	case kMenuActionOpen:
+	case kMenuActionClose:
+	case kMenuActionSave:
+	case kMenuActionSaveAs:
+	case kMenuActionRevert:
+	case kMenuActionQuit:
+
+	case kMenuActionUndo:
+		_gui->actionUndo();
+		break;
+	case kMenuActionCut:
+		_gui->actionCut();
+		break;
+	case kMenuActionCopy:
+		_gui->actionCopy();
+		break;
+	case kMenuActionPaste:
+		_gui->actionPaste();
+		break;
+	case kMenuActionClear:
+		_gui->actionClear();
+		break;
+
+	case kMenuActionCommand:
+		_gui->_engine->processTurn(&subitem->text, NULL);
+		break;
+
+	default:
+		warning("Unknown action: %d", subitem->action);
+
+	}
+}
+
+bool Menu::processMenuShortCut(byte flags, uint16 ascii) {
+	ascii = tolower(ascii);
+
+	if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
+		for (uint i = 0; i < _items.size(); i++)
+			for (uint j = 0; j < _items[i]->subitems.size(); j++)
+				if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
+					executeCommand(_items[i]->subitems[j]);
+					return true;
+				}
+	}
+
+	return false;
+}
+
+void Menu::enableCommand(int menunum, int action, bool state) {
+	for (uint i = 0; i < _items[menunum]->subitems.size(); i++)
+		if (_items[menunum]->subitems[i]->action == action)
+			_items[menunum]->subitems[i]->enabled = state;
+
+	_contentIsDirty = true;
+}
+
+void Menu::disableAllMenus() {
+	for (uint i = 1; i < _items.size(); i++) // Leave About menu on
+		for (uint j = 0; j < _items[i]->subitems.size(); j++)
+			_items[i]->subitems[j]->enabled = false;
+
+	_contentIsDirty = true;
+}
+
+} // End of namespace Wage
diff --git a/engines/wage/macmenu.h b/engines/wage/macmenu.h
new file mode 100644
index 0000000..0ad99a4
--- /dev/null
+++ b/engines/wage/macmenu.h
@@ -0,0 +1,148 @@
+/* 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_MACMENU_H
+#define WAGE_MACMENU_H
+
+namespace Wage {
+
+struct MenuItem;
+struct MenuSubItem;
+
+enum {
+	kFontStyleBold = 1,
+	kFontStyleItalic = 2,
+	kFontStyleUnderline = 4,
+	kFontStyleOutline = 8,
+	kFontStyleShadow = 16,
+	kFontStyleCondensed = 32,
+	kFontStyleExtended = 64
+};
+
+enum {
+	kMenuAbout = 0,
+	kMenuFile = 1,
+	kMenuEdit = 2,
+	kMenuCommands = 3,
+	kMenuWeapons = 4
+};
+
+enum {
+	kMenuActionAbout,
+	kMenuActionNew,
+	kMenuActionOpen,
+	kMenuActionClose,
+	kMenuActionSave,
+	kMenuActionSaveAs,
+	kMenuActionRevert,
+	kMenuActionQuit,
+
+	kMenuActionUndo,
+	kMenuActionCut,
+	kMenuActionCopy,
+	kMenuActionPaste,
+	kMenuActionClear,
+
+	kMenuActionCommand
+};
+
+class Menu : public BaseMacWindow {
+public:
+	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
+	~Menu();
+
+	bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
+	bool processEvent(Common::Event &event);
+
+	void regenCommandsMenu();
+	void regenWeaponsMenu();
+	void enableCommand(int menunum, int action, bool state);
+	void disableAllMenus();
+
+	void setActive(bool active) { _menuActivated = active; }
+	bool hasAllFocus() { return _menuActivated; }
+
+	Common::Rect _bbox;
+
+private:
+	Gui *_gui;
+	Graphics::ManagedSurface _screen;
+	Graphics::ManagedSurface _screenCopy;
+	Graphics::ManagedSurface _tempSurface;
+
+private:
+	const Graphics::Font *getMenuFont();
+	const char *getAcceleratorString(MenuSubItem *item, const char *prefix);
+	int calculateMenuWidth(MenuItem *menu);
+	void calcMenuBounds(MenuItem *menu);
+	void renderSubmenu(MenuItem *menu);
+	void createCommandsMenu(MenuItem *menu);
+	void createWeaponsMenu(MenuItem *menu);
+	void executeCommand(MenuSubItem *subitem);
+
+	bool keyEvent(Common::Event &event);
+	bool mouseClick(int x, int y);
+	bool mouseRelease(int x, int y);
+	bool mouseMove(int x, int y);
+
+	bool processMenuShortCut(byte flags, uint16 ascii);
+
+	Common::Array<MenuItem *> _items;
+	MenuItem *_weapons;
+	MenuItem *_commands;
+
+	const Graphics::Font *_font;
+
+	bool _menuActivated;
+
+	int _activeItem;
+	int _activeSubItem;
+};
+
+} // End of namespace Wage
+
+#endif
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 402350d..66c5bf1 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -59,7 +59,7 @@
 #include "wage/gui.h"
 #include "wage/macwindow.h"
 #include "wage/macwindowmanager.h"
-#include "wage/menu.h"
+#include "wage/macmenu.h"
 
 namespace Wage {
 
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
deleted file mode 100644
index 6a677fd..0000000
--- a/engines/wage/menu.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-/* 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 "common/keyboard.h"
-
-#include "wage/wage.h"
-#include "wage/entities.h"
-#include "wage/design.h"
-#include "wage/gui.h"
-#include "wage/menu.h"
-#include "wage/world.h"
-
-namespace Wage {
-
-struct MenuSubItem {
-	Common::String text;
-	int action;
-	int style;
-	char shortcut;
-	bool enabled;
-	Common::Rect bbox;
-
-	MenuSubItem(const char *t, int a, int s = 0, char sh = 0, bool e = true) : text(t), action(a), style(s), shortcut(sh), enabled(e) {}
-};
-
-typedef Common::Array<MenuSubItem *> SubItemArray;
-
-struct MenuItem {
-	Common::String name;
-	SubItemArray subitems;
-	Common::Rect bbox;
-	Common::Rect subbbox;
-
-	MenuItem(const char *n) : name(n) {}
-};
-
-struct MenuData {
-	int menunum;
-	const char *title;
-	int action;
-	byte shortcut;
-	bool enabled;
-} static const menuSubItems[] = {
-	{ kMenuFile, "New",			kMenuActionNew, 0, false },
-	{ kMenuFile, "Open...",		kMenuActionOpen, 0, false },
-	{ kMenuFile, "Close",		kMenuActionClose, 0, true },
-	{ kMenuFile, "Save",		kMenuActionSave, 0, false },
-	{ kMenuFile, "Save as...",	kMenuActionSaveAs, 0, true },
-	{ kMenuFile, "Revert",		kMenuActionRevert, 0, false },
-	{ kMenuFile, "Quit",		kMenuActionQuit, 0, true },
-
-	{ kMenuEdit, "Undo",		kMenuActionUndo, 'Z', false },
-	{ kMenuEdit, NULL,			0, 0, false },
-	{ kMenuEdit, "Cut",			kMenuActionCut, 'K', false },
-	{ kMenuEdit, "Copy",		kMenuActionCopy, 'C', false },
-	{ kMenuEdit, "Paste",		kMenuActionPaste, 'V', false },
-	{ kMenuEdit, "Clear",		kMenuActionClear, 'B', false },
-
-	{ 0, NULL,			0, 0, false }
-};
-
-Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
-		: BaseMacWindow(id, wm), _gui(gui) {
-	_font = getMenuFont();
-
-	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
-
-	MenuItem *about = new MenuItem(_wm->hasBuiltInFonts() ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
-	_items.push_back(about);
-	_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
-
-	MenuItem *file = new MenuItem("File");
-	_items.push_back(file);
-
-	MenuItem *edit = new MenuItem("Edit");
-	_items.push_back(edit);
-
-	for (int i = 0; menuSubItems[i].menunum; i++) {
-		const MenuData *m = &menuSubItems[i];
-
-		_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
-	}
-
-	_commands = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
-	_items.push_back(_commands);
-	regenCommandsMenu();
-
-	_weapons = NULL;
-
-	if (!_gui->_engine->_world->_weaponMenuDisabled) {
-		_weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
-		_items.push_back(_weapons);
-
-		regenWeaponsMenu();
-	}
-
-	// Calculate menu dimensions
-	int y = 1;
-	int x = 18;
-
-	for (uint i = 0; i < _items.size(); i++) {
-		int w = _font->getStringWidth(_items[i]->name);
-
-		if (_items[i]->bbox.bottom == 0) {
-			_items[i]->bbox.left = x - kMenuLeftMargin;
-			_items[i]->bbox.top = y;
-			_items[i]->bbox.right = x + w + kMenuSpacing - kMenuLeftMargin;
-			_items[i]->bbox.bottom = y + _font->getFontHeight() + (_wm->hasBuiltInFonts() ? 3 : 2);
-		}
-
-		calcMenuBounds(_items[i]);
-
-		x += w + kMenuSpacing;
-	}
-
-	_bbox.left = 0;
-	_bbox.top = 0;
-	_bbox.right = _screen.w - 1;
-	_bbox.bottom = kMenuHeight - 1;
-
-	_menuActivated = false;
-	_activeItem = -1;
-	_activeSubItem = -1;
-
-	_screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
-	_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
-}
-
-Menu::~Menu() {
-	for (uint i = 0; i < _items.size(); i++) {
-		for (uint j = 0; j < _items[i]->subitems.size(); j++)
-			delete _items[i]->subitems[j];
-		delete _items[i];
-	}
-}
-
-void Menu::regenCommandsMenu() {
-	for (uint j = 0; j < _commands->subitems.size(); j++)
-		delete _commands->subitems[j];
-
-	_commands->subitems.clear();
-
-	createCommandsMenu(_commands);
-	calcMenuBounds(_commands);
-}
-
-void Menu::createCommandsMenu(MenuItem *menu) {
-	Common::String string(_gui->_engine->_world->_commandsMenu);
-
-	Common::String item;
-
-	for (uint i = 0; i < string.size(); i++) {
-		while(i < string.size() && string[i] != ';') // Read token
-			item += string[i++];
-
-		if (item == "(-") {
-			menu->subitems.push_back(new MenuSubItem(NULL, 0));
-		} else {
-			bool enabled = true;
-			int style = 0;
-			char shortcut = 0;
-			const char *shortPtr = strrchr(item.c_str(), '/');
-			if (shortPtr != NULL) {
-				if (strlen(shortPtr) >= 2) {
-					shortcut = shortPtr[1];
-					item.deleteChar(shortPtr - item.c_str());
-					item.deleteChar(shortPtr - item.c_str());
-				} else {
-					error("Unexpected shortcut: '%s', item '%s' in menu '%s'", shortPtr, item.c_str(), string.c_str());
-				}
-			}
-
-			while (item.size() >= 2 && item[item.size() - 2] == '<') {
-				char c = item.lastChar();
-				if (c == 'B') {
-					style |= kFontStyleBold;
-				} else if (c == 'I') {
-					style |= kFontStyleItalic;
-				} else if (c == 'U') {
-					style |= kFontStyleUnderline;
-				} else if (c == 'O') {
-					style |= kFontStyleOutline;
-				} else if (c == 'S') {
-					style |= kFontStyleShadow;
-				} else if (c == 'C') {
-					style |= kFontStyleCondensed;
-				} else if (c == 'E') {
-					style |= kFontStyleExtended;
-				}
-				item.deleteLastChar();
-				item.deleteLastChar();
-			}
-
-			Common::String tmpitem(item);
-			tmpitem.trim();
-			if (tmpitem[0] == '(') {
-				enabled = false;
-
-				for (uint j = 0; j < item.size(); j++)
-					if (item[j] == '(') {
-						item.deleteChar(j);
-						break;
-					}
-			}
-
-			menu->subitems.push_back(new MenuSubItem(item.c_str(), kMenuActionCommand, style, shortcut, enabled));
-		}
-
-		item.clear();
-	}
-}
-
-void Menu::regenWeaponsMenu() {
-	if (_gui->_engine->_world->_weaponMenuDisabled)
-		return;
-
-	for (uint j = 0; j < _weapons->subitems.size(); j++)
-		delete _weapons->subitems[j];
-
-	_weapons->subitems.clear();
-
-	createWeaponsMenu(_weapons);
-	calcMenuBounds(_weapons);
-}
-
-void Menu::createWeaponsMenu(MenuItem *menu) {
-	Chr *player = _gui->_engine->_world->_player;
-	ObjArray *weapons = player->getWeapons(true);
-
-	for (uint i = 0; i < weapons->size(); i++) {
-		Obj *obj = (*weapons)[i];
-		if (obj->_type == Obj::REGULAR_WEAPON ||
-			obj->_type == Obj::THROW_WEAPON ||
-			obj->_type == Obj::MAGICAL_OBJECT) {
-			Common::String command(obj->_operativeVerb);
-			command += " ";
-			command += obj->_name;
-
-			menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
-		}
-	}
-	delete weapons;
-
-	if (menu->subitems.empty())
-		menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
-}
-
-const Graphics::Font *Menu::getMenuFont() {
-	return _wm->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
-}
-
-const char *Menu::getAcceleratorString(MenuSubItem *item, const char *prefix) {
-	static char res[20];
-	*res = 0;
-
-	if (item->shortcut != 0)
-		sprintf(res, "%s%c%c", prefix, (_wm->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
-
-	return res;
-}
-
-int Menu::calculateMenuWidth(MenuItem *menu) {
-	int maxWidth = 0;
-	for (uint i = 0; i < menu->subitems.size(); i++) {
-		MenuSubItem *item = menu->subitems[i];
-		if (!item->text.empty()) {
-			Common::String text(item->text);
-			Common::String acceleratorText(getAcceleratorString(item, "  "));
-			if (!acceleratorText.empty()) {
-				text += acceleratorText;
-			}
-
-			int width = _font->getStringWidth(text);
-			if (width > maxWidth) {
-				maxWidth = width;
-			}
-		}
-	}
-	return maxWidth;
-}
-
-void Menu::calcMenuBounds(MenuItem *menu) {
-	// TODO: cache maxWidth
-	int maxWidth = calculateMenuWidth(menu);
-	int x1 = menu->bbox.left - 1;
-	int y1 = menu->bbox.bottom + 1;
-	int x2 = x1 + maxWidth + kMenuDropdownPadding * 2 - 4;
-	int y2 = y1 + menu->subitems.size() * kMenuDropdownItemHeight + 2;
-
-	menu->subbbox.left = x1;
-	menu->subbbox.top = y1;
-	menu->subbbox.right = x2;
-	menu->subbbox.bottom = y2;
-}
-
-bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
-	Common::Rect r(_bbox);
-
-	if (!_contentIsDirty)
-		return false;
-
-	_contentIsDirty = true;
-
-	Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
-	r.top = 7;
-	Design::drawFilledRect(&_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
-	r.top = kMenuHeight - 1;
-	Design::drawFilledRect(&_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);
-
-	for (uint i = 0; i < _items.size(); i++) {
-		int color = kColorBlack;
-		MenuItem *it = _items[i];
-
-		if ((uint)_activeItem == i) {
-			Common::Rect hbox = it->bbox;
-
-			hbox.left -= 1;
-			hbox.right += 2;
-
-			Design::drawFilledRect(&_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid);
-			color = kColorWhite;
-
-			if (!it->subitems.empty())
-				renderSubmenu(it);
-		}
-
-		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color);
-	}
-
-	g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
-
-	return true;
-}
-
-void Menu::renderSubmenu(MenuItem *menu) {
-	Common::Rect *r = &menu->subbbox;
-
-	if (r->width() == 0 || r->height() == 0)
-		return;
-
-	Design::drawFilledRect(&_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid);
-	Design::drawRect(&_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid);
-	Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
-	Design::drawHLine(&_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
-
-	int x = r->left + kMenuDropdownPadding;
-	int y = r->top + 1;
-	for (uint i = 0; i < menu->subitems.size(); i++) {
-		Common::String text(menu->subitems[i]->text);
-		Common::String acceleratorText(getAcceleratorString(menu->subitems[i], ""));
-		int accelX = r->right - 25;
-
-		int color = kColorBlack;
-		if (i == (uint)_activeSubItem && !text.empty() && menu->subitems[i]->enabled) {
-			color = kColorWhite;
-			Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
-
-			Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
-		}
-
-		if (!text.empty()) {
-			Graphics::ManagedSurface *s = &_screen;
-			int tx = x, ty = y;
-
-			if (!menu->subitems[i]->enabled) {
-				s = &_tempSurface;
-				tx = 0;
-				ty = 0;
-				accelX -= x;
-
-				_tempSurface.clear(kColorGreen);
-			}
-
-			_font->drawString(s, text, tx, ty, r->width(), color);
-
-			if (!acceleratorText.empty())
-				_font->drawString(s, acceleratorText, accelX, ty, r->width(), color);
-
-			if (!menu->subitems[i]->enabled) {
-				// I am lazy to extend drawString() with plotProc as a parameter, so
-				// fake it here
-				for (int ii = 0; ii < _tempSurface.h; ii++) {
-					const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
-					byte *dst = (byte *)_screen.getBasePtr(x, y+ii);
-					byte pat = _gui->_patterns[kPatternCheckers2 - 1][ii % 8];
-					for (int j = 0; j < r->width(); j++) {
-						if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
-							*dst = *src;
-						src++;
-						dst++;
-					}
-				}
-			}
-		} else { // Delimiter
-			Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
-		}
-
-		y += kMenuDropdownItemHeight;
-	}
-
-	g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
-}
-
-bool Menu::processEvent(Common::Event &event) {
-	switch (event.type) {
-	case Common::EVENT_KEYDOWN:
-		return keyEvent(event);
-	case Common::EVENT_LBUTTONDOWN:
-		return mouseClick(event.mouse.x, event.mouse.y);
-	case Common::EVENT_LBUTTONUP:
-		return mouseRelease(event.mouse.x, event.mouse.y);
-	case Common::EVENT_MOUSEMOVE:
-		return mouseMove(event.mouse.x, event.mouse.y);
-	default:
-		return false;
-	}
-}
-
-bool Menu::keyEvent(Common::Event &event) {
-	if (event.type != Common::EVENT_KEYDOWN)
-		return false;
-
-	if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
-		if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
-			return processMenuShortCut(event.kbd.flags, event.kbd.ascii);
-		}
-	}
-
-	return false;
-}
-
-bool Menu::mouseClick(int x, int y) {
-	if (_bbox.contains(x, y)) {
-		if (!_menuActivated)
-			_screenCopy.copyFrom(_gui->_screen);
-
-		for (uint i = 0; i < _items.size(); i++)
-			if (_items[i]->bbox.contains(x, y)) {
-			  if ((uint)_activeItem == i)
-					return false;
-
-				if (_activeItem != -1) { // Restore background
-					Common::Rect r(_items[_activeItem]->subbbox);
-					r.right += 3;
-					r.bottom += 3;
-
-					_screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
-					g_system->copyRectToScreen(_screen.getBasePtr(r.left, r.top), _screen.pitch, r.left, r.top, r.width(), r.height());
-				}
-
-				_activeItem = i;
-				_activeSubItem = -1;
-				_menuActivated = true;
-
-				return true;
-			}
-	} else if (_menuActivated && _items[_activeItem]->subbbox.contains(x, y)) {
-		MenuItem *it = _items[_activeItem];
-		int numSubItem = (y - it->subbbox.top) / kMenuDropdownItemHeight;
-
-		if (numSubItem != _activeSubItem) {
-			_activeSubItem = numSubItem;
-
-			renderSubmenu(_items[_activeItem]);
-		}
-	} else if (_menuActivated && _activeItem != -1) {
-		_activeSubItem = -1;
-
-		renderSubmenu(_items[_activeItem]);
-	}
-
-	return false;
-}
-
-bool Menu::mouseMove(int x, int y) {
-	if (_menuActivated)
-		if (mouseClick(x, y))
-			return true;
-
-	return false;
-}
-
-bool Menu::mouseRelease(int x, int y) {
-	if (_menuActivated) {
-		_menuActivated = false;
-
-		if (_activeItem != -1 && _activeSubItem != -1 && _items[_activeItem]->subitems[_activeSubItem]->enabled)
-			executeCommand(_items[_activeItem]->subitems[_activeSubItem]);
-
-		_activeItem = -1;
-		_activeSubItem = -1;
-
-		_wm->setFullRefresh(true);
-
-		return true;
-	}
-
-	return false;
-}
-
-void Menu::executeCommand(MenuSubItem *subitem) {
-	switch(subitem->action) {
-	case kMenuActionAbout:
-	case kMenuActionNew:
-	case kMenuActionOpen:
-	case kMenuActionClose:
-	case kMenuActionSave:
-	case kMenuActionSaveAs:
-	case kMenuActionRevert:
-	case kMenuActionQuit:
-
-	case kMenuActionUndo:
-		_gui->actionUndo();
-		break;
-	case kMenuActionCut:
-		_gui->actionCut();
-		break;
-	case kMenuActionCopy:
-		_gui->actionCopy();
-		break;
-	case kMenuActionPaste:
-		_gui->actionPaste();
-		break;
-	case kMenuActionClear:
-		_gui->actionClear();
-		break;
-
-	case kMenuActionCommand:
-		_gui->_engine->processTurn(&subitem->text, NULL);
-		break;
-
-	default:
-		warning("Unknown action: %d", subitem->action);
-
-	}
-}
-
-bool Menu::processMenuShortCut(byte flags, uint16 ascii) {
-	ascii = tolower(ascii);
-
-	if (flags & (Common::KBD_CTRL | Common::KBD_META)) {
-		for (uint i = 0; i < _items.size(); i++)
-			for (uint j = 0; j < _items[i]->subitems.size(); j++)
-				if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
-					executeCommand(_items[i]->subitems[j]);
-					return true;
-				}
-	}
-
-	return false;
-}
-
-void Menu::enableCommand(int menunum, int action, bool state) {
-	for (uint i = 0; i < _items[menunum]->subitems.size(); i++)
-		if (_items[menunum]->subitems[i]->action == action)
-			_items[menunum]->subitems[i]->enabled = state;
-
-	_contentIsDirty = true;
-}
-
-void Menu::disableAllMenus() {
-	for (uint i = 1; i < _items.size(); i++) // Leave About menu on
-		for (uint j = 0; j < _items[i]->subitems.size(); j++)
-			_items[i]->subitems[j]->enabled = false;
-
-	_contentIsDirty = true;
-}
-
-} // End of namespace Wage
diff --git a/engines/wage/menu.h b/engines/wage/menu.h
deleted file mode 100644
index 7e8e9d9..0000000
--- a/engines/wage/menu.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* 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 {
-
-struct MenuItem;
-struct MenuSubItem;
-
-enum {
-	kFontStyleBold = 1,
-	kFontStyleItalic = 2,
-	kFontStyleUnderline = 4,
-	kFontStyleOutline = 8,
-	kFontStyleShadow = 16,
-	kFontStyleCondensed = 32,
-	kFontStyleExtended = 64
-};
-
-enum {
-	kMenuAbout = 0,
-	kMenuFile = 1,
-	kMenuEdit = 2,
-	kMenuCommands = 3,
-	kMenuWeapons = 4
-};
-
-enum {
-	kMenuActionAbout,
-	kMenuActionNew,
-	kMenuActionOpen,
-	kMenuActionClose,
-	kMenuActionSave,
-	kMenuActionSaveAs,
-	kMenuActionRevert,
-	kMenuActionQuit,
-
-	kMenuActionUndo,
-	kMenuActionCut,
-	kMenuActionCopy,
-	kMenuActionPaste,
-	kMenuActionClear,
-
-	kMenuActionCommand
-};
-
-class Menu : public BaseMacWindow {
-public:
-	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
-	~Menu();
-
-	bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
-	bool processEvent(Common::Event &event);
-
-	void regenCommandsMenu();
-	void regenWeaponsMenu();
-	void enableCommand(int menunum, int action, bool state);
-	void disableAllMenus();
-
-	void setActive(bool active) { _menuActivated = active; }
-	bool hasAllFocus() { return _menuActivated; }
-
-	Common::Rect _bbox;
-
-private:
-	Gui *_gui;
-	Graphics::ManagedSurface _screen;
-	Graphics::ManagedSurface _screenCopy;
-	Graphics::ManagedSurface _tempSurface;
-
-private:
-	const Graphics::Font *getMenuFont();
-	const char *getAcceleratorString(MenuSubItem *item, const char *prefix);
-	int calculateMenuWidth(MenuItem *menu);
-	void calcMenuBounds(MenuItem *menu);
-	void renderSubmenu(MenuItem *menu);
-	void createCommandsMenu(MenuItem *menu);
-	void createWeaponsMenu(MenuItem *menu);
-	void executeCommand(MenuSubItem *subitem);
-
-	bool keyEvent(Common::Event &event);
-	bool mouseClick(int x, int y);
-	bool mouseRelease(int x, int y);
-	bool mouseMove(int x, int y);
-
-	bool processMenuShortCut(byte flags, uint16 ascii);
-
-	Common::Array<MenuItem *> _items;
-	MenuItem *_weapons;
-	MenuItem *_commands;
-
-	const Graphics::Font *_font;
-
-	bool _menuActivated;
-
-	int _activeItem;
-	int _activeSubItem;
-};
-
-} // End of namespace Wage
-
-#endif
diff --git a/engines/wage/module.mk b/engines/wage/module.mk
index d65934f..e150d5f 100644
--- a/engines/wage/module.mk
+++ b/engines/wage/module.mk
@@ -9,9 +9,9 @@ MODULE_OBJS := \
 	entities.o \
 	gui.o \
 	gui-console.o \
+	macmenu.o \
 	macwindow.o \
 	macwindowmanager.o \
-	menu.o \
 	randomhat.o \
 	script.o \
 	sound.o \


Commit: 6998182b1fef719499ab8b19d415d1a24dd7d908
    https://github.com/scummvm/scummvm/commit/6998182b1fef719499ab8b19d415d1a24dd7d908
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T11:28:55+02:00

Commit Message:
WAGE: Moved pattern and palette to WM

Changed paths:
    engines/wage/dialog.cpp
    engines/wage/gui-console.cpp
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h



diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 5495409..981f42b 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -92,7 +92,7 @@ const Graphics::Font *Dialog::getDialogFont() {
 }
 
 void Dialog::paint() {
-	Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_patterns, kPatternSolid);
+	Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_wm.getPatterns(), kPatternSolid);
 	_font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.top + 16, _bbox.width(), kColorBlack);
 
 	static int boxOutline[] = { 1, 0, 0, 1, 1 };
@@ -114,7 +114,7 @@ void Dialog::paint() {
 			Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5,
 				button->bounds.right - 5, button->bounds.bottom - 5);
 
-			Design::drawFilledRect(&_gui->_screen, bb, kColorBlack, _gui->_patterns, kPatternSolid);
+			Design::drawFilledRect(&_gui->_screen, bb, kColorBlack, _gui->_wm.getPatterns(), kPatternSolid);
 
 			color = kColorWhite;
 		}
@@ -137,7 +137,7 @@ void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) {
 	for (int i = 0; i < speclen; i++)
 		if (spec[i] != 0)
 			Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - i, bounds.bottom - i,
-						1, kColorBlack, _gui->_patterns, kPatternSolid);
+						1, kColorBlack, _gui->_wm.getPatterns(), kPatternSolid);
 }
 
 int Dialog::run() {
diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index 9c89c27..ef494bf 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -198,7 +198,7 @@ void Gui::renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r) {
 			color = kColorWhite;
 			Common::Rect trect(0, y1, _console.w, y1 + _consoleLineHeight);
 
-			Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+			Design::drawFilledRect(&_console, trect, kColorBlack, _wm.getPatterns(), kPatternSolid);
 		}
 
 		if (line == _selectionStartY || line == _selectionEndY) {
@@ -225,7 +225,7 @@ void Gui::renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r) {
 				else
 					trect.left = rectW;
 
-				Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+				Design::drawFilledRect(&_console, trect, kColorBlack, _wm.getPatterns(), kPatternSolid);
 
 				font->drawString(&_console, beg, x1, y1, textW, color1);
 				font->drawString(&_console, end, x1 + rectW - kConWPadding - kConWOverlap, y1, textW, color2);
@@ -244,7 +244,7 @@ void Gui::renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r) {
 				int rectW2 = rectW1 + font->getStringWidth(mid);
 				Common::Rect trect(rectW1, y1, rectW2, y1 + _consoleLineHeight);
 
-				Design::drawFilledRect(&_console, trect, kColorBlack, _patterns, kPatternSolid);
+				Design::drawFilledRect(&_console, trect, kColorBlack, _wm.getPatterns(), kPatternSolid);
 
 				font->drawString(&_console, beg, x1, y1, textW, kColorBlack);
 				font->drawString(&_console, mid, x1 + rectW1 - kConWPadding - kConWOverlap, y1, textW, kColorWhite);
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index e3e7ccf..9689788 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -48,7 +48,6 @@
 #include "common/timer.h"
 #include "common/system.h"
 #include "graphics/cursorman.h"
-#include "graphics/palette.h"
 #include "graphics/primitives.h"
 
 #include "wage/wage.h"
@@ -62,19 +61,6 @@
 
 namespace Wage {
 
-static const byte palette[] = {
-	0, 0, 0,           // Black
-	0x80, 0x80, 0x80,  // Gray
-	0xff, 0xff, 0xff,  // White
-	0x00, 0xff, 0x00,  // Green
-	0x00, 0xcf, 0x00   // Green2
-};
-
-static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
-								  { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, // kPatternStripes
-								  { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }  // kPatternCheckers2
-};
-
 static const byte macCursorArrow[] = {
 	2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
 	2, 0, 2, 3, 3, 3, 3, 3, 3, 3, 3,
@@ -170,16 +156,10 @@ Gui::Gui(WageEngine *engine) {
 
 	_inputTextLineNum = 0;
 
-	g_system->getPaletteManager()->setPalette(palette, 0, ARRAYSIZE(palette) / 3);
-
-	CursorMan.replaceCursorPalette(palette, 0, 4);
 	CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
 	_cursorIsArrow = true;
 	CursorMan.showMouse(true);
 
-	for (int i = 0; i < ARRAYSIZE(fillPatterns); i++)
-		_patterns.push_back(fillPatterns[i]);
-
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
 	_menu = _wm.addMenu(this);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 9b1995c..448f0b4 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -75,12 +75,6 @@ enum {
 	kCursorHeight = 12
 };
 
-enum {
-	kPatternSolid = 1,
-	kPatternStripes = 2,
-	kPatternCheckers2 = 3
-};
-
 class Gui {
 public:
 	Gui(WageEngine *engine);
@@ -110,8 +104,6 @@ public:
 	bool processSceneEvents(WindowClick click, Common::Event &event);
 	bool processConsoleEvents(WindowClick click, Common::Event &event);
 
-	Patterns &getPatterns() { return _patterns; }
-
 private:
 	void drawScene();
 	void drawConsole();
@@ -132,8 +124,6 @@ public:
 
 	WageEngine *_engine;
 
-	Patterns _patterns;
-
 	bool _cursorDirty;
 	Common::Rect _cursorRect;
 	bool _cursorOff;
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 8dee8eb..1583182 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -346,11 +346,11 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 
 	_contentIsDirty = true;
 
-	Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _gui->_patterns, kPatternSolid);
+	Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _wm->getPatterns(), kPatternSolid);
 	r.top = 7;
-	Design::drawFilledRect(&_screen, r, kColorWhite, _gui->_patterns, kPatternSolid);
+	Design::drawFilledRect(&_screen, r, kColorWhite, _wm->getPatterns(), kPatternSolid);
 	r.top = kMenuHeight - 1;
-	Design::drawFilledRect(&_screen, r, kColorBlack, _gui->_patterns, kPatternSolid);
+	Design::drawFilledRect(&_screen, r, kColorBlack, _wm->getPatterns(), kPatternSolid);
 
 	for (uint i = 0; i < _items.size(); i++) {
 		int color = kColorBlack;
@@ -362,7 +362,7 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 			hbox.left -= 1;
 			hbox.right += 2;
 
-			Design::drawFilledRect(&_screen, hbox, kColorBlack, _gui->_patterns, kPatternSolid);
+			Design::drawFilledRect(&_screen, hbox, kColorBlack, _wm->getPatterns(), kPatternSolid);
 			color = kColorWhite;
 
 			if (!it->subitems.empty())
@@ -383,10 +383,10 @@ void Menu::renderSubmenu(MenuItem *menu) {
 	if (r->width() == 0 || r->height() == 0)
 		return;
 
-	Design::drawFilledRect(&_screen, *r, kColorWhite, _gui->_patterns, kPatternSolid);
-	Design::drawRect(&_screen, *r, 1, kColorBlack, _gui->_patterns, kPatternSolid);
-	Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
-	Design::drawHLine(&_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _gui->_patterns, kPatternSolid);
+	Design::drawFilledRect(&_screen, *r, kColorWhite, _wm->getPatterns(), kPatternSolid);
+	Design::drawRect(&_screen, *r, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
+	Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
+	Design::drawHLine(&_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
 
 	int x = r->left + kMenuDropdownPadding;
 	int y = r->top + 1;
@@ -400,7 +400,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 			color = kColorWhite;
 			Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
 
-			Design::drawFilledRect(&_screen, trect, kColorBlack, _gui->_patterns, kPatternSolid);
+			Design::drawFilledRect(&_screen, trect, kColorBlack, _wm->getPatterns(), kPatternSolid);
 		}
 
 		if (!text.empty()) {
@@ -427,7 +427,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 				for (int ii = 0; ii < _tempSurface.h; ii++) {
 					const byte *src = (const byte *)_tempSurface.getBasePtr(0, ii);
 					byte *dst = (byte *)_screen.getBasePtr(x, y+ii);
-					byte pat = _gui->_patterns[kPatternCheckers2 - 1][ii % 8];
+					byte pat = _wm->getPatterns()[kPatternCheckers2 - 1][ii % 8];
 					for (int j = 0; j < r->width(); j++) {
 						if (*src != kColorGreen && (pat & (1 << (7 - (x + j) % 8))))
 							*dst = *src;
@@ -437,7 +437,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 				}
 			}
 		} else { // Delimiter
-			Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _gui->_patterns, kPatternStripes);
+			Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _wm->getPatterns(), kPatternStripes);
 		}
 
 		y += kMenuDropdownItemHeight;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 66c5bf1..c98c635 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -51,8 +51,10 @@
 #include "common/unzip.h"
 #include "common/system.h"
 
+#include "graphics/cursorman.h"
 #include "graphics/fonts/bdf.h"
 #include "graphics/managed_surface.h"
+#include "graphics/palette.h"
 
 #include "wage/wage.h"
 #include "wage/design.h"
@@ -63,14 +65,20 @@
 
 namespace Wage {
 
-enum {
-	kPatternCheckers = 1
+static const byte palette[] = {
+	0, 0, 0,           // Black
+	0x80, 0x80, 0x80,  // Gray
+	0xff, 0xff, 0xff,  // White
+	0x00, 0xff, 0x00,  // Green
+	0x00, 0xcf, 0x00   // Green2
 };
 
-static byte fillPatterns[][8] = { { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 } // kPatternCheckers
+static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }, // kPatternSolid
+								  { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }, // kPatternStripes
+								  { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 }, // kPatternCheckers
+								  { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }  // kPatternCheckers2
 };
 
-
 MacWindowManager::MacWindowManager() {
     _screen = 0;
     _lastId = 0;
@@ -86,6 +94,10 @@ MacWindowManager::MacWindowManager() {
 		_patterns.push_back(fillPatterns[i]);
 
 	loadFonts();
+
+	g_system->getPaletteManager()->setPalette(palette, 0, ARRAYSIZE(palette) / 3);
+
+	CursorMan.replaceCursorPalette(palette, 0, ARRAYSIZE(palette) / 3);
 }
 
 MacWindowManager::~MacWindowManager() {
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 1c0b5c0..d570264 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -50,6 +50,13 @@
 
 namespace Wage {
 
+enum {
+	kPatternSolid = 1,
+	kPatternStripes = 2,
+	kPatternCheckers = 3,
+	kPatternCheckers2 = 4
+};
+
 class MacWindow;
 class Menu;
 
@@ -74,6 +81,8 @@ public:
 
 	BaseMacWindow *getWindow(int id) { return _windows[id]; }
 
+	Patterns &getPatterns() { return _patterns; }
+
 private:
 	void drawDesktop();
 	void loadFonts();


Commit: b5335ed9d46185cbd21c5a9840b1e28ad2cc79ac
    https://github.com/scummvm/scummvm/commit/b5335ed9d46185cbd21c5a9840b1e28ad2cc79ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T12:09:08+02:00

Commit Message:
WAGE: Moved cursor management to WM

Changed paths:
    engines/wage/dialog.cpp
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h



diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 981f42b..7a7ed37 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -145,7 +145,7 @@ int Dialog::run() {
 	Common::Rect r(_bbox);
 
 	_tempSurface.copyRectToSurface(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch, 0, 0, _bbox.width() + 1, _bbox.height() + 1);
-	_gui->pushArrowCursor();
+	_gui->_wm.pushArrowCursor();
 
 	while (!shouldQuit) {
 		Common::Event event;
@@ -189,7 +189,7 @@ int Dialog::run() {
 	_gui->_screen.copyRectToSurface(_tempSurface.getBasePtr(0, 0), _tempSurface.pitch, _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1);
 	g_system->copyRectToScreen(_gui->_screen.getBasePtr(r.left, r.top), _gui->_screen.pitch, r.left, r.top, r.width() + 1, r.height() + 1);
 
-	_gui->popCursor();
+	_gui->_wm.popCursor();
 
 	return _pressedButton;
 }
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 9689788..afc61c4 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -61,44 +61,6 @@
 
 namespace Wage {
 
-static const byte macCursorArrow[] = {
-	2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-	2, 0, 2, 3, 3, 3, 3, 3, 3, 3, 3,
-	2, 0, 0, 2, 3, 3, 3, 3, 3, 3, 3,
-	2, 0, 0, 0, 2, 3, 3, 3, 3, 3, 3,
-	2, 0, 0, 0, 0, 2, 3, 3, 3, 3, 3,
-	2, 0, 0, 0, 0, 0, 2, 3, 3, 3, 3,
-	2, 0, 0, 0, 0, 0, 0, 2, 3, 3, 3,
-	2, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3,
-	2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3,
-	2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
-	2, 0, 0, 2, 0, 0, 2, 3, 3, 3, 3,
-	2, 0, 2, 3, 2, 0, 0, 2, 3, 3, 3,
-	2, 2, 3, 3, 2, 0, 0, 2, 3, 3, 3,
-	2, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
-	3, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
-	3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3
-};
-
-static const byte macCursorBeam[] = {
-	0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
-	3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
-	3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
-	0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
-};
-
 static void cursorTimerHandler(void *refCon) {
     Gui *gui = (Gui *)refCon;
 
@@ -156,18 +118,14 @@ Gui::Gui(WageEngine *engine) {
 
 	_inputTextLineNum = 0;
 
-	CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
-	_cursorIsArrow = true;
-	CursorMan.showMouse(true);
-
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
 	_menu = _wm.addMenu(this);
 
-	_sceneWindow = _wm.addWindow(false, false);
+	_sceneWindow = _wm.addWindow(false, false, false);
 	_sceneWindow->setCallback(sceneWindowCallback, this);
 
-	_consoleWindow = _wm.addWindow(true, true);
+	_consoleWindow = _wm.addWindow(true, true, true);
 	_consoleWindow->setCallback(consoleWindowCallback, this);
 }
 
@@ -243,11 +201,6 @@ static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *g
 }
 
 bool Gui::processSceneEvents(WindowClick click, Common::Event &event) {
-	if (_cursorIsArrow == false) {
-		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
-		_cursorIsArrow = true;
-	}
-
 	if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) {
 		Designed *obj = _scene->lookUpEntity(event.mouse.x - _sceneWindow->getDimensions().left,
 												  event.mouse.y - _sceneWindow->getDimensions().top);
@@ -278,11 +231,6 @@ static bool consoleWindowCallback(WindowClick click, Common::Event &event, void
 }
 
 bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
-	if (click != kBorderInner && _cursorIsArrow == false) {
-		CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
-		_cursorIsArrow = true;
-	}
-
 	if (click == kBorderScrollUp || click == kBorderScrollDown) {
 		if (event.type == Common::EVENT_LBUTTONDOWN) {
 			int consoleHeight = _consoleWindow->getInnerDimensions().height();
@@ -361,11 +309,6 @@ bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
 				updateTextSelection(event.mouse.x, event.mouse.y);
 				return true;
 			}
-
-			if (_cursorIsArrow) {
-				CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
-				_cursorIsArrow = false;
-			}
 		}
 
 		return false;
@@ -382,14 +325,6 @@ void Gui::regenWeaponsMenu() {
 	_menu->regenWeaponsMenu();
 }
 
-void Gui::pushArrowCursor() {
-	CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
-}
-
-void Gui::popCursor() {
-	CursorMan.popCursor();
-}
-
 bool Gui::processEvent(Common::Event &event) {
 	return _wm.processEvent(event);
 }
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 448f0b4..5c3c281 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -89,8 +89,6 @@ public:
 	void setSceneDirty() { _sceneDirty = true; }
 	void regenCommandsMenu();
 	void regenWeaponsMenu();
-	void pushArrowCursor();
-	void popCursor();
 
 	void actionCopy();
 	void actionPaste();
@@ -147,8 +145,6 @@ private:
 	uint _consoleNumLines;
 	bool _consoleFullRedraw;
 
-	bool _cursorIsArrow;
-
 	bool _inTextSelection;
 	int _selectionStartX;
 	int _selectionStartY;
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 1583182..bc8718b 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -105,7 +105,7 @@ struct MenuData {
 };
 
 Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
-		: BaseMacWindow(id, wm), _gui(gui) {
+		: BaseMacWindow(id, false, wm), _gui(gui) {
 	_font = getMenuFont();
 
 	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index c46def6..c021836 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -54,7 +54,8 @@
 
 namespace Wage {
 
-BaseMacWindow::BaseMacWindow(int id, MacWindowManager *wm) : _id(id), _wm(wm) {
+BaseMacWindow::BaseMacWindow(int id, bool editable, MacWindowManager *wm) :
+		_id(id), _editable(editable), _wm(wm) {
 	_callback = 0;
 	_dataPtr = 0;
 
@@ -63,8 +64,8 @@ BaseMacWindow::BaseMacWindow(int id, MacWindowManager *wm) : _id(id), _wm(wm) {
 	_type = kWindowUnknown;
 }
 
-MacWindow::MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm) :
-		BaseMacWindow(id, wm), _scrollable(scrollable), _resizable(resizable) {
+MacWindow::MacWindow(int id, bool scrollable, bool resizable, bool editable, MacWindowManager *wm) :
+		BaseMacWindow(id, editable, wm), _scrollable(scrollable), _resizable(resizable) {
 	_active = false;
 	_borderIsDirty = true;
 
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 4b2f71e..8d2fda3 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -76,12 +76,13 @@ enum WindowClick {
 
 class BaseMacWindow {
 public:
-	BaseMacWindow(int id, MacWindowManager *wm);
+	BaseMacWindow(int id, bool editable, MacWindowManager *wm);
 	virtual ~BaseMacWindow() {}
 
 	const Common::Rect &getDimensions() { return _dims; }
 	int getId() { return _id; }
 	WindowType getType() { return _type; }
+	bool isEditable() { return _editable; }
 	Graphics::ManagedSurface *getSurface() { return &_surface; }
 	virtual void setActive(bool active) = 0;
 	void setDirty(bool dirty) { _contentIsDirty = dirty; }
@@ -97,6 +98,8 @@ protected:
 	int _id;
 	WindowType _type;
 
+	bool _editable;
+
 	Graphics::ManagedSurface _surface;
 	bool _contentIsDirty;
 
@@ -110,7 +113,7 @@ protected:
 
 class MacWindow : public BaseMacWindow {
 public:
-	MacWindow(int id, bool scrollable, bool resizable, MacWindowManager *wm);
+	MacWindow(int id, bool scrollable, bool resizable, bool editable, MacWindowManager *wm);
 	virtual ~MacWindow();
 	void move(int x, int y);
 	void resize(int w, int h);
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index c98c635..b70ebd2 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -79,6 +79,44 @@ static byte fillPatterns[][8] = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x
 								  { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }  // kPatternCheckers2
 };
 
+static const byte macCursorArrow[] = {
+	2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+	2, 0, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+	2, 0, 0, 2, 3, 3, 3, 3, 3, 3, 3,
+	2, 0, 0, 0, 2, 3, 3, 3, 3, 3, 3,
+	2, 0, 0, 0, 0, 2, 3, 3, 3, 3, 3,
+	2, 0, 0, 0, 0, 0, 2, 3, 3, 3, 3,
+	2, 0, 0, 0, 0, 0, 0, 2, 3, 3, 3,
+	2, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3,
+	2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3,
+	2, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2,
+	2, 0, 0, 2, 0, 0, 2, 3, 3, 3, 3,
+	2, 0, 2, 3, 2, 0, 0, 2, 3, 3, 3,
+	2, 2, 3, 3, 2, 0, 0, 2, 3, 3, 3,
+	2, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
+	3, 3, 3, 3, 3, 2, 0, 0, 2, 3, 3,
+	3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3
+};
+
+static const byte macCursorBeam[] = {
+	0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
+	3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 3,
+	3, 3, 0, 3, 0, 3, 3, 3, 3, 3, 3,
+	0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
+};
+
 MacWindowManager::MacWindowManager() {
     _screen = 0;
     _lastId = 0;
@@ -98,6 +136,9 @@ MacWindowManager::MacWindowManager() {
 	g_system->getPaletteManager()->setPalette(palette, 0, ARRAYSIZE(palette) / 3);
 
 	CursorMan.replaceCursorPalette(palette, 0, ARRAYSIZE(palette) / 3);
+	CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+	_cursorIsArrow = true;
+	CursorMan.showMouse(true);
 }
 
 MacWindowManager::~MacWindowManager() {
@@ -105,8 +146,8 @@ MacWindowManager::~MacWindowManager() {
         delete _windows[i];
 }
 
-MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable) {
-    MacWindow *w = new MacWindow(_lastId, scrollable, resizable, this);
+MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool editable) {
+    MacWindow *w = new MacWindow(_lastId, scrollable, resizable, editable, this);
 
     _windows.push_back(w);
     _windowStack.push_back(w);
@@ -186,6 +227,19 @@ bool MacWindowManager::processEvent(Common::Event &event) {
             event.type != Common::EVENT_LBUTTONUP)
         return false;
 
+	if (_windows[_activeWindow]->isEditable() && _windows[_activeWindow]->getType() == kWindowWindow &&
+			((MacWindow *)_windows[_activeWindow])->getInnerDimensions().contains(event.mouse.x, event.mouse.y)) {
+		if (_cursorIsArrow) {
+			CursorMan.replaceCursor(macCursorBeam, 11, 16, 3, 8, 3);
+			_cursorIsArrow = false;
+		}
+	} else {
+		if (_cursorIsArrow == false) {
+			CursorMan.replaceCursor(macCursorArrow, 11, 16, 1, 1, 3);
+			_cursorIsArrow = true;
+		}
+	}
+
     for (Common::List<BaseMacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) {
         it--;
         BaseMacWindow *w = *it;
@@ -264,4 +318,16 @@ const Graphics::Font *MacWindowManager::getFont(const char *name, Graphics::Font
 	return font;
 }
 
+/////////////////
+// Cursor stuff
+/////////////////
+void MacWindowManager::pushArrowCursor() {
+	CursorMan.pushCursor(macCursorArrow, 11, 16, 1, 1, 3);
+}
+
+void MacWindowManager::popCursor() {
+	CursorMan.popCursor();
+}
+
+
 } // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index d570264..fe85f8e 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -69,7 +69,7 @@ public:
 	bool hasBuiltInFonts() { return _builtInFonts; }
 	const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
 
-	MacWindow *addWindow(bool scrollable, bool resizable);
+	MacWindow *addWindow(bool scrollable, bool resizable, bool editable);
 	Menu *addMenu(Gui *gui);
 	void setActive(int id);
 
@@ -83,6 +83,9 @@ public:
 
 	Patterns &getPatterns() { return _patterns; }
 
+	void pushArrowCursor();
+	void popCursor();
+
 private:
 	void drawDesktop();
 	void loadFonts();
@@ -103,6 +106,7 @@ private:
 	Menu *_menu;
 
 	bool _builtInFonts;
+	bool _cursorIsArrow;
 };
 
 } // End of namespace Wage


Commit: 5fbac749e2951577dbe822aa789ad30005a2bf21
    https://github.com/scummvm/scummvm/commit/5fbac749e2951577dbe822aa789ad30005a2bf21
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T12:37:03+02:00

Commit Message:
WAGE: Moved patterns to WindowManager

Changed paths:
    engines/wage/design.cpp
    engines/wage/design.h
    engines/wage/dialog.cpp
    engines/wage/entities.cpp
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h
    engines/wage/wage.h
    engines/wage/world.cpp
    engines/wage/world.h



diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index e84cf2e..eda28df 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -45,8 +45,10 @@
  *
  */
 
+#include "graphics/managed_surface.h"
 #include "graphics/primitives.h"
-#include "wage/wage.h"
+
+#include "wage/macwindowmanager.h"
 #include "wage/design.h"
 
 namespace Wage {
diff --git a/engines/wage/design.h b/engines/wage/design.h
index a6e0df4..9b0231c 100644
--- a/engines/wage/design.h
+++ b/engines/wage/design.h
@@ -48,10 +48,11 @@
 #ifndef WAGE_DESIGN_H
 #define WAGE_DESIGN_H
 
-#include "graphics/managed_surface.h"
 #include "common/memstream.h"
 #include "common/rect.h"
 
+#include "wage/macwindowmanager.h"
+
 namespace Wage {
 
 class Design {
diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp
index 7a7ed37..d9bb3e6 100644
--- a/engines/wage/dialog.cpp
+++ b/engines/wage/dialog.cpp
@@ -49,6 +49,7 @@
 #include "common/events.h"
 
 #include "wage/wage.h"
+#include "wage/macwindowmanager.h"
 #include "wage/design.h"
 #include "wage/gui.h"
 #include "wage/dialog.h"
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index d0a838f..43ac6c8 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -52,6 +52,7 @@
 #include "wage/world.h"
 
 #include "common/memstream.h"
+#include "graphics/managed_surface.h"
 
 namespace Wage {
 
@@ -138,16 +139,16 @@ void Scene::paint(Graphics::ManagedSurface *surface, int x, int y) {
 	Common::Rect r(x + 5, y + 5, _design->getBounds()->width() + x - 10, _design->getBounds()->height() + y - 10);
 	surface->fillRect(r, kColorWhite);
 
-	_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
+	_design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y);
 
 	for (ObjList::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
 		debug(2, "paining Obj: %s, index: %d, type: %d", (*it)->_name.c_str(), (*it)->_index, (*it)->_type);
-		(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
+		(*it)->_design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y);
 	}
 
 	for (ChrList::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
 		debug(2, "paining Chr: %s", (*it)->_name.c_str());
-		(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
+		(*it)->_design->paint(surface, *((WageEngine *)g_engine)->_world->_patterns, x, y);
 	}
 }
 
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 5c3c281..cba02bb 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -50,7 +50,6 @@
 
 #include "common/str-array.h"
 #include "graphics/font.h"
-#include "graphics/fontman.h"
 #include "graphics/managed_surface.h"
 #include "common/events.h"
 #include "common/rect.h"
@@ -63,15 +62,6 @@ namespace Wage {
 class Menu;
 
 enum {
-	kMenuHeight = 20,
-	kMenuLeftMargin = 7,
-	kMenuSpacing = 13,
-	kMenuPadding = 16,
-	kMenuDropdownPadding = 14,
-	kMenuDropdownItemHeight = 16,
-	kMenuItemHeight = 20,
-	kDesktopArc = 7,
-	kComponentsPadding = 10,
 	kCursorHeight = 12
 };
 
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index bc8718b..5aecfb6 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -52,11 +52,22 @@
 #include "wage/entities.h"
 #include "wage/design.h"
 #include "wage/gui.h"
+#include "wage/macwindowmanager.h"
 #include "wage/macmenu.h"
 #include "wage/world.h"
 
 namespace Wage {
 
+enum {
+	kMenuHeight = 20,
+	kMenuLeftMargin = 7,
+	kMenuSpacing = 13,
+	kMenuPadding = 16,
+	kMenuDropdownPadding = 14,
+	kMenuDropdownItemHeight = 16,
+	kMenuItemHeight = 20
+};
+
 struct MenuSubItem {
 	Common::String text;
 	int action;
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index c021836..eece48e 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -49,6 +49,7 @@
 #include "common/events.h"
 
 #include "wage/wage.h"
+#include "wage/macwindowmanager.h"
 #include "wage/gui.h"
 #include "wage/macwindow.h"
 
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 8d2fda3..157a62b 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -50,6 +50,8 @@
 
 #include "graphics/managed_surface.h"
 
+#include "wage/macwindowmanager.h"
+
 namespace Wage {
 
 class MacWindowManager;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index b70ebd2..f741d3f 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -56,11 +56,11 @@
 #include "graphics/managed_surface.h"
 #include "graphics/palette.h"
 
-#include "wage/wage.h"
+//#include "wage/wage.h"
 #include "wage/design.h"
-#include "wage/gui.h"
-#include "wage/macwindow.h"
+//#include "wage/gui.h"
 #include "wage/macwindowmanager.h"
+#include "wage/macwindow.h"
 #include "wage/macmenu.h"
 
 namespace Wage {
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index fe85f8e..53db0d6 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -48,8 +48,33 @@
 #ifndef WAGE_MACWINDOWMANAGER_H
 #define WAGE_MACWINDOWMANAGER_H
 
+#include "common/array.h"
+#include "common/list.h"
+#include "common/events.h"
+#include "common/archive.h"
+
+#include "graphics/fontman.h"
+
+namespace Graphics {
+class ManagedSurface;
+}
+
 namespace Wage {
 
+class Gui; // FIXME
+
+enum {
+	kDesktopArc = 7
+};
+
+enum {
+	kColorBlack  = 0,
+	kColorGray   = 1,
+	kColorWhite  = 2,
+	kColorGreen  = 3,
+	kColorGreen2 = 4
+};
+
 enum {
 	kPatternSolid = 1,
 	kPatternStripes = 2,
@@ -57,9 +82,12 @@ enum {
 	kPatternCheckers2 = 4
 };
 
+class BaseMacWindow;
 class MacWindow;
 class Menu;
 
+typedef Common::Array<byte *> Patterns;
+
 class MacWindowManager {
 public:
 	MacWindowManager();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 87009c2..eb50a2e 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -103,14 +103,6 @@ enum {
 	// the current limitation is 32 debug levels (1 << 31 is the last one)
 };
 
-enum {
-	kColorBlack  = 0,
-	kColorGray   = 1,
-	kColorWhite  = 2,
-	kColorGreen  = 3,
-	kColorGreen2 = 4
-};
-
 Common::String readPascalString(Common::SeekableReadStream *in);
 Common::Rect *readRect(Common::SeekableReadStream *in);
 const char *getIndefiniteArticle(const Common::String &word);
@@ -118,8 +110,6 @@ const char *prependGenderSpecificPronoun(int gender);
 const char *getGenderSpecificPronoun(int gender, bool capitalize);
 bool isStorageScene(const Common::String &name);
 
-typedef Common::Array<byte *> Patterns;
-
 class WageEngine : public Engine {
 	friend class Dialog;
 public:
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 954a425..53fc1b4 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -73,6 +73,8 @@ World::World(WageEngine *engine) {
 	_weaponMenuDisabled = true;
 
 	_engine = engine;
+
+	_patterns = new Patterns;
 }
 
 World::~World() {
@@ -88,8 +90,10 @@ World::~World() {
 	for (uint i = 0; i < _orderedScenes.size(); i++)
 		delete _orderedScenes[i];
 
-	for (uint i = 0; i < _patterns.size(); i++)
-		free(_patterns[i]);
+	for (uint i = 0; i < _patterns->size(); i++)
+		free(_patterns->operator[](i));
+
+	delete _patterns;
 
 	delete _globalScript;
 
@@ -261,7 +265,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
 			byte *pattern = (byte *)malloc(8);
 
 			res->read(pattern, 8);
-			_patterns.push_back(pattern);
+			_patterns->push_back(pattern);
 		}
 
 		delete res;
@@ -274,7 +278,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
 				byte *pattern = (byte *)malloc(8);
 
 				res->read(pattern, 8);
-				_patterns.push_back(pattern);
+				_patterns->push_back(pattern);
 			}
 		}
 		delete res;
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 355d660..468bedb 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -48,6 +48,8 @@
 #ifndef WAGE_WORLD_H
 #define WAGE_WORLD_H
 
+#include "wage/macwindowmanager.h"
+
 namespace Wage {
 
 class Sound;
@@ -85,7 +87,7 @@ public:
 	ObjArray _orderedObjs;
 	ChrArray _orderedChrs;
 	Common::Array<Sound *> _orderedSounds;
-	Patterns _patterns;
+	Patterns *_patterns;
 	Scene *_storageScene;
 	Chr *_player;
 	//List<MoveListener> moveListeners;


Commit: 5fb5d7a814604fbe22b8dcef462e96fa9211e2c1
    https://github.com/scummvm/scummvm/commit/5fb5d7a814604fbe22b8dcef462e96fa9211e2c1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T12:45:59+02:00

Commit Message:
WAGE: Reduce header dependency

Changed paths:
    engines/wage/macwindow.cpp
    engines/wage/macwindowmanager.cpp



diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index eece48e..79a90d0 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -45,12 +45,10 @@
  *
  */
 
+#include "graphics/font.h"
 #include "graphics/primitives.h"
 #include "common/events.h"
 
-#include "wage/wage.h"
-#include "wage/macwindowmanager.h"
-#include "wage/gui.h"
 #include "wage/macwindow.h"
 
 namespace Wage {
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index f741d3f..9913a36 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -56,9 +56,7 @@
 #include "graphics/managed_surface.h"
 #include "graphics/palette.h"
 
-//#include "wage/wage.h"
 #include "wage/design.h"
-//#include "wage/gui.h"
 #include "wage/macwindowmanager.h"
 #include "wage/macwindow.h"
 #include "wage/macmenu.h"


Commit: 6c610e7a1882144283b1de0347ea91f4bb4f41ea
    https://github.com/scummvm/scummvm/commit/6c610e7a1882144283b1de0347ea91f4bb4f41ea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T12:51:30+02:00

Commit Message:
WAGE: Move rest of console-related functionality to gui-console.cpp

Changed paths:
    engines/wage/gui-console.cpp
    engines/wage/gui.cpp



diff --git a/engines/wage/gui-console.cpp b/engines/wage/gui-console.cpp
index ef494bf..8b6fe43 100644
--- a/engines/wage/gui-console.cpp
+++ b/engines/wage/gui-console.cpp
@@ -424,4 +424,140 @@ void Gui::enableNewGameMenus() {
 	_menu->enableCommand(kMenuFile, kMenuActionQuit, true);
 }
 
+bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
+	if (click == kBorderScrollUp || click == kBorderScrollDown) {
+		if (event.type == Common::EVENT_LBUTTONDOWN) {
+			int consoleHeight = _consoleWindow->getInnerDimensions().height();
+			int textFullSize = _lines.size() * _consoleLineHeight + consoleHeight;
+			float scrollPos = (float)_scrollPos / textFullSize;
+			float scrollSize = (float)consoleHeight / textFullSize;
+
+			_consoleWindow->setScroll(scrollPos, scrollSize);
+
+			return true;
+		} else if (event.type == Common::EVENT_LBUTTONUP) {
+			int oldScrollPos = _scrollPos;
+
+			switch (click) {
+			case kBorderScrollUp:
+				_scrollPos = MAX<int>(0, _scrollPos - _consoleLineHeight);
+				undrawCursor();
+				_cursorY -= (_scrollPos - oldScrollPos);
+				_consoleDirty = true;
+				_consoleFullRedraw = true;
+				break;
+			case kBorderScrollDown:
+				_scrollPos = MIN<int>((_lines.size() - 2) * _consoleLineHeight, _scrollPos + _consoleLineHeight);
+				undrawCursor();
+				_cursorY -= (_scrollPos - oldScrollPos);
+				_consoleDirty = true;
+				_consoleFullRedraw = true;
+				break;
+			default:
+				return false;
+			}
+
+			return true;
+		}
+
+		return false;
+	}
+
+	if (click == kBorderResizeButton) {
+		_consoleDirty = true;
+		_consoleFullRedraw = true;
+
+		return true;
+	}
+
+	if (click == kBorderInner) {
+		if (event.type == Common::EVENT_LBUTTONDOWN) {
+			startMarking(event.mouse.x, event.mouse.y);
+
+			return true;
+		} else if (event.type == Common::EVENT_LBUTTONUP) {
+			if (_inTextSelection) {
+				_inTextSelection = false;
+
+				if (_selectionEndY == -1 ||
+						(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
+					_selectionStartY = _selectionEndY = -1;
+					_consoleFullRedraw = true;
+					_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
+				} else {
+					_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
+
+					bool cutAllowed = false;
+
+					if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1)
+						cutAllowed = true;
+
+					_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
+					_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
+				}
+			}
+
+			return true;
+		} else if (event.type == Common::EVENT_MOUSEMOVE) {
+			if (_inTextSelection) {
+				updateTextSelection(event.mouse.x, event.mouse.y);
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	return false;
+}
+
+int Gui::calcTextX(int x, int textLine) {
+	const Graphics::Font *font = getConsoleFont();
+
+	if ((uint)textLine >= _lines.size())
+		return 0;
+
+	Common::String str = _lines[textLine];
+
+	x -= _consoleWindow->getInnerDimensions().left;
+
+	for (int i = str.size(); i >= 0; i--) {
+		if (font->getStringWidth(str) < x) {
+			return i;
+		}
+
+		str.deleteLastChar();
+	}
+
+	return 0;
+}
+
+int Gui::calcTextY(int y) {
+	y -= _consoleWindow->getInnerDimensions().top;
+
+	if (y < 0)
+		y = 0;
+
+	const int firstLine = _scrollPos / _consoleLineHeight;
+	int textLine = (y - _scrollPos % _consoleLineHeight) / _consoleLineHeight + firstLine;
+
+	return textLine;
+}
+
+void Gui::startMarking(int x, int y) {
+	_selectionStartY = calcTextY(y);
+	_selectionStartX = calcTextX(x, _selectionStartY);
+
+	_selectionEndY = -1;
+
+	_inTextSelection = true;
+}
+
+void Gui::updateTextSelection(int x, int y) {
+	_selectionEndY = calcTextY(y);
+	_selectionEndX = calcTextX(x, _selectionEndY);
+
+	_consoleFullRedraw = true;
+}
+
 } // End of namespace Wage
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index afc61c4..2809656 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -230,93 +230,6 @@ static bool consoleWindowCallback(WindowClick click, Common::Event &event, void
 	return gui->processConsoleEvents(click, event);
 }
 
-bool Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
-	if (click == kBorderScrollUp || click == kBorderScrollDown) {
-		if (event.type == Common::EVENT_LBUTTONDOWN) {
-			int consoleHeight = _consoleWindow->getInnerDimensions().height();
-			int textFullSize = _lines.size() * _consoleLineHeight + consoleHeight;
-			float scrollPos = (float)_scrollPos / textFullSize;
-			float scrollSize = (float)consoleHeight / textFullSize;
-
-			_consoleWindow->setScroll(scrollPos, scrollSize);
-
-			return true;
-		} else if (event.type == Common::EVENT_LBUTTONUP) {
-			int oldScrollPos = _scrollPos;
-
-			switch (click) {
-			case kBorderScrollUp:
-				_scrollPos = MAX<int>(0, _scrollPos - _consoleLineHeight);
-				undrawCursor();
-				_cursorY -= (_scrollPos - oldScrollPos);
-				_consoleDirty = true;
-				_consoleFullRedraw = true;
-				break;
-			case kBorderScrollDown:
-				_scrollPos = MIN<int>((_lines.size() - 2) * _consoleLineHeight, _scrollPos + _consoleLineHeight);
-				undrawCursor();
-				_cursorY -= (_scrollPos - oldScrollPos);
-				_consoleDirty = true;
-				_consoleFullRedraw = true;
-				break;
-			default:
-				return false;
-			}
-
-			return true;
-		}
-
-		return false;
-	}
-
-	if (click == kBorderResizeButton) {
-		_consoleDirty = true;
-		_consoleFullRedraw = true;
-
-		return true;
-	}
-
-	if (click == kBorderInner) {
-		if (event.type == Common::EVENT_LBUTTONDOWN) {
-			startMarking(event.mouse.x, event.mouse.y);
-
-			return true;
-		} else if (event.type == Common::EVENT_LBUTTONUP) {
-			if (_inTextSelection) {
-				_inTextSelection = false;
-
-				if (_selectionEndY == -1 ||
-						(_selectionEndX == _selectionStartX && _selectionEndY == _selectionStartY)) {
-					_selectionStartY = _selectionEndY = -1;
-					_consoleFullRedraw = true;
-					_menu->enableCommand(kMenuEdit, kMenuActionCopy, false);
-				} else {
-					_menu->enableCommand(kMenuEdit, kMenuActionCopy, true);
-
-					bool cutAllowed = false;
-
-					if (_selectionStartY == _selectionEndY && _selectionStartY == (int)_lines.size() - 1)
-						cutAllowed = true;
-
-					_menu->enableCommand(kMenuEdit, kMenuActionCut, cutAllowed);
-					_menu->enableCommand(kMenuEdit, kMenuActionClear, cutAllowed);
-				}
-			}
-
-			return true;
-		} else if (event.type == Common::EVENT_MOUSEMOVE) {
-			if (_inTextSelection) {
-				updateTextSelection(event.mouse.x, event.mouse.y);
-				return true;
-			}
-		}
-
-		return false;
-	}
-
-	return false;
-}
-
 void Gui::regenCommandsMenu() {
 	_menu->regenCommandsMenu();
 }
@@ -329,53 +242,4 @@ bool Gui::processEvent(Common::Event &event) {
 	return _wm.processEvent(event);
 }
 
-int Gui::calcTextX(int x, int textLine) {
-	const Graphics::Font *font = getConsoleFont();
-
-	if ((uint)textLine >= _lines.size())
-		return 0;
-
-	Common::String str = _lines[textLine];
-
-	x -= _consoleWindow->getInnerDimensions().left;
-
-	for (int i = str.size(); i >= 0; i--) {
-		if (font->getStringWidth(str) < x) {
-			return i;
-		}
-
-		str.deleteLastChar();
-	}
-
-	return 0;
-}
-
-int Gui::calcTextY(int y) {
-	y -= _consoleWindow->getInnerDimensions().top;
-
-	if (y < 0)
-		y = 0;
-
-	const int firstLine = _scrollPos / _consoleLineHeight;
-	int textLine = (y - _scrollPos % _consoleLineHeight) / _consoleLineHeight + firstLine;
-
-	return textLine;
-}
-
-void Gui::startMarking(int x, int y) {
-	_selectionStartY = calcTextY(y);
-	_selectionStartX = calcTextX(x, _selectionStartY);
-
-	_selectionEndY = -1;
-
-	_inTextSelection = true;
-}
-
-void Gui::updateTextSelection(int x, int y) {
-	_selectionEndY = calcTextY(y);
-	_selectionEndX = calcTextX(x, _selectionEndY);
-
-	_consoleFullRedraw = true;
-}
-
 } // End of namespace Wage


Commit: 3027433b669d00a5b16689a4de518639d7dff746
    https://github.com/scummvm/scummvm/commit/3027433b669d00a5b16689a4de518639d7dff746
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T13:43:29+02:00

Commit Message:
WAGE: Moved game-specific menu creation to gui.cpp

Changed paths:
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macmenu.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 2809656..9eca3a8 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -61,6 +61,27 @@
 
 namespace Wage {
 
+static const MenuData menuSubItems[] = {
+	{ kMenuHighLevel, "File",	0, 0, false },
+	{ kMenuHighLevel, "Edit",	0, 0, false },
+	{ kMenuFile, "New",			kMenuActionNew, 0, false },
+	{ kMenuFile, "Open...",		kMenuActionOpen, 0, false },
+	{ kMenuFile, "Close",		kMenuActionClose, 0, true },
+	{ kMenuFile, "Save",		kMenuActionSave, 0, false },
+	{ kMenuFile, "Save as...",	kMenuActionSaveAs, 0, true },
+	{ kMenuFile, "Revert",		kMenuActionRevert, 0, false },
+	{ kMenuFile, "Quit",		kMenuActionQuit, 0, true },
+
+	{ kMenuEdit, "Undo",		kMenuActionUndo, 'Z', false },
+	{ kMenuEdit, NULL,			0, 0, false },
+	{ kMenuEdit, "Cut",			kMenuActionCut, 'K', false },
+	{ kMenuEdit, "Copy",		kMenuActionCopy, 'C', false },
+	{ kMenuEdit, "Paste",		kMenuActionPaste, 'V', false },
+	{ kMenuEdit, "Clear",		kMenuActionClear, 'B', false },
+
+	{ 0, NULL,			0, 0, false }
+};
+
 static void cursorTimerHandler(void *refCon) {
     Gui *gui = (Gui *)refCon;
 
@@ -122,6 +143,22 @@ Gui::Gui(WageEngine *engine) {
 
 	_menu = _wm.addMenu(this);
 
+	_menu->addStaticMenus(menuSubItems);
+	_menu->addMenuSubItem(kMenuAbout, _engine->_world->getAboutMenuItemName(), kMenuActionAbout);
+
+	_commandsMenuId = _menu->addMenuItem(_engine->_world->_commandsMenuName.c_str());
+	regenCommandsMenu();
+
+	if (!_engine->_world->_weaponMenuDisabled) {
+		_weaponsMenuId = _menu->addMenuItem(_engine->_world->_weaponsMenuName.c_str());
+
+		regenWeaponsMenu();
+	} else {
+		_weaponsMenuId = -1;
+	}
+
+	_menu->calcDimensions();
+
 	_sceneWindow = _wm.addWindow(false, false, false);
 	_sceneWindow->setCallback(sceneWindowCallback, this);
 
@@ -231,11 +268,38 @@ static bool consoleWindowCallback(WindowClick click, Common::Event &event, void
 }
 
 void Gui::regenCommandsMenu() {
-	_menu->regenCommandsMenu();
+	_menu->createSubMenuFromString(_commandsMenuId, _engine->_world->_commandsMenu.c_str());
 }
 
 void Gui::regenWeaponsMenu() {
-	_menu->regenWeaponsMenu();
+	if (_engine->_world->_weaponMenuDisabled)
+		return;
+
+	_menu->clearSubMenu(_weaponsMenuId);
+
+	Chr *player = _engine->_world->_player;
+	ObjArray *weapons = player->getWeapons(true);
+
+	bool empty = true;
+
+	for (uint i = 0; i < weapons->size(); i++) {
+		Obj *obj = (*weapons)[i];
+		if (obj->_type == Obj::REGULAR_WEAPON ||
+			obj->_type == Obj::THROW_WEAPON ||
+			obj->_type == Obj::MAGICAL_OBJECT) {
+			Common::String command(obj->_operativeVerb);
+			command += " ";
+			command += obj->_name;
+
+			_menu->addMenuSubItem(_weaponsMenuId, command.c_str(), kMenuActionCommand, 0, 0, true);
+
+			empty = false;
+		}
+	}
+	delete weapons;
+
+	if (empty)
+		_menu->addMenuSubItem(_weaponsMenuId, "You have no weapons", 0, 0, 0, false);
 }
 
 bool Gui::processEvent(Common::Event &event) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index cba02bb..c3612db 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -145,6 +145,9 @@ private:
 	Common::String _undobuffer;
 
 	int _inputTextLineNum;
+
+	int _commandsMenuId;
+	int _weaponsMenuId;
 };
 
 } // End of namespace Wage
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 5aecfb6..0b3b76c 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -90,66 +90,63 @@ struct MenuItem {
 	MenuItem(const char *n) : name(n) {}
 };
 
-struct MenuData {
-	int menunum;
-	const char *title;
-	int action;
-	byte shortcut;
-	bool enabled;
-} static const menuSubItems[] = {
-	{ kMenuFile, "New",			kMenuActionNew, 0, false },
-	{ kMenuFile, "Open...",		kMenuActionOpen, 0, false },
-	{ kMenuFile, "Close",		kMenuActionClose, 0, true },
-	{ kMenuFile, "Save",		kMenuActionSave, 0, false },
-	{ kMenuFile, "Save as...",	kMenuActionSaveAs, 0, true },
-	{ kMenuFile, "Revert",		kMenuActionRevert, 0, false },
-	{ kMenuFile, "Quit",		kMenuActionQuit, 0, true },
-
-	{ kMenuEdit, "Undo",		kMenuActionUndo, 'Z', false },
-	{ kMenuEdit, NULL,			0, 0, false },
-	{ kMenuEdit, "Cut",			kMenuActionCut, 'K', false },
-	{ kMenuEdit, "Copy",		kMenuActionCopy, 'C', false },
-	{ kMenuEdit, "Paste",		kMenuActionPaste, 'V', false },
-	{ kMenuEdit, "Clear",		kMenuActionClear, 'B', false },
-
-	{ 0, NULL,			0, 0, false }
-};
-
 Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
 		: BaseMacWindow(id, false, wm), _gui(gui) {
 	_font = getMenuFont();
 
 	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
 
+	_bbox.left = 0;
+	_bbox.top = 0;
+	_bbox.right = _screen.w - 1;
+	_bbox.bottom = kMenuHeight - 1;
+
+	_menuActivated = false;
+	_activeItem = -1;
+	_activeSubItem = -1;
+
+	_screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
+	_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
+}
+
+Menu::~Menu() {
+	for (uint i = 0; i < _items.size(); i++) {
+		for (uint j = 0; j < _items[i]->subitems.size(); j++)
+			delete _items[i]->subitems[j];
+		delete _items[i];
+	}
+}
+
+void Menu::addStaticMenus(const MenuData *data) {
 	MenuItem *about = new MenuItem(_wm->hasBuiltInFonts() ? "\xa9" : "\xf0"); // (c) Symbol as the most resembling apple
 	_items.push_back(about);
-	_items[0]->subitems.push_back(new MenuSubItem(_gui->_engine->_world->getAboutMenuItemName(), kMenuActionAbout));
 
-	MenuItem *file = new MenuItem("File");
-	_items.push_back(file);
+	for (int i = 0; data[i].menunum; i++) {
+		const MenuData *m = &data[i];
 
-	MenuItem *edit = new MenuItem("Edit");
-	_items.push_back(edit);
+		if (m->menunum == kMenuHighLevel) {
+			MenuItem *item = new MenuItem(m->title);
+			_items.push_back(item);
 
-	for (int i = 0; menuSubItems[i].menunum; i++) {
-		const MenuData *m = &menuSubItems[i];
+			continue;
+		}
 
 		_items[m->menunum]->subitems.push_back(new MenuSubItem(m->title, m->action, 0, m->shortcut, m->enabled));
 	}
+}
 
-	_commands = new MenuItem(_gui->_engine->_world->_commandsMenuName.c_str());
-	_items.push_back(_commands);
-	regenCommandsMenu();
-
-	_weapons = NULL;
+int Menu::addMenuItem(const char *name) {
+	MenuItem *i = new MenuItem(name);
+	_items.push_back(i);
 
-	if (!_gui->_engine->_world->_weaponMenuDisabled) {
-		_weapons = new MenuItem(_gui->_engine->_world->_weaponsMenuName.c_str());
-		_items.push_back(_weapons);
+	return _items.size() - 1;
+}
 
-		regenWeaponsMenu();
-	}
+void Menu::addMenuSubItem(int id, const char *text, int action, int style, char shortcut, bool enabled) {
+	_items[id]->subitems.push_back(new MenuSubItem(text, action, style, shortcut, enabled));
+}
 
+void Menu::calcDimensions() {
 	// Calculate menu dimensions
 	int y = 1;
 	int x = 18;
@@ -168,40 +165,22 @@ Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
 
 		x += w + kMenuSpacing;
 	}
-
-	_bbox.left = 0;
-	_bbox.top = 0;
-	_bbox.right = _screen.w - 1;
-	_bbox.bottom = kMenuHeight - 1;
-
-	_menuActivated = false;
-	_activeItem = -1;
-	_activeSubItem = -1;
-
-	_screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
-	_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
-}
-
-Menu::~Menu() {
-	for (uint i = 0; i < _items.size(); i++) {
-		for (uint j = 0; j < _items[i]->subitems.size(); j++)
-			delete _items[i]->subitems[j];
-		delete _items[i];
-	}
 }
 
-void Menu::regenCommandsMenu() {
-	for (uint j = 0; j < _commands->subitems.size(); j++)
-		delete _commands->subitems[j];
+void Menu::clearSubMenu(int id) {
+	MenuItem *menu = _items[id];
 
-	_commands->subitems.clear();
+	for (uint j = 0; j < menu->subitems.size(); j++)
+		delete menu->subitems[j];
 
-	createCommandsMenu(_commands);
-	calcMenuBounds(_commands);
+	menu->subitems.clear();
 }
 
-void Menu::createCommandsMenu(MenuItem *menu) {
-	Common::String string(_gui->_engine->_world->_commandsMenu);
+void Menu::createSubMenuFromString(int id, const char *str) {
+	clearSubMenu(id);
+
+	MenuItem *menu = _items[id];
+	Common::String string(str);
 
 	Common::String item;
 
@@ -264,41 +243,8 @@ void Menu::createCommandsMenu(MenuItem *menu) {
 
 		item.clear();
 	}
-}
-
-void Menu::regenWeaponsMenu() {
-	if (_gui->_engine->_world->_weaponMenuDisabled)
-		return;
-
-	for (uint j = 0; j < _weapons->subitems.size(); j++)
-		delete _weapons->subitems[j];
-
-	_weapons->subitems.clear();
-
-	createWeaponsMenu(_weapons);
-	calcMenuBounds(_weapons);
-}
-
-void Menu::createWeaponsMenu(MenuItem *menu) {
-	Chr *player = _gui->_engine->_world->_player;
-	ObjArray *weapons = player->getWeapons(true);
-
-	for (uint i = 0; i < weapons->size(); i++) {
-		Obj *obj = (*weapons)[i];
-		if (obj->_type == Obj::REGULAR_WEAPON ||
-			obj->_type == Obj::THROW_WEAPON ||
-			obj->_type == Obj::MAGICAL_OBJECT) {
-			Common::String command(obj->_operativeVerb);
-			command += " ";
-			command += obj->_name;
-
-			menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true));
-		}
-	}
-	delete weapons;
 
-	if (menu->subitems.empty())
-		menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false));
+	calcMenuBounds(menu);
 }
 
 const Graphics::Font *Menu::getMenuFont() {
diff --git a/engines/wage/macmenu.h b/engines/wage/macmenu.h
index 0ad99a4..c80de9d 100644
--- a/engines/wage/macmenu.h
+++ b/engines/wage/macmenu.h
@@ -64,6 +64,7 @@ enum {
 };
 
 enum {
+	kMenuHighLevel = -1,
 	kMenuAbout = 0,
 	kMenuFile = 1,
 	kMenuEdit = 2,
@@ -90,16 +91,30 @@ enum {
 	kMenuActionCommand
 };
 
+struct MenuData {
+	int menunum;
+	const char *title;
+	int action;
+	byte shortcut;
+	bool enabled;
+};
+
 class Menu : public BaseMacWindow {
 public:
 	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
 	~Menu();
 
+	void addStaticMenus(const MenuData *data);
+	void calcDimensions();
+
+	int addMenuItem(const char *name);
+	void addMenuSubItem(int id, const char *text, int action, int style = 0, char shortcut = 0, bool enabled = true);
+	void createSubMenuFromString(int id, const char *string);
+	void clearSubMenu(int id);
+
 	bool draw(Graphics::ManagedSurface *g, bool forceRedraw = false);
 	bool processEvent(Common::Event &event);
 
-	void regenCommandsMenu();
-	void regenWeaponsMenu();
 	void enableCommand(int menunum, int action, bool state);
 	void disableAllMenus();
 
@@ -120,8 +135,6 @@ private:
 	int calculateMenuWidth(MenuItem *menu);
 	void calcMenuBounds(MenuItem *menu);
 	void renderSubmenu(MenuItem *menu);
-	void createCommandsMenu(MenuItem *menu);
-	void createWeaponsMenu(MenuItem *menu);
 	void executeCommand(MenuSubItem *subitem);
 
 	bool keyEvent(Common::Event &event);
@@ -132,8 +145,6 @@ private:
 	bool processMenuShortCut(byte flags, uint16 ascii);
 
 	Common::Array<MenuItem *> _items;
-	MenuItem *_weapons;
-	MenuItem *_commands;
 
 	const Graphics::Font *_font;
 


Commit: 72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f
    https://github.com/scummvm/scummvm/commit/72b8f3a1c7e47ec6fef962cd1aa7abebcf5d782f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T15:25:14+02:00

Commit Message:
WAGE: Implemented menu commands as callback

Changed paths:
    engines/wage/gui.cpp
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macmenu.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 9eca3a8..0ddae88 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -112,6 +112,8 @@ static void cursorTimerHandler(void *refCon) {
 
 static bool sceneWindowCallback(WindowClick click, Common::Event &event, void *gui);
 static bool consoleWindowCallback(WindowClick click, Common::Event &event, void *gui);
+static void menuCommandsCallback(int action, Common::String &text, void *data);
+
 
 Gui::Gui(WageEngine *engine) {
 	_engine = engine;
@@ -143,6 +145,8 @@ Gui::Gui(WageEngine *engine) {
 
 	_menu = _wm.addMenu(this);
 
+	_menu->setCommandsCallback(menuCommandsCallback, this);
+
 	_menu->addStaticMenus(menuSubItems);
 	_menu->addMenuSubItem(kMenuAbout, _engine->_world->getAboutMenuItemName(), kMenuActionAbout);
 
@@ -267,6 +271,9 @@ static bool consoleWindowCallback(WindowClick click, Common::Event &event, void
 	return gui->processConsoleEvents(click, event);
 }
 
+////////////////
+// Menu stuff
+////////////////
 void Gui::regenCommandsMenu() {
 	_menu->createSubMenuFromString(_commandsMenuId, _engine->_world->_commandsMenu.c_str());
 }
@@ -306,4 +313,47 @@ bool Gui::processEvent(Common::Event &event) {
 	return _wm.processEvent(event);
 }
 
+void menuCommandsCallback(int action, Common::String &text, void *data) {
+	Gui *g = (Gui *)data;
+
+	g->executeMenuCommand(action, text);
+}
+
+void Gui::executeMenuCommand(int action, Common::String &text) {
+	switch(action) {
+	case kMenuActionAbout:
+	case kMenuActionNew:
+	case kMenuActionOpen:
+	case kMenuActionClose:
+	case kMenuActionSave:
+	case kMenuActionSaveAs:
+	case kMenuActionRevert:
+	case kMenuActionQuit:
+
+	case kMenuActionUndo:
+		actionUndo();
+		break;
+	case kMenuActionCut:
+		actionCut();
+		break;
+	case kMenuActionCopy:
+		actionCopy();
+		break;
+	case kMenuActionPaste:
+		actionPaste();
+		break;
+	case kMenuActionClear:
+		actionClear();
+		break;
+
+	case kMenuActionCommand:
+		_engine->processTurn(&text, NULL);
+		break;
+
+	default:
+		warning("Unknown action: %d", action);
+
+	}
+}
+
 } // End of namespace Wage
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index c3612db..ecf54d4 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -91,6 +91,7 @@ public:
 
 	bool processSceneEvents(WindowClick click, Common::Event &event);
 	bool processConsoleEvents(WindowClick click, Common::Event &event);
+	void executeMenuCommand(int action, Common::String &text);
 
 private:
 	void drawScene();
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 0b3b76c..aecf277 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -487,7 +487,8 @@ bool Menu::mouseRelease(int x, int y) {
 		_menuActivated = false;
 
 		if (_activeItem != -1 && _activeSubItem != -1 && _items[_activeItem]->subitems[_activeSubItem]->enabled)
-			executeCommand(_items[_activeItem]->subitems[_activeSubItem]);
+			(*_ccallback)(_items[_activeItem]->subitems[_activeSubItem]->action,
+					_items[_activeItem]->subitems[_activeSubItem]->text, _cdata);
 
 		_activeItem = -1;
 		_activeSubItem = -1;
@@ -500,43 +501,6 @@ bool Menu::mouseRelease(int x, int y) {
 	return false;
 }
 
-void Menu::executeCommand(MenuSubItem *subitem) {
-	switch(subitem->action) {
-	case kMenuActionAbout:
-	case kMenuActionNew:
-	case kMenuActionOpen:
-	case kMenuActionClose:
-	case kMenuActionSave:
-	case kMenuActionSaveAs:
-	case kMenuActionRevert:
-	case kMenuActionQuit:
-
-	case kMenuActionUndo:
-		_gui->actionUndo();
-		break;
-	case kMenuActionCut:
-		_gui->actionCut();
-		break;
-	case kMenuActionCopy:
-		_gui->actionCopy();
-		break;
-	case kMenuActionPaste:
-		_gui->actionPaste();
-		break;
-	case kMenuActionClear:
-		_gui->actionClear();
-		break;
-
-	case kMenuActionCommand:
-		_gui->_engine->processTurn(&subitem->text, NULL);
-		break;
-
-	default:
-		warning("Unknown action: %d", subitem->action);
-
-	}
-}
-
 bool Menu::processMenuShortCut(byte flags, uint16 ascii) {
 	ascii = tolower(ascii);
 
@@ -544,7 +508,7 @@ bool Menu::processMenuShortCut(byte flags, uint16 ascii) {
 		for (uint i = 0; i < _items.size(); i++)
 			for (uint j = 0; j < _items[i]->subitems.size(); j++)
 				if (_items[i]->subitems[j]->enabled && tolower(_items[i]->subitems[j]->shortcut) == ascii) {
-					executeCommand(_items[i]->subitems[j]);
+					(*_ccallback)(_items[i]->subitems[j]->action, _items[i]->subitems[j]->text, _cdata);
 					return true;
 				}
 	}
diff --git a/engines/wage/macmenu.h b/engines/wage/macmenu.h
index c80de9d..929ce76 100644
--- a/engines/wage/macmenu.h
+++ b/engines/wage/macmenu.h
@@ -104,6 +104,8 @@ public:
 	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
 	~Menu();
 
+	void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; }
+
 	void addStaticMenus(const MenuData *data);
 	void calcDimensions();
 
@@ -135,7 +137,6 @@ private:
 	int calculateMenuWidth(MenuItem *menu);
 	void calcMenuBounds(MenuItem *menu);
 	void renderSubmenu(MenuItem *menu);
-	void executeCommand(MenuSubItem *subitem);
 
 	bool keyEvent(Common::Event &event);
 	bool mouseClick(int x, int y);
@@ -152,6 +153,9 @@ private:
 
 	int _activeItem;
 	int _activeSubItem;
+
+	void (*_ccallback)(int action, Common::String &text, void *data);
+	void *_cdata;
 };
 
 } // End of namespace Wage


Commit: 859cd9d1f953f3c4263996ad84c541d7d9f1580a
    https://github.com/scummvm/scummvm/commit/859cd9d1f953f3c4263996ad84c541d7d9f1580a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T16:13:27+02:00

Commit Message:
WAGE: Removed dependency of Menu on Wage::Design

Changed paths:
    engines/wage/gui.h
    engines/wage/macmenu.cpp
    engines/wage/macwindow.cpp
    engines/wage/macwindow.h



diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index ecf54d4..ba1bb5e 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -60,6 +60,8 @@
 namespace Wage {
 
 class Menu;
+class Scene;
+class WageEngine;
 
 enum {
 	kCursorHeight = 12
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index aecf277..19deffd 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -48,13 +48,11 @@
 #include "common/system.h"
 #include "common/keyboard.h"
 
-#include "wage/wage.h"
-#include "wage/entities.h"
-#include "wage/design.h"
+#include "graphics/primitives.h"
+
 #include "wage/gui.h"
 #include "wage/macwindowmanager.h"
 #include "wage/macmenu.h"
-#include "wage/world.h"
 
 namespace Wage {
 
@@ -98,8 +96,8 @@ Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
 
 	_bbox.left = 0;
 	_bbox.top = 0;
-	_bbox.right = _screen.w - 1;
-	_bbox.bottom = kMenuHeight - 1;
+	_bbox.right = _screen.w;
+	_bbox.bottom = kMenuHeight;
 
 	_menuActivated = false;
 	_activeItem = -1;
@@ -295,6 +293,17 @@ void Menu::calcMenuBounds(MenuItem *menu) {
 	menu->subbbox.bottom = y2;
 }
 
+static void drawPixelPlain(int x, int y, int color, void *data) {
+	Graphics::ManagedSurface *surface = (Graphics::ManagedSurface *)data;
+
+	if (x >= 0 && x < surface->w && y >= 0 && y < surface->h)
+		*((byte *)surface->getBasePtr(x, y)) = (byte)color;
+}
+
+static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color) {
+	Graphics::drawRoundRect(rect, arc, color, true, drawPixelPlain, surface);
+}
+
 bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 	Common::Rect r(_bbox);
 
@@ -303,11 +312,11 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 
 	_contentIsDirty = true;
 
-	Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite, _wm->getPatterns(), kPatternSolid);
+	drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite);
 	r.top = 7;
-	Design::drawFilledRect(&_screen, r, kColorWhite, _wm->getPatterns(), kPatternSolid);
+	_screen.fillRect(r, kColorWhite);
 	r.top = kMenuHeight - 1;
-	Design::drawFilledRect(&_screen, r, kColorBlack, _wm->getPatterns(), kPatternSolid);
+	_screen.fillRect(r, kColorBlack);
 
 	for (uint i = 0; i < _items.size(); i++) {
 		int color = kColorBlack;
@@ -317,9 +326,10 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 			Common::Rect hbox = it->bbox;
 
 			hbox.left -= 1;
-			hbox.right += 2;
+			hbox.right += 3;
+			hbox.bottom += 1;
 
-			Design::drawFilledRect(&_screen, hbox, kColorBlack, _wm->getPatterns(), kPatternSolid);
+			_screen.fillRect(hbox, kColorBlack);
 			color = kColorWhite;
 
 			if (!it->subitems.empty())
@@ -340,10 +350,12 @@ void Menu::renderSubmenu(MenuItem *menu) {
 	if (r->width() == 0 || r->height() == 0)
 		return;
 
-	Design::drawFilledRect(&_screen, *r, kColorWhite, _wm->getPatterns(), kPatternSolid);
-	Design::drawRect(&_screen, *r, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
-	Design::drawVLine(&_screen, r->right + 1, r->top + 3, r->bottom + 1, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
-	Design::drawHLine(&_screen, r->left + 3, r->right + 1, r->bottom + 1, 1, kColorBlack, _wm->getPatterns(), kPatternSolid);
+	_screen.fillRect(*r, kColorWhite);
+	_screen.frameRect(*r, kColorBlack);
+	_screen.vLine(r->right, r->top + 3, r->bottom + 1, kColorBlack);
+	_screen.vLine(r->right + 1, r->top + 3, r->bottom + 1, kColorBlack);
+	_screen.hLine(r->left + 3, r->bottom, r->right + 1, kColorBlack);
+	_screen.hLine(r->left + 3, r->bottom + 1, r->right + 1, kColorBlack);
 
 	int x = r->left + kMenuDropdownPadding;
 	int y = r->top + 1;
@@ -357,7 +369,7 @@ void Menu::renderSubmenu(MenuItem *menu) {
 			color = kColorWhite;
 			Common::Rect trect(r->left, y - (_wm->hasBuiltInFonts() ? 1 : 0), r->right, y + _font->getFontHeight());
 
-			Design::drawFilledRect(&_screen, trect, kColorBlack, _wm->getPatterns(), kPatternSolid);
+			_screen.fillRect(trect, kColorBlack);
 		}
 
 		if (!text.empty()) {
@@ -394,13 +406,17 @@ void Menu::renderSubmenu(MenuItem *menu) {
 				}
 			}
 		} else { // Delimiter
-			Design::drawHLine(&_screen, r->left + 1, r->right - 1, y + kMenuDropdownItemHeight / 2, 1, kColorBlack, _wm->getPatterns(), kPatternStripes);
+			bool flip = r->left & 2;
+			for (int xx = r->left + 1; xx <= r->right - 1; xx++) {
+				drawPixelPlain(xx, y + kMenuDropdownItemHeight / 2, (flip ? kColorBlack : kColorWhite), &_screen);
+				flip = !flip;
+			}
 		}
 
 		y += kMenuDropdownItemHeight;
 	}
 
-	g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 3, r->height() + 3);
+	g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
 }
 
 bool Menu::processEvent(Common::Event &event) {
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 79a90d0..7ff0f57 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -50,6 +50,7 @@
 #include "common/events.h"
 
 #include "wage/macwindow.h"
+#include "wage/macwindowmanager.h"
 
 namespace Wage {
 
@@ -201,11 +202,11 @@ void MacWindow::drawBorder() {
 	drawBox(g, x + width - size + 1, y + size,              size - 4,             height - 2 * size - 1);
 
 	if (active) {
-		fillRect(g, x + size, y + 5,           width - 2 * size - 1, 8);
-		fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8);
-		fillRect(g, x + 5,    y + size,        8,                    height - 2 * size - 1);
+		fillRect(g, x + size, y + 5,           width - 2 * size - 1, 8, kColorBlack);
+		fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8, kColorBlack);
+		fillRect(g, x + 5,    y + size,        8,                    height - 2 * size - 1, kColorBlack);
 		if (!scrollable) {
-			fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1);
+			fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1, kColorBlack);
 		} else {
 			int x1 = x + width - 15;
 			int y1 = y + size + 1;
@@ -215,7 +216,7 @@ void MacWindow::drawBorder() {
 					g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[yy][xx] != 0 ? kColorBlack : kColorWhite));
 			}
 
-			fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2);
+			fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2, kColorBlack);
 
 			y1 += height - 2 * size - ARROW_H - 2;
 			for (int yy = 0; yy < ARROW_H; yy++) {
@@ -235,7 +236,7 @@ void MacWindow::drawBorder() {
 		}
 		if (closeable) {
 			if (_highlightedPart == kBorderCloseButton) {
-				fillRect(g, x + 6, y + 6, 6, 6);
+				fillRect(g, x + 6, y + 6, 6, 6, kColorBlack);
 			} else {
 				drawBox(g, x + 5, y + 5, 7, 7);
 			}
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 157a62b..4c6e9ef 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -50,8 +50,6 @@
 
 #include "graphics/managed_surface.h"
 
-#include "wage/macwindowmanager.h"
-
 namespace Wage {
 
 class MacWindowManager;
@@ -134,7 +132,7 @@ public:
 private:
 	void drawBorder();
 	void drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h);
-	void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color = kColorBlack);
+	void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color);
 	const Graphics::Font *getTitleFont();
 	void updateInnerDims();
 	WindowClick isInBorder(int x, int y);


Commit: 8b41a507664eb077cdc233dfe1d6a31aa5ab8de3
    https://github.com/scummvm/scummvm/commit/8b41a507664eb077cdc233dfe1d6a31aa5ab8de3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T16:45:07+02:00

Commit Message:
WAGE: Compose MacMenu instead of screen copying.

This completes making Mac* classes engine-agnostic.

Changed paths:
    engines/wage/gui.cpp
    engines/wage/macmenu.cpp
    engines/wage/macmenu.h
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h



diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 0ddae88..310e573 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -143,7 +143,7 @@ Gui::Gui(WageEngine *engine) {
 
 	g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 200000, this, "wageCursor");
 
-	_menu = _wm.addMenu(this);
+	_menu = _wm.addMenu();
 
 	_menu->setCommandsCallback(menuCommandsCallback, this);
 
diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index 19deffd..bed9dd4 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -49,9 +49,10 @@
 #include "common/keyboard.h"
 
 #include "graphics/primitives.h"
+#include "graphics/font.h"
 
-#include "wage/gui.h"
 #include "wage/macwindowmanager.h"
+#include "wage/macwindow.h"
 #include "wage/macmenu.h"
 
 namespace Wage {
@@ -88,8 +89,8 @@ struct MenuItem {
 	MenuItem(const char *n) : name(n) {}
 };
 
-Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
-		: BaseMacWindow(id, false, wm), _gui(gui) {
+Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm)
+		: BaseMacWindow(id, false, wm) {
 	_font = getMenuFont();
 
 	_screen.create(bounds.width(), bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
@@ -103,7 +104,6 @@ Menu::Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui)
 	_activeItem = -1;
 	_activeSubItem = -1;
 
-	_screenCopy.create(_screen.w, _screen.h, Graphics::PixelFormat::createFormatCLUT8());
 	_tempSurface.create(_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8());
 }
 
@@ -307,10 +307,12 @@ static void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect
 bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 	Common::Rect r(_bbox);
 
-	if (!_contentIsDirty)
+	if (!_contentIsDirty && !forceRedraw)
 		return false;
 
-	_contentIsDirty = true;
+	_contentIsDirty = false;
+
+	_screen.clear(kColorGreen);
 
 	drawFilledRoundRect(&_screen, r, kDesktopArc, kColorWhite);
 	r.top = 7;
@@ -339,7 +341,9 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 		_font->drawString(&_screen, it->name, it->bbox.left + kMenuLeftMargin, it->bbox.top + (_wm->hasBuiltInFonts() ? 2 : 1), it->bbox.width(), color);
 	}
 
-	g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, kMenuHeight);
+	g->transBlitFrom(_screen, kColorGreen);
+
+	g_system->copyRectToScreen(g->getPixels(), g->pitch, 0, 0, g->w, g->h);
 
 	return true;
 }
@@ -416,7 +420,8 @@ void Menu::renderSubmenu(MenuItem *menu) {
 		y += kMenuDropdownItemHeight;
 	}
 
-	g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
+	_contentIsDirty = true;
+	//g_system->copyRectToScreen(_screen.getBasePtr(r->left, r->top), _screen.pitch, r->left, r->top, r->width() + 2, r->height() + 2);
 }
 
 bool Menu::processEvent(Common::Event &event) {
@@ -449,9 +454,6 @@ bool Menu::keyEvent(Common::Event &event) {
 
 bool Menu::mouseClick(int x, int y) {
 	if (_bbox.contains(x, y)) {
-		if (!_menuActivated)
-			_screenCopy.copyFrom(_gui->_screen);
-
 		for (uint i = 0; i < _items.size(); i++)
 			if (_items[i]->bbox.contains(x, y)) {
 			  if ((uint)_activeItem == i)
@@ -462,14 +464,15 @@ bool Menu::mouseClick(int x, int y) {
 					r.right += 3;
 					r.bottom += 3;
 
-					_screen.copyRectToSurface(_screenCopy, r.left, r.top, r);
-					g_system->copyRectToScreen(_screen.getBasePtr(r.left, r.top), _screen.pitch, r.left, r.top, r.width(), r.height());
+					_wm->setFullRefresh(true);
 				}
 
 				_activeItem = i;
 				_activeSubItem = -1;
 				_menuActivated = true;
 
+				_contentIsDirty = true;
+
 				return true;
 			}
 	} else if (_menuActivated && _items[_activeItem]->subbbox.contains(x, y)) {
@@ -480,11 +483,13 @@ bool Menu::mouseClick(int x, int y) {
 			_activeSubItem = numSubItem;
 
 			renderSubmenu(_items[_activeItem]);
+			_contentIsDirty = true;
 		}
 	} else if (_menuActivated && _activeItem != -1) {
 		_activeSubItem = -1;
 
 		renderSubmenu(_items[_activeItem]);
+		_contentIsDirty = true;
 	}
 
 	return false;
diff --git a/engines/wage/macmenu.h b/engines/wage/macmenu.h
index 929ce76..e73e4c4 100644
--- a/engines/wage/macmenu.h
+++ b/engines/wage/macmenu.h
@@ -101,7 +101,7 @@ struct MenuData {
 
 class Menu : public BaseMacWindow {
 public:
-	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm, Gui *gui);
+	Menu(int id, const Common::Rect &bounds, MacWindowManager *wm);
 	~Menu();
 
 	void setCommandsCallback(void (*callback)(int, Common::String &, void *), void *data) { _ccallback = callback; _cdata = data; }
@@ -126,9 +126,7 @@ public:
 	Common::Rect _bbox;
 
 private:
-	Gui *_gui;
 	Graphics::ManagedSurface _screen;
-	Graphics::ManagedSurface _screenCopy;
 	Graphics::ManagedSurface _tempSurface;
 
 private:
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 9913a36..3bebd86 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -157,8 +157,8 @@ MacWindow *MacWindowManager::addWindow(bool scrollable, bool resizable, bool edi
     return w;
 }
 
-Menu *MacWindowManager::addMenu(Gui *g) {
-	_menu = new Menu(_lastId, _screen->getBounds(), this, g);
+Menu *MacWindowManager::addMenu() {
+	_menu = new Menu(_lastId, _screen->getBounds(), this);
 
 	_windows.push_back(_menu);
 
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 53db0d6..2d03c9b 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -61,8 +61,6 @@ class ManagedSurface;
 
 namespace Wage {
 
-class Gui; // FIXME
-
 enum {
 	kDesktopArc = 7
 };
@@ -98,7 +96,7 @@ public:
 	const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
 
 	MacWindow *addWindow(bool scrollable, bool resizable, bool editable);
-	Menu *addMenu(Gui *gui);
+	Menu *addMenu();
 	void setActive(int id);
 
 	void setFullRefresh(bool redraw) { _fullRefresh = true; }


Commit: 7fd850c745fef7a222a1af9242799e8c11b4765c
    https://github.com/scummvm/scummvm/commit/7fd850c745fef7a222a1af9242799e8c11b4765c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T17:14:13+02:00

Commit Message:
WAGE: Remove yet another indirect reference to WAGE engine in WM

Changed paths:
    engines/wage/macmenu.cpp
    engines/wage/macwindowmanager.cpp
    engines/wage/macwindowmanager.h



diff --git a/engines/wage/macmenu.cpp b/engines/wage/macmenu.cpp
index bed9dd4..a97e442 100644
--- a/engines/wage/macmenu.cpp
+++ b/engines/wage/macmenu.cpp
@@ -318,6 +318,9 @@ bool Menu::draw(Graphics::ManagedSurface *g, bool forceRedraw) {
 	r.top = 7;
 	_screen.fillRect(r, kColorWhite);
 	r.top = kMenuHeight - 1;
+	r.bottom++;
+	_screen.fillRect(r, kColorGreen);
+	r.bottom--;
 	_screen.fillRect(r, kColorBlack);
 
 	for (uint i = 0; i < _items.size(); i++) {
@@ -411,8 +414,9 @@ void Menu::renderSubmenu(MenuItem *menu) {
 			}
 		} else { // Delimiter
 			bool flip = r->left & 2;
-			for (int xx = r->left + 1; xx <= r->right - 1; xx++) {
-				drawPixelPlain(xx, y + kMenuDropdownItemHeight / 2, (flip ? kColorBlack : kColorWhite), &_screen);
+			byte *ptr = (byte *)_screen.getBasePtr(r->left + 1, y + kMenuDropdownItemHeight / 2);
+			for (int xx = r->left + 1; xx <= r->right - 1; xx++, ptr++) {
+				*ptr = flip ? kColorBlack : kColorWhite;
 				flip = !flip;
 			}
 		}
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 3bebd86..5cc54d6 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -50,13 +50,14 @@
 #include "common/list.h"
 #include "common/unzip.h"
 #include "common/system.h"
+#include "common/stream.h"
 
 #include "graphics/cursorman.h"
 #include "graphics/fonts/bdf.h"
 #include "graphics/managed_surface.h"
 #include "graphics/palette.h"
+#include "graphics/primitives.h"
 
-#include "wage/design.h"
 #include "wage/macwindowmanager.h"
 #include "wage/macwindow.h"
 #include "wage/macmenu.h"
@@ -184,10 +185,58 @@ void MacWindowManager::setActive(int id) {
     _fullRefresh = true;
 }
 
+struct PlotData {
+	Graphics::ManagedSurface *surface;
+	Patterns *patterns;
+	uint fillType;
+	int thickness;
+
+	PlotData(Graphics::ManagedSurface *s, Patterns *p, int f, int t) :
+		surface(s), patterns(p), fillType(f), thickness(t) {}
+};
+
+static void drawPixel(int x, int y, int color, void *data) {
+	PlotData *p = (PlotData *)data;
+
+	if (p->fillType > p->patterns->size())
+		return;
+
+	byte *pat = p->patterns->operator[](p->fillType - 1);
+
+	if (p->thickness == 1) {
+		if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+			uint xu = (uint)x; // for letting compiler optimize it
+			uint yu = (uint)y;
+
+			*((byte *)p->surface->getBasePtr(xu, yu)) =
+				(pat[yu % 8] & (1 << (7 - xu % 8))) ?
+					color : kColorWhite;
+		}
+	} else {
+		int x1 = x;
+		int x2 = x1 + p->thickness;
+		int y1 = y;
+		int y2 = y1 + p->thickness;
+
+		for (y = y1; y < y2; y++)
+			for (x = x1; x < x2; x++)
+				if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) {
+					uint xu = (uint)x; // for letting compiler optimize it
+					uint yu = (uint)y;
+					*((byte *)p->surface->getBasePtr(xu, yu)) =
+						(pat[yu % 8] & (1 << (7 - xu % 8))) ?
+							color : kColorWhite;
+				}
+	}
+}
+
 void MacWindowManager::drawDesktop() {
 	Common::Rect r(_screen->getBounds());
 
-	Design::drawFilledRoundRect(_screen, r, kDesktopArc, kColorBlack, _patterns, kPatternCheckers);
+	PlotData pd(_screen, &_patterns, kPatternCheckers, 1);
+
+	Graphics::drawRoundRect(r, kDesktopArc, kColorBlack, true, drawPixel, &pd);
+
 	g_system->copyRectToScreen(_screen->getPixels(), _screen->pitch, 0, 0, _screen->w, _screen->h);
 }
 
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index 2d03c9b..13f85cd 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -108,6 +108,7 @@ public:
 	BaseMacWindow *getWindow(int id) { return _windows[id]; }
 
 	Patterns &getPatterns() { return _patterns; }
+	void drawFilledRoundRect(Graphics::ManagedSurface *surface, Common::Rect &rect, int arc, int color);
 
 	void pushArrowCursor();
 	void popCursor();


Commit: 5f301b24002fffb3e8e05061a92ae2e0ee3a92ec
    https://github.com/scummvm/scummvm/commit/5f301b24002fffb3e8e05061a92ae2e0ee3a92ec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-28T19:01:49+02:00

Commit Message:
SCUMM HE: Stubs for moonbase logic ops

Changed paths:
    engines/scumm/he/logic/moonbase.cpp



diff --git a/engines/scumm/he/logic/moonbase.cpp b/engines/scumm/he/logic/moonbase.cpp
index 29a0dde..3fcf30d 100644
--- a/engines/scumm/he/logic/moonbase.cpp
+++ b/engines/scumm/he/logic/moonbase.cpp
@@ -34,6 +34,22 @@ public:
 	LogicHEmoonbase(ScummEngine_v90he *vm) : LogicHE(vm) {}
 
 	int versionID();
+
+	int32 dispatch(int op, int numArgs, int32 *args);
+
+private:
+	void op_create_multi_state_wiz(int op, int numArgs, int32 *args);
+	void op_load_multi_channel_wiz(int op, int numArgs, int32 *args);
+	void op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *args);
+	void op_dos_command(int op, int numArgs, int32 *args);
+	void op_set_fow_sentinel(int op, int numArgs, int32 *args);
+	void op_set_fow_information(int op, int numArgs, int32 *args);
+	void op_set_fow_image(int op, int numArgs, int32 *args);
+	void op_ai_test_kludge(int op, int numArgs, int32 *args);
+	void op_ai_master_control_program(int op, int numArgs, int32 *args);
+	void op_ai_reset(int op, int numArgs, int32 *args);
+	void op_ai_set_type(int op, int numArgs, int32 *args);
+	void op_ai_clean_up(int op, int numArgs, int32 *args);
 };
 
 int LogicHEmoonbase::versionID() {
@@ -45,6 +61,127 @@ int LogicHEmoonbase::versionID() {
 		return 100;
 }
 
+#define OP_CREATE_MULTI_STATE_WIZ		100
+#define OP_LOAD_MULTI_CHANNEL_WIZ		101
+#define OP_WIZ_FROM_MULTI_CHANNEL_WIZ	102
+#define OP_DOS_COMMAND					103
+#define OP_SET_FOW_SENTINEL				104
+#define OP_SET_FOW_INFORMATION			105
+#define OP_SET_FOW_IMAGE				106
+
+#define OP_AI_TEST_KLUDGE				10000
+#define OP_AI_MASTER_CONTROL_PROGRAM	10001
+#define OP_AI_RESET						10002
+#define OP_AI_SET_TYPE					10003
+#define OP_AI_CLEAN_UP					10004
+
+int32 LogicHEmoonbase::dispatch(int op, int numArgs, int32 *args) {
+	switch (op) {
+	case OP_CREATE_MULTI_STATE_WIZ:
+		op_create_multi_state_wiz(op, numArgs, args);
+		break;
+	case OP_LOAD_MULTI_CHANNEL_WIZ:
+		op_load_multi_channel_wiz(op, numArgs, args);
+		break;
+	case OP_WIZ_FROM_MULTI_CHANNEL_WIZ:
+		op_wiz_from_multi_channel_wiz(op, numArgs, args);
+		break;
+	case OP_DOS_COMMAND:
+		op_dos_command(op, numArgs, args);
+		break;
+	case OP_SET_FOW_SENTINEL:
+		op_set_fow_sentinel(op, numArgs, args);
+		break;
+	case OP_SET_FOW_INFORMATION:
+		op_set_fow_information(op, numArgs, args);
+		break;
+	case OP_SET_FOW_IMAGE:
+		op_set_fow_image(op, numArgs, args);
+		break;
+
+	case OP_AI_TEST_KLUDGE:
+		op_ai_test_kludge(op, numArgs, args);
+		break;
+	case OP_AI_MASTER_CONTROL_PROGRAM:
+		op_ai_master_control_program(op, numArgs, args);
+		break;
+	case OP_AI_RESET:
+		op_ai_reset(op, numArgs, args);
+		break;
+	case OP_AI_SET_TYPE:
+		op_ai_set_type(op, numArgs, args);
+		break;
+	case OP_AI_CLEAN_UP:
+		op_ai_clean_up(op, numArgs, args);
+		break;
+
+	default:
+		LogicHE::dispatch(op, numArgs, args);
+	}
+
+	return 0;
+}
+
+void LogicHEmoonbase::op_create_multi_state_wiz(int op, int numArgs, int32 *args) {
+	warning("STUB: op_create_multi_state_wiz()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_load_multi_channel_wiz(int op, int numArgs, int32 *args) {
+	warning("STUB: op_load_multi_channel_wiz()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_wiz_from_multi_channel_wiz(int op, int numArgs, int32 *args) {
+	warning("STUB: op_wiz_from_multi_channel_wiz()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_dos_command(int op, int numArgs, int32 *args) {
+	warning("STUB: op_dos_command()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_set_fow_sentinel(int op, int numArgs, int32 *args) {
+	warning("STUB: op_set_fow_sentinel()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_set_fow_information(int op, int numArgs, int32 *args) {
+	warning("STUB: op_set_fow_information()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_set_fow_image(int op, int numArgs, int32 *args) {
+	warning("STUB: op_set_fow_image()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_ai_test_kludge(int op, int numArgs, int32 *args) {
+	warning("STUB: op_ai_test_kludge()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_ai_master_control_program(int op, int numArgs, int32 *args) {
+	warning("STUB: op_ai_master_control_program()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_ai_reset(int op, int numArgs, int32 *args) {
+	warning("STUB: op_ai_reset)");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_ai_set_type(int op, int numArgs, int32 *args) {
+	warning("STUB: op_ai_set_type()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
+void LogicHEmoonbase::op_ai_clean_up(int op, int numArgs, int32 *args) {
+	warning("STUB: op_ai_clean_up()");
+	LogicHE::dispatch(op, numArgs, args);
+}
+
 LogicHE *makeLogicHEmoonbase(ScummEngine_v90he *vm) {
 	return new LogicHEmoonbase(vm);
 }






More information about the Scummvm-git-logs mailing list