mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 13:19:20 +02:00
Every module unit now includes the standard headers it uses. Declarations reaching a unit only through an imported module's global module fragment are reachable but not visible, so ADL misses the free operators older libstdc++ declares beside a type - reproduced on ubuntu 24.04 (libstdc++ 13), where gl/vao.cpp could not compare vector iterators. Also drops a stale editor/editorSettings.hpp from the MSVC source list, which broke the Windows configure step, silences the deliberate include-in-purview warning in the glm wrapper, and removes GCC support: clang or MSVC only.
77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
module;
|
|
#include <ios>
|
|
#include <string>
|
|
#include "utilities/utilities_macros.h"
|
|
#include <cstdlib>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
|
|
module eu07.editor.editorsettings;
|
|
import eu07.utilities.logs;
|
|
import eu07.utilities.utilities;
|
|
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
|
|
|
|
editorSettings EditorSettings;
|
|
|
|
namespace
|
|
{
|
|
namespace fs = std::filesystem;
|
|
|
|
fs::path settings_path()
|
|
{
|
|
fs::path p = user_config_path("eu07_editor.ini");
|
|
return p.empty() ? fs::path("eu07_editor.ini") : p;
|
|
}
|
|
|
|
const char *scheme_to_string(editorSettings::movement_scheme scheme)
|
|
{
|
|
return scheme == editorSettings::movement_scheme::legacy ? "legacy" : "wsad";
|
|
}
|
|
}
|
|
|
|
bool editorSettings::load()
|
|
{
|
|
const fs::path path = settings_path();
|
|
std::error_code ec;
|
|
if (!fs::exists(path, ec))
|
|
return false;
|
|
|
|
std::ifstream stream(path);
|
|
if (!stream.is_open())
|
|
return false;
|
|
|
|
std::string key, value;
|
|
while (stream >> key >> value)
|
|
{
|
|
if (key == "movement_scheme")
|
|
m_movement = (value == "legacy") ? movement_scheme::legacy : movement_scheme::wsad;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool editorSettings::save()
|
|
{
|
|
const fs::path path = settings_path();
|
|
std::error_code ec;
|
|
fs::create_directories(path.parent_path(), ec);
|
|
|
|
std::ofstream stream(path, std::ios::trunc);
|
|
if (!stream.is_open())
|
|
{
|
|
ErrorLog("failed to save editor settings");
|
|
return false;
|
|
}
|
|
|
|
stream << "movement_scheme " << scheme_to_string(m_movement) << "\n";
|
|
return true;
|
|
}
|