iwyu
clang-format
This commit is contained in:
@@ -111,31 +111,31 @@ void Title::checkEvents() {
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
handleKeyDownEvent(event);
|
||||
}
|
||||
|
||||
|
||||
GlobalEvents::check(event);
|
||||
define_buttons_->checkEvents(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Title::handleKeyDownEvent(const SDL_Event& event) {
|
||||
bool isFirstPress = static_cast<int>(event.key.repeat) == 0;
|
||||
if (isFirstPress) {
|
||||
bool is_first_press = static_cast<int>(event.key.repeat) == 0;
|
||||
if (is_first_press) {
|
||||
handleControlKeys(event.key.key);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
bool isRepeat = static_cast<int>(event.key.repeat) == 1;
|
||||
if (isRepeat) {
|
||||
#ifdef _DEBUG
|
||||
bool is_repeat = static_cast<int>(event.key.repeat) == 1;
|
||||
if (is_repeat) {
|
||||
handleDebugColorKeys(event.key.key);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Title::handleDebugColorKeys(SDL_Keycode key) {
|
||||
static Color color_ = param.title.bg_color;
|
||||
|
||||
|
||||
adjustColorComponent(key, color_);
|
||||
|
||||
|
||||
counter_ = 0;
|
||||
tiled_bg_->setColor(color_);
|
||||
printColorValue(color_);
|
||||
@@ -143,15 +143,32 @@ void Title::handleDebugColorKeys(SDL_Keycode key) {
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,27 +211,27 @@ void Title::handleControlKeys(SDL_Keycode key) {
|
||||
define_buttons_->enable(0);
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
|
||||
case SDLK_2:
|
||||
define_buttons_->enable(1);
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
|
||||
case SDLK_3:
|
||||
swapControllers();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
|
||||
case SDLK_4:
|
||||
swapKeyboard();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
|
||||
case SDLK_5:
|
||||
showControllers();
|
||||
resetCounter();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -235,28 +252,27 @@ void Title::checkInput() {
|
||||
GlobalInputs::check();
|
||||
}
|
||||
|
||||
bool Title::shouldSkipInputCheck() const {
|
||||
auto Title::shouldSkipInputCheck() const -> bool {
|
||||
return define_buttons_->isEnabled();
|
||||
}
|
||||
|
||||
void Title::processControllerInputs() {
|
||||
for (const auto &controller : Options::controllers) {
|
||||
for (const auto& controller : Options::controllers) {
|
||||
if (isStartButtonPressed(controller)) {
|
||||
handleStartButtonPress(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Title::isStartButtonPressed(const Options::GamepadOptions &controller) const {
|
||||
auto Title::isStartButtonPressed(const Options::GamepadOptions& controller) -> bool {
|
||||
return Input::get()->checkInput(
|
||||
InputAction::START,
|
||||
INPUT_DO_NOT_ALLOW_REPEAT,
|
||||
controller.type,
|
||||
controller.index
|
||||
);
|
||||
InputAction::START,
|
||||
INPUT_DO_NOT_ALLOW_REPEAT,
|
||||
controller.type,
|
||||
controller.index);
|
||||
}
|
||||
|
||||
void Title::handleStartButtonPress(const Options::GamepadOptions &controller) {
|
||||
void Title::handleStartButtonPress(const Options::GamepadOptions& controller) {
|
||||
if (!canProcessStartButton()) {
|
||||
return;
|
||||
}
|
||||
@@ -268,7 +284,7 @@ void Title::handleStartButtonPress(const Options::GamepadOptions &controller) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Title::canProcessStartButton() const {
|
||||
auto Title::canProcessStartButton() const -> bool {
|
||||
return (state_ != TitleState::LOGO_ANIMATING || ALLOW_TITLE_ANIMATION_SKIP);
|
||||
}
|
||||
|
||||
@@ -546,21 +562,21 @@ void Title::initPlayers() {
|
||||
|
||||
// Actualza los jugadores
|
||||
void Title::updatePlayers() {
|
||||
for (auto &player : players_) {
|
||||
for (auto& player : players_) {
|
||||
player->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Renderiza los jugadores
|
||||
void Title::renderPlayers() {
|
||||
for (auto const &player : players_) {
|
||||
for (auto const& player : players_) {
|
||||
player->render();
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene un jugador a partir de su "id"
|
||||
auto Title::getPlayer(int id) -> std::shared_ptr<Player> {
|
||||
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto &player) { return player->getId() == id; });
|
||||
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto& player) { return player->getId() == id; });
|
||||
|
||||
if (it != players_.end()) {
|
||||
return *it;
|
||||
|
||||
Reference in New Issue
Block a user