scummvm/engines/macventure/gui.cpp

1365 lines
39 KiB
C++
Raw Normal View History

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-07-02 17:11:42 +02:00
#include "common/timer.h"
#include "common/system.h"
2016-06-08 11:02:21 +02:00
namespace MacVenture {
2016-06-09 11:31:19 +02:00
enum MenuAction;
enum {
kCursorWidth = 2, // HACK Arbitrary width to test
kCursorHeight = 2
};
2016-06-25 22:21:26 +02:00
enum {
kExitButtonWidth = 10, // HACK Arbitrary width to test
kExitButtonHeight = 10
};
2016-06-09 11:31:19 +02:00
enum {
kMenuHighLevel = -1,
kMenuAbout = 0,
kMenuFile = 1,
kMenuEdit = 2,
kMenuSpecial = 3
};
2016-06-08 16:07:53 +02:00
2016-07-04 11:45:47 +02:00
enum {
kCommandNum = 8
};
enum {
kDragThreshold = 5
2016-07-04 11:45:47 +02:00
};
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 },
{ 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-07-02 17:11:42 +02:00
static void cursorTimerHandler(void *refCon) {
Gui *gui = (Gui *)refCon;
gui->processCursorTick();
}
2016-06-17 12:44:52 +02:00
bool commandsWindowCallback(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);
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;
_windowData = nullptr;
_controlData = nullptr;
_draggedObj.id = 0;
_draggedObj.pos = Common::Point(0, 0);
2016-07-02 17:11:42 +02:00
_cursor = new Cursor(this);
2016-07-04 11:45:47 +02:00
g_system->getTimerManager()->installTimerProc(&cursorTimerHandler, 500000, this, "macVentureCursor");
_consoleText = new ConsoleText(this);
2016-07-02 17:11:42 +02:00
2016-06-08 11:02:21 +02:00
initGUI();
}
Gui::~Gui() {
if (_windowData)
delete _windowData;
if (_controlData)
delete _controlData;
2016-06-30 08:41:25 +02:00
if (_exitsData)
delete _exitsData;
2016-07-02 17:11:42 +02:00
if (_cursor)
delete _cursor;
2016-07-04 11:45:47 +02:00
if (_consoleText)
delete _consoleText;
Common::HashMap<ObjID, ImageAsset*>::const_iterator it = _assets.begin();
for (; it != _assets.end(); it++) {
delete it->_value;
}
2016-06-08 11:02:21 +02:00
}
2016-06-30 08:41:25 +02:00
void Gui::initGUI() {
_screen.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
_wm.setScreen(&_screen);
// Menu
_menu = _wm.addMenu();
if (!loadMenus())
error("Could not load menus");
_menu->setCommandsCallback(menuCommandsCallback, this);
_menu->calcDimensions();
loadGraphics();
if (!loadWindows())
error("Could not load windows");
initWindows();
assignObjReferences();
if (!loadControls())
error("Could not load controls");
draw();
}
2016-06-08 11:02:21 +02:00
void Gui::draw() {
2016-06-11 23:57:35 +02:00
// Will be performance-improved after the milestone
_wm.setFullRefresh(true);
drawWindows();
2016-06-22 21:48:14 +02:00
_wm.draw();
drawDraggedObject();
//drawWindowTitle(kMainGameWindow, _mainGameWindow->getSurface());
2016-06-08 11:02:21 +02:00
}
2016-06-20 08:59:53 +02:00
void Gui::drawMenu() {
_menu->draw(&_screen);
}
void Gui::drawTitle() {
warning("drawTitle hasn't been tested yet");
}
void Gui::clearControls() {
if (!_controlData)
return;
2016-06-30 08:41:25 +02:00
Common::Array<CommandButton>::iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
it->unselect();
}
}
void Gui::initWindows() {
// Game Controls Window
_controlsWindow = _wm.addWindow(false, false, false);
_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
_controlsWindow->setActive(false);
_controlsWindow->setCallback(commandsWindowCallback, this);
loadBorder(_controlsWindow, "border_command.bmp", false);
loadBorder(_controlsWindow, "border_command.bmp", true);
// Main Game Window
_mainGameWindow = _wm.addWindow(false, false, false);
_mainGameWindow->setDimensions(getWindowData(kMainGameWindow).bounds);
_mainGameWindow->setActive(false);
_mainGameWindow->setCallback(mainGameWindowCallback, this);
loadBorder(_mainGameWindow, "border_no_scroll_inac.bmp", false);
loadBorder(_mainGameWindow, "border_no_scroll_act.bmp", true);
// In-game Output Console
_outConsoleWindow = _wm.addWindow(false, true, true);
_outConsoleWindow->setDimensions(getWindowData(kOutConsoleWindow).bounds);
_outConsoleWindow->setActive(false);
_outConsoleWindow->setCallback(outConsoleWindowCallback, this);
loadBorder(_outConsoleWindow, "border_left_scroll_inac.bmp", false);
loadBorder(_outConsoleWindow, "border_left_scroll_inac.bmp", true);
// Self Window
_selfWindow = _wm.addWindow(false, true, false);
_selfWindow->setDimensions(getWindowData(kSelfWindow).bounds);
_selfWindow->setActive(false);
_selfWindow->setCallback(selfWindowCallback, this);
loadBorder(_selfWindow, "border_none.bmp", false);
loadBorder(_selfWindow, "border_none.bmp", true);
// Exits Window
_exitsWindow = _wm.addWindow(false, false, false);
_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
_exitsWindow->setActive(false);
_exitsWindow->setCallback(exitsWindowCallback, this);
loadBorder(_exitsWindow, "border_no_scroll_inac.bmp", false);
loadBorder(_exitsWindow, "border_no_scroll_act.bmp", true);
}
const WindowData& Gui::getWindowData(WindowReference reference) {
return findWindowData(reference);
}
const Graphics::Font& Gui::getCurrentFont() {
return *_wm.getFont("Chicago-12", Graphics::FontManager::kBigGUIFont);
}
void Gui::bringToFront(WindowReference winID) {
// FIXME: There has to be a better way to do this, maybe with the _wm
switch (winID) {
case MacVenture::kCommandsWindow:
_controlsWindow->setActive(true);
break;
case MacVenture::kMainGameWindow:
_mainGameWindow->setActive(true);
break;
case MacVenture::kOutConsoleWindow:
_outConsoleWindow->setActive(true);
break;
case MacVenture::kSelfWindow:
_selfWindow->setActive(true);
break;
case MacVenture::kExitsWindow:
_exitsWindow->setActive(true);
break;
case MacVenture::kDiplomaWindow:
_diplomaWindow->setActive(true);
break;
default:
break;
}
}
void Gui::setWindowTitle(WindowReference winID, Common::String string) {
findWindowData(winID).title = string;
findWindowData(winID).titleLength = string.size();
}
void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array<ObjID> &children) {
if (ref == kNoWindow) return;
WindowData &data = findWindowData(ref);
data.children.clear();
2016-06-25 17:38:15 +02:00
data.objRef = objID;
uint32 originx = 0x7fff;
uint32 originy = 0x7fff;
for (uint i = 0; i < children.size(); i++) {
if (children[i] != 1) {
ObjID child = children[i];
if (ref != kMainGameWindow) {
Common::Point childPos = _engine->getObjPosition(child);
originx = originx > (uint)childPos.x ? (uint)childPos.x : originx;
originy = originy > (uint)childPos.y ? (uint)childPos.y : originy;
}
2016-06-22 21:48:14 +02:00
data.children.push_back(DrawableObject(child, kBlitBIC));
}
}
if (originx != 0x7fff) data.bounds.left = originx;
if (originy != 0x7fff) data.bounds.top = originy;
if (ref != kMainGameWindow) data.updateScroll = true;
}
void Gui::addChild(WindowReference target, ObjID child) {
2016-06-22 21:48:14 +02:00
findWindowData(target).children.push_back(DrawableObject(child, kBlitBIC));
}
void Gui::removeChild(WindowReference target, ObjID child) {
WindowData &data = findWindowData(target);
uint index = 0;
for (;index < data.children.size(); index++) {
if (data.children[index].obj == child) break;
}
2016-06-25 22:21:26 +02:00
if (index < data.children.size())
data.children.remove_at(index);
}
2016-06-25 17:38:15 +02:00
void Gui::assignObjReferences() {
findWindowData(kSelfWindow).objRef = 0;
}
2016-06-24 21:00:06 +02:00
WindowReference Gui::createInventoryWindow(ObjID objRef) {
Graphics::MacWindow *newWindow = _wm.addWindow(true, true, true);
WindowData newData;
GlobalSettings settings = _engine->getGlobalSettings();
newData.refcon = (WindowReference)ABS(_inventoryWindows.size() + kInventoryStart); // This is a HACK
if (_windowData->back().refcon < 0x80) { // There is already another inventory window
newData.bounds = _windowData->back().bounds; // Inventory windows are always last
newData.bounds.translate(newData.bounds.left + settings.invOffsetX, newData.bounds.top + settings.invOffsetY);
}
else {
newData.bounds = Common::Rect(
settings.invLeft,
settings.invTop,
settings.invLeft + settings.invWidth,
settings.invTop + settings.invHeight);
}
newData.type = kZoomDoc;
newData.hasCloseBox = true;
newData.visible = true;
2016-06-24 21:00:06 +02:00
newData.objRef = objRef;
_windowData->push_back(newData);
newWindow->setDimensions(newData.bounds);
newWindow->setCallback(inventoryWindowCallback, this);
2016-06-25 22:21:26 +02:00
loadBorder(newWindow, "border_no_scroll_inac.bmp", false);
loadBorder(newWindow, "border_no_scroll_act.bmp", true);
_inventoryWindows.push_back(newWindow);
debug("Create new inventory window. Reference: %d", newData.refcon);
return newData.refcon;
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) {
2016-06-25 22:21:26 +02:00
debug(4, "Loading %s border from %s", (active ? "active" : "inactive"), filename.c_str());
target->loadBorder(*stream, active);
2016-06-08 11:02:21 +02:00
delete stream;
}
2016-06-25 22:21:26 +02:00
borderfile.close();
2016-06-08 11:02:21 +02:00
}
2016-06-21 13:22:56 +02:00
void Gui::loadGraphics() {
_graphics = new Container(_engine->getFilePath(kGraphicPathID).c_str());
2016-06-21 13:22:56 +02:00
}
2016-06-08 17:13:02 +02:00
bool Gui::loadMenus() {
2016-06-09 11:31:19 +02:00
if (kLoadStaticMenus) {
// We assume that, if there are static menus, we don't need dynamic ones
2016-06-09 11:31:19 +02:00
_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)
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
/* 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-08 17:13:02 +02:00
i++;
2016-06-09 11:31:19 +02:00
}
2016-06-08 17:13:02 +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;
2016-06-12 20:22:01 +02:00
top = res->readUint16BE();
left = res->readUint16BE();
bottom = res->readUint16BE();
right = res->readUint16BE();
data.type = (MVWindowType)res->readUint16BE();
data.bounds = Common::Rect(
left - borderBounds(data.type).leftOffset,
top - borderBounds(data.type).topOffset,
right + borderBounds(data.type).rightOffset * 2,
bottom + borderBounds(data.type).bottomOffset * 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) {
char* newTitle = new char[data.titleLength + 1];
res->read(newTitle, data.titleLength);
newTitle[data.titleLength] = '\0';
data.title = Common::String(newTitle);
2016-06-12 20:22:01 +02:00
}
debug(4, "Window loaded: %s", data.title);
2016-06-12 20:22:01 +02:00
_windowData->push_back(data);
}
return true;
}
bool Gui::loadControls() {
Common::MacResIDArray resArray;
Common::SeekableReadStream *res;
Common::MacResIDArray::const_iterator iter;
2016-06-30 08:41:25 +02:00
_controlData = new Common::Array<CommandButton>();
_exitsData = new Common::Array<CommandButton>();
2016-06-12 20:22:01 +02:00
if ((resArray = _resourceManager->getResIDArray(MKTAG('C', 'N', 'T', 'L'))).size() == 0)
return false;
uint16 commandsBorder = borderBounds(kPlainDBox).topOffset;
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();
2016-07-05 13:06:51 +02:00
data.refcon = (ControlAction)res->readUint32BE();//(ControlType)id; id++;
data.type = (ControlType)id; id++;
2016-06-12 20:22:01 +02:00
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-07-05 13:06:51 +02:00
if (data.type != kControlExitBox)
2016-06-12 22:09:06 +02:00
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-13 00:36:24 +02:00
void Gui::drawWindows() {
drawCommandsWindow();
drawMainGameWindow();
drawSelfWindow();
drawInventories();
drawExitsWindow();
2016-07-04 11:45:47 +02:00
drawConsoleWindow();
2016-06-13 00:36:24 +02:00
}
2016-06-12 22:09:06 +02:00
void Gui::drawCommandsWindow() {
if (_engine->needsClickToContinue()) {
2016-06-12 22:09:06 +02:00
Graphics::ManagedSurface *srf = _controlsWindow->getSurface();
WindowData data = getWindowData(kCommandsWindow);
uint16 border = borderBounds(data.type).topOffset;
2016-06-12 22:09:06 +02:00
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 {
2016-06-30 08:41:25 +02:00
Common::Array<CommandButton>::const_iterator it = _controlData->begin();
2016-06-12 22:09:06 +02:00
for (; it != _controlData->end(); ++it) {
CommandButton button = *it;
2016-07-05 13:06:51 +02:00
if (button.getData().type != kControlExitBox)
2016-06-12 22:09:06 +02:00
button.draw(*_controlsWindow->getSurface());
}
}
}
2016-06-13 00:36:24 +02:00
void Gui::drawMainGameWindow() {
const WindowData &data = getWindowData(kMainGameWindow);
BorderBounds border = borderBounds(data.type);
2016-06-30 08:41:25 +02:00
ObjID objRef = data.objRef;
_mainGameWindow->setDirty(true);
2016-06-30 08:41:25 +02:00
if (data.objRef > 0 && data.objRef < 2000) {
if (!_assets.contains(objRef)) {
_assets[objRef] = new ImageAsset(objRef, _graphics);
}
2016-06-22 21:48:14 +02:00
2016-06-30 08:41:25 +02:00
_assets[objRef]->blitInto(
_mainGameWindow->getSurface(),
border.leftOffset,
border.topOffset,
kBlitDirect);
}
drawObjectsInWindow(kMainGameWindow, _mainGameWindow->getSurface());
2016-06-25 22:21:26 +02:00
findWindow(kMainGameWindow)->setDirty(true);
2016-06-13 00:36:24 +02:00
}
void Gui::drawSelfWindow() {
drawObjectsInWindow(kSelfWindow, _selfWindow->getSurface());
if (_engine->isObjSelected(1)) invertWindowColors(kSelfWindow);
2016-06-25 22:21:26 +02:00
findWindow(kSelfWindow)->setDirty(true);
}
void Gui::drawInventories() {
Graphics::ManagedSurface *srf;
for (uint i = 0; i < _inventoryWindows.size(); i++) {
const WindowData &data = getWindowData((WindowReference)(kInventoryStart + i));
srf = findWindow(data.refcon)->getSurface(); // HACK
BorderBounds border = borderBounds(data.type);
srf->fillRect(Common::Rect(
border.leftOffset,
border.topOffset,
srf->w + border.rightOffset,
srf->h + border.bottomOffset), kColorWhite);
drawObjectsInWindow(data.refcon, srf);
2016-06-25 22:21:26 +02:00
findWindow(data.refcon)->setDirty(true);
}
2016-06-25 22:21:26 +02:00
}
void Gui::drawExitsWindow() {
2016-06-30 08:41:25 +02:00
Graphics::ManagedSurface *srf = _exitsWindow->getSurface();
2016-06-30 08:41:25 +02:00
BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
srf->fillRect(Common::Rect(
border.leftOffset,
border.topOffset,
srf->w + border.rightOffset,
srf->h + border.bottomOffset), kColorWhite);
2016-06-30 08:41:25 +02:00
Common::Array<CommandButton>::const_iterator it = _exitsData->begin();
for (; it != _exitsData->end(); ++it) {
CommandButton button = *it;
button.draw(*_exitsWindow->getSurface());
2016-06-25 22:21:26 +02:00
}
findWindow(kExitsWindow)->setDirty(true);
// To be deleted
//g_system->copyRectToScreen(srf->getPixels(), srf->pitch, 0, 0, srf->w, srf->h);
//g_system->updateScreen();
}
2016-07-04 11:45:47 +02:00
void Gui::drawConsoleWindow() {
Graphics::ManagedSurface *srf = _outConsoleWindow->getSurface();
BorderBounds bounds = borderBounds(getWindowData(kOutConsoleWindow).type);
_consoleText->renderInto(srf, bounds.leftOffset);
}
void Gui::drawObjectsInWindow(WindowReference target, Graphics::ManagedSurface * surface) {
WindowData &data = findWindowData(target);
BorderBounds border = borderBounds(data.type);
Common::Point pos;
ObjID child;
BlitMode mode;
if (data.children.size() == 0) return;
for (uint i = 0; i < data.children.size(); i++) {
child = data.children[i].obj;
mode = (BlitMode)data.children[i].mode;
pos = _engine->getObjPosition(child);
pos += Common::Point(border.leftOffset, border.topOffset);
if (!_assets.contains(child)) {
_assets[child] = new ImageAsset(child, _graphics);
}
_assets[child]->blitInto(
surface,
pos.x,
pos.y,
mode);
if (_engine->isObjSelected(child))
_assets[child]->blitInto(
surface, pos.x, pos.y, kBlitOR);
// For test
/*surface->frameRect(Common::Rect(
pos.x,
pos.y,
pos.x + _assets[child]->getWidth() + 1,
pos.y + _assets[child]->getHeight() + 1), kColorGreen);
*/
}
}
void Gui::drawWindowTitle(WindowReference target, Graphics::ManagedSurface * surface) {
WindowData &data = findWindowData(target);
BorderBounds border = borderBounds(data.type);
uint left = 10;//getCurrentFont().getStringWidth(data.title) - 10;
uint right = 30;//getCurrentFont().getStringWidth(data.title) + 10;
surface->fillRect(Common::Rect(left, 0, right, border.topOffset - 1), kColorGray);
getCurrentFont().drawString(
surface,
data.title,
0,
right,
right - left,
kColorBlack,
Graphics::kTextAlignCenter);
}
void Gui::drawDraggedObject() {
if (_draggedObj.id != 0) {
if (!_assets.contains(_draggedObj.id))
_assets[_draggedObj.id] = new ImageAsset(_draggedObj.id, _graphics);
ImageAsset *asset = _assets[_draggedObj.id];
_draggedSurface.create(asset->getWidth(), asset->getHeight(), _screen.format);
2016-07-09 19:46:10 +02:00
//_screen.copyRectToSurface(_draggedSurface, _draggedObj.pos.x, _draggedObj.pos.y,
// Common::Rect(asset->getWidth() - 1, asset->getHeight() - 1));
asset->blitInto(&_draggedSurface, 0, 0, kBlitBIC);
g_system->copyRectToScreen(
_draggedSurface.getPixels(),
_draggedSurface.pitch,
_draggedObj.pos.x,
_draggedObj.pos.y,
_draggedSurface.w,
_draggedSurface.h);
}
}
2016-06-30 08:41:25 +02:00
void Gui::updateWindow(WindowReference winID, bool containerOpen) {
if (winID == kNoWindow) return;
2016-06-30 08:41:25 +02:00
if (winID == kSelfWindow || containerOpen) {
WindowData &data = findWindowData(winID);
if (winID == kCommandsWindow) {
Common::Array<CommandButton>::iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
it->unselect();
}
}
Common::Array<DrawableObject> &children = data.children;
for (uint i = 0; i < children.size(); i++) {
uint flag = 0;
ObjID child = children[i].obj;
BlitMode mode = kBlitDirect;
bool off = !_engine->isObjVisible(child);
if (flag || !off || !_engine->isObjClickable(child)) {
mode = kBlitBIC;
if (off || flag) {
mode = kBlitXOR;
} else if (!off && _engine->isObjSelected(child)) {
2016-06-30 08:41:25 +02:00
mode = kBlitOR;
}
children[i] = DrawableObject(child, mode);
} else {
2016-06-30 08:41:25 +02:00
children[i] = DrawableObject(child, kBlitXOR);
}
}
if (winID == kMainGameWindow) {
drawMainGameWindow();
} else {
2016-06-30 08:41:25 +02:00
Graphics::MacWindow *winRef = findWindow(winID);
winRef->getSurface()->fillRect(data.bounds, kColorGray);
}
if (data.type == kZoomDoc && data.updateScroll) {
warning("Unimplemented: update scroll");
}
}
}
2016-07-09 19:46:10 +02:00
void Gui::clearExits() {
_exitsData->clear();
}
2016-06-30 08:41:25 +02:00
void Gui::unselectExits() {
Common::Array<CommandButton>::const_iterator it = _exitsData->begin();
for (; it != _exitsData->end(); ++it) {
CommandButton button = *it;
button.unselect();
}
}
void Gui::updateExit(ObjID obj) {
if (!_engine->isObjExit(obj)) return;
BorderBounds border = borderBounds(getWindowData(kExitsWindow).type);
int ctl = -1;
int i = 0;
Common::Array<CommandButton>::const_iterator it = _exitsData->begin();
for (;it != _exitsData->end(); it++) {
if (it->getData().refcon == obj)
ctl = i;
else
i++;
}
if (ctl != -1)
_exitsData->remove_at(ctl);
if (!_engine->isHiddenExit(obj) &&
_engine->getParent(obj) == _engine->getParent(1))
{
ControlData data;
data.titleLength = 0;
2016-07-05 13:06:51 +02:00
data.refcon = (ControlAction)obj; // Objects can be exits (actions)
2016-06-30 08:41:25 +02:00
Common::Point pos = _engine->getObjExitPosition(obj);
2016-07-09 19:46:10 +02:00
pos.x += border.leftOffset;
pos.y += border.topOffset;
2016-06-30 08:41:25 +02:00
data.bounds = Common::Rect(pos.x, pos.y, pos.x + kExitButtonWidth, pos.y + kExitButtonHeight);
data.visible = true;
_exitsData->push_back(CommandButton(data, this));
}
}
2016-07-04 11:45:47 +02:00
void Gui::printText(const Common::String & text) {
debug("Print Text: %s", text);
_consoleText->printLine(text, _outConsoleWindow->getDimensions().width());
}
void Gui::moveDraggedObject(Common::Point target) {
Common::Point newPos = target + _draggedObj.mouseOffset;
bool movement = false;
// If we overflow, move the mouseOffset, not the position.
if (newPos.x < 0 || newPos.x + _assets[_draggedObj.id]->getWidth() >= kScreenWidth) {
_draggedObj.mouseOffset.x = _draggedObj.pos.x - target.x;
} else {
_draggedObj.pos.x = newPos.x;
movement = true;
}
if (newPos.y < 0 || newPos.y + _assets[_draggedObj.id]->getHeight() >= kScreenHeight) {
_draggedObj.mouseOffset.y = _draggedObj.pos.y - target.y;
} else {
_draggedObj.pos.y = newPos.y;
movement = true;
}
// TODO FInd more elegant way of making pow2
_draggedObj.hasMoved = movement && (_draggedObj.startPos.sqrDist(_draggedObj.pos) >= (kDragThreshold * kDragThreshold));
debug(4, "Dragged obj position: (%d, %d), mouse offset: (%d, %d), hasMoved: %d, dist: %d, threshold: %d",
_draggedObj.pos.x, _draggedObj.pos.y,
_draggedObj.mouseOffset.x, _draggedObj.mouseOffset.y,
_draggedObj.hasMoved,
_draggedObj.startPos.sqrDist(_draggedObj.pos),
kDragThreshold * kDragThreshold
);
}
2016-06-30 08:41:25 +02:00
2016-07-02 17:11:42 +02:00
WindowReference Gui::findWindowAtPoint(Common::Point point) {
// HACK, MIGHT NEED TO LOOK INTO THE Graphcis::MacWindow dimensions to account for window movement
2016-07-02 17:11:42 +02:00
Common::List<WindowData>::iterator it;
for (it = _windowData->begin(); it != _windowData->end(); it++) {
if (it->bounds.contains(point) && it->refcon != kDiplomaWindow) { //HACK, diploma should be cosnidered
if (findWindow(it->refcon)->isActive())
return it->refcon;
2016-07-02 17:11:42 +02:00
}
}
return kNoWindow;
}
Common::Point Gui::getWindowSurfacePos(WindowReference reference) {
const WindowData &data = getWindowData(reference);
BorderBounds border = borderBounds(data.type);
Graphics::MacWindow *win = findWindow(reference);
return Common::Point(win->getDimensions().left + border.leftOffset, win->getDimensions().top + border.topOffset);
}
WindowData & Gui::findWindowData(WindowReference reference) {
assert(_windowData);
2016-06-13 00:36:24 +02:00
Common::List<WindowData>::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");
2016-06-13 00:36:24 +02:00
}
Graphics::MacWindow * Gui::findWindow(WindowReference reference) {
if (reference < 0x80 && reference >= kInventoryStart) { // It's an inventory window
return _inventoryWindows[reference - kInventoryStart];
}
switch (reference) {
case MacVenture::kNoWindow:
return nullptr;
case MacVenture::kCommandsWindow:
return _controlsWindow;
case MacVenture::kMainGameWindow:
return _mainGameWindow;
case MacVenture::kOutConsoleWindow:
return _outConsoleWindow;
case MacVenture::kSelfWindow:
return _selfWindow;
case MacVenture::kExitsWindow:
return _exitsWindow;
case MacVenture::kDiplomaWindow:
return _diplomaWindow;
}
return nullptr;
2016-06-11 23:57:35 +02:00
}
WindowReference Gui::getObjWindow(ObjID objID) {
switch (objID) {
case 0xfffc: return kExitsWindow;
case 0xfffd: return kSelfWindow;
case 0xfffe: return kOutConsoleWindow;
case 0xffff: return kCommandsWindow;
}
return findObjWindow(objID);
}
WindowReference Gui::findObjWindow(ObjID objID) {
// This is a bit of a HACK, we take advantage of the consecutive nature of references
for (uint i = kCommandsWindow; i <= kDiplomaWindow; i++) {
const WindowData &data = getWindowData((WindowReference)i);
if (data.objRef == objID) { return data.refcon; }
}
for (uint i = kInventoryStart; i < _inventoryWindows.size() + kInventoryStart; i++) {
const WindowData &data = getWindowData((WindowReference)i);
if (data.objRef == objID) { return data.refcon; }
}
return kNoWindow;
}
bool Gui::canBeSelected(ObjID obj, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
return (_engine->isObjVisible(obj) &&
_engine->isObjClickable(obj) &&
isRectInsideObject(clickRect, obj));
}
void Gui::checkSelect(const WindowData &data, const Common::Event &event, const Common::Rect &clickRect, WindowReference ref) {
ObjID child;
for (Common::Array<DrawableObject>::const_iterator it = data.children.begin(); it != data.children.end(); it++) {
if (canBeSelected((*it).obj, event, clickRect, ref)) {
child = (*it).obj;
}
}
if (child != 0) selectDraggable(child, ref, event.mouse);
}
2016-06-25 22:53:11 +02:00
bool Gui::isRectInsideObject(Common::Rect target, ObjID obj) {
if (_assets.contains(obj) &&
//_engine->isObjClickable(obj) &&
_engine->isObjVisible(obj))
{
2016-06-25 22:53:11 +02:00
Common::Rect bounds = _engine->getObjBounds(obj);
Common::Rect intersection = bounds.findIntersectingRect(target);
// We translate it to the image's coord system
intersection = Common::Rect(
intersection.left - bounds.left,
intersection.top - bounds.top,
intersection.left - bounds.left + intersection.width(),
intersection.top - bounds.top + intersection.height());
if (_assets[obj]->isRectInside(intersection)) {
return true;
}
}
return false;
}
void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point click) {
2016-07-04 11:45:47 +02:00
if (_engine->isObjClickable(child) && _draggedObj.id == 0) {
2016-07-02 17:11:42 +02:00
_draggedObj.hasMoved = false;
_draggedObj.id = child;
_draggedObj.startWin = origin;
_draggedObj.mouseOffset = (_engine->getObjPosition(child) + getWindowSurfacePos(origin)) - click;
_draggedObj.pos = click + _draggedObj.mouseOffset;
_draggedObj.startPos = _draggedObj.pos;
}
}
2016-07-02 17:11:42 +02:00
void Gui::handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleClick) {
WindowReference destinationWindow = findWindowAtPoint(pos);
if (destinationWindow == kNoWindow) return;
if (_draggedObj.id != 0) {
if (_draggedObj.hasMoved) {
ObjID destObject = getWindowData(destinationWindow).objRef;
pos -= _draggedObj.startPos;
pos = localize(pos, _draggedObj.startWin, destinationWindow);
debug("drop the object at obj %d, pos (%d, %d)", destObject, pos.x, pos.y);
2016-07-04 11:45:47 +02:00
_engine->handleObjectDrop(_draggedObj.id, pos, destObject);
}
_engine->handleObjectSelect(_draggedObj.id, destinationWindow, shiftPressed, isDoubleClick);
_draggedObj.id = 0;
_draggedObj.hasMoved = false;
}
}
Common::Rect Gui::calculateClickRect(Common::Point clickPos, Common::Rect windowBounds) {
int left = clickPos.x - windowBounds.left;
int top = clickPos.y - windowBounds.top;
return Common::Rect(left - kCursorWidth, top - kCursorHeight, left + kCursorWidth, top + kCursorHeight);
}
Common::Point Gui::localize(Common::Point point, WindowReference origin, WindowReference target) {
Graphics::MacWindow *oriWin = findWindow(origin);
Graphics::MacWindow *destWin = findWindow(target);
if (origin != target) {
// ori.local to global
point.x += oriWin->getDimensions().left;
point.y += oriWin->getDimensions().top;
if (destWin) {
// dest.globalToLocal
point.x -= destWin->getDimensions().left;
point.y -= destWin->getDimensions().top;
}
}
return point;
}
2016-06-09 11:31:19 +02:00
/* 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
}
/* CALLBACKS */
bool commandsWindowCallback(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 g->processMainGameEvents(click, event);
}
bool outConsoleWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processOutConsoleEvents(click, event);
}
bool selfWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processSelfEvents(click, event);
}
bool exitsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processExitsEvents(click, event);
}
bool diplomaWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processDiplomaEvents(click, event);
}
bool inventoryWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processInventoryEvents(click, event);
}
void menuCommandsCallback(int action, Common::String &text, void *data) {
Gui *g = (Gui *)data;
g->handleMenuAction((MenuAction)action);
}
void Gui::invertWindowColors(WindowReference winID) {
Graphics::ManagedSurface *srf = findWindow(winID)->getSurface();
for (uint y = 0; y < srf->h; y++) {
for (uint x = 0; x < srf->w; x++) {
byte p = *(byte *)srf->getBasePtr(x, y);
*(byte *)srf->getBasePtr(x, y) =
(p == kColorWhite) ? kColorBlack : kColorGray;
}
}
}
bool Gui::tryCloseWindow(WindowReference winID) {
WindowData data = findWindowData(winID);
if (winID < 0x80) { // Inventory window
warning("Window closing not implemented");
} else {
warning("Window closing not implemented");
}
return true;
}
2016-07-12 11:49:05 +02:00
Common::Point Gui::getObjMeasures(ObjID obj) {
if (!_assets.contains(obj)) {
_assets[obj] = new ImageAsset(obj, _graphics);
}
uint w = _assets[obj]->getWidth();
uint h = _assets[obj]->getHeight();
return Common::Point(w, h);
2016-06-24 21:00:06 +02:00
}
bool Gui::processEvent(Common::Event &event) {
bool processed = false;
2016-07-02 17:11:42 +02:00
processed |= _cursor->processEvent(event);
if (event.type == Common::EVENT_MOUSEMOVE) {
if (_draggedObj.id != 0) {
moveDraggedObject(event.mouse);
}
processed = true;
// TEST
2016-07-04 11:45:47 +02:00
//Common::Rect mr = calculateClickRect(event.mouse, _screen.getBounds());
//_screen.fillRect(mr, kColorGreen);
//g_system->copyRectToScreen(_screen.getPixels(), _screen.pitch, 0, 0, _screen.w, _screen.h);
//g_system->updateScreen();
}
processed |= _wm.processEvent(event);
return (processed);
}
2016-06-11 23:57:35 +02:00
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
if (_engine->needsClickToContinue()) {
2016-07-05 13:06:51 +02:00
_engine->activateCommand(kClickToContinue);
2016-06-17 12:44:52 +02:00
return true;
}
2016-06-17 12:44:52 +02:00
Common::Point position(
event.mouse.x - _controlsWindow->getDimensions().left,
event.mouse.y - _controlsWindow->getDimensions().top);
CommandButton data;
if (!_controlData)
return false;
2016-06-30 08:41:25 +02:00
Common::Array<CommandButton>::iterator it = _controlData->begin();
2016-06-17 12:44:52 +02:00
for (; it != _controlData->end(); ++it) {
if (it->isInsideBounds(position)) {
it->select();
2016-06-17 12:44:52 +02:00
data = *it;
2016-06-11 23:57:35 +02:00
}
else {
it->unselect();
}
2016-06-11 23:57:35 +02:00
}
2016-06-17 12:44:52 +02:00
2016-07-05 13:06:51 +02:00
_engine->selectControl(data.getData().refcon);
2016-07-04 11:45:47 +02:00
_engine->activateCommand(data.getData().refcon);
_engine->refreshReady();
_engine->preparedToRun();
2016-06-11 23:57:35 +02:00
}
return false;
}
bool MacVenture::Gui::processMainGameEvents(WindowClick click, Common::Event & event) {
if (_engine->needsClickToContinue())
return true;
if (click == kBorderInner && event.type == Common::EVENT_LBUTTONDOWN) {
WindowData &data = findWindowData(kMainGameWindow);
ObjID child = 0;
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
Common::Rect clickRect = calculateClickRect(event.mouse, _mainGameWindow->getDimensions());
checkSelect(data, event, clickRect, kMainGameWindow);
}
return false;
}
bool MacVenture::Gui::processOutConsoleEvents(WindowClick click, Common::Event & event) {
if (_engine->needsClickToContinue())
return true;
return getWindowData(kOutConsoleWindow).visible;
}
bool MacVenture::Gui::processSelfEvents(WindowClick click, Common::Event & event) {
if (_engine->needsClickToContinue())
return true;
if (event.type == Common::EVENT_LBUTTONUP) {
2016-07-02 17:11:42 +02:00
_engine->handleObjectSelect(1, kSelfWindow, false, false);
}
return true;
}
bool MacVenture::Gui::processExitsEvents(WindowClick click, Common::Event & event) {
2016-06-30 08:41:25 +02:00
if (event.type == Common::EVENT_LBUTTONUP) {
if (_engine->needsClickToContinue()) {
return true;
}
Common::Point position(
event.mouse.x - _exitsWindow->getDimensions().left,
event.mouse.y - _exitsWindow->getDimensions().top);
CommandButton button;
2016-06-30 08:41:25 +02:00
if (!_exitsData)
return false;
Common::Array<CommandButton>::iterator it = _exitsData->begin();
for (; it != _exitsData->end(); ++it) {
if (it->isInsideBounds(position)) {
it->select();
button = *it;
_engine->handleObjectSelect(button.getData().refcon, kExitsWindow, false, false);
return true;
2016-06-30 08:41:25 +02:00
}
else {
it->unselect();
}
}
}
return getWindowData(kExitsWindow).visible;
}
bool MacVenture::Gui::processDiplomaEvents(WindowClick click, Common::Event & event) {
if (_engine->needsClickToContinue())
return true;
return getWindowData(kDiplomaWindow).visible;
}
2016-06-20 08:59:53 +02:00
bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) {
if (_engine->needsClickToContinue())
return true;
if (event.type == Common::EVENT_LBUTTONDOWN) {
2016-06-25 22:53:11 +02:00
// Find the appropriate window
WindowReference ref = findWindowAtPoint(event.mouse);
if (ref == kNoWindow) return false;
Graphics::MacWindow *win = findWindow(ref);
2016-06-25 22:53:11 +02:00
WindowData &data = findWindowData((WindowReference) ref);
ObjID child;
Common::Point pos;
// Click rect to local coordinates. We assume the click is inside the window ^
Common::Rect clickRect = calculateClickRect(event.mouse, win->getDimensions());
checkSelect(data, event, clickRect, (WindowReference)ref);
2016-06-25 22:53:11 +02:00
}
return true;
2016-06-20 08:59:53 +02:00
}
2016-07-02 17:11:42 +02:00
void Gui::processCursorTick() {
_cursor->tick();
}
void Gui::handleSingleClick(Common::Point pos) {
debug("Single Click");
handleDragRelease(pos, false, false);
2016-07-05 13:06:51 +02:00
// HACK For test, please delete me
//WindowReference destinationWindow = findWindowAtPoint(pos);
//_engine->handleObjectSelect(_draggedObj.id, destinationWindow, false, false);
//_draggedObj.id = 0;
2016-07-02 17:11:42 +02:00
}
void Gui::handleDoubleClick(Common::Point pos) {
debug("Double Click");
handleDragRelease(pos, false, true);
2016-07-05 13:06:51 +02:00
// HACK For test, please delete me
//WindowReference destinationWindow = findWindowAtPoint(pos);
//_engine->handleObjectSelect(_draggedObj.id, destinationWindow, false, true);
//_draggedObj.id = 0;
2016-07-02 17:11:42 +02:00
}
2016-06-12 20:22:01 +02:00
/* Ugly switches */
BorderBounds Gui::borderBounds(MVWindowType type) {
2016-06-12 20:22:01 +02:00
switch (type) {
case MacVenture::kDocument:
break;
case MacVenture::kDBox:
break;
case MacVenture::kPlainDBox:
return BorderBounds(6, 6, 6, 6);
2016-06-12 20:22:01 +02:00
case MacVenture::kAltBox:
2016-07-04 11:45:47 +02:00
return BorderBounds(4, 4, 4, 4); // Hand-tested
2016-06-12 20:22:01 +02:00
break;
case MacVenture::kNoGrowDoc:
return BorderBounds(1, 17, 1, 1);
2016-06-12 20:22:01 +02:00
case MacVenture::kMovableDBox:
break;
case MacVenture::kZoomDoc:
return BorderBounds(1, 19, 16, 1);
2016-06-12 20:22:01 +02:00
case MacVenture::kZoomNoGrow:
break;
case MacVenture::kRDoc16:
break;
case MacVenture::kRDoc4:
2016-07-04 11:45:47 +02:00
return BorderBounds(0, 19, 1, 1);
2016-06-12 20:22:01 +02:00
case MacVenture::kRDoc6:
break;
case MacVenture::kRDoc10:
break;
default:
break;
}
return BorderBounds(0, 0, 0, 0);
2016-06-12 20:22:01 +02:00
}
2016-06-08 11:02:21 +02:00
} // End of namespace MacVenture