aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-06-12 20:22:01 +0200
committerBorja Lorente2016-08-14 18:17:45 +0200
commit1d5cbee3a820c34af2ecdc2221e38290ab33c82f (patch)
tree9a3989545ea4b28fe5d0711487089d2469aada72 /engines/macventure
parent63e4fe8fc7d99d858f5302a7c3321e1d73296904 (diff)
downloadscummvm-rg350-1d5cbee3a820c34af2ecdc2221e38290ab33c82f.tar.gz
scummvm-rg350-1d5cbee3a820c34af2ecdc2221e38290ab33c82f.tar.bz2
scummvm-rg350-1d5cbee3a820c34af2ecdc2221e38290ab33c82f.zip
MACVENTURE: Fix small border bug
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/gui.cpp121
-rw-r--r--engines/macventure/gui.h62
2 files changed, 181 insertions, 2 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 887f9c2b65..caf6eb1789 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -231,6 +231,91 @@ bool Gui::loadMenus() {
return true;
}
+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(
+ left,
+ top,
+ right + borderThickness(data.type),
+ bottom + borderThickness(data.type));
+ 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';
+ }
+
+ _windowData->push_back(data);
+ }
+
+ return true;
+}
+
+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;
+
+ 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();
+ 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
+ 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';
+ }
+
+ i++;
+ }
+
+ return true;
+}
+
/* CALLBACKS */
bool outConsoleWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
return true;
@@ -304,7 +389,6 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
Common::Point position(
event.mouse.x - _controlsWindow->getDimensions().left,
event.mouse.y - _controlsWindow->getDimensions().top);
- //debug("Click at: %d, %d", p)
Common::List<CommandButton>::const_iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
const CommandButton &data = *it;
@@ -316,4 +400,39 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
return false;
}
+/* 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;
+}
+
} // End of namespace MacVenture
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index c6446cec29..983dc10f74 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -53,6 +53,65 @@ enum MenuAction {
};
//} using namespace MacVentureMenuActions;
+enum WindowReference {
+ kCommandsWindow = 0x80,
+ kMainGameWindow = 0x81,
+ kOutConsoleWindow = 0x82,
+ kSelfWindow = 0x83,
+ kExitsWindow = 0x84,
+ kDiplomaWindow = 0x85
+};
+
+enum MVWindowType {
+ kDocument = 0x00,
+ kDBox = 0x01,
+ kPlainDBox = 0x02,
+ kAltBox = 0x03,
+ kNoGrowDoc = 0x04,
+ kMovableDBox = 0x05,
+ kZoomDoc = 0x08,
+ kZoomNoGrow = 0x0c,
+ kRDoc16 = 0x10,
+ kRDoc4 = 0x12,
+ kRDoc6 = 0x14,
+ kRDoc10 = 0x16
+};
+
+struct WindowData {
+ Common::Rect bounds;
+ MVWindowType type;
+ uint16 visible;
+ uint16 hasCloseBox;
+ WindowReference refcon;
+ uint8 titleLength;
+ char* title;
+};
+
+enum ControlReference {
+ kControlExitBox = 0,
+ kControlExamine = 1,
+ kControlOpen = 2,
+ kControlClose = 3,
+ kControlSpeak = 4,
+ kControlOperate = 5,
+ kControlGo = 6,
+ kControlHit = 7,
+ kControlConsume = 8
+};
+
+struct ControlData {
+ Common::Rect bounds;
+ uint16 scrollValue;
+ uint8 visible;
+ uint16 scrollMax;
+ uint16 scrollMin;
+ uint16 cdef;
+ uint32 refcon;
+ uint8 titleLength;
+ char* title;
+};
+
+
class Gui {
public:
@@ -81,6 +140,8 @@ private: // Methods
bool loadMenus();
void loadBorder(Graphics::MacWindow * target, Common::String filename, bool active);
+ uint16 borderThickness(MVWindowType type);
+
};
class CommandButton {
@@ -113,7 +174,6 @@ public:
_data.bounds.right - _data.bounds.left,
kColorBlack,
Graphics::kTextAlignCenter);
-
}
bool isInsideBounds(const Common::Point point) const {