mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Adds a persistent file used to store user settings (#2931)
* Enable the loading of settings * Add a user interface for changing the settings in the launcher Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -34,9 +34,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace::documentation { struct Documentation; }
|
||||
namespace openspace {
|
||||
|
||||
namespace openspace::configuration {
|
||||
namespace documentation { struct Documentation; }
|
||||
|
||||
struct Configuration {
|
||||
Configuration() = default;
|
||||
@@ -147,9 +147,10 @@ struct Configuration {
|
||||
|
||||
std::filesystem::path findConfiguration(const std::string& filename = "openspace.cfg");
|
||||
|
||||
Configuration loadConfigurationFromFile(const std::filesystem::path& filename,
|
||||
Configuration loadConfigurationFromFile(const std::filesystem::path& configurationFile,
|
||||
const std::filesystem::path& settingsFile,
|
||||
const glm::ivec2& primaryMonitorResolution);
|
||||
|
||||
} // namespace openspace::configuration
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___CONFIGURATION___H__
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace ghoul::fontrendering { class FontManager; }
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct Configuration;
|
||||
class Dashboard;
|
||||
class DeferredcasterManager;
|
||||
class DownloadManager;
|
||||
@@ -50,7 +51,6 @@ class SyncEngine;
|
||||
class TimeManager;
|
||||
class VersionChecker;
|
||||
struct WindowDelegate;
|
||||
namespace configuration { struct Configuration; }
|
||||
namespace interaction {
|
||||
struct JoystickInputStates;
|
||||
struct WebsocketInputStates;
|
||||
@@ -88,7 +88,7 @@ inline SyncEngine* syncEngine;
|
||||
inline TimeManager* timeManager;
|
||||
inline VersionChecker* versionChecker;
|
||||
inline WindowDelegate* windowDelegate;
|
||||
inline configuration::Configuration* configuration;
|
||||
inline Configuration* configuration;
|
||||
inline interaction::ActionManager* actionManager;
|
||||
inline interaction::InteractionMonitor* interactionMonitor;
|
||||
inline interaction::JoystickInputStates* joystickInputStates;
|
||||
|
||||
62
include/openspace/engine/settings.h
Normal file
62
include/openspace/engine/settings.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2023 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___SETTINGS___H__
|
||||
#define __OPENSPACE_CORE___SETTINGS___H__
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct Settings {
|
||||
auto operator<=>(const Settings&) const = default;
|
||||
|
||||
std::optional<bool> hasStartedBefore;
|
||||
|
||||
std::optional<std::string> configuration;
|
||||
std::optional<bool> rememberLastConfiguration;
|
||||
std::optional<std::string> profile;
|
||||
std::optional<bool> rememberLastProfile;
|
||||
std::optional<properties::Property::Visibility> visibility;
|
||||
std::optional<bool> bypassLauncher;
|
||||
|
||||
struct MRF {
|
||||
auto operator<=>(const MRF&) const = default;
|
||||
|
||||
std::optional<bool> isEnabled;
|
||||
std::optional<std::string> location;
|
||||
};
|
||||
MRF mrf;
|
||||
};
|
||||
|
||||
std::filesystem::path findSettings(const std::string& filename = "settings.json");
|
||||
|
||||
Settings loadSettings(const std::filesystem::path& filename = findSettings());
|
||||
void saveSettings(const Settings& settings, const std::filesystem::path& filename);
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___SETTINGS___H__
|
||||
Reference in New Issue
Block a user