[Scummvm-git-logs] scummvm master -> 1f63c7ec98ac91017cabd7722bd69ced3c1bdb71
aquadran
noreply at scummvm.org
Sun Nov 17 14:08:58 UTC 2024
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:
1f63c7ec98 WINTERMUTE: Added stub for ShadowManager plugin
Commit: 1f63c7ec98ac91017cabd7722bd69ced3c1bdb71
https://github.com/scummvm/scummvm/commit/1f63c7ec98ac91017cabd7722bd69ced3c1bdb71
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2024-11-17T15:08:54+01:00
Commit Message:
WINTERMUTE: Added stub for ShadowManager plugin
Changed paths:
A engines/wintermute/ext/wme_shadowmanager.cpp
A engines/wintermute/ext/wme_shadowmanager.h
engines/wintermute/ext/plugins.h
engines/wintermute/module.mk
engines/wintermute/persistent.cpp
diff --git a/engines/wintermute/ext/plugins.h b/engines/wintermute/ext/plugins.h
index 86fe1fb7469..ed1d84b6784 100644
--- a/engines/wintermute/ext/plugins.h
+++ b/engines/wintermute/ext/plugins.h
@@ -41,6 +41,7 @@ BaseScriptable *makeSX3fStatistics(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXCommandLineHelper(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXSample(BaseGame *inGame, ScStack *stack);
BaseScriptable *makeSXVlink(BaseGame *inGame, ScStack *stack);
+BaseScriptable *makeSXShadowManager(BaseGame *inGame, ScStack *stack);
bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, char *name) {
ScValue *thisObj;
@@ -117,6 +118,18 @@ bool EmulatePluginCall(BaseGame *inGame, ScStack *stack, ScStack *thisStack, cha
return STATUS_OK;
}
+ //////////////////////////////////////////////////////////////////////////
+ // ShadowManager (from wme_shadows.dll of "Stroke of Fate" duology games)
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "ShadowManager") == 0) {
+ thisObj = thisStack->getTop();
+
+ thisObj->setNative(makeSXShadowManager(inGame, stack));
+
+ stack->pushNULL();
+ return STATUS_OK;
+ }
+
return STATUS_FAILED;
}
diff --git a/engines/wintermute/ext/wme_shadowmanager.cpp b/engines/wintermute/ext/wme_shadowmanager.cpp
new file mode 100644
index 00000000000..cf7a5b926b6
--- /dev/null
+++ b/engines/wintermute/ext/wme_shadowmanager.cpp
@@ -0,0 +1,387 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "engines/metaengine.h"
+#include "engines/wintermute/wintermute.h"
+#include "engines/wintermute/base/base_game.h"
+#include "engines/wintermute/base/base_engine.h"
+#include "engines/wintermute/base/scriptables/script_stack.h"
+#include "engines/wintermute/base/scriptables/script_value.h"
+#include "engines/wintermute/ext/wme_shadowmanager.h"
+#include "engines/wintermute/ext/plugin_event.h"
+
+namespace Wintermute {
+
+IMPLEMENT_PERSISTENT(SXShadowManager, false)
+
+BaseScriptable *makeSXShadowManager(BaseGame *inGame, ScStack *stack) {
+ return new SXShadowManager(inGame, stack);
+}
+
+//////////////////////////////////////////////////////////////////////////
+SXShadowManager::SXShadowManager(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
+ stack->correctParams(0);
+
+ PluginEventEntry event = {
+ event._type = WME_EVENT_UPDATE,
+ event._callback = callback,
+ event._plugin = this
+ };
+ _gameRef->pluginEvents().subscribeEvent(event);
+
+ _defaultLightPos = DXVector3(1.0f, 200.0f, 1.0f);
+ _minShadow = 0.1f;
+ _maxShadow = 1.0f;
+ _useSmartShadows = false;
+}
+
+//////////////////////////////////////////////////////////////////////////
+SXShadowManager::~SXShadowManager() {
+ PluginEventEntry event = {
+ event._type = WME_EVENT_UPDATE,
+ event._callback = callback,
+ event._plugin = this
+ };
+ _gameRef->pluginEvents().unsubscribeEvent(event);
+}
+
+//////////////////////////////////////////////////////////////////////////
+const char *SXShadowManager::scToString() {
+ return "[shadowmanager object]";
+}
+
+//////////////////////////////////////////////////////////////////////////
+bool SXShadowManager::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
+ //////////////////////////////////////////////////////////////////////////
+ // Run()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Run") == 0) {
+ stack->correctParams(0);
+
+ run();
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Stop()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "Stop") == 0) {
+ stack->correctParams(0);
+
+ stop();
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // AddActor(string)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "AddActor") == 0) {
+ stack->correctParams(1);
+ const char *actorName = stack->pop()->getString();
+
+ stack->pushBool(addActor(actorName));
+
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // RemoveActor(string)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "RemoveActor") == 0) {
+ stack->correctParams(1);
+
+ // nothing todo
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // RemoveAllActors()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "RemoveAllActors") == 0) {
+ stack->correctParams(0);
+
+ stack->pushBool(removeAllActors());
+
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // GetNumLights()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "GetNumLights") == 0) {
+ stack->correctParams(0);
+
+ // nothing todo
+
+ stack->pushInt(0);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // GetLightInfo()
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "GetLightInfo") == 0) {
+ stack->correctParams(1);
+
+ // nothing todo
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // SetDefaultLightPos(float, float, float)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "SetDefaultLightPos") == 0) {
+ stack->correctParams(3);
+
+ _defaultLightPos._x = stack->pop()->getFloat();
+ _defaultLightPos._y = stack->pop()->getFloat();
+ _defaultLightPos._z = stack->pop()->getFloat();
+
+ stack->pushBool(true);
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // EnableLight(string)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "EnableLight") == 0) {
+ stack->correctParams(1);
+ const char *lightName = stack->pop()->getString();
+
+ stack->pushBool(enableLight(lightName));
+
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DisableLight(string)
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "DisableLight") == 0) {
+ stack->correctParams(1);
+ const char *lightName = stack->pop()->getString();
+
+ stack->pushBool(disableLight(lightName));
+
+ return STATUS_OK;
+ }
+
+ stack->pushNULL();
+ return STATUS_FAILED;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+ScValue *SXShadowManager::scGetProperty(const Common::String &name) {
+ _scValue->setNULL();
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPos
+ //////////////////////////////////////////////////////////////////////////
+ if (name == "DefaultLightPos") {
+ _scValue->setProperty("x", _defaultLightPos._x);
+ _scValue->setProperty("y", _defaultLightPos._y);
+ _scValue->setProperty("z", _defaultLightPos._z);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosX
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "DefaultLightPosX") {
+ _scValue->setFloat(_defaultLightPos._x);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosY
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "DefaultLightPosY") {
+ _scValue->setFloat(_defaultLightPos._y);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosZ
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "DefaultLightPosZ") {
+ _scValue->setFloat(_defaultLightPos._z);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // MinShadow
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "MinShadow") {
+ _scValue->setFloat(_minShadow);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // MaxShadow
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "MaxShadow") {
+ _scValue->setFloat(_maxShadow);
+ return _scValue;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // UseSmartShadows
+ //////////////////////////////////////////////////////////////////////////
+ else if (name == "UseSmartShadows") {
+ _scValue->setBool(_useSmartShadows);
+ return _scValue;
+ }
+
+ return _scValue;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool SXShadowManager::scSetProperty(const char *name, ScValue *value) {
+ // DefaultLightPos, DefaultLightPosX, DefaultLightPosY, DefaultLightPosZ, MinShadow, MaxShadow, UseSmartShadows
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPos
+ //////////////////////////////////////////////////////////////////////////
+ if (strcmp(name, "DefaultLightPos") == 0) {
+ _defaultLightPos._x = value->getProp("x")->getFloat();
+ _defaultLightPos._y = value->getProp("y")->getFloat();
+ _defaultLightPos._z = value->getProp("z")->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosX
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "DefaultLightPosX") == 0) {
+ _defaultLightPos._x = value->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosY
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "DefaultLightPosY") == 0) {
+ _defaultLightPos._y = value->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // DefaultLightPosZ
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "DefaultLightPosZ") == 0) {
+ _defaultLightPos._z = value->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // MinShadow
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "MinShadow") == 0) {
+ _minShadow = value->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // MaxShadow
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "MaxShadow") == 0) {
+ _maxShadow = value->getFloat();
+ return STATUS_OK;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // UseSmartShadows
+ //////////////////////////////////////////////////////////////////////////
+ else if (strcmp(name, "UseSmartShadows") == 0) {
+ _useSmartShadows = value->getBool();
+ return STATUS_OK;
+ }
+
+ return STATUS_FAILED;
+}
+
+
+//////////////////////////////////////////////////////////////////////////
+bool SXShadowManager::persist(BasePersistenceManager *persistMgr) {
+ BaseScriptable::persist(persistMgr);
+
+ if (!persistMgr->getIsSaving()) {
+ PluginEventEntry event = {
+ event._type = WME_EVENT_UPDATE,
+ event._callback = callback,
+ event._plugin = this
+ };
+ _gameRef->pluginEvents().subscribeEvent(event);
+ }
+
+ persistMgr->transferVector3d(TMEMBER(_defaultLightPos));
+ persistMgr->transferFloat(TMEMBER(_minShadow));
+ persistMgr->transferFloat(TMEMBER(_maxShadow));
+ persistMgr->transferBool(TMEMBER(_useSmartShadows));
+
+ return STATUS_OK;
+}
+
+void SXShadowManager::callback(void *eventData1, void *eventData2) {
+ SXShadowManager *shadowManager = (SXShadowManager *)eventData2;
+
+ uint32 time = shadowManager->_gameRef->scGetProperty("CurrentTime")->getInt();
+ if (time - shadowManager->_lastTime > 20) {
+ shadowManager->_lastTime = time;
+ shadowManager->update();
+ }
+}
+
+void SXShadowManager::update() {
+}
+
+void SXShadowManager::run() {
+}
+
+void SXShadowManager::stop() {
+}
+
+bool SXShadowManager::addActor(const char *actorName) {
+ return true;
+}
+
+bool SXShadowManager::removeAllActors() {
+ return true;
+}
+
+bool SXShadowManager::enableLight(const char *lightName) {
+ return true;
+}
+
+bool SXShadowManager::disableLight(const char *lightName) {
+ return true;
+}
+
+} // End of namespace Wintermute
diff --git a/engines/wintermute/ext/wme_shadowmanager.h b/engines/wintermute/ext/wme_shadowmanager.h
new file mode 100644
index 00000000000..a037b817739
--- /dev/null
+++ b/engines/wintermute/ext/wme_shadowmanager.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef WINTERMUTE_SHADOWMANAGER_H
+#define WINTERMUTE_SHADOWMANAGER_H
+
+#include "common/str.h"
+
+#include "engines/wintermute/base/base_scriptable.h"
+
+namespace Wintermute {
+
+class SXShadowManager : public BaseScriptable {
+public:
+ DECLARE_PERSISTENT(SXShadowManager, BaseScriptable)
+ ScValue *scGetProperty(const Common::String &name) override;
+ bool scSetProperty(const char *name, ScValue *value) override;
+ bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
+ const char *scToString() override;
+ SXShadowManager(BaseGame *inGame, ScStack *stack);
+ ~SXShadowManager() override;
+
+private:
+ static void callback(void *eventData1, void *eventData2);
+ void update();
+ void run();
+ void stop();
+ bool addActor(const char *actorName);
+ bool removeAllActors();
+ bool enableLight(const char *lightName);
+ bool disableLight(const char *lightName);
+
+ int _lastTime{};
+ DXVector3 _defaultLightPos;
+ float _minShadow;
+ float _maxShadow;
+ bool _useSmartShadows;
+};
+
+} // End of namespace Wintermute
+
+#endif
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index b64df887c88..25b6eb733c8 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -106,6 +106,7 @@ MODULE_OBJS := \
ext/wme_3fstatistics.o \
ext/wme_commandlinehelper.o \
ext/wme_galaxy.o \
+ ext/wme_shadowmanager.o \
ext/wme_steam.o \
ext/wme_windowmode.o \
ext/wme_vlink.o \
diff --git a/engines/wintermute/persistent.cpp b/engines/wintermute/persistent.cpp
index 443bf18312f..130c7ad1cf3 100644
--- a/engines/wintermute/persistent.cpp
+++ b/engines/wintermute/persistent.cpp
@@ -85,6 +85,7 @@
#include "engines/wintermute/ext/wme_steam.h"
#include "engines/wintermute/ext/wme_galaxy.h"
#include "engines/wintermute/ext/wme_vlink.h"
+#include "engines/wintermute/ext/wme_shadowmanager.h"
#include "engines/wintermute/ui/ui_button.h"
#include "engines/wintermute/ui/ui_edit.h"
#include "engines/wintermute/ui/ui_entity.h"
@@ -176,6 +177,7 @@ void SystemClassRegistry::registerClasses() {
REGISTER_CLASS(SXWMEGalaxyAPI, false)
REGISTER_CLASS(SXCommandLineHelper, false)
REGISTER_CLASS(SXVlink, false)
+ REGISTER_CLASS(SXShadowManager, false)
REGISTER_CLASS(UIButton, false)
REGISTER_CLASS(UIEdit, false)
More information about the Scummvm-git-logs
mailing list