From 788aec0dab9871f7c14d5ed7d3304950a61b4010 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 21 Feb 2025 12:02:39 +0100 Subject: [PATCH] Pasaeta de include-what-you-use Afegit fitxer CMakeLists.txt --- .gitignore | 1 + source/animatedsprite.cpp | 4 ++++ source/animatedsprite.h | 14 ++++++------- source/asset.cpp | 5 ++++- source/asset.h | 5 ++--- source/balloon.cpp | 8 +++++++- source/balloon.h | 12 ++++++----- source/bullet.cpp | 4 +++- source/bullet.h | 8 +++++--- source/director.cpp | 37 ++++++++++++++++++++++++++------- source/director.h | 35 ++++++++++++------------------- source/fade.cpp | 8 ++++++-- source/fade.h | 5 +++-- source/game.cpp | 26 +++++++++++++++++++++++ source/game.h | 43 ++++++++++++++++++++++----------------- source/input.cpp | 7 ++++++- source/input.h | 8 +++++--- source/instructions.cpp | 18 +++++++++++++++- source/instructions.h | 21 +++++++++++-------- source/intro.cpp | 13 ++++++++++++ source/intro.h | 24 +++++++++++++--------- source/item.cpp | 5 ++++- source/item.h | 10 ++++++--- source/lang.cpp | 4 ++-- source/lang.h | 6 +++--- source/logo.cpp | 11 ++++++++++ source/logo.h | 17 ++++++++-------- source/main.cpp | 4 ++-- source/menu.cpp | 9 ++++++-- source/menu.h | 19 ++++++++--------- source/movingsprite.cpp | 1 + source/movingsprite.h | 7 +++++-- source/player.cpp | 6 +++++- source/player.h | 13 ++++++------ source/screen.cpp | 10 +++++++-- source/screen.h | 12 ++++++----- source/smartsprite.cpp | 2 ++ source/smartsprite.h | 7 +++---- source/sprite.cpp | 1 + source/sprite.h | 5 +++-- source/text.cpp | 7 +++++-- source/text.h | 8 ++++++-- source/texture.cpp | 9 ++++++-- source/texture.h | 8 +++++--- source/title.cpp | 21 +++++++++++++++++++ source/title.h | 37 ++++++++++++++++++--------------- source/utils.cpp | 3 ++- source/utils.h | 27 +++++++++--------------- source/writer.cpp | 1 + source/writer.h | 5 ++--- 50 files changed, 385 insertions(+), 196 deletions(-) diff --git a/.gitignore b/.gitignore index ff6c66a..880319f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ SDL2.dll libwinpthread-1.dll libstdc++-6.dll libgcc_s_seh-1.dll +linux_utils/ \ No newline at end of file diff --git a/source/animatedsprite.cpp b/source/animatedsprite.cpp index d53889e..233fae8 100644 --- a/source/animatedsprite.cpp +++ b/source/animatedsprite.cpp @@ -1,4 +1,8 @@ #include "animatedsprite.h" +#include // for basic_ostream, operator<<, basic_istream, basic... +#include // for cout +#include // for basic_stringstream +#include "texture.h" // for Texture // Carga la animación desde un fichero animatedSprite_t loadAnimationFromFile(Texture *texture, std::string filePath, bool verbose) diff --git a/source/animatedsprite.h b/source/animatedsprite.h index d7dc898..f0d5c74 100644 --- a/source/animatedsprite.h +++ b/source/animatedsprite.h @@ -1,12 +1,12 @@ #pragma once -#include -#include "movingsprite.h" -#include -#include -#include -#include -#include +#include // for SDL_Rect +#include // for SDL_Renderer +#include // for Uint8 +#include // for string, basic_string +#include // for vector +#include "movingsprite.h" // for MovingSprite +class Texture; struct animation_t { diff --git a/source/asset.cpp b/source/asset.cpp index 1202129..d3a4823 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -1,5 +1,8 @@ #include "asset.h" -#include +#include // for SDL_RWFromFile, SDL_RWclose, SDL_RWops +#include // for SDL_max +#include // for size_t +#include // for basic_ostream, operator<<, cout, endl // Constructor Asset::Asset(std::string executablePath) diff --git a/source/asset.h b/source/asset.h index bb0ffee..51a2318 100644 --- a/source/asset.h +++ b/source/asset.h @@ -1,8 +1,7 @@ #pragma once -#include -#include -#include +#include // for string, basic_string +#include // for vector enum assetType { diff --git a/source/balloon.cpp b/source/balloon.cpp index 4bab7b2..1830f70 100644 --- a/source/balloon.cpp +++ b/source/balloon.cpp @@ -1,5 +1,11 @@ -#include "const.h" #include "balloon.h" +#include // for abs +#include // for abs +#include "animatedsprite.h" // for AnimatedSprite +#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR... +#include "movingsprite.h" // for MovingSprite +#include "sprite.h" // for Sprite +#include "texture.h" // for Texture // Constructor Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector *animation, SDL_Renderer *renderer) diff --git a/source/balloon.h b/source/balloon.h index 29ebfdd..9b8c445 100644 --- a/source/balloon.h +++ b/source/balloon.h @@ -1,10 +1,12 @@ #pragma once -#include -#include "animatedsprite.h" -#include "utils.h" -#include -#include +#include // for SDL_Renderer +#include // for Uint8, Uint16, Uint32 +#include // for string +#include // for vector +#include "utils.h" // for circle_t +class AnimatedSprite; +class Texture; // Cantidad de elementos del vector con los valores de la deformación del globo al rebotar #define MAX_BOUNCE 10 diff --git a/source/bullet.cpp b/source/bullet.cpp index deaab39..66d64ec 100644 --- a/source/bullet.cpp +++ b/source/bullet.cpp @@ -1,5 +1,7 @@ -#include "const.h" #include "bullet.h" +#include "const.h" // for NO_KIND, PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_A... +#include "sprite.h" // for Sprite +class Texture; // Constructor Bullet::Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer) diff --git a/source/bullet.h b/source/bullet.h index 785e0b0..e4e8003 100644 --- a/source/bullet.h +++ b/source/bullet.h @@ -1,8 +1,10 @@ #pragma once -#include -#include "sprite.h" -#include "utils.h" +#include // for SDL_Renderer +#include // for Uint8 +#include "utils.h" // for circle_t +class Sprite; +class Texture; // Tipos de bala #define BULLET_UP 1 diff --git a/source/director.cpp b/source/director.cpp index fee323b..950462c 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -1,11 +1,34 @@ -#include "utils.h" -#include "const.h" #include "director.h" -#include -#include -#include -#include -#include +#include // for SDL_Init, SDL_Quit, SDL_INIT_EV... +#include // for AUDIO_S16 +#include // for SDL_BLENDMODE_BLEND +#include // for SDL_GetError +#include // for SDL_CONTROLLER_BUTTON_B, SDL_CO... +#include // for SDL_SetHint, SDL_HINT_RENDER_SC... +#include // for SDL_SCANCODE_ESCAPE, SDL_SCANCO... +#include // for Uint32 +#include // for SDL_GetTicks +#include // for errno, EEXIST, EACCES, ENAMETOO... +#include // for printf, perror +#include // for strcmp +#include // for mkdir, stat, S_IRWXU +#include // for getuid +#include // for exit, EXIT_FAILURE, srand +#include // for basic_ostream, operator<<, basi... +#include // for cout +#include // for basic_string, operator+, char_t... +#include // for vector +#include "asset.h" // for Asset, assetType +#include "const.h" // for SECTION_PROG_LOGO, GAMECANVAS_H... +#include "game.h" // for Game +#include "input.h" // for Input, inputs_e, INPUT_USE_GAME... +#include "intro.h" // for Intro +#include "jail_audio.h" // for JA_Init +#include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK +#include "logo.h" // for Logo +#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_... +#include "title.h" // for Title +#include "utils.h" // for options_t, input_t, boolToString #ifndef _WIN32 #include diff --git a/source/director.h b/source/director.h index b4d9426..e974cd0 100644 --- a/source/director.h +++ b/source/director.h @@ -1,27 +1,18 @@ #pragma once -#include -#include "balloon.h" -#include "bullet.h" -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "menu.h" -#include "movingsprite.h" -#include "screen.h" -#include "smartsprite.h" -#include "sprite.h" -#include "text.h" -#include "utils.h" -#include "writer.h" -#include "const.h" -#include "fade.h" -#include "game.h" -#include "intro.h" -#include "item.h" -#include "logo.h" -#include "player.h" -#include "title.h" +#include // for SDL_Renderer +#include // for SDL_Window +#include // for string, basic_string +class Asset; +class Game; +class Input; +class Intro; +class Lang; +class Logo; +class Screen; +class Title; +struct options_t; +struct section_t; // Textos #define WINDOW_CAPTION "Coffee Crisis" diff --git a/source/fade.cpp b/source/fade.cpp index 78e986e..6d46b52 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -1,6 +1,10 @@ #include "fade.h" -#include "const.h" -#include +#include // for SDL_GetError +#include // for SDL_PIXELFORMAT_RGBA8888 +#include // for SDL_Delay +#include // for rand +#include // for char_traits, basic_ostream, operator<< +#include "const.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH // Constructor Fade::Fade(SDL_Renderer *renderer) diff --git a/source/fade.h b/source/fade.h index 1a0e478..6cf4dcc 100644 --- a/source/fade.h +++ b/source/fade.h @@ -1,7 +1,8 @@ #pragma once -#include -#include "texture.h" +#include // for SDL_Rect +#include // for SDL_Renderer, SDL_Texture +#include // for Uint8, Uint16 // Tipos de fundido #define FADE_FULLSCREEN 0 diff --git a/source/game.cpp b/source/game.cpp index a01bd3b..2b1257b 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -1,4 +1,30 @@ #include "game.h" +#include // for SDL_GetError +#include // for SDL_RWFromFile, SDL_RWclose, SDL_RWwrite +#include // for SDL_GetTicks, SDL_Delay +#include // for SDL_WINDOWEVENT_FOCUS_LOST +#include // for rand +#include // for max, min +#include // for basic_ifstream +#include // for basic_ostream, char_traits, operator<< +#include "asset.h" // for Asset +#include "balloon.h" // for Balloon, BALLOON_VELX_NEGATIVE, BALLOON_... +#include "bullet.h" // for Bullet, BULLET_LEFT, BULLET_RIGHT, BULLE... +#include "const.h" // for PLAY_AREA_CENTER_X, BLOCK, PLAY_AREA_CEN... +#include "fade.h" // for Fade, FADE_CENTER +#include "input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE +#include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK +#include "jail_audio.h" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound +#include "lang.h" // for Lang +#include "menu.h" // for Menu +#include "movingsprite.h" // for MovingSprite +#include "player.h" // for Player, DEATH_COUNTER +#include "screen.h" // for Screen +#include "smartsprite.h" // for SmartSprite +#include "sprite.h" // for Sprite +#include "text.h" // for Text, TXT_CENTER +#include "texture.h" // for Texture +struct JA_Sound_t; // Constructor Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options, section_t *section) diff --git a/source/game.h b/source/game.h index 4ad19dc..50358e3 100644 --- a/source/game.h +++ b/source/game.h @@ -1,24 +1,29 @@ #pragma once -#include -#include "balloon.h" -#include "bullet.h" -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "menu.h" -#include "movingsprite.h" -#include "screen.h" -#include "smartsprite.h" -#include "sprite.h" -#include "text.h" -#include "utils.h" -#include "writer.h" -#include "const.h" -#include "fade.h" -#include "item.h" -#include "player.h" -#include +#include // for SDL_Event +#include // for SDL_Rect +#include // for SDL_Renderer +#include // for Uint8, Uint16, Uint32 +#include // for string, basic_string +#include // for vector +#include "utils.h" // for demoKeys_t, color_t +class Asset; +class Balloon; +class Bullet; +class Fade; +class Input; +class Item; +class Lang; +class Menu; +class MovingSprite; +class Player; +class Screen; +class SmartSprite; +class Sprite; +class Text; +class Texture; +struct JA_Music_t; +struct JA_Sound_t; // Cantidad de elementos a escribir en los ficheros de datos #define TOTAL_SCORE_DATA 3 diff --git a/source/input.cpp b/source/input.cpp index 25f325e..353d894 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -1,5 +1,10 @@ #include "input.h" -#include +#include // for SDL_INIT_GAMECONTROLLER, SDL_InitSubS... +#include // for SDL_GetError +#include // for SDL_ENABLE +#include // for SDL_NumJoysticks +#include // for SDL_GetKeyboardState +#include // for basic_ostream, operator<<, cout, basi... // Constructor Input::Input(std::string file) diff --git a/source/input.h b/source/input.h index 9fc6e75..40683f8 100644 --- a/source/input.h +++ b/source/input.h @@ -1,8 +1,10 @@ #pragma once -#include -#include -#include +#include // for SDL_GameControllerButton, SDL_G... +#include // for SDL_Scancode +#include // for Uint8 +#include // for string, basic_string +#include // for vector enum inputs_e { diff --git a/source/instructions.cpp b/source/instructions.cpp index 2989eae..3b08e93 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -1,5 +1,21 @@ #include "instructions.h" -#include +#include // for SDL_GetError +#include // for SDL_PIXELFORMAT_RGBA8888 +#include // for SDL_Rect +#include // for SDL_GetTicks +#include // for max +#include // for char_traits, basic_ostream, operator<< +#include // for basic_string +#include "asset.h" // for Asset +#include "const.h" // for shdwTxtColor, GAMECANVAS_CENTER_X, GAME... +#include "input.h" // for Input, REPEAT_FALSE, inputs_e +#include "jail_audio.h" // for JA_StopMusic +#include "lang.h" // for Lang +#include "screen.h" // for Screen +#include "sprite.h" // for Sprite +#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW +#include "texture.h" // for Texture +#include "utils.h" // for color_t, section_t const Uint8 SELF = 0; diff --git a/source/instructions.h b/source/instructions.h index 36240d0..385400a 100644 --- a/source/instructions.h +++ b/source/instructions.h @@ -1,14 +1,17 @@ #pragma once -#include -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "screen.h" -#include "sprite.h" -#include "text.h" -#include "utils.h" -#include "const.h" +#include // for SDL_Event +#include // for SDL_Renderer, SDL_Texture +#include // for Uint16, Uint32 +#include // for vector +class Asset; +class Input; +class Lang; +class Screen; +class Sprite; +class Text; +class Texture; +struct section_t; enum mode_e { diff --git a/source/intro.cpp b/source/intro.cpp index 579000a..361dfa1 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -1,4 +1,17 @@ #include "intro.h" +#include // for SDL_GetTicks +#include // for basic_string +#include "asset.h" // for Asset +#include "const.h" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU... +#include "input.h" // for Input, REPEAT_FALSE, inputs_e +#include "jail_audio.h" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic +#include "lang.h" // for Lang +#include "screen.h" // for Screen +#include "smartsprite.h" // for SmartSprite +#include "text.h" // for Text +#include "texture.h" // for Texture +#include "utils.h" // for section_t, color_t +#include "writer.h" // for Writer // Constructor Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) diff --git a/source/intro.h b/source/intro.h index b9f251b..5f54ac8 100644 --- a/source/intro.h +++ b/source/intro.h @@ -1,15 +1,19 @@ #pragma once -#include -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "screen.h" -#include "smartsprite.h" -#include "utils.h" -#include "writer.h" -#include "const.h" -#include +#include // for SDL_Event +#include // for SDL_Renderer +#include // for Uint32, Uint8 +#include // for vector +class Asset; +class Input; +class Lang; +class Screen; +class SmartSprite; +class Text; +class Texture; +class Writer; +struct JA_Music_t; +struct section_t; #ifndef INTRO_H #define INTRO_H diff --git a/source/item.cpp b/source/item.cpp index 5c2007b..3f0aed6 100644 --- a/source/item.cpp +++ b/source/item.cpp @@ -1,5 +1,8 @@ -#include "const.h" #include "item.h" +#include // for rand +#include "animatedsprite.h" // for AnimatedSprite +#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT, PLAY_AR... +class Texture; // Constructor Item::Item(Uint8 kind, float x, float y, Texture *texture, std::vector *animation, SDL_Renderer *renderer) diff --git a/source/item.h b/source/item.h index 283dede..7b66c0d 100644 --- a/source/item.h +++ b/source/item.h @@ -1,8 +1,12 @@ #pragma once -#include -#include "animatedsprite.h" -#include "utils.h" +#include // for SDL_Renderer +#include // for Uint8, Uint16 +#include // for string +#include // for vector +#include "utils.h" // for circle_t +class AnimatedSprite; +class Texture; // Tipos de objetos #define ITEM_POINTS_1_DISK 1 diff --git a/source/lang.cpp b/source/lang.cpp index e553e52..6c3997e 100644 --- a/source/lang.cpp +++ b/source/lang.cpp @@ -1,6 +1,6 @@ #include "lang.h" -#include -#include +#include // for basic_ifstream, basic_istream, ifstream +#include "asset.h" // for Asset // Constructor Lang::Lang(Asset *mAsset) diff --git a/source/lang.h b/source/lang.h index d912ae3..a9734ef 100644 --- a/source/lang.h +++ b/source/lang.h @@ -1,8 +1,8 @@ #pragma once -#include -#include "asset.h" -#include +#include // for Uint8 +#include // for string, basic_string +class Asset; // Códigos de idioma #define es_ES 0 diff --git a/source/logo.cpp b/source/logo.cpp index 9aae7b2..6e173d4 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -1,4 +1,15 @@ #include "logo.h" +#include // for SDL_GetTicks +#include // for min +#include // for basic_string +#include "asset.h" // for Asset +#include "const.h" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG... +#include "input.h" // for Input, REPEAT_FALSE, inputs_e +#include "jail_audio.h" // for JA_StopMusic +#include "screen.h" // for Screen +#include "sprite.h" // for Sprite +#include "texture.h" // for Texture +#include "utils.h" // for section_t, color_t #define INIT_FADE 100 #define END_LOGO 200 diff --git a/source/logo.h b/source/logo.h index 2d226f2..06939c5 100644 --- a/source/logo.h +++ b/source/logo.h @@ -1,13 +1,14 @@ #pragma once -#include -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "screen.h" -#include "sprite.h" -#include "utils.h" -#include "const.h" +#include // for SDL_Event +#include // for SDL_Renderer +#include // for Uint32 +class Asset; +class Input; +class Screen; +class Sprite; +class Texture; +struct section_t; // Clase Logo class Logo diff --git a/source/main.cpp b/source/main.cpp index 59c5640..97a2454 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -39,8 +39,8 @@ Reescribiendo el código el 27/09/2022 */ -#include "director.h" -#include +#include // for char_traits, basic_ostream, operator<<, endl +#include "director.h" // for Director int main(int argc, char *argv[]) { diff --git a/source/menu.cpp b/source/menu.cpp index 4f96018..5545207 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -1,6 +1,11 @@ -#include "const.h" #include "menu.h" -#include +#include // for max, min +#include // for char_traits, basic_ifstream, basic_istream +#include // for basic_stringstream +#include "asset.h" // for Asset +#include "input.h" // for Input, REPEAT_FALSE, inputs_e +#include "jail_audio.h" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound +#include "text.h" // for Text // Constructor Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) diff --git a/source/menu.h b/source/menu.h index 06a705b..fa79c98 100644 --- a/source/menu.h +++ b/source/menu.h @@ -1,15 +1,14 @@ #pragma once -#include -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "sprite.h" -#include "text.h" -#include "utils.h" -#include -#include -#include +#include // for SDL_Rect +#include // for SDL_Renderer +#include // for string, basic_string +#include // for vector +#include "utils.h" // for color_t +class Asset; +class Input; +class Text; +struct JA_Sound_t; // Tipos de fondos para el menu #define MENU_BACKGROUND_TRANSPARENT 0 diff --git a/source/movingsprite.cpp b/source/movingsprite.cpp index 8b48765..360107c 100644 --- a/source/movingsprite.cpp +++ b/source/movingsprite.cpp @@ -1,4 +1,5 @@ #include "movingsprite.h" +#include "texture.h" // for Texture // Constructor MovingSprite::MovingSprite(float x, float y, int w, int h, float velx, float vely, float accelx, float accely, Texture *texture, SDL_Renderer *renderer) diff --git a/source/movingsprite.h b/source/movingsprite.h index b55bfc3..e8d73cc 100644 --- a/source/movingsprite.h +++ b/source/movingsprite.h @@ -1,7 +1,10 @@ #pragma once -#include -#include "sprite.h" +#include // for SDL_Rect, SDL_Point +#include // for SDL_RendererFlip, SDL_Renderer +#include // for Uint16 +#include "sprite.h" // for Sprite +class Texture; // Clase MovingSprite. Añade posicion y velocidad en punto flotante class MovingSprite : public Sprite diff --git a/source/player.cpp b/source/player.cpp index c9af1d3..de7a497 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -1,5 +1,9 @@ -#include "const.h" #include "player.h" +#include // for rand +#include "animatedsprite.h" // for AnimatedSprite +#include "const.h" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT +#include "input.h" // for inputs_e +#include "texture.h" // for Texture // Constructor Player::Player(float x, int y, SDL_Renderer *renderer, std::vector texture, std::vector *> animations) diff --git a/source/player.h b/source/player.h index 5931388..d0205f6 100644 --- a/source/player.h +++ b/source/player.h @@ -1,11 +1,12 @@ #pragma once -#include -#include "animatedsprite.h" -#include "asset.h" -#include "input.h" -#include "texture.h" -#include "utils.h" +#include // for SDL_Renderer +#include // for Uint8, Uint16, Uint32 +#include // for string +#include // for vector +#include "utils.h" // for circle_t +class AnimatedSprite; +class Texture; // Contadores #define DEATH_COUNTER 350 diff --git a/source/screen.cpp b/source/screen.cpp index 1f3a348..e071105 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -1,6 +1,12 @@ #include "screen.h" -#include -#include +#include // for SDL_GetError +#include // for SDL_DISABLE, SDL_ENABLE +#include // for SDL_ShowCursor +#include // for SDL_PIXELFORMAT_RGBA8888 +#include // for max, min +#include // for basic_ostream, operator<<, cout, endl +#include // for basic_string, char_traits, string +class Asset; // Constructor Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options_t *options) diff --git a/source/screen.h b/source/screen.h index f9733ae..4b793e8 100644 --- a/source/screen.h +++ b/source/screen.h @@ -1,10 +1,12 @@ #pragma once -#include -#include "asset.h" -#include "utils.h" -#include "const.h" -#include +#include // for SDL_BlendMode +#include // for SDL_Rect +#include // for SDL_Renderer, SDL_Texture +#include // for SDL_Window +#include // for vector +#include "utils.h" // for color_t +class Asset; #define FILTER_NEAREST 0 #define FILTER_LINEAL 1 diff --git a/source/smartsprite.cpp b/source/smartsprite.cpp index 5edea95..db57b51 100644 --- a/source/smartsprite.cpp +++ b/source/smartsprite.cpp @@ -1,4 +1,6 @@ #include "smartsprite.h" +#include "movingsprite.h" // for MovingSprite +class Texture; // Constructor SmartSprite::SmartSprite(Texture *texture, SDL_Renderer *renderer) diff --git a/source/smartsprite.h b/source/smartsprite.h index 565053a..be18630 100644 --- a/source/smartsprite.h +++ b/source/smartsprite.h @@ -1,9 +1,8 @@ #pragma once -#include -#include "animatedsprite.h" -#include "utils.h" -#include +#include // for SDL_Renderer +#include "animatedsprite.h" // for AnimatedSprite +class Texture; // Clase SmartSprite class SmartSprite : public AnimatedSprite diff --git a/source/sprite.cpp b/source/sprite.cpp index faa81eb..a62980c 100644 --- a/source/sprite.cpp +++ b/source/sprite.cpp @@ -1,4 +1,5 @@ #include "sprite.h" +#include "texture.h" // for Texture // Constructor Sprite::Sprite(int x, int y, int w, int h, Texture *texture, SDL_Renderer *renderer) diff --git a/source/sprite.h b/source/sprite.h index 610759e..2dec4a1 100644 --- a/source/sprite.h +++ b/source/sprite.h @@ -1,7 +1,8 @@ #pragma once -#include -#include "texture.h" +#include // for SDL_Rect +#include // for SDL_Renderer +class Texture; // Clase sprite class Sprite diff --git a/source/text.cpp b/source/text.cpp index 4563b2a..17868c3 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -1,7 +1,10 @@ #include "text.h" -#include -#include +#include // for char_traits, basic_ostream, basic_ifstream, ope... +#include // for cout +#include "sprite.h" // for Sprite +#include "texture.h" // for Texture +#include "utils.h" // for color_t // Llena una estructuta textFile_t desde un fichero textFile_t LoadTextFile(std::string file, bool verbose) diff --git a/source/text.h b/source/text.h index 74f2828..d9cbb28 100644 --- a/source/text.h +++ b/source/text.h @@ -1,6 +1,10 @@ #pragma once -#include "sprite.h" +#include // for SDL_Renderer +#include // for Uint8 +#include // for string +class Sprite; +class Texture; #include "utils.h" #define TXT_COLOR 1 @@ -61,7 +65,7 @@ public: void writeCentered(int x, int y, std::string text, int kerning = 1, int lenght = -1); // Escribe texto con extras - void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = {255, 255, 255}, Uint8 shadowDistance = 1, color_t shadowColor = {0, 0, 0}, int lenght = -1); + void writeDX(Uint8 flags, int x, int y, std::string text, int kerning = 1, color_t textColor = color_t(255, 255, 255), Uint8 shadowDistance = 1, color_t shadowColor = color_t(0, 0, 0), int lenght = -1); // Obtiene la longitud en pixels de una cadena int lenght(std::string text, int kerning = 1); diff --git a/source/texture.cpp b/source/texture.cpp index dce9ed2..3faa12f 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,8 +1,13 @@ #include "texture.h" +#include // for SDL_GetError +#include // for SDL_Log +#include // for SDL_PIXELFORMAT_RGB24, SDL_PIXELFORMAT... +#include // for SDL_CreateRGBSurfaceWithFormatFrom +#include // for exit +#include // for basic_ostream, operator<<, cout, endl #define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" -#include +#include "stb_image.h" // for stbi_failure_reason, stbi_image_free // Constructor Texture::Texture(SDL_Renderer *renderer, std::string path, bool verbose) diff --git a/source/texture.h b/source/texture.h index 9035f69..7df00be 100644 --- a/source/texture.h +++ b/source/texture.h @@ -1,8 +1,10 @@ #pragma once -#include -#include -#include +#include // for SDL_BlendMode +#include // for SDL_Point, SDL_Rect +#include // for SDL_Renderer, SDL_FLIP_NONE, SDL_TEX... +#include // for Uint8 +#include // for basic_string, string class Texture { diff --git a/source/title.cpp b/source/title.cpp index fd24b31..f33b65b 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -1,4 +1,25 @@ #include "title.h" +#include // for SDL_GetError +#include // for SDL_PIXELFORMAT_RGBA8888 +#include // for SDL_GetTicks +#include // for SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLS... +#include // for rand +#include // for basic_ostream, operator<<, basic_ostrea... +#include // for basic_string, operator+, char_traits +#include "animatedsprite.h" // for AnimatedSprite +#include "asset.h" // for Asset +#include "const.h" // for GAMECANVAS_CENTER_X, SECTION_PROG_QUIT +#include "fade.h" // for Fade +#include "game.h" // for Game +#include "input.h" // for Input, INPUT_USE_GAMECONTROLLER, INPUT_... +#include "jail_audio.h" // for JA_StopMusic, JA_GetMusicState, JA_Play... +#include "lang.h" // for Lang, ba_BA, en_UK, es_ES +#include "menu.h" // for Menu +#include "screen.h" // for Screen, FILTER_LINEAL, FILTER_NEAREST +#include "smartsprite.h" // for SmartSprite +#include "sprite.h" // for Sprite +#include "text.h" // for Text, TXT_CENTER, TXT_SHADOW +#include "texture.h" // for Texture // Constructor Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section) diff --git a/source/title.h b/source/title.h index 74809e0..af923a4 100644 --- a/source/title.h +++ b/source/title.h @@ -1,21 +1,26 @@ #pragma once -#include -#include "asset.h" -#include "input.h" -#include "jail_audio.h" -#include "menu.h" -#include "movingsprite.h" -#include "screen.h" -#include "smartsprite.h" -#include "sprite.h" -#include "text.h" -#include "utils.h" -#include "const.h" -#include "fade.h" -#include "game.h" -#include "instructions.h" -#include "item.h" +#include // for SDL_Event +#include // for SDL_Rect +#include // for SDL_Renderer, SDL_Texture +#include // for Uint32, Uint8 +#include // for vector +#include "instructions.h" // for mode_e +#include "utils.h" // for input_t, options_t, section_t +class AnimatedSprite; +class Asset; +class Fade; +class Game; +class Input; +class Lang; +class Menu; +class Screen; +class SmartSprite; +class Sprite; +class Text; +class Texture; +struct JA_Music_t; +struct JA_Sound_t; // Textos #define TEXT_COPYRIGHT "@2020,2023 JailDesigner (v2.3.1)" diff --git a/source/utils.cpp b/source/utils.cpp index 6252753..b30e92d 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,5 +1,6 @@ #include "utils.h" -#include +#include // for abs, free, malloc +#include // for round, abs // Calcula el cuadrado de la distancia entre dos puntos double distanceSquared(int x1, int y1, int x2, int y2) diff --git a/source/utils.h b/source/utils.h index 02db63b..3baa125 100644 --- a/source/utils.h +++ b/source/utils.h @@ -1,9 +1,9 @@ #pragma once -#include -#include "texture.h" -#include -#include +#include // for SDL_Rect, SDL_Point +#include // for Uint8, Uint32 +#include // for string, basic_string +#include // for vector // Dificultad del juego #define DIFFICULTY_EASY 0 @@ -49,9 +49,12 @@ struct line_t // Estructura para definir un color struct color_t { - Uint8 r; - Uint8 g; - Uint8 b; + Uint8 r; + Uint8 g; + Uint8 b; + + color_t() : r(0), g(0), b(0) {} // Constructor por defecto + color_t(Uint8 red, Uint8 green, Uint8 blue) : r(red), g(green), b(blue) {} }; // Tipos de paleta @@ -61,16 +64,6 @@ enum palette_e p_zxarne }; -// Posiciones de las notificaciones -enum not_pos_e -{ - pos_top, - pos_bottom, - pos_left, - pos_middle, - pos_right -}; - // Estructura para saber la seccion y subseccion del programa struct section_t { diff --git a/source/writer.cpp b/source/writer.cpp index 7035f32..137ea6b 100644 --- a/source/writer.cpp +++ b/source/writer.cpp @@ -1,4 +1,5 @@ #include "writer.h" +#include "text.h" // for Text // Constructor Writer::Writer(Text *text) diff --git a/source/writer.h b/source/writer.h index 9affecb..e1adf72 100644 --- a/source/writer.h +++ b/source/writer.h @@ -1,8 +1,7 @@ #pragma once -#include -#include "sprite.h" -#include "text.h" +#include // for string, basic_string +class Text; // Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un bitmap class Writer