mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-06 08:39:07 +00:00
Some changes. ;P
This commit is contained in:
+4
-3
@@ -46,7 +46,8 @@ bool currentScreen = false;
|
|||||||
extern bool isScriptSelected;
|
extern bool isScriptSelected;
|
||||||
|
|
||||||
extern u32 barColor;
|
extern u32 barColor;
|
||||||
extern u32 bgColor;
|
extern u32 bgTopColor;
|
||||||
|
extern u32 bgBottomColor;
|
||||||
extern u32 TextColor;
|
extern u32 TextColor;
|
||||||
|
|
||||||
// Clear Text.
|
// Clear Text.
|
||||||
@@ -182,7 +183,7 @@ void Gui::DrawTop(void) {
|
|||||||
Gui::Draw_Rect(0, 210, 400, 30, Config::Color1);
|
Gui::Draw_Rect(0, 210, 400, 30, Config::Color1);
|
||||||
} else if (isScriptSelected == true) {
|
} else if (isScriptSelected == true) {
|
||||||
Gui::Draw_Rect(0, 0, 400, 30, barColor);
|
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);
|
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);
|
Gui::Draw_Rect(0, 210, 400, 30, Config::Color1);
|
||||||
} else if (isScriptSelected == true) {
|
} else if (isScriptSelected == true) {
|
||||||
Gui::Draw_Rect(0, 0, 400, 30, barColor);
|
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);
|
Gui::Draw_Rect(0, 210, 400, 30, barColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,16 +41,17 @@
|
|||||||
|
|
||||||
bool isScriptSelected = false;
|
bool isScriptSelected = false;
|
||||||
|
|
||||||
// Information like Title and Description.
|
// Information like Title and Author.
|
||||||
struct Info {
|
struct Info {
|
||||||
std::string title;
|
std::string title;
|
||||||
std::string description;
|
std::string author;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string choice;
|
std::string choice;
|
||||||
std::string currentFile;
|
std::string currentFile;
|
||||||
std::string selectedTitle;
|
std::string selectedTitle;
|
||||||
std::string longDesc = "";
|
std::string Desc = "";
|
||||||
|
nlohmann::json jsonFile;
|
||||||
|
|
||||||
Info parseInfo(std::string fileName) {
|
Info parseInfo(std::string fileName) {
|
||||||
FILE* file = fopen(fileName.c_str(), "rt");
|
FILE* file = fopen(fileName.c_str(), "rt");
|
||||||
@@ -64,7 +65,7 @@ Info parseInfo(std::string fileName) {
|
|||||||
|
|
||||||
Info info;
|
Info info;
|
||||||
info.title = get(json, "info", "title");
|
info.title = get(json, "info", "title");
|
||||||
info.description = get(json, "info", "description");
|
info.author = get(json, "info", "author");
|
||||||
return info;
|
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.
|
// Objects like Release or Nightly.
|
||||||
std::vector<std::string> parseObjects(std::string fileName) {
|
std::vector<std::string> parseObjects(std::string fileName) {
|
||||||
@@ -101,21 +109,9 @@ std::vector<std::string> parseObjects(std::string fileName) {
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string longDescription() {
|
std::string Description(nlohmann::json &json) {
|
||||||
std::string out;
|
std::string out = "";
|
||||||
FILE* file = fopen(currentFile.c_str(), "rt");
|
if (json.at("info").contains("description")) out = json.at("info").at("description");
|
||||||
|
|
||||||
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");
|
|
||||||
else out = "";
|
else out = "";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -128,10 +124,7 @@ Result createFile(const char * path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void runFunctions(void) {
|
void runFunctions(nlohmann::json &json) {
|
||||||
FILE* file = fopen(currentFile.c_str(), "rt");
|
|
||||||
nlohmann::json json = nlohmann::json::parse(file, nullptr, false);
|
|
||||||
fclose(file);
|
|
||||||
for(int i=0;i<(int)json.at(choice).size();i++) {
|
for(int i=0;i<(int)json.at(choice).size();i++) {
|
||||||
std::string type = json.at(choice).at(i).at("type");
|
std::string type = json.at(choice).at(i).at("type");
|
||||||
|
|
||||||
@@ -234,27 +227,22 @@ u32 getColor(std::string colorString) {
|
|||||||
|
|
||||||
// Color listing!
|
// Color listing!
|
||||||
u32 barColor;
|
u32 barColor;
|
||||||
u32 bgColor;
|
u32 bgTopColor;
|
||||||
|
u32 bgBottomColor;
|
||||||
u32 TextColor;
|
u32 TextColor;
|
||||||
u32 selected;
|
u32 selected;
|
||||||
u32 unselected;
|
u32 unselected;
|
||||||
|
|
||||||
void loadColors() {
|
void loadColors(nlohmann::json &json) {
|
||||||
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);
|
|
||||||
|
|
||||||
u32 colorTemp;
|
u32 colorTemp;
|
||||||
colorTemp = getColor(get(json, "info", "barColor"));
|
colorTemp = getColor(get(json, "info", "barColor"));
|
||||||
barColor = colorTemp == 0 ? Config::Color2 : colorTemp;
|
barColor = colorTemp == 0 ? Config::Color1 : colorTemp;
|
||||||
|
|
||||||
colorTemp = getColor(get(json, "info", "bgColor"));
|
colorTemp = getColor(get(json, "info", "bgTopColor"));
|
||||||
bgColor = colorTemp == 0 ? Config::Color3 : colorTemp;
|
bgTopColor = colorTemp == 0 ? Config::Color2 : colorTemp;
|
||||||
|
|
||||||
|
colorTemp = getColor(get(json, "info", "bgBottomColor"));
|
||||||
|
bgBottomColor = colorTemp == 0 ? Config::Color3 : colorTemp;
|
||||||
|
|
||||||
colorTemp = getColor(get(json, "info", "textColor"));
|
colorTemp = getColor(get(json, "info", "textColor"));
|
||||||
TextColor = colorTemp == 0 ? Config::TxtColor : colorTemp;
|
TextColor = colorTemp == 0 ? Config::TxtColor : colorTemp;
|
||||||
@@ -283,7 +271,7 @@ void ScriptList::DrawList(void) const {
|
|||||||
Gui::DrawBottom();
|
Gui::DrawBottom();
|
||||||
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size();i++) {
|
for(int i=0;i<ENTRIES_PER_SCREEN && i<(int)fileInfo.size();i++) {
|
||||||
line1 = fileInfo[screenPos + i].title;
|
line1 = fileInfo[screenPos + i].title;
|
||||||
line2 = fileInfo[screenPos + i].description;
|
line2 = fileInfo[screenPos + i].author;
|
||||||
if(screenPos + i == selection) {
|
if(screenPos + i == selection) {
|
||||||
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::SelectedColor);
|
Gui::Draw_Rect(0, 40+(i*57), 320, 45, Config::SelectedColor);
|
||||||
} else {
|
} else {
|
||||||
@@ -303,13 +291,13 @@ void ScriptList::Draw(void) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLongDesc(void) {
|
void loadDesc(void) {
|
||||||
lines.clear();
|
lines.clear();
|
||||||
while(longDesc.find('\n') != longDesc.npos) {
|
while(Desc.find('\n') != Desc.npos) {
|
||||||
lines.push_back(longDesc.substr(0, longDesc.find('\n')));
|
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||||
longDesc = longDesc.substr(longDesc.find('\n')+1);
|
Desc = Desc.substr(Desc.find('\n')+1);
|
||||||
}
|
}
|
||||||
lines.push_back(longDesc.substr(0, longDesc.find('\n')));
|
lines.push_back(Desc.substr(0, Desc.find('\n')));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptList::DrawSingleObject(void) const {
|
void ScriptList::DrawSingleObject(void) const {
|
||||||
@@ -369,11 +357,12 @@ void ScriptList::ListSelection(u32 hDown, u32 hHeld) {
|
|||||||
if (fileInfo.size() != 0) {
|
if (fileInfo.size() != 0) {
|
||||||
currentFile = dirContents[selection].name;
|
currentFile = dirContents[selection].name;
|
||||||
selectedTitle = fileInfo[selection].title;
|
selectedTitle = fileInfo[selection].title;
|
||||||
longDesc = longDescription();
|
jsonFile = openScriptFile();
|
||||||
|
Desc = Description(jsonFile);
|
||||||
checkForValidate();
|
checkForValidate();
|
||||||
fileInfo2 = parseObjects(currentFile);
|
fileInfo2 = parseObjects(currentFile);
|
||||||
loadColors();
|
loadColors(jsonFile);
|
||||||
loadLongDesc();
|
loadDesc();
|
||||||
isScriptSelected = true;
|
isScriptSelected = true;
|
||||||
selection = 0;
|
selection = 0;
|
||||||
mode = 1;
|
mode = 1;
|
||||||
@@ -416,10 +405,20 @@ void ScriptList::SelectFunction(u32 hDown, u32 hHeld) {
|
|||||||
if (hDown & KEY_A) {
|
if (hDown & KEY_A) {
|
||||||
if (fileInfo2.size() != 0) {
|
if (fileInfo2.size() != 0) {
|
||||||
choice = fileInfo2[selection2];
|
choice = fileInfo2[selection2];
|
||||||
runFunctions();
|
runFunctions(jsonFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hDown & KEY_SELECT) {
|
||||||
|
Config::Color1 = barColor;
|
||||||
|
Config::Color2 = bgTopColor;
|
||||||
|
Config::Color3 = bgBottomColor;
|
||||||
|
Config::TxtColor = TextColor;
|
||||||
|
Config::SelectedColor = selected;
|
||||||
|
Config::UnselectedColor = unselected;
|
||||||
|
Config::saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
if (hDown & KEY_B) {
|
if (hDown & KEY_B) {
|
||||||
selection2 = 0;
|
selection2 = 0;
|
||||||
fileInfo2.clear();
|
fileInfo2.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user