mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-15 13:45:46 -04:00
Add Host/HostSettings
This commit is contained in:
@ -51,12 +51,14 @@ add_library(core
|
||||
gte.cpp
|
||||
gte.h
|
||||
gte_types.h
|
||||
host.h
|
||||
host_display.cpp
|
||||
host_display.h
|
||||
host_interface.cpp
|
||||
host_interface.h
|
||||
host_interface_progress_callback.cpp
|
||||
host_interface_progress_callback.h
|
||||
host_settings.h
|
||||
imgui_styles.cpp
|
||||
imgui_styles.h
|
||||
imgui_fullscreen.cpp
|
||||
|
@ -117,9 +117,11 @@
|
||||
<ClInclude Include="gpu_hw.h" />
|
||||
<ClInclude Include="gpu_hw_opengl.h" />
|
||||
<ClInclude Include="gte_types.h" />
|
||||
<ClInclude Include="host.h" />
|
||||
<ClInclude Include="host_display.h" />
|
||||
<ClInclude Include="host_interface.h" />
|
||||
<ClInclude Include="host_interface_progress_callback.h" />
|
||||
<ClInclude Include="host_settings.h" />
|
||||
<ClInclude Include="imgui_fullscreen.h" />
|
||||
<ClInclude Include="imgui_styles.h" />
|
||||
<ClInclude Include="interrupt_controller.h" />
|
||||
|
@ -126,5 +126,7 @@
|
||||
<ClInclude Include="imgui_fullscreen.h" />
|
||||
<ClInclude Include="imgui_styles.h" />
|
||||
<ClInclude Include="cheevos.h" />
|
||||
<ClInclude Include="host.h" />
|
||||
<ClInclude Include="host_settings.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
29
src/core/host.h
Normal file
29
src/core/host.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Host {
|
||||
/// Reads a file from the resources directory of the application.
|
||||
/// This may be outside of the "normal" filesystem on platforms such as Mac.
|
||||
std::optional<std::vector<u8>> ReadResourceFile(const char* filename);
|
||||
|
||||
/// Reads a resource file file from the resources directory as a string.
|
||||
std::optional<std::string> ReadResourceFileToString(const char* filename);
|
||||
|
||||
/// Adds OSD messages, duration is in seconds.
|
||||
void AddOSDMessage(std::string message, float duration = 2.0f);
|
||||
void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f);
|
||||
void AddFormattedOSDMessage(float duration, const char* format, ...);
|
||||
void AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...);
|
||||
void RemoveKeyedOSDMessage(std::string key);
|
||||
void ClearOSDMessages();
|
||||
|
||||
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
|
||||
void ReportErrorAsync(const std::string_view& title, const std::string_view& message);
|
||||
void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...);
|
||||
} // namespace Host
|
70
src/core/host_settings.h
Normal file
70
src/core/host_settings.h
Normal file
@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/types.h"
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class SettingsInterface;
|
||||
|
||||
namespace Host {
|
||||
// Base setting retrieval, bypasses layers.
|
||||
std::string GetBaseStringSettingValue(const char* section, const char* key, const char* default_value = "");
|
||||
bool GetBaseBoolSettingValue(const char* section, const char* key, bool default_value = false);
|
||||
s32 GetBaseIntSettingValue(const char* section, const char* key, s32 default_value = 0);
|
||||
u32 GetBaseUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
|
||||
float GetBaseFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
|
||||
double GetBaseDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
|
||||
std::vector<std::string> GetBaseStringListSetting(const char* section, const char* key);
|
||||
|
||||
// Allows the emucore to write settings back to the frontend. Use with care.
|
||||
// You should call CommitBaseSettingChanges() after finishing writing, or it may not be written to disk.
|
||||
void SetBaseBoolSettingValue(const char* section, const char* key, bool value);
|
||||
void SetBaseIntSettingValue(const char* section, const char* key, s32 value);
|
||||
void SetBaseUIntSettingValue(const char* section, const char* key, u32 value);
|
||||
void SetBaseFloatSettingValue(const char* section, const char* key, float value);
|
||||
void SetBaseStringSettingValue(const char* section, const char* key, const char* value);
|
||||
void SetBaseStringListSettingValue(const char* section, const char* key, const std::vector<std::string>& values);
|
||||
void DeleteBaseSettingValue(const char* section, const char* key);
|
||||
void CommitBaseSettingChanges();
|
||||
|
||||
// Settings access, thread-safe.
|
||||
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "");
|
||||
bool GetBoolSettingValue(const char* section, const char* key, bool default_value = false);
|
||||
int GetIntSettingValue(const char* section, const char* key, s32 default_value = 0);
|
||||
u32 GetUIntSettingValue(const char* section, const char* key, u32 default_value = 0);
|
||||
float GetFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
|
||||
double GetDoubleSettingValue(const char* section, const char* key, double default_value = 0.0);
|
||||
std::vector<std::string> GetStringListSetting(const char* section, const char* key);
|
||||
|
||||
/// Direct access to settings interface. Must hold the lock when calling GetSettingsInterface() and while using it.
|
||||
std::unique_lock<std::mutex> GetSettingsLock();
|
||||
SettingsInterface* GetSettingsInterface();
|
||||
|
||||
/// Returns the settings interface that controller bindings should be loaded from.
|
||||
/// If an input profile is being used, this will be the input layer, otherwise the layered interface.
|
||||
SettingsInterface* GetSettingsInterfaceForBindings();
|
||||
|
||||
namespace Internal {
|
||||
/// Retrieves the base settings layer. Must call with lock held.
|
||||
SettingsInterface* GetBaseSettingsLayer();
|
||||
|
||||
/// Retrieves the game settings layer, if present. Must call with lock held.
|
||||
SettingsInterface* GetGameSettingsLayer();
|
||||
|
||||
/// Retrieves the input settings layer, if present. Must call with lock held.
|
||||
SettingsInterface* GetInputSettingsLayer();
|
||||
|
||||
/// Sets the base settings layer. Should be called by the host at initialization time.
|
||||
void SetBaseSettingsLayer(SettingsInterface* sif);
|
||||
|
||||
/// Sets the game settings layer. Called by VMManager when the game changes.
|
||||
void SetGameSettingsLayer(SettingsInterface* sif);
|
||||
|
||||
/// Sets the input profile settings layer. Called by VMManager when the game changes.
|
||||
void SetInputSettingsLayer(SettingsInterface* sif);
|
||||
|
||||
/// Updates the variables in the EmuFolders namespace, reloading subsystems if needed. Must call with the lock held.
|
||||
void UpdateEmuFolders();
|
||||
} // namespace Internal
|
||||
} // namespace Host
|
Reference in New Issue
Block a user