diff --git a/.gitignore b/.gitignore index a2b356a..30e611e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ makerom* *.pfs0 *.nso *.nacp +build/sprites.h +*.t3x diff --git a/Makefile b/Makefile index d88f339..ecfeb32 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ RSF_FILE := app/build-cia.rsf ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft CFLAGS := -g -Wall -Wno-psabi -O2 -mword-relocations \ - -DVERSION_STRING=\"$(GIT_VER)\" \ + -DV_STRING=\"$(GIT_VER)\" \ -fomit-frame-pointer -ffunction-sections \ $(ARCH) @@ -136,6 +136,7 @@ CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica))) SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist))) +GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- @@ -152,6 +153,19 @@ else endif #--------------------------------------------------------------------------------- +#--------------------------------------------------------------------------------- +ifeq ($(GFXBUILD),$(BUILD)) +#--------------------------------------------------------------------------------- +export T3XFILES := $(GFXFILES:.t3s=.t3x) +#--------------------------------------------------------------------------------- +else +#--------------------------------------------------------------------------------- +export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES)) +export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES)) +#--------------------------------------------------------------------------------- +endif +#--------------------------------------------------------------------------------- + export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ @@ -194,7 +208,7 @@ endif .PHONY: all clean #--------------------------------------------------------------------------------- -all: $(BUILD) $(DEPSDIR) +all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES) @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile #------------------------------------------------------------------------------ @@ -212,6 +226,12 @@ cia: $(BUILD) 3dsx: $(BUILD) @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 3dsx +#--------------------------------------------------------------------------------- +$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + $(DEVKITPRO)/tools/bin/tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x + #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @@ -240,6 +260,10 @@ $(OUTPUT).cia : $(OUTPUT).elf $(OUTPUT).smdh @echo $(notdir $<) @$(bin2o) +#--------------------------------------------------------------------------------- +.PRECIOUS : %.t3x +#--------------------------------------------------------------------------------- +%.t3x.o %_t3x.h : %.t3x #--------------------------------------------------------------------------------- @echo $(notdir $<) @$(bin2o) @@ -271,8 +295,13 @@ endef @$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file))) #--------------------------------------------------------------------------------- +%.t3x %.h : %.t3s +#--------------------------------------------------------------------------------- + @echo $(notdir $<) + @tex3ds -i $< -H $*.h -d $*.d -o $*.t3x + -include $(DEPSDIR)/*.d #--------------------------------------------------------------------------------------- endif -#--------------------------------------------------------------------------------------- +#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/assets/gfx/sprites.t3s b/assets/gfx/sprites.t3s new file mode 100644 index 0000000..c40ca54 --- /dev/null +++ b/assets/gfx/sprites.t3s @@ -0,0 +1,4 @@ +--atlas -f rgba -z auto + +sprites/credits/discord.png +sprites/credits/voltZ.png \ No newline at end of file diff --git a/assets/gfx/sprites/credits/discord.png b/assets/gfx/sprites/credits/discord.png new file mode 100644 index 0000000..5935bb8 Binary files /dev/null and b/assets/gfx/sprites/credits/discord.png differ diff --git a/assets/gfx/sprites/credits/voltZ.png b/assets/gfx/sprites/credits/voltZ.png new file mode 100644 index 0000000..26cfc22 Binary files /dev/null and b/assets/gfx/sprites/credits/voltZ.png differ diff --git a/include/download/download.hpp b/include/download/download.hpp index c18e7b6..f4b5f14 100644 --- a/include/download/download.hpp +++ b/include/download/download.hpp @@ -29,7 +29,7 @@ #include "utils/common.hpp" #define APP_TITLE "Universal-Updater" -#define V_STRING "1.0.0" +#define VERSION_STRING "2.0.0" enum DownloadError { DL_ERROR_NONE = 0, diff --git a/include/gui.hpp b/include/gui.hpp index 2226f5f..ce1e14c 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -28,6 +28,8 @@ #define GUI_HPP #include "colors.hpp" +#include "sprites.h" + #include "screens/screen.hpp" #include <3ds.h> @@ -55,6 +57,9 @@ namespace Gui // Clear Text. void clearTextBufs(void); + // Draw a Sprite from the sheet. + void sprite(int key, int x, int y, float ScaleX = 1, float ScaleY = 1); + // Misc. bool Draw_Rect(float x, float y, float w, float h, u32 color); diff --git a/include/screens/scriptCreator.hpp b/include/screens/scriptCreator.hpp index abca930..3d17d87 100644 --- a/include/screens/scriptCreator.hpp +++ b/include/screens/scriptCreator.hpp @@ -30,6 +30,9 @@ #include "screens/screenCommon.hpp" #include "utils/json.hpp" +#include "utils/structs.hpp" + +#include class ScriptCreator : public Screen { @@ -39,13 +42,19 @@ public: ScriptCreator(); private: - void openJson(); - void save(); - + int Selection = 0; + void openJson(std::string fileName); + void save(std::string fileName); + void setInfoStuff(void); void setBool(const std::string &object, const std::string &key, bool v); void setInt(const std::string &object, const std::string &key, int v); void setString(const std::string &object, const std::string &key, const std::string &v); + + std::vector mainButtons = { + {90, 40, 140, 35, -1}, // New Script. + {90, 100, 140, 35, -1}, // Existing Script. + }; }; #endif \ No newline at end of file diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index 60252d8..73d7cd0 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -39,10 +39,29 @@ public: void Draw(void) const override; void Logic(u32 hDown, u32 hHeld, touchPosition touch) override; private: + // Credits stuff. + int DisplayMode = 1; + int delay = 120; + bool discordText = false; + + int colorMode = 0; + int mode = 0; + int Selection = 0; + + void DrawSubMenu(void) const; void DrawLanguageSelection(void) const; void DrawColorChanging(void) const; + void DrawCreditsScreen(void) const; + void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); void LanguageSelection(u32 hDown, touchPosition touch); void colorChanging(u32 hDown, touchPosition touch); + void CreditsLogic(u32 hDown, touchPosition touch); + + std::vector mainButtons = { + {90, 40, 140, 35, -1}, // Language. + {90, 100, 140, 35, -1}, // Colors. + {90, 160, 140, 35, -1}, // Misc. + }; std::vector langBlocks = { {37, 32, 20, 20, -1}, @@ -63,6 +82,9 @@ private: {220, 85, 95, 41, -1}, }; + std::vector barPos = { + {0, 210, 320, 30, -1}, + }; }; #endif \ No newline at end of file diff --git a/romfs/lang/en/app.json b/romfs/lang/en/app.json index e0baeb2..834c650 100644 --- a/romfs/lang/en/app.json +++ b/romfs/lang/en/app.json @@ -1,15 +1,16 @@ { - "DOWNLOAD_FAILED": "Download Failed!", - "NOT_IMPLEMENTED": "Not Implemented Yet.", - "DONE": "Done!", - "CONNECT_WIFI": "Please Connect to WiFi.", - "DOWNLOADING": "Downloading: ", - "CURRENTLY_EXTRACTING": "\nCurrently extracting:\n", - "KB_DOWNLOADED": "KB downloaded.", - "FILE_EXTRACTED": "file extracted.", - "FILES_EXTRACTED": "files extracted.", + "DOWNLOAD_FAILED": "Download Failed!", + "NOT_IMPLEMENTED": "Not Implemented Yet.", + "DONE": "Done!", + "CONNECT_WIFI": "Please Connect to WiFi.", + "DOWNLOADING": "Downloading: ", + "CURRENTLY_EXTRACTING": "\nCurrently extracting:\n", + "KB_DOWNLOADED": "KB downloaded.", + "FILE_EXTRACTED": "file extracted.", + "FILES_EXTRACTED": "files extracted.", "SCRIPTLIST": "Scriptlist", + "SETTINGS": "Settings", "LANGUAGE": "Language", "COLORS": "Colors", @@ -53,5 +54,18 @@ "B_FTP_EXIT": "Press B to exit from FTP.", "WIFI_NOT_ENABLED": "WiFi not enabled.", - "SCRIPTCREATOR": "Script Creator" + "SCRIPTCREATOR": "Script Creator", + + "CREDITS": "Credits", + "DEVELOPED_BY": "Developed by: Universal-Team.", + "MAIN_DEV": "Main Developer: VoltZ", + "CURRENT_VERSION": "Current version: ", + "MANY_THANKS": "Many Thanks to:", + "TRANSLATORS": "All our Translators", + "HELP_TRANSLATE": "- For helping translate Universal-Updater's strings.", + "HELP_OUT": "- For helping out by Universal-Updater.", + "SCRIPTCREATORS": "All Script Creators", + "CREATING_SCRIPTS": "- For creating Scripts for Universal-Updater.", + "SHOW_QR": "Click here to show the QR Code.", + "LINK": "Join our Discord: https://discord.gg/KDJCfGF" } diff --git a/source/download/download.cpp b/source/download/download.cpp index b109997..ed5486e 100644 --- a/source/download/download.cpp +++ b/source/download/download.cpp @@ -45,7 +45,7 @@ extern "C" { #include "utils/cia.h" } -#define USER_AGENT APP_TITLE "-" V_STRING +#define USER_AGENT APP_TITLE "-" VERSION_STRING static char* result_buf = NULL; static size_t result_sz = 0; diff --git a/source/gui.cpp b/source/gui.cpp index ce0ec7e..6451f5f 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -42,6 +42,7 @@ C3D_RenderTarget* bottom; C2D_TextBuf sizeBuf; std::stack> screens; +C2D_SpriteSheet sprites; bool currentScreen = false; extern bool isScriptSelected; @@ -64,6 +65,7 @@ Result Gui::init(void) C2D_Prepare(); top = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT); bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT); + sprites = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x"); sizeBuf = C2D_TextBufNew(4096); return 0; } @@ -72,6 +74,7 @@ Result Gui::init(void) void Gui::exit(void) { C2D_TextBufDelete(sizeBuf); + C2D_SpriteSheetFree(sprites); C2D_Fini(); C3D_Fini(); } @@ -91,6 +94,11 @@ void DisplayMsg(std::string text) { C3D_FrameEnd(0); } +void Gui::sprite(int key, int x, int y, float ScaleX, float ScaleY) +{ + C2D_DrawImageAt(C2D_SpriteSheetGetImage(sprites, key), x, y, 0.5f, NULL, ScaleX, ScaleY); +} + void Gui::DisplayWarnMsg(std::string Text) { Gui::clearTextBufs(); diff --git a/source/main.cpp b/source/main.cpp index 7b80fab..908c103 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -53,8 +53,8 @@ bool touching(touchPosition touch, Structs::ButtonPos button) { int main() { gfxInitDefault(); - Gui::init(); romfsInit(); + Gui::init(); sdmcInit(); cfguInit(); acInit(); diff --git a/source/screens/mainMenu.cpp b/source/screens/mainMenu.cpp index c9f59fb..e52c02a 100644 --- a/source/screens/mainMenu.cpp +++ b/source/screens/mainMenu.cpp @@ -36,7 +36,6 @@ #include "utils/config.hpp" -extern int mode; extern bool exiting; extern bool touching(touchPosition touch, Structs::ButtonPos button); extern bool checkWifiStatus(void); @@ -47,7 +46,7 @@ bool isTesting = false; void MainMenu::Draw(void) const { Gui::DrawTop(); Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, "Universal-Updater", 400); - Gui::DrawString(397-Gui::GetStringWidth(0.5f, VERSION_STRING), 237-Gui::GetStringHeight(0.5f, VERSION_STRING), 0.5f, Config::TxtColor, VERSION_STRING); + Gui::DrawString(397-Gui::GetStringWidth(0.5f, V_STRING), 237-Gui::GetStringHeight(0.5f, V_STRING), 0.5f, Config::TxtColor, V_STRING); Gui::DrawBottom(); for (int i = 0; i < 6; i++) { @@ -62,8 +61,8 @@ void MainMenu::Draw(void) const { Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("GET_SCRIPTS")))/2+150-70, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("GET_SCRIPTS"), 140); Gui::DrawString((320-Gui::GetStringWidth(0.6f, "TinyDB"))/2-150+70, mainButtons[2].y+10, 0.6f, Config::TxtColor, "TinyDB", 140); Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SCRIPTCREATOR")))/2+150-70, mainButtons[3].y+10, 0.6f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("LANGUAGE")))/2-150+70, mainButtons[4].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 140); - Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("COLORS")))/2+150-70, mainButtons[5].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("SETTINGS")))/2-150+70, mainButtons[4].y+10, 0.6f, Config::TxtColor, Lang::get("SETTINGS"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, "FTP"))/2+150-70, mainButtons[5].y+10, 0.6f, Config::TxtColor, "FTP", 140); } void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) { @@ -108,12 +107,12 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) { } break; case 4: - mode = 0; Gui::setScreen(std::make_unique()); break; case 5: - mode = 1; - Gui::setScreen(std::make_unique()); + if (checkWifiStatus() == true) { + Gui::setScreen(std::make_unique()); + } break; } } @@ -141,11 +140,11 @@ void MainMenu::Logic(u32 hDown, u32 hHeld, touchPosition touch) { Gui::setScreen(std::make_unique()); } } else if (touching(touch, mainButtons[4])) { - mode = 0; Gui::setScreen(std::make_unique()); } else if (touching(touch, mainButtons[5])) { - mode = 1; - Gui::setScreen(std::make_unique()); + if (checkWifiStatus() == true) { + Gui::setScreen(std::make_unique()); + } } } } \ No newline at end of file diff --git a/source/screens/scriptCreator.cpp b/source/screens/scriptCreator.cpp index 0ebeda0..182c193 100644 --- a/source/screens/scriptCreator.cpp +++ b/source/screens/scriptCreator.cpp @@ -33,8 +33,9 @@ // The to editing script. nlohmann::json editScript; -void ScriptCreator::openJson() { - FILE* file = fopen("sdmc:/3ds/Universal-Updater/Test.json", "r"); +void ScriptCreator::openJson(std::string fileName) { + std::string scriptFile = Config::ScriptPath + fileName; + FILE* file = fopen(scriptFile.c_str(), "r"); if(file) editScript = nlohmann::json::parse(file, nullptr, false); fclose(file); } @@ -55,37 +56,66 @@ void ScriptCreator::Draw(void) const { Gui::DrawTop(); Gui::DrawStringCentered(0, 2, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATOR"), 400); Gui::DrawBottom(); + + for (int i = 0; i < 2; i++) { + if (Selection == i) { + Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor); + } else { + Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor); + } + } + + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("NEW_SCRIPT")))/2, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("NEW_SCRIPT"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("EXISTING_SCRIPT")))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("EXISTING_SCRIPT"), 140); } // Testing purpose for now. ScriptCreator::ScriptCreator() { - openJson(); + openJson("Test.json"); } -void ScriptCreator::save() { - FILE* file = fopen("sdmc:/3ds/Universal-Updater/Test.json", "w"); +void ScriptCreator::save(std::string fileName) { + std::string scriptFile = Config::ScriptPath + fileName; + FILE* file = fopen(scriptFile.c_str(), "w"); if(file) fwrite(editScript.dump(1, '\t').c_str(), 1, editScript.dump(1, '\t').size(), file); fclose(file); } +// Importaant to make Scripts valid. +void ScriptCreator::setInfoStuff(void) { + // Get needed things. + const std::string &test = Input::getString("Enter the Title of the script.", 50); + const std::string &test2 = Input::getString("Enter the Author name of the script.", 50); + const std::string &test3 = Input::getString("Enter the short description of the script.", 80); + const std::string &test4 = Input::getString("Enter the long description of the script.", 300); + int scriptRevision = Input::getUint(99, "Enter the script revision."); + // Set the real JSON stuff. + setString("info", "title", test); + setString("info", "author", test2); + setString("info", "shortDesc", test3); + setString("info", "description", test4); + setInt("info", "version", 2); + setInt("info", "revision", scriptRevision); +} + + + void ScriptCreator::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (hDown & KEY_B) { - save(); + save("Test.json"); Gui::screenBack(); return; } - if (hDown & KEY_X) { - const std::string &test = Input::getString("Enter the Title of the Script.", 50); - const std::string &test2 = Input::getString("Enter the Author name of the Script.", 50); - const std::string &test3 = Input::getString("Enter the short description of the Script.", 80); - const std::string &test4 = Input::getString("Enter the long description of the Script.", 300); + if (hDown & KEY_UP) { + if(Selection == 1) Selection = 0; + } - setString("info", "title", test); - setString("info", "author", test2); - setString("info", "shortDesc", test3); - setString("info", "description", test4); - setInt("info", "version", 2); - setInt("info", "revision", 1); + if (hDown & KEY_DOWN) { + if(Selection == 0) Selection = 1; + } + + if (hDown & KEY_X) { + setInfoStuff(); } } \ No newline at end of file diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 7eda1e8..8887f0c 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -32,17 +32,37 @@ extern bool touching(touchPosition touch, Structs::ButtonPos button); -int mode; -int colorMode = 0; - void Settings::Draw(void) const { if (mode == 0) { - DrawLanguageSelection(); + DrawSubMenu(); } else if (mode == 1) { + DrawLanguageSelection(); + } else if (mode == 2) { DrawColorChanging(); + } else if (mode == 3) { + DrawCreditsScreen(); } } + +void Settings::DrawSubMenu(void) const { + Gui::DrawTop(); + Gui::DrawString((400-Gui::GetStringWidth(0.8f, "Universal-Updater"))/2, 2, 0.8f, Config::TxtColor, "Universal-Updater", 400); + Gui::DrawBottom(); + + for (int i = 0; i < 3; i++) { + if (Selection == i) { + Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::SelectedColor); + } else { + Gui::Draw_Rect(mainButtons[i].x, mainButtons[i].y, mainButtons[i].w, mainButtons[i].h, Config::UnselectedColor); + } + } + + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("LANGUAGE")))/2, mainButtons[0].y+10, 0.6f, Config::TxtColor, Lang::get("LANGUAGE"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("COLORS")))/2, mainButtons[1].y+10, 0.6f, Config::TxtColor, Lang::get("COLORS"), 140); + Gui::DrawString((320-Gui::GetStringWidth(0.6f, Lang::get("CREDITS")))/2, mainButtons[2].y+10, 0.6f, Config::TxtColor, Lang::get("CREDITS"), 140); +} + void Settings::DrawLanguageSelection(void) const { Gui::DrawTop(); Gui::DrawString((400-Gui::GetStringWidth(0.8f, Lang::get("SELECT_LANG")))/2, 2, 0.8f, Config::TxtColor, Lang::get("SELECT_LANG"), 400); @@ -138,6 +158,77 @@ void Settings::DrawColorChanging(void) const { } } +void Settings::DrawCreditsScreen(void) const { + if (DisplayMode == 1) { + Gui::DrawTop(); + std::string title = "Universal-Updater - "; + title += Lang::get("CREDITS"); + + Gui::DrawString((400-Gui::GetStringWidth(0.8f, title.c_str()))/2, 2, 0.8f, Config::TxtColor, title.c_str(), 400); + Gui::DrawString((400-Gui::GetStringWidth(0.8f, Lang::get("DEVELOPED_BY")))/2, 40, 0.8f, Config::TxtColor, Lang::get("DEVELOPED_BY"), 400); + Gui::DrawString((400-Gui::GetStringWidth(0.8f, Lang::get("MAIN_DEV")))/2, 70, 0.8f, Config::TxtColor, Lang::get("MAIN_DEV"), 400); + Gui::sprite(sprites_voltZ_idx, 150, 110); + std::string currentVersion = Lang::get("CURRENT_VERSION"); + currentVersion += V_STRING; + Gui::DrawString(395-Gui::GetStringWidth(0.72f, currentVersion), 215, 0.72f, Config::TxtColor, currentVersion, 400); + Gui::DrawBottom(); + Gui::DrawString((320-Gui::GetStringWidth(0.7f, Lang::get("MANY_THANKS")))/2, 2, 0.8f, Config::TxtColor, Lang::get("MANY_THANKS"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.7f, Lang::get("TRANSLATORS")))/2, 40, 0.7f, Config::TxtColor, Lang::get("TRANSLATORS"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.5f, Lang::get("HELP_TRANSLATE")))/2, 70, 0.5f, Config::TxtColor, Lang::get("HELP_TRANSLATE"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.7f, "Pk11"))/2, 100, 0.7f, Config::TxtColor, "Pk11", 320); + Gui::DrawString((320-Gui::GetStringWidth(0.5f, Lang::get("HELP_OUT")))/2, 130, 0.5f, Config::TxtColor, Lang::get("HELP_OUT"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.7f, Lang::get("SCRIPTCREATORS")))/2, 160, 0.7f, Config::TxtColor, Lang::get("SCRIPTCREATORS"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.5f, Lang::get("CREATING_SCRIPTS")))/2, 190, 0.5f, Config::TxtColor, Lang::get("CREATING_SCRIPTS"), 320); + Gui::DrawString((320-Gui::GetStringWidth(0.55, discordText ? Lang::get("SHOW_QR") : Lang::get("LINK")))/2, 217, 0.55, Config::TxtColor, discordText ? Lang::get("SHOW_QR") : Lang::get("LINK"), 320); + } else if (DisplayMode == 2) { + Gui::DrawTop(); + Gui::Draw_Rect(0, 0, 400, 240, C2D_Color32(0, 0, 0, 190)); + Gui::sprite(sprites_discord_idx, 115, 35); + Gui::DrawBottom(); + Gui::Draw_Rect(0, 0, 320, 240, C2D_Color32(0, 0, 0, 190)); + } +} + + +void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { + if (hDown & KEY_UP) { + if(Selection > 0) Selection--; + } + + if (hDown & KEY_DOWN) { + if(Selection < 2) Selection++; + } + + if (hDown & KEY_A) { + switch(Selection) { + case 0: + mode = 1; + break; + case 1: + mode = 2; + break; + case 2: + mode = 3; + break; + } + } + + if (hDown & KEY_TOUCH) { + if (touching(touch, mainButtons[0])) { + mode = 1; + } else if (touching(touch, mainButtons[1])) { + mode = 2; + } else if (touching(touch, mainButtons[2])) { + mode = 3; + } + } + + if (hDown & KEY_B) { + Gui::screenBack(); + return; + } +} + void Settings::LanguageSelection(u32 hDown, touchPosition touch) { if (hDown & KEY_TOUCH) { for (int language = 0; language < 10; language++) { @@ -150,11 +241,11 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) { } if (hDown & KEY_B) { - Gui::screenBack(); - return; + mode = 0; } } + void Settings::colorChanging(u32 hDown, touchPosition touch) { int red; int green; @@ -162,8 +253,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { if (hDown & KEY_B) { Config::save(); - Gui::screenBack(); - return; + mode = 0; } if (hDown & KEY_L || hDown & KEY_LEFT) { @@ -235,11 +325,38 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { } } +void Settings::CreditsLogic(u32 hDown, touchPosition touch) { + gspWaitForVBlank(); + if(delay > 0) { + delay--; + } else { + delay = 120; + discordText = !discordText; + } + if (DisplayMode == 1) { + if (hDown & KEY_TOUCH) { + if (touching(touch, barPos[0])) { + DisplayMode = 2; + } + } + if (hDown & KEY_B) { + mode = 0; + } + } else if (DisplayMode == 2) { + if (hDown & KEY_B) { + DisplayMode = 1; + } + } +} void Settings::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (mode == 0) { - LanguageSelection(hDown, touch); + SubMenuLogic(hDown, hHeld, touch); } else if (mode == 1) { + LanguageSelection(hDown, touch); + } else if (mode == 2) { colorChanging(hDown, touch); + } else if (mode == 3) { + CreditsLogic(hDown, touch); } } \ No newline at end of file