[Scummvm-git-logs] scummvm master -> 714c3faf0a623cf2ba7a6d1041a2ded51947dc9a
sev-
noreply at scummvm.org
Sun Feb 23 00:20:52 UTC 2025
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:
714c3faf0a DIRECTOR: XLIBS: Initial code for QTVR Xlib
Commit: 714c3faf0a623cf2ba7a6d1041a2ded51947dc9a
https://github.com/scummvm/scummvm/commit/714c3faf0a623cf2ba7a6d1041a2ded51947dc9a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-02-23T01:20:35+01:00
Commit Message:
DIRECTOR: XLIBS: Initial code for QTVR Xlib
Used in trektech
Changed paths:
engines/director/lingo/xlibs/qtvr.cpp
engines/director/lingo/xlibs/qtvr.h
diff --git a/engines/director/lingo/xlibs/qtvr.cpp b/engines/director/lingo/xlibs/qtvr.cpp
index 1972434c113..cf7c7e8a898 100644
--- a/engines/director/lingo/xlibs/qtvr.cpp
+++ b/engines/director/lingo/xlibs/qtvr.cpp
@@ -57,6 +57,7 @@
#include "director/lingo/lingo-object.h"
#include "director/lingo/lingo-utils.h"
#include "director/lingo/xlibs/qtvr.h"
+#include "director/window.h"
namespace Director {
@@ -128,7 +129,44 @@ XOBJSTUB(QTVR::m_getVPanAngle, "")
XOBJSTUB(QTVR::m_getZoomAngle, "")
XOBJSTUB(QTVR::m_mouseOver, "")
XOBJSTUB(QTVR::m_name, "")
-XOBJSTUB(QTVR::m_openMovie, 0)
+
+void QTVR::m_openMovie(int nargs) {
+ g_lingo->printArgs("QtvrxtraXtra::m_QTVROpen", nargs);
+ ARGNUMCHECK(3);
+
+ int top = g_lingo->pop().asInt();
+ int left = g_lingo->pop().asInt();
+ Common::String pathStr = g_lingo->pop().asString();
+
+ QTVRXObject *me = (QTVRXObject *)g_lingo->_state->me.u.obj;
+
+ Common::Path path = findMoviePath(pathStr);
+ if (path.empty()) {
+ Common::String error = Common::String::format("Error: Movie file ('%s') not found!", pathStr.c_str());
+ g_lingo->push(error);
+ return;
+ }
+
+ me->_video = new Video::QuickTimeDecoder();
+ debugC(5, kDebugXObj, "QtvrxtraXtra::m_QTVROpen(): Loading QT file ('%s')", path.toString().c_str());
+ if (!me->_video->loadFile(path)) {
+ Common::String error = Common::String::format("Error: Failed to load movie file ('%s')!", path.toString().c_str());
+ g_lingo->push(error);
+ return;
+ }
+
+ me->_video->setTargetSize(320, 200);
+
+ me->_rect = Common::Rect(left, top, left + me->_video->getWidth(), top + me->_video->getHeight());
+
+
+ me->_widget = new QtvrWidget(me, g_director->getCurrentWindow(),
+ me->_rect.left, me->_rect.top, me->_rect.width(), me->_rect.height(),
+ g_director->getMacWindowManager());
+
+ g_lingo->push(path.toString());
+}
+
XOBJSTUB(QTVR::m_setActive, 0)
XOBJSTUBNR(QTVR::m_setHPanAngle)
XOBJSTUB(QTVR::m_setNodeID, 0)
@@ -138,6 +176,53 @@ XOBJSTUB(QTVR::m_setTransitionMode, 0)
XOBJSTUB(QTVR::m_setTransitionSpeed, 0)
XOBJSTUBNR(QTVR::m_setVPanAngle)
XOBJSTUBNR(QTVR::m_setZoomAngle)
-XOBJSTUB(QTVR::m_update, 0)
+
+void QTVR::m_update(int nargs) {
+ ARGNUMCHECK(0);
+
+ QTVRXObject *me = (QTVRXObject *)g_lingo->_state->me.u.obj;
+
+ Graphics::Surface const *frame = me->_video->decodeNextFrame();
+
+ if (!frame)
+ return;
+
+ Graphics::Surface *dither = frame->convertTo(g_director->_wm->_pixelformat, me->_video->getPalette(), 256, g_director->getPalette(), 256, Graphics::kDitherNaive);
+
+ g_director->getCurrentWindow()->getSurface()->copyRectToSurface(
+ dither->getPixels(), dither->pitch, me->_rect.left, me->_rect.top, dither->w, dither->h
+ );
+}
+
+
+///////////////
+// Widget
+///////////////
+
+QtvrWidget::QtvrWidget(QTVRXObject *xtra, Graphics::MacWidget *parent, int x, int y, int w, int h, Graphics::MacWindowManager *wm) :
+ Graphics::MacWidget(parent, x, y, w, h, wm, true), _xtra(xtra) {
+
+ _priority = 10000; // We stay on top of everything
+}
+
+bool QtvrWidget::processEvent(Common::Event &event) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ _xtra->_video->handleMouseButton(true, event.mouse.x - _xtra->_rect.left, event.mouse.y - _xtra->_rect.top);
+ return true;
+ case Common::EVENT_LBUTTONUP:
+ _xtra->_video->handleMouseButton(false, event.mouse.x - _xtra->_rect.left, event.mouse.y - _xtra->_rect.top);
+ return true;
+ case Common::EVENT_MOUSEMOVE:
+ _xtra->_video->handleMouseMove(event.mouse.x - _xtra->_rect.left, event.mouse.y - _xtra->_rect.top);
+ return true;
+ case Common::EVENT_KEYDOWN:
+ case Common::EVENT_KEYUP:
+ _xtra->_video->handleKey(event.kbd, event.type == Common::EVENT_KEYDOWN);
+ return true;
+ default:
+ return false;
+ }
+}
} // End of namespace Director
diff --git a/engines/director/lingo/xlibs/qtvr.h b/engines/director/lingo/xlibs/qtvr.h
index 9400cdeaa38..6ab03580ebe 100644
--- a/engines/director/lingo/xlibs/qtvr.h
+++ b/engines/director/lingo/xlibs/qtvr.h
@@ -22,6 +22,8 @@
#ifndef DIRECTOR_LINGO_XLIBS_QTVR_H
#define DIRECTOR_LINGO_XLIBS_QTVR_H
+#include "video/qt_decoder.h"
+
namespace Director {
namespace QTVR {
@@ -56,9 +58,25 @@ void m_update(int nargs);
} // End of namespace QTVR
+class QTVRXObject;
+
+class QtvrWidget : public Graphics::MacWidget {
+public:
+ QtvrWidget(QTVRXObject *xtra, Graphics::MacWidget *parent, int x, int y, int w, int h, Graphics::MacWindowManager *wm);
+
+ virtual bool processEvent(Common::Event &event);
+
+ QTVRXObject *_xtra;
+};
+
+
class QTVRXObject : public Object<QTVRXObject> {
public:
QTVRXObject(ObjectType objType);
+
+ Common::Rect _rect;
+ Video::QuickTimeDecoder *_video = nullptr;
+ QtvrWidget *_widget = nullptr;
};
} // End of namespace Director
More information about the Scummvm-git-logs
mailing list