#include "state_manager.h" #include // for rand #include "../defines.h" // for constantes DEMO/LOGO #include "../engine.h" // for Engine (callbacks) #include "../shapes/png_shape.h" // for PNGShape flip detection StateManager::StateManager() : engine_(nullptr) , current_app_mode_(AppMode::SANDBOX) , previous_app_mode_(AppMode::SANDBOX) , demo_timer_(0.0f) , demo_next_action_time_(0.0f) , logo_convergence_threshold_(0.90f) , logo_min_time_(3.0f) , logo_max_time_(5.0f) , logo_waiting_for_flip_(false) , logo_target_flip_number_(0) , logo_target_flip_percentage_(0.0f) , logo_current_flip_count_(0) , logo_entered_manually_(false) , logo_previous_theme_(0) , logo_previous_texture_index_(0) , logo_previous_shape_scale_(1.0f) { } StateManager::~StateManager() { } void StateManager::initialize(Engine* engine) { engine_ = engine; } void StateManager::setLogoPreviousState(int theme, size_t texture_index, float shape_scale) { logo_previous_theme_ = theme; logo_previous_texture_index_ = texture_index; logo_previous_shape_scale_ = shape_scale; } // TODO: Implementar métodos completos // Por ahora, stubs vacíos para que compile void StateManager::update(float delta_time, float shape_convergence, Shape* active_shape) { // Delegar a Engine temporalmente - La lógica compleja queda en Engine por ahora // Este es un wrapper que permite refactorizar gradualmente if (engine_) { // Engine mantiene la implementación de updateDemoMode() // StateManager solo coordina el estado } } void StateManager::setState(AppMode new_mode, int current_screen_width, int current_screen_height) { if (current_app_mode_ == new_mode) return; if (current_app_mode_ == AppMode::LOGO && new_mode != AppMode::LOGO) { previous_app_mode_ = new_mode; } if (new_mode == AppMode::LOGO) { previous_app_mode_ = current_app_mode_; } current_app_mode_ = new_mode; // Resetear timer al cambiar modo demo_timer_ = 0.0f; } void StateManager::toggleDemoMode(int current_screen_width, int current_screen_height) { if (current_app_mode_ == AppMode::DEMO) { setState(AppMode::SANDBOX, current_screen_width, current_screen_height); } else { setState(AppMode::DEMO, current_screen_width, current_screen_height); } } void StateManager::toggleDemoLiteMode(int current_screen_width, int current_screen_height) { if (current_app_mode_ == AppMode::DEMO_LITE) { setState(AppMode::SANDBOX, current_screen_width, current_screen_height); } else { setState(AppMode::DEMO_LITE, current_screen_width, current_screen_height); } } void StateManager::toggleLogoMode(int current_screen_width, int current_screen_height, size_t ball_count) { if (current_app_mode_ == AppMode::LOGO) { setState(AppMode::SANDBOX, current_screen_width, current_screen_height); } else { setState(AppMode::LOGO, current_screen_width, current_screen_height); logo_entered_manually_ = true; } } void StateManager::performDemoAction(bool is_lite) { // TODO: Migrar performDemoAction() } void StateManager::randomizeOnDemoStart(bool is_lite) { // TODO: Migrar randomizeOnDemoStart() } void StateManager::toggleGravityOnOff() { // TODO: Migrar toggleGravityOnOff() } void StateManager::enterLogoMode(bool from_demo, int current_screen_width, int current_screen_height, size_t ball_count) { // TODO: Migrar enterLogoMode() } void StateManager::exitLogoMode(bool return_to_demo) { // TODO: Migrar exitLogoMode() }