build: unifica .clang-format/.clang-tidy i exclou external/ i spv/ amb dummies

This commit is contained in:
2026-04-17 16:21:56 +02:00
parent 007c1d3554
commit 55caef3210
25 changed files with 119 additions and 119 deletions

View File

@@ -2,8 +2,8 @@ BasedOnStyle: Google
IndentWidth: 4 IndentWidth: 4
NamespaceIndentation: All NamespaceIndentation: All
IndentAccessModifiers: false IndentAccessModifiers: false
ColumnLimit: 0 # Sin limite de longitud de linea ColumnLimit: 0 # Sin límite de longitud de línea
BreakBeforeBraces: Attach # Llaves en la misma linea BreakBeforeBraces: Attach # Llaves en la misma línea
AllowShortIfStatementsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true
AllowShortBlocksOnASingleLine: true AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: All AllowShortFunctionsOnASingleLine: All

View File

@@ -2,28 +2,23 @@ Checks:
- readability-* - readability-*
- modernize-* - modernize-*
- performance-* - performance-*
- bugprone-unchecked-optional-access - bugprone-*
- bugprone-sizeof-expression
- bugprone-suspicious-missing-comma
- bugprone-suspicious-index
- bugprone-undefined-memory-manipulation
- bugprone-use-after-move
- bugprone-out-of-bound-access
- -readability-identifier-length - -readability-identifier-length
- -readability-magic-numbers - -readability-magic-numbers
- -bugprone-narrowing-conversions
- -performance-enum-size
- -performance-inefficient-string-concatenation
- -bugprone-integer-division - -bugprone-integer-division
- -bugprone-easily-swappable-parameters - -bugprone-easily-swappable-parameters
- -bugprone-narrowing-conversions
- -modernize-avoid-c-arrays,-warnings-as-errors - -modernize-avoid-c-arrays,-warnings-as-errors
WarningsAsErrors: '*' WarningsAsErrors: '*'
# Excluye jail_audio.hpp, stb_image.h y stb_vorbis.c del analisis # Solo headers del propio código fuente (external/ y spv/ tienen su propio .clang-tidy dummy)
HeaderFilterRegex: 'source/(?!jail_audio\.hpp|stb_image\.h|stb_vorbis\.c).*' HeaderFilterRegex: 'source/.*'
FormatStyle: file FormatStyle: file
CheckOptions: 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 # Variables locales en snake_case
- { key: readability-identifier-naming.VariableCase, value: lower_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.ProtectedMemberCase, value: lower_case }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } - { 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 } - { key: readability-identifier-naming.PublicMemberCase, value: lower_case }
# Namespaces en CamelCase # Namespaces en CamelCase
- { key: readability-identifier-naming.NamespaceCase, value: 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.StaticVariableCase, value: lower_case }
- { key: readability-identifier-naming.StaticVariableSuffix, value: _ } - { key: readability-identifier-naming.StaticVariableSuffix, value: _ }
# Constantes estaticas sin sufijo # Constantes estáticas sin sufijo
- { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE } - { key: readability-identifier-naming.StaticConstantCase, value: UPPER_CASE }
# Constantes globales en UPPER_CASE # Constantes globales en UPPER_CASE
@@ -71,7 +66,7 @@ CheckOptions:
# Valores de enums en UPPER_CASE # Valores de enums en UPPER_CASE
- { key: readability-identifier-naming.EnumConstantCase, value: 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.MethodCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMethodCase, value: camelBack } - { key: readability-identifier-naming.PrivateMethodCase, value: camelBack }
- { key: readability-identifier-naming.ProtectedMethodCase, value: camelBack } - { key: readability-identifier-naming.ProtectedMethodCase, value: camelBack }
@@ -80,5 +75,5 @@ CheckOptions:
# Funciones en camelBack # Funciones en camelBack
- { key: readability-identifier-naming.FunctionCase, value: 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 } - { key: readability-identifier-naming.ParameterCase, value: lower_case }

View File

