[Scummvm-git-logs] scummvm master -> 106ad4af85bac5e73cc8177397f39d5c31189991

aquadran noreply at scummvm.org
Sun Jul 3 12:09:58 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:
106ad4af85 WINTERMUTE: WME3D: Restore original code for 'getLatyerSize' and 3 more attributes


Commit: 106ad4af85bac5e73cc8177397f39d5c31189991
    https://github.com/scummvm/scummvm/commit/106ad4af85bac5e73cc8177397f39d5c31189991
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2022-07-03T14:09:52+02:00

Commit Message:
WINTERMUTE: WME3D: Restore original code for 'getLatyerSize' and 3 more attributes

Changed paths:
    engines/wintermute/ad/ad_game.cpp
    engines/wintermute/ad/ad_game.h
    engines/wintermute/ad/ad_scene.cpp
    engines/wintermute/ad/ad_scene.h
    engines/wintermute/base/base_game.cpp
    engines/wintermute/base/base_game.h


diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp
index 886f1e49704..0a637f91025 100644
--- a/engines/wintermute/ad/ad_game.cpp
+++ b/engines/wintermute/ad/ad_game.cpp
@@ -34,6 +34,7 @@
 #include "engines/wintermute/ad/ad_inventory.h"
 #include "engines/wintermute/ad/ad_inventory_box.h"
 #include "engines/wintermute/ad/ad_item.h"
+#include "engines/wintermute/ad/ad_layer.h"
 #include "engines/wintermute/ad/ad_response.h"
 #include "engines/wintermute/ad/ad_response_box.h"
 #include "engines/wintermute/ad/ad_response_context.h"
