// LoadingState.cpp
#include "LoadingState.h"
#include "../gameplay/core/Game.h"
#include <SDL3/SDL.h>
#include <cstdio>

LoadingState::LoadingState(StateContext& ctx) : State(ctx) {}

void LoadingState::onEnter() {
    loadStart = SDL_GetTicks();
    loadingProgress = 0.0;
    musicLoaded = false;
    currentTrackLoading = 0;
    totalTracks = 0;
    // Kick off audio loading if available
    if (ctx.game) {
        // audio initialization handled elsewhere (main still creates Audio)
    }
}

void LoadingState::onExit() {
}

void LoadingState::handleEvent(const SDL_Event& e) {
    (void)e; // no direct event handling in loading screen
}

void LoadingState::update(double frameMs) {
    // Progress calculation is done in main; keep this simple
    // This stub allows later migration of Audio::background loading
    loadingProgress = std::min(1.0, loadingProgress + frameMs / 1000.0);
}

void LoadingState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect logicalVP) {
    (void)renderer; (void)logicalScale; (void)logicalVP;
    // Rendering is still performed in main for now; this placeholder keeps the API.
}
