diff --git a/3ds/Makefile b/3ds/Makefile index 43627f4..346fb5b 100644 --- a/3ds/Makefile +++ b/3ds/Makefile @@ -36,8 +36,8 @@ APP_DESCRIPTION := Fast and simple save manager APP_AUTHOR := Bernardo Giordano VERSION_MAJOR := 3 -VERSION_MINOR := 4 -VERSION_MICRO := 2 +VERSION_MINOR := 5 +VERSION_MICRO := 0 TARGET := $(subst $e ,_,$(notdir $(APP_TITLE))) OUTDIR := out diff --git a/switch/Makefile b/switch/Makefile index 05b22f3..a644615 100644 --- a/switch/Makefile +++ b/switch/Makefile @@ -31,8 +31,8 @@ include $(DEVKITPRO)/libnx/switch_rules # - /default_icon.jpg #--------------------------------------------------------------------------------- VERSION_MAJOR := 3 -VERSION_MINOR := 4 -VERSION_MICRO := 2 +VERSION_MINOR := 5 +VERSION_MICRO := 0 APP_TITLE := Checkpoint APP_AUTHOR := Bernardo Giordano @@ -68,7 +68,8 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 ASFLAGS := -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-no-as-needed,-Map,$(notdir $*.map) -LIBS := -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lnx +LIBS := -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lpng -ljpeg `sdl2-config --libs` `freetype-config --libs` -lnx + #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/switch/include/SDLHelper.hpp b/switch/include/SDLHelper.hpp index ab9f449..4bf7ceb 100644 --- a/switch/include/SDLHelper.hpp +++ b/switch/include/SDLHelper.hpp @@ -5,6 +5,7 @@ #include #include #include +// #include #include #include #include "SDL_FontCache.h" @@ -24,5 +25,6 @@ void SDLH_DrawIcon(std::string icon, int x, int y); void SDLH_GetTextDimensions(int size, const char* text, u32* w, u32* h); void SDLH_DrawTextBox(int size, int x, int y, SDL_Color color, int max, const char* text); void SDLH_Render(void); +void SDLH_PlayClick(void); #endif \ No newline at end of file diff --git a/switch/include/gui.hpp b/switch/include/gui.hpp index 8f2ee05..08d502b 100644 --- a/switch/include/gui.hpp +++ b/switch/include/gui.hpp @@ -45,7 +45,7 @@ namespace Gui { - void init(void); + bool init(void); void exit(void); void draw(u128 uid); diff --git a/switch/include/main.hpp b/switch/include/main.hpp index ace4d56..470e52e 100644 --- a/switch/include/main.hpp +++ b/switch/include/main.hpp @@ -2,9 +2,9 @@ #define MAIN_HPP #include +#include "io.hpp" #include "title.hpp" #include "util.hpp" -#include "io.hpp" extern u128 g_currentUId; extern u8 g_currentUserIndex; diff --git a/switch/source/SDLHelper.cpp b/switch/source/SDLHelper.cpp index d930f65..7ea4378 100644 --- a/switch/source/SDLHelper.cpp +++ b/switch/source/SDLHelper.cpp @@ -5,6 +5,7 @@ static SDL_Renderer* s_renderer; static SDL_Texture* s_star; static SDL_Texture* s_checkbox; static SDL_Texture* s_flag; +// static Mix_Music* s_click; static PlFontData fontData, fontExtData; static std::unordered_map s_fonts; @@ -24,20 +25,46 @@ static FC_Font* getFontFromMap(int size) bool SDLH_Init(void) { - bool ok = false; - SDL_Init(SDL_INIT_EVERYTHING); + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) + { + fprintf(stderr, "SDL_Init: %s\n", SDL_GetError()); + return false; + } s_window = SDL_CreateWindow("Checkpoint", 0, 0, 1280, 720, SDL_WINDOW_FULLSCREEN); + if (!s_window) + { + fprintf(stderr, "SDL_CreateWindow: %s\n", SDL_GetError()); + return false; + } s_renderer = SDL_CreateRenderer(s_window, 0, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + if (!s_renderer) + { + fprintf(stderr, "SDL_CreateRenderer: %s\n", SDL_GetError()); + return false; + } SDL_SetRenderDrawBlendMode(s_renderer, SDL_BLENDMODE_BLEND); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); - IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG); - plGetSharedFontByType(&fontData, PlSharedFontType_Standard); - plGetSharedFontByType(&fontExtData, PlSharedFontType_NintendoExt); - + const int img_flags = IMG_INIT_PNG | IMG_INIT_JPG; + if ((IMG_Init(img_flags) & img_flags) != img_flags) + { + fprintf(stderr, "IMG_Init: %s\n", IMG_GetError()); + return false; + } SDLH_LoadImage(&s_flag, "romfs:/flag.png"); SDLH_LoadImage(&s_star, "romfs:/star.png"); SDLH_LoadImage(&s_checkbox, "romfs:/checkbox.png"); + + // const int mix_flags = MIX_INIT_OGG; + // if ((Mix_Init(mix_flags) & mix_flags) != mix_flags) + // { + // fprintf(stderr, "Mix_Init: %s\n", Mix_GetError()); + // } + // Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 4096); + // s_click = Mix_LoadMUS("romfs:/click.ogg"); + + plGetSharedFontByType(&fontData, PlSharedFontType_Standard); + plGetSharedFontByType(&fontExtData, PlSharedFontType_NintendoExt); return true; } @@ -50,6 +77,9 @@ void SDLH_Exit(void) } TTF_Quit(); + // Mix_FreeMusic(s_click); + // Mix_CloseAudio(); + // Mix_Quit(); SDL_DestroyTexture(s_flag); SDL_DestroyTexture(s_star); SDL_DestroyTexture(s_checkbox); @@ -163,4 +193,9 @@ void SDLH_DrawIcon(std::string icon, int x, int y) if (t != nullptr) { SDLH_DrawImage(t, x, y); } -} \ No newline at end of file +} + +// void SDLH_PlayClick(void) +// { +// Mix_PlayMusic(s_click, 1); +// } \ No newline at end of file diff --git a/switch/source/gui.cpp b/switch/source/gui.cpp index bd74536..ec54c7a 100644 --- a/switch/source/gui.cpp +++ b/switch/source/gui.cpp @@ -165,7 +165,7 @@ static void drawBackground(void) SDLH_GetTextDimensions(30, "checkpoint", &checkpoint_w, NULL); u32 h = (bar_height - ver_h) / 2 - 1; SDLH_DrawText(23, 10, h + 3, COLOR_GREY_LIGHT, DateTime::timeStr().c_str()); - SDLH_DrawText(30, 1280 - 10 - ver_w - image_dim - 12 - checkpoint_w, h, COLOR_WHITE, "checkpoint"); + SDLH_DrawText(30, 1280 - 10 - ver_w - image_dim - 12 - checkpoint_w, h - 2, COLOR_WHITE, "checkpoint"); SDLH_DrawText(23, 1280 - 10 - ver_w, h + 3, COLOR_GREY_LIGHT, ver); SDLH_DrawIcon("flag", 1280 - 10 - ver_w - image_dim - 6, -2); // shadow @@ -232,9 +232,13 @@ bool Gui::askForConfirmation(const std::string& text) return ret; } -void Gui::init(void) +bool Gui::init(void) { - SDLH_Init(); + if (!SDLH_Init()) + { + return false; + } + sprintf(ver, "v%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO); backupScrollEnabled = false; info = new Info(); @@ -254,6 +258,8 @@ void Gui::init(void) messageBox->push_message("Hold \ue003 to multiselect all titles."); messageBox->push_message("Press \ue041 to move between titles."); messageBox->push_message("Press \ue085/\ue086 to switch user."); + + return true; } void Gui::exit(void) diff --git a/switch/source/util.cpp b/switch/source/util.cpp index 34712c9..7acf2e6 100644 --- a/switch/source/util.cpp +++ b/switch/source/util.cpp @@ -40,6 +40,12 @@ void servicesExit(void) Result servicesInit(void) { + // debug + // if (socketInitializeDefault() == 0) + // { + // nxlinkStdio(); + // } + Result res = 0; romfsInit(); res = io::createDirectory("sdmc:/switch"); @@ -65,13 +71,10 @@ Result servicesInit(void) return res; } - Gui::init(); - - // debug - // if (socketInitializeDefault() == 0) - // { - // nxlinkStdio(); - // } + if (!Gui::init()) + { + return -1; + } Configuration::getInstance();