2016-06-08 17:13:02 +02:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
#include "common/file.h"
|
|
|
|
#include "image/bmp.h"
|
|
|
|
|
2016-06-08 16:07:53 +02:00
|
|
|
#include "macventure/macventure.h"
|
|
|
|
#include "macventure/gui.h"
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
namespace MacVenture {
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
enum MenuAction;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kMenuHighLevel = -1,
|
|
|
|
kMenuAbout = 0,
|
|
|
|
kMenuFile = 1,
|
|
|
|
kMenuEdit = 2,
|
|
|
|
kMenuSpecial = 3
|
|
|
|
};
|
2016-06-08 16:07:53 +02:00
|
|
|
|
|
|
|
static const Graphics::MenuData menuSubItems[] = {
|
2016-06-09 11:31:19 +02:00
|
|
|
{ kMenuHighLevel, "File", 0, 0, false },
|
2016-06-11 23:25:42 +02:00
|
|
|
{ kMenuHighLevel, "Edit", 0, 0, false },
|
2016-06-09 11:31:19 +02:00
|
|
|
{ kMenuHighLevel, "Special", 0, 0, false },
|
|
|
|
{ kMenuHighLevel, "Font", 0, 0, false },
|
|
|
|
{ kMenuHighLevel, "FontSize", 0, 0, false },
|
|
|
|
|
|
|
|
//{ kMenuAbout, "About", kMenuActionAbout, 0, true},
|
|
|
|
|
|
|
|
{ kMenuFile, "New", kMenuActionNew, 0, true },
|
|
|
|
{ kMenuFile, NULL, 0, 0, false },
|
|
|
|
{ kMenuFile, "Open...", kMenuActionOpen, 0, true },
|
|
|
|
{ kMenuFile, "Save", kMenuActionSave, 0, true },
|
|
|
|
{ kMenuFile, "Save as...", kMenuActionSaveAs, 0, true },
|
|
|
|
{ kMenuFile, NULL, 0, 0, false },
|
|
|
|
{ kMenuFile, "Quit", kMenuActionQuit, 0, true },
|
|
|
|
|
|
|
|
{ kMenuEdit, "Undo", kMenuActionUndo, 'Z', true },
|
|
|
|
{ kMenuEdit, NULL, 0, 0, false },
|
|
|
|
{ kMenuEdit, "Cut", kMenuActionCut, 'K', true },
|
|
|
|
{ kMenuEdit, "Copy", kMenuActionCopy, 'C', true },
|
|
|
|
{ kMenuEdit, "Paste", kMenuActionPaste, 'V', true },
|
|
|
|
{ kMenuEdit, "Clear", kMenuActionClear, 'B', true },
|
|
|
|
|
|
|
|
{ kMenuSpecial, "Clean Up", kMenuActionCleanUp, 0, true },
|
|
|
|
{ kMenuSpecial, "Mess Up", kMenuActionMessUp, 0, true },
|
|
|
|
|
|
|
|
{ 0, NULL, 0, 0, false }
|
2016-06-08 16:07:53 +02:00
|
|
|
};
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
bool controlsWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
|
|
|
bool mainGameWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
2016-06-09 11:31:19 +02:00
|
|
|
bool outConsoleWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
2016-06-12 22:27:23 +02:00
|
|
|
bool selfWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
|
|
|
bool exitsWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
|
|
|
bool diplomaWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
|
|
|
bool inventoryWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
void menuCommandsCallback(int action, Common::String &text, void *data);
|
|
|
|
|
2016-06-08 17:13:02 +02:00
|
|
|
Gui::Gui(MacVentureEngine *engine, Common::MacResManager *resman) {
|
2016-06-08 16:07:53 +02:00
|
|
|
_engine = engine;
|
2016-06-08 17:13:02 +02:00
|
|
|
_resourceManager = resman;
|
2016-06-08 11:02:21 +02:00
|
|
|
initGUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
Gui::~Gui() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gui::draw() {
|
2016-06-11 23:57:35 +02:00
|
|
|
|
2016-06-12 22:09:06 +02:00
|
|
|
drawCommandsWindow();
|
2016-06-11 23:57:35 +02:00
|
|
|
|
|
|
|
_wm.draw();
|
2016-06-08 11:02:21 +02:00
|
|
|
}
|
|
|
|
|
2016-06-08 17:13:02 +02:00
|
|
|
bool Gui::processEvent(Common::Event &event) {
|
|
|
|
return _wm.processEvent(event);
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
const WindowData& Gui::getWindowData(WindowReference reference) {
|
|
|
|
assert(_windowData);
|
|
|
|
|
|
|
|
Common::List<WindowData>::const_iterator iter = _windowData->begin();
|
|
|
|
while (iter->refcon != reference && iter != _windowData->end()) {
|
|
|
|
iter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iter->refcon == reference)
|
|
|
|
return *iter;
|
|
|
|
|
|
|
|
error("Could not locate the desired window data");
|
|
|
|
}
|
|
|
|
|
|
|
|
const Graphics::Font& Gui::getCurrentFont() {
|
|
|
|
return *_wm.getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
|
|
|
|
}
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
void Gui::initGUI() {
|
|
|
|
_screen.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
|
|
|
|
_wm.setScreen(&_screen);
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
// Menu
|
2016-06-08 16:07:53 +02:00
|
|
|
_menu = _wm.addMenu();
|
2016-06-08 17:13:02 +02:00
|
|
|
if (!loadMenus())
|
|
|
|
error("Could not load menus");
|
2016-06-09 11:31:19 +02:00
|
|
|
_menu->setCommandsCallback(menuCommandsCallback, this);
|
2016-06-08 16:07:53 +02:00
|
|
|
_menu->calcDimensions();
|
|
|
|
|
2016-06-11 23:25:42 +02:00
|
|
|
if (!loadWindows())
|
|
|
|
error("Could not load windows");
|
|
|
|
|
|
|
|
initWindows();
|
|
|
|
|
|
|
|
if (!loadControls())
|
|
|
|
error("Could not load controls");
|
|
|
|
|
|
|
|
draw();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Gui::initWindows() {
|
|
|
|
|
|
|
|
// Game Controls Window
|
|
|
|
_controlsWindow = _wm.addWindow(false, false, false);
|
|
|
|
_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
|
|
|
|
_controlsWindow->setActive(false);
|
|
|
|
_controlsWindow->setCallback(controlsWindowCallback, this);
|
|
|
|
loadBorder(_controlsWindow, "border_command.bmp", false);
|
2016-06-11 23:57:35 +02:00
|
|
|
loadBorder(_controlsWindow, "border_command.bmp", true);
|
2016-06-11 23:25:42 +02:00
|
|
|
|
2016-06-12 22:09:06 +02:00
|
|
|
// Main Game Window
|
2016-06-12 22:27:23 +02:00
|
|
|
_mainGameWindow = _wm.addWindow(false, false, false);
|
|
|
|
_mainGameWindow->setDimensions(getWindowData(kMainGameWindow).bounds);
|
|
|
|
_mainGameWindow->setActive(false);
|
|
|
|
_mainGameWindow->setCallback(mainGameWindowCallback, this);
|
|
|
|
loadBorder(_mainGameWindow, "border_command.bmp", false);
|
|
|
|
loadBorder(_mainGameWindow, "border_command.bmp", true);
|
2016-06-12 22:09:06 +02:00
|
|
|
|
|
|
|
// In-game Output Console
|
|
|
|
_outConsoleWindow = _wm.addWindow(false, true, true);
|
|
|
|
_outConsoleWindow->setDimensions(Common::Rect(20, 20, 120, 120));
|
|
|
|
_outConsoleWindow->setActive(false);
|
|
|
|
_outConsoleWindow->setCallback(outConsoleWindowCallback, this);
|
|
|
|
loadBorder(_outConsoleWindow, "border_command.bmp", false);
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
// Self Window
|
|
|
|
_selfWindow = _wm.addWindow(false, true, true);
|
|
|
|
_selfWindow->setDimensions(getWindowData(kSelfWindow).bounds);
|
|
|
|
_selfWindow->setActive(false);
|
|
|
|
_selfWindow->setCallback(selfWindowCallback, this);
|
|
|
|
loadBorder(_selfWindow, "border_command.bmp", false);
|
|
|
|
|
|
|
|
// Exits Window
|
|
|
|
_exitsWindow = _wm.addWindow(false, true, true);
|
|
|
|
_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
|
|
|
|
_exitsWindow->setActive(false);
|
|
|
|
_exitsWindow->setCallback(exitsWindowCallback, this);
|
|
|
|
loadBorder(_exitsWindow, "border_command.bmp", false);
|
|
|
|
|
|
|
|
// Diploma Window
|
|
|
|
_diplomaWindow = _wm.addWindow(false, true, true);
|
|
|
|
_diplomaWindow->setDimensions(getWindowData(kDiplomaWindow).bounds);
|
|
|
|
_diplomaWindow->setActive(false);
|
|
|
|
_diplomaWindow->setCallback(diplomaWindowCallback, this);
|
|
|
|
loadBorder(_diplomaWindow, "border_command.bmp", false);
|
|
|
|
// Render invisible for now
|
|
|
|
_diplomaWindow->getSurface()->fillRect(_diplomaWindow->getSurface()->getBounds(), kColorGreen2);
|
|
|
|
|
|
|
|
// Inventory Window
|
|
|
|
_inventoryWindow = _wm.addWindow(false, true, true);
|
|
|
|
_inventoryWindow->setDimensions(getWindowData(kInventoryWindow).bounds);
|
|
|
|
_inventoryWindow->setActive(false);
|
|
|
|
_inventoryWindow->setCallback(inventoryWindowCallback, this);
|
|
|
|
loadBorder(_inventoryWindow, "border_command.bmp", false);
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Gui::loadBorder(Graphics::MacWindow * target, Common::String filename, bool active) {
|
|
|
|
Common::File borderfile;
|
|
|
|
|
|
|
|
if (!borderfile.open(filename)) {
|
|
|
|
debug(1, "Cannot open border file");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Image::BitmapDecoder bmpDecoder;
|
|
|
|
Common::SeekableReadStream *stream = borderfile.readStream(borderfile.size());
|
|
|
|
Graphics::Surface source;
|
|
|
|
Graphics::TransparentSurface *surface = new Graphics::TransparentSurface();
|
|
|
|
|
|
|
|
if (stream) {
|
|
|
|
debug(4, "Loading %s border from %s", (active ? "active" : "inactive"), filename);
|
|
|
|
bmpDecoder.loadStream(*stream);
|
|
|
|
source = *(bmpDecoder.getSurface());
|
|
|
|
|
|
|
|
source.convertToInPlace(surface->getSupportedPixelFormat(), bmpDecoder.getPalette());
|
|
|
|
surface->create(source.w, source.h, source.format);
|
|
|
|
surface->copyFrom(source);
|
|
|
|
surface->applyColorKey(255, 0, 255, false);
|
|
|
|
|
|
|
|
target->setBorder(*surface, active);
|
|
|
|
|
|
|
|
borderfile.close();
|
|
|
|
|
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-08 17:13:02 +02:00
|
|
|
bool Gui::loadMenus() {
|
2016-06-09 11:31:19 +02:00
|
|
|
|
|
|
|
// We assume that, if there are static menus, we don't need dynamic ones
|
|
|
|
if (menuSubItems) {
|
|
|
|
_menu->addStaticMenus(menuSubItems);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-08 17:13:02 +02:00
|
|
|
Common::MacResIDArray resArray;
|
|
|
|
Common::SeekableReadStream *res;
|
|
|
|
Common::MacResIDArray::const_iterator iter;
|
|
|
|
|
|
|
|
if ((resArray = _resourceManager->getResIDArray(MKTAG('M', 'E', 'N', 'U'))).size() == 0)
|
2016-06-11 23:25:42 +02:00
|
|
|
return false;
|
2016-06-08 17:13:02 +02:00
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
_menu->addMenuSubItem(0, "Abb", kMenuActionAbout, 0, 'A', true);
|
2016-06-08 17:13:02 +02:00
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
|
|
|
|
res = _resourceManager->getResource(MKTAG('M', 'E', 'N', 'U'), *iter);
|
2016-06-08 19:02:15 +02:00
|
|
|
bool enabled;
|
|
|
|
uint16 key;
|
2016-06-09 11:31:19 +02:00
|
|
|
uint16 style;
|
2016-06-08 19:02:15 +02:00
|
|
|
uint8 titleLength;
|
|
|
|
char* title;
|
2016-06-08 17:13:02 +02:00
|
|
|
|
|
|
|
int menunum = -1; // High level menus have level -1
|
|
|
|
/* Skip menuID, width, height, resourceID, placeholder */
|
|
|
|
for (int skip = 0; skip < 5; skip++) { res->readUint16BE(); }
|
2016-06-08 19:02:15 +02:00
|
|
|
enabled = res->readUint32BE();
|
|
|
|
titleLength = res->readByte();
|
|
|
|
title = new char[titleLength + 1];
|
2016-06-08 17:13:02 +02:00
|
|
|
res->read(title, titleLength);
|
|
|
|
title[titleLength] = '\0';
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
if (titleLength > 1) {
|
2016-06-08 17:13:02 +02:00
|
|
|
_menu->addMenuItem(title);
|
|
|
|
|
|
|
|
// Read submenu items
|
|
|
|
while (titleLength = res->readByte()) {
|
|
|
|
title = new char[titleLength + 1];
|
|
|
|
res->read(title, titleLength);
|
|
|
|
title[titleLength] = '\0';
|
2016-06-08 19:02:15 +02:00
|
|
|
// Skip icon
|
|
|
|
res->readUint16BE();
|
2016-06-09 11:31:19 +02:00
|
|
|
// Read key
|
2016-06-08 19:02:15 +02:00
|
|
|
key = res->readUint16BE();
|
2016-06-09 11:31:19 +02:00
|
|
|
// Skip mark
|
|
|
|
res->readUint16BE();
|
|
|
|
// Read style
|
|
|
|
style = res->readUint16BE();
|
|
|
|
_menu->addMenuSubItem(i, title, 0, style, key, false);
|
2016-06-08 17:13:02 +02:00
|
|
|
}
|
2016-06-11 23:25:42 +02:00
|
|
|
}
|
2016-06-08 17:13:02 +02:00
|
|
|
|
|
|
|
i++;
|
2016-06-09 11:31:19 +02:00
|
|
|
}
|
2016-06-08 17:13:02 +02:00
|
|
|
|
2016-06-11 23:25:42 +02:00
|
|
|
return true;
|
2016-06-09 11:31:19 +02:00
|
|
|
}
|
|
|
|
|
2016-06-12 20:22:01 +02:00
|
|
|
bool Gui::loadWindows() {
|
|
|
|
Common::MacResIDArray resArray;
|
|
|
|
Common::SeekableReadStream *res;
|
|
|
|
Common::MacResIDArray::const_iterator iter;
|
|
|
|
|
|
|
|
_windowData = new Common::List<WindowData>();
|
|
|
|
|
|
|
|
if ((resArray = _resourceManager->getResIDArray(MKTAG('W', 'I', 'N', 'D'))).size() == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uint32 id = kCommandsWindow;
|
|
|
|
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
|
|
|
|
res = _resourceManager->getResource(MKTAG('W', 'I', 'N', 'D'), *iter);
|
|
|
|
WindowData data;
|
|
|
|
uint16 top, left, bottom, right;
|
|
|
|
uint16 borderSize;
|
|
|
|
top = res->readUint16BE();
|
|
|
|
left = res->readUint16BE();
|
|
|
|
bottom = res->readUint16BE();
|
|
|
|
right = res->readUint16BE();
|
|
|
|
data.type = (MVWindowType)res->readUint16BE();
|
|
|
|
data.bounds = Common::Rect(
|
2016-06-12 22:09:06 +02:00
|
|
|
left - borderThickness(data.type),
|
|
|
|
top - borderThickness(data.type),
|
|
|
|
right + borderThickness(data.type) * 2,
|
|
|
|
bottom + borderThickness(data.type) * 2);
|
2016-06-12 20:22:01 +02:00
|
|
|
data.visible = res->readUint16BE();
|
|
|
|
data.hasCloseBox = res->readUint16BE();
|
|
|
|
data.refcon = (WindowReference)id; id++;
|
|
|
|
res->readUint32BE(); // Skip the true id. For some reason it's reading 0
|
|
|
|
data.titleLength = res->readByte();
|
|
|
|
if (data.titleLength) {
|
|
|
|
data.title = new char[data.titleLength + 1];
|
|
|
|
res->read(data.title, data.titleLength);
|
|
|
|
data.title[data.titleLength] = '\0';
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
debug(5, "Window loaded: %s", data.title);
|
|
|
|
|
2016-06-12 20:22:01 +02:00
|
|
|
_windowData->push_back(data);
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
loadInventoryWindow();
|
|
|
|
|
2016-06-12 20:22:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
void Gui::loadInventoryWindow() {
|
|
|
|
WindowData data;
|
|
|
|
data.bounds = Common::Rect(5, 30, 125, 190);
|
|
|
|
data.title = "Inventory";
|
|
|
|
data.visible = true;
|
|
|
|
data.hasCloseBox = false;
|
|
|
|
data.refcon = kInventoryWindow;
|
|
|
|
data.titleLength = 10;
|
|
|
|
|
|
|
|
_windowData->push_back(data);
|
|
|
|
}
|
|
|
|
|
2016-06-12 20:22:01 +02:00
|
|
|
bool Gui::loadControls() {
|
|
|
|
Common::MacResIDArray resArray;
|
|
|
|
Common::SeekableReadStream *res;
|
|
|
|
Common::MacResIDArray::const_iterator iter;
|
|
|
|
|
|
|
|
_controlData = new Common::List<CommandButton>();
|
|
|
|
|
|
|
|
if ((resArray = _resourceManager->getResIDArray(MKTAG('C', 'N', 'T', 'L'))).size() == 0)
|
|
|
|
return false;
|
|
|
|
|
2016-06-12 22:09:06 +02:00
|
|
|
uint16 commandsBorder = borderThickness(kPlainDBox);
|
2016-06-12 20:22:01 +02:00
|
|
|
uint32 id = kControlExitBox;
|
|
|
|
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
|
|
|
|
res = _resourceManager->getResource(MKTAG('C', 'N', 'T', 'L'), *iter);
|
|
|
|
ControlData data;
|
|
|
|
uint16 top, left, bottom, right;
|
|
|
|
top = res->readUint16BE();
|
|
|
|
left = res->readUint16BE();
|
|
|
|
bottom = res->readUint16BE();
|
|
|
|
right = res->readUint16BE();
|
|
|
|
data.scrollValue = res->readUint16BE();
|
|
|
|
data.visible = res->readByte();
|
|
|
|
res->readByte(); // Unused
|
|
|
|
data.scrollMax = res->readUint16BE();
|
|
|
|
data.scrollMin = res->readUint16BE();
|
|
|
|
data.cdef = res->readUint16BE();
|
|
|
|
data.refcon = (ControlReference)id; id++;
|
|
|
|
res->readUint32BE();
|
|
|
|
data.titleLength = res->readByte();
|
|
|
|
if (data.titleLength) {
|
|
|
|
data.title = new char[data.titleLength + 1];
|
|
|
|
res->read(data.title, data.titleLength);
|
|
|
|
data.title[data.titleLength] = '\0';
|
|
|
|
}
|
2016-06-12 22:09:06 +02:00
|
|
|
if (data.refcon != kControlExitBox)
|
|
|
|
data.border = commandsBorder;
|
|
|
|
|
|
|
|
Common::Rect bounds(left, top, right, bottom); // For some reason, if I remove this it segfaults
|
|
|
|
data.bounds = Common::Rect(left + data.border, top + data.border, right + data.border, bottom + data.border);
|
2016-06-12 20:22:01 +02:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-12 22:09:06 +02:00
|
|
|
void Gui::drawCommandsWindow() {
|
|
|
|
if (_engine->isPaused()) {
|
|
|
|
Graphics::ManagedSurface *srf = _controlsWindow->getSurface();
|
|
|
|
WindowData data = getWindowData(kCommandsWindow);
|
|
|
|
uint16 border = borderThickness(data.type);
|
|
|
|
srf->fillRect(Common::Rect(border * 2, border * 2, srf->w - (border * 3), srf->h - (border * 3)), kColorWhite);
|
|
|
|
getCurrentFont().drawString(
|
|
|
|
srf,
|
|
|
|
_engine->getCommandsPausedString(),
|
|
|
|
0,
|
|
|
|
(srf->h / 2) - getCurrentFont().getFontHeight(),
|
|
|
|
data.bounds.right - data.bounds.left,
|
|
|
|
kColorBlack,
|
|
|
|
Graphics::kTextAlignCenter);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Common::List<CommandButton>::const_iterator it = _controlData->begin();
|
|
|
|
for (; it != _controlData->end(); ++it) {
|
|
|
|
CommandButton button = *it;
|
|
|
|
if (button.getData().refcon != kControlExitBox)
|
|
|
|
button.draw(*_controlsWindow->getSurface());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
/* CALLBACKS */
|
2016-06-12 22:27:23 +02:00
|
|
|
|
|
|
|
bool controlsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
|
|
|
return g->processCommandEvents(click, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool mainGameWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-06-11 23:57:35 +02:00
|
|
|
bool outConsoleWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
2016-06-08 17:13:02 +02:00
|
|
|
return true;
|
2016-06-09 11:31:19 +02:00
|
|
|
}
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
bool selfWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
2016-06-11 23:57:35 +02:00
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
2016-06-12 22:27:23 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool exitsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool diplomaWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool inventoryWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
|
|
|
|
Gui *g = (Gui*)gui;
|
|
|
|
|
|
|
|
return true;
|
2016-06-11 23:57:35 +02:00
|
|
|
}
|
|
|
|
|
2016-06-09 11:31:19 +02:00
|
|
|
void menuCommandsCallback(int action, Common::String &text, void *data) {
|
|
|
|
Gui *g = (Gui *)data;
|
|
|
|
|
|
|
|
g->handleMenuAction((MenuAction)action);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* HANDLERS */
|
|
|
|
void Gui::handleMenuAction(MenuAction action) {
|
|
|
|
switch (action) {
|
|
|
|
case MacVenture::kMenuActionAbout:
|
|
|
|
debug("MacVenture Menu Action: About");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionNew:
|
|
|
|
debug("MacVenture Menu Action: New");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionOpen:
|
|
|
|
debug("MacVenture Menu Action: Open");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionSave:
|
|
|
|
debug("MacVenture Menu Action: Save");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionSaveAs:
|
|
|
|
debug("MacVenture Menu Action: Save As");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionQuit:
|
|
|
|
debug("MacVenture Menu Action: Quit");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionUndo:
|
|
|
|
debug("MacVenture Menu Action: Undo");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionCut:
|
|
|
|
debug("MacVenture Menu Action: Cut");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionCopy:
|
|
|
|
debug("MacVenture Menu Action: Copy");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionPaste:
|
|
|
|
debug("MacVenture Menu Action: Paste");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionClear:
|
|
|
|
debug("MacVenture Menu Action: Clear");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionCleanUp:
|
|
|
|
debug("MacVenture Menu Action: Clean Up");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionMessUp:
|
|
|
|
debug("MacVenture Menu Action: Mess Up");
|
|
|
|
break;
|
|
|
|
case MacVenture::kMenuActionCommand:
|
|
|
|
debug("MacVenture Menu Action: GENERIC");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-06-08 16:07:53 +02:00
|
|
|
}
|
|
|
|
|
2016-06-11 23:57:35 +02:00
|
|
|
|
|
|
|
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
|
|
|
|
if (event.type == Common::EVENT_LBUTTONUP) {
|
2016-06-12 22:09:06 +02:00
|
|
|
if (_engine->isPaused()) {
|
|
|
|
_engine->requestUnpause();
|
|
|
|
} else {
|
|
|
|
Common::Point position(
|
|
|
|
event.mouse.x - _controlsWindow->getDimensions().left,
|
|
|
|
event.mouse.y - _controlsWindow->getDimensions().top);
|
|
|
|
Common::List<CommandButton>::const_iterator it = _controlData->begin();
|
|
|
|
for (; it != _controlData->end(); ++it) {
|
|
|
|
const CommandButton &data = *it;
|
|
|
|
if (data.isInsideBounds(position)) {
|
|
|
|
debug("Command active: %s", data.getData().title);
|
|
|
|
}
|
2016-06-11 23:57:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-12 20:22:01 +02:00
|
|
|
/* Ugly switches */
|
|
|
|
|
|
|
|
uint16 Gui::borderThickness(MVWindowType type) {
|
|
|
|
switch (type) {
|
|
|
|
case MacVenture::kDocument:
|
|
|
|
break;
|
|
|
|
case MacVenture::kDBox:
|
|
|
|
break;
|
|
|
|
case MacVenture::kPlainDBox:
|
|
|
|
return 6;
|
|
|
|
case MacVenture::kAltBox:
|
|
|
|
break;
|
|
|
|
case MacVenture::kNoGrowDoc:
|
|
|
|
break;
|
|
|
|
case MacVenture::kMovableDBox:
|
|
|
|
break;
|
|
|
|
case MacVenture::kZoomDoc:
|
|
|
|
break;
|
|
|
|
case MacVenture::kZoomNoGrow:
|
|
|
|
break;
|
|
|
|
case MacVenture::kRDoc16:
|
|
|
|
break;
|
|
|
|
case MacVenture::kRDoc4:
|
|
|
|
break;
|
|
|
|
case MacVenture::kRDoc6:
|
|
|
|
break;
|
|
|
|
case MacVenture::kRDoc10:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-08 11:02:21 +02:00
|
|
|
} // End of namespace MacVenture
|