style: aplicar fixes de clang-tidy (todo excepto uppercase-literal-suffix)
Corregidos ~2570 issues automáticamente con clang-tidy --fix-errors más ajustes manuales posteriores: - modernize: designated-initializers, trailing-return-type, use-auto, avoid-c-arrays (→ std::array<>), use-ranges, use-emplace, deprecated-headers, use-equals-default, pass-by-value, return-braced-init-list, use-default-member-init - readability: math-missing-parentheses, implicit-bool-conversion, braces-around-statements, isolate-declaration, use-std-min-max, identifier-naming, else-after-return, redundant-casting, convert-member-functions-to-static, make-member-function-const, static-accessed-through-instance - performance: avoid-endl, unnecessary-value-param, type-promotion, inefficient-vector-operation - dead code: XOR_KEY (orphan tras eliminar encryptData/decryptData), dead stores en engine.cpp y png_shape.cpp - NOLINT justificado en 10 funciones con alta complejidad cognitiva (initialize, render, main, processEvents, update×3, performDemoAction, randomizeOnDemoStart, renderDebugHUD, AppLogo::update) Compilación: gcc -Wall sin warnings. clang-tidy: 0 issues. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,39 +1,37 @@
|
||||
#include "state_manager.hpp"
|
||||
|
||||
#include <algorithm> // for std::min
|
||||
#include <array> // for std::array
|
||||
#include <cstdlib> // for rand
|
||||
#include <vector> // for std::vector
|
||||
|
||||
#include "defines.hpp" // for constantes DEMO/LOGO
|
||||
#include "engine.hpp" // for Engine (enter/exitShapeMode, texture)
|
||||
#include "scene/scene_manager.hpp" // for SceneManager
|
||||
#include "shapes_mgr/shape_manager.hpp" // for ShapeManager
|
||||
#include "shapes/png_shape.hpp" // for PNGShape flip detection
|
||||
#include "theme_manager.hpp" // for ThemeManager
|
||||
#include "defines.hpp" // for constantes DEMO/LOGO
|
||||
#include "engine.hpp" // for Engine (enter/exitShapeMode, texture)
|
||||
#include "scene/scene_manager.hpp" // for SceneManager
|
||||
#include "shapes/png_shape.hpp" // for PNGShape flip detection
|
||||
#include "shapes_mgr/shape_manager.hpp" // for ShapeManager
|
||||
#include "theme_manager.hpp" // for ThemeManager
|
||||
|
||||
StateManager::StateManager()
|
||||
: engine_(nullptr)
|
||||
, scene_mgr_(nullptr)
|
||||
, theme_mgr_(nullptr)
|
||||
, shape_mgr_(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() {
|
||||
: engine_(nullptr),
|
||||
scene_mgr_(nullptr),
|
||||
theme_mgr_(nullptr),
|
||||
shape_mgr_(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) {
|
||||
}
|
||||
|
||||
void StateManager::initialize(Engine* engine, SceneManager* scene_mgr, ThemeManager* theme_mgr, ShapeManager* shape_mgr) {
|
||||
@@ -53,8 +51,10 @@ void StateManager::setLogoPreviousState(int theme, size_t texture_index, float s
|
||||
// ACTUALIZACIÓN DE ESTADOS
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::update(float delta_time, float shape_convergence, Shape* active_shape) {
|
||||
if (current_app_mode_ == AppMode::SANDBOX) return;
|
||||
void StateManager::update(float delta_time, float shape_convergence, Shape* active_shape) { // NOLINT(readability-function-cognitive-complexity)
|
||||
if (current_app_mode_ == AppMode::SANDBOX) {
|
||||
return;
|
||||
}
|
||||
|
||||
demo_timer_ += delta_time;
|
||||
|
||||
@@ -63,14 +63,12 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
if (current_app_mode_ == AppMode::LOGO) {
|
||||
if (logo_waiting_for_flip_) {
|
||||
// CAMINO B: Esperando a que ocurran flips
|
||||
PNGShape* png_shape = dynamic_cast<PNGShape*>(active_shape);
|
||||
auto* png_shape = dynamic_cast<PNGShape*>(active_shape);
|
||||
|
||||
if (png_shape) {
|
||||
if (png_shape != nullptr) {
|
||||
int current_flip_count = png_shape->getFlipCount();
|
||||
|
||||
if (current_flip_count > logo_current_flip_count_) {
|
||||
logo_current_flip_count_ = current_flip_count;
|
||||
}
|
||||
logo_current_flip_count_ = std::max(current_flip_count, logo_current_flip_count_);
|
||||
|
||||
if (logo_current_flip_count_ + 1 >= logo_target_flip_number_) {
|
||||
if (png_shape->isFlipping()) {
|
||||
@@ -93,7 +91,9 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
should_trigger = demo_timer_ >= demo_next_action_time_;
|
||||
}
|
||||
|
||||
if (!should_trigger) return;
|
||||
if (!should_trigger) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_app_mode_ == AppMode::LOGO) {
|
||||
// LOGO MODE: Sistema de acciones variadas con gravedad dinámica
|
||||
@@ -104,7 +104,7 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
if (logo_waiting_for_flip_) {
|
||||
// Ya estábamos esperando flips → hacer el cambio SHAPE → PHYSICS
|
||||
if (action < 50) {
|
||||
engine_->exitShapeMode(true); // Con gravedad ON
|
||||
engine_->exitShapeMode(true); // Con gravedad ON
|
||||
} else {
|
||||
engine_->exitShapeMode(false); // Con gravedad OFF
|
||||
}
|
||||
@@ -122,15 +122,15 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
logo_target_flip_percentage_ = LOGO_FLIP_TRIGGER_MIN + (rand() % 1000) / 1000.0f * (LOGO_FLIP_TRIGGER_MAX - LOGO_FLIP_TRIGGER_MIN);
|
||||
logo_current_flip_count_ = 0;
|
||||
|
||||
PNGShape* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape) {
|
||||
auto* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape != nullptr) {
|
||||
png_shape->resetFlipCount();
|
||||
}
|
||||
// No hacer nada más — esperar a que ocurran los flips
|
||||
} else {
|
||||
// CAMINO A (50%): Cambio inmediato
|
||||
if (action < 50) {
|
||||
engine_->exitShapeMode(true); // SHAPE → PHYSICS con gravedad ON
|
||||
engine_->exitShapeMode(true); // SHAPE → PHYSICS con gravedad ON
|
||||
} else {
|
||||
engine_->exitShapeMode(false); // SHAPE → PHYSICS con gravedad OFF
|
||||
}
|
||||
@@ -158,7 +158,7 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
scene_mgr_->forceBallsGravityOff();
|
||||
} else {
|
||||
// 16%: Cambiar dirección de gravedad
|
||||
GravityDirection new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
auto new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
scene_mgr_->changeGravityDirection(new_direction);
|
||||
scene_mgr_->forceBallsGravityOn();
|
||||
}
|
||||
@@ -186,7 +186,9 @@ void StateManager::update(float delta_time, float shape_convergence, Shape* acti
|
||||
}
|
||||
|
||||
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_ == new_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current_app_mode_ == AppMode::LOGO && new_mode != AppMode::LOGO) {
|
||||
previous_app_mode_ = new_mode;
|
||||
@@ -201,7 +203,8 @@ void StateManager::setState(AppMode new_mode, int current_screen_width, int curr
|
||||
demo_timer_ = 0.0f;
|
||||
|
||||
if (new_mode == AppMode::DEMO || new_mode == AppMode::DEMO_LITE || new_mode == AppMode::LOGO) {
|
||||
float min_interval, max_interval;
|
||||
float min_interval;
|
||||
float max_interval;
|
||||
|
||||
if (new_mode == AppMode::LOGO) {
|
||||
float resolution_scale = current_screen_height / 720.0f;
|
||||
@@ -250,8 +253,10 @@ void StateManager::toggleLogoMode(int current_screen_width, int current_screen_h
|
||||
// ACCIONES DE DEMO
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::performDemoAction(bool is_lite) {
|
||||
if (!engine_ || !scene_mgr_ || !theme_mgr_ || !shape_mgr_) return;
|
||||
void StateManager::performDemoAction(bool is_lite) { // NOLINT(readability-function-cognitive-complexity)
|
||||
if ((engine_ == nullptr) || (scene_mgr_ == nullptr) || (theme_mgr_ == nullptr) || (shape_mgr_ == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// SALTO AUTOMÁTICO A LOGO MODE (Easter Egg)
|
||||
@@ -278,18 +283,18 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
// ACCIONES NORMALES DE DEMO/DEMO_LITE
|
||||
// ============================================
|
||||
|
||||
int TOTAL_WEIGHT;
|
||||
int total_weight;
|
||||
int random_value;
|
||||
int accumulated_weight = 0;
|
||||
|
||||
if (is_lite) {
|
||||
TOTAL_WEIGHT = DEMO_LITE_WEIGHT_GRAVITY_DIR + DEMO_LITE_WEIGHT_GRAVITY_TOGGLE + DEMO_LITE_WEIGHT_SHAPE + DEMO_LITE_WEIGHT_TOGGLE_PHYSICS + DEMO_LITE_WEIGHT_IMPULSE;
|
||||
random_value = rand() % TOTAL_WEIGHT;
|
||||
total_weight = DEMO_LITE_WEIGHT_GRAVITY_DIR + DEMO_LITE_WEIGHT_GRAVITY_TOGGLE + DEMO_LITE_WEIGHT_SHAPE + DEMO_LITE_WEIGHT_TOGGLE_PHYSICS + DEMO_LITE_WEIGHT_IMPULSE;
|
||||
random_value = rand() % total_weight;
|
||||
|
||||
// Cambiar dirección gravedad (25%)
|
||||
accumulated_weight += DEMO_LITE_WEIGHT_GRAVITY_DIR;
|
||||
if (random_value < accumulated_weight) {
|
||||
GravityDirection new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
auto new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
scene_mgr_->changeGravityDirection(new_direction);
|
||||
return;
|
||||
}
|
||||
@@ -304,8 +309,8 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
// Activar figura 3D (25%) - PNG_SHAPE excluido
|
||||
accumulated_weight += DEMO_LITE_WEIGHT_SHAPE;
|
||||
if (random_value < accumulated_weight) {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(shapes[rand() % 8]);
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(SHAPES[rand() % 8]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -324,13 +329,13 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
}
|
||||
|
||||
} else {
|
||||
TOTAL_WEIGHT = DEMO_WEIGHT_GRAVITY_DIR + DEMO_WEIGHT_GRAVITY_TOGGLE + DEMO_WEIGHT_SHAPE + DEMO_WEIGHT_TOGGLE_PHYSICS + DEMO_WEIGHT_REGENERATE_SHAPE + DEMO_WEIGHT_THEME + DEMO_WEIGHT_SCENARIO + DEMO_WEIGHT_IMPULSE + DEMO_WEIGHT_DEPTH_ZOOM + DEMO_WEIGHT_SHAPE_SCALE + DEMO_WEIGHT_SPRITE;
|
||||
random_value = rand() % TOTAL_WEIGHT;
|
||||
total_weight = DEMO_WEIGHT_GRAVITY_DIR + DEMO_WEIGHT_GRAVITY_TOGGLE + DEMO_WEIGHT_SHAPE + DEMO_WEIGHT_TOGGLE_PHYSICS + DEMO_WEIGHT_REGENERATE_SHAPE + DEMO_WEIGHT_THEME + DEMO_WEIGHT_SCENARIO + DEMO_WEIGHT_IMPULSE + DEMO_WEIGHT_DEPTH_ZOOM + DEMO_WEIGHT_SHAPE_SCALE + DEMO_WEIGHT_SPRITE;
|
||||
random_value = rand() % total_weight;
|
||||
|
||||
// Cambiar dirección gravedad (10%)
|
||||
accumulated_weight += DEMO_WEIGHT_GRAVITY_DIR;
|
||||
if (random_value < accumulated_weight) {
|
||||
GravityDirection new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
auto new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
scene_mgr_->changeGravityDirection(new_direction);
|
||||
return;
|
||||
}
|
||||
@@ -345,8 +350,8 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
// Activar figura 3D (20%) - PNG_SHAPE excluido
|
||||
accumulated_weight += DEMO_WEIGHT_SHAPE;
|
||||
if (random_value < accumulated_weight) {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(shapes[rand() % 8]);
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(SHAPES[rand() % 8]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,10 +383,12 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
if (random_value < accumulated_weight) {
|
||||
int auto_max = std::min(engine_->getMaxAutoScenario(), DEMO_AUTO_MAX_SCENARIO);
|
||||
std::vector<int> candidates;
|
||||
for (int i = DEMO_AUTO_MIN_SCENARIO; i <= auto_max; ++i)
|
||||
for (int i = DEMO_AUTO_MIN_SCENARIO; i <= auto_max; ++i) {
|
||||
candidates.push_back(i);
|
||||
if (engine_->isCustomScenarioEnabled() && engine_->isCustomAutoAvailable())
|
||||
}
|
||||
if (engine_->isCustomScenarioEnabled() && engine_->isCustomAutoAvailable()) {
|
||||
candidates.push_back(CUSTOM_SCENARIO_IDX);
|
||||
}
|
||||
int new_scenario = candidates[rand() % candidates.size()];
|
||||
SimulationMode current_sim_mode = shape_mgr_->getCurrentMode();
|
||||
scene_mgr_->changeScenario(new_scenario, current_sim_mode);
|
||||
@@ -439,15 +446,15 @@ void StateManager::performDemoAction(bool is_lite) {
|
||||
// RANDOMIZACIÓN AL INICIAR DEMO
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
if (!engine_ || !scene_mgr_ || !theme_mgr_ || !shape_mgr_) return;
|
||||
void StateManager::randomizeOnDemoStart(bool is_lite) { // NOLINT(readability-function-cognitive-complexity)
|
||||
if ((engine_ == nullptr) || (scene_mgr_ == nullptr) || (theme_mgr_ == nullptr) || (shape_mgr_ == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Si venimos de LOGO con PNG_SHAPE, cambiar figura obligatoriamente
|
||||
if (shape_mgr_->getCurrentShapeType() == ShapeType::PNG_SHAPE) {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX,
|
||||
ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER,
|
||||
ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(shapes[rand() % 8]);
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(SHAPES[rand() % 8]);
|
||||
}
|
||||
|
||||
if (is_lite) {
|
||||
@@ -457,11 +464,11 @@ void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
engine_->exitShapeMode(false);
|
||||
}
|
||||
} else {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(shapes[rand() % 8]);
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(SHAPES[rand() % 8]);
|
||||
}
|
||||
|
||||
GravityDirection new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
auto new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
scene_mgr_->changeGravityDirection(new_direction);
|
||||
if (rand() % 2 == 0) {
|
||||
toggleGravityOnOff();
|
||||
@@ -476,14 +483,14 @@ void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
engine_->exitShapeMode(false);
|
||||
}
|
||||
} else {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
ShapeType selected_shape = shapes[rand() % 8];
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
ShapeType selected_shape = SHAPES[rand() % 8];
|
||||
|
||||
// Randomizar profundidad y escala ANTES de activar la figura
|
||||
if (rand() % 2 == 0) {
|
||||
shape_mgr_->setDepthZoomEnabled(!shape_mgr_->isDepthZoomEnabled());
|
||||
}
|
||||
shape_mgr_->setShapeScaleFactor(0.5f + (rand() % 1500) / 1000.0f);
|
||||
shape_mgr_->setShapeScaleFactor(0.5f + ((rand() % 1500) / 1000.0f));
|
||||
|
||||
engine_->enterShapeMode(selected_shape);
|
||||
}
|
||||
@@ -491,10 +498,12 @@ void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
// 2. Escenario
|
||||
int auto_max = std::min(engine_->getMaxAutoScenario(), DEMO_AUTO_MAX_SCENARIO);
|
||||
std::vector<int> candidates;
|
||||
for (int i = DEMO_AUTO_MIN_SCENARIO; i <= auto_max; ++i)
|
||||
for (int i = DEMO_AUTO_MIN_SCENARIO; i <= auto_max; ++i) {
|
||||
candidates.push_back(i);
|
||||
if (engine_->isCustomScenarioEnabled() && engine_->isCustomAutoAvailable())
|
||||
}
|
||||
if (engine_->isCustomScenarioEnabled() && engine_->isCustomAutoAvailable()) {
|
||||
candidates.push_back(CUSTOM_SCENARIO_IDX);
|
||||
}
|
||||
int new_scenario = candidates[rand() % candidates.size()];
|
||||
SimulationMode current_sim_mode = shape_mgr_->getCurrentMode();
|
||||
scene_mgr_->changeScenario(new_scenario, current_sim_mode);
|
||||
@@ -513,7 +522,7 @@ void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
}
|
||||
|
||||
// 5. Gravedad
|
||||
GravityDirection new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
auto new_direction = static_cast<GravityDirection>(rand() % 4);
|
||||
scene_mgr_->changeGravityDirection(new_direction);
|
||||
if (rand() % 3 == 0) {
|
||||
toggleGravityOnOff();
|
||||
@@ -526,10 +535,12 @@ void StateManager::randomizeOnDemoStart(bool is_lite) {
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::toggleGravityOnOff() {
|
||||
if (!scene_mgr_) return;
|
||||
if (scene_mgr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool gravity_enabled = scene_mgr_->hasBalls() &&
|
||||
(scene_mgr_->getFirstBall()->getGravityForce() > 0.0f);
|
||||
(scene_mgr_->getFirstBall()->getGravityForce() > 0.0f);
|
||||
|
||||
if (gravity_enabled) {
|
||||
scene_mgr_->forceBallsGravityOff();
|
||||
@@ -543,7 +554,9 @@ void StateManager::toggleGravityOnOff() {
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::enterLogoMode(bool from_demo, int current_screen_width, int current_screen_height, size_t ball_count) {
|
||||
if (!engine_ || !scene_mgr_ || !theme_mgr_ || !shape_mgr_) return;
|
||||
if ((engine_ == nullptr) || (scene_mgr_ == nullptr) || (theme_mgr_ == nullptr) || (shape_mgr_ == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
logo_entered_manually_ = !from_demo;
|
||||
|
||||
@@ -585,8 +598,8 @@ void StateManager::enterLogoMode(bool from_demo, int current_screen_width, int c
|
||||
}
|
||||
|
||||
// Cambiar a tema aleatorio entre: MONOCHROME, LAVENDER, CRIMSON, ESMERALDA
|
||||
int logo_themes[] = {5, 6, 7, 8};
|
||||
theme_mgr_->switchToTheme(logo_themes[rand() % 4]);
|
||||
constexpr std::array<int, 4> LOGO_THEMES = {5, 6, 7, 8};
|
||||
theme_mgr_->switchToTheme(LOGO_THEMES[rand() % 4]);
|
||||
|
||||
// Establecer escala a 120%
|
||||
shape_mgr_->setShapeScaleFactor(LOGO_MODE_SHAPE_SCALE);
|
||||
@@ -595,8 +608,8 @@ void StateManager::enterLogoMode(bool from_demo, int current_screen_width, int c
|
||||
engine_->enterShapeMode(ShapeType::PNG_SHAPE);
|
||||
|
||||
// Configurar PNG_SHAPE en modo LOGO
|
||||
PNGShape* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape) {
|
||||
auto* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape != nullptr) {
|
||||
png_shape->setLogoMode(true);
|
||||
png_shape->resetFlipCount();
|
||||
}
|
||||
@@ -607,8 +620,12 @@ void StateManager::enterLogoMode(bool from_demo, int current_screen_width, int c
|
||||
// ===========================================================================
|
||||
|
||||
void StateManager::exitLogoMode(bool return_to_demo) {
|
||||
if (current_app_mode_ != AppMode::LOGO) return;
|
||||
if (!engine_ || !scene_mgr_ || !theme_mgr_ || !shape_mgr_) return;
|
||||
if (current_app_mode_ != AppMode::LOGO) {
|
||||
return;
|
||||
}
|
||||
if ((engine_ == nullptr) || (scene_mgr_ == nullptr) || (theme_mgr_ == nullptr) || (shape_mgr_ == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
logo_entered_manually_ = false;
|
||||
|
||||
@@ -624,17 +641,15 @@ void StateManager::exitLogoMode(bool return_to_demo) {
|
||||
}
|
||||
|
||||
// Desactivar modo LOGO en PNG_SHAPE
|
||||
PNGShape* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape) {
|
||||
auto* png_shape = dynamic_cast<PNGShape*>(shape_mgr_->getActiveShape());
|
||||
if (png_shape != nullptr) {
|
||||
png_shape->setLogoMode(false);
|
||||
}
|
||||
|
||||
// Si la figura activa es PNG_SHAPE, cambiar a otra figura aleatoria
|
||||
if (shape_mgr_->getCurrentShapeType() == ShapeType::PNG_SHAPE) {
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX,
|
||||
ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER,
|
||||
ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(shapes[rand() % 8]);
|
||||
constexpr std::array<ShapeType, 8> SHAPES = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
engine_->enterShapeMode(SHAPES[rand() % 8]);
|
||||
}
|
||||
|
||||
if (!return_to_demo) {
|
||||
|
||||
Reference in New Issue
Block a user