aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/wage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wage/wage.cpp')
-rw-r--r--engines/wage/wage.cpp72
1 files changed, 41 insertions, 31 deletions
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 8886b0d67d..3419a86fbd 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -45,11 +45,14 @@
*
*/
+#include "common/config-manager.h"
#include "common/debug-channels.h"
+#include "common/error.h"
+#include "common/events.h"
+#include "common/system.h"
#include "engines/engine.h"
#include "engines/util.h"
-#include "gui/EventRecorder.h"
#include "wage/wage.h"
#include "wage/entities.h"
@@ -84,6 +87,7 @@ WageEngine::WageEngine(OSystem *syst, const ADGameDescription *desc) : Engine(sy
_offer = NULL;
_resManager = NULL;
+ _debugger = NULL;
debug("WageEngine::WageEngine()");
}
@@ -100,12 +104,14 @@ WageEngine::~WageEngine() {
}
Common::Error WageEngine::run() {
+ debug("WageEngine::init");
+
initGraphics(512, 342, true);
// Create debugger console. It requires GFX to be initialized
_console = new Console(this);
- debug("WageEngine::init");
+ _debugger = new Debugger(this);
// Your main event loop should be (invoked from) here.
_resManager = new Common::MacResManager();
@@ -121,6 +127,12 @@ Common::Error WageEngine::run() {
_temporarilyHidden = true;
performInitialSetup();
+ if (ConfMan.hasKey("save_slot")) {
+ int saveSlot = ConfMan.getInt("save_slot");
+ loadGame(saveSlot);
+ _gui->regenCommandsMenu();
+ _gui->regenWeaponsMenu();
+ }
Common::String input("look");
processTurn(&input, NULL);
_temporarilyHidden = false;
@@ -128,6 +140,8 @@ Common::Error WageEngine::run() {
_shouldQuit = false;
while (!_shouldQuit) {
+ _debugger->onFrame();
+
processEvents();
_gui->draw();
@@ -142,24 +156,14 @@ void WageEngine::processEvents() {
Common::Event event;
while (_eventMan->pollEvent(event)) {
+ if (_gui->processEvent(event))
+ continue;
+
switch (event.type) {
case Common::EVENT_QUIT:
if (saveDialog())
_shouldQuit = true;
break;
- case Common::EVENT_MOUSEMOVE:
- _gui->mouseMove(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONDOWN:
- _gui->mouseDown(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- {
- Designed *obj = _gui->mouseUp(event.mouse.x, event.mouse.y);
- if (obj != NULL)
- processTurn(NULL, obj);
- }
- break;
case Common::EVENT_KEYDOWN:
switch (event.kbd.keycode) {
case Common::KEYCODE_BACKSPACE:
@@ -178,10 +182,8 @@ void WageEngine::processEvents() {
break;
default:
- if (event.kbd.flags & (Common::KBD_ALT | Common::KBD_CTRL | Common::KBD_META)) {
- if (event.kbd.ascii >= 0x20 && event.kbd.ascii <= 0x7f) {
- _gui->processMenuShortCut(event.kbd.flags, event.kbd.ascii);
- }
+ if (event.kbd.ascii == '~') {
+ _debugger->attach();
break;
}
@@ -225,7 +227,6 @@ void WageEngine::gameOver() {
_gui->disableAllMenus();
_gui->enableNewGameMenus();
- _gui->_menuDirty = true;
}
bool WageEngine::saveDialog() {
@@ -270,15 +271,16 @@ void WageEngine::performInitialSetup() {
debug(5, "Resetting Owners: %d", _world->_orderedObjs.size());
for (uint i = 0; i < _world->_orderedObjs.size(); i++) {
Obj *obj = _world->_orderedObjs[i];
- if (!obj->_sceneOrOwner.equalsIgnoreCase(STORAGESCENE)) {
+ if (!isStorageScene(obj->_sceneOrOwner)) {
Common::String location = obj->_sceneOrOwner;
location.toLowercase();
- if (_world->_scenes.contains(location)) {
- _world->move(obj, _world->_scenes[location]);
+ Scene *scene = getSceneByName(location);
+ if (scene != NULL) {
+ _world->move(obj, scene);
} else {
if (!_world->_chrs.contains(location)) {
// Note: PLAYER@ is not a valid target here.
- warning("Couldn't move %s to %s", obj->_name.c_str(), obj->_sceneOrOwner.c_str());
+ warning("Couldn't move %s to \"%s\"", obj->_name.c_str(), obj->_sceneOrOwner.c_str());
} else {
// TODO: Add check for max items.
_world->move(obj, _world->_chrs[location]);
@@ -290,7 +292,7 @@ void WageEngine::performInitialSetup() {
bool playerPlaced = false;
for (uint i = 0; i < _world->_orderedChrs.size(); i++) {
Chr *chr = _world->_orderedChrs[i];
- if (!chr->_initialScene.equalsIgnoreCase(STORAGESCENE)) {
+ if (!isStorageScene(chr->_initialScene)) {
Common::String key = chr->_initialScene;
key.toLowercase();
if (_world->_scenes.contains(key) && _world->_scenes[key] != NULL) {
@@ -312,18 +314,24 @@ void WageEngine::performInitialSetup() {
}
}
+void WageEngine::wearObjs(Chr* chr) {
+ if (chr != nullptr)
+ chr->wearObjs();
+}
+
void WageEngine::doClose() {
warning("STUB: doClose()");
}
Scene *WageEngine::getSceneByName(Common::String &location) {
- Scene *scene;
if (location.equals("random@")) {
- scene = _world->getRandomScene();
+ return _world->getRandomScene();
} else {
- scene = _world->_scenes[location];
+ if (_world->_scenes.contains(location))
+ return _world->_scenes[location];
+ else
+ return NULL;
}
- return scene;
}
void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
@@ -375,6 +383,7 @@ void WageEngine::onMove(Designed *what, Designed *from, Designed *to) {
if (!_temporarilyHidden) {
if (to == currentScene || from == currentScene) {
redrawScene();
+ g_system->updateScreen();
g_system->delayMillis(100);
}
}
@@ -386,6 +395,7 @@ void WageEngine::redrawScene() {
if (currentScene != NULL) {
bool firstTime = (_lastScene != currentScene);
+ _gui->draw();
updateSoundTimerForScene(currentScene, firstTime);
}
}