MACVENTURE: Fix border offsets
This commit is contained in:
parent
1d5cbee3a8
commit
ec40b4ec44
4 changed files with 109 additions and 32 deletions
|
@ -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,6 +413,9 @@ void Gui::handleMenuAction(MenuAction action) {
|
|||
|
||||
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
|
||||
if (event.type == Common::EVENT_LBUTTONUP) {
|
||||
if (_engine->isPaused()) {
|
||||
_engine->requestUnpause();
|
||||
} else {
|
||||
Common::Point position(
|
||||
event.mouse.x - _controlsWindow->getDimensions().left,
|
||||
event.mouse.y - _controlsWindow->getDimensions().top);
|
||||
|
@ -397,6 +427,7 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -58,6 +58,13 @@ public:
|
|||
|
||||
virtual Common::Error run();
|
||||
|
||||
void requestQuit();
|
||||
void requestUnpause();
|
||||
|
||||
// Data retrieval
|
||||
bool isPaused();
|
||||
Common::String getCommandsPausedString();
|
||||
|
||||
private:
|
||||
void processEvents();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue