latest state
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include "../core/Settings.h"
|
||||
#include "../graphics/renderers/UIRenderer.h"
|
||||
|
||||
OptionsState::OptionsState(StateContext& ctx) : State(ctx) {}
|
||||
|
||||
@ -89,32 +90,17 @@ void OptionsState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
||||
|
||||
float winW = static_cast<float>(logicalVP.w);
|
||||
float winH = static_cast<float>(logicalVP.h);
|
||||
float contentW = LOGICAL_W * logicalScale;
|
||||
float contentH = LOGICAL_H * logicalScale;
|
||||
float contentOffsetX = (winW - contentW) * 0.5f / logicalScale;
|
||||
float contentOffsetY = (winH - contentH) * 0.5f / logicalScale;
|
||||
float contentOffsetX = 0.0f;
|
||||
float contentOffsetY = 0.0f;
|
||||
UIRenderer::computeContentOffsets(winW, winH, LOGICAL_W, LOGICAL_H, logicalScale, contentOffsetX, contentOffsetY);
|
||||
|
||||
SDL_Texture* logoTexture = ctx.logoSmallTex ? ctx.logoSmallTex : ctx.logoTex;
|
||||
if (logoTexture) {
|
||||
float texW = 0.0f;
|
||||
float texH = 0.0f;
|
||||
if (logoTexture == ctx.logoSmallTex && ctx.logoSmallW > 0 && ctx.logoSmallH > 0) {
|
||||
texW = static_cast<float>(ctx.logoSmallW);
|
||||
texH = static_cast<float>(ctx.logoSmallH);
|
||||
} else {
|
||||
SDL_GetTextureSize(logoTexture, &texW, &texH);
|
||||
}
|
||||
if (texW > 0.0f && texH > 0.0f) {
|
||||
float maxWidth = LOGICAL_W * 0.6f;
|
||||
float scale = std::min(1.0f, maxWidth / texW);
|
||||
float dw = texW * scale;
|
||||
float dh = texH * scale;
|
||||
float logoX = (LOGICAL_W - dw) * 0.5f + contentOffsetX;
|
||||
float logoY = LOGICAL_H * 0.05f + contentOffsetY;
|
||||
SDL_FRect dst{logoX, logoY, dw, dh};
|
||||
SDL_RenderTexture(renderer, logoTexture, nullptr, &dst);
|
||||
}
|
||||
int logoW = 0, logoH = 0;
|
||||
if (logoTexture == ctx.logoSmallTex && ctx.logoSmallW > 0) {
|
||||
logoW = ctx.logoSmallW;
|
||||
logoH = ctx.logoSmallH;
|
||||
}
|
||||
UIRenderer::drawLogo(renderer, logoTexture, LOGICAL_W, LOGICAL_H, contentOffsetX, contentOffsetY, logoW, logoH);
|
||||
|
||||
const float panelW = 520.0f;
|
||||
const float panelH = 420.0f;
|
||||
@ -125,23 +111,7 @@ void OptionsState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
||||
panelH
|
||||
};
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Panel styling similar to level selector
|
||||
SDL_FRect shadow{panel.x + 6.0f, panel.y + 10.0f, panel.w, panel.h};
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 120);
|
||||
SDL_RenderFillRect(renderer, &shadow);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
SDL_FRect glow{panel.x - float(i * 2), panel.y - float(i * 2), panel.w + float(i * 4), panel.h + float(i * 4)};
|
||||
SDL_SetRenderDrawColor(renderer, 0, 180, 255, Uint8(42 - i * 8));
|
||||
SDL_RenderRect(renderer, &glow);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 18, 30, 52, 255);
|
||||
SDL_RenderFillRect(renderer, &panel);
|
||||
SDL_SetRenderDrawColor(renderer, 70, 120, 210, 255);
|
||||
SDL_RenderRect(renderer, &panel);
|
||||
UIRenderer::drawSciFiPanel(renderer, panel);
|
||||
|
||||
FontAtlas* retroFont = ctx.pixelFont ? ctx.pixelFont : ctx.font;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user