diff --git a/Makefile b/Makefile index 30a0762..28507c5 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ ROMFS := romfs VERSION_MAJOR := 0 VERSION_MINOR := 2 -VERSION_MICRO := 1 +VERSION_MICRO := 2 APP_TITLE := eBookReader APP_AUTHOR := SeanOMik @@ -63,7 +63,7 @@ CFLAGS := -g -std=c++17 -Wall -O2 -ffunction-sections \ CFLAGS += -D__SWITCH__ $(INCLUDE) `sdl2-config --cflags` -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -DDEBUG=1 -DEXPERIMENTAL=1 +CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions #-DDEBUG=1 -DEXPERIMENTAL=1 ASFLAGS := -g $(ARCH) LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) diff --git a/include/common.h b/include/common.h index 2e52aea..e51d0ca 100644 --- a/include/common.h +++ b/include/common.h @@ -8,6 +8,6 @@ extern SDL_Window *WINDOW; //extern SDL_Surface *WINDOW_SURFACE; extern SDL_Renderer *RENDERER; -extern TTF_Font *ARIAL, *ARIAL_35, *ARIAL_30, *ARIAL_27, *ARIAL_25, *ARIAL_20, *ARIAL_15; +extern TTF_Font *ROBOTO_35, *ROBOTO_30, *ROBOTO_27, *ROBOTO_25, *ROBOTO_20, *ROBOTO_15; #endif \ No newline at end of file diff --git a/include/helpers/SDL_helper.h b/include/helpers/SDL_helper.h index 5844200..189aa76 100644 --- a/include/helpers/SDL_helper.h +++ b/include/helpers/SDL_helper.h @@ -36,11 +36,12 @@ void SDL_DrawCircle(SDL_Renderer *renderer, int x, int y, int r, SDL_Color colou void SDL_DrawText(SDL_Renderer *renderer, TTF_Font *font, int x, int y, SDL_Color colour, const char *text); void SDL_DrawRotatedText(SDL_Renderer *renderer, TTF_Font *font, double rotation, int x, int y, SDL_Color colour, const char *text); void SDL_DrawTextf(SDL_Renderer *renderer, TTF_Font *font, int x, int y, SDL_Color colour, const char* text, ...); -//void SDL_LoadImage(SDL_Renderer *renderer, SDL_Texture **texture, char *path); void SDL_LoadImage(SDL_Texture **texture, char *path); void SDL_LoadImageBuf(SDL_Renderer *renderer, SDL_Texture **texture, void *mem, int size); void SDL_DrawImage(SDL_Renderer *renderer, SDL_Texture *texture, int x, int y); void SDL_DrawImageScale(SDL_Renderer *renderer, SDL_Texture *texture, int x, int y, int w, int h); +void SDL_DrawButtonPrompt(SDL_Renderer *renderer, SDL_Texture *texture, TTF_Font *font, SDL_Color textColor, const char* text, int x, int y, int imageW, int imageH, int imageDistance, int yTextOffset); +void SDL_DrawHorizonalAlignedImageText (SDL_Renderer *renderer, SDL_Texture *texture, TTF_Font *font, SDL_Color textColor, const char* text, int x, int y, int imageW, int imageH, int imageDistance, int yTextOffset); void SDL_InvertSurfaceColor(SDL_Surface *surface); Uint32 SDL_GetPixel32(SDL_Surface *surface, int x, int y); void SDL_PutPixel32(SDL_Surface *surface, int x, int y, Uint32 pixel); diff --git a/include/textures.h b/include/textures.h index a4debe2..8fdb570 100644 --- a/include/textures.h +++ b/include/textures.h @@ -6,8 +6,8 @@ extern SDL_Texture *battery_20, *battery_20_charging, *battery_30, *battery_30_charging, *battery_50, *battery_50_charging, \ *battery_60, *battery_60_charging, *battery_80, *battery_80_charging, *battery_90, *battery_90_charging, \ *battery_full, *battery_full_charging, *battery_low, *battery_unknown, *error, *warning, *button_a, *button_b, \ - *button_x, *button_y, *button_down, *button_up, *button_left, *button_right, *button_lb, *button_rb, *button_lt, \ - *button_rt, *button_minus, *button_plus, *button_capture, *button_home; + *button_x, *button_y, *button_dpad_up_down, *button_dpad_left_right, *button_lb, *button_rb, *button_lt, \ + *button_rt, *button_minus, *button_plus, *left_stick_up_down, *right_stick_up_down; void Textures_Load(void); void Textures_Free(void); diff --git a/romfs/resources/font/Roboto-Light.ttf b/romfs/resources/font/Roboto-Light.ttf new file mode 100644 index 0000000..3526798 Binary files /dev/null and b/romfs/resources/font/Roboto-Light.ttf differ diff --git a/romfs/resources/font/arial.ttf b/romfs/resources/font/arial.ttf deleted file mode 100644 index 8682d94..0000000 Binary files a/romfs/resources/font/arial.ttf and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Controller_Left.png b/romfs/resources/images/control/Switch_Controller_Left.png deleted file mode 100644 index f90a244..0000000 Binary files a/romfs/resources/images/control/Switch_Controller_Left.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Controller_Right.png b/romfs/resources/images/control/Switch_Controller_Right.png deleted file mode 100644 index 873da7e..0000000 Binary files a/romfs/resources/images/control/Switch_Controller_Right.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Controllers.png b/romfs/resources/images/control/Switch_Controllers.png deleted file mode 100644 index b6ee54d..0000000 Binary files a/romfs/resources/images/control/Switch_Controllers.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Controllers_Separate.png b/romfs/resources/images/control/Switch_Controllers_Separate.png deleted file mode 100644 index 0c019da..0000000 Binary files a/romfs/resources/images/control/Switch_Controllers_Separate.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Down.png b/romfs/resources/images/control/Switch_Down.png deleted file mode 100644 index 7b7b2b2..0000000 Binary files a/romfs/resources/images/control/Switch_Down.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad.png b/romfs/resources/images/control/Switch_Dpad.png deleted file mode 100644 index 12f01eb..0000000 Binary files a/romfs/resources/images/control/Switch_Dpad.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad_Down.png b/romfs/resources/images/control/Switch_Dpad_Down.png deleted file mode 100644 index 37f6d5b..0000000 Binary files a/romfs/resources/images/control/Switch_Dpad_Down.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad_Left.png b/romfs/resources/images/control/Switch_Dpad_Left.png deleted file mode 100644 index 8efd7a4..0000000 Binary files a/romfs/resources/images/control/Switch_Dpad_Left.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad_Left_right.png b/romfs/resources/images/control/Switch_Dpad_Left_right.png new file mode 100644 index 0000000..29d8075 Binary files /dev/null and b/romfs/resources/images/control/Switch_Dpad_Left_right.png differ diff --git a/romfs/resources/images/control/Switch_Dpad_Right.png b/romfs/resources/images/control/Switch_Dpad_Right.png deleted file mode 100644 index 8b5411d..0000000 Binary files a/romfs/resources/images/control/Switch_Dpad_Right.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad_Up.png b/romfs/resources/images/control/Switch_Dpad_Up.png deleted file mode 100644 index 700a8ba..0000000 Binary files a/romfs/resources/images/control/Switch_Dpad_Up.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Dpad_Up_down.png b/romfs/resources/images/control/Switch_Dpad_Up_down.png new file mode 100644 index 0000000..5108976 Binary files /dev/null and b/romfs/resources/images/control/Switch_Dpad_Up_down.png differ diff --git a/romfs/resources/images/control/Switch_Home.png b/romfs/resources/images/control/Switch_Home.png deleted file mode 100644 index 9b6733c..0000000 Binary files a/romfs/resources/images/control/Switch_Home.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Left.png b/romfs/resources/images/control/Switch_Left.png deleted file mode 100644 index fd58439..0000000 Binary files a/romfs/resources/images/control/Switch_Left.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Left_Stick.png b/romfs/resources/images/control/Switch_Left_Stick.png deleted file mode 100644 index d861ca5..0000000 Binary files a/romfs/resources/images/control/Switch_Left_Stick.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Left_Stick_up_down.png b/romfs/resources/images/control/Switch_Left_Stick_up_down.png new file mode 100644 index 0000000..7830104 Binary files /dev/null and b/romfs/resources/images/control/Switch_Left_Stick_up_down.png differ diff --git a/romfs/resources/images/control/Switch_Right.png b/romfs/resources/images/control/Switch_Right.png deleted file mode 100644 index f524c6c..0000000 Binary files a/romfs/resources/images/control/Switch_Right.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Right_Stick.png b/romfs/resources/images/control/Switch_Right_Stick.png deleted file mode 100644 index f2c605b..0000000 Binary files a/romfs/resources/images/control/Switch_Right_Stick.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Right_Stick_up_down.png b/romfs/resources/images/control/Switch_Right_Stick_up_down.png new file mode 100644 index 0000000..85dd999 Binary files /dev/null and b/romfs/resources/images/control/Switch_Right_Stick_up_down.png differ diff --git a/romfs/resources/images/control/Switch_Square.png b/romfs/resources/images/control/Switch_Square.png deleted file mode 100644 index d0fd432..0000000 Binary files a/romfs/resources/images/control/Switch_Square.png and /dev/null differ diff --git a/romfs/resources/images/control/Switch_Up.png b/romfs/resources/images/control/Switch_Up.png deleted file mode 100644 index 352f890..0000000 Binary files a/romfs/resources/images/control/Switch_Up.png and /dev/null differ diff --git a/source/helpers/SDL_helper.c b/source/helpers/SDL_helper.c index b7cec5d..8d33804 100644 --- a/source/helpers/SDL_helper.c +++ b/source/helpers/SDL_helper.c @@ -87,4 +87,21 @@ void SDL_DrawImageScale(SDL_Renderer *renderer, SDL_Texture *texture, int x, int SDL_Rect position; position.x = x; position.y = y; position.w = w; position.h = h; SDL_RenderCopy(renderer, texture, NULL, &position); +} + +void SDL_DrawButtonPrompt(SDL_Renderer *renderer, SDL_Texture *texture, TTF_Font *font, SDL_Color textColor, const char* text, int x, int y, int imageW, int imageH, int imageDistance, int yTextOffset) { + int textWidth, textHeight; + TTF_SizeText(ROBOTO_20, text, &textWidth, &textHeight); + + int imageX = x; + int imageY = y - imageH; + SDL_DrawImageScale(RENDERER, texture, imageX, imageY, imageW, imageH); + + int textX = x + imageDistance + imageW; + int textY = y - (imageH * 0.85) - yTextOffset; // 0.85 was retreived from trail and error when trying to center the text with the image. + SDL_DrawText(RENDERER, ROBOTO_20, textX, textY, textColor, text); +} + +void SDL_DrawHorizonalAlignedImageText (SDL_Renderer *renderer, SDL_Texture *texture, TTF_Font *font, SDL_Color textColor, const char* text, int x, int y, int imageW, int imageH, int imageDistance, int yTextOffset) { + SDL_DrawButtonPrompt(renderer, texture, font, textColor, text, x, y, imageW, imageH, imageDistance, yTextOffset); } \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index 36096de..8f29822 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -23,7 +23,7 @@ extern "C" { SDL_Renderer* RENDERER; SDL_Window* WINDOW; SDL_Event EVENT; -TTF_Font *ARIAL, *ARIAL_35, *ARIAL_30, *ARIAL_27, *ARIAL_25, *ARIAL_20, *ARIAL_15; +TTF_Font *ROBOTO_35, *ROBOTO_30, *ROBOTO_27, *ROBOTO_25, *ROBOTO_20, *ROBOTO_15; bool configDarkMode; bool run = true; @@ -32,13 +32,12 @@ void Term_Services() { run = false; timeExit(); - TTF_CloseFont(ARIAL_35); - TTF_CloseFont(ARIAL_30); - TTF_CloseFont(ARIAL_27); - TTF_CloseFont(ARIAL_25); - TTF_CloseFont(ARIAL_20); - TTF_CloseFont(ARIAL_15); - TTF_CloseFont(ARIAL); + TTF_CloseFont(ROBOTO_35); + TTF_CloseFont(ROBOTO_30); + TTF_CloseFont(ROBOTO_27); + TTF_CloseFont(ROBOTO_25); + TTF_CloseFont(ROBOTO_20); + TTF_CloseFont(ROBOTO_15); TTF_Quit(); Textures_Free(); @@ -96,19 +95,16 @@ void Init_Services() { } std::cout << "Initalized TTF" << std::endl; - #ifdef EXPERIMENTAL - std::cout << "Loading Textures" << std::endl; - Textures_Load(); - #endif + Textures_Load(); + std::cout << "Loaded Textures" << std::endl; - ARIAL_35 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 35); - ARIAL_30 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 30); - ARIAL_27 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 27); - ARIAL_25 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 25); - ARIAL_20 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 20); - ARIAL_15 = TTF_OpenFont("romfs:/resources/font/arial.ttf", 15); - ARIAL = TTF_OpenFont("romfs:/resources/font/arial.ttf", 20); - if (!ARIAL_35 || !ARIAL_25 || !ARIAL_15 || !ARIAL) { + ROBOTO_35 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 35); + ROBOTO_30 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 30); + ROBOTO_27 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 27); + ROBOTO_25 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 25); + ROBOTO_20 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 20); + ROBOTO_15 = TTF_OpenFont("romfs:/resources/font/Roboto-Light.ttf", 15); + if (!ROBOTO_35 || !ROBOTO_25 || !ROBOTO_15) { std::cout << "Failure to retrieve fonts" << std::endl; Term_Services(); } @@ -131,7 +127,9 @@ void Init_Services() { int main(int argc, char *argv[]) { Init_Services(); - Menu_StartChoosing(); + if (run) { + Menu_StartChoosing(); + } Term_Services(); return 0; diff --git a/source/menus/book-chooser/MenuChooser.cpp b/source/menus/book-chooser/MenuChooser.cpp index a702b88..67a4cf9 100644 --- a/source/menus/book-chooser/MenuChooser.cpp +++ b/source/menus/book-chooser/MenuChooser.cpp @@ -22,7 +22,7 @@ template bool contains(list & listOfElements, const T & element) return it != listOfElements.end(); } -extern TTF_Font *ARIAL, *ARIAL_35, *ARIAL_25, *ARIAL_15; +extern TTF_Font *ROBOTO_35, *ROBOTO_25, *ROBOTO_15; void Menu_StartChoosing() { int choosenIndex = 0; @@ -129,8 +129,13 @@ void Menu_StartChoosing() { configDarkMode = !configDarkMode; } - SDL_DrawText(RENDERER, ARIAL_25, windowX - 123, windowY - 45, textColor, "\"B\" - Exit"); - SDL_DrawText(RENDERER, ARIAL_25, windowX - 200, windowY - 80, textColor, "\"-\" - Switch theme"); + int exitWidth = 0; + TTF_SizeText(ROBOTO_20, "Exit", &exitWidth, NULL); + SDL_DrawButtonPrompt(RENDERER, button_b, ROBOTO_20, textColor, "Exit", windowX - exitWidth - 50, windowY - 10, 35, 35, 5, 0); + + int themeWidth = 0; + TTF_SizeText(ROBOTO_20, "Switch Theme", &themeWidth, NULL); + SDL_DrawButtonPrompt(RENDERER, button_minus, ROBOTO_20, textColor, "Switch Theme", windowX - themeWidth - 50, windowY - 40, 35, 35, 5, 0); int choosingIndex = 0; for (const auto & entry : fs::directory_iterator(path)) { @@ -142,13 +147,11 @@ void Menu_StartChoosing() { SDL_DrawRect(RENDERER, 15, 15 + (40 * choosingIndex), 1265, 40, configDarkMode ? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT); } - #ifdef EXPERIMENTAL - if (contains(warnedExtentions, extention)) { - SDL_DrawImage(RENDERER, warning, 25, 18 + (40 * choosingIndex)); - } - #endif + if (contains(warnedExtentions, extention)) { + SDL_DrawImage(RENDERER, warning, 25, 18 + (40 * choosingIndex)); + } - SDL_DrawText(RENDERER, ARIAL_25, 70, 20 + (40 * choosingIndex), textColor, entry.path().filename().c_str()); + SDL_DrawText(RENDERER, ROBOTO_25, 70, 20 + (40 * choosingIndex), textColor, entry.path().filename().c_str()); if (isWarningOnScreen) { if (!configDarkMode) { // Display a dimmed background if on light mode @@ -156,10 +159,10 @@ void Menu_StartChoosing() { } SDL_DrawRect(RENDERER, (windowX - warningWidth) / 2, (windowY - warningHeight) / 2, warningWidth, warningHeight, configDarkMode ? HINT_COLOUR_DARK : HINT_COLOUR_LIGHT); - SDL_DrawText(RENDERER, ARIAL_30, (windowX - warningWidth) / 2 + 15, (windowY - warningHeight) / 2 + 15, textColor, "This file is not yet fully supported, and may"); - SDL_DrawText(RENDERER, ARIAL_30, (windowX - warningWidth) / 2 + 15, (windowY - warningHeight) / 2 + 50, textColor, "cause a system, or app crash."); - SDL_DrawText(RENDERER, ARIAL_20, (windowX - warningWidth) / 2 + warningWidth - 250, (windowY - warningHeight) / 2 + warningHeight - 30, textColor, "\"A\" - Read"); - SDL_DrawText(RENDERER, ARIAL_20, (windowX - warningWidth) / 2 + warningWidth - 125, (windowY - warningHeight) / 2 + warningHeight - 30, textColor, "\"B\" - Cancel."); + SDL_DrawText(RENDERER, ROBOTO_30, (windowX - warningWidth) / 2 + 15, (windowY - warningHeight) / 2 + 15, textColor, "This file is not yet fully supported, and may"); + SDL_DrawText(RENDERER, ROBOTO_30, (windowX - warningWidth) / 2 + 15, (windowY - warningHeight) / 2 + 50, textColor, "cause a system, or app crash."); + SDL_DrawText(RENDERER, ROBOTO_20, (windowX - warningWidth) / 2 + warningWidth - 250, (windowY - warningHeight) / 2 + warningHeight - 30, textColor, "\"A\" - Read"); + SDL_DrawText(RENDERER, ROBOTO_20, (windowX - warningWidth) / 2 + warningWidth - 125, (windowY - warningHeight) / 2 + warningHeight - 30, textColor, "\"B\" - Cancel."); } choosingIndex++; diff --git a/source/menus/book/BookReader.cpp b/source/menus/book/BookReader.cpp index 1eda2e0..68029e0 100644 --- a/source/menus/book/BookReader.cpp +++ b/source/menus/book/BookReader.cpp @@ -1,7 +1,6 @@ #include "BookReader.hpp" #include "PageLayout.hpp" #include "LandscapePageLayout.hpp" -#include "common.h" #include #include #include @@ -10,6 +9,8 @@ extern "C" { #include "SDL_helper.h" #include "status_bar.h" #include "config.h" + #include "textures.h" + #include "common.h" } fz_context *ctx = NULL; @@ -147,6 +148,7 @@ void BookReader::draw(bool drawHelp) { if (drawHelp) { // Help menu int helpWidth = 680; int helpHeight = 365; + helpHeight -= 38; // Removed due to removing the skip forward page button prompt. if (!configDarkMode) { // Display a dimmed background if on light mode SDL_DrawRect(RENDERER, 0, 0, 1280, 720, SDL_MakeColour(50, 50, 50, 150)); @@ -154,39 +156,39 @@ void BookReader::draw(bool drawHelp) { SDL_DrawRect(RENDERER, (windowX - helpWidth) / 2, (windowY - helpHeight) / 2, helpWidth, helpHeight, configDarkMode ? HINT_COLOUR_DARK : HINT_COLOUR_LIGHT); - // These already have margin added to them int textX = (windowX - helpWidth) / 2 + 20; - int textY = (windowY - helpHeight) / 2 + 75; - SDL_DrawText(RENDERER, ARIAL_30, textX, (windowY - helpHeight) / 2 + 10, configDarkMode ? WHITE : BLACK, "Help Menu:"); + int textY = (windowY - helpHeight) / 2 + 87; + SDL_Color textColor = configDarkMode ? WHITE : BLACK; + SDL_DrawText(RENDERER, ROBOTO_30, textX, (windowY - helpHeight) / 2 + 10, textColor, "Help Menu:"); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY, configDarkMode ? WHITE : BLACK, "\"B\" - Stop reading / Close help menu."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35, configDarkMode ? WHITE : BLACK, "\"-\" - Switch to dark/light theme."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 2, configDarkMode ? WHITE : BLACK, "\"Right Stick Up/Down\" - Zoom in/out."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 3, configDarkMode ? WHITE : BLACK, "\"Left Stick Up/Down\" - Page up/down."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 4, configDarkMode ? WHITE : BLACK, "\"Y\" - Rotate page."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 5, configDarkMode ? WHITE : BLACK, "\"X\" - Keep status bar on."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 6, configDarkMode ? WHITE : BLACK, "\"Left/Right DPad\" - Next/previous page."); - SDL_DrawText(RENDERER, ARIAL_25, textX, textY + 35 * 7, configDarkMode ? WHITE : BLACK, "\"Left/Right Bumper\" - Skip forward/backward 10 pages."); + SDL_DrawButtonPrompt(RENDERER, button_b, ROBOTO_25, textColor, "Stop reading / Close help menu.", textX, textY, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, button_minus, ROBOTO_25, textColor, "Switch to dark/light theme.", textX, textY + 38, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, right_stick_up_down, ROBOTO_25, textColor, "Zoom in/out.", textX, textY + 38 * 2, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, left_stick_up_down, ROBOTO_25, textColor, "Page up/down.", textX, textY + 38 * 3, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, button_y, ROBOTO_25, textColor, "Rotate page.", textX, textY + 38 * 4, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, button_x, ROBOTO_25, textColor, "Keep status bar on.", textX, textY + 38 * 5, 35, 35, 5, 0); + SDL_DrawButtonPrompt(RENDERER, button_dpad_left_right, ROBOTO_25, textColor, "Next/previous page.", textX, textY + 38 * 6, 35, 35, 5, 0); + //SDL_DrawButtonPrompt(RENDERER, button_dpad_up_down, ROBOTO_25, textColor, "Skip forward/backward 10 pages.", textX, textY + 38 * 7, 35, 35, 5, 0); } if (permStatusBar || --status_bar_visible_counter > 0) { char *title = layout->info(); int title_width = 0, title_height = 0; - TTF_SizeText(ARIAL_15, title, &title_width, &title_height); + TTF_SizeText(ROBOTO_15, title, &title_width, &title_height); SDL_Color color = configDarkMode ? STATUS_BAR_DARK : STATUS_BAR_LIGHT; if (_currentPageLayout == BookPageLayoutPortrait) { SDL_DrawRect(RENDERER, 0, 0, 1280, 45, SDL_MakeColour(color.r, color.g, color.b , 180)); - SDL_DrawText(RENDERER, ARIAL_25, (1280 - title_width) / 2, (40 - title_height) / 2, WHITE, title); + SDL_DrawText(RENDERER, ROBOTO_25, (1280 - title_width) / 2, (40 - title_height) / 2, WHITE, title); StatusBar_DisplayTime(false); } else if (_currentPageLayout == BookPageLayoutLandscape) { SDL_DrawRect(RENDERER, 1280 - 45, 0, 45, 720, SDL_MakeColour(color.r, color.g, color.b , 180)); int x = (1280 - title_width) - ((40 - title_height) / 2); int y = (720 - title_height) / 2; - SDL_DrawRotatedText(RENDERER, ARIAL_25, (double) 90, x, y, WHITE, title); + SDL_DrawRotatedText(RENDERER, ROBOTO_25, (double) 90, x, y, WHITE, title); StatusBar_DisplayTime(true); } diff --git a/source/status_bar.c b/source/status_bar.c index e5fa8fc..1f2cf82 100644 --- a/source/status_bar.c +++ b/source/status_bar.c @@ -41,88 +41,103 @@ static void StatusBar_GetBatteryStatus(int x, int y) { state = 0; if (R_SUCCEEDED(psmGetBatteryChargePercentage(&percent))) { + SDL_Texture *batteryImage; if (percent < 20) { - SDL_DrawImage(RENDERER, battery_low, x, 3); + //SDL_DrawImage(RENDERER, battery_low, x, 3); + batteryImage = battery_low; } else if ((percent >= 20) && (percent < 30)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_20_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_20_charging, x, 3); + batteryImage = battery_20_charging; } else { - SDL_DrawImage(RENDERER, battery_20, x, 3); + //SDL_DrawImage(RENDERER, battery_20, x, 3); + batteryImage = battery_20; } } else if ((percent >= 30) && (percent < 50)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_50_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_50_charging, x, 3); + batteryImage = battery_50_charging; } else { - SDL_DrawImage(RENDERER, battery_50, x, 3); + //SDL_DrawImage(RENDERER, battery_50, x, 3); + batteryImage = battery_50; } } else if ((percent >= 50) && (percent < 60)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_50_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_50_charging, x, 3); + batteryImage = battery_50_charging; } else { - SDL_DrawImage(RENDERER, battery_50, x, 3); + //SDL_DrawImage(RENDERER, battery_50, x, 3); + batteryImage = battery_50; } } else if ((percent >= 60) && (percent < 80)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_60_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_60_charging, x, 3); + batteryImage = battery_60_charging; } else { - SDL_DrawImage(RENDERER, battery_60, x, 3); + //SDL_DrawImage(RENDERER, battery_60, x, 3); + batteryImage = battery_60; } } else if ((percent >= 80) && (percent < 90)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_80_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_80_charging, x, 3); + batteryImage = battery_80_charging; } else { - SDL_DrawImage(RENDERER, battery_80, x, 3); + //SDL_DrawImage(RENDERER, battery_80, x, 3); + batteryImage = battery_80; } } else if ((percent >= 90) && (percent < 100)) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_90_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_90_charging, x, 3); + batteryImage = battery_90_charging; } else { - SDL_DrawImage(RENDERER, battery_90, x, 3); + //SDL_DrawImage(RENDERER, battery_90, x, 3); + batteryImage = battery_90; } } else if (percent == 100) { if (state != 0) { - SDL_DrawImage(RENDERER, battery_full_charging, x, 3); + //SDL_DrawImage(RENDERER, battery_full_charging, x, 3); + batteryImage = battery_full_charging; } else { - SDL_DrawImage(RENDERER, battery_full, x, 3); + //SDL_DrawImage(RENDERER, battery_full, x, 3); + batteryImage = battery_full; } } snprintf(buf, 5, "%d%%", percent); - TTF_SizeText(ARIAL_20, buf, &width, NULL); - SDL_DrawText(RENDERER, ARIAL_20, (x + width + 5), y, WHITE, buf); + TTF_SizeText(ROBOTO_20, buf, &width, NULL); + SDL_DrawHorizonalAlignedImageText(RENDERER, batteryImage, ROBOTO_20, WHITE, buf, (x + width + 5), y, 34, 34, -2, -7); + //SDL_DrawText(RENDERER, ROBOTO_20, (x + width + 5), y, WHITE, buf); } else { snprintf(buf, 5, "%d%%", percent); - TTF_SizeText(ARIAL_20, buf, &width, NULL); - SDL_DrawText(RENDERER, ARIAL_20, (x + width + 5), y, WHITE, buf); - SDL_DrawImage(RENDERER, battery_unknown, x, 1); + TTF_SizeText(ROBOTO_20, buf, &width, NULL); + SDL_DrawHorizonalAlignedImageText(RENDERER, battery_unknown, ROBOTO_20, WHITE, buf, x, y, 34, 34, -2, -7); + + /*SDL_DrawText(RENDERER, ROBOTO_20, (x + width + 5), y, WHITE, buf); + SDL_DrawImage(RENDERER, battery_unknown, x, 1);*/ } } void StatusBar_DisplayTime(bool portriat) { int timeWidth = 0, timeHeight = 0; - TTF_SizeText(ARIAL_25, Clock_GetCurrentTime(), &timeWidth, &timeHeight); + TTF_SizeText(ROBOTO_25, Clock_GetCurrentTime(), &timeWidth, &timeHeight); int helpWidth, helpHeight; - TTF_SizeText(ARIAL_20, "\"+\" - Help", &helpWidth, &helpHeight); + TTF_SizeText(ROBOTO_20, "\"+\" - Help", &helpWidth, &helpHeight); if (portriat) { int timeX = (1280 - timeWidth) + timeHeight; int timeY = (720 - timeWidth) + 15; - SDL_DrawRotatedText(RENDERER, ARIAL_25, (double) 90, timeX, timeY, WHITE, Clock_GetCurrentTime()); + SDL_DrawRotatedText(RENDERER, ROBOTO_25, (double) 90, timeX, timeY, WHITE, Clock_GetCurrentTime()); int helpX = (1280 - helpWidth) + 21; int helpY = (720 - helpHeight) - (720 - timeY) - 75; - SDL_DrawRotatedText(RENDERER, ARIAL_20, (double) 90, helpX, helpY, WHITE, "\"+\" - Help"); + SDL_DrawRotatedText(RENDERER, ROBOTO_20, (double) 90, helpX, helpY, WHITE, "\"+\" - Help"); - //SDL_DrawRotatedText(RENDERER, ARIAL_25, (double) 90, 1270 - width, (720 - height), WHITE, Clock_GetCurrentTime()); + //SDL_DrawRotatedText(RENDERER, ROBOTO_25, (double) 90, 1270 - width, (720 - height), WHITE, Clock_GetCurrentTime()); } else { - SDL_DrawText(RENDERER, ARIAL_25, 1260 - timeWidth, (40 - timeHeight) / 2, WHITE, Clock_GetCurrentTime()); + SDL_DrawText(RENDERER, ROBOTO_25, 1260 - timeWidth, (40 - timeHeight) / 2, WHITE, Clock_GetCurrentTime()); - SDL_DrawText(RENDERER, ARIAL_20, 1260 - helpWidth - timeWidth - 25, (40 - helpHeight) / 2, WHITE, "\"+\" - Help"); + SDL_DrawText(RENDERER, ROBOTO_20, 1260 - helpWidth - timeWidth - 25, (40 - helpHeight) / 2, WHITE, "\"+\" - Help"); - StatusBar_GetBatteryStatus(1260 - (timeWidth + helpWidth) - 110, (40 - timeHeight) / 2 + 15); // 34 is height of battery img + StatusBar_GetBatteryStatus(1260 - (timeWidth + helpWidth) - 110, (40 - timeHeight) / 2 + 34); // 34 is height of battery img } - - #ifdef EXPERIMENTAL - - #endif } \ No newline at end of file diff --git a/source/textures.c b/source/textures.c index 7a3a402..9c2cd48 100644 --- a/source/textures.c +++ b/source/textures.c @@ -5,14 +5,15 @@ SDL_Texture *battery_20, *battery_20_charging, *battery_30, *battery_30_charging, *battery_50, *battery_50_charging, \ *battery_60, *battery_60_charging, *battery_80, *battery_80_charging, *battery_90, *battery_90_charging, \ *battery_full, *battery_full_charging, *battery_low, *battery_unknown, *error, *warning, *button_a, *button_b, \ - *button_x, *button_y, *button_down, *button_up, *button_left, *button_right, *button_lb, *button_rb, *button_lt, \ - *button_rt, *button_minus, *button_plus, *button_capture, *button_home; + *button_x, *button_y, *button_dpad_up_down, *button_dpad_left_right, *button_lb, *button_rb, *button_lt, \ + *button_rt, *button_minus, *button_plus, *left_stick_up_down, *right_stick_up_down; void Textures_Load(void) { + // Battery images SDL_LoadImage(&battery_20, "romfs:/resources/images/battery/battery_20.png"); SDL_LoadImage(&battery_20_charging, "romfs:/resources/images/battery/battery_20_charging.png"); SDL_LoadImage(&battery_30, "romfs:/resources/images/battery/battery_30.png"); - SDL_LoadImage(&battery_30_charging, "romfs:/resources/images/battery/battery/battery_30_charging.png"); + SDL_LoadImage(&battery_30_charging, "romfs:/resources/images/battery/battery_30_charging.png"); SDL_LoadImage(&battery_50, "romfs:/resources/images/battery/battery_50.png"); SDL_LoadImage(&battery_50_charging, "romfs:/resources/images/battery/battery_50_charging.png"); SDL_LoadImage(&battery_60, "romfs:/resources/images/battery/battery_60.png"); @@ -25,13 +26,50 @@ void Textures_Load(void) { SDL_LoadImage(&battery_full_charging, "romfs:/resources/images/battery/battery_full_charging.png"); SDL_LoadImage(&battery_low, "romfs:/resources/images/battery/battery_low.png"); SDL_LoadImage(&battery_unknown, "romfs:/resources/images/battery/battery_unknown.png"); + + // Info images SDL_LoadImage(&error, "romfs:/resources/images/info/error.png"); SDL_LoadImage(&warning, "romfs:/resources/images/info/warning.png"); + + // Button images + SDL_LoadImage(&button_a, "romfs:/resources/images/control/Switch_A.png"); + SDL_LoadImage(&button_b, "romfs:/resources/images/control/Switch_B.png"); + SDL_LoadImage(&button_x, "romfs:/resources/images/control/Switch_X.png"); + SDL_LoadImage(&button_y, "romfs:/resources/images/control/Switch_Y.png"); + SDL_LoadImage(&button_dpad_up_down, "romfs:/resources/images/control/Switch_Dpad_Up_down.png"); + SDL_LoadImage(&button_dpad_left_right, "romfs:/resources/images/control/Switch_Dpad_Left_right.png"); + SDL_LoadImage(&button_lb, "romfs:/resources/images/control/Switch_LB.png"); + SDL_LoadImage(&button_rb, "romfs:/resources/images/control/Switch_RB.png"); + SDL_LoadImage(&button_lt, "romfs:/resources/images/control/Switch_LT.png"); + SDL_LoadImage(&button_rt, "romfs:/resources/images/control/Switch_RT.png"); + SDL_LoadImage(&button_minus, "romfs:/resources/images/control/Switch_Minus.png"); + SDL_LoadImage(&button_plus, "romfs:/resources/images/control/Switch_Plus.png"); + SDL_LoadImage(&left_stick_up_down, "romfs:/resources/images/control/Switch_Left_Stick_up_down.png"); + SDL_LoadImage(&right_stick_up_down, "romfs:/resources/images/control/Switch_Right_Stick_up_down.png"); } void Textures_Free(void) { + // Button images + SDL_DestroyTexture(button_a); + SDL_DestroyTexture(button_b); + SDL_DestroyTexture(button_x); + SDL_DestroyTexture(button_y); + SDL_DestroyTexture(button_dpad_up_down); + SDL_DestroyTexture(button_dpad_left_right); + SDL_DestroyTexture(button_lb); + SDL_DestroyTexture(button_rb); + SDL_DestroyTexture(button_lt); + SDL_DestroyTexture(button_rt); + SDL_DestroyTexture(button_minus); + SDL_DestroyTexture(button_plus); + SDL_DestroyTexture(left_stick_up_down); + SDL_DestroyTexture(right_stick_up_down); + + // Info images SDL_DestroyTexture(warning); SDL_DestroyTexture(error); + + // Battery images SDL_DestroyTexture(battery_unknown); SDL_DestroyTexture(battery_low); SDL_DestroyTexture(battery_full_charging);