mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
fix gem scaling, attempt #2
This sort-of-reverts 4a71c5e12f
and fixes overlooked cases
This commit is contained in:
parent
da7cd05ffa
commit
5516c89576
2 changed files with 27 additions and 30 deletions
|
@ -262,8 +262,6 @@ public:
|
||||||
position = tc ? tc->worldPosToTilePos(gemData->pos) : gemData->pos;
|
position = tc ? tc->worldPosToTilePos(gemData->pos) : gemData->pos;
|
||||||
text->setText(gemData->userString);
|
text->setText(gemData->userString);
|
||||||
textBG->setWidthHeight(text->getActualWidth() + 20, 25, 10);
|
textBG->setWidthHeight(text->getActualWidth() + 20, 25, 10);
|
||||||
|
|
||||||
this->update(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy()
|
void destroy()
|
||||||
|
@ -294,6 +292,29 @@ protected:
|
||||||
{
|
{
|
||||||
Quad::onUpdate(dt);
|
Quad::onUpdate(dt);
|
||||||
|
|
||||||
|
// Make sure ALL gems always have the same size no matter the container's scale.
|
||||||
|
// This is a bit nasty because some gems have the world map surface as parent (where gemData->global),
|
||||||
|
// while the map-local gems have their map tile as parent.
|
||||||
|
// So for scaling them properly, make sure the tile scale factor cancels out while normalizing the scale.
|
||||||
|
|
||||||
|
float invparent = gemData->global ? 1.0f : 1.0f / parent->scale.x; // factor used to cancel out parent tile scaling, if the parent is a tile.
|
||||||
|
float sz = parent->getRealScale().x;
|
||||||
|
|
||||||
|
sz *= invparent;
|
||||||
|
|
||||||
|
if (sz < zoomMin)
|
||||||
|
sz = zoomMin;
|
||||||
|
if (sz > zoomMax)
|
||||||
|
sz = zoomMax;
|
||||||
|
|
||||||
|
sz = sz < 1.0f ? 1.0f : 1.0f / sz;
|
||||||
|
|
||||||
|
sz *= invparent;
|
||||||
|
|
||||||
|
scale.x = sz;
|
||||||
|
scale.y = sz;
|
||||||
|
|
||||||
|
|
||||||
Vector wp = getWorldPosition();
|
Vector wp = getWorldPosition();
|
||||||
|
|
||||||
if (gemData->blink)
|
if (gemData->blink)
|
||||||
|
@ -1154,7 +1175,10 @@ void WorldMapRender::toggle(bool turnON)
|
||||||
addHintQuads[i]->alpha.interpolateTo(1.0f, 0.2f);
|
addHintQuads[i]->alpha.interpolateTo(1.0f, 0.2f);
|
||||||
|
|
||||||
assert(gemMovers.empty());
|
assert(gemMovers.empty());
|
||||||
for (Continuity::Gems::iterator i = dsq->continuity.gems.begin(); i != dsq->continuity.gems.end(); i++)
|
|
||||||
|
// I'm not sure why this is all backwards but i'm thinking that it's because the naija gem should always be on top,
|
||||||
|
// and since it's the very first one in the list that adds it last, ie. on top of everything else.
|
||||||
|
for (Continuity::Gems::reverse_iterator i = dsq->continuity.gems.rbegin(); i != dsq->continuity.gems.rend(); i++)
|
||||||
addGem(&(*i));
|
addGem(&(*i));
|
||||||
|
|
||||||
for (Continuity::Beacons::reverse_iterator i = dsq->continuity.beacons.rbegin(); i != dsq->continuity.beacons.rend(); i++)
|
for (Continuity::Beacons::reverse_iterator i = dsq->continuity.beacons.rbegin(); i != dsq->continuity.beacons.rend(); i++)
|
||||||
|
@ -1373,30 +1397,6 @@ GemMover* WorldMapTileContainer::getGem(const GemData* gemData) const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldMapTileContainer::updateGems()
|
|
||||||
{
|
|
||||||
// Make sure the gems always have the same size no matter the container's scale
|
|
||||||
// -> bypass this, go directly to parent
|
|
||||||
float sz = parent->scale.x;
|
|
||||||
|
|
||||||
if (sz < zoomMin)
|
|
||||||
sz = zoomMin;
|
|
||||||
if (sz > zoomMax)
|
|
||||||
sz = zoomMax;
|
|
||||||
|
|
||||||
sz = sz < 1.0f ? 1.0f : 1.0f / sz;
|
|
||||||
|
|
||||||
for(size_t i = 0; i < gems.size(); ++i)
|
|
||||||
{
|
|
||||||
Quad *q = gems[i];
|
|
||||||
|
|
||||||
q->scale.x = sz;
|
|
||||||
q->scale.y = sz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector WorldMapTileContainer::worldPosToTilePos(const Vector& position) const
|
Vector WorldMapTileContainer::worldPosToTilePos(const Vector& position) const
|
||||||
{
|
{
|
||||||
// Notes: TILE_SIZE in the world is 1 pixel in the map template png.
|
// Notes: TILE_SIZE in the world is 1 pixel in the map template png.
|
||||||
|
@ -1429,7 +1429,5 @@ void WorldMapTileContainer::onUpdate(float dt)
|
||||||
q.scale.y = tile.scale * tileScaleFactor;
|
q.scale.y = tile.scale * tileScaleFactor;
|
||||||
q.renderQuad = tile.revealed || tile.prerevealed;
|
q.renderQuad = tile.revealed || tile.prerevealed;
|
||||||
|
|
||||||
updateGems();
|
|
||||||
|
|
||||||
RenderObject::onUpdate(dt);
|
RenderObject::onUpdate(dt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
bool removeGem(GemMover *gem);
|
bool removeGem(GemMover *gem);
|
||||||
GemMover *removeGem(const GemData *gem);
|
GemMover *removeGem(const GemData *gem);
|
||||||
GemMover *getGem(const GemData *gemData) const;
|
GemMover *getGem(const GemData *gemData) const;
|
||||||
void updateGems();
|
|
||||||
|
|
||||||
Vector worldPosToTilePos(const Vector& p) const;
|
Vector worldPosToTilePos(const Vector& p) const;
|
||||||
Vector worldPosToMapPos(const Vector& p) const;
|
Vector worldPosToMapPos(const Vector& p) const;
|
||||||
|
|
Loading…
Reference in a new issue