Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
8 changes: 6 additions & 2 deletions include/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Audio : public Module
void SetMusicVolume(float volume); // 0.0f - 1.0f
void SetSFXVolume(float volume); // 0.0f - 1.0f

void PauseMusic();
void ResumeMusic();

private:

struct SoundData {
Expand All @@ -64,8 +67,9 @@ class Audio : public Module
std::vector<SoundData> sfx_; // 1-based indexing outwardly

// Volume control
float music_volume_ = 1.0f; // 0.0 = mute, 1.0 = full
float sfx_volume_ = 1.0f;
float music_volume_{ 0.5f };
float sfx_volume_{ 0.5f };
bool musicPaused_{ false };

// helpers
bool LoadWavFile(const char* path, SoundData& out);
Expand Down
2 changes: 1 addition & 1 deletion include/Render.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Render : public Module
bool DrawTextureAlphaF(SDL_Texture* texture, float x, float y, float w, float h, Uint8 alpha = 255) const;
bool DrawMenuText(const char* text, int x, int y, int w, int h, SDL_Color color) const;
bool DrawMenuTextCentered(const char* text, SDL_Rect area, SDL_Color color) const;
bool DrawMenuTextCentered(const char* text, SDL_Rect area, SDL_Color color, float textScale) const;
bool DrawMenuTextCentered(const char* text, SDL_Rect area, SDL_Color color, float textScale, bool shrinkToFit = false) const;
SDL_Texture* CreateMenuTextTexture(const char* text, SDL_Color color) const;
SDL_Texture* RecolorTexture(SDL_Texture* src, Uint8 r, Uint8 g, Uint8 b) const;

Expand Down
Empty file added old_scene.txt
Empty file.
23 changes: 17 additions & 6 deletions src/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,30 @@ void Audio::StopFx() {
}
}

