mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-20 04:29:13 +12:00
Make battery stuff configurable
This commit is contained in:
parent
950e5da03a
commit
51b2b8eee5
9 changed files with 36 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "config.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
@ -57,6 +58,19 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
|
|||
shaderJitEnabled = toml::find_or<toml::boolean>(gpu, "EnableShaderJIT", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.contains("Battery")) {
|
||||
auto batteryResult = toml::expect<toml::value>(data.at("Battery"));
|
||||
if (batteryResult.is_ok()) {
|
||||
auto battery = batteryResult.unwrap();
|
||||
|
||||
chargerPlugged = toml::find_or<toml::boolean>(battery, "ChargerPlugged", true);
|
||||
batteryPercentage = toml::find_or<toml::integer>(battery, "BatteryPercentage", 3);
|
||||
|
||||
// Clamp battery % to [0, 100] to make sure it's a valid value
|
||||
batteryPercentage = std::clamp(batteryPercentage, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatorConfig::save(const std::filesystem::path& path) {
|
||||
|
@ -81,6 +95,9 @@ void EmulatorConfig::save(const std::filesystem::path& path) {
|
|||
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
|
||||
data["GPU"]["Renderer"] = std::string(Renderer::typeToString(rendererType));
|
||||
|
||||
data["Battery"]["ChargerPlugged"] = chargerPlugged;
|
||||
data["Battery"]["BatteryPercentage"] = batteryPercentage;
|
||||
|
||||
std::ofstream file(path, std::ios::out);
|
||||
file << data;
|
||||
file.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue