aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBorja Lorente2016-06-12 22:09:06 +0200
committerBorja Lorente2016-08-14 18:20:54 +0200
commitec40b4ec441dd1e3af4cdf1fb670d44efc19f7f4 (patch)
treea40e2023b69e0808ca71c352bc073928a9007612 /engines
parent1d5cbee3a820c34af2ecdc2221e38290ab33c82f (diff)
downloadscummvm-rg350-ec40b4ec441dd1e3af4cdf1fb670d44efc19f7f4.tar.gz
scummvm-rg350-ec40b4ec441dd1e3af4cdf1fb670d44efc19f7f4.tar.bz2
scummvm-rg350-ec40b4ec441dd1e3af4cdf1fb670d44efc19f7f4.zip
MACVENTURE: Fix border offsets
Diffstat (limited to 'engines')
-rw-r--r--engines/macventure/gui.cpp85
-rw-r--r--engines/macventure/gui.h25
-rw-r--r--engines/macventure/macventure.cpp18
-rw-r--r--engines/macventure/macventure.h13
4 files changed, 109 insertions, 32 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index caf6eb1789..8f922d3dd2 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -83,12 +83,7 @@ Gui::~Gui() {
void Gui::draw() {
- 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());
- }
+ drawCommandsWindow();
_wm.draw();
}
@@ -122,13 +117,6 @@ void Gui::initGUI() {
void Gui::initWindows() {
- // 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);
-
// Game Controls Window
_controlsWindow = _wm.addWindow(false, false, false);
_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
@@ -137,6 +125,15 @@ void Gui::initWindows() {
loadBorder(_controlsWindow, "border_command.bmp", false);
loadBorder(_controlsWindow, "border_command.bmp", true);
+ // Main Game Window
+
+ // 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);
+
}
void Gui::loadBorder(Graphics::MacWindow * target, Common::String filename, bool active) {
@@ -253,10 +250,10 @@ bool Gui::loadWindows() {
right = res->readUint16BE();
data.type = (MVWindowType)res->readUint16BE();
data.bounds = Common::Rect(
- left,
- top,
- right + borderThickness(data.type),
- bottom + borderThickness(data.type));
+ left - borderThickness(data.type),
+ top - borderThickness(data.type),
+ right + borderThickness(data.type) * 2,
+ bottom + borderThickness(data.type) * 2);
data.visible = res->readUint16BE();
data.hasCloseBox = res->readUint16BE();
data.refcon = (WindowReference)id; id++;
@@ -284,6 +281,7 @@ bool Gui::loadControls() {
if ((resArray = _resourceManager->getResIDArray(MKTAG('C', 'N', 'T', 'L'))).size() == 0)
return false;
+ uint16 commandsBorder = borderThickness(kPlainDBox);
uint32 id = kControlExitBox;
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = _resourceManager->getResource(MKTAG('C', 'N', 'T', 'L'), *iter);
@@ -293,8 +291,6 @@ bool Gui::loadControls() {
left = res->readUint16BE();
bottom = res->readUint16BE();
right = res->readUint16BE();
- Common::Rect bounds(left, top, right, bottom); // For some reason, if I remove this it segfaults
- data.bounds = Common::Rect(left, top, right, bottom);
data.scrollValue = res->readUint16BE();
data.visible = res->readByte();
res->readByte(); // Unused
@@ -309,6 +305,11 @@ bool Gui::loadControls() {
res->read(data.title, data.titleLength);
data.title[data.titleLength] = '\0';
}
+ 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);
i++;
}
@@ -316,6 +317,32 @@ bool Gui::loadControls() {
return true;
}
+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());
+ }
+ }
+}
+
+
/* CALLBACKS */
bool outConsoleWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
return true;
@@ -386,14 +413,18 @@ void Gui::handleMenuAction(MenuAction action) {
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
- 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);
+ 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);
+ }
}
}
}
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 983dc10f74..9316f91fd3 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -109,6 +109,7 @@ struct ControlData {
uint32 refcon;
uint8 titleLength;
char* title;
+ uint16 border;
};
@@ -123,6 +124,13 @@ public:
void handleMenuAction(MenuAction action);
bool processCommandEvents(WindowClick click, Common::Event &event);
+ const WindowData& getWindowData(WindowReference reference);
+
+ const Graphics::Font& getCurrentFont();
+
+ // Ugly switches
+ uint16 borderThickness(MVWindowType type);
+
private: // Attributes
MacVentureEngine *_engine;
@@ -131,16 +139,30 @@ private: // Attributes
Graphics::ManagedSurface _screen;
Graphics::MacWindowManager _wm;
+ Common::List<WindowData> *_windowData;
+ Common::List<CommandButton> *_controlData;
+
+ Graphics::MacWindow *_controlsWindow;
+ Graphics::MacWindow *_mainGameWindow;
Graphics::MacWindow *_outConsoleWindow;
+ Graphics::MacWindow *_selfWindow;
+ Graphics::MacWindow *_exitsWindow;
+ Graphics::MacWindow *_diplomaWindow;
Graphics::Menu *_menu;
private: // Methods
+
+ // Initializers
void initGUI();
+ void initWindows();
+
+ // Loaders
bool loadMenus();
void loadBorder(Graphics::MacWindow * target, Common::String filename, bool active);
- uint16 borderThickness(MVWindowType type);
+ // Drawers
+ void drawCommandsWindow();
};
@@ -160,7 +182,6 @@ public:
void draw(Graphics::ManagedSurface &surface) const {
-
surface.fillRect(_data.bounds, kColorWhite);
surface.frameRect(_data.bounds, kColorBlack);
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 5660fde16c..19021278cb 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -87,6 +87,24 @@ Common::Error MacVentureEngine::run() {
return Common::kNoError;
}
+void MacVentureEngine::requestQuit() {
+ _shouldQuit = true;
+}
+
+void MacVentureEngine::requestUnpause() {
+ _paused = false;
+}
+
+// Data retrieval
+
+bool MacVentureEngine::isPaused() {
+ return _paused;
+}
+
+Common::String MacVentureEngine::getCommandsPausedString() {
+ return Common::String("Click to continue");
+}
+
void MacVentureEngine::processEvents() {
Common::Event event;
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 771588fde1..b8d065b876 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -58,16 +58,23 @@ public:
virtual Common::Error run();
+ void requestQuit();
+ void requestUnpause();
+
+ // Data retrieval
+ bool isPaused();
+ Common::String getCommandsPausedString();
+
private:
void processEvents();
-
+
private: // Attributes
const ADGameDescription *_gameDescription;
Common::RandomSource *_rnd;
Common::MacResManager *_resourceManager;
-
+
Console *_debugger;
Gui *_gui;
@@ -88,4 +95,4 @@ public:
};
} // End of namespace MacVenture
-#endif \ No newline at end of file
+#endif