mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Fixed ScrollableContainer clipping.
Changed game select effect to interpolate more interestingly.
This commit is contained in:
parent
541d9a62d1
commit
55b71fab49
|
@ -78,6 +78,7 @@ Font::Font(const ResourceManager& rm, const std::string& path, int size) : fontS
|
||||||
|
|
||||||
Font::~Font()
|
Font::~Font()
|
||||||
{
|
{
|
||||||
|
LOG(LogInfo) << "Destroying font \"" << mPath << "\" with size " << mSize << ".";
|
||||||
deinit();
|
deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,14 +239,14 @@ void Font::buildAtlas(ResourceData data)
|
||||||
if((y + maxHeight) >= textureHeight)
|
if((y + maxHeight) >= textureHeight)
|
||||||
{
|
{
|
||||||
//failed to create a proper font texture
|
//failed to create a proper font texture
|
||||||
LOG(LogWarning) << "Font with size " << mSize << " exceeded max texture size! Trying again...";
|
LOG(LogWarning) << "Font \"" << mPath << "\" with size " << mSize << " exceeded max texture size! Trying again...";
|
||||||
//try a 3/4th smaller size and redo initialization
|
//try a 3/4th smaller size and redo initialization
|
||||||
fontScale *= 1.25f;
|
fontScale *= 1.25f;
|
||||||
mSize = (int)(mSize * (1.0f / fontScale));
|
mSize = (int)(mSize * (1.0f / fontScale));
|
||||||
deinit();
|
deinit();
|
||||||
init(data);
|
init(data);
|
||||||
}else{
|
}else{
|
||||||
LOG(LogInfo) << "Created font with size " << mSize << ".";
|
LOG(LogInfo) << "Created font \"" << mPath << "\" with size " << mSize << ".";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,15 +442,35 @@ Eigen::Vector2f lerpVector2f(const Eigen::Vector2f& start, const Eigen::Vector2f
|
||||||
return (start * (1 - t) + end * t);
|
return (start * (1 - t) + end * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float clamp(float min, float max, float val)
|
||||||
|
{
|
||||||
|
if(val < min)
|
||||||
|
val = min;
|
||||||
|
else if(val > max)
|
||||||
|
val = max;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
//http://en.wikipedia.org/wiki/Smoothstep
|
||||||
|
float smoothStep(float edge0, float edge1, float x)
|
||||||
|
{
|
||||||
|
// Scale, and clamp x to 0..1 range
|
||||||
|
x = clamp(0, 1, (x - edge0)/(edge1 - edge0));
|
||||||
|
|
||||||
|
// Evaluate polynomial
|
||||||
|
return x*x*x*(x*(x*6 - 15) + 10);
|
||||||
|
}
|
||||||
|
|
||||||
void GuiGameList::updateGameLaunchEffect(int t)
|
void GuiGameList::updateGameLaunchEffect(int t)
|
||||||
{
|
{
|
||||||
const int endTime = mGameLaunchEffectLength;
|
const int endTime = mGameLaunchEffectLength;
|
||||||
|
|
||||||
const int zoomTime = endTime;
|
const int zoomTime = endTime;
|
||||||
const int centerTime = endTime - 100;
|
const int centerTime = endTime - 50;
|
||||||
|
|
||||||
const int fadeDelay = endTime - 500;
|
const int fadeDelay = endTime - 600;
|
||||||
const int fadeTime = endTime - fadeDelay;
|
const int fadeTime = endTime - fadeDelay - 100;
|
||||||
|
|
||||||
Eigen::Vector2f imageCenter(mScreenshot.getCenter());
|
Eigen::Vector2f imageCenter(mScreenshot.getCenter());
|
||||||
if(!isDetailed())
|
if(!isDetailed())
|
||||||
|
@ -460,8 +480,11 @@ void GuiGameList::updateGameLaunchEffect(int t)
|
||||||
|
|
||||||
const Eigen::Vector2f centerStart(Renderer::getScreenWidth() / 2, Renderer::getScreenHeight() / 2);
|
const Eigen::Vector2f centerStart(Renderer::getScreenWidth() / 2, Renderer::getScreenHeight() / 2);
|
||||||
|
|
||||||
mWindow->setCenterPoint(lerpVector2f(centerStart, imageCenter, (float)t / endTime));
|
//remember to clamp or zoom factor will be incorrect with a negative t because squared
|
||||||
mWindow->setZoomFactor(lerpFloat(1.0f, 2.0f, (float)t / endTime));
|
const float tNormalized = clamp(0, 1, (float)t / endTime);
|
||||||
|
|
||||||
|
mWindow->setCenterPoint(lerpVector2f(centerStart, imageCenter, smoothStep(0.0, 1.0, tNormalized)));
|
||||||
|
mWindow->setZoomFactor(lerpFloat(1.0f, 3.0f, tNormalized*tNormalized));
|
||||||
mWindow->setFadePercent(lerpFloat(0.0f, 1.0f, (float)(t - fadeDelay) / fadeTime));
|
mWindow->setFadePercent(lerpFloat(0.0f, 1.0f, (float)(t - fadeDelay) / fadeTime));
|
||||||
|
|
||||||
if(t > endTime)
|
if(t > endTime)
|
||||||
|
|
|
@ -12,7 +12,9 @@ void ScrollableContainer::render(const Eigen::Affine3f& parentTrans)
|
||||||
Eigen::Affine3f trans = parentTrans * getTransform();
|
Eigen::Affine3f trans = parentTrans * getTransform();
|
||||||
|
|
||||||
Eigen::Vector2i clipPos((int)trans.translation().x(), (int)trans.translation().y());
|
Eigen::Vector2i clipPos((int)trans.translation().x(), (int)trans.translation().y());
|
||||||
Eigen::Vector2i clipDim((int)mSize.x(), (int)mSize.y());
|
|
||||||
|
Eigen::Vector3f dimScaled = trans * Eigen::Vector3f(mSize.x(), mSize.y(), 0);
|
||||||
|
Eigen::Vector2i clipDim((int)dimScaled.x() - trans.translation().x(), (int)dimScaled.y() - trans.translation().y());
|
||||||
|
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,10 @@ int main(int argc, char* argv[])
|
||||||
int deltaTime = curTime - lastTime;
|
int deltaTime = curTime - lastTime;
|
||||||
lastTime = curTime;
|
lastTime = curTime;
|
||||||
|
|
||||||
|
//cap deltaTime at 1000
|
||||||
|
if(deltaTime > 1000 || deltaTime < 0)
|
||||||
|
deltaTime = 1000;
|
||||||
|
|
||||||
window.update(deltaTime);
|
window.update(deltaTime);
|
||||||
Renderer::swapBuffers(); //swap here so we can read the last screen state during updates (see ImageComponent::copyScreen())
|
Renderer::swapBuffers(); //swap here so we can read the last screen state during updates (see ImageComponent::copyScreen())
|
||||||
window.render();
|
window.render();
|
||||||
|
|
Loading…
Reference in a new issue