void Audio::SetMusicVolume(float volume)
{
// clamp
void Audio::SetMusicVolume(float volume) {
if (volume < 0.0f) volume = 0.0f;
else if (volume > 1.0f) volume = 1.0f;

if (volume > 1.0f) volume = 1.0f;
music_volume_ = volume;

if (music_stream_) {
if (music_stream_ && !musicPaused_) {
SDL_SetAudioStreamGain(music_stream_, music_volume_);
}
}

void Audio::PauseMusic() {
musicPaused_ = true;
if (device_ != 0) {
SDL_PauseAudioDevice(device_);
}
}

void Audio::ResumeMusic() {
musicPaused_ = false;
if (device_ != 0) {
SDL_ResumeAudioDevice(device_);
}
}

void Audio::SetSFXVolume(float volume)
{
// clamp
Expand Down
5 changes: 5 additions & 0 deletions src/Cinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Window.h"
#include "Input.h"
#include "Log.h"
#include "Audio.h"

// FFmpeg headers (C linkage)
extern "C" {
Expand Down Expand Up @@ -111,6 +112,8 @@ bool Cinematics::PlayVideo(const char* path)
// Decode the first frame immediately so we have something to show
DecodeNextFrame();

Engine::GetInstance().audio->PauseMusic();

return true;
}

Expand Down Expand Up @@ -322,6 +325,8 @@ void Cinematics::CloseVideo()
audioStreamIdx = -1;
videoWidth = 0;
videoHeight = 0;

Engine::GetInstance().audio->ResumeMusic();
}

// ===================================================================
Expand Down
16 changes: 13 additions & 3 deletions src/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,10 @@ bool Render::DrawMenuText(const char* t, int x, int y, int w, int h, SDL_Color c

bool Render::DrawMenuTextCentered(const char* t, SDL_Rect a, SDL_Color c) const
{
return DrawMenuTextCentered(t, a, c, 1.0f);
return DrawMenuTextCentered(t, a, c, 1.0f, false);
}

bool Render::DrawMenuTextCentered(const char* t, SDL_Rect a, SDL_Color c, float ts) const
bool Render::DrawMenuTextCentered(const char* t, SDL_Rect a, SDL_Color c, float ts, bool shrinkToFit) const
{
if (!menuFont || !t) return false;
SDL_Surface* s = TTF_RenderText_Blended(menuFont, t, 0, c);
Expand All @@ -623,7 +623,17 @@ bool Render::DrawMenuTextCentered(const char* t, SDL_Rect a, SDL_Color c, float
SDL_SetTextureBlendMode(tx, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(tx, c.a);

float tw = (float)s->w * ts, th = (float)s->h * ts, sc = (float)Engine::GetInstance().window->GetScale();
float tw = (float)s->w * ts;
float th = (float)s->h * ts;

float sc = (float)Engine::GetInstance().window->GetScale();

if (shrinkToFit && tw > (float)(a.w * sc) && a.w > 0) {
float ratio = (float)(a.w * sc) / tw;
tw *= ratio;
th *= ratio;
}

SDL_FRect d = { (a.x * sc) + (a.w * sc - tw) / 2.0f, (a.y * sc) + (a.h * sc - th) / 2.0f, tw, th };

bool ok = SDL_RenderTexture(renderer, tx, nullptr, &d);
Expand Down
48 changes: 36 additions & 12 deletions src/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,24 @@ void Scene::LoadGameplay()

LoadPauseMenuButtons();

Engine::GetInstance().render->SetAmbientTint(140, 155, 190);
// Set ambient lighting tint based on the current level environment
switch (currentLevelIndex_) {
case 0: // LEVEL 1: Rock Bottom (Cave - dark blue-grey)
Engine::GetInstance().render->SetAmbientTint(100, 115, 160);
break;
case 1: // LEVEL 2: Shattered Ruins (Pink tint)
Engine::GetInstance().render->SetAmbientTint(113, 124, 170);
break;
case 2: // LEVEL 3: Forest Borderlines (Forest - dark green/teal)
Engine::GetInstance().render->SetAmbientTint(110, 140, 120);
break;
case 3: // LEVEL 4: Forgotten Playground (Playground - twilight/purple)
Engine::GetInstance().render->SetAmbientTint(130, 110, 150);
break;
default:
Engine::GetInstance().render->SetAmbientTint(255, 255, 255); // No tint
break;
}


auto setupAnimFromTSX = [](const char* tsxPath, Animation& anim, SDL_Texture*& tex) {
Expand Down Expand Up @@ -2358,7 +2375,6 @@ void Scene::UpdateGameplay(float dt)
}
}

DrawInventory(winW, winH);
return;
}

Expand Down Expand Up @@ -3696,7 +3712,7 @@ void Scene::PostUpdateGameplay()
}

// --- Boss health bar ---
{
if (!showMapViewer_ && !showInventory_ && !isPaused_ && !isGameOver_) {
int winW = 0, winH = 0;
Engine::GetInstance().window->GetWindowSize(winW, winH);
DrawBossHUD(winW, winH);
Expand Down Expand Up @@ -3939,7 +3955,12 @@ void Scene::PostUpdateGameplay()
Engine::GetInstance().window->GetWindowSize(winW, winH);
DrawMapViewer(winW, winH);
}
else if (isPaused_ && !showInventory_) {
else if (showInventory_) {
int winW = 0, winH = 0;
Engine::GetInstance().window->GetWindowSize(winW, winH);
DrawInventory(winW, winH);
}
else if (isPaused_) {
DrawPauseMenu();
}

Expand Down Expand Up @@ -4448,18 +4469,21 @@ void Scene::DrawInventory(int winW, int winH)

// Small helper instructions text in footer
SDL_Rect hintArea = { (int)frameX, (int)(frameY + frameH - 35.0f * fScale), (int)frameW, 20 };
render.DrawMenuTextCentered("Click bordes o Flechas para cambiar de pagina | ESC / Click fuera para cerrar", hintArea, { 180, 200, 220, 180 }, 0.28f);
render.DrawMenuTextCentered("Click edges or Arrows to change page | ESC / Click outside to close", hintArea, { 180, 200, 220, 180 }, 0.28f);
}

// 5. Instructions Footer Overlay
SDL_Rect footer = { 0, winH - 45, winW, 30 };
if (Engine::GetInstance().input->IsGamepadConnected())
{
render.DrawMenuTextCentered("Clic en slots para Equipar | ARRIBA o 'I' para cerrar", footer, { 180, 210, 240, 200 }, 0.35f);
}
else
if (!showMemoryViewer_ || activeMemoryIndex_ == -1)
{
render.DrawMenuTextCentered("Clic en slots para Equipar (Teclas 1, 2, 3 en juego) | 'I' para cerrar", footer, { 180, 210, 240, 200 }, 0.35f);
SDL_Rect footer = { 0, winH - 45, winW, 30 };
if (Engine::GetInstance().input->IsGamepadConnected())
{
render.DrawMenuTextCentered("Click slots to Equip | UP or 'I' to close", footer, { 180, 210, 240, 200 }, 0.35f);
}
else
{
render.DrawMenuTextCentered("Click slots to Equip (Keys 1, 2, 3 in game) | 'I' to close", footer, { 180, 210, 240, 200 }, 0.35f);
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/UIButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ bool UIButton::Draw()
// Draw text centered on the LOGICAL area (to keep it stable)
// but matching the animation scale
SDL_Rect textBounds = renderBounds;

// Shrink bounds to avoid drawing over the button's broken edges (approx 28% each side)
int paddingX = (int)(renderBounds.w * 0.28f);
textBounds.x += paddingX;
textBounds.w -= paddingX * 2;

textBounds.y += (int)(5 * scaleAnim);
render.DrawMenuTextCentered(text.c_str(), textBounds, textColor);
render.DrawMenuTextCentered(text.c_str(), textBounds, textColor, 1.0f, true);
}
else {
// ── Renderizado por defecto con rectángulos (sin textura) ──────────────
Expand Down
Loading