From 55caef32107a0ca7693275fba5fa8ebc83c553e5 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 17 Apr 2026 16:21:56 +0200 Subject: [PATCH] build: unifica .clang-format/.clang-tidy i exclou external/ i spv/ amb dummies --- .clang-format | 4 ++-- .clang-tidy | 29 +++++++++++---------------- CMakeLists.txt | 15 ++++++-------- gamecontrollerdb.txt | 1 + source/director.cpp | 28 +++++++++++++------------- source/external/.clang-format | 2 ++ source/external/.clang-tidy | 4 ++++ source/{ => external}/stb_image.h | 0 source/{ => external}/stb_vorbis.c | 0 source/game.cpp | 12 +++++------ source/input.cpp | 23 +++++++++++---------- source/instructions.cpp | 10 +++++----- source/intro.cpp | 12 +++++------ source/jail_audio.hpp | 2 +- source/logo.cpp | 8 ++++---- source/main.cpp | 2 +- source/menu.cpp | 2 +- source/resource.h | 2 +- source/resource_helper.cpp | 2 +- source/resource_helper.h | 2 +- source/resource_pack.cpp | 2 +- source/screen.cpp | 32 +++++++++++++++--------------- source/screen.h | 32 +++++++++++++++--------------- source/texture.cpp | 2 +- source/title.cpp | 10 +++++----- 25 files changed, 119 insertions(+), 119 deletions(-) create mode 100644 source/external/.clang-format create mode 100644 source/external/.clang-tidy rename source/{ => external}/stb_image.h (100%) rename source/{ => external}/stb_vorbis.c (100%) diff --git a/.clang-format b/.clang-format index b10f47b..e148dad 100644 --- a/.clang-format +++ b/.clang-format @@ -2,8 +2,8 @@ BasedOnStyle: Google IndentWidth: 4 NamespaceIndentation: All IndentAccessModifiers: false -ColumnLimit: 0 # Sin limite de longitud de linea -BreakBeforeBraces: Attach # Llaves en la misma linea +ColumnLimit: 0 # Sin límite de longitud de línea +BreakBeforeBraces: Attach # Llaves en la misma línea AllowShortIfStatementsOnASingleLine: true AllowShortBlocksOnASingleLine: true AllowShortFunctionsOnASingleLine: All diff --git a/.clang-tidy b/.clang-tidy index ed370f3..91d231a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,28 +2,23 @@ Checks: - readability-* - modernize-* - performance-* - - bugprone-unchecked-optional-access - - bugprone-sizeof-expression - - bugprone-suspicious-missing-comma - - bugprone-suspicious-index - - bugprone-undefined-memory-manipulation - - bugprone-use-after-move - - bugprone-out-of-bound-access + - bugprone-* - -readability-identifier-length - -readability-magic-numbers - - -bugprone-narrowing-conversions - - -performance-enum-size - - -performance-inefficient-string-concatenation - -bugprone-integer-division - -bugprone-easily-swappable-parameters + - -bugprone-narrowing-conversions - -modernize-avoid-c-arrays,-warnings-as-errors WarningsAsErrors: '*' -# Excluye jail_audio.hpp, stb_image.h y stb_vorbis.c del analisis -HeaderFilterRegex: 'source/(?!jail_audio\.hpp|stb_image\.h|stb_vorbis\.c).*' +# Solo headers del propio código fuente (external/ y spv/ tienen su propio .clang-tidy dummy) +HeaderFilterRegex: 'source/.*' FormatStyle: file CheckOptions: + # bugprone-empty-catch: aceptar catches vacíos marcados con @INTENTIONAL en un comentario + - { key: bugprone-empty-catch.IgnoreCatchWithKeywords, value: '@INTENTIONAL' } + # Variables locales en snake_case - { key: readability-identifier-naming.VariableCase, value: lower_case } @@ -35,17 +30,17 @@ CheckOptions: - { key: readability-identifier-naming.ProtectedMemberCase, value: lower_case } - { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } - # Miembros publicos en snake_case (sin sufijo) + # Miembros públicos en snake_case (sin sufijo) - { key: readability-identifier-naming.PublicMemberCase, value: lower_case } # Namespaces en CamelCase - { key: readability-identifier-naming.NamespaceCase, value: CamelCase } - # Variables estaticas privadas como miembros privados + # Variables estáticas privadas como miembros privados - { key: readability-identifier-naming.StaticVariableCase, value: lower_case } - { key: readability-identifier-naming.StaticVariableSuffix, value: _ } - # Constantes estaticas sin sufijo + # Constantes estáticas sin sufijo - { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE } # Constantes globales en UPPER_CASE @@ -71,7 +66,7 @@ CheckOptions: # Valores de enums en UPPER_CASE - { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE } - # Metodos en camelBack (sin sufijos) + # Métodos en camelBack (sin sufijos) - { key: readability-identifier-naming.MethodCase, value: camelBack } - { key: readability-identifier-naming.PrivateMethodCase, value: camelBack } - { key: readability-identifier-naming.ProtectedMethodCase, value: camelBack } @@ -80,5 +75,5 @@ CheckOptions: # Funciones en camelBack - { key: readability-identifier-naming.FunctionCase, value: camelBack } - # Parametros en lower_case + # Parámetros en lower_case - { key: readability-identifier-naming.ParameterCase, value: lower_case } diff --git a/CMakeLists.txt b/CMakeLists.txt index b709920..4a9617a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,11 @@ cmake_minimum_required(VERSION 3.10) project(coffee_crisis VERSION 1.00) +# Tipus de build per defecte (Debug) si no se n'ha especificat cap +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) +endif() + # Configuración de compilador para MinGW en Windows if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(CMAKE_CXX_COMPILER "g++") @@ -118,22 +123,14 @@ file(GLOB_RECURSE ALL_SOURCE_FILES "${CMAKE_SOURCE_DIR}/source/*.h" ) -# Excluir stb_image.h y stb_vorbis.c del analisis set(CLANG_TIDY_SOURCES ${ALL_SOURCE_FILES}) -list(FILTER CLANG_TIDY_SOURCES EXCLUDE REGEX ".*stb_image\\.h$") -list(FILTER CLANG_TIDY_SOURCES EXCLUDE REGEX ".*stb_vorbis\\.c$") -list(FILTER CLANG_TIDY_SOURCES EXCLUDE REGEX ".*jail_audio\\.hpp$") -# Excluir stb y jail_audio del formateo tambien set(FORMAT_SOURCES ${ALL_SOURCE_FILES}) -list(FILTER FORMAT_SOURCES EXCLUDE REGEX ".*stb_image\\.h$") -list(FILTER FORMAT_SOURCES EXCLUDE REGEX ".*stb_vorbis\\.c$") -list(FILTER FORMAT_SOURCES EXCLUDE REGEX ".*jail_audio\\.hpp$") # Para cppcheck, pasar solo .cpp (los headers se procesan transitivamente). set(CPPCHECK_SOURCES ${ALL_SOURCE_FILES}) list(FILTER CPPCHECK_SOURCES INCLUDE REGEX ".*\\.cpp$") -list(FILTER CPPCHECK_SOURCES EXCLUDE REGEX ".*stb_vorbis\\.c$") +list(FILTER CPPCHECK_SOURCES EXCLUDE REGEX ".*/source/external/.*") # Targets de clang-tidy if(CLANG_TIDY_EXE) diff --git a/gamecontrollerdb.txt b/gamecontrollerdb.txt index 3b14721..ce52a7a 100644 --- a/gamecontrollerdb.txt +++ b/gamecontrollerdb.txt @@ -1009,6 +1009,7 @@ xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2, 030000006d04000018c2000000000000,Logitech F510,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 030000006d0400001fc2000000000000,Logitech F710,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X, +030000006d0400001ac2000004000000,Logitech Precision,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X, 030000006d04000018c2000000010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000380700005032000000010000,Mad Catz PS3 Fightpad Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, 03000000380700008433000000010000,Mad Catz PS3 Fightstick TE S Plus,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X, diff --git a/source/director.cpp b/source/director.cpp index c09f13b..999d787 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -9,7 +9,7 @@ #include // for getuid #endif -#include // for exit, EXIT_FAILURE, srand +#include // for exit, EXIT_FAILURE, srand #include #include // for basic_ostream, operator<<, basi... #include // for cout @@ -24,14 +24,14 @@ #include "intro.h" // for Intro #include "jail_audio.hpp" // for JA_Init #include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK -#include "resource.h" -#include "resource_helper.h" #include "logo.h" // for Logo #include "mouse.hpp" // for Mouse::handleEvent, Mouse::upda... -#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_... -#include "texture.h" // for Texture -#include "title.h" // for Title -#include "utils.h" // for options_t, input_t, boolToString +#include "resource.h" +#include "resource_helper.h" +#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_... +#include "texture.h" // for Texture +#include "title.h" // for Title +#include "utils.h" // for options_t, input_t, boolToString #if !defined(_WIN32) && !defined(__EMSCRIPTEN__) #include @@ -62,13 +62,13 @@ Director::Director(int argc, const char *argv[]) { // En wasm siempre se usa filesystem (MEMFS) porque el propio --preload-file // de emscripten ya empaqueta data/ — no hay resources.pack. { - #if defined(__EMSCRIPTEN__) +#if defined(__EMSCRIPTEN__) const bool enable_fallback = true; - #elif defined(RELEASE_BUILD) +#elif defined(RELEASE_BUILD) const bool enable_fallback = false; - #else +#else const bool enable_fallback = true; - #endif +#endif if (!ResourceHelper::initializeResourceSystem("resources.pack", enable_fallback)) { std::cerr << "Fatal: resource system init failed (missing resources.pack?)" << std::endl; exit(EXIT_FAILURE); @@ -105,11 +105,11 @@ Director::Director(int argc, const char *argv[]) { #else { const std::string binDir = std::filesystem::path(executablePath).parent_path().string(); - #ifdef MACOS_BUNDLE +#ifdef MACOS_BUNDLE input = new Input(binDir + "/../Resources/gamecontrollerdb.txt"); - #else +#else input = new Input(binDir + "/gamecontrollerdb.txt"); - #endif +#endif } #endif initInput(); diff --git a/source/external/.clang-format b/source/external/.clang-format new file mode 100644 index 0000000..47a38a9 --- /dev/null +++ b/source/external/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/source/external/.clang-tidy b/source/external/.clang-tidy new file mode 100644 index 0000000..7e6f5e7 --- /dev/null +++ b/source/external/.clang-tidy @@ -0,0 +1,4 @@ +# source/external/.clang-tidy +Checks: '-*' +WarningsAsErrors: '' +HeaderFilterRegex: '' diff --git a/source/stb_image.h b/source/external/stb_image.h similarity index 100% rename from source/stb_image.h rename to source/external/stb_image.h diff --git a/source/stb_vorbis.c b/source/external/stb_vorbis.c similarity index 100% rename from source/stb_vorbis.c rename to source/external/stb_vorbis.c diff --git a/source/game.cpp b/source/game.cpp index f28ef90..f85734f 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -15,16 +15,16 @@ #include "input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE #include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK #include "jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound -#include "resource.h" #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 +#include "resource.h" +#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 diff --git a/source/input.cpp b/source/input.cpp index e7747d3..1229b72 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -21,17 +21,18 @@ static void installWebStandardMapping(SDL_JoystickID jid) { char mapping[512]; SDL_snprintf(mapping, sizeof(mapping), - "%s,%s," - "a:b0,b:b1,x:b2,y:b3," - "leftshoulder:b4,rightshoulder:b5," - "lefttrigger:b6,righttrigger:b7," - "back:b8,start:b9," - "leftstick:b10,rightstick:b11," - "dpup:b12,dpdown:b13,dpleft:b14,dpright:b15," - "guide:b16," - "leftx:a0,lefty:a1,rightx:a2,righty:a3," - "platform:Emscripten", - guidStr, name); + "%s,%s," + "a:b0,b:b1,x:b2,y:b3," + "leftshoulder:b4,rightshoulder:b5," + "lefttrigger:b6,righttrigger:b7," + "back:b8,start:b9," + "leftstick:b10,rightstick:b11," + "dpup:b12,dpdown:b13,dpleft:b14,dpright:b15," + "guide:b16," + "leftx:a0,lefty:a1,rightx:a2,righty:a3," + "platform:Emscripten", + guidStr, + name); SDL_AddGamepadMapping(mapping); #else (void)jid; diff --git a/source/instructions.cpp b/source/instructions.cpp index 8388510..a411464 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -12,11 +12,11 @@ #include "jail_audio.hpp" // for JA_StopMusic #include "lang.h" // for Lang #include "resource.h" -#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 +#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 // Constructor Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) { diff --git a/source/intro.cpp b/source/intro.cpp index b53834b..3e778b0 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -10,12 +10,12 @@ #include "jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic #include "lang.h" // for Lang #include "resource.h" -#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 +#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/jail_audio.hpp b/source/jail_audio.hpp index fe763ef..6fe39b1 100644 --- a/source/jail_audio.hpp +++ b/source/jail_audio.hpp @@ -8,7 +8,7 @@ #include // Para strcpy, strlen #define STB_VORBIS_HEADER_ONLY -#include "stb_vorbis.c" +#include "external/stb_vorbis.c" // --- Public Enums --- enum JA_Channel_state { JA_CHANNEL_INVALID, diff --git a/source/logo.cpp b/source/logo.cpp index 99f24f1..b4a7445 100644 --- a/source/logo.cpp +++ b/source/logo.cpp @@ -10,10 +10,10 @@ #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "jail_audio.hpp" // for JA_StopMusic #include "resource.h" -#include "screen.h" // for Screen -#include "sprite.h" // for Sprite -#include "texture.h" // for Texture -#include "utils.h" // for section_t, color_t +#include "screen.h" // for Screen +#include "sprite.h" // for Sprite +#include "texture.h" // for Texture +#include "utils.h" // for section_t, color_t // Valores de inicialización y fin constexpr int INIT_FADE = 100; diff --git a/source/main.cpp b/source/main.cpp index 7258c2e..62c4439 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -43,7 +43,7 @@ Reescribiendo el código el 27/09/2022 #include #include "director.h" -#include "stb_vorbis.c" +#include "external/stb_vorbis.c" SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { auto *director = new Director(argc, const_cast(argv)); diff --git a/source/menu.cpp b/source/menu.cpp index f4af07d..86ac884 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -8,7 +8,7 @@ #include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "jail_audio.hpp" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound #include "resource_helper.h" -#include "text.h" // for Text +#include "text.h" // for Text // Constructor Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) { diff --git a/source/resource.h b/source/resource.h index 5b97adb..e5623d8 100644 --- a/source/resource.h +++ b/source/resource.h @@ -28,7 +28,7 @@ class Resource { JA_Music_t *getMusic(const std::string &name); std::vector &getAnimationLines(const std::string &name); Text *getText(const std::string &name); // name sin extensión: "smb2", "nokia2", ... - Menu *getMenu(const std::string &name); // name sin extensión: "title", "options", ... + Menu *getMenu(const std::string &name); // name sin extensión: "title", "options", ... const std::vector &getDemoBytes() const { return demoBytes_; } private: diff --git a/source/resource_helper.cpp b/source/resource_helper.cpp index ea13130..a27c73a 100644 --- a/source/resource_helper.cpp +++ b/source/resource_helper.cpp @@ -74,4 +74,4 @@ namespace ResourceHelper { } return pack_path; } -} +} // namespace ResourceHelper diff --git a/source/resource_helper.h b/source/resource_helper.h index 88af4bc..4463b63 100644 --- a/source/resource_helper.h +++ b/source/resource_helper.h @@ -12,4 +12,4 @@ namespace ResourceHelper { bool shouldUseResourcePack(const std::string& filepath); std::string getPackPath(const std::string& asset_path); -} +} // namespace ResourceHelper diff --git a/source/resource_pack.cpp b/source/resource_pack.cpp index 66a0a6f..99a0f57 100644 --- a/source/resource_pack.cpp +++ b/source/resource_pack.cpp @@ -189,7 +189,7 @@ std::vector ResourcePack::getResource(const std::string& filename) { } std::vector result(data_.begin() + entry.offset, - data_.begin() + entry.offset + entry.size); + data_.begin() + entry.offset + entry.size); uint32_t checksum = calculateChecksum(result); if (checksum != entry.checksum) { diff --git a/source/screen.cpp b/source/screen.cpp index df568e9..12dd001 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -9,7 +9,7 @@ #include "asset.h" // for Asset #include "mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime #include "resource.h" -#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE +#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_STROKE #ifdef __EMSCRIPTEN__ #include @@ -30,26 +30,26 @@ // interna a SDL_SetWindowFullscreen(false) és la peça que realment fa eixir // SDL del seu estat intern de fullscreen — sense això res més funciona. namespace { -Screen *g_screen_instance = nullptr; + Screen *g_screen_instance = nullptr; -void deferredCanvasResize(void * /*userData*/) { - if (g_screen_instance) { - g_screen_instance->handleCanvasResized(); + void deferredCanvasResize(void * /*userData*/) { + if (g_screen_instance) { + g_screen_instance->handleCanvasResized(); + } } -} -EM_BOOL onEmFullscreenChange(int /*eventType*/, const EmscriptenFullscreenChangeEvent *event, void * /*userData*/) { - if (g_screen_instance && event) { - g_screen_instance->syncFullscreenFlagFromBrowser(event->isFullscreen != 0); + EM_BOOL onEmFullscreenChange(int /*eventType*/, const EmscriptenFullscreenChangeEvent *event, void * /*userData*/) { + if (g_screen_instance && event) { + g_screen_instance->syncFullscreenFlagFromBrowser(event->isFullscreen != 0); + } + emscripten_async_call(deferredCanvasResize, nullptr, 0); + return EM_FALSE; } - emscripten_async_call(deferredCanvasResize, nullptr, 0); - return EM_FALSE; -} -EM_BOOL onEmOrientationChange(int /*eventType*/, const EmscriptenOrientationChangeEvent * /*event*/, void * /*userData*/) { - emscripten_async_call(deferredCanvasResize, nullptr, 0); - return EM_FALSE; -} + EM_BOOL onEmOrientationChange(int /*eventType*/, const EmscriptenOrientationChangeEvent * /*event*/, void * /*userData*/) { + emscripten_async_call(deferredCanvasResize, nullptr, 0); + return EM_FALSE; + } } // namespace #endif // __EMSCRIPTEN__ diff --git a/source/screen.h b/source/screen.h index b04fa83..d68c167 100644 --- a/source/screen.h +++ b/source/screen.h @@ -30,21 +30,21 @@ class Screen { // Render loop void clean(color_t color = {0x00, 0x00, 0x00}); // Limpia la pantalla - void start(); // Prepara para empezar a dibujar en la textura de juego - void blit(); // Vuelca el contenido del renderizador en pantalla + void start(); // Prepara para empezar a dibujar en la textura de juego + void blit(); // Vuelca el contenido del renderizador en pantalla // Video y ventana - void setVideoMode(bool fullscreen); // Establece el modo de video - void toggleVideoMode(); // Cambia entre pantalla completa y ventana - void handleCanvasResized(); // En Emscripten, reaplica setVideoMode tras un cambio del navegador (salida de fullscreen con Esc, rotación). No-op fuera de Emscripten + void setVideoMode(bool fullscreen); // Establece el modo de video + void toggleVideoMode(); // Cambia entre pantalla completa y ventana + void handleCanvasResized(); // En Emscripten, reaplica setVideoMode tras un cambio del navegador (salida de fullscreen con Esc, rotación). No-op fuera de Emscripten void syncFullscreenFlagFromBrowser(bool isFullscreen); // Sincroniza el flag interno de fullscreen con el estado real del navegador. Debe llamarse antes de diferir handleCanvasResized. No-op fuera de Emscripten - void toggleIntegerScale(); // Alterna el escalado entero - void setIntegerScale(bool enabled); // Establece el escalado entero - void toggleVSync(); // Alterna el V-Sync - void setVSync(bool enabled); // Establece el V-Sync - auto decWindowZoom() -> bool; // Reduce el zoom de la ventana (devuelve true si cambió) - auto incWindowZoom() -> bool; // Aumenta el zoom de la ventana (devuelve true si cambió) - auto setWindowZoom(int zoom) -> bool; // Establece el zoom de la ventana (devuelve true si cambió) + void toggleIntegerScale(); // Alterna el escalado entero + void setIntegerScale(bool enabled); // Establece el escalado entero + void toggleVSync(); // Alterna el V-Sync + void setVSync(bool enabled); // Establece el V-Sync + auto decWindowZoom() -> bool; // Reduce el zoom de la ventana (devuelve true si cambió) + auto incWindowZoom() -> bool; // Aumenta el zoom de la ventana (devuelve true si cambió) + auto setWindowZoom(int zoom) -> bool; // Establece el zoom de la ventana (devuelve true si cambió) // Borde void setBorderColor(color_t color); // Cambia el color del borde @@ -55,10 +55,10 @@ class Screen { private: // Helpers internos de setVideoMode - void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor - void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition - void applyFullscreenLayout(); // SDL_GetWindowSize + delegación a computeFullscreenGameRect - void computeFullscreenGameRect(); // Calcula dest en fullscreen (integerScale / keepAspect / stretched) + void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor + void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition + void applyFullscreenLayout(); // SDL_GetWindowSize + delegación a computeFullscreenGameRect + void computeFullscreenGameRect(); // Calcula dest en fullscreen (integerScale / keepAspect / stretched) void applyLogicalPresentation(bool fullscreen); // SDL_SetRenderLogicalPresentation + persistencia a options // Emscripten diff --git a/source/texture.cpp b/source/texture.cpp index d5c31d2..6b082bd 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -6,7 +6,7 @@ #include // for basic_ostream, operator<<, cout, endl #define STB_IMAGE_IMPLEMENTATION -#include "stb_image.h" // for stbi_failure_reason, stbi_image_free +#include "external/stb_image.h" // for stbi_failure_reason, stbi_image_free SDL_ScaleMode Texture::currentScaleMode = SDL_SCALEMODE_NEAREST; diff --git a/source/title.cpp b/source/title.cpp index 32ec048..d629414 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -16,11 +16,11 @@ #include "lang.h" // for Lang, ba_BA, en_UK, es_ES #include "menu.h" // for Menu #include "resource.h" -#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 +#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) {