mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-24 19:45:07 +00:00
EMI: Sort actors seperatly from invalidating the active actors list
This commit is contained in:
parent
f1c188382e
commit
7e87286cb8
@ -37,6 +37,7 @@
|
||||
#include "engines/grim/gfx_base.h"
|
||||
#include "engines/grim/model.h"
|
||||
|
||||
#include "engines/grim/emi/emi.h"
|
||||
#include "engines/grim/emi/costumeemi.h"
|
||||
#include "engines/grim/emi/skeleton.h"
|
||||
#include "engines/grim/emi/costume/emiskel_component.h"
|
||||
@ -1372,7 +1373,7 @@ void Actor::update(uint frameTime) {
|
||||
}
|
||||
if (getSortOrder() != sortorder) {
|
||||
setSortOrder(sortorder);
|
||||
g_grim->invalidateActiveActorsList();
|
||||
g_emi->invalidateSortOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace Grim {
|
||||
EMIEngine *g_emi = NULL;
|
||||
|
||||
EMIEngine::EMIEngine(OSystem *syst, uint32 gameFlags, GrimGameType gameType, Common::Platform platform, Common::Language language) :
|
||||
GrimEngine(syst, gameFlags, gameType, platform, language) {
|
||||
GrimEngine(syst, gameFlags, gameType, platform, language), _sortOrderInvalidated(false) {
|
||||
g_emi = this;
|
||||
}
|
||||
|
||||
@ -76,6 +76,7 @@ void EMIEngine::drawNormalMode() {
|
||||
|
||||
// Draw actors
|
||||
buildActiveActorsList();
|
||||
sortActiveActorsList();
|
||||
|
||||
Bitmap *background = _currSet->getCurrSetup()->_bkgndBm;
|
||||
uint32 numLayers = background->_data->_numLayers;
|
||||
@ -101,4 +102,27 @@ void EMIEngine::drawNormalMode() {
|
||||
|
||||
}
|
||||
|
||||
void EMIEngine::invalidateActiveActorsList() {
|
||||
GrimEngine::invalidateActiveActorsList();
|
||||
invalidateSortOrder();
|
||||
}
|
||||
|
||||
void EMIEngine::invalidateSortOrder() {
|
||||
_sortOrderInvalidated = true;
|
||||
}
|
||||
|
||||
bool EMIEngine::compareActor(Actor *x, Actor *y) {
|
||||
return x->getSortOrder() > y->getSortOrder();
|
||||
}
|
||||
|
||||
void EMIEngine::sortActiveActorsList() {
|
||||
if (!_sortOrderInvalidated) {
|
||||
return;
|
||||
}
|
||||
|
||||
_sortOrderInvalidated = false;
|
||||
|
||||
Common::sort(_activeActors.begin(), _activeActors.end(), compareActor);
|
||||
}
|
||||
|
||||
} // end of namespace Grim
|
||||
|
@ -28,6 +28,7 @@
|
||||
namespace Grim {
|
||||
|
||||
class TextObject;
|
||||
class Actor;
|
||||
|
||||
class EMIEngine : public GrimEngine {
|
||||
public:
|
||||
@ -37,11 +38,18 @@ public:
|
||||
void pushText(Common::List<TextObject *> *objects);
|
||||
Common::List<TextObject *> *popText();
|
||||
|
||||
void invalidateActiveActorsList() override;
|
||||
void invalidateSortOrder();
|
||||
void sortActiveActorsList();
|
||||
|
||||
private:
|
||||
LuaBase *createLua() override;
|
||||
void drawNormalMode() override;
|
||||
static bool compareActor(Actor *x, Actor *y);
|
||||
|
||||
Common::List<Common::List<TextObject *> *> _textstack;
|
||||
|
||||
bool _sortOrderInvalidated;
|
||||
};
|
||||
|
||||
extern EMIEngine *g_emi;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "engines/grim/costume.h"
|
||||
#include "engines/grim/costume/chore.h"
|
||||
|
||||
#include "engines/grim/emi/emi.h"
|
||||
#include "engines/grim/emi/costumeemi.h"
|
||||
#include "engines/grim/emi/skeleton.h"
|
||||
#include "engines/grim/emi/costume/emiskel_component.h"
|
||||
@ -331,6 +332,8 @@ void Lua_V2::SetActorSortOrder() {
|
||||
Actor *actor = getactor(actorObj);
|
||||
int order = (int)lua_getnumber(orderObj);
|
||||
actor->setSortOrder(order);
|
||||
|
||||
g_emi->invalidateSortOrder();
|
||||
}
|
||||
|
||||
void Lua_V2::GetActorSortOrder() {
|
||||
|
@ -1139,16 +1139,7 @@ void GrimEngine::buildActiveActorsList() {
|
||||
_activeActors.clear();
|
||||
foreach (Actor *a, Actor::getPool()) {
|
||||
if ((_mode == NormalMode && a->isInSet(_currSet->getName())) || a->isInOverworld()) {
|
||||
if (getGameType() == GType_MONKEY4) {
|
||||
Common::List<Actor *>::iterator it = _activeActors.begin();
|
||||
for (; it != _activeActors.end(); ++it) {
|
||||
if (a->getSortOrder() >= (*it)->getSortOrder())
|
||||
break;
|
||||
}
|
||||
_activeActors.insert(it, a);
|
||||
} else {
|
||||
_activeActors.push_back(a);
|
||||
}
|
||||
_activeActors.push_back(a);
|
||||
}
|
||||
}
|
||||
_buildActiveActorsList = false;
|
||||
|
@ -153,7 +153,7 @@ public:
|
||||
* Tell the engine that an actor has been moved into/outside a set,
|
||||
* and so that it should rebuild the list of active ones.
|
||||
*/
|
||||
void invalidateActiveActorsList();
|
||||
virtual void invalidateActiveActorsList();
|
||||
/**
|
||||
* Return a list of the currently active actors, i. e. the actors in the current set.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user