summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/CMakeLists.txt16
-rw-r--r--core/include/turns/core/settings.hpp21
-rw-r--r--core/schemas/ch.arknet.Turns.gschema.xml25
-rw-r--r--core/src/settings.cpp28
4 files changed, 90 insertions, 0 deletions
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index 9b6390c..5ec88e4 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -4,6 +4,7 @@ add_library("core"
"src/disposition.cpp"
"src/init.cpp"
"src/participant.cpp"
+ "src/settings.cpp"
"src/turn_order.cpp"
)
@@ -16,6 +17,12 @@ target_compile_options("core" PUBLIC
"$<$<CXX_COMPILER_ID:GNU,Clang>:-pedantic-errors>"
)
+if(NOT TURNS_USE_INSTALLED_SCHEMA_FILES)
+ target_compile_definitions("core" PUBLIC
+ "TURNS_SETTINGS_SCHEMA_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\""
+ )
+endif()
+
target_include_directories("core" PUBLIC
"include"
)
@@ -26,8 +33,17 @@ target_link_libraries("core" PUBLIC
"nlohmann_json::nlohmann_json"
)
+target_add_glib_schemas("core"
+ SCHEMA_DIR "schemas"
+)
+
enable_coverage("core")
+install(FILES
+ "schemas/ch.arknet.Turns.gschema.xml"
+ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/glib-2.0/schemas"
+)
+
# Tests
add_executable("core-tests"
diff --git a/core/include/turns/core/settings.hpp b/core/include/turns/core/settings.hpp
new file mode 100644
index 0000000..3e21a47
--- /dev/null
+++ b/core/include/turns/core/settings.hpp
@@ -0,0 +1,21 @@
+#ifndef TURNS_CORE_SETTINGS_HPP
+#define TURNS_CORE_SETTINGS_HPP
+
+#include <glibmm/refptr.h>
+
+#include <giomm/settings.h>
+
+namespace turns::core
+{
+ namespace key
+ {
+ auto constexpr disposition_friendly_color = "disposition-friendly-color";
+ auto constexpr disposition_hostile_color = "disposition-hostile-color";
+ auto constexpr disposition_secret_color = "disposition-secret-color";
+ auto constexpr skip_defeated = "skip-defeated";
+ } // namespace key
+
+ auto get_settings() -> Glib::RefPtr<Gio::Settings>;
+} // namespace turns::core
+
+#endif \ No newline at end of file
diff --git a/core/schemas/ch.arknet.Turns.gschema.xml b/core/schemas/ch.arknet.Turns.gschema.xml
new file mode 100644
index 0000000..d764608
--- /dev/null
+++ b/core/schemas/ch.arknet.Turns.gschema.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+ <schema path="/ch/arknet/Turns/" id="ch.arknet.Turns">
+ <key name="disposition-color-friendly" type="s">
+ <default>'#33d17a'</default>
+ <summary>Friendly Disposition Color</summary>
+ <description>The color used to shade friendly participants.</description>
+ </key>
+ <key name="disposition-color-hostile" type="s">
+ <default>'#e01b24'</default>
+ <summary>Hostile Disposition Color</summary>
+ <description>The color used to shade hostile participants.</description>
+ </key>
+ <key name="disposition-color-secret" type="s">
+ <default>'#9141ac'</default>
+ <summary>Secret Disposition Color</summary>
+ <description>The color used to shade secret participants.</description>
+ </key>
+ <key name="skip-defeated" type="b">
+ <default>false</default>
+ <summary>Skip Defeated Participants</summary>
+ <description>Whether or not defeated participants shall be skipped while stepping through the turn order.</description>
+ </key>
+ </schema>
+</schemalist> \ No newline at end of file
diff --git a/core/src/settings.cpp b/core/src/settings.cpp
new file mode 100644
index 0000000..c98e5eb
--- /dev/null
+++ b/core/src/settings.cpp
@@ -0,0 +1,28 @@
+#include "turns/core/settings.hpp"
+
+#include <glibmm/refptr.h>
+#include <glibmm/wrap.h>
+
+#include <giomm/settings.h>
+#include <giomm/settingsschemasource.h>
+
+#include <gio/gsettings.h>
+
+namespace turns::core
+{
+
+ auto get_settings() -> Glib::RefPtr<Gio::Settings>
+ {
+ auto constexpr schema_id = "ch.arknet.Turns";
+
+#ifdef TURNS_SETTINGS_SCHEMA_DIR
+ auto source = Gio::SettingsSchemaSource::create(TURNS_SETTINGS_SCHEMA_DIR "/glib-2.0/schemas", true);
+ auto schema = source->lookup(schema_id, true);
+ auto settings = g_settings_new_full(Glib::unwrap(schema), nullptr, nullptr);
+ return Glib::wrap(settings);
+#else
+ return Gio::Settings::create(schema);
+#endif
+ }
+
+} // namespace turns::core