@@ -2494,14 +2495,47 @@ bool AdGame::displayDebugInfo() {
 
 #ifdef ENABLE_WME3D
 //////////////////////////////////////////////////////////////////////////
-Wintermute::TShadowType Wintermute::AdGame::getMaxShadowType(Wintermute::BaseObject *object) {
+Wintermute::TShadowType AdGame::getMaxShadowType(Wintermute::BaseObject *object) {
 	TShadowType ret = BaseGame::getMaxShadowType(object);
 
 	return MIN(ret, _scene->_maxShadowType);
 }
+#endif
+
+//////////////////////////////////////////////////////////////////////////
+bool AdGame::getLayerSize(int *layerWidth, int *layerHeight, Rect32 *viewport, bool *customViewport) {
+	if (_scene && _scene->_mainLayer) {
+		int portX, portY, portWidth, portHeight;
+		_scene->getViewportOffset(&portX, &portY);
+		_scene->getViewportSize(&portWidth, &portHeight);
+		*customViewport = _sceneViewport || _scene->_viewport;
 
+		viewport->setRect(portX, portY, portX + portWidth, portY + portHeight);
+
+#ifdef ENABLE_WME3D
+		if (_scene->_scroll3DCompatibility) {
+			// backward compatibility hack
+			// WME pre-1.7 expects the camera to only view the top-left part of the scene
+			*layerWidth = _gameRef->_renderer->getWidth();
+			*layerHeight = _gameRef->_renderer->getHeight();
+			if (_gameRef->_editorResolutionWidth > 0)
+				*layerWidth = _gameRef->_editorResolutionWidth;
+			if (_gameRef->_editorResolutionHeight > 0)
+				*layerHeight = _gameRef->_editorResolutionHeight;
+		} else
+#endif
+		{
+			*layerWidth = _scene->_mainLayer->_width;
+			*layerHeight = _scene->_mainLayer->_height;
+		}
+		return true;
+	} else
+		return BaseGame::getLayerSize(layerWidth, layerHeight, viewport, customViewport);
+}
+
+#ifdef ENABLE_WME3D
 //////////////////////////////////////////////////////////////////////////
-uint32 Wintermute::AdGame::getAmbientLightColor() {
+uint32 AdGame::getAmbientLightColor() {
 	if (_scene) {
 		return _scene->_ambientLightColor;
 	} else {
@@ -2510,7 +2544,7 @@ uint32 Wintermute::AdGame::getAmbientLightColor() {
 }
 
 //////////////////////////////////////////////////////////////////////////
-bool Wintermute::AdGame::getFogParams(bool *fogEnabled, uint32 *fogColor, float *start, float *end) {
+bool AdGame::getFogParams(bool *fogEnabled, uint32 *fogColor, float *start, float *end) {
 	if (_scene) {
 		*fogEnabled = _scene->_fogEnabled;
 		*fogColor = _scene->_fogColor;
diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h
index 3e97fd975d0..d9e13894e6f 100644
--- a/engines/wintermute/ad/ad_game.h
+++ b/engines/wintermute/ad/ad_game.h
@@ -96,6 +96,7 @@ public:
 	TTalkSkipButton _talkSkipButton;
 	TVideoSkipButton _videoSkipButton;
 
+	virtual bool getLayerSize(int *layerWidth, int *layerHeight, Rect32 *viewport, bool *customViewport) override;
 #ifdef ENABLE_WME3D
 	uint32 getAmbientLightColor() override;
 
diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp
index 8a4c61eb03f..90019e38640 100644
--- a/engines/wintermute/ad/ad_scene.cpp
+++ b/engines/wintermute/ad/ad_scene.cpp
@@ -140,6 +140,11 @@ void AdScene::setDefaults() {
 	_editorShowEntities = true;
 	_editorShowScale    = true;
 
+#ifdef ENABLE_WME3D
+	_editorResolutionWidth = 0;
+	_editorResolutionHeight = 0;
+#endif
+
 	_shieldWindow = nullptr;
 
 	_fader = new BaseFader(_gameRef);
@@ -157,6 +162,7 @@ void AdScene::setDefaults() {
 	_2DPathfinding = false;
 	_maxShadowType = SHADOW_FLAT;
 
+	_scroll3DCompatibility = false;
 	_ambientLightColor = 0x00000000;
 
 	_fogEnabled = false;
@@ -649,7 +655,7 @@ TOKEN_DEF(NEAR_CLIPPING_PLANE) // WME3D
 TOKEN_DEF(FAR_CLIPPING_PLANE) // WME3D
 TOKEN_DEF(2D_PATHFINDING) // WME3D
 TOKEN_DEF(MAX_SHADOW_TYPE) // WME3D
-TOKEN_DEF(SCROLL_3D_COMPABILITY) // WME3D
+TOKEN_DEF(SCROLL_3D_COMPATIBILITY) // WME3D
 TOKEN_DEF(AMBIENT_LIGHT_COLOR) // WME3D
 TOKEN_DEF_END
 //////////////////////////////////////////////////////////////////////////
@@ -702,7 +708,7 @@ bool AdScene::loadBuffer(char *buffer, bool complete) {
 	TOKEN_TABLE(FAR_CLIPPING_PLANE) // WME3D
 	TOKEN_TABLE(2D_PATHFINDING) // WME3D
 	TOKEN_TABLE(MAX_SHADOW_TYPE) // WME3D
-	TOKEN_TABLE(SCROLL_3D_COMPABILITY) // WME3D
+	TOKEN_TABLE(SCROLL_3D_COMPATIBILITY) // WME3D
 	TOKEN_TABLE(AMBIENT_LIGHT_COLOR) // WME3D
 	TOKEN_TABLE_END
 
@@ -722,7 +728,9 @@ bool AdScene::loadBuffer(char *buffer, bool complete) {
 
 	int ar, ag, ab, aa;
 	char camera[MAX_PATH_LENGTH] = "";
+#ifdef ENABLE_WME3D
 	float waypointHeight = -1.0f;
+#endif
 
 	while ((cmd = parser.getCommand(&buffer, commands, &params)) > 0) {
 		switch (cmd) {
@@ -967,6 +975,14 @@ bool AdScene::loadBuffer(char *buffer, bool complete) {
 			break;
 
 #ifdef ENABLE_WME3D
+		case TOKEN_EDITOR_RESOLUTION_WIDTH:
+			parser.scanStr(params, "%d", &_editorResolutionWidth);
+			break;
+
+		case TOKEN_EDITOR_RESOLUTION_HEIGHT:
+			parser.scanStr(params, "%d", &_editorResolutionHeight);
+			break;
+
 		case TOKEN_FOV_OVERRIDE:
 			parser.scanStr(params, "%f", &_fov);
 			break;
@@ -991,8 +1007,12 @@ bool AdScene::loadBuffer(char *buffer, bool complete) {
 			int maxShadowType = SHADOW_NONE;
 			parser.scanStr(params, "%d", &maxShadowType);
 			setMaxShadowType(static_cast<TShadowType>(maxShadowType));
-		}
-		break;
+			}
+			break;
+
+		case TOKEN_SCROLL_3D_COMPATIBILITY:
+			parser.scanStr(params, "%b", &_scroll3DCompatibility);
+			break;
 
 		case TOKEN_AMBIENT_LIGHT_COLOR:
 			parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab);
@@ -1038,6 +1058,13 @@ bool AdScene::loadBuffer(char *buffer, bool complete) {
 			_sceneGeometry->render(false);
 		}
 	}
+
+	if (_mainLayer) {
+		if (_editorResolutionWidth <= 0)
+			_editorResolutionWidth = _mainLayer->_width;
+		if (_editorResolutionHeight <= 0)
+			_editorResolutionHeight = _mainLayer->_height;
+	}
 #endif
 
 	return STATUS_OK;
@@ -2766,12 +2793,17 @@ bool AdScene::saveAsText(BaseDynamicBuffer *buffer, int indent) {
 			buffer->putTextIndent(indent + 2, "2D_PATHFINDING=%s\n", "TRUE");
 
 		buffer->putTextIndent(indent + 2, "MAX_SHADOW_TYPE=%d\n", _maxShadowType);
+		if (_scroll3DCompatibility)
+			buffer->putTextIndent(indent + 2, "SCROLL_3D_COMPATIBILITY=%s\n", "TRUE");
 
 		if (_ambientLightColor != 0x00000000)
 			buffer->putTextIndent(indent + 2, "AMBIENT_LIGHT_COLOR { %d,%d,%d }\n", RGBCOLGetR(_ambientLightColor), RGBCOLGetG(_ambientLightColor), RGBCOLGetB(_ambientLightColor));
 
 		buffer->putTextIndent(indent + 2, "WAYPOINT_HEIGHT=%f\n", _sceneGeometry->_waypointHeight);
 
+		buffer->putTextIndent(indent + 2, "EDITOR_RESOLUTION_WIDTH=%d\n", _editorResolutionWidth);
+		buffer->putTextIndent(indent + 2, "EDITOR_RESOLUTION_HEIGHT=%d\n", _editorResolutionHeight);
+
 		buffer->putTextIndent(indent + 2, "\n");
 	}
 #endif
@@ -2968,6 +3000,13 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) {
 	persistMgr->transferBool(TMEMBER(_editorShowRegions));
 	persistMgr->transferBool(TMEMBER(_editorShowScale));
 	persistMgr->transferPtr(TMEMBER_PTR(_fader));
+#ifdef ENABLE_WME3D
+	if (BaseEngine::instance().getFlags() & GF_3D) {
+		persistMgr->transferPtr(TMEMBER(_sceneGeometry));
+	} else {
+		_sceneGeometry = nullptr;
+	}
+#endif
 	persistMgr->transferSint32(TMEMBER(_height));
 	persistMgr->transferBool(TMEMBER(_initialized));
 	persistMgr->transferUint32(TMEMBER(_lastTimeH));
@@ -2994,6 +3033,13 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) {
 	persistMgr->transferUint32(TMEMBER(_scrollTimeH));
 	persistMgr->transferUint32(TMEMBER(_scrollTimeV));
 	persistMgr->transferPtr(TMEMBER_PTR(_shieldWindow));
+#ifdef ENABLE_WME3D
+	if (BaseEngine::instance().getFlags() & GF_3D) {
+		persistMgr->transferBool(TMEMBER(_showGeometry));
+	} else {
+		_showGeometry = false;
+	}
+#endif
 	persistMgr->transferSint32(TMEMBER(_targetOffsetLeft));
 	persistMgr->transferSint32(TMEMBER(_targetOffsetTop));
 	_waypointGroups.persist(persistMgr);
@@ -3002,20 +3048,26 @@ bool AdScene::persist(BasePersistenceManager *persistMgr) {
 
 #ifdef ENABLE_WME3D
 	if (BaseEngine::instance().getFlags() & GF_3D) {
-		persistMgr->transferPtr(TMEMBER(_sceneGeometry));
-		persistMgr->transferBool(TMEMBER(_2DPathfinding));
-		persistMgr->transferBool(TMEMBER(_showGeometry));
+		persistMgr->transferSint32(TMEMBER(_editorResolutionWidth));
+		persistMgr->transferSint32(TMEMBER(_editorResolutionHeight));
 		persistMgr->transferFloat(TMEMBER(_fov));
 		persistMgr->transferFloat(TMEMBER(_nearPlane));
 		persistMgr->transferFloat(TMEMBER(_farPlane));
+		persistMgr->transferBool(TMEMBER(_2DPathfinding));
 		persistMgr->transferSint32(TMEMBER_INT(_maxShadowType));
+		persistMgr->transferBool(TMEMBER(_scroll3DCompatibility));
 		persistMgr->transferUint32(TMEMBER(_ambientLightColor));
 		persistMgr->transferBool(TMEMBER(_fogEnabled));
 		persistMgr->transferUint32(TMEMBER(_fogColor));
 		persistMgr->transferFloat(TMEMBER(_fogStart));
 		persistMgr->transferFloat(TMEMBER(_fogEnd));
 	} else {
-		_sceneGeometry = nullptr;
+		_editorResolutionWidth = _editorResolutionHeight = 0;
+		_fov = _nearPlane = _farPlane = -1.0f;
+		_2DPathfinding = false;
+		_maxShadowType = SHADOW_SIMPLE;
+		_scroll3DCompatibility = false;
+		_ambientLightColor = 0x00000000;
 		_fogEnabled = false;
 	}
 #endif
@@ -3028,7 +3080,6 @@ bool AdScene::afterLoad() {
 #ifdef ENABLE_WME3D
 	if (_sceneGeometry) {
 		int activeCamera = _sceneGeometry->_activeCamera;
-
 		if (activeCamera >= 0 && static_cast<uint>(activeCamera) < _sceneGeometry->_cameras.size()) {
 			_sceneGeometry->setActiveCamera(activeCamera, _fov, _nearPlane, _farPlane);
 		}
diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h
index 5e3366ec7bd..00ac465356e 100644
--- a/engines/wintermute/ad/ad_scene.h
+++ b/engines/wintermute/ad/ad_scene.h
@@ -49,30 +49,36 @@ class AdSceneGeometry;
 class AdScene : public BaseObject {
 public:
 
+#ifdef ENABLE_WME3D
+	uint32 _ambientLightColor;
+	TShadowType _maxShadowType;
+	bool _scroll3DCompatibility;
+
+	bool _fogEnabled;
+	uint32 _fogColor;
+	float _fogStart;
+	float _fogEnd;
+#endif
+
 	BaseObject *getNextAccessObject(BaseObject *currObject);
 	BaseObject *getPrevAccessObject(BaseObject *currObject);
 	bool getSceneObjects(BaseArray<AdObject *> &objects, bool interactiveOnly);
 	bool getRegionObjects(AdRegion *region, BaseArray<AdObject *> &objects, bool interactiveOnly);
 
 #ifdef ENABLE_WME3D
-	uint32 _ambientLightColor;
-	TShadowType _maxShadowType;
+	bool _2DPathfinding;
+#endif
+	bool afterLoad();
 
 	void setMaxShadowType(TShadowType shadowType);
 
-	bool _2DPathfinding;
-
-	float _fov;
+#ifdef ENABLE_WME3D
 	float _nearPlane;
 	float _farPlane;
-
-	bool _fogEnabled;
-	uint32 _fogColor;
-	float _fogStart;
-	float _fogEnd;
+	float _fov;
+	int _editorResolutionWidth;
+	int _editorResolutionHeight;
 #endif
-	bool afterLoad();
-
 	bool getRegionsAt(int x, int y, AdRegion **regionList, int numRegions);
 	bool handleItemAssociations(const char *itemName, bool show);
 	UIWindow *_shieldWindow;
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index d62e6128b9a..64a8ce1dac3 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -203,6 +203,9 @@ BaseGame::BaseGame(const Common::String &targetName) : BaseObject(this), _target
 #ifdef ENABLE_WME3D
 	_maxShadowType = SHADOW_STENCIL;
 	_supportsRealTimeShadows = false;
+
+	_editorResolutionWidth = 0;
+	_editorResolutionHeight = 0;
 #endif
 
 	_localSaveDir = "saves";
@@ -3888,6 +3891,16 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) {
 
 	_renderer->persistSaveLoadImages(persistMgr);
 
+#ifdef ENABLE_WME3D
+	if (BaseEngine::instance().getFlags() & GF_3D) {
+		persistMgr->transferSint32(TMEMBER_INT(_maxShadowType));
+		persistMgr->transferSint32(TMEMBER(_editorResolutionWidth));
+		persistMgr->transferSint32(TMEMBER(_editorResolutionHeight));
+	} else {
+		_editorResolutionWidth = _editorResolutionHeight = 0;
+	}
+#endif
+
 	persistMgr->transferSint32(TMEMBER_INT(_textEncoding));
 	persistMgr->transferBool(TMEMBER(_textRTL));
 
@@ -3913,12 +3926,6 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) {
 		_quitting = false;
 	}
 
-#ifdef ENABLE_WME3D
-	if (BaseEngine::instance().getFlags() & GF_3D) {
-		persistMgr->transferSint32(TMEMBER_INT(_maxShadowType));
-	}
-#endif
-
 	return STATUS_OK;
 }
 
@@ -4633,12 +4640,25 @@ TShadowType BaseGame::getMaxShadowType(BaseObject *object) {
 		return _maxShadowType;
 	}
 }
+#endif
 
+//////////////////////////////////////////////////////////////////////////
+bool BaseGame::getLayerSize(int *layerWidth, int *layerHeight, Rect32 *viewport, bool *customViewport) {
+	if (_renderer) {
+		*layerWidth = _renderer->getWidth();
+		*layerHeight = _renderer->getHeight();
+		*customViewport = false;
+		viewport->setRect(0, 0, _renderer->getWidth(), _renderer->getHeight());
+		return true;
+	} else
+		return false;
+}
+
+#ifdef ENABLE_WME3D
 //////////////////////////////////////////////////////////////////////////
 uint32 BaseGame::getAmbientLightColor() {
 	return 0x00000000;
 }
-
 #endif
 
 //////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h
index 442ac4596bd..648b257ed66 100644
--- a/engines/wintermute/base/base_game.h
+++ b/engines/wintermute/base/base_game.h
@@ -76,6 +76,7 @@ class BaseGame: public BaseObject {
 public:
 	DECLARE_PERSISTENT(BaseGame, BaseObject)
 
+	virtual bool getLayerSize(int *LayerWidth, int *LayerHeight, Rect32 *viewport, bool *customViewport);
 #ifdef ENABLE_WME3D
 	virtual uint32 getAmbientLightColor();
 	virtual bool getFogParams(bool *fogEnabled, uint32 *fogColor, float *start, float *end);
@@ -131,6 +132,9 @@ public:
 
 	bool setMaxShadowType(TShadowType maxShadowType);
 	virtual TShadowType getMaxShadowType(BaseObject *object = nullptr);
+
+	int _editorResolutionWidth;
+	int _editorResolutionHeight;
 #endif
 
 	uint32 getSaveThumbWidth() const { return _thumbnailWidth; }




More information about the Scummvm-git-logs mailing list