[Scummvm-git-logs] scummvm master -> 806966389cd21dfe1bbb3dc2db4060f6e635075c
elasota
noreply at scummvm.org
Sun Nov 13 23:20:38 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
806966389c MTROPOLIS: Add keybind to skip movies for debug purposes.
Commit: 806966389cd21dfe1bbb3dc2db4060f6e635075c
https://github.com/scummvm/scummvm/commit/806966389cd21dfe1bbb3dc2db4060f6e635075c
Author: elasota (ejlasota at gmail.com)
Date: 2022-11-13T18:19:49-05:00
Commit Message:
MTROPOLIS: Add keybind to skip movies for debug purposes.
Changed paths:
engines/mtropolis/actions.h
engines/mtropolis/elements.cpp
engines/mtropolis/elements.h
engines/mtropolis/metaengine.cpp
engines/mtropolis/mtropolis.cpp
engines/mtropolis/render.cpp
engines/mtropolis/render.h
engines/mtropolis/runtime.cpp
engines/mtropolis/runtime.h
diff --git a/engines/mtropolis/actions.h b/engines/mtropolis/actions.h
index 14b39025aff..42ff6b5ff5c 100644
--- a/engines/mtropolis/actions.h
+++ b/engines/mtropolis/actions.h
@@ -30,6 +30,7 @@ enum Action {
kNone = 0,
kDebugToggleOverlay,
+ kDebugSkipMovies,
};
enum MouseButton {
diff --git a/engines/mtropolis/elements.cpp b/engines/mtropolis/elements.cpp
index 5a479fc9213..cbb49f6397a 100644
--- a/engines/mtropolis/elements.cpp
+++ b/engines/mtropolis/elements.cpp
@@ -814,6 +814,16 @@ void MovieElement::setResizeFilter(const Common::SharedPtr<MovieResizeFilter> &f
_resizeFilter = filter;
}
+#ifdef MTROPOLIS_DEBUG_ENABLE
+void MovieElement::debugSkipMovies() {
+ if (_videoDecoder && !_videoDecoder->endOfVideo()) {
+ const IntRange realRange = computeRealRange();
+
+ _videoDecoder->seek(Audio::Timestamp(0, _timeScale).addFrames(_reversed ? realRange.min : realRange.max));
+ }
+}
+#endif
+
void MovieElement::onSegmentUnloaded(int segmentIndex) {
_videoDecoder.reset();
}
diff --git a/engines/mtropolis/elements.h b/engines/mtropolis/elements.h
index 01011a304bc..0e001c73895 100644
--- a/engines/mtropolis/elements.h
+++ b/engines/mtropolis/elements.h
@@ -107,6 +107,8 @@ public:
#ifdef MTROPOLIS_DEBUG_ENABLE
const char *debugGetTypeName() const override { return "Movie Element"; }
SupportStatus debugGetSupportStatus() const override { return kSupportStatusDone; }
+
+ void debugSkipMovies() override;
#endif
protected:
diff --git a/engines/mtropolis/metaengine.cpp b/engines/mtropolis/metaengine.cpp
index 19829627670..bb85092386b 100644
--- a/engines/mtropolis/metaengine.cpp
+++ b/engines/mtropolis/metaengine.cpp
@@ -100,6 +100,10 @@ Common::Array<Common::Keymap *> MTropolisMetaEngine::initKeymaps(const char *tar
act->addDefaultInputMapping("F10");
keymap->addAction(act);
+ act = new Common::Action("DEBUG_SKIP_MOVIES", _("Force any playing movies to end"));
+ act->setCustomEngineActionEvent(MTropolis::Actions::kDebugSkipMovies);
+ keymap->addAction(act);
+
return Common::Keymap::arrayOf(keymap);
}
diff --git a/engines/mtropolis/mtropolis.cpp b/engines/mtropolis/mtropolis.cpp
index a1c9a5548a3..a75765cb191 100644
--- a/engines/mtropolis/mtropolis.cpp
+++ b/engines/mtropolis/mtropolis.cpp
@@ -92,6 +92,9 @@ void MTropolisEngine::handleEvents() {
case Common::EVENT_KEYUP:
_runtime->onKeyboardEvent(evt.type, evt.kbdRepeat, evt.kbd);
break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ _runtime->onAction(static_cast<MTropolis::Actions::Action>(evt.customType));
+ break;
default:
break;
diff --git a/engines/mtropolis/render.cpp b/engines/mtropolis/render.cpp
index cffb1f2914f..c0b23fbc16c 100644
--- a/engines/mtropolis/render.cpp
+++ b/engines/mtropolis/render.cpp
@@ -198,6 +198,9 @@ void Window::onMouseUp(int32 x, int32 y, int mouseButton) {
void Window::onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt) {
}
+void Window::onAction(Actions::Action action) {
+}
+
namespace Render {
uint32 resolveRGB(uint8 r, uint8 g, uint8 b, const Graphics::PixelFormat &fmt) {
diff --git a/engines/mtropolis/render.h b/engines/mtropolis/render.h
index 761ef688fab..5249cf84e1e 100644
--- a/engines/mtropolis/render.h
+++ b/engines/mtropolis/render.h
@@ -28,6 +28,8 @@
#include "graphics/pixelformat.h"
+#include "actions.h"
+
namespace Graphics {
class ManagedSurface;
@@ -120,6 +122,7 @@ public:
virtual void onMouseMove(int32 x, int32 y);
virtual void onMouseUp(int32 x, int32 y, int mouseButton);
virtual void onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt);
+ virtual void onAction(Actions::Action action);
protected:
int32 _x;
diff --git a/engines/mtropolis/runtime.cpp b/engines/mtropolis/runtime.cpp
index 024e8740f68..51c41d7f433 100644
--- a/engines/mtropolis/runtime.cpp
+++ b/engines/mtropolis/runtime.cpp
@@ -93,6 +93,7 @@ public:
void onMouseMove(int32 x, int32 y) override;
void onMouseUp(int32 x, int32 y, int mouseButton) override;
void onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt) override;
+ void onAction(MTropolis::Actions::Action action) override;
private:
bool _mouseButtonStates[Actions::kMouseButtonCount];
@@ -131,6 +132,10 @@ void MainWindow::onKeyboardEvent(const Common::EventType evtType, bool repeat, c
_runtime->queueOSEvent(Common::SharedPtr<OSEvent>(new KeyboardInputEvent(kOSEventTypeKeyboard, evtType, repeat, keyEvt)));
}
+void MainWindow::onAction(MTropolis::Actions::Action action) {
+ _runtime->queueOSEvent(Common::SharedPtr<OSEvent>(new ActionEvent(kOSEventTypeAction, action)));
+}
+
class ModifierInnerScopeBuilder : public IStructuralReferenceVisitor {
public:
@@ -3440,6 +3445,11 @@ void Structural::debugInspect(IDebugInspectionReport *report) const {
report->declareStaticContents(Common::String::format("%x", getStaticGUID()));
}
+void Structural::debugSkipMovies() {
+ for (Common::SharedPtr<Structural> &child : _children)
+ child->debugSkipMovies();
+}
+
#endif /* MTROPOLIS_DEBUG_ENABLE */
void Structural::linkInternalReferences(ObjectLinkingScope *scope) {
@@ -4040,6 +4050,13 @@ const Common::KeyState &KeyboardInputEvent::getKeyState() const {
return _keyEvt;
}
+ActionEvent::ActionEvent(OSEventType osEventType, Actions::Action action) : OSEvent(osEventType), _action(action) {
+}
+
+Actions::Action ActionEvent::getAction() const {
+ return _action;
+}
+
Runtime::SceneStackEntry::SceneStackEntry() {
}
@@ -4263,6 +4280,12 @@ bool Runtime::runFrame() {
taskData->y = mouseEvt->getY();
}
} break;
+ case kOSEventTypeAction: {
+ Actions::Action action = static_cast<ActionEvent *>(evt.get())->getAction();
+
+ DispatchActionTaskData *taskData = _vthread->pushTask("Runtime::dispatchAction", this, &Runtime::dispatchActionTask);
+ taskData->action = action;
+ } break;
default:
break;
}
@@ -5399,6 +5422,22 @@ VThreadState Runtime::dispatchKeyTask(const DispatchKeyTaskData &data) {
}
}
+VThreadState Runtime::dispatchActionTask(const DispatchActionTaskData &data) {
+ switch (data.action)
+ {
+ case Actions::kDebugSkipMovies:
+#ifdef MTROPOLIS_DEBUG_ENABLE
+ _project->debugSkipMovies();
+#endif
+ break;
+ default:
+ warning("Unhandled action %i", static_cast<int>(data.action));
+ break;
+ }
+
+ return kVThreadReturn;
+}
+
VThreadState Runtime::consumeMessageTask(const ConsumeMessageTaskData &data) {
IMessageConsumer *consumer = data.consumer;
assert(consumer->respondsToEvent(data.message->getEvent()));
@@ -5751,6 +5790,13 @@ void Runtime::onKeyboardEvent(const Common::EventType evtType, bool repeat, cons
focusWindow->onKeyboardEvent(evtType, repeat, keyEvt);
}
+
+void Runtime::onAction(MTropolis::Actions::Action action) {
+ Common::SharedPtr<Window> focusWindow = _keyFocusWindow.lock();
+ if (focusWindow)
+ focusWindow->onAction(action);
+}
+
const Common::Point &Runtime::getCachedMousePosition() const {
return _cachedMousePosition;
}
diff --git a/engines/mtropolis/runtime.h b/engines/mtropolis/runtime.h
index 006be8d011b..83d47f115cf 100644
--- a/engines/mtropolis/runtime.h
+++ b/engines/mtropolis/runtime.h
@@ -1479,6 +1479,8 @@ enum OSEventType {
kOSEventTypeMouseMove,
kOSEventTypeKeyboard,
+
+ kOSEventTypeAction,
};
class OSEvent {
@@ -1520,6 +1522,16 @@ private:
const Common::KeyState _keyEvt;
};
+class ActionEvent : public OSEvent {
+public:
+ explicit ActionEvent(OSEventType osEventType, Actions::Action action);
+
+ Actions::Action getAction() const;
+
+private:
+ Actions::Action _action;
+};
+
struct DragMotionProperties {
DragMotionProperties();
@@ -1628,6 +1640,7 @@ public:
void onMouseMove(int32 x, int32 y);
void onMouseUp(int32 x, int32 y, Actions::MouseButton mButton);
void onKeyboardEvent(const Common::EventType evtType, bool repeat, const Common::KeyState &keyEvt);
+ void onAction(MTropolis::Actions::Action action);
const Common::Point &getCachedMousePosition() const;
void setModifierCursorOverride(uint32 cursorID);
@@ -1723,6 +1736,10 @@ private:
Common::SharedPtr<KeyEventDispatch> dispatch;
};
+ struct DispatchActionTaskData {
+ Actions::Action action;
+ };
+
struct ConsumeMessageTaskData {
ConsumeMessageTaskData();
@@ -1801,6 +1818,7 @@ private:
VThreadState dispatchMessageTask(const DispatchMethodTaskData &data);
VThreadState dispatchKeyTask(const DispatchKeyTaskData &data);
+ VThreadState dispatchActionTask(const DispatchActionTaskData &data);
VThreadState consumeMessageTask(const ConsumeMessageTaskData &data);
VThreadState consumeCommandTask(const ConsumeCommandTaskData &data);
VThreadState updateMouseStateTask(const UpdateMouseStateTaskData &data);
@@ -2121,6 +2139,8 @@ public:
SupportStatus debugGetSupportStatus() const override;
const Common::String &debugGetName() const override;
void debugInspect(IDebugInspectionReport *report) const override;
+
+ virtual void debugSkipMovies();
#endif
protected:
More information about the Scummvm-git-logs
mailing list