afegit debug.yaml
This commit is contained in:
@@ -30,11 +30,6 @@
|
||||
|
||||
class Texture;
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <iomanip> // Para operator<<, setfill, setw
|
||||
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, hex
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
Title::Title()
|
||||
: text_(Resource::get()->getText("smb2_grad")),
|
||||
@@ -43,12 +38,7 @@ Title::Title()
|
||||
game_logo_(std::make_unique<GameLogo>(param.game.game_area.center_x, param.title.title_c_c_position)),
|
||||
mini_logo_sprite_(std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"))),
|
||||
state_(State::LOGO_ANIMATING),
|
||||
num_controllers_(Input::get()->getNumGamepads())
|
||||
#ifdef _DEBUG
|
||||
,
|
||||
debug_color_(param.title.bg_color)
|
||||
#endif
|
||||
{
|
||||
num_controllers_(Input::get()->getNumGamepads()) {
|
||||
// Configura objetos
|
||||
tiled_bg_->setColor(param.title.bg_color);
|
||||
tiled_bg_->setSpeed(0.0F);
|
||||
@@ -132,88 +122,9 @@ void Title::checkEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
void Title::handleKeyDownEvent(const SDL_Event& event) {
|
||||
#ifdef _DEBUG
|
||||
bool is_repeat = static_cast<int>(event.key.repeat) == 1;
|
||||
if (is_repeat) {
|
||||
handleDebugColorKeys(event.key.key);
|
||||
}
|
||||
#endif
|
||||
void Title::handleKeyDownEvent(const SDL_Event& /*event*/) {
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Title::handleDebugColorKeys(SDL_Keycode key) {
|
||||
adjustColorComponent(key, debug_color_);
|
||||
|
||||
counter_time_ = 0.0F;
|
||||
tiled_bg_->setColor(debug_color_);
|
||||
printColorValue(debug_color_);
|
||||
}
|
||||
|
||||
void Title::adjustColorComponent(SDL_Keycode key, Color& color) {
|
||||
switch (key) {
|
||||
case SDLK_A:
|
||||
incrementColorComponent(color.r);
|
||||
break;
|
||||
case SDLK_Z:
|
||||
decrementColorComponent(color.r);
|
||||
break;
|
||||
case SDLK_S:
|
||||
incrementColorComponent(color.g);
|
||||
break;
|
||||
case SDLK_X:
|
||||
decrementColorComponent(color.g);
|
||||
break;
|
||||
case SDLK_D:
|
||||
incrementColorComponent(color.b);
|
||||
break;
|
||||
case SDLK_C:
|
||||
decrementColorComponent(color.b);
|
||||
break;
|
||||
case SDLK_F:
|
||||
incrementAllComponents(color);
|
||||
break;
|
||||
case SDLK_V:
|
||||
decrementAllComponents(color);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Title::incrementColorComponent(uint8_t& component) {
|
||||
if (component < 255) {
|
||||
++component;
|
||||
}
|
||||
}
|
||||
|
||||
void Title::decrementColorComponent(uint8_t& component) {
|
||||
if (component > 0) {
|
||||
--component;
|
||||
}
|
||||
}
|
||||
|
||||
void Title::incrementAllComponents(Color& color) {
|
||||
incrementColorComponent(color.r);
|
||||
incrementColorComponent(color.g);
|
||||
incrementColorComponent(color.b);
|
||||
}
|
||||
|
||||
void Title::decrementAllComponents(Color& color) {
|
||||
decrementColorComponent(color.r);
|
||||
decrementColorComponent(color.g);
|
||||
decrementColorComponent(color.b);
|
||||
}
|
||||
|
||||
void Title::printColorValue(const Color& color) {
|
||||
std::cout << "#"
|
||||
<< std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(color.r)
|
||||
<< std::setw(2) << std::setfill('0') << static_cast<int>(color.g)
|
||||
<< std::setw(2) << std::setfill('0') << static_cast<int>(color.b)
|
||||
<< '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
// Comprueba las entradas
|
||||
void Title::checkInput() {
|
||||
Input::get()->update();
|
||||
|
||||
Reference in New Issue
Block a user