diff options
Diffstat (limited to 'gui')
46 files changed, 3102 insertions, 0 deletions
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt new file mode 100644 index 0000000..1ae7a31 --- /dev/null +++ b/gui/CMakeLists.txt @@ -0,0 +1,59 @@ + + +# add_executable("app" +# "src/main.cpp" +# ) + +# target_link_libraries("app" PRIVATE +# "$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<CONFIG:Debug>>:gcov>" + +# "PkgConfig::gtkmm" +# "adwaitamm::adwaitamm" + +# "turns::core" +# "turns::lang" + +# "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--whole-archive>" +# "turns::ui" +# "turns::style" +# "$<$<CXX_COMPILER_ID:GNU,Clang>:-Wl,--no-whole-archive>" +# ) + +# target_add_glib_resources("app" +# PREFIX "/ch/arknet/Turns" +# UI_FILES "metainfo.xml" +# ) + +# set_target_properties("app" PROPERTIES +# OUTPUT_NAME "turns" +# ) + +# install(TARGETS "app" +# RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" +# ) + +# install(FILES +# "${CMAKE_CURRENT_SOURCE_DIR}/metainfo.xml" +# DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo" +# RENAME "ch.arknet.Turns.metainfo.xml" +# ) + +# configure_file("desktop.in" +# "turns.desktop" +# ) + +# install(FILES +# "${CMAKE_CURRENT_BINARY_DIR}/turns.desktop" +# DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" +# RENAME "ch.arknet.Turns.desktop" +# ) + +# configure_file("mime.xml" +# "turns.xml" +# ) + +# install(FILES +# "${CMAKE_CURRENT_BINARY_DIR}/turns.xml" +# DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages" +# RENAME "ch.arknet.Turns.xml" +# ) diff --git a/gui/desktop.in b/gui/desktop.in new file mode 100644 index 0000000..99c0307 --- /dev/null +++ b/gui/desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=Turns +Name[de]=Züge +GenericName=Turn Tracker +Icon=ch.arknet.Turns +StartupNotify=true +Exec=@CMAKE_INSTALL_FULL_BINDIR@/turns %u +Categories=Utility; +MimeType=text/x-turn-order;
\ No newline at end of file diff --git a/gui/lang/CMakeLists.txt b/gui/lang/CMakeLists.txt new file mode 100644 index 0000000..1842615 --- /dev/null +++ b/gui/lang/CMakeLists.txt @@ -0,0 +1,77 @@ +set(TRANSLATIONS + "de" + "de_CH" + "en" +) + +foreach(LANG IN LISTS TRANSLATIONS) + set(BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/${LANG}/LC_MESSAGES/turns.mo") + set(SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/po/${LANG}.po") + + list(APPEND TRANSLATION_BINARIES "${BINARY_FILE}") + + add_custom_command(OUTPUT "${BINARY_FILE}" + COMMAND "${GETTEXT_MSGFMT_EXECUTABLE}" + ARGS + "-o" + "${BINARY_FILE}" + "${SOURCE_FILE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS + "${SOURCE_FILE}" + COMMENT "Processing translation ${LANG}" + ) + + install(FILES "${BINARY_FILE}" + DESTINATION "${CMAKE_INSTALL_FULL_LOCALEDIR}/${LANG}/LC_MESSAGES" + ) +endforeach() + +add_custom_target("mofiles" DEPENDS ${TRANSLATION_BINARIES}) + +add_library("lang" INTERFACE) + +add_library("turns::lang" ALIAS "lang") + +if(TURNS_USE_INSTALLED_TRANSLATIONS) + target_compile_definitions("lang" INTERFACE + "LOCALEDIR=\"${CMAKE_INSTALL_FULL_LOCALEDIR}\"" + ) +else() + target_compile_definitions("lang" INTERFACE + "LOCALEDIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" + ) +endif() + +target_include_directories("lang" INTERFACE + "include" +) + +add_dependencies("lang" "mofiles") + +# Tests + +add_executable("lang-tests" + "tests/intl_test_init.cpp" + + "tests/messages.cpp" +) + +target_link_libraries("lang-tests" PRIVATE + "Catch2::Catch2WithMain" + "Intl::Intl" + + "turns::lang" +) + +target_compile_definitions("lang-tests" PRIVATE + "TESTLOCALEDIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" +) + +enable_coverage("lang-tests") + +target_link_options("lang-tests" PRIVATE + "$<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<CONFIG:Debug>>:--coverage>" +) + +catch_discover_tests("lang-tests")
\ No newline at end of file diff --git a/gui/lang/include/turns/lang/messages.hpp b/gui/lang/include/turns/lang/messages.hpp new file mode 100644 index 0000000..e57fce4 --- /dev/null +++ b/gui/lang/include/turns/lang/messages.hpp @@ -0,0 +1,49 @@ +#ifndef TURNS_LANG_MESSAGES_HPP +#define TURNS_LANG_MESSAGES_HPP + +namespace turns::lang +{ + auto constexpr static add_participant = "Add participant"; + auto constexpr static cancel = "Cancel"; + auto constexpr static clear = "_Clear"; + auto constexpr static delete_participant = "Delete participant"; + auto constexpr static disposition = "Disposition"; + auto constexpr static disposition_colors = "Disposition Colors"; + auto constexpr static edit_participant = "Edit participant"; + auto constexpr static end_turn_order = "End turn order"; + auto constexpr static finish = "Finish"; + auto constexpr static flow = "Flow"; + auto constexpr static friendly = "Friendly"; + auto constexpr static hostile = "Hostile"; + auto constexpr static main_menu = "Main Menu"; + auto constexpr static mark_as_defeated = "Mark as defeated"; + auto constexpr static name = "Name"; + auto constexpr static new_turn_order_file_name = "New turn order.trns"; + auto constexpr static next_participant = "Next participant"; + auto constexpr static no_active_turn_order = "No active turn order"; + auto constexpr static open = "_Open..."; + auto constexpr static preferences = "Preferences"; + auto constexpr static preferences_mnemonic = "_Preferences"; + auto constexpr static previous_participant = "Previous participant"; + auto constexpr static priority = "Priority"; + auto constexpr static priority_number = "Priority {}"; + auto constexpr static question_clear_turn_order = "Do you want to clear the turn order?"; + auto constexpr static quit = "_Quit"; + auto constexpr static reset = "Reset"; + auto constexpr static round_number = "Round {}"; + auto constexpr static save = "_Save"; + auto constexpr static save_as = "Save as..."; + auto constexpr static saving_failed_format = "Saving failed: {}"; + auto constexpr static secret = "Secret"; + auto constexpr static skip_defeated = "Skip defeated"; + auto constexpr static start_turn_order = "Start turn order"; + auto constexpr static stop = "Stop"; + auto constexpr static stop_and_clear = "Stop and clear"; + auto constexpr static stop_turn_order = "Stop turn order"; + auto constexpr static successfully_opened_format = "Successfully opened '{}'"; + auto constexpr static successfully_saved_format = "Successfully saved '{}'"; + auto constexpr static turns = "Turns"; + auto constexpr static turns_files = "Turns Files"; +} // namespace turns::lang + +#endif
\ No newline at end of file diff --git a/gui/lang/po/de.po b/gui/lang/po/de.po new file mode 100644 index 0000000..15c2d72 --- /dev/null +++ b/gui/lang/po/de.po @@ -0,0 +1,132 @@ +msgid "" +msgstr "" +"Project-Id-Version: turns 1.0.0\n" +"Last-Translator: Felix Morgner\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Add participant" +msgstr "Teilnehmer hinzufügen" + +msgid "Cancel" +msgstr "Abbrechen" + +msgid "_Clear" +msgstr "_Leeren" + +msgid "Disposition" +msgstr "Gesinnung" + +msgid "Disposition Colors" +msgstr "Gesinnungsfarben" + +msgid "Delete participant" +msgstr "Teilnehmer entfernen" + +msgid "Do you want to clear the turn order?" +msgstr "Möchten Sie die Zugreihenfolge leeren?" + +msgid "Edit participant" +msgstr "Teilnehmer bearbeiten" + +msgid "End turn order" +msgstr "Zugreihenfolge beenden" + +msgid "Finish" +msgstr "Abschließen" + +msgid "Flow" +msgstr "Ablaufsteuerung" + +msgid "Friendly" +msgstr "Freundlich" + +msgid "Hostile" +msgstr "Feindseelig" + +msgid "Main Menu" +msgstr "Hauptmenü" + +msgid "Mark as defeated" +msgstr "Als besiegt markieren" + +msgid "Name" +msgstr "Name" + +msgid "New turn order.trns" +msgstr "Neue Zugreihenfolge.trns" + +msgid "Next participant" +msgstr "Nächster Teilnehmer" + +msgid "No active turn order" +msgstr "Keine aktive Zugreihenfolge" + +msgid "_Open..." +msgstr "_Öffnen..." + +msgid "Preferences" +msgstr "Einstellungen" + +msgid "_Preferences" +msgstr "_Einstellungen" + +msgid "Previous participant" +msgstr "Vorhergehender Teilnehmer" + +msgid "Priority" +msgstr "Priorität" + +msgid "Priority {}" +msgstr "Priorität {}" + +msgid "_Quit" +msgstr "_Beenden" + +msgid "Reset" +msgstr "Zurücksetzen" + +msgid "Round {}" +msgstr "Runde {}" + +msgid "_Save" +msgstr "_Speichern" + +msgid "Save as..." +msgstr "Speichern unter..." + +msgid "Saving failed: {}" +msgstr "Speichern fehlgeschlagen: {}" + +msgid "Secret" +msgstr "Geheim" + +msgid "Skip defeated" +msgstr "Besiegte Teilnehmer überspringen" + +msgid "Start turn order" +msgstr "Zugreihenfolge starten" + +msgid "Stop" +msgstr "Stoppen" + +msgid "Stop and clear" +msgstr "Stoppen und leeren" + +msgid "Stop turn order" +msgstr "Zugreihenfolge Stoppen" + +msgid "Successfully opened '{}'" +msgstr "'{}' wurde erfolgreich geöffnet." + +msgid "Successfully saved '{}'" +msgstr "'{}' wurde erfolgreich gespeichert." + +msgid "Turns" +msgstr "Züge" + +msgid "Turns Files" +msgstr "Züge Dateien"
\ No newline at end of file diff --git a/gui/lang/po/de_CH.po b/gui/lang/po/de_CH.po new file mode 100644 index 0000000..e79f91e --- /dev/null +++ b/gui/lang/po/de_CH.po @@ -0,0 +1,12 @@ +msgid "" +msgstr "" +"Project-Id-Version: turns 1.0.0\n" +"Last-Translator: Felix Morgner\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Finish" +msgstr "Abschliessen" diff --git a/gui/lang/po/en.po b/gui/lang/po/en.po new file mode 100644 index 0000000..54df09f --- /dev/null +++ b/gui/lang/po/en.po @@ -0,0 +1,132 @@ +msgid "" +msgstr "" +"Project-Id-Version: turns 1.0.0\n" +"Last-Translator: Felix Morgner\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Add participant" +msgstr "Add participant" + +msgid "Cancel" +msgstr "Cancel" + +msgid "_Clear" +msgstr "_Clear" + +msgid "Disposition" +msgstr "Disposition" + +msgid "Disposition Colors" +msgstr "Disposition Colors" + +msgid "Delete participant" +msgstr "Delete participant" + +msgid "Do you want to clear the turn order?" +msgstr "Do you want to clear the turn order?" + +msgid "Edit participant" +msgstr "Edit participant" + +msgid "End turn order" +msgstr "End turn order" + +msgid "Finish" +msgstr "Finish" + +msgid "Flow" +msgstr "Flow" + +msgid "Friendly" +msgstr "Friendly" + +msgid "Hostile" +msgstr "Hostile" + +msgid "Main Menu" +msgstr "Main Menu" + +msgid "Mark as defeated" +msgstr "Mark as defeated" + +msgid "Name" +msgstr "Name" + +msgid "New turn order.trns" +msgstr "New turn order.trns" + +msgid "Next participant" +msgstr "Next participant" + +msgid "No active turn order" +msgstr "No active turn order" + +msgid "_Open..." +msgstr "_Open..." + +msgid "Preferences" +msgstr "Preferences" + +msgid "_Preferences" +msgstr "_Preferences" + +msgid "Previous participant" +msgstr "Previous participant" + +msgid "Priority" +msgstr "Priority" + +msgid "Priority {}" +msgstr "Priority {}" + +msgid "_Quit" +msgstr "_Quit" + +msgid "Reset" +msgstr "Reset" + +msgid "Round {}" +msgstr "Round {}" + +msgid "_Save" +msgstr "_Save" + +msgid "Save as..." +msgstr "Save as..." + +msgid "Saving failed: {}" +msgstr "Saving failed: {}" + +msgid "Secret" +msgstr "Secret" + +msgid "Skip defeated" +msgstr "Skip defeated" + +msgid "Start turn order" +msgstr "Start turn order" + +msgid "Stop" +msgstr "Stop" + +msgid "Stop and clear" +msgstr "Stop and clear" + +msgid "Stop turn order" +msgstr "Stop turn order" + +msgid "Successfully opened '{}'" +msgstr "Successfully opened '{}'" + +msgid "Successfully saved '{}'" +msgstr "Successfully saved '{}'." + +msgid "Turns" +msgstr "Turns" + +msgid "Turns Files" +msgstr "Turns Files" diff --git a/gui/lang/tests/intl_test_init.cpp b/gui/lang/tests/intl_test_init.cpp new file mode 100644 index 0000000..5438179 --- /dev/null +++ b/gui/lang/tests/intl_test_init.cpp @@ -0,0 +1,26 @@ +#include <catch2/reporters/catch_reporter_event_listener.hpp> +#include <catch2/reporters/catch_reporter_registrars.hpp> + +#include <libintl.h> + +#include <clocale> + +namespace turns::lang::tests +{ + + struct intl_test_init : Catch::EventListenerBase + { + using Catch::EventListenerBase::EventListenerBase; + + auto testRunStarting(Catch::TestRunInfo const &) -> void override + { + setlocale(LC_ALL, ""); + bindtextdomain("turns", TESTLOCALEDIR); + bind_textdomain_codeset("turns", "UTF-8"); + textdomain("turns"); + } + }; + + CATCH_REGISTER_LISTENER(intl_test_init); + +} // namespace turns::lang::tests
\ No newline at end of file diff --git a/gui/lang/tests/messages.cpp b/gui/lang/tests/messages.cpp new file mode 100644 index 0000000..cecb038 --- /dev/null +++ b/gui/lang/tests/messages.cpp @@ -0,0 +1,72 @@ +#include "turns/lang/messages.hpp" + +#include <catch2/catch_test_macros.hpp> +#include <catch2/generators/catch_generators.hpp> + +#include <libintl.h> + +#include <clocale> +#include <format> +#include <string> + +namespace turns::lang::tests +{ + + TEST_CASE("Translated messages") + { + auto locale = GENERATE("de_CH.UTF-8", "de_DE.UTF-8", "de_AT.UTF-8"); + setlocale(LC_ALL, locale); + + SECTION(std::format("Locale '{}'", locale)) + { + auto message = GENERATE(add_participant, + cancel, + clear, + delete_participant, + disposition, + disposition_colors, + edit_participant, + end_turn_order, + finish, + flow, + friendly, + hostile, + main_menu, + mark_as_defeated, + // a better solution is required to test the following entry: + // name, + new_turn_order_file_name, + next_participant, + no_active_turn_order, + open, + preferences, + preferences_mnemonic, + previous_participant, + priority, + priority_number, + question_clear_turn_order, + quit, + reset, + save, + save_as, + saving_failed_format, + secret, + skip_defeated, + start_turn_order, + stop, + stop_and_clear, + stop_turn_order, + successfully_opened_format, + successfully_saved_format, + round_number, + turns, + turns_files); + + SECTION(std::format("has a translation for '{}'", message)) + { + REQUIRE(std::string{gettext(message)} != message); + } + } + } + +} // namespace turns::lang::tests
\ No newline at end of file diff --git a/gui/metainfo.xml b/gui/metainfo.xml new file mode 100644 index 0000000..621c1ee --- /dev/null +++ b/gui/metainfo.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component type="desktop"> + <id>ch.arknet.Turns</id> + <metadata_license>CC-BY-SA-4.0</metadata_license> + <project_license>LGPL-2.1-or-later</project_license> + <name>Turns</name> + <name xml:lang="de">Züge</name> + <summary>A simple turn order tracker</summary> + <description> + <p> + Turns is an application to track turn order for TTRPGs like Dungeons and Dragons or Call of Cthulhu. + </p> + </description> + <releases> + <release version="1.0" date="2025-12-31" type="stable"> + <description> + <p>This is the first public release</p> + </description> + </release> + </releases> + <recommends> + <control>keyboard</control> + <control>pointing</control> + </recommends> + <content_rating type="oars-1.1" /> + <keywords> + <keyword>Role-playing Games</keyword> + <keyword>Tabletop Games</keyword> + </keywords> + <developer id="ch.arknet"> + <name>Felix Morgner</name> + </developer> + <update_contact>felix.morgner@gmail.com</update_contact> + <launchable type="desktop-id">ch.arknet.Turns.desktop</launchable> + <url type="homepage">https://source.arknet.ch/fmorgner/turns</url> + <url type="bugtracker">https://source.arknet.ch/fmorgner/turns/-/issues</url> + <url type="vcs-browser">https://source.arknet.ch/fmorgner/turns</url> +</component>
\ No newline at end of file diff --git a/gui/mime.xml b/gui/mime.xml new file mode 100644 index 0000000..92e0ff4 --- /dev/null +++ b/gui/mime.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> + <mime-type type="text/x-turn-order"> + <comment>Turn order file</comment> + <icon name="text-plain"/> + <glob-deleteall/> + <glob pattern="*.trns"/> + </mime-type> +</mime-info>
\ No newline at end of file diff --git a/gui/schemas/ch.arknet.Turns.gschema.xml b/gui/schemas/ch.arknet.Turns.gschema.xml new file mode 100644 index 0000000..d764608 --- /dev/null +++ b/gui/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/gui/settings.cpp b/gui/settings.cpp new file mode 100644 index 0000000..13cf665 --- /dev/null +++ b/gui/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_id); +#endif + } + +} // namespace turns::core diff --git a/gui/settings.hpp b/gui/settings.hpp new file mode 100644 index 0000000..304394d --- /dev/null +++ b/gui/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 settings::key + { + auto constexpr disposition_friendly_color = "disposition-color-friendly"; + auto constexpr disposition_hostile_color = "disposition-color-hostile"; + auto constexpr disposition_secret_color = "disposition-color-secret"; + auto constexpr skip_defeated = "skip-defeated"; + } // namespace settings::key + + auto get_settings() -> Glib::RefPtr<Gio::Settings>; +} // namespace turns::core + +#endif
\ No newline at end of file diff --git a/gui/src/main.cpp b/gui/src/main.cpp new file mode 100644 index 0000000..030aa0f --- /dev/null +++ b/gui/src/main.cpp @@ -0,0 +1,97 @@ +// #include "turns/core/init.hpp" +// #include "turns/core/settings.hpp" +// #include "turns/ui/init.hpp" +// #include "turns/ui/tracker.hpp" + +// #include <sigc++/adaptors/bind.h> +// #include <sigc++/functors/mem_fun.h> + +// #include <glibmm/refptr.h> + +// #include <giomm/application.h> +// #include <giomm/settings.h> + +// #include <gtkmm/application.h> +// #include <gtkmm/builder.h> +// #include <gtkmm/object.h> + +// #include <adwaitamm/aboutdialog.hpp> +// #include <adwaitamm/application.hpp> +// #include <adwaitamm/enums.hpp> +// #include <adwaitamm/stylemanager.hpp> + +// #include <libintl.h> |
