new main screen
This commit is contained in:
63
src/main.cpp
63
src/main.cpp
@ -624,7 +624,7 @@ int main(int, char **)
|
||||
// Load the new main screen overlay that sits above the background but below buttons
|
||||
int mainScreenW = 0;
|
||||
int mainScreenH = 0;
|
||||
SDL_Texture* mainScreenTex = loadTextureFromImage(renderer, "assets/images/main_screen_003.png", &mainScreenW, &mainScreenH);
|
||||
SDL_Texture* mainScreenTex = loadTextureFromImage(renderer, "assets/images/main_screen_004.png", &mainScreenW, &mainScreenH);
|
||||
if (mainScreenTex) {
|
||||
SDL_SetTextureBlendMode(mainScreenTex, SDL_BLENDMODE_BLEND);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loaded main_screen overlay %dx%d (tex=%p)", mainScreenW, mainScreenH, (void*)mainScreenTex);
|
||||
@ -1574,28 +1574,8 @@ int main(int, char **)
|
||||
} else if (state == AppState::Menu) {
|
||||
// Space flyover backdrop for the main screen
|
||||
spaceWarp.draw(renderer, 1.0f);
|
||||
|
||||
if (mainScreenTex) {
|
||||
float texW = mainScreenW > 0 ? static_cast<float>(mainScreenW) : 0.0f;
|
||||
float texH = mainScreenH > 0 ? static_cast<float>(mainScreenH) : 0.0f;
|
||||
if (texW <= 0.0f || texH <= 0.0f) {
|
||||
if (!SDL_GetTextureSize(mainScreenTex, &texW, &texH)) {
|
||||
texW = texH = 0.0f;
|
||||
}
|
||||
}
|
||||
if (texW > 0.0f && texH > 0.0f) {
|
||||
const float drawH = static_cast<float>(winH);
|
||||
const float scale = drawH / texH;
|
||||
const float drawW = texW * scale;
|
||||
SDL_FRect dst{
|
||||
(winW - drawW) * 0.5f,
|
||||
0.0f,
|
||||
drawW,
|
||||
drawH
|
||||
};
|
||||
SDL_RenderTexture(renderer, mainScreenTex, nullptr, &dst);
|
||||
}
|
||||
}
|
||||
// `mainScreenTex` is rendered as a top layer just before presenting
|
||||
// so we don't draw it here. Keep the space warp background only.
|
||||
} else if (state == AppState::LevelSelector || state == AppState::Options) {
|
||||
if (backgroundTex) {
|
||||
SDL_FRect fullRect = { 0, 0, (float)winW, (float)winH };
|
||||
@ -1927,6 +1907,43 @@ int main(int, char **)
|
||||
HelpOverlay::Render(renderer, pixelFont, LOGICAL_W, LOGICAL_H, contentOffsetX, contentOffsetY);
|
||||
}
|
||||
|
||||
// Top-layer overlay: render `mainScreenTex` above all other layers when in Menu
|
||||
if (state == AppState::Menu && mainScreenTex) {
|
||||
SDL_SetRenderViewport(renderer, nullptr);
|
||||
SDL_SetRenderScale(renderer, 1.f, 1.f);
|
||||
float texW = mainScreenW > 0 ? static_cast<float>(mainScreenW) : 0.0f;
|
||||
float texH = mainScreenH > 0 ? static_cast<float>(mainScreenH) : 0.0f;
|
||||
if (texW <= 0.0f || texH <= 0.0f) {
|
||||
float iwf = 0.0f, ihf = 0.0f;
|
||||
if (SDL_GetTextureSize(mainScreenTex, &iwf, &ihf) != 0) {
|
||||
iwf = ihf = 0.0f;
|
||||
}
|
||||
texW = iwf;
|
||||
texH = ihf;
|
||||
}
|
||||
if (texW > 0.0f && texH > 0.0f) {
|
||||
const float drawH = static_cast<float>(winH);
|
||||
const float scale = drawH / texH;
|
||||
const float drawW = texW * scale;
|
||||
SDL_FRect dst{
|
||||
(winW - drawW) * 0.5f,
|
||||
0.0f,
|
||||
drawW,
|
||||
drawH
|
||||
};
|
||||
SDL_SetTextureBlendMode(mainScreenTex, SDL_BLENDMODE_BLEND);
|
||||
SDL_RenderTexture(renderer, mainScreenTex, nullptr, &dst);
|
||||
}
|
||||
// Restore logical viewport/scale and draw the main PLAY button above the overlay
|
||||
SDL_SetRenderViewport(renderer, &logicalVP);
|
||||
SDL_SetRenderScale(renderer, logicalScale, logicalScale);
|
||||
if (menuState) {
|
||||
menuState->drawMainButtonNormally = false; // ensure it isn't double-drawn
|
||||
menuState->renderMainButtonTop(renderer, logicalScale, logicalVP);
|
||||
menuState->drawMainButtonNormally = true;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_SetRenderScale(renderer, 1.f, 1.f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user