mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Make the progressbar color Customizable.
Scripts can have their own progressbar color as well.
This commit is contained in:
@@ -69,6 +69,9 @@ bool progressBarType = 0; // 0 = Download | 1 = Extract
|
||||
#define TIMEOPT CURLINFO_TOTAL_TIME_T
|
||||
#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000
|
||||
|
||||
extern u32 progressBar;
|
||||
extern bool isScriptSelected;
|
||||
|
||||
// following function is from
|
||||
// https://github.com/angelsl/libctrfgh/blob/master/curl_test/src/main.c
|
||||
static size_t handle_data(char* ptr, size_t size, size_t nmemb, void* userdata)
|
||||
@@ -702,11 +705,13 @@ void displayProgressBar() {
|
||||
|
||||
Gui::DrawStringCentered(0, 80, 0.6f, Config::TxtColor, str, 400);
|
||||
Gui::Draw_Rect(30, 120, 340, 30, BLACK);
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, WHITE);
|
||||
if (isScriptSelected == true) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, progressBar);
|
||||
} else {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)downloadNow/(float)downloadTotal) * 338.0f), 28, Config::progressbarColor);
|
||||
}
|
||||
Gui::DrawBottom();
|
||||
C3D_FrameEnd(0);
|
||||
|
||||
//DisplayMsg(str);
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +267,7 @@ u32 bgBottomColor;
|
||||
u32 TextColor;
|
||||
u32 selected;
|
||||
u32 unselected;
|
||||
u32 progressBar;
|
||||
|
||||
void loadColors(nlohmann::json &json) {
|
||||
u32 colorTemp;
|
||||
@@ -287,6 +288,9 @@ void loadColors(nlohmann::json &json) {
|
||||
|
||||
colorTemp = getColor(get(json, "info", "unselectedColor"));
|
||||
unselected = colorTemp == 0 ? Config::UnselectedColor : colorTemp;
|
||||
|
||||
colorTemp = getColor(get(json, "info", "progressbarColor"));
|
||||
progressBar = colorTemp == 0 ? Config::progressbarColor : colorTemp;
|
||||
}
|
||||
|
||||
ScriptList::ScriptList() {
|
||||
|
||||
+41
-27
@@ -102,24 +102,27 @@ void Settings::DrawColorChanging(void) const {
|
||||
} else if (colorMode == 5) {
|
||||
Gui::Draw_Rect(0, 40, 400, 45, Config::UnselectedColor);
|
||||
Gui::DrawStringCentered(0, 45, 0.7f, Config::TxtColor, Lang::get("UNSELECTED_COLOR"), 320);
|
||||
} else if (colorMode == 6) {
|
||||
Gui::Draw_Rect(31, 121, (int)(((float)100/(float)100) * 338.0f), 28, Config::progressbarColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Gui::DrawBottom();
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (colorMode == i) {
|
||||
Gui::Draw_Rect(25 + i * 25, 5, 16, 16, Config::SelectedColor);
|
||||
Gui::Draw_Rect(25 + i * 25, 5, 16, 16, C2D_Color32(140, 140, 140, 255));
|
||||
}
|
||||
}
|
||||
|
||||
Gui::DrawString(29 + 0 * 25, 5, 0.5f, Config::TxtColor, "1", 400);
|
||||
Gui::DrawString(29 + 1 * 25, 5, 0.5f, Config::TxtColor, "2", 400);
|
||||
Gui::DrawString(29 + 2 * 25, 5, 0.5f, Config::TxtColor, "3", 400);
|
||||
Gui::DrawString(29 + 3 * 25, 5, 0.5f, Config::TxtColor, "4", 400);
|
||||
Gui::DrawString(29 + 4 * 25, 5, 0.5f, Config::TxtColor, "5", 400);
|
||||
Gui::DrawString(29 + 5 * 25, 5, 0.5f, Config::TxtColor, "6", 400);
|
||||
Gui::DrawString(29 + 0 * 25, 5, 0.5f, WHITE, "1", 400);
|
||||
Gui::DrawString(29 + 1 * 25, 5, 0.5f, WHITE, "2", 400);
|
||||
Gui::DrawString(29 + 2 * 25, 5, 0.5f, WHITE, "3", 400);
|
||||
Gui::DrawString(29 + 3 * 25, 5, 0.5f, WHITE, "4", 400);
|
||||
Gui::DrawString(29 + 4 * 25, 5, 0.5f, WHITE, "5", 400);
|
||||
Gui::DrawString(29 + 5 * 25, 5, 0.5f, WHITE, "6", 400);
|
||||
Gui::DrawString(29 + 6 * 25, 5, 0.5f, WHITE, "7", 400);
|
||||
|
||||
Gui::Draw_Rect(buttons[0].x, buttons[0].y, 95, 41, C2D_Color32(255, 0, 0, 255));
|
||||
Gui::Draw_Rect(buttons[1].x, buttons[1].y, 95, 41, C2D_Color32(0, 255, 0, 255));
|
||||
@@ -127,34 +130,39 @@ void Settings::DrawColorChanging(void) const {
|
||||
|
||||
if (colorMode == 0) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("BAR_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color1, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color1, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color1, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color1, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color1, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color1, 0).c_str(), 400);
|
||||
} else if (colorMode == 1) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("TOP_BG_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color2, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color2, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color2, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color2, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color2, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color2, 0).c_str(), 400);
|
||||
} else if (colorMode == 2) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("BOTTOM_BG_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color3, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color3, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::Color3, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color3, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color3, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::Color3, 0).c_str(), 400);
|
||||
} else if (colorMode == 3) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("TEXT_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::TxtColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::TxtColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::TxtColor, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::TxtColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::TxtColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::TxtColor, 0).c_str(), 400);
|
||||
} else if (colorMode == 4) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("SELECTED_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::SelectedColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::SelectedColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::SelectedColor, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::SelectedColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::SelectedColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::SelectedColor, 0).c_str(), 400);
|
||||
} else if (colorMode == 5) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("UNSELECTED_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::UnselectedColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::UnselectedColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, Config::TxtColor, ColorHelper::getColorName(Config::UnselectedColor, 0).c_str(), 400);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::UnselectedColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::UnselectedColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::UnselectedColor, 0).c_str(), 400);
|
||||
} else if (colorMode == 6) {
|
||||
Gui::DrawStringCentered(0, 60, 0.7f, Config::TxtColor, Lang::get("PROGRESSBAR_COLOR"), 320);
|
||||
Gui::DrawString(40, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 2).c_str(), 400);
|
||||
Gui::DrawString(140, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 1).c_str(), 400);
|
||||
Gui::DrawString(245, 98, 0.7f, WHITE, ColorHelper::getColorName(Config::progressbarColor, 0).c_str(), 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +267,7 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
||||
}
|
||||
|
||||
if (hDown & KEY_R || hDown & KEY_RIGHT) {
|
||||
if(colorMode < 5) colorMode++;
|
||||
if(colorMode < 6) colorMode++;
|
||||
}
|
||||
|
||||
if (hDown & KEY_TOUCH) {
|
||||
@@ -279,6 +287,8 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
||||
Config::SelectedColor = RGBA8(red, ColorHelper::getColorValue(Config::SelectedColor, 1), ColorHelper::getColorValue(Config::SelectedColor, 0), 255);
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(red, ColorHelper::getColorValue(Config::UnselectedColor, 1), ColorHelper::getColorValue(Config::UnselectedColor, 0), 255);
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(red, ColorHelper::getColorValue(Config::progressbarColor, 1), ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,6 +309,8 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
||||
Config::SelectedColor = RGBA8(ColorHelper::getColorValue(Config::SelectedColor, 2), green, ColorHelper::getColorValue(Config::SelectedColor, 0), 255);
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(ColorHelper::getColorValue(Config::UnselectedColor, 2), green, ColorHelper::getColorValue(Config::UnselectedColor, 0), 255);
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), green, ColorHelper::getColorValue(Config::progressbarColor, 0), 255);
|
||||
}
|
||||
}
|
||||
} else if (touching(touch, buttons[2])) {
|
||||
@@ -317,6 +329,8 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) {
|
||||
Config::SelectedColor = RGBA8(ColorHelper::getColorValue(Config::SelectedColor, 2), ColorHelper::getColorValue(Config::SelectedColor, 1), blue, 255);
|
||||
} else if (colorMode == 5) {
|
||||
Config::UnselectedColor = RGBA8(ColorHelper::getColorValue(Config::UnselectedColor, 2), ColorHelper::getColorValue(Config::UnselectedColor, 1), blue, 255);
|
||||
} else if (colorMode == 6) {
|
||||
Config::progressbarColor = RGBA8(ColorHelper::getColorValue(Config::progressbarColor, 2), ColorHelper::getColorValue(Config::progressbarColor, 1), blue, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+72
-10
@@ -42,6 +42,7 @@ int Config::SelectedColor;
|
||||
int Config::UnselectedColor;
|
||||
int Config::viewMode;
|
||||
int Config::ColorKeys;
|
||||
int Config::progressbarColor;
|
||||
std::string Config::ScriptPath;
|
||||
nlohmann::json configJson;
|
||||
|
||||
@@ -49,16 +50,73 @@ void Config::load() {
|
||||
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "r");
|
||||
if(file) {
|
||||
configJson = nlohmann::json::parse(file, nullptr, false);
|
||||
Config::Color1 = getInt("BARCOLOR");
|
||||
Config::Color2 = getInt("TOPBGCOLOR");
|
||||
Config::Color3 = getInt("BOTTOMBGCOLOR");
|
||||
Config::TxtColor = getInt("TEXTCOLOR");
|
||||
Config::SelectedColor = getInt("SELECTEDCOLOR");
|
||||
Config::UnselectedColor = getInt("UNSELECTEDCOLOR");
|
||||
Config::ScriptPath = getString("SCRIPTPATH");
|
||||
Config::lang = getInt("LANGUAGE");
|
||||
Config::viewMode = getInt("VIEWMODE");
|
||||
Config::ColorKeys = getInt("COLORKEYS");
|
||||
|
||||
if(!configJson.contains("BARCOLOR")) {
|
||||
Config::Color1 = BarColor;
|
||||
} else {
|
||||
Config::Color1 = getInt("BARCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("TOPBGCOLOR")) {
|
||||
Config::Color2 = TopBGColor;
|
||||
} else {
|
||||
Config::Color2 = getInt("TOPBGCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("BOTTOMBGCOLOR")) {
|
||||
Config::Color3 = BottomBGColor;
|
||||
} else {
|
||||
Config::Color3 = getInt("BOTTOMBGCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("TEXTCOLOR")) {
|
||||
Config::TxtColor = WHITE;
|
||||
} else {
|
||||
Config::TxtColor = getInt("TEXTCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("UNSELECTEDCOLOR")) {
|
||||
Config::UnselectedColor = UnselectedColordefault;
|
||||
} else {
|
||||
Config::UnselectedColor = getInt("UNSELECTEDCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("SELECTEDCOLOR")) {
|
||||
Config::SelectedColor = SelectedColordefault;
|
||||
} else {
|
||||
Config::SelectedColor = getInt("SELECTEDCOLOR");
|
||||
}
|
||||
|
||||
if(!configJson.contains("SCRIPTPATH")) {
|
||||
Config::ScriptPath = SCRIPTS_PATH;
|
||||
} else {
|
||||
Config::ScriptPath = getString("SCRIPTPATH");
|
||||
}
|
||||
|
||||
if(!configJson.contains("LANGUAGE")) {
|
||||
Config::lang = 2;
|
||||
} else {
|
||||
Config::lang = getInt("LANGUAGE");
|
||||
}
|
||||
|
||||
if(!configJson.contains("VIEWMODE")) {
|
||||
Config::viewMode = 0;
|
||||
} else {
|
||||
Config::viewMode = getInt("VIEWMODE");
|
||||
}
|
||||
|
||||
if(!configJson.contains("COLORKEYS")) {
|
||||
Config::ColorKeys = C2D_Color32(0, 0, 200, 255);
|
||||
} else {
|
||||
Config::ColorKeys = getInt("COLORKEYS");
|
||||
}
|
||||
|
||||
if(!configJson.contains("PROGRESSBARCOLOR")) {
|
||||
Config::progressbarColor = WHITE;
|
||||
} else {
|
||||
Config::progressbarColor = getInt("PROGRESSBARCOLOR");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
} else {
|
||||
Config::Color1 = BarColor;
|
||||
@@ -71,6 +129,7 @@ void Config::load() {
|
||||
Config::lang = 2;
|
||||
Config::viewMode = 0;
|
||||
Config::ColorKeys = C2D_Color32(0, 0, 200, 255);
|
||||
Config::progressbarColor = WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +144,7 @@ void Config::save() {
|
||||
Config::setInt("LANGUAGE", Config::lang);
|
||||
Config::setInt("VIEWMODE", Config::viewMode);
|
||||
Config::setInt("COLORKEYS", Config::ColorKeys);
|
||||
Config::setInt("PROGRESSBARCOLOR", Config::progressbarColor);
|
||||
FILE* file = fopen("sdmc:/3ds/Universal-Updater/Settings.json", "w");
|
||||
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
||||
fclose(file);
|
||||
@@ -103,6 +163,8 @@ void Config::initializeNewConfig() {
|
||||
Config::setInt("LANGUAGE", 2);
|
||||
Config::setInt("VIEWMODE", 0);
|
||||
Config::setInt("COLORKEYS", C2D_Color32(0, 0, 200, 255));
|
||||
Config::setInt("PROGRESSBARCOLOR", WHITE);
|
||||
|
||||
if(file) fwrite(configJson.dump(1, '\t').c_str(), 1, configJson.dump(1, '\t').size(), file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user