mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 18:06:26 +00:00
TETRAEDGE: Implement updateScroll and updateViewport for Syberia 2
This commit is contained in:
parent
50d4766109
commit
ae5d052ce2
@ -328,6 +328,7 @@ bool Application::run() {
|
||||
|
||||
renderer->reset();
|
||||
game->update();
|
||||
game->scene().updateScroll();
|
||||
g_engine->getSoundManager()->update();
|
||||
performRender();
|
||||
if (game->_returnToMainMenu) {
|
||||
@ -352,7 +353,6 @@ bool Application::run() {
|
||||
}
|
||||
_finishedGame = false;
|
||||
}
|
||||
InGameScene::updateScroll();
|
||||
TeObject::deleteNow();
|
||||
}
|
||||
return true;
|
||||
|
@ -67,7 +67,8 @@ const float InGameScene::DEPTH_MAX_FLAKE = 0.1;
|
||||
|
||||
InGameScene::InGameScene() : _character(nullptr), _charactersShadow(nullptr),
|
||||
_shadowLightNo(-1), _waitTime(-1.0f), _shadowColor(0, 0, 0, 0x80), _shadowFov(20.0f),
|
||||
_shadowFarPlane(1000), _shadowNearPlane(1), _maskAlpha(false) {
|
||||
_shadowFarPlane(1000), _shadowNearPlane(1), _maskAlpha(false),
|
||||
_verticalScrollTime(1000000.0f), _verticalScrollPlaying(false) {
|
||||
}
|
||||
|
||||
void InGameScene::activateAnchorZone(const Common::String &name, bool val) {
|
||||
@ -588,7 +589,7 @@ Common::String InGameScene::imagePathMarker(const Common::String &name) {
|
||||
}
|
||||
|
||||
void InGameScene::initScroll() {
|
||||
_someScrollVector = TeVector2f32(0.5f, 0.0f);
|
||||
_scrollOffset = TeVector2f32(0.5f, 0.0f);
|
||||
}
|
||||
|
||||
bool InGameScene::isMarker(const Common::String &name) {
|
||||
@ -607,6 +608,21 @@ bool InGameScene::isObjectBlocking(const Common::String &name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TeVector2f32 InGameScene::layerSize() {
|
||||
TeLayout *bglayout = _bgGui.layout("background");
|
||||
TeVector3f32 sz;
|
||||
if (bglayout) {
|
||||
TeLayout *rootlayout = Game::findSpriteLayoutByName(bglayout, "root");
|
||||
if (!rootlayout)
|
||||
error("InGameScene::layerSize: No root layout inside the background");
|
||||
sz = rootlayout->size();
|
||||
_scrollScale = TeVector2f32(sz.x(), sz.y());
|
||||
} else {
|
||||
sz = g_engine->getApplication()->getMainWindow().size();
|
||||
}
|
||||
return TeVector2f32(sz.x(), sz.y());
|
||||
}
|
||||
|
||||
bool InGameScene::load(const Common::FSNode &sceneNode) {
|
||||
// Syberia 1 has loadActZones function contents inline.
|
||||
loadActZones();
|
||||
@ -1322,6 +1338,14 @@ TeFreeMoveZone *InGameScene::pathZone(const Common::String &name) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void InGameScene::playVerticalScrolling(float time) {
|
||||
_verticalScrollTimer.start();
|
||||
_verticalScrollTimer.stop();
|
||||
_verticalScrollTimer.start();
|
||||
_verticalScrollTime = time * 1000000.0f;
|
||||
_verticalScrollPlaying = true;
|
||||
}
|
||||
|
||||
void InGameScene::reset() {
|
||||
for (auto *character : _characters)
|
||||
character->setFreeMoveZone(nullptr);
|
||||
@ -1422,7 +1446,7 @@ void InGameScene::unloadCharacter(const Common::String &name) {
|
||||
_character->deleteAnim();
|
||||
_character->deleteAllCallback();
|
||||
if (_character->_model->anim())
|
||||
_character->_model->anim()->stop(); // TODO: added this
|
||||
_character->_model->anim()->stop(); // TODO: added this
|
||||
_character->setFreeMoveZone(nullptr); // TODO: added this
|
||||
// TODO: deleteLater() something here..
|
||||
_character = nullptr;
|
||||
@ -1570,6 +1594,52 @@ void InGameScene::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void InGameScene::updateScroll() {
|
||||
if (g_engine->gameType() != TetraedgeEngine::kSyberia2)
|
||||
return;
|
||||
|
||||
TeLayout *bg = _bgGui.layout("background");
|
||||
if (!bg)
|
||||
return;
|
||||
|
||||
TeSpriteLayout *root = Game::findSpriteLayoutByName(bg, "root");
|
||||
if (!root)
|
||||
error("No root layout in the background");
|
||||
_scrollOffset = TeVector2f32();
|
||||
TeVector2s32 texSize = root->_tiledSurfacePtr->tiledTexture()->totalSize();
|
||||
if (texSize._x < 801) {
|
||||
if (texSize._y < 601) {
|
||||
_scrollOffset = TeVector2f32(0.5f, 0.0f);
|
||||
updateViewport(0);
|
||||
} else {
|
||||
// TODO: update stuff here.
|
||||
}
|
||||
} else {
|
||||
// TODO: update stuff here.
|
||||
}
|
||||
}
|
||||
|
||||
void InGameScene::updateViewport(int ival) {
|
||||
TeVector2f32 lsize = layerSize();
|
||||
TeVector2f32 offset((0.5f - _scrollOffset.getX()) * _scrollScale.getX(),
|
||||
_scrollOffset.getY() * _scrollScale.getY());
|
||||
TeVector3f32 winSize = g_engine->getApplication()->getMainWindow().size();
|
||||
for (auto cam : cameras()) {
|
||||
//cam->setSomething(ival);
|
||||
int x = (winSize.x() - lsize.getX()) / 2.0f + offset.getX();
|
||||
int y = (winSize.y() - lsize.getY()) / 2.0f;
|
||||
int width = lsize.getX();
|
||||
int height = lsize.getY();
|
||||
cam->viewport(x, y, width, height);
|
||||
float aspectRatio = lsize.getX() / lsize.getY();
|
||||
/* TODO: Handle ratioStretched
|
||||
if (g_engine->getApplication()->_ratioStretched) {
|
||||
aspectRatio = (aspectRatio / (winSize.x() / winSize.y())) * 1.333333f;
|
||||
} */
|
||||
cam->setAspectRatio(aspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
void InGameScene::activateMask(const Common::String &name, bool val) {
|
||||
for (auto mask : _masks) {
|
||||
if (mask->name() == name) {
|
||||
|
@ -215,6 +215,7 @@ public:
|
||||
Object3D *object3D(const Common::String &oname);
|
||||
void onMainWindowSizeChanged();
|
||||
TeFreeMoveZone *pathZone(const Common::String &zname);
|
||||
void playVerticalScrolling(float time);
|
||||
TeVector3f32 positionMarker(const Common::String &mname);
|
||||
void removeBlockingObject(const Common::String &oname);
|
||||
|
||||
@ -233,8 +234,8 @@ public:
|
||||
void update() override;
|
||||
|
||||
// Does nothing, but to keep calls from original..
|
||||
static void updateScroll() {};
|
||||
static void updateViewport() {};
|
||||
void updateScroll();
|
||||
void updateViewport(int ival);
|
||||
|
||||
Character *_character;
|
||||
Common::Array<Character *> _characters;
|
||||
@ -317,7 +318,8 @@ private:
|
||||
|
||||
Common::Array<Common::SharedPtr<TeLight>> _lights;
|
||||
|
||||
TeVector2f32 _someScrollVector;
|
||||
TeVector2f32 _scrollOffset;
|
||||
TeVector2f32 _scrollScale;
|
||||
TeVector2f32 _viewportSize;
|
||||
|
||||
Common::Path _loadedPath;
|
||||
@ -328,7 +330,9 @@ private:
|
||||
Common::String _zoneName;
|
||||
bool _maskAlpha;
|
||||
YoukiManager _youkiManager;
|
||||
|
||||
TeTimer _verticalScrollTimer;
|
||||
float _verticalScrollTime;
|
||||
bool _verticalScrollPlaying;
|
||||
};
|
||||
|
||||
} // end namespace Tetraedge
|
||||
|
@ -2511,6 +2511,20 @@ static int tolua_ExportedFunctions_RemoveRandomSound00(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void PlayVerticalScrolling(float time) {
|
||||
g_engine->getGame()->scene().playVerticalScrolling(time);
|
||||
}
|
||||
|
||||
static int tolua_ExportedFunctions_PlayVerticalScrolling00(lua_State *L) {
|
||||
tolua_Error err;
|
||||
if (tolua_isnumber(L, 1, 0, &err) && tolua_isnoobj(L, 2, &err)) {
|
||||
float f1 = tolua_tonumber(L, 1, 0.0);
|
||||
PlayVerticalScrolling(f1);
|
||||
return 0;
|
||||
}
|
||||
error("#ferror in function 'SetObjectMoveTime': %d %d %s", err.index, err.array, err.type);
|
||||
}
|
||||
|
||||
// Not your imagination, the implementation of these two is quite different to the others.
|
||||
static int tolua_GetParticleIndex(lua_State *L) {
|
||||
Common::String s1(tolua_tostring(L, 1, nullptr));
|
||||
@ -2704,12 +2718,10 @@ void LuaOpenBinds(lua_State *L) {
|
||||
tolua_function(L, "PlaySnowCustom", tolua_ExportedFunctions_PlaySnowCustom00);
|
||||
tolua_function(L, "SnowCustomVisible", tolua_ExportedFunctions_SnowCustomVisible00);
|
||||
tolua_function(L, "RemoveRandomSound", tolua_ExportedFunctions_RemoveRandomSound00);
|
||||
tolua_function(L, "PlayVerticalScrolling", tolua_ExportedFunctions_PlayVerticalScrolling00);
|
||||
tolua_function(L, "GetParticleIndex", tolua_GetParticleIndex);
|
||||
tolua_function(L, "EnableParticle", tolua_EnableParticle);
|
||||
|
||||
// TODO Syberia 2 functions..
|
||||
//tolua_function(L, "PlayVerticalScrolling", tolua_ExportedFunctions_PlayVerticalScrolling00);
|
||||
|
||||
tolua_endmodule(L);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user