mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
Cleanup, C string -> std::string
This commit is contained in:
parent
19a77c2a85
commit
77b0382d0c
3 changed files with 14 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
#include <string>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "PICA/pica_vertex.hpp"
|
#include "PICA/pica_vertex.hpp"
|
||||||
|
@ -11,6 +12,7 @@ enum class RendererType : s8 {
|
||||||
// Todo: Auto = -1,
|
// Todo: Auto = -1,
|
||||||
Null = 0,
|
Null = 0,
|
||||||
OpenGL = 1,
|
OpenGL = 1,
|
||||||
|
Vulkan = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
class GPU;
|
class GPU;
|
||||||
|
@ -36,7 +38,7 @@ class Renderer {
|
||||||
|
|
||||||
static constexpr u32 vertexBufferSize = 0x10000;
|
static constexpr u32 vertexBufferSize = 0x10000;
|
||||||
static std::optional<RendererType> typeFromString(std::string inString);
|
static std::optional<RendererType> typeFromString(std::string inString);
|
||||||
static const char* typeToString(RendererType rendererType);
|
static std::string typeToString(RendererType rendererType);
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
virtual void display() = 0; // Display the 3DS screen contents to the window
|
virtual void display() = 0; // Display the 3DS screen contents to the window
|
||||||
|
|
|
@ -34,16 +34,14 @@ void EmulatorConfig::load(const std::filesystem::path& path) {
|
||||||
auto gpu = gpuResult.unwrap();
|
auto gpu = gpuResult.unwrap();
|
||||||
|
|
||||||
// Get renderer
|
// Get renderer
|
||||||
auto rendererResult = toml::expect<std::string>(gpu, "Renderer");
|
auto rendererName = toml::find_or<std::string>(gpu, "Renderer", "OpenGL");
|
||||||
if (rendererResult.is_ok()) {
|
auto configRendererType = Renderer::typeFromString(rendererName);
|
||||||
auto rendererName = rendererResult.unwrap();
|
|
||||||
if (auto configRendererType = Renderer::typeFromString(rendererName); configRendererType.has_value()) {
|
if (configRendererType.has_value()) {
|
||||||
rendererType = configRendererType.value();
|
rendererType = configRendererType.value();
|
||||||
} else {
|
|
||||||
Helpers::warn("Invalid renderer specified: %s\n", rendererName.c_str());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Helpers::warn("Renderer not specified: %s\n", rendererResult.unwrap_err().c_str());
|
Helpers::warn("Invalid renderer specified: %s\n", rendererName.c_str());
|
||||||
|
rendererType = RendererType::OpenGL;
|
||||||
}
|
}
|
||||||
|
|
||||||
shaderJitEnabled = toml::find_or<toml::boolean>(gpu, "EnableShaderJIT", false);
|
shaderJitEnabled = toml::find_or<toml::boolean>(gpu, "EnableShaderJIT", false);
|
||||||
|
@ -58,7 +56,7 @@ void EmulatorConfig::save(const std::filesystem::path& path) {
|
||||||
if (std::filesystem::exists(path, error)) {
|
if (std::filesystem::exists(path, error)) {
|
||||||
try {
|
try {
|
||||||
data = toml::parse<toml::preserve_comments>(path);
|
data = toml::parse<toml::preserve_comments>(path);
|
||||||
} catch (std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Helpers::warn("Exception trying to parse config file. Exception: %s\n", ex.what());
|
Helpers::warn("Exception trying to parse config file. Exception: %s\n", ex.what());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +67,8 @@ void EmulatorConfig::save(const std::filesystem::path& path) {
|
||||||
printf("Saving new configuration file %s\n", path.string().c_str());
|
printf("Saving new configuration file %s\n", path.string().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
data["GPU"]["Renderer"] = Renderer::typeToString(rendererType);
|
|
||||||
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
|
data["GPU"]["EnableShaderJIT"] = shaderJitEnabled;
|
||||||
|
data["GPU"]["Renderer"] = Renderer::typeToString(rendererType);
|
||||||
|
|
||||||
std::ofstream file(path, std::ios::out);
|
std::ofstream file(path, std::ios::out);
|
||||||
file << data;
|
file << data;
|
||||||
|
|
|
@ -17,10 +17,11 @@ std::optional<RendererType> Renderer::typeFromString(std::string inString) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Renderer::typeToString(RendererType rendererType) {
|
std::string Renderer::typeToString(RendererType rendererType) {
|
||||||
switch (rendererType) {
|
switch (rendererType) {
|
||||||
case RendererType::Null: return "null";
|
case RendererType::Null: return "null";
|
||||||
case RendererType::OpenGL: return "opengl";
|
case RendererType::OpenGL: return "opengl";
|
||||||
|
case RendererType::Vulkan: return "vk";
|
||||||
default: return "Invalid";
|
default: return "Invalid";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue