MACVENTURE: Delete duplicate code

This commit is contained in:
Borja Lorente 2016-08-12 10:02:24 +02:00
parent 580c8136f4
commit 7b9c63b1b9
4 changed files with 6 additions and 21 deletions

View File

@ -1247,7 +1247,7 @@ bool Gui::processEvent(Common::Event &event) {
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) { bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) { if (event.type == Common::EVENT_LBUTTONUP) {
if (_engine->needsClickToContinue()) { if (_engine->needsClickToContinue()) {
_engine->activateCommand(kClickToContinue); _engine->selectControl(kClickToContinue);
return true; return true;
} }
@ -1271,7 +1271,6 @@ bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
} }
_engine->selectControl(data.getData().refcon); _engine->selectControl(data.getData().refcon);
_engine->activateCommand(data.getData().refcon);
_engine->refreshReady(); _engine->refreshReady();
_engine->preparedToRun(); _engine->preparedToRun();
} }

View File

@ -270,21 +270,13 @@ void MacVentureEngine::requestUnpause() {
void MacVentureEngine::selectControl(ControlAction id) { void MacVentureEngine::selectControl(ControlAction id) {
debugC(2, kMVDebugMain, "Select control %x", id); debugC(2, kMVDebugMain, "Select control %x", id);
_selectedControl = id;
}
void MacVentureEngine::activateCommand(ControlAction id) {
if (id == kClickToContinue) { if (id == kClickToContinue) {
_clickToContinue = false; _clickToContinue = false;
_paused = true; _paused = true;
return; return;
} }
if (id != _activeControl) {
if (_activeControl) _selectedControl = id;
_activeControl = kNoCommand;
_activeControl = id;
}
debugC(2, kMVDebugMain, "Activating Command %x... Command %x is active", id, _activeControl);
refreshReady(); refreshReady();
} }
@ -408,7 +400,6 @@ void MacVentureEngine::handleObjectSelect(ObjID objID, WindowReference win, bool
setDeltaPoint(Common::Point(0, 0)); setDeltaPoint(Common::Point(0, 0));
if (!_cmdReady) { if (!_cmdReady) {
selectControl(kActivateObject); selectControl(kActivateObject);
_activeControl = kActivateObject;
_cmdReady = true; _cmdReady = true;
} }
} else { } else {
@ -426,7 +417,6 @@ void MacVentureEngine::handleObjectDrop(ObjID objID, Common::Point delta, ObjID
_destObject = newParent; _destObject = newParent;
setDeltaPoint(delta); setDeltaPoint(delta);
selectControl(kMoveObject); selectControl(kMoveObject);
activateCommand(kMoveObject);
refreshReady(); refreshReady();
preparedToRun(); preparedToRun();
} }
@ -655,16 +645,14 @@ void MacVentureEngine::playSounds(bool pause) {
} }
void MacVentureEngine::updateControls() { void MacVentureEngine::updateControls() {
if (_activeControl) _selectedControl = kNoCommand;
_activeControl = kNoCommand;
_gui->clearControls(); _gui->clearControls();
toggleExits(); toggleExits();
resetVars(); resetVars();
} }
void MacVentureEngine::resetVars() { void MacVentureEngine::resetVars() {
_selectedControl = kNoCommand; selectControl(kNoCommand);
_activeControl = kNoCommand;
_currentSelection.clear(); _currentSelection.clear();
_destObject = 0; _destObject = 0;
setDeltaPoint(Common::Point(0, 0)); setDeltaPoint(Common::Point(0, 0));

View File

@ -201,7 +201,6 @@ public:
void requestQuit(); void requestQuit();
void requestUnpause(); void requestUnpause();
void selectControl(ControlAction action); void selectControl(ControlAction action);
void activateCommand(ControlAction id);
void refreshReady(); void refreshReady();
void preparedToRun(); void preparedToRun();
void gameChanged(); void gameChanged();
@ -344,7 +343,6 @@ private: // Attributes
// Selections // Selections
ObjID _destObject; ObjID _destObject;
ControlAction _selectedControl; ControlAction _selectedControl;
ControlAction _activeControl;
Common::Array<ObjID> _currentSelection; Common::Array<ObjID> _currentSelection;
Common::Array<ObjID> _selectedObjs; Common::Array<ObjID> _selectedObjs;
Common::Point _deltaPoint; Common::Point _deltaPoint;

View File

@ -1083,7 +1083,7 @@ void ScriptEngine::opd5DLOG(EngineState * state, EngineFrame * frame) {
} }
void ScriptEngine::opd6ACMD(EngineState * state, EngineFrame * frame) { void ScriptEngine::opd6ACMD(EngineState * state, EngineFrame * frame) {
_engine->activateCommand((ControlAction)state->pop()); _engine->selectControl((ControlAction)state->pop());
} }
void ScriptEngine::opd7LOSE(EngineState * state, EngineFrame * frame) { void ScriptEngine::opd7LOSE(EngineState * state, EngineFrame * frame) {