scummvm/engines/saga2/modal.cpp

107 lines
2.7 KiB
C++
Raw Normal View History

2021-05-17 20:47:39 +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 3 of the License, or
* (at your option) any later version.
2021-05-17 20:47:39 +02:00
*
* 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
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
2021-06-23 14:41:01 +02:00
#include "saga2/saga2.h"
2021-05-17 20:47:39 +02:00
#include "saga2/modal.h"
#include "saga2/speech.h"
#include "saga2/grabinfo.h"
namespace Saga2 {
ModalWindow *mWinPtr;
APPFUNC(cmdModalWindow);
2021-09-11 12:13:35 +03:00
void ModalModeSetup() {}
void ModalModeCleanup() {}
void ModalModeHandleTask() {}
2021-05-17 20:47:39 +02:00
GameMode ModalMode = {
nullptr, // no previous mode
2021-06-13 16:56:52 +02:00
false, // mode is not nestable
2021-05-17 20:47:39 +02:00
ModalModeSetup,
ModalModeCleanup,
ModalModeHandleTask,
ModalModeHandleKey,
2021-06-21 23:16:32 +02:00
nullptr
2021-05-17 20:47:39 +02:00
};
extern void updateWindowSection(const Rect16 &r);
/* ===================================================================== *
Modal Window class member functions
* ===================================================================== */
ModalWindow *ModalWindow::current = nullptr;
2021-05-17 20:47:39 +02:00
ModalWindow::ModalWindow(const Rect16 &r, uint16 ident, AppFunc *cmd)
: DecoratedWindow(r, ident, "DialogWindow", cmd) {
prevModeStackCtr = 0;
for (int i = 0; i < Max_Modes; i++)
prevModeStackPtr[i] = nullptr;
2021-05-17 20:47:39 +02:00
}
2021-09-11 12:13:35 +03:00
ModalWindow::~ModalWindow() {
2021-05-17 20:47:39 +02:00
// Kludge because of Visual C's patching of vptr in destructor.
if (isOpen()) close();
}
2021-09-11 12:13:35 +03:00
bool ModalWindow::isModal() {
2021-05-17 20:47:39 +02:00
return openFlag;
}
2021-09-11 12:13:35 +03:00
bool ModalWindow::open() {
2021-07-01 05:05:03 +09:00
g_vm->_mouseInfo->replaceObject();
g_vm->_mouseInfo->clearGauge();
g_vm->_mouseInfo->setText(nullptr);
2021-07-01 05:05:03 +09:00
g_vm->_mouseInfo->setIntent(GrabInfo::WalkTo);
2021-05-17 20:47:39 +02:00
prevModeStackCtr = GameMode::getStack(prevModeStackPtr);
2021-06-10 23:28:21 +09:00
GameMode *gameModes[] = {&PlayMode, &TileMode, &ModalMode};
GameMode::SetStack(gameModes, 3);
2021-05-17 20:47:39 +02:00
current = this;
return gWindow::open();
}
2021-09-11 12:13:35 +03:00
void ModalWindow::close() {
2021-05-17 20:47:39 +02:00
gWindow::close();
GameMode::SetStack(prevModeStackPtr, prevModeStackCtr);
updateWindowSection(_extent);
2021-05-17 20:47:39 +02:00
}
void ModalModeHandleKey(short k, short s) {
}
} // end of namespace Saga2