aboutsummaryrefslogtreecommitdiff
path: root/engines/macventure
diff options
context:
space:
mode:
authorBorja Lorente2016-07-05 13:06:51 +0200
committerBorja Lorente2016-08-14 18:46:56 +0200
commitb4609642840917fe08d675960ce9f0e4567bd6c9 (patch)
treeab174b42dca899a803b600427f1e4f4446a97c63 /engines/macventure
parent46a85f02d6086bb14a6635a6af77ba85520a7e39 (diff)
downloadscummvm-rg350-b4609642840917fe08d675960ce9f0e4567bd6c9.tar.gz
scummvm-rg350-b4609642840917fe08d675960ce9f0e4567bd6c9.tar.bz2
scummvm-rg350-b4609642840917fe08d675960ce9f0e4567bd6c9.zip
MACVENTURE: Add double click
Diffstat (limited to 'engines/macventure')
-rw-r--r--engines/macventure/gui.cpp25
-rw-r--r--engines/macventure/gui.h28
-rw-r--r--engines/macventure/macventure.cpp24
-rw-r--r--engines/macventure/macventure.h23
-rw-r--r--engines/macventure/script.cpp15
-rw-r--r--engines/macventure/script.h20
6 files changed, 86 insertions, 49 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 7ad5eb0d41..fb6f46ba03 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -521,15 +521,15 @@ bool Gui::loadControls() {
data.scrollMax = res->readUint16BE();
data.scrollMin = res->readUint16BE();
data.cdef = res->readUint16BE();
- data.refcon = (ControlType)id; id++;
- res->readUint32BE();
+ data.refcon = (ControlAction)res->readUint32BE();//(ControlType)id; id++;
+ data.type = (ControlType)id; id++;
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';
}
- if (data.refcon != kControlExitBox)
+ if (data.type != kControlExitBox)
data.border = commandsBorder;
Common::Rect bounds(left, top, right, bottom); // For some reason, if I remove this it segfaults
@@ -570,7 +570,7 @@ void Gui::drawCommandsWindow() {
Common::Array<CommandButton>::const_iterator it = _controlData->begin();
for (; it != _controlData->end(); ++it) {
CommandButton button = *it;
- if (button.getData().refcon != kControlExitBox)
+ if (button.getData().type != kControlExitBox)
button.draw(*_controlsWindow->getSurface());
}
}
@@ -816,7 +816,7 @@ void Gui::updateExit(ObjID obj) {
{
ControlData data;
data.titleLength = 0;
- data.objref = obj;
+ data.refcon = (ControlAction)obj; // Objects can be exits (actions)
Common::Point pos = _engine->getObjExitPosition(obj);
pos.x = border.leftOffset;
pos.y = border.topOffset;
@@ -935,7 +935,6 @@ void Gui::handleDragRelease(Common::Point pos, bool shiftPressed, bool isDoubleC
}
_engine->handleObjectSelect(_draggedObj.id, destinationWindow, shiftPressed, isDoubleClick);
-
_draggedObj.id = 0;
}
@@ -1102,7 +1101,7 @@ bool Gui::processEvent(Common::Event &event) {
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
if (_engine->needsClickToContinue()) {
- _engine->activateCommand(kControlClickToContinue);
+ _engine->activateCommand(kClickToContinue);
return true;
}
@@ -1126,7 +1125,7 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
}
- _engine->selectControl(_engine->referenceToAction(data.getData().refcon));
+ _engine->selectControl(data.getData().refcon);
_engine->activateCommand(data.getData().refcon);
_engine->refreshReady();
_engine->preparedToRun();
@@ -1240,11 +1239,21 @@ void Gui::processCursorTick() {
void Gui::handleSingleClick(Common::Point pos) {
debug("Single Click");
handleDragRelease(_draggedObj.pos, false, false);
+
+ // HACK For test, please delete me
+ //WindowReference destinationWindow = findWindowAtPoint(pos);
+ //_engine->handleObjectSelect(_draggedObj.id, destinationWindow, false, false);
+ //_draggedObj.id = 0;
}
void Gui::handleDoubleClick(Common::Point pos) {
debug("Double Click");
handleDragRelease(_draggedObj.pos, false, true);
+
+ // HACK For test, please delete me
+ //WindowReference destinationWindow = findWindowAtPoint(pos);
+ //_engine->handleObjectSelect(_draggedObj.id, destinationWindow, false, true);
+ //_draggedObj.id = 0;
}
/* Ugly switches */
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 6dd22f568c..4e4eda7092 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -111,7 +111,7 @@ struct WindowData {
bool updateScroll;
};
-enum ControlType {
+enum ControlType { // HACK, should correspond exactly with the types of controls (sliders etc)
kControlExitBox = 0,
kControlExamine = 1,
kControlOpen = 2,
@@ -124,6 +124,26 @@ enum ControlType {
kControlClickToContinue = 9
};
+enum ControlAction { // HACK, figure out a way to put it in engine
+ kNoCommand = 0,
+ kStartOrResume = 1,
+ kClose = 2,
+ kTick = 3,
+ kActivateObject = 4,
+ kMoveObject = 5,
+ kConsume = 6,
+ kExamine = 7,
+ kGo = 8,
+ kHit = 9,
+ kOpen = 10,
+ kOperate = 11,
+ kSpeak = 12,
+ kBabble = 13,
+ kTargetName = 14,
+ kDebugObject = 15,
+ kClickToContinue = 16
+};
+
struct ControlData {
Common::Rect bounds;
uint16 scrollValue;
@@ -131,8 +151,8 @@ struct ControlData {
uint16 scrollMax;
uint16 scrollMin;
uint16 cdef;
- ObjID objref;
- ControlType refcon; // If exits window, then the obj id. Otherwise, the control type
+ ControlAction refcon;
+ ControlType type;
uint8 titleLength;
char* title;
uint16 border;
@@ -362,7 +382,7 @@ public:
private:
void changeState(CursorInput input) {
- debug("Change cursor state: [%d] -> [%d]", _state, _transitionTable[_state][input]);
+ debug(4, "Change cursor state: [%d] -> [%d]", _state, _transitionTable[_state][input]);
_state = _transitionTable[_state][input];
}
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 6a9f82f468..42829d97cd 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -177,19 +177,18 @@ void MacVentureEngine::selectControl(ControlAction id) {
_selectedControl = id;
}
-void MacVentureEngine::activateCommand(ControlType id) {
- if (id == kControlClickToContinue) {
+void MacVentureEngine::activateCommand(ControlAction id) {
+ if (id == kClickToContinue) {
_clickToContinue = false;
_paused = true;
return;
- }
- ControlAction action = referenceToAction(id);
- if (action != _activeControl) {
+ }
+ if (id != _activeControl) {
if (_activeControl)
_activeControl = kNoCommand;
- _activeControl = action;
+ _activeControl = id;
}
- debug(2, "Activating Command %x... Command %x is active", action, _activeControl);
+ debug(2, "Activating Command %x... Command %x is active", id, _activeControl);
refreshReady();
}
@@ -267,7 +266,7 @@ bool MacVentureEngine::printTexts() {
gameChanged();
break;
case kTextNewLine:
- _gui->printText(Common::String("\n"));
+ _gui->printText(Common::String(""));
gameChanged();
break;
case kTextPlain:
@@ -314,10 +313,9 @@ void MacVentureEngine::handleObjectSelect(ObjID objID, WindowReference win, bool
if (i >= 0)
unselectAll();
selectObject(objID);
- if (!_cmdReady)
- {
- selectObject(objID);
-
+ _destObject = objID;
+ _deltaPoint = Common::Point(0, 0);
+ if (!_cmdReady) {
selectControl(kActivateObject);
_activeControl = kActivateObject;
_cmdReady = true;
@@ -340,7 +338,7 @@ void MacVentureEngine::handleObjectDrop(ObjID objID, Common::Point delta, ObjID
_destObject = newParent;
updateDelta(delta);
selectControl(kOperate);
- activateCommand(kControlOperate);
+ activateCommand(kOperate);
refreshReady();
preparedToRun();
}
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index a1f570ed98..6dab558a0d 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -71,6 +71,27 @@ enum {
kClickToContinueTextID = 0x84,
kStartGameFilenameID = 0x85
};
+/*
+enum ControlAction {
+ kNoCommand = 0,
+ kStartOrResume = 1,
+ kClose = 2,
+ kTick = 3,
+ kActivateObject = 4,
+ kMoveObject = 5,
+ kConsume = 6,
+ kExamine = 7,
+ kGo = 8,
+ kHit = 9,
+ kOpen = 10,
+ kOperate = 11,
+ kSpeak = 12,
+ kBabble = 13,
+ kTargetName = 14,
+ kDebugObject = 15,
+ kClickToContinue = 16
+};
+*/
enum FilePathID {
kMCVID = 1,
@@ -162,7 +183,7 @@ public:
void requestQuit();
void requestUnpause();
void selectControl(ControlAction action);
- void activateCommand(ControlType id);
+ void activateCommand(ControlAction id);
void refreshReady();
void preparedToRun();
void gameChanged();
diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp
index 230198bc6c..a86347ba4c 100644
--- a/engines/macventure/script.cpp
+++ b/engines/macventure/script.cpp
@@ -353,7 +353,8 @@ bool ScriptEngine::runFunc(EngineFrame *frame) {
opbaCRAN(state, frame);
break;
case 0xbb: //fork
- opbbFORK(state, frame);
+ if (opbbFORK(state, frame))
+ return true;
break;
case 0xbc: //call
if (opbcCALL(state, frame, script))
@@ -902,14 +903,20 @@ void ScriptEngine::opbaCRAN(EngineState * state, EngineFrame * frame) {
frame->saves[i].rank = 0;
}
-void ScriptEngine::opbbFORK(EngineState * state, EngineFrame * frame) {
+bool ScriptEngine::opbbFORK(EngineState * state, EngineFrame * frame) {
EngineFrame newframe;
newframe.action = (ControlAction)state->pop();
newframe.src = state->pop();
newframe.dest = state->pop();
newframe.x = state->pop();
newframe.y = state->pop();
- _frames.push_back(newframe);
+ newframe.haltedInFamily = false;
+ newframe.haltedInFirst = false;
+ newframe.haltedInSaves = false;
+ _frames.push_front(newframe);
+ if (execFrame(true)) {
+ return true;
+ }
}
bool ScriptEngine::opbcCALL(EngineState * state, EngineFrame * frame, ScriptAsset &script) {
@@ -1071,7 +1078,7 @@ void ScriptEngine::opd5DLOG(EngineState * state, EngineFrame * frame) {
}
void ScriptEngine::opd6ACMD(EngineState * state, EngineFrame * frame) {
- _engine->activateCommand((ControlType)state->pop());
+ _engine->activateCommand((ControlAction)state->pop());
}
void ScriptEngine::opd7LOSE(EngineState * state, EngineFrame * frame) {
diff --git a/engines/macventure/script.h b/engines/macventure/script.h
index acbffcd315..8aee88fd66 100644
--- a/engines/macventure/script.h
+++ b/engines/macventure/script.h
@@ -31,24 +31,6 @@ namespace MacVenture {
class Container;
class World;
-enum ControlAction {
- kNoCommand = 0,
- kStartOrResume = 1,
- kClose = 2,
- kTick = 3,
- kActivateObject = 4,
- kMoveObject = 5,
- kConsume = 6,
- kExamine = 7,
- kGo = 8,
- kHit = 9,
- kOpen = 10,
- kOperate = 11,
- kSpeak = 12,
- kBabble = 13,
- kTargetName = 14,
- kDebugObject = 15
-};
typedef uint32 ObjID;
typedef int16 word;
@@ -239,7 +221,7 @@ private:
void opb8CLOW(EngineState *state, EngineFrame *frame); //cancel low priority
void opb9CHI(EngineState *state, EngineFrame *frame); //cancel high priority
void opbaCRAN(EngineState *state, EngineFrame *frame); //cancel priority range
- void opbbFORK(EngineState *state, EngineFrame *frame); //fork
+ bool opbbFORK(EngineState *state, EngineFrame *frame); //fork
bool opbcCALL(EngineState *state, EngineFrame *frame, ScriptAsset &script); //call
void opbdFOOB(EngineState *state, EngineFrame *frame); //focus object
void opbeSWOB(EngineState *state, EngineFrame *frame); //swap objects