Compare commits
4 Commits
86cd7b0f16
...
2024-11-03
| Author | SHA1 | Date | |
|---|---|---|---|
| e0e82ee273 | |||
| 371c477d0d | |||
| f29eb2f411 | |||
| 69a92cba66 |
@@ -206,7 +206,7 @@ NORMAL
|
|||||||
DIFICIL
|
DIFICIL
|
||||||
|
|
||||||
## 69 - MENU DE OPCIONES
|
## 69 - MENU DE OPCIONES
|
||||||
TECLAT
|
Teclat
|
||||||
|
|
||||||
## 70 - MENU DE OPCIONES
|
## 70 - MENU DE OPCIONES
|
||||||
MANDO
|
MANDO
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ NORMAL
|
|||||||
HARD
|
HARD
|
||||||
|
|
||||||
## 69 - MENU DE OPCIONES
|
## 69 - MENU DE OPCIONES
|
||||||
KEYBOARD
|
Keyboard
|
||||||
|
|
||||||
## 70 - MENU DE OPCIONES
|
## 70 - MENU DE OPCIONES
|
||||||
GAME CONTROLLER
|
GAME CONTROLLER
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ NORMAL
|
|||||||
DIFICIL
|
DIFICIL
|
||||||
|
|
||||||
## 69 - MENU DE OPCIONES
|
## 69 - MENU DE OPCIONES
|
||||||
TECLADO
|
Teclado
|
||||||
|
|
||||||
## 70 - MENU DE OPCIONES
|
## 70 - MENU DE OPCIONES
|
||||||
MANDO
|
MANDO
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void DefineButtons::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el botón que se ha pulsado
|
// Comprueba el botón que se ha pulsado
|
||||||
void DefineButtons::doControllerButtonDown(SDL_ControllerButtonEvent &event)
|
void DefineButtons::doControllerButtonDown(const SDL_ControllerButtonEvent &event)
|
||||||
{
|
{
|
||||||
// Solo pilla botones del mando que toca
|
// Solo pilla botones del mando que toca
|
||||||
if (input_->getJoyIndex(event.which) != static_cast<int>(index_controller_))
|
if (input_->getJoyIndex(event.which) != static_cast<int>(index_controller_))
|
||||||
@@ -124,8 +124,6 @@ void DefineButtons::incIndexButton()
|
|||||||
saveBindingsToOptions();
|
saveBindingsToOptions();
|
||||||
|
|
||||||
// Deshabilita
|
// Deshabilita
|
||||||
//index_controller_ = 0;
|
|
||||||
//index_button_ = 0;
|
|
||||||
enabled_ = false;
|
enabled_ = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_events.h> // para SDL_ControllerButtonEvent
|
#include <SDL2/SDL_events.h> // Para SDL_ControllerButtonEvent
|
||||||
#include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton
|
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
|
||||||
#include <memory> // para shared_ptr, unique_ptr
|
#include <stddef.h> // Para size_t
|
||||||
#include <string> // para string
|
#include <memory> // Para shared_ptr, unique_ptr
|
||||||
#include <vector> // para vector
|
#include <string> // Para string
|
||||||
class Input;
|
#include <vector> // Para vector
|
||||||
class Text;
|
class Input; // lines 8-8
|
||||||
enum class InputType : int;
|
class Text; // lines 9-9
|
||||||
|
enum class InputType : int; // lines 10-10
|
||||||
|
|
||||||
struct DefineButtonsButton
|
struct DefineButtonsButton
|
||||||
{
|
{
|
||||||
@@ -41,7 +42,7 @@ private:
|
|||||||
void incIndexButton();
|
void incIndexButton();
|
||||||
|
|
||||||
// Comprueba el botón que se ha pulsado
|
// Comprueba el botón que se ha pulsado
|
||||||
void doControllerButtonDown(SDL_ControllerButtonEvent &event);
|
void doControllerButtonDown(const SDL_ControllerButtonEvent &event);
|
||||||
|
|
||||||
// Asigna los botones definidos al input
|
// Asigna los botones definidos al input
|
||||||
void bindButtons();
|
void bindButtons();
|
||||||
|
|||||||
@@ -7,17 +7,17 @@
|
|||||||
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
|
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
|
||||||
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
||||||
#include <SDL2/SDL_stdinc.h> // Para SDL_bool, Uint32
|
#include <SDL2/SDL_stdinc.h> // Para SDL_bool, Uint32
|
||||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
#include <bits/chrono.h> // Para duration, system_clock
|
||||||
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
|
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
|
||||||
#include <stdio.h> // Para printf, perror
|
#include <stdio.h> // Para printf, perror
|
||||||
#include <string.h> // Para strcmp
|
|
||||||
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
||||||
#include <unistd.h> // Para getuid
|
#include <unistd.h> // Para getuid
|
||||||
#include <cstdlib> // Para exit, EXIT_FAILURE, rand, srand
|
#include <algorithm> // Para min
|
||||||
#include <iostream> // Para basic_ostream, operator<<, cout
|
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, rand
|
||||||
|
#include <iostream> // Para basic_ostream, operator<<, basi...
|
||||||
#include <memory> // Para make_unique, unique_ptr, make_s...
|
#include <memory> // Para make_unique, unique_ptr, make_s...
|
||||||
#include <stdexcept> // Para runtime_error
|
#include <stdexcept> // Para runtime_error
|
||||||
#include <string> // Para operator+, allocator, char_traits
|
#include <string> // Para operator+, char_traits, allocator
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include "asset.h" // Para Asset, AssetType
|
#include "asset.h" // Para Asset, AssetType
|
||||||
#include "dbgtxt.h" // Para dbg_init
|
#include "dbgtxt.h" // Para dbg_init
|
||||||
@@ -27,13 +27,13 @@
|
|||||||
#include "input.h" // Para Input, InputType
|
#include "input.h" // Para Input, InputType
|
||||||
#include "instructions.h" // Para Instructions
|
#include "instructions.h" // Para Instructions
|
||||||
#include "intro.h" // Para Intro
|
#include "intro.h" // Para Intro
|
||||||
#include "jail_audio.h" // Para JA_EnableMusic, JA_EnableSound
|
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundV...
|
||||||
#include "lang.h" // Para Code, loadFromFile
|
#include "lang.h" // Para Code, loadFromFile
|
||||||
#include "logo.h" // Para Logo
|
#include "logo.h" // Para Logo
|
||||||
#include "manage_hiscore_table.h" // Para ManageHiScoreTable
|
#include "manage_hiscore_table.h" // Para ManageHiScoreTable
|
||||||
#include "notifier.h" // Para Notifier
|
#include "notifier.h" // Para Notifier
|
||||||
#include "on_screen_help.h" // Para OnScreenHelp
|
#include "on_screen_help.h" // Para OnScreenHelp
|
||||||
#include "options.h" // Para Options, options, OptionsContro...
|
#include "options.h" // Para Options, OptionsController, opt...
|
||||||
#include "param.h" // Para Param, ParamGame, param, loadPa...
|
#include "param.h" // Para Param, ParamGame, param, loadPa...
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
#include "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
#include "title.h" // Para Title
|
#include "title.h" // Para Title
|
||||||
#include "utils.h" // Para Overrides, overrides
|
#include "utils.h" // Para Overrides, overrides
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <pwd.h> // para getpwuid, passwd
|
#include <pwd.h> // para getpwuid, passwd
|
||||||
@@ -233,6 +232,12 @@ void Director::bindInputs()
|
|||||||
options.controllers.at(i).buttons.at(j) = Input::get()->getControllerBinding(i, options.controllers.at(i).inputs.at(j));
|
options.controllers.at(i).buttons.at(j) = Input::get()->getControllerBinding(i, options.controllers.at(i).inputs.at(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Asegura que algún jugador tenga el teclado asignado
|
||||||
|
if (getPlayerWhoUsesKeyboard() == 0)
|
||||||
|
{
|
||||||
|
setKeyboardToPlayer(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa JailAudio
|
// Inicializa JailAudio
|
||||||
@@ -505,8 +510,6 @@ void Director::setFileList()
|
|||||||
// Comprueba los parametros del programa
|
// Comprueba los parametros del programa
|
||||||
void Director::checkProgramArguments(int argc, const char *argv[])
|
void Director::checkProgramArguments(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
const std::vector<std::string> argument_list = {"--320x240", "--clear_score"};
|
|
||||||
|
|
||||||
// Establece la ruta del programa
|
// Establece la ruta del programa
|
||||||
executable_path_ = argv[0];
|
executable_path_ = argv[0];
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "asset.h" // for Asset
|
#include "asset.h" // Para Asset
|
||||||
#include "background.h" // for Background
|
#include "background.h" // Para Background
|
||||||
#include "balloon.h" // for Balloon, BALLOON_SCORE, BALLOON_VE...
|
#include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VE...
|
||||||
#include "balloon_formations.h" // for BalloonFormations, BalloonFormatio...
|
#include "balloon_formations.h" // Para BalloonFormations, BalloonFormatio...
|
||||||
#include "bullet.h" // for Bullet, BulletType, BulletMoveStatus
|
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
|
||||||
#include "explosions.h" // for Explosions
|
#include "explosions.h" // Para Explosions
|
||||||
#include "fade.h" // for Fade, FadeType
|
#include "fade.h" // Para Fade, FadeType
|
||||||
#include "global_inputs.h" // for check
|
#include "global_inputs.h" // Para check
|
||||||
#include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL...
|
#include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL...
|
||||||
#include "item.h" // for Item, ItemType
|
#include "item.h" // Para Item, ItemType
|
||||||
#include "jail_audio.h" // for JA_PlaySound, JA_GetMusicState
|
#include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState
|
||||||
#include "lang.h" // for getText
|
#include "lang.h" // Para getText
|
||||||
#include "manage_hiscore_table.h" // for ManageHiScoreTable, HiScoreEntry
|
#include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry
|
||||||
#include "notifier.h" // for Notifier
|
#include "notifier.h" // Para Notifier
|
||||||
#include "param.h" // for Param, param, ParamGame, ParamFade
|
#include "param.h" // Para Param, param, ParamGame, ParamFade
|
||||||
#include "path_sprite.h" // for Path, PathSprite, createPath, Path...
|
#include "path_sprite.h" // Para Path, PathSprite, createPath, Path...
|
||||||
#include "player.h" // for Player, PlayerStatus
|
#include "player.h" // Para Player, PlayerStatus
|
||||||
#include "resource.h" // for Resource
|
#include "resource.h" // Para Resource
|
||||||
#include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB...
|
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
|
||||||
#include "screen.h" // for Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "section.h" // for Name, name, Options, options
|
#include "section.h" // Para Name, name, Options, options
|
||||||
#include "smart_sprite.h" // for SmartSprite
|
#include "smart_sprite.h" // Para SmartSprite
|
||||||
#include "text.h" // for Text
|
#include "text.h" // Para Text
|
||||||
#include "texture.h" // for Texture
|
#include "texture.h" // Para Texture
|
||||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||||
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
|
||||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
||||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||||
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
|
||||||
#include <algorithm> // for find_if, clamp, min, remove_if
|
#include <algorithm> // Para find_if, clamp, min, remove_if
|
||||||
#include <functional> // for function
|
#include <functional> // Para function
|
||||||
#include <iterator> // for distance, size
|
#include <iterator> // Para distance, size
|
||||||
#include <numeric> // for accumulate
|
#include <numeric> // Para accumulate
|
||||||
#include <stdlib.h> // for rand, size_t
|
#include <stdlib.h> // Para rand, size_t
|
||||||
|
|
||||||
struct JA_Sound_t; // lines 36-36
|
struct JA_Sound_t; // lines 36-36
|
||||||
|
|
||||||
@@ -1451,7 +1451,7 @@ void Game::checkEvents()
|
|||||||
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
case SDLK_3: // Activa el modo para pasar el juego automaticamente
|
||||||
{
|
{
|
||||||
auto_pop_balloons_ = !auto_pop_balloons_;
|
auto_pop_balloons_ = !auto_pop_balloons_;
|
||||||
Notifier::get()->showText("auto_pop_balloons_ " + boolToString(auto_pop_balloons_));
|
Notifier::get()->showText({"auto_pop_balloons_ " + boolToString(auto_pop_balloons_)});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_4: // Suelta un item
|
case SDLK_4: // Suelta un item
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
|
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
|
||||||
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8
|
#include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
|
||||||
#include <memory> // for shared_ptr, unique_ptr
|
#include <memory> // Para shared_ptr, unique_ptr
|
||||||
#include <string> // for string
|
#include <string> // Para string
|
||||||
#include <vector> // for vector
|
#include <vector> // Para vector
|
||||||
#include "balloon.h" // for Balloon
|
#include "balloon.h" // Para Balloon
|
||||||
#include "manage_hiscore_table.h" // for HiScoreEntry
|
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||||
#include "options.h" // for Options, OptionsGame, options
|
#include "options.h" // Para Options, OptionsGame, options
|
||||||
#include "player.h" // for Player
|
#include "player.h" // Para Player
|
||||||
#include "utils.h" // for Demo
|
#include "utils.h" // Para Demo
|
||||||
class Asset; // lines 14-14
|
class Asset; // lines 14-14
|
||||||
class Background; // lines 15-15
|
class Background; // lines 15-15
|
||||||
class BalloonFormations; // lines 16-16
|
class BalloonFormations; // lines 16-16
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ namespace globalInputs
|
|||||||
{
|
{
|
||||||
#ifdef ARCADE
|
#ifdef ARCADE
|
||||||
const int index = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
|
const int index = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
|
||||||
Notifier::get()->showText(lang::getText(index), std::string(), -1, exit_code);
|
Notifier::get()->showText({lang::getText(index), std::string()}, -1, exit_code);
|
||||||
#else
|
#else
|
||||||
Notifier::get()->showText(lang::getText(94), std::string(), -1, exit_code);
|
Notifier::get()->showText({lang::getText(94), std::string()}, -1, exit_code);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ namespace globalInputs
|
|||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
section::name = section::Name::INIT;
|
section::name = section::Name::INIT;
|
||||||
Notifier::get()->showText("Reset");
|
Notifier::get()->showText({"Reset"});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activa o desactiva el audio
|
// Activa o desactiva el audio
|
||||||
@@ -68,7 +68,7 @@ namespace globalInputs
|
|||||||
JA_SetMusicVolume(0);
|
JA_SetMusicVolume(0);
|
||||||
JA_SetSoundVolume(0);
|
JA_SetSoundVolume(0);
|
||||||
}
|
}
|
||||||
Notifier::get()->showText("Audio " + boolToOnOff(options.audio.enabled));
|
Notifier::get()->showText({"Audio " + boolToOnOff(options.audio.enabled)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||||
@@ -82,7 +82,7 @@ namespace globalInputs
|
|||||||
{
|
{
|
||||||
Screen::get()->toggleVideoMode();
|
Screen::get()->toggleVideoMode();
|
||||||
const std::string mode = options.video.mode == ScreenVideoMode::WINDOW ? "Window" : "Fullscreen";
|
const std::string mode = options.video.mode == ScreenVideoMode::WINDOW ? "Window" : "Fullscreen";
|
||||||
Notifier::get()->showText(mode + " mode");
|
Notifier::get()->showText({mode + " mode"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ namespace globalInputs
|
|||||||
{
|
{
|
||||||
Screen::get()->decWindowSize();
|
Screen::get()->decWindowSize();
|
||||||
const std::string size = std::to_string(options.video.window.size);
|
const std::string size = std::to_string(options.video.window.size);
|
||||||
Notifier::get()->showText("Window size x" + size);
|
Notifier::get()->showText({"Window size x" + size});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ namespace globalInputs
|
|||||||
{
|
{
|
||||||
Screen::get()->incWindowSize();
|
Screen::get()->incWindowSize();
|
||||||
const std::string size = std::to_string(options.video.window.size);
|
const std::string size = std::to_string(options.video.window.size);
|
||||||
Notifier::get()->showText("Window size x" + size);
|
Notifier::get()->showText({"Window size x" + size});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include <SDL2/SDL.h> // para SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
|
#include <SDL2/SDL.h> // Para SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
|
||||||
#include <SDL2/SDL_error.h> // para SDL_GetError
|
#include <SDL2/SDL_error.h> // Para SDL_GetError
|
||||||
#include <SDL2/SDL_events.h> // para SDL_ENABLE
|
#include <SDL2/SDL_events.h> // Para SDL_ENABLE
|
||||||
#include <SDL2/SDL_keyboard.h> // para SDL_GetKeyboardState
|
#include <SDL2/SDL_keyboard.h> // Para SDL_GetKeyboardState
|
||||||
#include <iostream> // para basic_ostream, operator<<, cout, basi...
|
#include <algorithm> // Para find
|
||||||
#include <unordered_map>
|
#include <iostream> // Para basic_ostream, operator<<, cout, endl
|
||||||
#include <algorithm>
|
#include <iterator> // Para distance
|
||||||
|
#include <unordered_map> // Para unordered_map, operator==, _Node_cons...
|
||||||
|
#include <utility> // Para pair
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
Input *Input::input_ = nullptr;
|
Input *Input::input_ = nullptr;
|
||||||
@@ -80,14 +82,7 @@ bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, in
|
|||||||
|
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (keyStates[key_bindings_[input_index].scancode] != 0)
|
success_keyboard = keyStates[key_bindings_[input_index].scancode] != 0;
|
||||||
{
|
|
||||||
success_keyboard = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
success_keyboard = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -108,12 +103,8 @@ bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, in
|
|||||||
if (keyStates[key_bindings_[input_index].scancode] == 0)
|
if (keyStates[key_bindings_[input_index].scancode] == 0)
|
||||||
{
|
{
|
||||||
key_bindings_[input_index].active = false;
|
key_bindings_[input_index].active = false;
|
||||||
success_keyboard = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
success_keyboard = false;
|
|
||||||
}
|
}
|
||||||
|
success_keyboard = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,22 +117,15 @@ bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, in
|
|||||||
{
|
{
|
||||||
if (repeat)
|
if (repeat)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[controller_index], controller_bindings_[controller_index][input_index].button) != 0)
|
success_controller = SDL_GameControllerGetButton(connected_controllers_.at(controller_index), controller_bindings_.at(controller_index).at(input_index).button) != 0;
|
||||||
{
|
|
||||||
success_controller = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
success_controller = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!controller_bindings_[controller_index][input_index].active)
|
if (!controller_bindings_.at(controller_index).at(input_index).active)
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[controller_index], controller_bindings_[controller_index][input_index].button) != 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(controller_index), controller_bindings_.at(controller_index).at(input_index).button) != 0)
|
||||||
{
|
{
|
||||||
controller_bindings_[controller_index][input_index].active = true;
|
controller_bindings_.at(controller_index).at(input_index).active = true;
|
||||||
success_controller = true;
|
success_controller = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -151,15 +135,11 @@ bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SDL_GameControllerGetButton(connected_controllers_[controller_index], controller_bindings_[controller_index][input_index].button) == 0)
|
if (SDL_GameControllerGetButton(connected_controllers_.at(controller_index), controller_bindings_.at(controller_index).at(input_index).button) == 0)
|
||||||
{
|
{
|
||||||
controller_bindings_[controller_index][input_index].active = false;
|
controller_bindings_.at(controller_index).at(input_index).active = false;
|
||||||
success_controller = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
success_controller = false;
|
|
||||||
}
|
}
|
||||||
|
success_controller = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,11 +151,6 @@ bool Input::checkInput(InputType input, bool repeat, InputDeviceToUse device, in
|
|||||||
// Comprueba si hay almenos un input activo
|
// Comprueba si hay almenos un input activo
|
||||||
bool Input::checkAnyInput(InputDeviceToUse device, int controller_index)
|
bool Input::checkAnyInput(InputDeviceToUse device, int controller_index)
|
||||||
{
|
{
|
||||||
if (device == InputDeviceToUse::ANY)
|
|
||||||
{
|
|
||||||
controller_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
|
if (device == InputDeviceToUse::KEYBOARD || device == InputDeviceToUse::ANY)
|
||||||
{
|
{
|
||||||
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
const Uint8 *mKeystates = SDL_GetKeyboardState(nullptr);
|
||||||
@@ -411,10 +386,4 @@ bool Input::checkAxisInput(InputType input, int controller_index) const
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el indice de mando que usará el teclado
|
|
||||||
void Input::setKeyboardIndex(int index)
|
|
||||||
{
|
|
||||||
keyboard_index_ = index;
|
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,6 @@ private:
|
|||||||
int num_joysticks_ = 0; // Número de joysticks conectados
|
int num_joysticks_ = 0; // Número de joysticks conectados
|
||||||
int num_gamepads_ = 0; // Número de mandos conectados
|
int num_gamepads_ = 0; // Número de mandos conectados
|
||||||
std::string game_controller_db_path_; // Ruta al archivo gamecontrollerdb.txt
|
std::string game_controller_db_path_; // Ruta al archivo gamecontrollerdb.txt
|
||||||
int keyboard_index_ = 0;
|
|
||||||
|
|
||||||
// Comprueba el eje del mando
|
// Comprueba el eje del mando
|
||||||
bool checkAxisInput(InputType input, int controller_index = 0) const;
|
bool checkAxisInput(InputType input, int controller_index = 0) const;
|
||||||
@@ -161,7 +160,4 @@ public:
|
|||||||
|
|
||||||
// Obtiene el indice a partir del nombre del mando
|
// Obtiene el indice a partir del nombre del mando
|
||||||
int getIndexByName(const std::string &name) const;
|
int getIndexByName(const std::string &name) const;
|
||||||
|
|
||||||
// Establece el indice de mando que usará el teclado
|
|
||||||
void setKeyboardIndex(int index);
|
|
||||||
};
|
};
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "section.h" // Para Name, name, Options, options
|
#include "section.h" // Para Name, name, Options, options
|
||||||
#include "sprite.h" // Para Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
|
#include "utils.h" // Para Color, Zone
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Logo::Logo()
|
Logo::Logo()
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_rect.h> // para SDL_Point
|
#include <SDL2/SDL_rect.h> // Para SDL_Point
|
||||||
#include <SDL2/SDL_stdinc.h> // para Uint32
|
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
||||||
#include <memory> // para unique_ptr, shared_ptr
|
#include <memory> // Para shared_ptr, unique_ptr
|
||||||
#include <vector> // para vector
|
#include <vector> // Para vector
|
||||||
#include "sprite.h" // para Sprite
|
class Sprite;
|
||||||
#include "utils.h" // para Color
|
class Texture; // lines 9-9
|
||||||
class Texture;
|
struct Color;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
|
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||||
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
#include <algorithm>
|
||||||
#include "param.h" // Para Param, param, ParamNotification, Par...
|
#include <vector>
|
||||||
#include "screen.h" // Para Screen
|
#include "jail_audio.h" // Para JA_DeleteSound, JA_LoadSound, JA_Pla...
|
||||||
#include "sprite.h" // Para Sprite
|
#include "param.h" // Para Param, param, ParamNotification, Par...
|
||||||
#include "text.h" // Para Text
|
#include "screen.h" // Para Screen
|
||||||
#include "texture.h" // Para Texture
|
#include "sprite.h" // Para Sprite
|
||||||
|
#include "text.h" // Para Text
|
||||||
|
#include "texture.h" // Para Texture
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
Notifier *Notifier::notifier_ = nullptr;
|
Notifier *Notifier::notifier_ = nullptr;
|
||||||
@@ -51,7 +53,9 @@ Notifier::~Notifier()
|
|||||||
void Notifier::render()
|
void Notifier::render()
|
||||||
{
|
{
|
||||||
for (int i = (int)notifications_.size() - 1; i >= 0; --i)
|
for (int i = (int)notifications_.size() - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
notifications_[i].sprite->render();
|
notifications_[i].sprite->render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado de las notificaiones
|
// Actualiza el estado de las notificaiones
|
||||||
@@ -154,39 +158,41 @@ void Notifier::clearFinishedNotifications()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notifier::showText(std::string text1, std::string text2, int icon, const std::string &code)
|
void Notifier::showText(std::vector<std::string> texts, int icon, const std::string &code)
|
||||||
{
|
{
|
||||||
// Cuenta el número de textos a mostrar
|
|
||||||
const int num_texts = !text1.empty() + !text2.empty();
|
|
||||||
|
|
||||||
// Si no hay texto, acaba
|
// Si no hay texto, acaba
|
||||||
if (num_texts == 0)
|
if (texts.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si solo hay un texto, lo coloca en la primera variable
|
|
||||||
if (num_texts == 1)
|
|
||||||
{
|
|
||||||
text1 += text2;
|
|
||||||
text2.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Si las notificaciones no se apilan, elimina las anteriores
|
// Si las notificaciones no se apilan, elimina las anteriores
|
||||||
if (!stack_)
|
if (!stack_)
|
||||||
{
|
{
|
||||||
clearNotifications();
|
clearNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elimina las cadenas vacías
|
||||||
|
texts.erase(std::remove_if(texts.begin(), texts.end(), [](const std::string &s)
|
||||||
|
{ return s.empty(); }),
|
||||||
|
texts.end());
|
||||||
|
|
||||||
|
// Encuentra la cadena más larga
|
||||||
|
std::string longest;
|
||||||
|
for (const auto &text : texts)
|
||||||
|
{
|
||||||
|
if (text.length() > longest.length())
|
||||||
|
longest = text;
|
||||||
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
constexpr auto icon_size = 16;
|
constexpr int icon_size = 16;
|
||||||
constexpr auto padding_out = 1;
|
constexpr int padding_out = 1;
|
||||||
const auto padding_in_h = text_->getCharacterSize();
|
const auto padding_in_h = text_->getCharacterSize();
|
||||||
const auto padding_in_v = text_->getCharacterSize() / 2;
|
const auto padding_in_v = text_->getCharacterSize() / 2;
|
||||||
const auto icon_space = icon >= 0 ? icon_size + padding_in_h : 0;
|
const int icon_space = icon >= 0 ? icon_size + padding_in_h : 0;
|
||||||
const std::string txt = text1.length() > text2.length() ? text1 : text2;
|
const int width = text_->lenght(longest) + (padding_in_h * 2) + icon_space;
|
||||||
const auto width = text_->lenght(txt) + (padding_in_h * 2) + icon_space;
|
const int height = (text_->getCharacterSize() * texts.size()) + (padding_in_v * 2);
|
||||||
const auto height = (text_->getCharacterSize() * num_texts) + (padding_in_v * 2);
|
|
||||||
const auto shape = NotificationShape::SQUARED;
|
const auto shape = NotificationShape::SQUARED;
|
||||||
|
|
||||||
// Posición horizontal
|
// Posición horizontal
|
||||||
@@ -212,11 +218,11 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
auto offset = 0;
|
auto offset = 0;
|
||||||
if (param.notification.pos_v == NotifyPosition::TOP)
|
if (param.notification.pos_v == NotifyPosition::TOP)
|
||||||
{
|
{
|
||||||
offset = (int)notifications_.size() > 0 ? notifications_.back().y + travel_dist : desp_v;
|
offset = !notifications_.empty() ? notifications_.back().y + travel_dist : desp_v;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offset = (int)notifications_.size() > 0 ? notifications_.back().y - travel_dist : desp_v;
|
offset = !notifications_.empty() ? notifications_.back().y - travel_dist : desp_v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la notificacion
|
// Crea la notificacion
|
||||||
@@ -226,8 +232,7 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
n.code = code;
|
n.code = code;
|
||||||
n.y = offset;
|
n.y = offset;
|
||||||
n.travel_dist = travel_dist;
|
n.travel_dist = travel_dist;
|
||||||
n.text1 = text1;
|
n.texts = texts;
|
||||||
n.text2 = text2;
|
|
||||||
n.shape = shape;
|
n.shape = shape;
|
||||||
auto y_pos = offset + (param.notification.pos_v == NotifyPosition::TOP ? -travel_dist : travel_dist);
|
auto y_pos = offset + (param.notification.pos_v == NotifyPosition::TOP ? -travel_dist : travel_dist);
|
||||||
n.rect = {desp_h, y_pos, width, height};
|
n.rect = {desp_h, y_pos, width, height};
|
||||||
@@ -264,7 +269,7 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el icono de la notificación
|
// Dibuja el icono de la notificación
|
||||||
if (has_icons_ && icon >= 0 && num_texts == 2)
|
if (has_icons_ && icon >= 0 && texts.size() >= 2)
|
||||||
{
|
{
|
||||||
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_Rect){0, 0, icon_size, icon_size});
|
auto sp = std::make_unique<Sprite>(icon_texture_, (SDL_Rect){0, 0, icon_size, icon_size});
|
||||||
sp->setPosition({padding_in_h, padding_in_v, icon_size, icon_size});
|
sp->setPosition({padding_in_h, padding_in_v, icon_size, icon_size});
|
||||||
@@ -273,15 +278,12 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto de la notificación
|
// Escribe el texto de la notificación
|
||||||
Color color{255, 255, 255};
|
const Color color{255, 255, 255};
|
||||||
if (num_texts == 2)
|
int iterator = 0;
|
||||||
{ // Dos lineas de texto
|
for (const auto &text : texts)
|
||||||
text_->writeColored(padding_in_h + icon_space, padding_in_v, text1, color);
|
{
|
||||||
text_->writeColored(padding_in_h + icon_space, padding_in_v + text_->getCharacterSize() + 1, text2, color);
|
text_->writeColored(padding_in_h + icon_space, padding_in_v + iterator * (text_->getCharacterSize() + 1), text, color);
|
||||||
}
|
++iterator;
|
||||||
else
|
|
||||||
{ // Una linea de texto
|
|
||||||
text_->writeColored(padding_in_h + icon_space, padding_in_v, text1, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deja de dibujar en la textura
|
// Deja de dibujar en la textura
|
||||||
@@ -294,26 +296,18 @@ void Notifier::showText(std::string text1, std::string text2, int icon, const st
|
|||||||
n.texture->setAlpha(0);
|
n.texture->setAlpha(0);
|
||||||
|
|
||||||
// Añade la notificación a la lista
|
// Añade la notificación a la lista
|
||||||
notifications_.push_back(n);
|
notifications_.emplace_back(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool Notifier::isActive()
|
bool Notifier::isActive() { return !notifications_.empty(); }
|
||||||
{
|
|
||||||
if ((int)notifications_.size() > 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finaliza y elimnina todas las notificaciones activas
|
// Finaliza y elimnina todas las notificaciones activas
|
||||||
void Notifier::clearNotifications()
|
void Notifier::clearNotifications()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)notifications_.size(); ++i)
|
for (auto ¬ification : notifications_)
|
||||||
{
|
{
|
||||||
notifications_[i].status = NotificationStatus::FINISHED;
|
notification.status = NotificationStatus::FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearFinishedNotifications();
|
clearFinishedNotifications();
|
||||||
@@ -323,9 +317,9 @@ void Notifier::clearNotifications()
|
|||||||
std::vector<std::string> Notifier::getCodes()
|
std::vector<std::string> Notifier::getCodes()
|
||||||
{
|
{
|
||||||
std::vector<std::string> codes;
|
std::vector<std::string> codes;
|
||||||
for (int i = 0; i < (int)notifications_.size(); ++i)
|
for (const auto ¬ification : notifications_)
|
||||||
{
|
{
|
||||||
codes.push_back(notifications_[i].code);
|
codes.emplace_back(notification.code);
|
||||||
}
|
}
|
||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,7 @@ private:
|
|||||||
{
|
{
|
||||||
std::shared_ptr<Texture> texture;
|
std::shared_ptr<Texture> texture;
|
||||||
std::shared_ptr<Sprite> sprite;
|
std::shared_ptr<Sprite> sprite;
|
||||||
std::string text1;
|
std::vector<std::string> texts;
|
||||||
std::string text2;
|
|
||||||
int counter;
|
int counter;
|
||||||
NotificationStatus status;
|
NotificationStatus status;
|
||||||
NotificationShape shape;
|
NotificationShape shape;
|
||||||
@@ -47,7 +46,7 @@ private:
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
explicit Notification()
|
explicit Notification()
|
||||||
: texture(nullptr), sprite(nullptr), text1(""), text2(""), counter(0), status(NotificationStatus::RISING),
|
: texture(nullptr), sprite(nullptr), texts(), counter(0), status(NotificationStatus::RISING),
|
||||||
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code("") {}
|
shape(NotificationShape::SQUARED), rect{0, 0, 0, 0}, y(0), travel_dist(0), code("") {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,15 +94,8 @@ public:
|
|||||||
// Actualiza el estado de las notificaiones
|
// Actualiza el estado de las notificaiones
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
/**
|
// Muestra una notificación de texto por pantalla
|
||||||
* @brief Muestra una notificación de texto por pantalla.
|
void showText(std::vector<std::string> texts, int icon = -1, const std::string &code = std::string());
|
||||||
*
|
|
||||||
* @param text1 Primer texto opcional para mostrar (valor predeterminado: cadena vacía).
|
|
||||||
* @param text2 Segundo texto opcional para mostrar (valor predeterminado: cadena vacía).
|
|
||||||
* @param icon Icono opcional para mostrar (valor predeterminado: -1).
|
|
||||||
* @param code Permite asignar un código a la notificación (valor predeterminado: cadena vacía).
|
|
||||||
*/
|
|
||||||
void showText(std::string text1 = std::string(), std::string text2 = std::string(), int icon = -1, const std::string &code = std::string());
|
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton, SDL_C...
|
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
|
||||||
#include <algorithm> // para max, min
|
#include <algorithm> // Para clamp
|
||||||
#include <fstream> // para basic_ostream, operator<<, basi...
|
#include <fstream> // Para basic_ostream, operator<<, basi...
|
||||||
#include <iostream> // para cout
|
#include <iostream> // Para cout
|
||||||
#include <vector> // para vector
|
#include <utility> // Para swap
|
||||||
#include "input.h" // para inputs_e, InputDeviceToUse::ANY, INPUT_...
|
#include <vector> // Para vector
|
||||||
#include "lang.h" // para lang_e
|
#include "input.h" // Para InputDeviceToUse
|
||||||
#include "screen.h" // para ScreenVideoMode, ScreenFilter
|
#include "lang.h" // Para Code
|
||||||
#include "utils.h" // para OptionsController, Options, op_...
|
#include "screen.h" // Para ScreenVideoMode, ScreenFilter
|
||||||
|
#include "utils.h" // Para boolToString, stringToBool, get...
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
Options options;
|
Options options;
|
||||||
@@ -166,17 +167,21 @@ bool saveOptionsFile(std::string file_path)
|
|||||||
// Opciones de mandos
|
// Opciones de mandos
|
||||||
file << "\n\n## CONTROLLERS\n";
|
file << "\n\n## CONTROLLERS\n";
|
||||||
|
|
||||||
|
int controller_index = 0;
|
||||||
for (const auto &controller : options.controllers)
|
for (const auto &controller : options.controllers)
|
||||||
{
|
{
|
||||||
file << "\n";
|
file << "\n";
|
||||||
file << "controller." << controller.index << ".name=" << controller.name << "\n";
|
file << "controller." << controller_index << ".name=" << controller.name << "\n";
|
||||||
file << "controller." << controller.index << ".player=" << controller.player_id << "\n";
|
file << "controller." << controller_index << ".player=" << controller.player_id << "\n";
|
||||||
file << "controller." << controller.index << ".type=" << static_cast<int>(controller.type) << "\n";
|
file << "controller." << controller_index << ".type=" << static_cast<int>(controller.type) << "\n";
|
||||||
file << "controller." << controller.index << ".button.fire_left=" << controller.buttons.at(0) << "\n";
|
file << "controller." << controller_index << ".button.fire_left=" << controller.buttons.at(0) << "\n";
|
||||||
file << "controller." << controller.index << ".button.fire_center=" << controller.buttons.at(1) << "\n";
|
file << "controller." << controller_index << ".button.fire_center=" << controller.buttons.at(1) << "\n";
|
||||||
file << "controller." << controller.index << ".button.fire_right=" << controller.buttons.at(2) << "\n";
|
file << "controller." << controller_index << ".button.fire_right=" << controller.buttons.at(2) << "\n";
|
||||||
file << "controller." << controller.index << ".button.start=" << controller.buttons.at(3) << "\n";
|
file << "controller." << controller_index << ".button.start=" << controller.buttons.at(3) << "\n";
|
||||||
file << "controller." << controller.index << ".button.service=" << controller.buttons.at(4) << "\n";
|
file << "controller." << controller_index << ".button.service=" << controller.buttons.at(4) << "\n";
|
||||||
|
|
||||||
|
// Incrementa el índice
|
||||||
|
++controller_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cierra el fichero
|
// Cierra el fichero
|
||||||
@@ -378,7 +383,7 @@ void swapOptionsControllers()
|
|||||||
// Averigua quien está usando el teclado
|
// Averigua quien está usando el teclado
|
||||||
int getPlayerWhoUsesKeyboard()
|
int getPlayerWhoUsesKeyboard()
|
||||||
{
|
{
|
||||||
for (auto &controller : options.controllers)
|
for (const auto &controller : options.controllers)
|
||||||
{
|
{
|
||||||
if (controller.type == InputDeviceToUse::ANY)
|
if (controller.type == InputDeviceToUse::ANY)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
|
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
|
||||||
#include <SDL2/SDL_stdinc.h> // Para Uint8
|
#include <string> // Para string
|
||||||
#include "manage_hiscore_table.h"
|
#include <vector> // Para vector
|
||||||
#include <vector> // Para vector
|
#include "input.h" // Para InputType, InputDeviceToUse
|
||||||
#include "input.h"
|
#include "manage_hiscore_table.h" // Para HiScoreEntry
|
||||||
#include <string>
|
enum class ScreenFilter : int; // lines 10-10
|
||||||
enum class InputType : int;
|
enum class ScreenVideoMode : int; // lines 11-11
|
||||||
enum class ScreenFilter : int;
|
|
||||||
enum class ScreenVideoMode : int;
|
|
||||||
namespace lang
|
namespace lang
|
||||||
{
|
{
|
||||||
enum class Code : int;
|
enum class Code : int;
|
||||||
}
|
} // lines 14-14
|
||||||
|
|
||||||
// Dificultad del juego
|
// Dificultad del juego
|
||||||
enum class GameDifficulty
|
enum class GameDifficulty
|
||||||
@@ -76,7 +74,7 @@ struct OptionsController
|
|||||||
{
|
{
|
||||||
int index; // Indice en el vector de mandos
|
int index; // Indice en el vector de mandos
|
||||||
int player_id; // Jugador asociado al mando
|
int player_id; // Jugador asociado al mando
|
||||||
InputDeviceToUse type; // Indica si se utilizará teclado o mando o ambos
|
InputDeviceToUse type; // Indica si se utilizará teclado o mando o ambos
|
||||||
std::string name; // Nombre del dispositivo
|
std::string name; // Nombre del dispositivo
|
||||||
bool plugged; // Indica si el mando se encuentra conectado
|
bool plugged; // Indica si el mando se encuentra conectado
|
||||||
std::vector<InputType> inputs; // Listado de inputs
|
std::vector<InputType> inputs; // Listado de inputs
|
||||||
@@ -84,11 +82,9 @@ struct OptionsController
|
|||||||
|
|
||||||
// Constructor por defecto
|
// Constructor por defecto
|
||||||
OptionsController()
|
OptionsController()
|
||||||
: index(-1), player_id(-1), type(InputDeviceToUse::CONTROLLER), name(""), plugged(false)
|
: index(-1), player_id(-1), type(InputDeviceToUse::CONTROLLER), name(""), plugged(false),
|
||||||
{
|
inputs{InputType::FIRE_LEFT, InputType::FIRE_CENTER, InputType::FIRE_RIGHT, InputType::START, InputType::SERVICE},
|
||||||
inputs = {InputType::FIRE_LEFT, InputType::FIRE_CENTER, InputType::FIRE_RIGHT, InputType::START, InputType::SERVICE};
|
buttons{SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_BACK} {}
|
||||||
buttons = {SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_BACK};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura con todas las opciones de configuración del programa
|
// Estructura con todas las opciones de configuración del programa
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "path_sprite.h"
|
#include "path_sprite.h"
|
||||||
#include <cmath> // for abs
|
#include <cmath> // Para abs
|
||||||
#include <stdlib.h> // for abs
|
#include <stdlib.h> // Para abs
|
||||||
#include <functional> // for function
|
#include <functional> // Para function
|
||||||
#include <utility> // for move
|
#include <utility> // Para move
|
||||||
|
|
||||||
// Devuelve un vector con los puntos que conforman la ruta
|
// Devuelve un vector con los puntos que conforman la ruta
|
||||||
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
|
std::vector<SDL_Point> createPath(int start, int end, PathType type, int fixed_pos, int steps, const std::function<double(double)> &easingFunction)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_rect.h> // for SDL_Point
|
#include <SDL2/SDL_rect.h> // Para SDL_Point
|
||||||
#include <functional> // for function
|
#include <functional> // Para function
|
||||||
#include <memory> // for shared_ptr
|
#include <memory> // Para shared_ptr
|
||||||
#include <vector> // for vector
|
#include <vector> // Para vector
|
||||||
#include "sprite.h" // for Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
class Texture; // lines 8-8
|
class Texture; // lines 8-8
|
||||||
|
|
||||||
enum class PathType
|
enum class PathType
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
|
#include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
|
||||||
#include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
|
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
|
||||||
#include <SDL2/SDL_stdinc.h> // para Uint32
|
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
||||||
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||||
#include <memory> // para unique_ptr, shared_ptr
|
#include <stddef.h> // Para size_t
|
||||||
#include <string> // para string
|
#include <memory> // Para unique_ptr, shared_ptr
|
||||||
#include <vector> // para vector
|
#include <string> // Para string
|
||||||
#include "utils.h" // para Color
|
#include <vector> // Para vector
|
||||||
class Sprite;
|
#include "utils.h" // Para Color
|
||||||
class Text;
|
class Sprite; // lines 11-11
|
||||||
class Texture;
|
class Text; // lines 12-12
|
||||||
|
class Texture; // lines 13-13
|
||||||
|
|
||||||
// Defines
|
// Defines
|
||||||
constexpr int SCOREBOARD_LEFT_PANEL = 0;
|
constexpr int SCOREBOARD_LEFT_PANEL = 0;
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
#include <algorithm> // Para clamp, max, min
|
#include <algorithm> // Para clamp, max, min
|
||||||
#include <fstream> // Para basic_ifstream, ifstream
|
#include <fstream> // Para basic_ifstream, ifstream
|
||||||
#include <iterator> // Para istreambuf_iterator, operator==
|
#include <iterator> // Para istreambuf_iterator, operator==
|
||||||
#include <string> // Para allocator, operator+, to_string, char_t...
|
#include <string> // Para allocator, operator+, char_traits, to_s...
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include "asset.h" // Para Asset
|
#include "asset.h" // Para Asset
|
||||||
#include "dbgtxt.h" // Para dbg_print
|
#include "dbgtxt.h" // Para dbg_print
|
||||||
#include "global_inputs.h" // Para service_pressed_counter
|
#include "global_inputs.h" // Para service_pressed_counter
|
||||||
#include "input.h" // Para Input, InputType, INPUT_DO_NOT_ALLOW_RE...
|
#include "jail_shader.h" // Para init, render
|
||||||
#include "notifier.h" // Para Notifier
|
#include "notifier.h" // Para Notifier
|
||||||
#include "on_screen_help.h" // Para OnScreenHelp
|
#include "on_screen_help.h" // Para OnScreenHelp
|
||||||
#include "options.h" // Para Options, OptionsVideo, options, Options...
|
#include "options.h" // Para Options, OptionsVideo, options, Options...
|
||||||
@@ -342,7 +342,7 @@ void Screen::toggleShaders()
|
|||||||
options.video.shaders = !options.video.shaders;
|
options.video.shaders = !options.video.shaders;
|
||||||
setVideoMode(options.video.mode);
|
setVideoMode(options.video.mode);
|
||||||
const std::string value = options.video.shaders ? "on" : "off";
|
const std::string value = options.video.shaders ? "on" : "off";
|
||||||
Notifier::get()->showText("Shaders " + value);
|
Notifier::get()->showText({"Shaders " + value});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activa / desactiva la información de debug
|
// Activa / desactiva la información de debug
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
||||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
||||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
||||||
#include <SDL2/SDL_render.h> // for SDL_TEXTUREACCESS_TARGET
|
#include <SDL2/SDL_render.h> // Para SDL_TEXTUREACCESS_TARGET
|
||||||
#include <stddef.h> // for size_t
|
#include <stddef.h> // Para size_t
|
||||||
#include <fstream> // for basic_ifstream, basic_istream, basic...
|
#include <fstream> // Para basic_ifstream, basic_istream, basic...
|
||||||
#include <iostream> // for cerr
|
#include <iostream> // Para cerr
|
||||||
#include <stdexcept> // for runtime_error
|
#include <stdexcept> // Para runtime_error
|
||||||
#include "screen.h" // for Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "sprite.h" // for Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
#include "texture.h" // for Texture
|
#include "texture.h" // Para Texture
|
||||||
#include "utils.h" // for Color, getFileName, printWithDots
|
#include "utils.h" // Para Color, getFileName, printWithDots
|
||||||
|
|
||||||
// Llena una estructuta TextFile desde un fichero
|
// Llena una estructuta TextFile desde un fichero
|
||||||
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)
|
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include <SDL2/SDL_error.h> // Para SDL_GetError
|
#include <SDL2/SDL_error.h> // Para SDL_GetError
|
||||||
#include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
|
#include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
|
||||||
#include <fcntl.h> // Para SEEK_END, SEEK_SET
|
|
||||||
#include <stdio.h> // Para fseek, fclose, fopen, fread, ftell, FILE
|
|
||||||
#include <stdlib.h> // Para free, malloc
|
|
||||||
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream
|
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream
|
||||||
#include <iostream> // Para cerr, cout
|
#include <iostream> // Para cerr, cout
|
||||||
#include <stdexcept> // Para runtime_error
|
#include <stdexcept> // Para runtime_error
|
||||||
|
#include <string> // Para char_traits, operator<<, operator+
|
||||||
|
#include <vector> // Para vector
|
||||||
#include "gif.c" // Para LoadGif, LoadPalette
|
#include "gif.c" // Para LoadGif, LoadPalette
|
||||||
|
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_a...
|
||||||
#include "utils.h" // Para getFileName, printWithDots
|
#include "utils.h" // Para getFileName, printWithDots
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
@@ -315,8 +315,8 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
|
|||||||
{
|
{
|
||||||
std::vector<Uint32> palette;
|
std::vector<Uint32> palette;
|
||||||
|
|
||||||
FILE *f = fopen(file_path.c_str(), "rb");
|
std::ifstream file(file_path, std::ios::binary | std::ios::ate);
|
||||||
if (!f)
|
if (!file)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << std::endl;
|
std::cerr << "Error: Fichero no encontrado " << getFileName(file_path) << std::endl;
|
||||||
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
throw std::runtime_error("Fichero no encontrado: " + getFileName(file_path));
|
||||||
@@ -326,21 +326,22 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
|
|||||||
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]");
|
printWithDots("Image : ", getFileName(file_path), "[ LOADED ]");
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
auto size = file.tellg();
|
||||||
long size = ftell(f);
|
file.seekg(0, std::ios::beg);
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
Uint8 *buffer = static_cast<Uint8 *>(malloc(size));
|
|
||||||
fread(buffer, size, 1, f);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
const auto *pal = LoadPalette(buffer);
|
std::vector<Uint8> buffer(size);
|
||||||
|
if (!file.read(reinterpret_cast<char *>(buffer.data()), size))
|
||||||
|
{
|
||||||
|
std::cerr << "Error: No se pudo leer completamente el fichero " << getFileName(file_path) << std::endl;
|
||||||
|
throw std::runtime_error("Error al leer el fichero: " + getFileName(file_path));
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto pal = LoadPalette(buffer.data());
|
||||||
if (!pal)
|
if (!pal)
|
||||||
{
|
{
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
for (int i = 0; i < 256; ++i)
|
for (int i = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
palette.push_back((pal[i] << 8) + 255);
|
palette.push_back((pal[i] << 8) + 255);
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
|
||||||
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3
|
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5
|
||||||
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
||||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||||
#include <string> // Para char_traits, operator+, to_string, bas...
|
#include <stddef.h> // Para size_t
|
||||||
|
#include <string> // Para char_traits, operator+, basic_string
|
||||||
#include <utility> // Para move
|
#include <utility> // Para move
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include "define_buttons.h" // Para DefineButtons
|
#include "define_buttons.h" // Para DefineButtons
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
#include "param.h" // Para Param, param, ParamGame, ParamTitle
|
#include "param.h" // Para Param, param, ParamGame, ParamTitle
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
#include "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "section.h" // Para Options, options, name, Name
|
#include "section.h" // Para Options, options, Name, name, AttractMode
|
||||||
#include "sprite.h" // Para Sprite
|
#include "sprite.h" // Para Sprite
|
||||||
#include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW
|
#include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
@@ -173,7 +174,7 @@ void Title::checkEvents()
|
|||||||
{
|
{
|
||||||
// Comprueba el input para el resto de objetos
|
// Comprueba el input para el resto de objetos
|
||||||
define_buttons_->checkEvents();
|
define_buttons_->checkEvents();
|
||||||
|
|
||||||
// Si define_buttons_ está habilitado, es él quien gestiona los eventos
|
// Si define_buttons_ está habilitado, es él quien gestiona los eventos
|
||||||
if (!define_buttons_->isEnabled())
|
if (!define_buttons_->isEnabled())
|
||||||
{
|
{
|
||||||
@@ -213,16 +214,19 @@ void Title::checkEvents()
|
|||||||
case SDLK_3: // Intercambia los mandos entre los dos jugadores
|
case SDLK_3: // Intercambia los mandos entre los dos jugadores
|
||||||
{
|
{
|
||||||
swapControllers();
|
swapControllers();
|
||||||
|
resetCounter();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDLK_4: // Muestra la asignacion de mandos
|
case SDLK_4: // Intercambia la asignación del teclado
|
||||||
{
|
|
||||||
showControllers();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDLK_5: // Intercambia la asignación del teclado
|
|
||||||
{
|
{
|
||||||
swapKeyboard();
|
swapKeyboard();
|
||||||
|
resetCounter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_5: // Muestra la asignacion de mandos y teclado
|
||||||
|
{
|
||||||
|
showControllers();
|
||||||
|
resetCounter();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -311,7 +315,8 @@ void Title::swapControllers()
|
|||||||
void Title::swapKeyboard()
|
void Title::swapKeyboard()
|
||||||
{
|
{
|
||||||
swapOptionsKeyboard();
|
swapOptionsKeyboard();
|
||||||
Notifier::get()->showText("Teclat per al jugador " + std::to_string(getPlayerWhoUsesKeyboard()));
|
std::string text = lang::getText(100) + std::to_string(getPlayerWhoUsesKeyboard()) + ": " + lang::getText(69);
|
||||||
|
Notifier::get()->showText({text});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra información sobre los controles y los jugadores
|
// Muestra información sobre los controles y los jugadores
|
||||||
@@ -339,6 +344,7 @@ void Title::showControllers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifier::get()->showText(text.at(0), text.at(1));
|
// std::string spaces(lang::getText(100).length() + 3, ' ');
|
||||||
resetCounter();
|
// std::string kb_text = spaces + lang::getText(69);
|
||||||
|
Notifier::get()->showText({text.at(0), text.at(1)});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
|
|
||||||
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
#include <SDL2/SDL_stdinc.h> // Para Uint32
|
||||||
#include <memory> // Para unique_ptr, shared_ptr
|
#include <memory> // Para unique_ptr, shared_ptr
|
||||||
#include "section.h" // Para Name
|
class DefineButtons; // lines 6-6
|
||||||
class DefineButtons;
|
class Fade; // lines 7-7
|
||||||
class Fade;
|
class GameLogo; // lines 8-8
|
||||||
class GameLogo;
|
class Sprite; // lines 9-9
|
||||||
class Sprite;
|
class Text; // lines 10-10
|
||||||
class Text;
|
class Texture; // lines 11-11
|
||||||
class Texture; // lines 14-14
|
class TiledBG; // lines 12-12
|
||||||
class TiledBG;
|
namespace section
|
||||||
|
{
|
||||||
|
enum class Name;
|
||||||
|
}
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";
|
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";
|
||||||
|
|||||||
Reference in New Issue
Block a user