Alias filesystem namespace + attempt at fixing Windows compilation
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#include <execution>
|
#include <execution>
|
||||||
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
using namespace std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
GameList::GameList(const std::string& path) {
|
GameList::GameList(const std::string& path) {
|
||||||
if(!path.empty()) {
|
if(!path.empty()) {
|
||||||
@@ -16,7 +16,7 @@ GameList::GameList(const std::string& path) {
|
|||||||
json gameDb = json::parse(gameDbFile);
|
json gameDb = json::parse(gameDbFile);
|
||||||
std::vector<u8> rom{};
|
std::vector<u8> rom{};
|
||||||
|
|
||||||
for(const auto& p : directory_iterator{path}) {
|
for(const auto& p : fs::directory_iterator{path}) {
|
||||||
const auto filename = p.path().string();
|
const auto filename = p.path().string();
|
||||||
if(p.path().extension() == ".n64" || p.path().extension() == ".z64" || p.path().extension() == ".v64" ||
|
if(p.path().extension() == ".n64" || p.path().extension() == ".z64" || p.path().extension() == ".v64" ||
|
||||||
p.path().extension() == ".N64" || p.path().extension() == ".Z64" || p.path().extension() == ".V64") {
|
p.path().extension() == ".N64" || p.path().extension() == ".Z64" || p.path().extension() == ".V64") {
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
#include <utilities.hpp>
|
#include <utilities.hpp>
|
||||||
#include <nfd.h>
|
#include <nfd.h>
|
||||||
|
|
||||||
using namespace std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
Settings::Settings(n64::Core& core) {
|
Settings::Settings(n64::Core& core) {
|
||||||
auto modes = std::fstream::in | std::fstream::out;
|
auto modes = std::fstream::in | std::fstream::out;
|
||||||
auto fileExists = exists("resources/settings.json");
|
auto fileExists = fs::exists("resources/settings.json");
|
||||||
if(!fileExists) {
|
if(!fileExists) {
|
||||||
modes |= std::fstream::trunc;
|
modes |= std::fstream::trunc;
|
||||||
}
|
}
|
||||||
@@ -57,9 +57,9 @@ Settings::Settings(n64::Core& core) {
|
|||||||
|
|
||||||
Settings::~Settings() {
|
Settings::~Settings() {
|
||||||
auto modes = std::fstream::out;
|
auto modes = std::fstream::out;
|
||||||
auto fileExists = exists("resources/settings.json");
|
auto fileExists = fs::exists("resources/settings.json");
|
||||||
if(fileExists) {
|
if(fileExists) {
|
||||||
modes |= std::fstream::trunc;
|
modes = modes | std::fstream::trunc;
|
||||||
|
|
||||||
std::fstream settingsFile{"resources/settings.json", modes};
|
std::fstream settingsFile{"resources/settings.json", modes};
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ void Settings::RenderWidget(bool& show) {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Select...")) {
|
if(ImGui::Button("Select...")) {
|
||||||
nfdchar_t *outpath;
|
nfdchar_t *outpath;
|
||||||
nfdresult_t result = NFD_PickFolderN(&outpath, nullptr);
|
nfdresult_t result = NFD_PickFolder(&outpath, nullptr);
|
||||||
if (result == NFD_OKAY) {
|
if (result == NFD_OKAY) {
|
||||||
gamesDir = outpath;
|
gamesDir = outpath;
|
||||||
NFD_FreePath(outpath);
|
NFD_FreePath(outpath);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
VkInstance instance{};
|
VkInstance instance{};
|
||||||
|
using fs = std::filesystem;
|
||||||
|
|
||||||
Window::Window(n64::Core& core) : settings(core), gameList(settings.GetGamesDir()) {
|
Window::Window(n64::Core& core) : settings(core), gameList(settings.GetGamesDir()) {
|
||||||
InitSDL();
|
InitSDL();
|
||||||
@@ -175,7 +176,7 @@ void Window::LoadROM(n64::Core& core, const std::string &path) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(gameName.empty()) {
|
if(gameName.empty()) {
|
||||||
gameName = std::filesystem::path(path).stem().string();
|
gameName = fs::path(path).stem().string();
|
||||||
}
|
}
|
||||||
|
|
||||||
util::UpdateRPC(util::Playing, gameName);
|
util::UpdateRPC(util::Playing, gameName);
|
||||||
|
|||||||
@@ -18,4 +18,19 @@ inline bool CreateComboList(const char* label, int* index, const char** items, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define checkjsonentry(name, type, param1, param2, defaultVal) \
|
||||||
|
do { \
|
||||||
|
auto name##Entry = settings[param1][param2]; \
|
||||||
|
if(!name##Entry.empty()) { \
|
||||||
|
auto value = name##Entry.get<type>(); \
|
||||||
|
name = value; \
|
||||||
|
} else { \
|
||||||
|
settingsFile.clear(); \
|
||||||
|
settings[param1][param2] = defaultVal; \
|
||||||
|
settingsFile << settings; \
|
||||||
|
name = defaultVal; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
}
|
}
|
||||||
15
src/util.hpp
15
src/util.hpp
@@ -323,19 +323,4 @@ inline void UpdateRPC(State state, const std::string& game = "") {
|
|||||||
|
|
||||||
inline void ClearRPC() {
|
inline void ClearRPC() {
|
||||||
Discord_ClearPresence();
|
Discord_ClearPresence();
|
||||||
}
|
|
||||||
|
|
||||||
#define checkjsonentry(name, type, param1, param2, defaultVal) \
|
|
||||||
do { \
|
|
||||||
auto name##Entry = settings[param1][param2]; \
|
|
||||||
if(!name##Entry.empty()) { \
|
|
||||||
auto value = name##Entry.get<type>(); \
|
|
||||||
name = value; \
|
|
||||||
} else { \
|
|
||||||
settingsFile.clear(); \
|
|
||||||
settings[param1][param2] = defaultVal; \
|
|
||||||
settingsFile << settings; \
|
|
||||||
name = defaultVal; \
|
|
||||||
} \
|
|
||||||
} while(0)
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user