1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

More fixes for breakage introduced in 70b8dcdc3a:

- fix typo that broke repeat-scale loading
- fix broken tile effects loading
- fix randomly shuffled world map tiles (as textures were loaded in a random order)
- reload tileset on editor reload (because we want to edit textures duh)
This commit is contained in:
fgenesis 2023-06-02 01:32:37 +02:00
parent 478857f149
commit 825670f651
4 changed files with 19 additions and 6 deletions

View file

@ -227,6 +227,7 @@ Game::Game() : StateObject()
cookingScript = 0; cookingScript = 0;
doScreenTrans = false; doScreenTrans = false;
noSceneTransitionFadeout = false; noSceneTransitionFadeout = false;
fullTilesetReload = false;
} }
Game::~Game() Game::~Game()
@ -1725,7 +1726,7 @@ bool Game::loadSceneXML(std::string scene)
struct ElementDef struct ElementDef
{ {
ElementDef(int lr) ElementDef(int lr)
: layer(lr), idx(0), x(0), y(0), rot(0), fh(0), fv(0), flags(0), efxIdx(0), repeat(0) : layer(lr), idx(0), x(0), y(0), rot(0), fh(0), fv(0), flags(0), efxIdx(-1), repeat(0)
, tag(0), sx(1), sy(1), rsx(1), rsy(1) , tag(0), sx(1), sy(1), rsx(1), rsy(1)
{} {}
@ -1838,7 +1839,7 @@ bool Game::loadSceneXML(std::string scene)
ElementDef& d = elemsDefs[i]; ElementDef& d = elemsDefs[i];
if(d.repeat) if(d.repeat)
{ {
if(!(is >> d.rsx >> d.rsx)) if(!(is >> d.rsx >> d.rsy))
break; break;
} }
} }
@ -1856,6 +1857,14 @@ bool Game::loadSceneXML(std::string scene)
simpleElements = simpleElements->NextSiblingElement("SE"); simpleElements = simpleElements->NextSiblingElement("SE");
} }
if(fullTilesetReload)
{
fullTilesetReload = false;
// used by SceneEditor
// no elements exist right now -> textures will be cleared and reloaded
dsq->texmgr.clearUnused();
}
// figure out which textures in the tileset are used and preload those that are actually used // figure out which textures in the tileset are used and preload those that are actually used
{ {
unsigned char usedIdx[1024] = {0}; unsigned char usedIdx[1024] = {0};
@ -1904,8 +1913,7 @@ bool Game::loadSceneXML(std::string scene)
e->rotation.z = d.rot; e->rotation.z = d.rot;
e->repeatToFillScale.x = d.rsx; e->repeatToFillScale.x = d.rsx;
e->repeatToFillScale.y = d.rsy; e->repeatToFillScale.y = d.rsy;
if(d.efxIdx) e->setElementEffectByIndex(d.efxIdx);
e->setElementEffectByIndex(d.efxIdx);
if (d.repeat) if (d.repeat)
e->repeatTextureToFill(true); // also applies repeatToFillScale e->repeatTextureToFill(true); // also applies repeatToFillScale
e->setTag(d.tag); e->setTag(d.tag);

View file

@ -350,6 +350,7 @@ public:
bool loadingScene; bool loadingScene;
bool doScreenTrans; bool doScreenTrans;
bool noSceneTransitionFadeout; bool noSceneTransitionFadeout;
bool fullTilesetReload;
WaterSurfaceRender *waterSurfaceRender; WaterSurfaceRender *waterSurfaceRender;

View file

@ -1817,6 +1817,7 @@ void SceneEditor::loadSceneByName()
if (!s.empty()) if (!s.empty())
{ {
game->noSceneTransitionFadeout = true; game->noSceneTransitionFadeout = true;
game->fullTilesetReload = true;
game->transitionToScene(s); game->transitionToScene(s);
} }
} }
@ -1825,6 +1826,7 @@ void SceneEditor::reloadScene()
{ {
debugLog("reloadScene"); debugLog("reloadScene");
game->noSceneTransitionFadeout = true; game->noSceneTransitionFadeout = true;
game->fullTilesetReload = true;
game->positionToAvatar = game->avatar->position; game->positionToAvatar = game->avatar->position;
game->transitionToScene(game->sceneName); game->transitionToScene(game->sceneName);
} }

View file

@ -8,13 +8,14 @@
struct TexLoadTmp struct TexLoadTmp
{ {
TexLoadTmp() : loadmode(TextureMgr::KEEP), curTex(NULL), success(false) { img.pixels = NULL; } TexLoadTmp() : loadmode(TextureMgr::KEEP), curTex(NULL), success(false), arrayidx(0) { img.pixels = NULL; }
std::string name, filename; std::string name, filename;
ImageData img; ImageData img;
TextureMgr::LoadMode loadmode; TextureMgr::LoadMode loadmode;
Texture *curTex; // immutable Texture *curTex; // immutable
bool success; // if this is true and img.pixels is NULL, don't change anything bool success; // if this is true and img.pixels is NULL, don't change anything
//bool mipmap; //bool mipmap;
size_t arrayidx;
}; };
typedef ImageData (*ImageLoadFunc)(const char *fn); typedef ImageData (*ImageLoadFunc)(const char *fn);
@ -289,6 +290,7 @@ void TextureMgr::loadBatch(Texture * pdst[], const std::string texnames[], size_
for(size_t i = 0; i < n; ++i) for(size_t i = 0; i < n; ++i)
{ {
TexLoadTmp& tt = tmp[i]; TexLoadTmp& tt = tmp[i];
tt.arrayidx = i;
tt.name = texnames[i]; tt.name = texnames[i];
stringToLower(tt.name); stringToLower(tt.name);
TexCache::iterator it = cache.find(tt.name); TexCache::iterator it = cache.find(tt.name);
@ -315,7 +317,7 @@ void TextureMgr::loadBatch(Texture * pdst[], const std::string texnames[], size_
TexLoadTmp& tt = *(TexLoadTmp*)p; TexLoadTmp& tt = *(TexLoadTmp*)p;
Texture *tex = finalize(tt); Texture *tex = finalize(tt);
if(pdst) if(pdst)
pdst[i] = tex; pdst[tt.arrayidx] = tex;
if(cb) if(cb)
cb(++doneCB, cbUD); cb(++doneCB, cbUD);
} }