MACVENTURE: Add appropriate border bounding boxes

This commit is contained in:
Borja Lorente 2016-06-13 00:01:39 +02:00
parent d43523010b
commit 88e6f9257e
2 changed files with 31 additions and 19 deletions

View File

@ -177,9 +177,11 @@ void Gui::initWindows() {
_exitsWindow->setDimensions(getWindowData(kExitsWindow).bounds);
_exitsWindow->setActive(false);
_exitsWindow->setCallback(exitsWindowCallback, this);
loadBorder(_exitsWindow, "border_command.bmp", false);
loadBorder(_exitsWindow, "border_title_inac.bmp", false);
loadBorder(_exitsWindow, "border_title_inac.bmp", true);
// Diploma Window
// Diploma Window (we can go without it for now)
/*
_diplomaWindow = _wm.addWindow(false, true, true);
_diplomaWindow->setDimensions(getWindowData(kDiplomaWindow).bounds);
_diplomaWindow->setActive(false);
@ -187,6 +189,7 @@ void Gui::initWindows() {
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);
@ -311,10 +314,10 @@ bool Gui::loadWindows() {
right = res->readUint16BE();
data.type = (MVWindowType)res->readUint16BE();
data.bounds = Common::Rect(
left - borderThickness(data.type),
top - borderThickness(data.type),
right + borderThickness(data.type) * 2,
bottom + borderThickness(data.type) * 2);
left - borderBounds(data.type).leftOffset,
top - borderBounds(data.type).topOffset,
right + borderBounds(data.type).rightOffset * 2,
bottom + borderBounds(data.type).bottomOffset * 2);
data.visible = res->readUint16BE();
data.hasCloseBox = res->readUint16BE();
data.refcon = (WindowReference)id; id++;
@ -340,9 +343,9 @@ void Gui::loadInventoryWindow() {
WindowData data;
GlobalSettings settings = _engine->getGlobalSettings();
data.bounds = Common::Rect(
settings.invLeft,
settings.invTop,
settings.invLeft + settings.invWidth,
settings.invLeft,
settings.invTop,
settings.invLeft + settings.invWidth,
settings.invTop + settings.invHeight);
data.title = "Inventory";
data.visible = true;
@ -363,7 +366,7 @@ bool Gui::loadControls() {
if ((resArray = _resourceManager->getResIDArray(MKTAG('C', 'N', 'T', 'L'))).size() == 0)
return false;
uint16 commandsBorder = borderThickness(kPlainDBox);
uint16 commandsBorder = borderBounds(kPlainDBox).topOffset;
uint32 id = kControlExitBox;
for (iter = resArray.begin(); iter != resArray.end(); ++iter) {
res = _resourceManager->getResource(MKTAG('C', 'N', 'T', 'L'), *iter);
@ -403,7 +406,7 @@ void Gui::drawCommandsWindow() {
if (_engine->isPaused()) {
Graphics::ManagedSurface *srf = _controlsWindow->getSurface();
WindowData data = getWindowData(kCommandsWindow);
uint16 border = borderThickness(data.type);
uint16 border = borderBounds(data.type).topOffset;
srf->fillRect(Common::Rect(border * 2, border * 2, srf->w - (border * 3), srf->h - (border * 3)), kColorWhite);
getCurrentFont().drawString(
srf,
@ -429,7 +432,7 @@ void Gui::drawCommandsWindow() {
bool controlsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
return g->processCommandEvents(click, event);
}
@ -573,28 +576,28 @@ bool MacVenture::Gui::processDiplomaEvents(WindowClick click, Common::Event & ev
/* Ugly switches */
uint16 Gui::borderThickness(MVWindowType type) {
BorderBounds Gui::borderBounds(MVWindowType type) {
switch (type) {
case MacVenture::kDocument:
break;
case MacVenture::kDBox:
break;
case MacVenture::kPlainDBox:
return 6;
return BorderBounds(6, 6, 6, 6);
case MacVenture::kAltBox:
break;
case MacVenture::kNoGrowDoc:
break;
return BorderBounds(1, 17, 1, 1);
case MacVenture::kMovableDBox:
break;
case MacVenture::kZoomDoc:
break;
return BorderBounds(1, 19, 16, 1);
case MacVenture::kZoomNoGrow:
break;
case MacVenture::kRDoc16:
break;
case MacVenture::kRDoc4:
break;
return BorderBounds(1, 19, 1, 1);
case MacVenture::kRDoc6:
break;
case MacVenture::kRDoc10:
@ -603,7 +606,7 @@ uint16 Gui::borderThickness(MVWindowType type) {
break;
}
return 0;
return BorderBounds(0, 0, 0, 0);
}
} // End of namespace MacVenture

View File

@ -113,6 +113,15 @@ struct ControlData {
uint16 border;
};
struct BorderBounds {
uint16 leftOffset;
uint16 topOffset;
uint16 rightOffset;
uint16 bottomOffset;
BorderBounds(uint16 l, uint16 t, uint16 r, uint16 b) : leftOffset(l), topOffset(t), rightOffset(r), bottomOffset(b) {}
};
class Gui {
@ -137,7 +146,7 @@ public:
const Graphics::Font& getCurrentFont();
// Ugly switches
uint16 borderThickness(MVWindowType type);
BorderBounds borderBounds(MVWindowType type);
private: // Attributes