@@ -3,6 +3,11 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(coffee_crisis VERSION 1.00) 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 # Configuración de compilador para MinGW en Windows
if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_COMPILER "g++") set(CMAKE_CXX_COMPILER "g++")
@@ -118,22 +123,14 @@ file(GLOB_RECURSE ALL_SOURCE_FILES
"${CMAKE_SOURCE_DIR}/source/*.h" "${CMAKE_SOURCE_DIR}/source/*.h"
) )
# Excluir stb_image.h y stb_vorbis.c del analisis
set(CLANG_TIDY_SOURCES ${ALL_SOURCE_FILES}) 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}) 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). # Para cppcheck, pasar solo .cpp (los headers se procesan transitivamente).
set(CPPCHECK_SOURCES ${ALL_SOURCE_FILES}) set(CPPCHECK_SOURCES ${ALL_SOURCE_FILES})
list(FILTER CPPCHECK_SOURCES INCLUDE REGEX ".*\\.cpp$") 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 # Targets de clang-tidy
if(CLANG_TIDY_EXE) if(CLANG_TIDY_EXE)

View File

@@ -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, 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, 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, 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, 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, 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, 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,

View File

@@ -9,7 +9,7 @@
#include <unistd.h> // for getuid #include <unistd.h> // for getuid
#endif #endif
#include <cstdlib> // for exit, EXIT_FAILURE, srand #include <cstdlib> // for exit, EXIT_FAILURE, srand
#include <filesystem> #include <filesystem>
#include <fstream> // for basic_ostream, operator<<, basi... #include <fstream> // for basic_ostream, operator<<, basi...
#include <iostream> // for cout #include <iostream> // for cout
@@ -24,14 +24,14 @@
#include "intro.h" // for Intro #include "intro.h" // for Intro
#include "jail_audio.hpp" // for JA_Init #include "jail_audio.hpp" // for JA_Init
#include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK #include "lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
#include "resource.h"
#include "resource_helper.h"
#include "logo.h" // for Logo #include "logo.h" // for Logo
#include "mouse.hpp" // for Mouse::handleEvent, Mouse::upda... #include "mouse.hpp" // for Mouse::handleEvent, Mouse::upda...
#include "screen.h" // for FILTER_NEAREST, Screen, FILTER_... #include "resource.h"
#include "texture.h" // for Texture #include "resource_helper.h"
#include "title.h" // for Title #include "screen.h" // for FILTER_NEAREST, Screen, FILTER_...
#include "utils.h" // for options_t, input_t, boolToString #include "texture.h" // for Texture
#include "title.h" // for Title
#include "utils.h" // for options_t, input_t, boolToString
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) #if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
#include <pwd.h> #include <pwd.h>
@@ -62,13 +62,13 @@ Director::Director(int argc, const char *argv[]) {
// En wasm siempre se usa filesystem (MEMFS) porque el propio --preload-file // En wasm siempre se usa filesystem (MEMFS) porque el propio --preload-file
// de emscripten ya empaqueta data/ — no hay resources.pack. // de emscripten ya empaqueta data/ — no hay resources.pack.
{ {
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
const bool enable_fallback = true; const bool enable_fallback = true;
#elif defined(RELEASE_BUILD) #elif defined(RELEASE_BUILD)
const bool enable_fallback = false; const bool enable_fallback = false;
#else #else
const bool enable_fallback = true; const bool enable_fallback = true;
#endif #endif
if (!ResourceHelper::initializeResourceSystem("resources.pack", enable_fallback)) { if (!ResourceHelper::initializeResourceSystem("resources.pack", enable_fallback)) {
std::cerr << "Fatal: resource system init failed (missing resources.pack?)" << std::endl; std::cerr << "Fatal: resource system init failed (missing resources.pack?)" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -105,11 +105,11 @@ Director::Director(int argc, const char *argv[]) {
#else #else
{ {
const std::string binDir = std::filesystem::path(executablePath).parent_path().string(); const std::string binDir = std::filesystem::path(executablePath).parent_path().string();
#ifdef MACOS_BUNDLE #ifdef MACOS_BUNDLE
input = new Input(binDir + "/../Resources/gamecontrollerdb.txt"); input = new Input(binDir + "/../Resources/gamecontrollerdb.txt");
#else #else
input = new Input(binDir + "/gamecontrollerdb.txt"); input = new Input(binDir + "/gamecontrollerdb.txt");
#endif #endif
} }
#endif #endif
initInput(); initInput();

2
source/external/.clang-format vendored Normal file
View File

@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: Never

4
source/external/.clang-tidy vendored Normal file
View File

@@ -0,0 +1,4 @@
# source/external/.clang-tidy
Checks: '-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''

View File

@@ -15,16 +15,16 @@
#include "input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE #include "input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE
#include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK #include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK
#include "jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound #include "jail_audio.hpp" // for JA_PlaySound, JA_DeleteSound, JA_LoadSound
#include "resource.h"
#include "lang.h" // for Lang #include "lang.h" // for Lang
#include "menu.h" // for Menu #include "menu.h" // for Menu
#include "movingsprite.h" // for MovingSprite #include "movingsprite.h" // for MovingSprite
#include "player.h" // for Player, DEATH_COUNTER #include "player.h" // for Player, DEATH_COUNTER
#include "screen.h" // for Screen #include "resource.h"
#include "smartsprite.h" // for SmartSprite #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "smartsprite.h" // for SmartSprite
#include "text.h" // for Text, TXT_CENTER #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "text.h" // for Text, TXT_CENTER
#include "texture.h" // for Texture
struct JA_Sound_t; struct JA_Sound_t;
// Constructor // Constructor

View File

@@ -21,17 +21,18 @@ static void installWebStandardMapping(SDL_JoystickID jid) {
char mapping[512]; char mapping[512];
SDL_snprintf(mapping, sizeof(mapping), SDL_snprintf(mapping, sizeof(mapping),
"%s,%s," "%s,%s,"
"a:b0,b:b1,x:b2,y:b3," "a:b0,b:b1,x:b2,y:b3,"
"leftshoulder:b4,rightshoulder:b5," "leftshoulder:b4,rightshoulder:b5,"
"lefttrigger:b6,righttrigger:b7," "lefttrigger:b6,righttrigger:b7,"
"back:b8,start:b9," "back:b8,start:b9,"
"leftstick:b10,rightstick:b11," "leftstick:b10,rightstick:b11,"
"dpup:b12,dpdown:b13,dpleft:b14,dpright:b15," "dpup:b12,dpdown:b13,dpleft:b14,dpright:b15,"
"guide:b16," "guide:b16,"
"leftx:a0,lefty:a1,rightx:a2,righty:a3," "leftx:a0,lefty:a1,rightx:a2,righty:a3,"
"platform:Emscripten", "platform:Emscripten",
guidStr, name); guidStr,
name);
SDL_AddGamepadMapping(mapping); SDL_AddGamepadMapping(mapping);
#else #else
(void)jid; (void)jid;

View File

@@ -12,11 +12,11 @@
#include "jail_audio.hpp" // for JA_StopMusic #include "jail_audio.hpp" // for JA_StopMusic
#include "lang.h" // for Lang #include "lang.h" // for Lang
#include "resource.h" #include "resource.h"
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW #include "text.h" // for Text, TXT_CENTER, TXT_COLOR, TXT_SHADOW
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for color_t, section_t #include "utils.h" // for color_t, section_t
// Constructor // Constructor
Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) { Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {

View File

@@ -10,12 +10,12 @@
#include "jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic #include "jail_audio.hpp" // for JA_StopMusic, JA_DeleteMusic, JA_LoadMusic
#include "lang.h" // for Lang #include "lang.h" // for Lang
#include "resource.h" #include "resource.h"
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "smartsprite.h" // for SmartSprite #include "smartsprite.h" // for SmartSprite
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for section_t, color_t #include "utils.h" // for section_t, color_t
#include "writer.h" // for Writer #include "writer.h" // for Writer
// Constructor // Constructor
Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) { Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input, Lang *lang, section_t *section) {

View File

@@ -8,7 +8,7 @@
#include <string.h> // Para strcpy, strlen #include <string.h> // Para strcpy, strlen
#define STB_VORBIS_HEADER_ONLY #define STB_VORBIS_HEADER_ONLY
#include "stb_vorbis.c" #include "external/stb_vorbis.c"
// --- Public Enums --- // --- Public Enums ---
enum JA_Channel_state { JA_CHANNEL_INVALID, enum JA_Channel_state { JA_CHANNEL_INVALID,

View File

@@ -10,10 +10,10 @@
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "input.h" // for Input, REPEAT_FALSE, inputs_e
#include "jail_audio.hpp" // for JA_StopMusic #include "jail_audio.hpp" // for JA_StopMusic
#include "resource.h" #include "resource.h"
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for section_t, color_t #include "utils.h" // for section_t, color_t
// Valores de inicialización y fin // Valores de inicialización y fin
constexpr int INIT_FADE = 100; constexpr int INIT_FADE = 100;

View File

@@ -43,7 +43,7 @@ Reescribiendo el código el 27/09/2022
#include <SDL3/SDL_main.h> #include <SDL3/SDL_main.h>
#include "director.h" #include "director.h"
#include "stb_vorbis.c" #include "external/stb_vorbis.c"
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) {
auto *director = new Director(argc, const_cast<const char **>(argv)); auto *director = new Director(argc, const_cast<const char **>(argv));

View File

@@ -8,7 +8,7 @@
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "input.h" // for Input, REPEAT_FALSE, inputs_e
#include "jail_audio.hpp" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound #include "jail_audio.hpp" // for JA_LoadSound, JA_PlaySound, JA_DeleteSound
#include "resource_helper.h" #include "resource_helper.h"
#include "text.h" // for Text #include "text.h" // for Text
// Constructor // Constructor
Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) { Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file) {

View File

@@ -28,7 +28,7 @@ class Resource {
JA_Music_t *getMusic(const std::string &name); JA_Music_t *getMusic(const std::string &name);
std::vector<std::string> &getAnimationLines(const std::string &name); std::vector<std::string> &getAnimationLines(const std::string &name);
Text *getText(const std::string &name); // name sin extensión: "smb2", "nokia2", ... 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<uint8_t> &getDemoBytes() const { return demoBytes_; } const std::vector<uint8_t> &getDemoBytes() const { return demoBytes_; }
private: private:

View File

@@ -74,4 +74,4 @@ namespace ResourceHelper {
} }
return pack_path; return pack_path;
} }
} } // namespace ResourceHelper

View File

@@ -12,4 +12,4 @@ namespace ResourceHelper {
bool shouldUseResourcePack(const std::string& filepath); bool shouldUseResourcePack(const std::string& filepath);
std::string getPackPath(const std::string& asset_path); std::string getPackPath(const std::string& asset_path);
} } // namespace ResourceHelper

View File

@@ -189,7 +189,7 @@ std::vector<uint8_t> ResourcePack::getResource(const std::string& filename) {
} }
std::vector<uint8_t> result(data_.begin() + entry.offset, std::vector<uint8_t> result(data_.begin() + entry.offset,
data_.begin() + entry.offset + entry.size); data_.begin() + entry.offset + entry.size);
uint32_t checksum = calculateChecksum(result); uint32_t checksum = calculateChecksum(result);
if (checksum != entry.checksum) { if (checksum != entry.checksum) {

View File

@@ -9,7 +9,7 @@
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime #include "mouse.hpp" // for Mouse::cursorVisible, Mouse::lastMouseMoveTime
#include "resource.h" #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__ #ifdef __EMSCRIPTEN__
#include <emscripten.h> #include <emscripten.h>
@@ -30,26 +30,26 @@
// interna a SDL_SetWindowFullscreen(false) és la peça que realment fa eixir // 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. // SDL del seu estat intern de fullscreen — sense això res més funciona.
namespace { namespace {
Screen *g_screen_instance = nullptr; Screen *g_screen_instance = nullptr;
void deferredCanvasResize(void * /*userData*/) { void deferredCanvasResize(void * /*userData*/) {
if (g_screen_instance) { if (g_screen_instance) {
g_screen_instance->handleCanvasResized(); g_screen_instance->handleCanvasResized();
}
} }
}
EM_BOOL onEmFullscreenChange(int /*eventType*/, const EmscriptenFullscreenChangeEvent *event, void * /*userData*/) { EM_BOOL onEmFullscreenChange(int /*eventType*/, const EmscriptenFullscreenChangeEvent *event, void * /*userData*/) {
if (g_screen_instance && event) { if (g_screen_instance && event) {
g_screen_instance->syncFullscreenFlagFromBrowser(event->isFullscreen != 0); 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*/) { EM_BOOL onEmOrientationChange(int /*eventType*/, const EmscriptenOrientationChangeEvent * /*event*/, void * /*userData*/) {
emscripten_async_call(deferredCanvasResize, nullptr, 0); emscripten_async_call(deferredCanvasResize, nullptr, 0);
return EM_FALSE; return EM_FALSE;
} }
} // namespace } // namespace
#endif // __EMSCRIPTEN__ #endif // __EMSCRIPTEN__

View File

@@ -30,21 +30,21 @@ class Screen {
// Render loop // Render loop
void clean(color_t color = {0x00, 0x00, 0x00}); // Limpia la pantalla void clean(color_t color = {0x00, 0x00, 0x00}); // Limpia la pantalla
void start(); // Prepara para empezar a dibujar en la textura de juego void start(); // Prepara para empezar a dibujar en la textura de juego
void blit(); // Vuelca el contenido del renderizador en pantalla void blit(); // Vuelca el contenido del renderizador en pantalla
// Video y ventana // Video y ventana
void setVideoMode(bool fullscreen); // Establece el modo de video void setVideoMode(bool fullscreen); // Establece el modo de video
void toggleVideoMode(); // Cambia entre pantalla completa y ventana 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 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 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 toggleIntegerScale(); // Alterna el escalado entero
void setIntegerScale(bool enabled); // Establece el escalado entero void setIntegerScale(bool enabled); // Establece el escalado entero
void toggleVSync(); // Alterna el V-Sync void toggleVSync(); // Alterna el V-Sync
void setVSync(bool enabled); // Establece 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 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 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ó) auto setWindowZoom(int zoom) -> bool; // Establece el zoom de la ventana (devuelve true si cambió)
// Borde // Borde
void setBorderColor(color_t color); // Cambia el color del borde void setBorderColor(color_t color); // Cambia el color del borde
@@ -55,10 +55,10 @@ class Screen {
private: private:
// Helpers internos de setVideoMode // Helpers internos de setVideoMode
void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor void applyFullscreen(bool fullscreen); // SDL_SetWindowFullscreen + visibilidad del cursor
void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition void applyWindowedLayout(); // Calcula windowWidth/Height/dest + SDL_SetWindowSize + SDL_SetWindowPosition
void applyFullscreenLayout(); // SDL_GetWindowSize + delegación a computeFullscreenGameRect void applyFullscreenLayout(); // SDL_GetWindowSize + delegación a computeFullscreenGameRect
void computeFullscreenGameRect(); // Calcula dest en fullscreen (integerScale / keepAspect / stretched) void computeFullscreenGameRect(); // Calcula dest en fullscreen (integerScale / keepAspect / stretched)
void applyLogicalPresentation(bool fullscreen); // SDL_SetRenderLogicalPresentation + persistencia a options void applyLogicalPresentation(bool fullscreen); // SDL_SetRenderLogicalPresentation + persistencia a options
// Emscripten // Emscripten

View File

@@ -6,7 +6,7 @@
#include <iostream> // for basic_ostream, operator<<, cout, endl #include <iostream> // for basic_ostream, operator<<, cout, endl
#define STB_IMAGE_IMPLEMENTATION #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; SDL_ScaleMode Texture::currentScaleMode = SDL_SCALEMODE_NEAREST;

View File

@@ -16,11 +16,11 @@
#include "lang.h" // for Lang, ba_BA, en_UK, es_ES #include "lang.h" // for Lang, ba_BA, en_UK, es_ES
#include "menu.h" // for Menu #include "menu.h" // for Menu
#include "resource.h" #include "resource.h"
#include "screen.h" // for Screen, FILTER_LINEAL, FILTER_NEAREST #include "screen.h" // for Screen, FILTER_LINEAL, FILTER_NEAREST
#include "smartsprite.h" // for SmartSprite #include "smartsprite.h" // for SmartSprite
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "text.h" // for Text, TXT_CENTER, TXT_SHADOW #include "text.h" // for Text, TXT_CENTER, TXT_SHADOW
#include "texture.h" // for Texture #include "texture.h" // for Texture
// Constructor // Constructor
Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section) { Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t *section) {