mirror of
https://github.com/DarkStore-3DS/DarkStore.git
synced 2026-07-03 00:39:02 +00:00
Fully rewrite config.
This commit is contained in:
+3
-1
@@ -31,6 +31,8 @@
|
||||
#include "gui.hpp"
|
||||
#include "sprites.h"
|
||||
|
||||
extern std::unique_ptr<Config> config;
|
||||
|
||||
namespace GFX {
|
||||
// Basic GUI.
|
||||
void DrawTop(void);
|
||||
@@ -41,7 +43,7 @@ namespace GFX {
|
||||
void DrawSprite(int img, int x, int y, float ScaleX = 1, float ScaleY = 1);
|
||||
void DrawSpriteBlend(int img, int x, int y, float ScaleX = 1, float ScaleY = 1);
|
||||
|
||||
void DrawButton(int x, int y, std::string ButtonText = "", u32 color = Config::Button);
|
||||
void DrawButton(int x, int y, std::string ButtonText = "", u32 color = config->buttonColor());
|
||||
}
|
||||
|
||||
#endif
|
||||
+97
-12
@@ -24,28 +24,113 @@
|
||||
* reasonable ways as different from the original version.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_HPP
|
||||
#define CONFIG_HPP
|
||||
#ifndef _UNIVERSAL_UPDATER_CONFIG_HPP
|
||||
#define _UNIVERSAL_UPDATER_CONFIG_HPP
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
#include <3ds.h>
|
||||
#include <string>
|
||||
|
||||
namespace Config {
|
||||
extern int LangPath, Color1, Color2, Color3, TxtColor, SelectedColor, UnselectedColor, viewMode, progressbarColor, autoboot, outdated, uptodate, notFound, future, Button, keyDelay;
|
||||
extern std::string lang, ScriptPath, MusicPath, StorePath, AutobootFile;
|
||||
extern bool Logging, UseBars, fading, progress;
|
||||
|
||||
void load();
|
||||
class Config {
|
||||
public:
|
||||
Config();
|
||||
void save();
|
||||
void initializeNewConfig();
|
||||
void initialize();
|
||||
|
||||
// Bar Color.
|
||||
u32 barColor() { return this->v_barColor; }
|
||||
void barColor(u32 v) { this->v_barColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Top BG Color.
|
||||
u32 topBG() { return this->v_topBG; }
|
||||
void topBG(u32 v) { this->v_topBG = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Bottom BG Color.
|
||||
u32 bottomBG() { return this->v_bottomBG; }
|
||||
void bottomBG(u32 v) { this->v_bottomBG = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Text Color.
|
||||
u32 textColor() { return this->v_textColor; }
|
||||
void textColor(u32 v) { this->v_textColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Button Color.
|
||||
u32 buttonColor() { return this->v_buttonColor; }
|
||||
void buttonColor(u32 v) { this->v_buttonColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Selected Color.
|
||||
u32 selectedColor() { return this->v_selectedColor; }
|
||||
void selectedColor(u32 v) { this->v_selectedColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Unselected Color.
|
||||
u32 unselectedColor() { return this->v_unselectedColor; }
|
||||
void unselectedColor(u32 v) { this->v_unselectedColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Script Path.
|
||||
std::string scriptPath() { return this->v_scriptPath; }
|
||||
void scriptPath(std::string v) { this->v_scriptPath = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Lang Path.
|
||||
int langPath() { return this->v_langPath; }
|
||||
void langPath(int v) { this->v_langPath = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// View Mode.
|
||||
int viewMode() { return this->v_viewMode; }
|
||||
void viewMode(int v) { this->v_viewMode = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Progressbar Color.
|
||||
u32 progressbarColor() { return this->v_progressbarColor; }
|
||||
void progressbarColor(u32 v) { this->v_progressbarColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Music Path.
|
||||
std::string musicPath() { return this->v_musicPath; }
|
||||
void musicPath(std::string v) { this->v_musicPath = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Logging.
|
||||
bool logging() { return this->v_logging; }
|
||||
void logging(bool v) { this->v_logging = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Use bars.
|
||||
bool useBars() { return this->v_useBars; }
|
||||
void useBars(bool v) { this->v_useBars = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Autoboot.
|
||||
int autoboot() { return this->v_autoboot; }
|
||||
void autoboot(int v) { this->v_autoboot = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Store Path.
|
||||
std::string storePath() { return this->v_storePath; }
|
||||
void storePath(std::string v) { this->v_storePath = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Autoboto file.
|
||||
std::string autobootFile() { return this->v_autobootFile; }
|
||||
void autobootFile(std::string v) { this->v_autobootFile = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Outdated Script Color.
|
||||
u32 outdatedColor() { return this->v_outdatedColor; }
|
||||
void outdatedColor(u32 v) { this->v_outdatedColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Uptodate Script Color.
|
||||
u32 uptodateColor() { return this->v_uptodateColor; }
|
||||
void uptodateColor(u32 v) { this->v_uptodateColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Not found Script Color.
|
||||
u32 notfoundColor() { return this->v_notfoundColor; }
|
||||
void notfoundColor(u32 v) { this->v_notfoundColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Future Script Color.
|
||||
u32 futureColor() { return this->v_futureColor; }
|
||||
void futureColor(u32 v) { this->v_futureColor = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Keydelay.
|
||||
int keyDelay() { return this->v_keyDelay; }
|
||||
void keyDelay(int v) { this->v_keyDelay = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Screen Fade.
|
||||
bool screenFade() { return this->v_screenFade; }
|
||||
void screenFade(bool v) { this->v_screenFade = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Progressbar Display.
|
||||
bool progressDisplay() { return this->v_progressDisplay; }
|
||||
void progressDisplay(bool v) { this->v_progressDisplay = v; if (!this->changesMade) this->changesMade = true; }
|
||||
// Language.
|
||||
std::string language() { return this->v_language; }
|
||||
void language(std::string v) { this->v_language = v; if (!this->changesMade) this->changesMade = true; }
|
||||
|
||||
// Mainly helper.
|
||||
bool getBool(const std::string &key);
|
||||
void setBool(const std::string &key, bool v);
|
||||
|
||||
int getInt(const std::string &key);
|
||||
void setInt(const std::string &key, int v);
|
||||
|
||||
std::string getString(const std::string &key);
|
||||
void setString(const std::string &key, const std::string &v);
|
||||
}
|
||||
private:
|
||||
nlohmann::json json; // Our private JSON file.
|
||||
bool changesMade = false;
|
||||
|
||||
// Color variables and more.
|
||||
u32 v_barColor, v_topBG, v_bottomBG, v_textColor, v_buttonColor, v_selectedColor, v_unselectedColor, v_progressbarColor,
|
||||
v_outdatedColor, v_uptodateColor, v_notfoundColor, v_futureColor;
|
||||
std::string v_scriptPath, v_musicPath, v_storePath, v_autobootFile, v_language;
|
||||
int v_langPath, v_viewMode, v_autoboot, v_keyDelay;
|
||||
bool v_logging, v_useBars, v_screenFade, v_progressDisplay;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user