diff --git a/source/gui.cpp b/source/gui.cpp index 91709e2..6951c8f 100644 --- a/source/gui.cpp +++ b/source/gui.cpp @@ -46,7 +46,8 @@ bool currentScreen = false; extern bool isScriptSelected; extern u32 barColor; -extern u32 bgColor; +extern u32 bgTopColor; +extern u32 bgBottomColor; extern u32 TextColor; // Clear Text. @@ -182,7 +183,7 @@ void Gui::DrawTop(void) { Gui::Draw_Rect(0, 210, 400, 30, Config::Color1); } else if (isScriptSelected == true) { Gui::Draw_Rect(0, 0, 400, 30, barColor); - Gui::Draw_Rect(0, 30, 400, 180, bgColor); + Gui::Draw_Rect(0, 30, 400, 180, bgTopColor); Gui::Draw_Rect(0, 210, 400, 30, barColor); } } @@ -195,7 +196,7 @@ void Gui::DrawBottom(void) { Gui::Draw_Rect(0, 210, 400, 30, Config::Color1); } else if (isScriptSelected == true) { Gui::Draw_Rect(0, 0, 400, 30, barColor); - Gui::Draw_Rect(0, 30, 400, 180, bgColor); + Gui::Draw_Rect(0, 30, 400, 180, bgBottomColor); Gui::Draw_Rect(0, 210, 400, 30, barColor); } } diff --git a/source/main.cpp b/source/main.cpp index 415f824..1b6a09d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -92,4 +92,4 @@ int main() romfsExit(); sdmcExit(); return 0; -} +} \ No newline at end of file diff --git a/source/screens/scriptlist.cpp b/source/screens/scriptlist.cpp index 27d1069..02fe38f 100644 --- a/source/screens/scriptlist.cpp +++ b/source/screens/scriptlist.cpp @@ -41,16 +41,17 @@ bool isScriptSelected = false; -// Information like Title and Description. +// Information like Title and Author. struct Info { std::string title; - std::string description; + std::string author; }; std::string choice; std::string currentFile; std::string selectedTitle; -std::string longDesc = ""; +std::string Desc = ""; +nlohmann::json jsonFile; Info parseInfo(std::string fileName) { FILE* file = fopen(fileName.c_str(), "rt"); @@ -64,7 +65,7 @@ Info parseInfo(std::string fileName) { Info info; info.title = get(json, "info", "title"); - info.description = get(json, "info", "description"); + info.author = get(json, "info", "author"); return info; } @@ -80,6 +81,13 @@ void checkForValidate(void) { } } +nlohmann::json openScriptFile() { + FILE* file = fopen(currentFile.c_str(), "rt"); + nlohmann::json jsonFile; + if(file) jsonFile = nlohmann::json::parse(file, nullptr, false); + fclose(file); + return jsonFile; +} // Objects like Release or Nightly. std::vector parseObjects(std::string fileName) { @@ -101,21 +109,9 @@ std::vector parseObjects(std::string fileName) { return objs; } -std::string longDescription() { - std::string out; - FILE* file = fopen(currentFile.c_str(), "rt"); - - if(!file) { - printf("File not found\n"); - fclose(file); - return ""; - } - - nlohmann::json json = nlohmann::json::parse(file, nullptr, false); - fclose(file); - - if (json.at("info").contains("longDescription")) out = json.at("info").at("longDescription"); - else if (json.at("info").contains("description")) out = json.at("info").at("description"); +std::string Description(nlohmann::json &json) { + std::string out = ""; + if (json.at("info").contains("description")) out = json.at("info").at("description"); else out = ""; return out; } @@ -128,10 +124,7 @@ Result createFile(const char * path) { return 0; } -void runFunctions(void) { - FILE* file = fopen(currentFile.c_str(), "rt"); - nlohmann::json json = nlohmann::json::parse(file, nullptr, false); - fclose(file); +void runFunctions(nlohmann::json &json) { for(int i=0;i<(int)json.at(choice).size();i++) { std::string type = json.at(choice).at(i).at("type"); @@ -234,27 +227,22 @@ u32 getColor(std::string colorString) { // Color listing! u32 barColor; -u32 bgColor; +u32 bgTopColor; +u32 bgBottomColor; u32 TextColor; u32 selected; u32 unselected; -void loadColors() { - FILE* file = fopen(currentFile.c_str(), "rt"); - if(!file) { - printf("File not found\n"); - fclose(file); - return; - } - nlohmann::json json = nlohmann::json::parse(file, nullptr, false); - fclose(file); - +void loadColors(nlohmann::json &json) { u32 colorTemp; colorTemp = getColor(get(json, "info", "barColor")); - barColor = colorTemp == 0 ? Config::Color2 : colorTemp; + barColor = colorTemp == 0 ? Config::Color1 : colorTemp; - colorTemp = getColor(get(json, "info", "bgColor")); - bgColor = colorTemp == 0 ? Config::Color3 : colorTemp; + colorTemp = getColor(get(json, "info", "bgTopColor")); + bgTopColor = colorTemp == 0 ? Config::Color2 : colorTemp; + + colorTemp = getColor(get(json, "info", "bgBottomColor")); + bgBottomColor = colorTemp == 0 ? Config::Color3 : colorTemp; colorTemp = getColor(get(json, "info", "textColor")); TextColor = colorTemp == 0 ? Config::TxtColor : colorTemp; @@ -283,7 +271,7 @@ void ScriptList::DrawList(void) const { Gui::DrawBottom(); for(int i=0;i