From 5d8f799a1171f92054d4b45ba130cd7fdad0bd01 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 23 May 2025 14:04:27 +0200 Subject: app: prepare restructuring --- LICENSE.txt | 504 ------------------------- LICENSES/LGPL-2.1-only.txt | 176 +++++++++ app/CMakeLists.txt | 57 --- app/desktop.in | 10 - app/metainfo.xml | 38 -- app/mime.xml | 9 - app/schemas/ch.arknet.Turns.gschema.xml | 25 -- app/src/main.cpp | 97 ----- core/CMakeLists.txt | 87 ----- core/include/turns/core/json_ext.hpp | 43 --- core/include/turns/core/settings.hpp | 21 -- core/include/turns/core/turn_order_model.hpp | 102 ----- core/schemas/ch.arknet.Turns.gschema.xml | 25 -- core/src/settings.cpp | 28 -- core/src/turn_order_model.cpp | 312 --------------- core/tests/disposition.cpp | 32 -- core/tests/glib_test_init.cpp | 28 -- core/tests/participant.cpp | 310 --------------- core/tests/single_participant.trns | 11 - core/tests/turn_order_bugs.cpp | 40 -- core/tests/turn_order_model.cpp | 314 --------------- gui/CMakeLists.txt | 59 +++ gui/desktop.in | 10 + gui/lang/CMakeLists.txt | 77 ++++ gui/lang/include/turns/lang/messages.hpp | 49 +++ gui/lang/po/de.po | 132 +++++++ gui/lang/po/de_CH.po | 12 + gui/lang/po/en.po | 132 +++++++ gui/lang/tests/intl_test_init.cpp | 26 ++ gui/lang/tests/messages.cpp | 72 ++++ gui/metainfo.xml | 38 ++ gui/mime.xml | 9 + gui/schemas/ch.arknet.Turns.gschema.xml | 25 ++ gui/settings.cpp | 28 ++ gui/settings.hpp | 21 ++ gui/src/main.cpp | 97 +++++ gui/style/CMakeLists.txt | 18 + gui/style/style-dark.css | 32 ++ gui/style/style.css | 31 ++ gui/ui/CMakeLists.txt | 59 +++ gui/ui/include/turns/ui/fwd.hpp | 14 + gui/ui/include/turns/ui/init.hpp | 15 + gui/ui/include/turns/ui/participant_editor.hpp | 82 ++++ gui/ui/include/turns/ui/participant_row.hpp | 50 +++ gui/ui/include/turns/ui/preferences.hpp | 53 +++ gui/ui/include/turns/ui/template_widget.hpp | 67 ++++ gui/ui/include/turns/ui/tracker.hpp | 104 +++++ gui/ui/include/turns/ui/turn_order_view.hpp | 40 ++ gui/ui/src/init.cpp | 23 ++ gui/ui/src/participant_editor.cpp | 162 ++++++++ gui/ui/src/participant_editor.ui | 71 ++++ gui/ui/src/participant_row.cpp | 149 ++++++++ gui/ui/src/participant_row.ui | 89 +++++ gui/ui/src/preferences.cpp | 81 ++++ gui/ui/src/preferences.ui | 104 +++++ gui/ui/src/tracker.cpp | 255 +++++++++++++ gui/ui/src/tracker.ui | 153 ++++++++ gui/ui/src/tracker/actions.cpp | 125 ++++++ gui/ui/src/tracker/event_handlers.cpp | 105 ++++++ gui/ui/src/turn_order_view.cpp | 64 ++++ gui/ui/src/turn_order_view.ui | 38 ++ gui/ui/tests/gtk_test_init.cpp | 41 ++ gui/ui/tests/participant_editor.cpp | 150 ++++++++ gui/ui/tests/participant_row.cpp | 30 ++ gui/ui/tests/resources.cpp | 21 ++ gui/ui/tests/tracker.cpp | 79 ++++ gui/ui/ui.cmb | 10 + lang/CMakeLists.txt | 77 ---- lang/include/turns/lang/messages.hpp | 49 --- lang/po/de.po | 132 ------- lang/po/de_CH.po | 12 - lang/po/en.po | 132 ------- lang/tests/intl_test_init.cpp | 26 -- lang/tests/messages.cpp | 72 ---- lib/LICENSES/LGPL-2.1-only.txt | 176 --------- style/CMakeLists.txt | 18 - style/style-dark.css | 32 -- style/style.css | 31 -- ui/CMakeLists.txt | 59 --- ui/include/turns/ui/fwd.hpp | 14 - ui/include/turns/ui/init.hpp | 15 - ui/include/turns/ui/participant_editor.hpp | 82 ---- ui/include/turns/ui/participant_row.hpp | 50 --- ui/include/turns/ui/preferences.hpp | 53 --- ui/include/turns/ui/template_widget.hpp | 67 ---- ui/include/turns/ui/tracker.hpp | 104 ----- ui/include/turns/ui/turn_order_view.hpp | 40 -- ui/src/init.cpp | 23 -- ui/src/participant_editor.cpp | 162 -------- ui/src/participant_editor.ui | 71 ---- ui/src/participant_row.cpp | 149 -------- ui/src/participant_row.ui | 89 ----- ui/src/preferences.cpp | 81 ---- ui/src/preferences.ui | 104 ----- ui/src/tracker.cpp | 255 ------------- ui/src/tracker.ui | 153 -------- ui/src/tracker/actions.cpp | 125 ------ ui/src/tracker/event_handlers.cpp | 105 ------ ui/src/turn_order_view.cpp | 64 ---- ui/src/turn_order_view.ui | 38 -- ui/tests/gtk_test_init.cpp | 41 -- ui/tests/participant_editor.cpp | 150 -------- ui/tests/participant_row.cpp | 30 -- ui/tests/resources.cpp | 21 -- ui/tests/tracker.cpp | 79 ---- ui/ui.cmb | 10 - 106 files changed, 3278 insertions(+), 5084 deletions(-) delete mode 100644 LICENSE.txt create mode 100644 LICENSES/LGPL-2.1-only.txt delete mode 100644 app/CMakeLists.txt delete mode 100644 app/desktop.in delete mode 100644 app/metainfo.xml delete mode 100644 app/mime.xml delete mode 100644 app/schemas/ch.arknet.Turns.gschema.xml delete mode 100644 app/src/main.cpp delete mode 100644 core/CMakeLists.txt delete mode 100644 core/include/turns/core/json_ext.hpp delete mode 100644 core/include/turns/core/settings.hpp delete mode 100644 core/include/turns/core/turn_order_model.hpp delete mode 100644 core/schemas/ch.arknet.Turns.gschema.xml delete mode 100644 core/src/settings.cpp delete mode 100644 core/src/turn_order_model.cpp delete mode 100644 core/tests/disposition.cpp delete mode 100644 core/tests/glib_test_init.cpp delete mode 100644 core/tests/participant.cpp delete mode 100644 core/tests/single_participant.trns delete mode 100644 core/tests/turn_order_bugs.cpp delete mode 100644 core/tests/turn_order_model.cpp create mode 100644 gui/CMakeLists.txt create mode 100644 gui/desktop.in create mode 100644 gui/lang/CMakeLists.txt create mode 100644 gui/lang/include/turns/lang/messages.hpp create mode 100644 gui/lang/po/de.po create mode 100644 gui/lang/po/de_CH.po create mode 100644 gui/lang/po/en.po create mode 100644 gui/lang/tests/intl_test_init.cpp create mode 100644 gui/lang/tests/messages.cpp create mode 100644 gui/metainfo.xml create mode 100644 gui/mime.xml create mode 100644 gui/schemas/ch.arknet.Turns.gschema.xml create mode 100644 gui/settings.cpp create mode 100644 gui/settings.hpp create mode 100644 gui/src/main.cpp create mode 100644 gui/style/CMakeLists.txt create mode 100644 gui/style/style-dark.css create mode 100644 gui/style/style.css create mode 100644 gui/ui/CMakeLists.txt create mode 100644 gui/ui/include/turns/ui/fwd.hpp create mode 100644 gui/ui/include/turns/ui/init.hpp create mode 100644 gui/ui/include/turns/ui/participant_editor.hpp create mode 100644 gui/ui/include/turns/ui/participant_row.hpp create mode 100644 gui/ui/include/turns/ui/preferences.hpp create mode 100644 gui/ui/include/turns/ui/template_widget.hpp create mode 100644 gui/ui/include/turns/ui/tracker.hpp create mode 100644 gui/ui/include/turns/ui/turn_order_view.hpp create mode 100644 gui/ui/src/init.cpp create mode 100644 gui/ui/src/participant_editor.cpp create mode 100644 gui/ui/src/participant_editor.ui create mode 100644 gui/ui/src/participant_row.cpp create mode 100644 gui/ui/src/participant_row.ui create mode 100644 gui/ui/src/preferences.cpp create mode 100644 gui/ui/src/preferences.ui create mode 100644 gui/ui/src/tracker.cpp create mode 100644 gui/ui/src/tracker.ui create mode 100644 gui/ui/src/tracker/actions.cpp create mode 100644 gui/ui/src/tracker/event_handlers.cpp create mode 100644 gui/ui/src/turn_order_view.cpp create mode 100644 gui/ui/src/turn_order_view.ui create mode 100644 gui/ui/tests/gtk_test_init.cpp create mode 100644 gui/ui/tests/participant_editor.cpp create mode 100644 gui/ui/tests/participant_row.cpp create mode 100644 gui/ui/tests/resources.cpp create mode 100644 gui/ui/tests/tracker.cpp create mode 100644 gui/ui/ui.cmb delete mode 100644 lang/CMakeLists.txt delete mode 100644 lang/include/turns/lang/messages.hpp delete mode 100644 lang/po/de.po delete mode 100644 lang/po/de_CH.po delete mode 100644 lang/po/en.po delete mode 100644 lang/tests/intl_test_init.cpp delete mode 100644 lang/tests/messages.cpp delete mode 100644 lib/LICENSES/LGPL-2.1-only.txt delete mode 100644 style/CMakeLists.txt delete mode 100644 style/style-dark.css delete mode 100644 style/style.css delete mode 100644 ui/CMakeLists.txt delete mode 100644 ui/include/turns/ui/fwd.hpp delete mode 100644 ui/include/turns/ui/init.hpp delete mode 100644 ui/include/turns/ui/participant_editor.hpp delete mode 100644 ui/include/turns/ui/participant_row.hpp delete mode 100644 ui/include/turns/ui/preferences.hpp delete mode 100644 ui/include/turns/ui/template_widget.hpp delete mode 100644 ui/include/turns/ui/tracker.hpp delete mode 100644 ui/include/turns/ui/turn_order_view.hpp delete mode 100644 ui/src/init.cpp delete mode 100644 ui/src/participant_editor.cpp delete mode 100644 ui/src/participant_editor.ui delete mode 100644 ui/src/participant_row.cpp delete mode 100644 ui/src/participant_row.ui delete mode 100644 ui/src/preferences.cpp delete mode 100644 ui/src/preferences.ui delete mode 100644 ui/src/tracker.cpp delete mode 100644 ui/src/tracker.ui delete mode 100644 ui/src/tracker/actions.cpp delete mode 100644 ui/src/tracker/event_handlers.cpp delete mode 100644 ui/src/turn_order_view.cpp delete mode 100644 ui/src/turn_order_view.ui delete mode 100644 ui/tests/gtk_test_init.cpp delete mode 100644 ui/tests/participant_editor.cpp delete mode 100644 ui/tests/participant_row.cpp delete mode 100644 ui/tests/resources.cpp delete mode 100644 ui/tests/tracker.cpp delete mode 100644 ui/ui.cmb diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 8000a6f..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random - Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 0000000..c6487f4 --- /dev/null +++ b/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,176 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +GNU LESSER GENERAL PUBLIC LICENSE +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt deleted file mode 100644 index a231ec6..0000000 --- a/app/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -add_executable("app" - "src/main.cpp" -) - -target_link_libraries("app" PRIVATE - "$<$,$>:gcov>" - - "PkgConfig::gtkmm" - "adwaitamm::adwaitamm" - - "turns::core" - "turns::lang" - - "$<$:-Wl,--whole-archive>" - "turns::ui" - "turns::style" - "$<$:-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/app/desktop.in b/app/desktop.in deleted file mode 100644 index 99c0307..0000000 --- a/app/desktop.in +++ /dev/null @@ -1,10 +0,0 @@ -[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/app/metainfo.xml b/app/metainfo.xml deleted file mode 100644 index 621c1ee..0000000 --- a/app/metainfo.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - ch.arknet.Turns - CC-BY-SA-4.0 - LGPL-2.1-or-later - Turns - Züge - A simple turn order tracker - -

- Turns is an application to track turn order for TTRPGs like Dungeons and Dragons or Call of Cthulhu. -

-
- - - -

This is the first public release

-
-
-
- - keyboard - pointing - - - - Role-playing Games - Tabletop Games - - - Felix Morgner - - felix.morgner@gmail.com - ch.arknet.Turns.desktop - https://source.arknet.ch/fmorgner/turns - https://source.arknet.ch/fmorgner/turns/-/issues - https://source.arknet.ch/fmorgner/turns -
\ No newline at end of file diff --git a/app/mime.xml b/app/mime.xml deleted file mode 100644 index 92e0ff4..0000000 --- a/app/mime.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - Turn order file - - - - - \ No newline at end of file diff --git a/app/schemas/ch.arknet.Turns.gschema.xml b/app/schemas/ch.arknet.Turns.gschema.xml deleted file mode 100644 index d764608..0000000 --- a/app/schemas/ch.arknet.Turns.gschema.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - '#33d17a' - Friendly Disposition Color - The color used to shade friendly participants. - - - '#e01b24' - Hostile Disposition Color - The color used to shade hostile participants. - - - '#9141ac' - Secret Disposition Color - The color used to shade secret participants. - - - false - Skip Defeated Participants - Whether or not defeated participants shall be skipped while stepping through the turn order. - - - \ No newline at end of file diff --git a/app/src/main.cpp b/app/src/main.cpp deleted file mode 100644 index f179cf8..0000000 --- a/app/src/main.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "turns/core/init.hpp" -#include "turns/core/settings.hpp" -#include "turns/ui/init.hpp" -#include "turns/ui/tracker.hpp" - -#include -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -auto show_about(Glib::RefPtr app) -{ - auto active_window = app->get_active_window(); - auto dialog = Gtk::make_managed("/ch/arknet/Turns/metainfo.xml", ""); - dialog->present(active_window); -} - -auto main(int argc, char * argv[]) -> int -{ - setlocale(LC_ALL, ""); - bindtextdomain("turns", LOCALEDIR); - bind_textdomain_codeset("turns", "UTF-8"); - textdomain("turns"); - - auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN); - auto settings = turns::core::get_settings(); - - turns::core::register_types(); - - app->signal_startup().connect([app] { - turns::ui::register_types(); - - auto style_manager = Adwaita::StyleManager::get_default(); - style_manager->set_color_scheme(Adwaita::ColorScheme::PreferLight); - - app->add_action("quit", sigc::mem_fun(*app, &Adwaita::Application::quit)); - app->add_action("about", sigc::bind(&show_about, app)); - app->set_accel_for_action("app.quit", "q"); - app->set_accel_for_action("win.clear", "x"); - app->set_accel_for_action("win.next", "space"); - app->set_accel_for_action("win.previous", "BackSpace"); - app->set_accel_for_action("win.add_participant", "a"); - app->set_accel_for_action("win.open", "o"); - app->set_accel_for_action("win.preferences", "comma"); - app->set_accel_for_action("win.save", "s"); - app->set_accel_for_action("win.save-as", "s"); - }); - - app->signal_activate().connect([app, settings] { - auto window = new turns::ui::Tracker{app, settings}; - window->present(); - }); - - app->signal_open().connect([app, settings](auto files, auto) { - auto windows = app->get_windows(); - auto window = static_cast(nullptr); - - if (windows.empty()) - { - window = new turns::ui::Tracker{app, settings}; - } - else - { - window = dynamic_cast(windows[0]); - } - - window->present(); - window->load(files[0]); - }); - - app->signal_window_removed().connect([](auto window) { - auto tracker = dynamic_cast(window); - if (tracker) - { - delete tracker; - } - }); - - return app->run(argc, argv); -} \ No newline at end of file diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt deleted file mode 100644 index 788d80b..0000000 --- a/core/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -# Library - -add_library("core" - "src/disposition.cpp" - "src/init.cpp" - "src/participant.cpp" - "src/settings.cpp" - "src/turn_order_model.cpp" - - "src/turns-participant.cpp" -) - -add_library("turns::core" ALIAS "core") - -target_compile_options("core" PUBLIC - "$<$:-Wall>" - "$<$:-Wextra>" - "$<$:-Werror>" - "$<$:-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" -) - -target_link_libraries("core" PUBLIC - "PkgConfig::giomm" - "PkgConfig::glibmm" - "nlohmann_json::nlohmann_json" -) - -target_add_glib_schemas("core" - SCHEMA_DIR "schemas" -) - -target_add_glib_enums("core" - HEADER_OUTPUT_DIR "turns" - HEADER_TEMPLATE "include/turns/turns-enums.h.in" - SOURCE_TEMPLATE "src/turns-enums.c.in" - OUTPUT_NAME "turns-enums" - HEADERS - "include/turns/turns-disposition.h" -) - -enable_coverage("core") - -install(FILES - "schemas/ch.arknet.Turns.gschema.xml" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/glib-2.0/schemas" -) - -# Tests - -add_executable("core-tests" - "tests/glib_test_init.cpp" - - "tests/disposition.cpp" - "tests/participant.cpp" - "tests/turn_order_bugs.cpp" - "tests/turn_order_model.cpp" -) - -target_link_libraries("core-tests" PRIVATE - "Catch2::Catch2WithMain" - - "turns::core" -) - -target_link_options("core-tests" PRIVATE - "$<$,$>:--coverage>" -) - -file(GLOB_RECURSE TEST_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/tests" CONFIGURE_DEPENDS "*.trns") - -target_add_glib_resources("core-tests" - PREFIX "/ch/arknet/Turns/core-tests/" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests" - CSS_FILES ${TEST_FILES} -) - -catch_discover_tests("core-tests") \ No newline at end of file diff --git a/core/include/turns/core/json_ext.hpp b/core/include/turns/core/json_ext.hpp deleted file mode 100644 index 3eedb64..0000000 --- a/core/include/turns/core/json_ext.hpp +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TURNS_CORE_JSON_EXT_HPP -#define TURNS_CORE_JSON_EXT_HPP - -#include -#include - -#include - -#include - -NLOHMANN_JSON_NAMESPACE_BEGIN - -template -struct adl_serializer> -{ - static void to_json(json & to, Glib::Property const & from) - { - to = from.get_value(); - } - - static void from_json(json const & from, Glib::Property & to) - { - to = from.template get(); - } -}; - -template<> -struct adl_serializer -{ - static void to_json(json & to, Glib::ustring const & from) - { - to = static_cast(from); - } - - static void from_json(json const & from, Glib::ustring & to) - { - to = from.template get(); - } -}; - -NLOHMANN_JSON_NAMESPACE_END - -#endif \ No newline at end of file diff --git a/core/include/turns/core/settings.hpp b/core/include/turns/core/settings.hpp deleted file mode 100644 index 304394d..0000000 --- a/core/include/turns/core/settings.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef TURNS_CORE_SETTINGS_HPP -#define TURNS_CORE_SETTINGS_HPP - -#include - -#include - -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; -} // namespace turns::core - -#endif \ No newline at end of file diff --git a/core/include/turns/core/turn_order_model.hpp b/core/include/turns/core/turn_order_model.hpp deleted file mode 100644 index b7ce484..0000000 --- a/core/include/turns/core/turn_order_model.hpp +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef TURNS_CORE_TURN_ORDER_MODEL_HPP -#define TURNS_CORE_TURN_ORDER_MODEL_HPP - -#include "turns/core/fwd.hpp" - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace turns::core -{ - - struct TurnOderModel : Gio::ListModel, - Glib::Object - { - using value_type = Glib::RefPtr; - using container_type = std::vector; - using iterator = container_type::iterator; - using const_iterator = container_type::const_iterator; - - using active_participant_type = unsigned int; - using is_empty_type = bool; - using has_next_type = bool; - using has_previous_type = bool; - using is_running_type = bool; - using progress_type = double; - using round_number_type = unsigned int; - using skip_defeated_type = bool; - - // auto static constexpr invalid_participant_index = std::numeric_limits::max(); - // auto static constexpr invalid_round_number = std::numeric_limits::max(); - - /** Life-time */ - // TurnOderModel(); - - // auto static create() -> Glib::RefPtr; - // auto static create(nlohmann::json const & from) -> Glib::RefPtr; - - /** Properties */ - // auto is_empty() const -> Glib::PropertyProxy_ReadOnly; - auto has_next() const -> Glib::PropertyProxy_ReadOnly; - auto has_previous() const -> Glib::PropertyProxy_ReadOnly; - auto is_running() const -> Glib::PropertyProxy_ReadOnly; - auto progress() const -> Glib::PropertyProxy_ReadOnly; - auto round_number() const -> Glib::PropertyProxy_ReadOnly; - auto skip_defeated() -> Glib::PropertyProxy; - - /** Element Modifications */ - // auto add(Glib::ustring const & name, float priority, Disposition disposition) -> void; - // auto clear() -> void; - // auto remove(unsigned index) -> void; - - /** Turn Modification */ - auto next() -> void; - auto previous() -> void; - auto start() -> void; - auto stop() -> void; - - /** Serialization */ - auto load(nlohmann::json const & from) -> void; - auto serialize() -> nlohmann::json; - - private: - explicit TurnOderModel(nlohmann::json const & from); - - auto get_item_type_vfunc() -> GType override; - auto get_n_items_vfunc() -> unsigned override; - auto get_item_vfunc(unsigned position) -> void * override; - - /** Signal handlers */ - auto handle_priority_changed(value_type entry) -> void; - - /** Data management */ - auto find(value_type entry) const -> const_iterator; - auto insert(value_type entry) -> const_iterator; - - container_type m_data{}; - std::optional m_active{}; - - Glib::Property m_has_next{*this, "has-next", false}; - Glib::Property m_has_previous{*this, "has-previous", false}; - Glib::Property m_is_empty{*this, "is-empty", true}; - Glib::Property m_is_running{*this, "is-running", false}; - Glib::Property m_progress{*this, "progress", 0.0}; - Glib::Property m_round_number{*this, "round-number", invalid_round_number}; - Glib::Property m_skip_defeated{*this, "skip-defeated", false}; - }; - -} // 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 deleted file mode 100644 index d764608..0000000 --- a/core/schemas/ch.arknet.Turns.gschema.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - '#33d17a' - Friendly Disposition Color - The color used to shade friendly participants. - - - '#e01b24' - Hostile Disposition Color - The color used to shade hostile participants. - - - '#9141ac' - Secret Disposition Color - The color used to shade secret participants. - - - false - Skip Defeated Participants - Whether or not defeated participants shall be skipped while stepping through the turn order. - - - \ No newline at end of file diff --git a/core/src/settings.cpp b/core/src/settings.cpp deleted file mode 100644 index 13cf665..0000000 --- a/core/src/settings.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "turns/core/settings.hpp" - -#include -#include - -#include -#include - -#include - -namespace turns::core -{ - - auto get_settings() -> Glib::RefPtr - { - 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/core/src/turn_order_model.cpp b/core/src/turn_order_model.cpp deleted file mode 100644 index e430fed..0000000 --- a/core/src/turn_order_model.cpp +++ /dev/null @@ -1,312 +0,0 @@ -#include "turns/core/turn_order_model.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/json_ext.hpp" -#include "turns/core/participant.hpp" - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace std::placeholders; - -namespace turns::core -{ - - namespace - { - auto constexpr comparator = [](auto lhs, auto rhs) { - return *lhs > *rhs; - }; - } // namespace - - /** Construction */ - - TurnOderModel::TurnOderModel() - : Glib::ObjectBase{typeid(TurnOderModel)} - , Gio::ListModel{} - { - } - - TurnOderModel::TurnOderModel(nlohmann::json const & from) - : TurnOderModel{} - { - load(from); - } - - auto TurnOderModel::create() -> Glib::RefPtr - { - return Glib::make_refptr_for_instance(new TurnOderModel{}); - } - - auto TurnOderModel::create(nlohmann::json const & from) -> Glib::RefPtr - { - return Glib::make_refptr_for_instance(new TurnOderModel{from}); - } - - /** Queries */ - - auto TurnOderModel::is_empty() const -> Glib::PropertyProxy_ReadOnly - { - return m_is_empty.get_proxy(); - } - - auto TurnOderModel::has_next() const -> Glib::PropertyProxy_ReadOnly - { - return m_has_next.get_proxy(); - } - - auto TurnOderModel::has_previous() const -> Glib::PropertyProxy_ReadOnly - { - return m_has_previous.get_proxy(); - } - - auto TurnOderModel::is_running() const -> Glib::PropertyProxy_ReadOnly - { - return m_is_running.get_proxy(); - } - - auto TurnOderModel::progress() const -> Glib::PropertyProxy_ReadOnly - { - return m_progress.get_proxy(); - } - - auto TurnOderModel::round_number() const -> Glib::PropertyProxy_ReadOnly - { - return m_round_number.get_proxy(); - } - - auto TurnOderModel::skip_defeated() -> Glib::PropertyProxy - { - return m_skip_defeated.get_proxy(); - } - - /** Modifiers */ - - auto TurnOderModel::add(Glib::ustring const & name, float priority, Disposition disposition) -> void - { - auto entry = Participant::create(name, priority, disposition); - entry->property_priority().signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &TurnOderModel::handle_priority_changed), entry)); - auto position = std::distance(m_data.cbegin(), insert(entry)); - items_changed(position, 0, 1); - - if (get_n_items() == 1) - { - m_is_empty = false; - m_has_next = true; - } - } - - auto TurnOderModel::clear() -> void - { - m_is_running = false; - m_is_empty = true; - m_has_next = false; - m_has_previous = false; - m_active.reset(); - m_round_number = invalid_round_number; - m_progress = 0; - - auto old_size = get_n_items(); - m_data.clear(); - items_changed(0, old_size, 0); - } - - auto TurnOderModel::next() -> void - { - auto old_active = *m_active; - m_active = m_active.transform([this](auto index) { return (index + 1) % get_n_items(); }); - - m_has_previous = true; - m_data[old_active]->property_is_active() = false; - m_data[*m_active]->property_is_active() = true; - - m_progress = (static_cast(*m_active) + 1) / get_n_items(); - - if (m_active == 0) - { - m_round_number = m_round_number + 1; - } - } - - auto TurnOderModel::previous() -> void - { - if (!(m_has_previous && m_is_running)) - { - return; - } - - auto old_active = *m_active; - m_active = m_active.transform([this](auto index) { return index ? index - 1 : get_n_items() - 1; }); - - m_has_previous = m_round_number > 0 || m_active > 0; - m_data[old_active]->property_is_active() = false; - m_data[*m_active]->property_is_active() = true; - - m_progress = (static_cast(*m_active) + 1) / get_n_items(); - - if (m_active == 0 && m_round_number > 0) - { - m_round_number = m_round_number - 1; - } - } - - auto TurnOderModel::remove(unsigned index) -> void - { - if (index >= get_n_items()) - { - return; - } - - auto position = m_data.begin() + index; - m_data.erase(position); - items_changed(index, 1, 0); - if (get_n_items() == 0) - { - m_is_empty = true; - m_is_running = false; - m_has_next = false; - } - } - - auto TurnOderModel::start() -> void - { - if (!m_active) - { - m_active = 0; - m_data[*m_active]->property_is_active() = true; - } - if (m_round_number == invalid_round_number) - { - m_round_number = 0; - } - m_is_running = true; - - m_progress = (static_cast(*m_active) + 1) / get_n_items(); - } - - auto TurnOderModel::stop() -> void - { - m_is_running = false; - m_progress = 0; - } - - /** Serialization */ - auto TurnOderModel::load(nlohmann::json const & from) -> void - { - auto old_size = get_n_items(); - - this->freeze_notify(); - - m_round_number = from.value("round", invalid_round_number); - - m_data.clear(); - auto participants = from.value("participants", std::vector{}); - auto factory = [](auto s) { - return Participant::create(s); - }; - auto inserter = std::bind(&TurnOderModel::insert, this, _1); - std::ranges::for_each(participants | std::views::transform(factory), inserter); - - auto active = std::ranges::find_if(m_data, [](auto participant) { return participant->property_is_active(); }); - if (active != std::ranges::end(m_data)) - { - m_active = std::ranges::distance(std::ranges::begin(m_data), active); - } - - m_is_empty = m_data.empty(); - m_has_next = !m_is_empty; - m_has_previous = m_round_number > 0 || m_active > 0; - - this->thaw_notify(); - - items_changed(0, old_size, get_n_items()); - } - - auto TurnOderModel::serialize() -> nlohmann::json - { - auto serialized = nlohmann::json{}; - if (m_round_number != invalid_round_number) - { - serialized["round"] = m_round_number; - } - serialized["participants"] = m_data | std::views::transform([](auto const & p) { return p->serialize(); }) | std::ranges::to(); - ; - return serialized; - } - - /** ListModel implementation */ - - auto TurnOderModel::get_item_type_vfunc() -> GType - { - return Participant::get_type(); - } - - auto TurnOderModel::get_n_items_vfunc() -> unsigned - { - return m_data.size(); - } - - auto TurnOderModel::get_item_vfunc(unsigned position) -> void * - { - if (position >= get_n_items()) - { - return nullptr; - } - auto item = m_data[position]; - item->reference(); - return Glib::unwrap(item); - } - - /** Signal handlers */ - - auto TurnOderModel::handle_priority_changed(value_type entry) -> void - { - auto original_position = find(entry); - auto original_index = distance(m_data.cbegin(), original_position); - auto target_position = std::ranges::upper_bound(m_data, entry, comparator); - if (original_position == target_position) - { - return; - } - - m_data.erase(original_position); - auto inserted_position = insert(entry); - items_changed(0, get_n_items(), get_n_items()); - if (m_active == original_index) - { - m_active = distance(m_data.cbegin(), inserted_position); - m_has_previous = m_round_number > 0 || m_active > 0; - } - } - - /** Data management */ - - auto TurnOderModel::find(value_type entry) const -> const_iterator - { - return std::ranges::find(m_data, entry); - } - - auto TurnOderModel::insert(value_type entry) -> const_iterator - { - return m_data.insert(std::ranges::upper_bound(m_data, entry, comparator), entry); - } - -} // namespace turns::core \ No newline at end of file diff --git a/core/tests/disposition.cpp b/core/tests/disposition.cpp deleted file mode 100644 index fadf476..0000000 --- a/core/tests/disposition.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "turns/core/disposition.hpp" - -#include -#include - -#include -#include - -#include -#include -#include -#include - -namespace turns::core::tests -{ - - TEST_CASE("to_presentation_name returns the correct string for the current language", "[disposition]") - { - auto [value, name] = GENERATE(std::pair{Disposition::Neutral, Glib::ustring{_("Neutral")}}, - std::pair{Disposition::Friendly, Glib::ustring{_("Friendly")}}, - std::pair{Disposition::Hostile, Glib::ustring{_("Hostile")}}, - std::pair{Disposition::Secret, Glib::ustring{_("Secret")}}, - std::pair{static_cast(std::numeric_limits>::max()), - Glib::ustring{_("Unknown disposition value")}}); - - SECTION(std::format("the presentation name for '{}' is '{}'", static_cast>(value), name.c_str())) - { - REQUIRE(presentation_name_for(value) == name); - } - } - -} // namespace turns::core::tests \ No newline at end of file diff --git a/core/tests/glib_test_init.cpp b/core/tests/glib_test_init.cpp deleted file mode 100644 index b521189..0000000 --- a/core/tests/glib_test_init.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "turns/core/init.hpp" - -#include -#include - -#include - -#include - -namespace turns::core::tests -{ - - struct glib_test_init : Catch::EventListenerBase - { - using Catch::EventListenerBase::EventListenerBase; - - auto testRunStarting(Catch::TestRunInfo const &) -> void override - { - Gio::init(); - Glib::init(); - - register_types(); - } - }; - - CATCH_REGISTER_LISTENER(glib_test_init); - -} // namespace turns::core::tests \ No newline at end of file diff --git a/core/tests/participant.cpp b/core/tests/participant.cpp deleted file mode 100644 index b417e36..0000000 --- a/core/tests/participant.cpp +++ /dev/null @@ -1,310 +0,0 @@ -#include "turns/core/participant.hpp" - -#include "turns/core/disposition.hpp" - -#include -#include - -#include - -#include - -namespace turns::core::tests -{ - - TEST_CASE("Constructing a participant", "[core][construction]") - { - auto constexpr name = "Participant #1"; - auto constexpr priority = 17; - auto constexpr disposition = Disposition::Friendly; - - auto json = nlohmann::json::parse(R"( - { - "name": "Participant #1", - "priority": 17, - "disposition": 1, - "is-active": false, - "is-defeated": false - } - )"); - - SECTION("Can be constructed using default ctor") - { - auto instance = Participant{}; - REQUIRE(instance.property_name() == ""); - REQUIRE(instance.property_priority() == 0); - REQUIRE(instance.property_disposition() == Disposition::Neutral); - REQUIRE(!instance.property_is_active()); - REQUIRE(!instance.property_is_defeated()); - } - - SECTION("Can be constructed using ctor") - { - auto instance = Participant{name, priority, disposition}; - REQUIRE(instance.property_name() == name); - REQUIRE(instance.property_priority() == priority); - REQUIRE(instance.property_disposition() == disposition); - REQUIRE(!instance.property_is_active()); - REQUIRE(!instance.property_is_defeated()); - } - - SECTION("Can be constructed using factory") - { - auto instance = Participant::create(name, priority, disposition); - REQUIRE(instance->property_name() == name); - REQUIRE(instance->property_priority() == priority); - REQUIRE(instance->property_disposition() == disposition); - REQUIRE(!instance->property_is_active()); - REQUIRE(!instance->property_is_defeated()); - } - - SECTION("Can be constructed using JSON factory", "[json]") - { - auto instance = Participant::create(json); - REQUIRE(instance->property_name() == name); - REQUIRE(instance->property_priority() == priority); - REQUIRE(instance->property_disposition() == disposition); - REQUIRE(!instance->property_is_active()); - REQUIRE(!instance->property_is_defeated()); - } - } - - TEST_CASE("Setting properties on participant", "[core][properties]") - { - auto constexpr name = "Participant #2"; - auto constexpr priority = 10; - auto constexpr disposition = Disposition::Hostile; - - auto instance = Participant{name, priority, disposition}; - - SECTION("Setting '::disposition' via proxy changes the 'disposition' value") - { - auto old = instance.property_disposition().get_value(); - instance.property_disposition() = static_cast(static_cast(disposition) - 1); - REQUIRE(instance.property_disposition() != old); - } - - SECTION("Setting '::disposition' via glib changes the 'disposition' value") - { - auto old = instance.property_disposition().get_value(); - instance.set_property("disposition", static_cast(static_cast(disposition) - 1)); - REQUIRE(instance.property_disposition() != old); - } - - SECTION("Setting '::is-active' via proxy changes the 'is_active' value") - { - auto old = instance.property_is_active().get_value(); - instance.property_is_active() = !old; - REQUIRE(instance.property_is_active() != old); - } - - SECTION("Setting '::is-active' via glib changes the 'is_active' value") - { - auto old = instance.property_is_active().get_value(); - instance.set_property("is-active", !old); - REQUIRE(instance.property_is_active() != old); - } - - SECTION("Setting '::is-defeated' via proxy changes the 'is_defeated' value") - { - auto old = instance.property_is_defeated().get_value(); - instance.property_is_defeated() = !old; - REQUIRE(instance.property_is_defeated() != old); - } - - SECTION("Setting '::is-defeated' via glib changes the 'is_defeated' value") - { - auto old = instance.property_is_defeated().get_value(); - instance.set_property("is-defeated", !old); - REQUIRE(instance.property_is_defeated() != old); - } - - SECTION("Setting '::name' via proxy changes the 'name' value") - { - auto old = instance.property_name().get_value(); - instance.property_name() = old + " Changed"; - REQUIRE(instance.property_name().get_value() != old); - } - - SECTION("Setting '::name' via glib changes the 'name' value") - { - auto old = instance.property_name().get_value(); - instance.set_property("name", old + " Changed"); - REQUIRE(instance.property_name().get_value() != old); - } - - SECTION("Setting '::priority' via proxy changes the 'priority' value") - { - auto old = instance.property_priority().get_value(); - instance.property_priority() = old + 1; - REQUIRE(instance.property_priority() != old); - } - - SECTION("Setting '::priority' via glib changes the 'priority' value") - { - auto old = instance.property_priority().get_value(); - instance.set_property("priority", old + 1); - REQUIRE(instance.property_priority() != old); - } - } - - TEST_CASE("A freshly constructed participant") - { - auto constexpr constructed_name = "Vana Thistletop"; - auto constexpr constructed_priority = 17; - auto constexpr constructed_disposition = Disposition::Friendly; - auto instance = Participant{constructed_name, constructed_priority, constructed_disposition}; - - SECTION("can be created") - { - REQUIRE(Participant::create(constructed_name, constructed_priority, constructed_disposition)); - } - - SECTION("allows access to its disposition") - { - SECTION("allowing to get it") - { - REQUIRE(instance.property_disposition() == constructed_disposition); - } - - SECTION("allowing to get it via a constant object") - { - auto const & cref = instance; - REQUIRE(cref.property_disposition() == constructed_disposition); - } - - SECTION("allowing to set it") - { - instance.property_disposition() = Disposition::Hostile; - REQUIRE(instance.property_disposition() == Disposition::Hostile); - } - } - - SECTION("allows access to its name") - { - SECTION("allowing to get it") - { - REQUIRE(instance.property_name() == constructed_name); - } - - SECTION("allowing to get it via a constant object") - { - auto const & cref = instance; - REQUIRE(cref.property_name() == constructed_name); - } - - SECTION("allowing to set it") - { - instance.property_name() = "replaced"; - REQUIRE(instance.property_name() == "replaced"); - } - } - - SECTION("allows access to its priority") - { - SECTION("allowing to get it") - { - REQUIRE(instance.property_priority() == constructed_priority); - } - - SECTION("allowing to get it via a constant object") - { - auto const & cref = instance; - REQUIRE(cref.property_priority() == constructed_priority); - } - - SECTION("allowing to set it") - { - instance.property_priority() = 4; - REQUIRE(instance.property_priority() == 4); - } - } - - SECTION("can be compared with another participant") - { - auto equivalent_instance = Participant{"Equivalent", constructed_priority, constructed_disposition}; - auto lesser_instance = Participant{"Lesser", constructed_priority - 1, constructed_disposition}; - auto greater_instance = Participant{"Greater", constructed_priority + 1, constructed_disposition}; - - SECTION("yielding std::partial_ordering::equivalent for itself") - { - REQUIRE((instance <=> equivalent_instance) == std::partial_ordering::equivalent); - } - - SECTION("yielding std::partial_ordering::equivalent for an equivalent participant") - { - REQUIRE((instance <=> equivalent_instance) == std::partial_ordering::equivalent); - } - - SECTION("yielding std::partial_ordering::greater for a lesser participant") - { - REQUIRE((instance <=> lesser_instance) == std::partial_ordering::greater); - } - - SECTION("yielding std::partial_ordering::less for a greater participant") - { - REQUIRE((instance <=> greater_instance) == std::partial_ordering::less); - } - } - } - - TEST_CASE("Serializing a participant") - { - auto instance = Participant::create("Participant #0", 17.2, Disposition::Friendly); - auto serialized = instance->serialize(); - - SECTION("the active state is serialized correctly") - { - REQUIRE_FALSE(serialized.at("is-active")); - } - - SECTION("the disposition is serialized correctly") - { - REQUIRE(serialized.at("disposition") == Disposition::Friendly); - } - - SECTION("the name is serialized correctly") - { - REQUIRE(serialized.at("name") == "Participant #0"); - } - - SECTION("the priority is serialized correctly") - { - REQUIRE(serialized.at("priority") == Catch::Approx{17.2}); - } - } - - TEST_CASE("De-Serializing a participant") - { - auto serialized = nlohmann::json::parse(R"( - { - "name": "Participant #1", - "priority": -2.3, - "disposition": 2, - "is-active": true - } - )"); - auto instance = Participant::create(serialized); - - SECTION("the active state is de-serialized correctly") - { - REQUIRE(instance->property_is_active()); - } - - SECTION("the disposition is de-serialized correctly") - { - REQUIRE(instance->property_disposition() == Disposition::Hostile); - } - - SECTION("the name is de-serialized correctly") - { - REQUIRE(instance->property_name() == "Participant #1"); - } - - SECTION("the priority is de-serialized correctly") - { - REQUIRE(instance->property_priority() == Catch::Approx{-2.3}); - } - } - -} // namespace turns::core::tests \ No newline at end of file diff --git a/core/tests/single_participant.trns b/core/tests/single_participant.trns deleted file mode 100644 index bcce137..0000000 --- a/core/tests/single_participant.trns +++ /dev/null @@ -1,11 +0,0 @@ -{ - "participants": [ - { - "disposition": 0, - "is-active": false, - "is-defeated": false, - "name": "Riamin", - "priority": 0.0 - } - ] -} \ No newline at end of file diff --git a/core/tests/turn_order_bugs.cpp b/core/tests/turn_order_bugs.cpp deleted file mode 100644 index 7bfde78..0000000 --- a/core/tests/turn_order_bugs.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "turns/core/disposition.hpp" -#include "turns/core/turn_order_model.hpp" - -#include - -namespace turns::core::tests -{ - /** - * Bug description: - * - * After having stepped according to the step pattern below, tt was possible to step backward often enough to underflow the round number: - * - forward - * - backward - * - forward - */ - SCENARIO("Can step back infinitely", "[turn_order][bug]") - { - GIVEN("a non-empty turn_order") - { - auto instance = TurnOderModel::create(); - - instance->add("A", 0, Disposition::Neutral); - - WHEN("it is started and then stepped forward, backward, forward") - { - instance->start(); - instance->next(); - instance->previous(); - instance->next(); - - THEN("it is not possible to step backwards more than once") - { - instance->previous(); - instance->previous(); - REQUIRE(instance->round_number() == 0); - } - } - } - } -} // namespace turns::core::tests \ No newline at end of file diff --git a/core/tests/turn_order_model.cpp b/core/tests/turn_order_model.cpp deleted file mode 100644 index 1cd3633..0000000 --- a/core/tests/turn_order_model.cpp +++ /dev/null @@ -1,314 +0,0 @@ -#include "turns/core/turn_order_model.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" - -#include - -#include - -#include - -#include - -namespace turns::core::tests -{ - SCENARIO("Queries on a fresh turn_order instance", "[turn_order]") - { - GIVEN("an empty turn_order") - { - auto instance = TurnOderModel::create(); - - THEN("get_n_items() returns 0") - { - REQUIRE(instance->get_n_items() == 0); - } - - THEN("get_type() returns participant::get_type()") - { - REQUIRE(instance->get_item_type() == Participant::get_type()); - } - - THEN("get_typed_object(0) returns nullptr") - { - REQUIRE(instance->get_typed_object(0) == nullptr); - } - - THEN("has_next() returns false") - { - REQUIRE_FALSE(instance->has_next()); - } - - THEN("has_previous() returns false") - { - REQUIRE_FALSE(instance->has_previous()); - } - - THEN("is_empty() returns true") - { - REQUIRE(instance->is_empty()); - } - - THEN("is_running() returns false") - { - REQUIRE_FALSE(instance->is_running()); - } - - THEN("round_number() returns invalid_round_number") - { - REQUIRE(instance->round_number() == TurnOderModel::invalid_round_number); - } - } - } - - SCENARIO("Adding participants") - { - auto instance = TurnOderModel::create(); - - GIVEN("a participant has been added to a turn_order") - { - instance->add("Participant #0", 0, Disposition::Neutral); - - THEN("get_n_items() returns 1") - { - REQUIRE(instance->get_n_items() == 1); - } - - THEN("get_typed_object(0) returns a non-null pointer") - { - REQUIRE(instance->get_typed_object(0) != nullptr); - } - - THEN("has_next() returns true") - { - REQUIRE(instance->has_next()); - } - - THEN("has_previous() returns false") - { - REQUIRE_FALSE(instance->has_previous()); - } - - THEN("is_empty() returns false") - { - REQUIRE_FALSE(instance->is_empty()); - } - - THEN("is_running() returns false") - { - REQUIRE_FALSE(instance->is_running()); - } - - THEN("round_number() returns invalid_round_number") - { - REQUIRE(instance->round_number() == TurnOderModel::invalid_round_number); - } - - WHEN("the turn_order is start()ed") - { - instance->start(); - - THEN("get_n_items() still returns 1") - { - REQUIRE(instance->get_n_items() == 1); - } - - THEN("get_typed_object(0) still returns a non-null pointer") - { - REQUIRE(instance->get_typed_object(0) != nullptr); - } - - THEN("has_next() still returns true") - { - REQUIRE(instance->has_next()); - } - - THEN("has_previous() still returns false") - { - REQUIRE_FALSE(instance->has_previous()); - } - - THEN("is_empty() still returns false") - { - REQUIRE_FALSE(instance->is_empty()); - } - - THEN("is_running() returns true") - { - REQUIRE(instance->is_running()); - } - - THEN("round_number() returns 0") - { - REQUIRE(instance->round_number() == 0); - } - - AND_WHEN("invoking previous()") - { - instance->previous(); - - THEN("get_n_items() still returns 1") - { - REQUIRE(instance->get_n_items() == 1); - } - - THEN("get_typed_object(0) still returns a non-null pointer") - { - REQUIRE(instance->get_typed_object(0) != nullptr); - } - - THEN("has_next() still returns true") - { - REQUIRE(instance->has_next()); - } - - THEN("has_previous() still returns false") - { - REQUIRE_FALSE(instance->has_previous()); - } - - THEN("is_empty() still returns false") - { - REQUIRE_FALSE(instance->is_empty()); - } - - THEN("is_running() returns true") - { - REQUIRE(instance->is_running()); - } - - THEN("round_number() returns 0") - { - REQUIRE(instance->round_number() == 0); - } - } - - AND_WHEN("invoking next()") - { - instance->next(); - - THEN("get_n_items() still returns 1") - { - REQUIRE(instance->get_n_items() == 1); - } - - THEN("get_typed_object(0) still returns a non-null pointer") - { - REQUIRE(instance->get_typed_object(0) != nullptr); - } - - THEN("has_next() still returns true") - { - REQUIRE(instance->has_next()); - } - - THEN("has_previous() returns true") - { - REQUIRE(instance->has_previous()); - } - - THEN("is_empty() still returns false") - { - REQUIRE_FALSE(instance->is_empty()); - } - - THEN("is_running() returns true") - { - REQUIRE(instance->is_running()); - } - - THEN("round_number() returns 1") - { - REQUIRE(instance->round_number() == 1); - } - } - } - } - } - - SCENARIO("Loading from json data") - { - GIVEN("an empty turn order") - { - auto instance = TurnOderModel{}; - CHECK(instance.is_empty()); - - WHEN("loading a serialized turn order with one named participant") - { - auto data = Gio::Resource::lookup_data_global("/ch/arknet/Turns/core-tests/single_participant.trns"); - auto size = 0uz; - instance.load(nlohmann::json::parse(std::string_view{static_cast(data->get_data(size)), data->get_size()})); - - THEN("it is no longer empty") - { - REQUIRE_FALSE(instance.is_empty()); - } - - THEN("it has 1 element") - { - REQUIRE(instance.get_n_items() == 1); - } - - THEN("the single participant's name is set") - { - auto participant = instance.get_typed_object(0); - REQUIRE_FALSE(participant->get_name().empty()); - } - - AND_THEN("adding another participant with a higher priority") - { - auto participant = instance.get_typed_object(0); - instance.add("Higher Priority", 100.0f, Disposition::Neutral); - - THEN("the index of the test participant is 1") - { - CHECK(instance.get_typed_object(0) != participant); - REQUIRE(instance.get_typed_object(1) == participant); - } - } - - AND_WHEN("calling clear") - { - instance.clear(); - - THEN("it is empty") - { - REQUIRE(instance.is_empty()); - } - } - } - } - } - - SCENARIO("Sorting of participants") - { - GIVEN("A turn order with 3 participants (A,B,C) of priorities 100, 0, and -100 respectively") - { - auto instance = TurnOderModel{}; - - instance.add("A", 100, Disposition::Friendly); - instance.add("B", 0, Disposition::Friendly); - instance.add("C", -100, Disposition::Friendly); - - THEN("A comes before B comes before C") - { - REQUIRE(instance.get_typed_object(0)->get_name() == "A"); - REQUIRE(instance.get_typed_object(1)->get_name() == "B"); - REQUIRE(instance.get_typed_object(2)->get_name() == "C"); - } - - WHEN("changing the priority of the B to 50") - { - instance.get_typed_object(1)->set_priority(50); - - THEN("the order stays the same") - { - REQUIRE(instance.get_typed_object(0)->get_name() == "A"); - REQUIRE(instance.get_typed_object(1)->get_name() == "B"); - REQUIRE(instance.get_typed_object(2)->get_name() == "C"); - } - } - } - } - -} // namespace turns::core::tests \ No newline at end of file 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 +# "$<$,$>:gcov>" + +# "PkgConfig::gtkmm" +# "adwaitamm::adwaitamm" + +# "turns::core" +# "turns::lang" + +# "$<$:-Wl,--whole-archive>" +# "turns::ui" +# "turns::style" +# "$<$:-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 + "$<$,$>:--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 +#include + +#include + +#include + +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 +#include + +#include + +#include +#include +#include + +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 @@ + + + ch.arknet.Turns + CC-BY-SA-4.0 + LGPL-2.1-or-later + Turns + Züge + A simple turn order tracker + +

+ Turns is an application to track turn order for TTRPGs like Dungeons and Dragons or Call of Cthulhu. +

+
+ + + +

This is the first public release

+
+
+
+ + keyboard + pointing + + + + Role-playing Games + Tabletop Games + + + Felix Morgner + + felix.morgner@gmail.com + ch.arknet.Turns.desktop + https://source.arknet.ch/fmorgner/turns + https://source.arknet.ch/fmorgner/turns/-/issues + https://source.arknet.ch/fmorgner/turns +
\ 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 @@ + + + + Turn order file + + + + + \ 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 @@ + + + + + '#33d17a' + Friendly Disposition Color + The color used to shade friendly participants. + + + '#e01b24' + Hostile Disposition Color + The color used to shade hostile participants. + + + '#9141ac' + Secret Disposition Color + The color used to shade secret participants. + + + false + Skip Defeated Participants + Whether or not defeated participants shall be skipped while stepping through the turn order. + + + \ 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 +#include + +#include +#include + +#include + +namespace turns::core +{ + + auto get_settings() -> Glib::RefPtr + { + 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 + +#include + +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; +} // 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 +// #include + +// #include + +// #include +// #include + +// #include +// #include +// #include + +// #include +// #include +// #include +// #include + +// #include + +// #include +// #include + +// auto show_about(Glib::RefPtr app) +// { +// auto active_window = app->get_active_window(); +// auto dialog = Gtk::make_managed("/ch/arknet/Turns/metainfo.xml", ""); +// dialog->present(active_window); +// } + +// auto main(int argc, char * argv[]) -> int +// { +// setlocale(LC_ALL, ""); +// bindtextdomain("turns", LOCALEDIR); +// bind_textdomain_codeset("turns", "UTF-8"); +// textdomain("turns"); + +// auto app = Adwaita::Application::create("ch.arknet.Turns", Gio::Application::Flags::HANDLES_OPEN); +// auto settings = turns::core::get_settings(); + +// turns::core::register_types(); + +// app->signal_startup().connect([app] { +// turns::ui::register_types(); + +// auto style_manager = Adwaita::StyleManager::get_default(); +// style_manager->set_color_scheme(Adwaita::ColorScheme::PreferLight); + +// app->add_action("quit", sigc::mem_fun(*app, &Adwaita::Application::quit)); +// app->add_action("about", sigc::bind(&show_about, app)); +// app->set_accel_for_action("app.quit", "q"); +// app->set_accel_for_action("win.clear", "x"); +// app->set_accel_for_action("win.next", "space"); +// app->set_accel_for_action("win.previous", "BackSpace"); +// app->set_accel_for_action("win.add_participant", "a"); +// app->set_accel_for_action("win.open", "o"); +// app->set_accel_for_action("win.preferences", "comma"); +// app->set_accel_for_action("win.save", "s"); +// app->set_accel_for_action("win.save-as", "s"); +// }); + +// app->signal_activate().connect([app, settings] { +// auto window = new turns::ui::Tracker{app, settings}; +// window->present(); +// }); + +// app->signal_open().connect([app, settings](auto files, auto) { +// auto windows = app->get_windows(); +// auto window = static_cast(nullptr); + +// if (windows.empty()) +// { +// window = new turns::ui::Tracker{app, settings}; +// } +// else +// { +// window = dynamic_cast(windows[0]); +// } + +// window->present(); +// window->load(files[0]); +// }); + +// app->signal_window_removed().connect([](auto window) { +// auto tracker = dynamic_cast(window); +// if (tracker) +// { +// delete tracker; +// } +// }); + +// return app->run(argc, argv); +// } \ No newline at end of file diff --git a/gui/style/CMakeLists.txt b/gui/style/CMakeLists.txt new file mode 100644 index 0000000..8ddbae8 --- /dev/null +++ b/gui/style/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library("style") + +add_library("turns::style" ALIAS "style") + +target_add_glib_resources("style" + PREFIX "ch/arknet/Turns" + CSS_FILES + "style.css" + "style-dark.css" +) + +target_link_libraries("style" PUBLIC + "PkgConfig::giomm" + PRIVATE + "$<$,$>:gcov>" +) + +enable_coverage("style") diff --git a/gui/style/style-dark.css b/gui/style/style-dark.css new file mode 100644 index 0000000..928264a --- /dev/null +++ b/gui/style/style-dark.css @@ -0,0 +1,32 @@ +@define-color hostile #e01b24; +@define-color friendly #33d17a; +@define-color secret #9141ac; + + +.disposition-hostile { + background-color: mix(shade(@hostile, 0.8), @window_bg_color, 0.5); +} + +:checked.disposition-hostile { + background-color: mix(shade(@hostile, 0.5), @window_bg_color, 0.5); +} + +.disposition-friendly { + background-color: mix(shade(@friendly, 0.8), @window_bg_color, 0.5); +} + +:checked.disposition-friendly { + background-color: mix(shade(@friendly, 0.5), @window_bg_color, 0.5); +} + +.disposition-secret { + background-color: mix(shade(@secret, 0.8), @window_bg_color, 0.5); +} + +:checked.disposition-secret { + background-color: mix(shade(@secret, 0.5), @window_bg_color, 0.5); +} + +.active-participant { + background-color: mix(shade(@accent_bg_color, 0.5), @card_bg_color, 0.5); +} \ No newline at end of file diff --git a/gui/style/style.css b/gui/style/style.css new file mode 100644 index 0000000..a185c9b --- /dev/null +++ b/gui/style/style.css @@ -0,0 +1,31 @@ +@define-color hostile #e01b24; +@define-color friendly #33d17a; +@define-color secret #9141ac; + +.disposition-hostile { + background-color: mix(shade(@hostile, 1.6), @window_bg_color, 0.5); +} + +:checked.disposition-hostile { + background-color: mix(shade(@hostile, 1), @window_bg_color, 0.5); +} + +.disposition-friendly { + background-color: mix(shade(@friendly, 1.6), @window_bg_color, 0.5); +} + +:checked.disposition-friendly { + background-color: mix(shade(@friendly, 1), @window_bg_color, 0.5); +} + +.disposition-secret { + background-color: mix(shade(@secret, 1.6), @window_bg_color, 0.5); +} + +:checked.disposition-secret { + background-color: mix(shade(@secret, 1), @window_bg_color, 0.5); +} + +.active-participant { + background-color: mix(shade(@accent_bg_color, 1.5), @card_bg_color, 0.5); +} \ No newline at end of file diff --git a/gui/ui/CMakeLists.txt b/gui/ui/CMakeLists.txt new file mode 100644 index 0000000..1584479 --- /dev/null +++ b/gui/ui/CMakeLists.txt @@ -0,0 +1,59 @@ +# Library + +file(GLOB_RECURSE UI_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" CONFIGURE_DEPENDS "*.ui") +file(GLOB_RECURSE UI_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "src/*.cpp") +file(GLOB_RECURSE UI_TESTS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "tests/*.cpp") + +add_library("ui" ${UI_SOURCES}) +add_library("turns::ui" ALIAS "ui") + +target_compile_options("ui" PUBLIC + "$<$:-Wall>" + "$<$:-Wextra>" + "$<$:-Werror>" + "$<$:-pedantic-errors>" +) + +target_include_directories("ui" PUBLIC + "include" +) + +target_link_libraries("ui" PUBLIC + "turns::core" + "turns::lang" + + "adwaitamm::adwaitamm" + "PkgConfig::gtkmm" +) + +target_add_glib_resources("ui" + PREFIX "/ch/arknet/Turns/" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" + UI_FILES ${UI_FILES} +) + +enable_coverage("ui") + +# Tests + +get_target_property(TRANSLATIONS_BINARY_DIR "lang" BINARY_DIR) + +add_executable("ui-tests" ${UI_TESTS}) + +target_compile_definitions("ui-tests" PUBLIC + "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" +) + +target_link_libraries("ui-tests" PRIVATE + "Catch2::Catch2WithMain" + + "$<$:-Wl,--whole-archive>" + "turns::ui" + "$<$:-Wl,--no-whole-archive>" +) + +target_link_options("ui-tests" PRIVATE + "$<$,$>:--coverage>" +) + +catch_discover_tests("ui-tests") diff --git a/gui/ui/include/turns/ui/fwd.hpp b/gui/ui/include/turns/ui/fwd.hpp new file mode 100644 index 0000000..69dc0b5 --- /dev/null +++ b/gui/ui/include/turns/ui/fwd.hpp @@ -0,0 +1,14 @@ +#ifndef TURNS_UI_WIDGETS_FWD_HPP +#define TURNS_UI_WIDGETS_FWD_HPP + +namespace turns::ui::widgets +{ + struct participant_editor; + struct participant_row; + struct preferences; + struct tracker; + struct turn_order_view; + struct preferences; +} // namespace turns::ui::widgets + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/init.hpp b/gui/ui/include/turns/ui/init.hpp new file mode 100644 index 0000000..77bd009 --- /dev/null +++ b/gui/ui/include/turns/ui/init.hpp @@ -0,0 +1,15 @@ +#ifndef TURNS_UI_INIT_HPP +#define TURNS_UI_INIT_HPP + +#include + +#include + +namespace turns::ui +{ + + auto register_types() -> void; + +} // namespace turns::ui + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/participant_editor.hpp b/gui/ui/include/turns/ui/participant_editor.hpp new file mode 100644 index 0000000..0fbc504 --- /dev/null +++ b/gui/ui/include/turns/ui/participant_editor.hpp @@ -0,0 +1,82 @@ +#ifndef TURNS_UI_PARTICIPANT_EDITOR_HPP +#define TURNS_UI_PARTICIPANT_EDITOR_HPP + +#include "turns/core/disposition.hpp" +#include "turns/core/fwd.hpp" +#include "turns/core/participant.hpp" +#include "turns/ui/template_widget.hpp" + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace turns::ui +{ + + struct ParticipantEditor : template_widget + { + using SignalFinishedType = sigc::signal; + + auto constexpr inline static children = std::array{ + "disposition", + "finish", + "name", + "priority", + }; + + explicit ParticipantEditor(Glib::RefPtr participant); + + [[nodiscard]] auto get_disposition() const -> core::Disposition; + [[nodiscard]] auto get_name() const -> Glib::ustring; + [[nodiscard]] auto get_participant() const -> Glib::RefPtr; + [[nodiscard]] auto get_priority() const -> double; + + auto set_disposition(core::Disposition value) -> void; + auto set_name(Glib::ustring const & value) -> void; + auto set_participant(Glib::RefPtr const & value) -> void; + auto set_priority(double value) -> void; + + [[nodiscard]] auto property_participant() -> Glib::PropertyProxy>; + [[nodiscard]] auto property_participant() const -> Glib::PropertyProxy_ReadOnly>; + + auto signal_finished() -> SignalFinishedType; + + private: + auto handle_finish_clicked() -> void; + auto handle_item_bind(Glib::RefPtr item) -> void; + auto handle_item_setup(Glib::RefPtr item) -> void; + auto handle_participant_changed() -> void; + + Adwaita::ComboRow * m_disposition; + Gtk::Button * m_finish; + Adwaita::EntryRow * m_name; + Adwaita::SpinRow * m_priority; + + Glib::RefPtr m_disposition_factory; + Glib::RefPtr m_disposition_model; + + Glib::Property> m_participant; + + SignalFinishedType m_signal_finished{}; + }; + +} // namespace turns::ui + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/participant_row.hpp b/gui/ui/include/turns/ui/participant_row.hpp new file mode 100644 index 0000000..561214b --- /dev/null +++ b/gui/ui/include/turns/ui/participant_row.hpp @@ -0,0 +1,50 @@ +#ifndef TURNS_UI_PARTICIPANT_ROW_HPP +#define TURNS_UI_PARTICIPANT_ROW_HPP + +#include "turns/core/fwd.hpp" +#include "turns/ui/template_widget.hpp" + +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace turns::ui +{ + struct ParticipantRow : template_widget + { + auto constexpr inline static children = std::array{ + "delete", + "edit", + "subtitle", + "title", + "toggle_defeated", + }; + + ParticipantRow(Glib::RefPtr participant); + + auto delete_enabled() -> Glib::PropertyProxy; + auto edit_enabled() -> Glib::PropertyProxy; + + private: + auto handle_delete() -> void; + auto handle_edit() -> void; + + Gtk::Button * m_delete; + Gtk::Button * m_edit; + Gtk::Label * m_subtitle; + Gtk::Label * m_title; + Gtk::ToggleButton * m_toggle_defeated; + + Glib::Property m_delete_enabled; + Glib::Property m_edit_enabled; + }; +} // namespace turns::ui::widgets + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/preferences.hpp b/gui/ui/include/turns/ui/preferences.hpp new file mode 100644 index 0000000..b68b91c --- /dev/null +++ b/gui/ui/include/turns/ui/preferences.hpp @@ -0,0 +1,53 @@ +#ifndef TURNS_UI_PREFERENCES_HPP +#define TURNS_UI_PREFERENCES_HPP + +#include "turns/ui/template_widget.hpp" + +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +namespace turns::ui +{ + struct Preferences : template_widget + { + + auto constexpr inline static children = std::array{ + "friendly_reset_button", + "hostile_reset_button", + "secret_reset_button", + "friendly_color_button", + "hostile_color_button", + "secret_color_button", + "skip_defeated", + }; + + explicit Preferences(Glib::RefPtr settings = {}); + + private: + auto bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void; + auto bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void; + auto update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void; + + Glib::RefPtr m_settings; + + Gtk::Button * m_friendly_reset_button{}; + Gtk::Button * m_hostile_reset_button{}; + Gtk::Button * m_secret_reset_button{}; + Gtk::ColorDialogButton * m_friendly_color_button{}; + Gtk::ColorDialogButton * m_hostile_color_button{}; + Gtk::ColorDialogButton * m_secret_color_button{}; + Adwaita::SwitchRow * m_skip_defeated{}; + }; +} // namespace turns::ui::widgets + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/template_widget.hpp b/gui/ui/include/turns/ui/template_widget.hpp new file mode 100644 index 0000000..7147560 --- /dev/null +++ b/gui/ui/include/turns/ui/template_widget.hpp @@ -0,0 +1,67 @@ +#ifndef TURNS_UI_TEMPLATE_WIDGET_HPP +#define TURNS_UI_TEMPLATE_WIDGET_HPP + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +namespace turns::ui +{ + + template + struct template_widget : Glib::ExtraClassInit, + BaseWidgetType + { + template + template_widget(Glib::ustring && resource_path, BaseWidgetCtorArgTypes &&... base_widget_ctor_args) + : Glib::ExtraClassInit{class_init, &resource_path, instance_init} + , BaseWidgetType{std::forward(base_widget_ctor_args)...} + { + } + + protected: + template + auto get_widget(char const * name) -> WidgetType * + { + auto self = static_cast(this); + auto widget = GTK_WIDGET(Glib::unwrap(self)); + auto type = G_OBJECT_TYPE(Glib::unwrap(self)); + auto child = GTK_WIDGET(gtk_widget_get_template_child(widget, type, name)); + g_assert_nonnull(child); + return dynamic_cast(Glib::wrap(child)); + } + + private: + auto static class_init(void * g_class, void * g_class_data) -> void + { + g_return_if_fail(GTK_IS_WIDGET_CLASS(g_class)); + + auto resource_path = static_cast(g_class_data); + + gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(g_class), resource_path->c_str()); + + std::ranges::for_each(CustomWidgetType::children, [g_class](auto const & child) { + gtk_widget_class_bind_template_child_full(GTK_WIDGET_CLASS(g_class), child, false, 0); + }); + } + + auto static instance_init(GTypeInstance * instance, void * /* type_class */) -> void + { + g_return_if_fail(GTK_IS_WIDGET(instance)); + + gtk_widget_init_template(GTK_WIDGET(instance)); + } + }; + +} // namespace turns::ui::widgets + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/tracker.hpp b/gui/ui/include/turns/ui/tracker.hpp new file mode 100644 index 0000000..2e3adf5 --- /dev/null +++ b/gui/ui/include/turns/ui/tracker.hpp @@ -0,0 +1,104 @@ +#ifndef TURNS_UI_TRACKER_HPP +#define TURNS_UI_TRACKER_HPP + +#include "turns/core/turn_order_model.hpp" +#include "turns/ui/template_widget.hpp" +#include "turns/ui/turn_order_view.hpp" + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace turns::ui +{ + + struct Tracker : template_widget + { + auto constexpr inline static children = std::array{ + "controls", + "empty", + "overlay", + "stack", + "start", + "title", + }; + + Tracker(Glib::RefPtr const & app, Glib::RefPtr const & settings); + + auto load(Glib::RefPtr file) -> void; + + private: + friend auto register_types() -> void; + Tracker(); + + /** Setup */ + auto setup_actions() -> void; + auto setup_colors() -> void; + + /** Actions */ + auto add_participant() -> void; + auto delete_participant(Glib::VariantBase param) -> void; + auto edit_participant(Glib::VariantBase param) -> void; + auto open() -> void; + auto preferences() -> void; + auto save(bool force_ask) -> void; + auto stop() -> void; + + /** Event Handlers */ + auto on_open_response(Glib::RefPtr result, Glib::RefPtr dialog) -> void; + auto on_save_response(Glib::RefPtr result, Glib::RefPtr dialog) -> void; + auto on_load_content_done(Glib::RefPtr result) -> void; + auto on_replace_content_done(Glib::RefPtr result) -> void; + auto on_settings_changed(Glib::ustring key) -> void; + + /** Helpers */ + auto show_error(std::exception const & e) -> void; + auto show_toast(std::string const & message) -> void; + auto start_replace_content() -> void; + auto update_colors() -> void; + auto update_subtitle() -> void; + + Gtk::Revealer * m_controls; + Gtk::Widget * m_empty; + Adwaita::ToastOverlay * m_overlay; + Gtk::Stack * m_stack; + Gtk::Button * m_start; + Adwaita::WindowTitle * m_title; + Glib::RefPtr m_turn_order; + TurnOrderView * m_turn_order_view; + Glib::RefPtr m_settings{}; + Glib::PropertyProxy m_subtitle; + + Glib::RefPtr m_file{}; + std::string m_file_etag{}; + std::string m_file_buffer{}; + + Glib::RefPtr m_css{}; + }; + +} // namespace turns::ui + +#endif \ No newline at end of file diff --git a/gui/ui/include/turns/ui/turn_order_view.hpp b/gui/ui/include/turns/ui/turn_order_view.hpp new file mode 100644 index 0000000..8dae4e4 --- /dev/null +++ b/gui/ui/include/turns/ui/turn_order_view.hpp @@ -0,0 +1,40 @@ +#ifndef TURNS_UI_TURN_ORDER_VIEW_HPP +#define TURNS_UI_TURN_ORDER_VIEW_HPP + +#include "turns/core/fwd.hpp" +#include "turns/core/turn_order_model.hpp" +#include "turns/ui/template_widget.hpp" + +#include +#include + +#include +#include +#include +#include + +#include + +namespace turns::ui +{ + struct TurnOrderView : template_widget + { + using model_type = core::TurnOderModel; + + auto constexpr inline static children = std::array{ + "progress", + "view", + }; + + explicit TurnOrderView(Glib::RefPtr model = {}); + + private: + auto handle_create_row(Glib::RefPtr const item) -> Gtk::Widget *; + + Glib::RefPtr m_model; + Gtk::ProgressBar * m_progress; + Gtk::ListBox * m_view; + }; +} // namespace turns::ui::widgets + +#endif \ No newline at end of file diff --git a/gui/ui/src/init.cpp b/gui/ui/src/init.cpp new file mode 100644 index 0000000..1c0295a --- /dev/null +++ b/gui/ui/src/init.cpp @@ -0,0 +1,23 @@ +#include "turns/ui/init.hpp" + +#include "turns/ui/participant_editor.hpp" +#include "turns/ui/participant_row.hpp" +#include "turns/ui/preferences.hpp" +#include "turns/ui/tracker.hpp" +#include "turns/ui/turn_order_view.hpp" +#include +#include + +namespace turns::ui +{ + + auto register_types() -> void + { + static_cast(ParticipantEditor{{}}); + static_cast(ParticipantRow{{}}); + static_cast(Preferences{{}}); + static_cast(Tracker{}); + static_cast(TurnOrderView{{}}); + } + +} // namespace turns::ui \ No newline at end of file diff --git a/gui/ui/src/participant_editor.cpp b/gui/ui/src/participant_editor.cpp new file mode 100644 index 0000000..8c83559 --- /dev/null +++ b/gui/ui/src/participant_editor.cpp @@ -0,0 +1,162 @@ +#include "turns/ui/participant_editor.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" +#include "turns/lang/messages.hpp" +#include "turns/ui/template_widget.hpp" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +namespace turns::ui +{ + namespace + { + auto constexpr static TYPE_NAME = "ParticipantEditor"; + auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_editor.ui"; + } // namespace + + ParticipantEditor::ParticipantEditor(Glib::RefPtr participant) + : Glib::ObjectBase{TYPE_NAME} + , template_widget{TEMPLATE} + , m_disposition{get_widget("disposition")} + , m_finish{get_widget("finish")} + , m_name{get_widget("name")} + , m_priority{get_widget("priority")} + , m_disposition_factory{Gtk::SignalListItemFactory::create()} + , m_disposition_model{Gtk::StringList::create()} + , m_participant{*this, "participant", nullptr} + { + m_finish->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_finish_clicked)); + + for (auto n : std::views::iota(std::uint8_t{}, static_cast(core::Disposition::END))) + { + m_disposition_model->append(presentation_name_for(core::Disposition{n})); + } + + m_disposition_factory->signal_bind().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_item_bind)); + m_disposition_factory->signal_setup().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_item_setup)); + + m_disposition->set_factory(m_disposition_factory); + m_disposition->set_model(m_disposition_model); + + property_participant().signal_changed().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_participant_changed)); + + set_participant(participant); + } + + auto ParticipantEditor::get_disposition() const -> core::Disposition + { + return static_cast(m_disposition->get_selected()); + } + + auto ParticipantEditor::get_name() const -> Glib::ustring + { + return m_name->get_text(); + } + + auto ParticipantEditor::get_participant() const -> Glib::RefPtr + { + return m_participant.get_value(); + } + + auto ParticipantEditor::get_priority() const -> double + { + return m_priority->get_value(); + } + + auto ParticipantEditor::set_disposition(core::Disposition value) -> void + { + m_disposition->set_selected(static_cast(value)); + } + + auto ParticipantEditor::set_name(Glib::ustring const & value) -> void + { + m_name->set_text(value); + } + + auto ParticipantEditor::set_participant(Glib::RefPtr const & value) -> void + { + m_participant.set_value(value); + } + + auto ParticipantEditor::set_priority(double value) -> void + { + m_priority->set_value(value); + } + + auto ParticipantEditor::property_participant() -> Glib::PropertyProxy> + { + return m_participant.get_proxy(); + } + + auto ParticipantEditor::property_participant() const -> Glib::PropertyProxy_ReadOnly> + { + return m_participant.get_proxy(); + } + + auto ParticipantEditor::signal_finished() -> SignalFinishedType + { + return m_signal_finished; + } + + auto ParticipantEditor::handle_finish_clicked() -> void + { + m_signal_finished.emit(m_name->get_text(), m_priority->get_value(), static_cast(m_disposition->get_selected())); + close(); + } + + auto ParticipantEditor::handle_item_bind(Glib::RefPtr item) -> void + { + auto value = std::dynamic_pointer_cast(item->get_item())->get_string(); + dynamic_cast(item->get_child())->set_label(value); + } + + auto ParticipantEditor::handle_item_setup(Glib::RefPtr item) -> void + { + item->set_child(*Gtk::make_managed()); + } + + auto ParticipantEditor::handle_participant_changed() -> void + { + auto value = m_participant.get_value(); + set_title(_(value ? lang::edit_participant : lang::add_participant)); + if (value) + { + Glib::Binding::bind_property(value->property_name(), + m_name->property_text(), + Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE); + Glib::Binding::bind_property(value->property_priority(), + m_priority->property_value(), + Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE); + Glib::Binding::bind_property(value->property_disposition(), + m_disposition->property_selected(), + Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE, + [](auto value) { return static_cast(value); }, + [](auto value) { return static_cast(value); }); + } + } + +} // namespace turns::ui \ No newline at end of file diff --git a/gui/ui/src/participant_editor.ui b/gui/ui/src/participant_editor.ui new file mode 100644 index 0000000..6bcf83e --- /dev/null +++ b/gui/ui/src/participant_editor.ui @@ -0,0 +1,71 @@ + + + + + + + + diff --git a/gui/ui/src/participant_row.cpp b/gui/ui/src/participant_row.cpp new file mode 100644 index 0000000..7ce8e53 --- /dev/null +++ b/gui/ui/src/participant_row.cpp @@ -0,0 +1,149 @@ +#include "turns/ui/participant_row.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" +#include "turns/lang/messages.hpp" +#include "turns/ui/template_widget.hpp" + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace turns::ui +{ + namespace + { + auto constexpr static TYPE_NAME = "ParticipantRow"; + auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_row.ui"; + + auto css_class_for(core::Disposition value) -> Glib::ustring + { + switch (value) + { + case core::Disposition::Friendly: + return "disposition-friendly"; + case core::Disposition::Hostile: + return "disposition-hostile"; + case core::Disposition::Secret: + return "disposition-secret"; + default: + return ""; + } + } + } // namespace + + ParticipantRow::ParticipantRow(Glib::RefPtr participant) + : Glib::ObjectBase(TYPE_NAME) + , template_widget{TEMPLATE} + , m_delete{get_widget("delete")} + , m_edit{get_widget("edit")} + , m_subtitle{get_widget("subtitle")} + , m_title{get_widget("title")} + , m_toggle_defeated{get_widget("toggle_defeated")} + , m_delete_enabled{*this, "delete-enabled", true} + , m_edit_enabled{*this, "edit-enabled", true} + + { + m_delete->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantRow::handle_delete)); + m_edit->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantRow::handle_edit)); + + Glib::Binding::bind_property(m_subtitle->property_label(), + m_subtitle->property_visible(), + Glib::Binding::Flags::DEFAULT, + sigc::mem_fun(&Glib::ustring::size)); + Glib::Binding::bind_property(m_title->property_label(), + m_title->property_visible(), + Glib::Binding::Flags::INVERT_BOOLEAN, + sigc::mem_fun(&Glib::ustring::size)); + Glib::Binding::bind_property(m_toggle_defeated->property_active(), + m_toggle_defeated->property_icon_name(), + Glib::Binding::Flags::SYNC_CREATE, + [](auto active) { return active ? "face-sick-symbolic" : "face-smile-symbolic"; }); + + // clang-format off + Glib::Binding::bind_property(delete_enabled(), + m_delete->property_sensitive(), + Glib::Binding::Flags::SYNC_CREATE); + Glib::Binding::bind_property(edit_enabled(), + m_edit->property_sensitive(), + Glib::Binding::Flags::SYNC_CREATE); + // clang-format on + + if (participant) + { + Glib::Binding::bind_property(participant->property_name(), m_title->property_label(), Glib::Binding::Flags::SYNC_CREATE); + + Glib::Binding::bind_property(participant->property_priority(), + m_subtitle->property_label(), + Glib::Binding::Flags::SYNC_CREATE, + [](auto n) { return std::vformat(_(lang::priority_number), std::make_format_args(n)); }); + + Glib::Binding::bind_property(participant->property_disposition(), + m_toggle_defeated->property_css_classes(), + Glib::Binding::Flags::SYNC_CREATE, + [this](auto value) { + auto classes = m_toggle_defeated->get_css_classes(); + auto removed = std::ranges::remove_if(classes, [](auto cls) { + return (cls == "disposition-friendly") | (cls == "disposition-hostile") || (cls == "disposition-secret"); + }); + classes.erase(removed.begin(), removed.end()); + classes.push_back(css_class_for(value)); + return classes; + }); + + Glib::Binding::bind_property(participant->property_is_active(), + property_css_classes(), + Glib::Binding::Flags::SYNC_CREATE, + [this](auto value) { + auto classes = get_css_classes(); + if (!value) + { + std::erase(classes, "active-participant"); + } + else + { + classes.push_back("active-participant"); + } + return classes; + }); + } + } + + auto ParticipantRow::delete_enabled() -> Glib::PropertyProxy + { + return m_delete_enabled.get_proxy(); + } + + auto ParticipantRow::edit_enabled() -> Glib::PropertyProxy + { + return m_edit_enabled.get_proxy(); + } + + auto ParticipantRow::handle_delete() -> void + { + auto index = Glib::Variant::create(get_index()); + activate_action("win.delete", index); + } + + auto ParticipantRow::handle_edit() -> void + { + auto index = Glib::Variant::create(get_index()); + activate_action("win.edit", index); + } + +} // namespace turns::ui \ No newline at end of file diff --git a/gui/ui/src/participant_row.ui b/gui/ui/src/participant_row.ui new file mode 100644 index 0000000..b53cc53 --- /dev/null +++ b/gui/ui/src/participant_row.ui @@ -0,0 +1,89 @@ + + + + + + + diff --git a/gui/ui/src/preferences.cpp b/gui/ui/src/preferences.cpp new file mode 100644 index 0000000..88e6d0f --- /dev/null +++ b/gui/ui/src/preferences.cpp @@ -0,0 +1,81 @@ +#include "turns/ui/preferences.hpp" + +#include "turns/core/settings.hpp" +#include "turns/ui/template_widget.hpp" + +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace turns::ui +{ + namespace + { + auto constexpr static TYPE_NAME = "Preferences"; + auto constexpr static TEMPLATE = "/ch/arknet/Turns/preferences.ui"; + } // namespace + + Preferences::Preferences(Glib::RefPtr settings) + : Glib::ObjectBase{TYPE_NAME} + , template_widget{TEMPLATE} + , m_settings{settings} + , m_friendly_reset_button{get_widget("friendly_reset_button")} + , m_hostile_reset_button{get_widget("hostile_reset_button")} + , m_secret_reset_button{get_widget("secret_reset_button")} + , m_friendly_color_button{get_widget("friendly_color_button")} + , m_hostile_color_button{get_widget("hostile_color_button")} + , m_secret_color_button{get_widget("secret_color_button")} + , m_skip_defeated{get_widget("skip_defeated")} + { + if (!m_settings) + { + return; + } + + bind_reset(core::settings::key::disposition_friendly_color, m_friendly_reset_button); + bind_setting(core::settings::key::disposition_friendly_color, m_friendly_color_button); + bind_reset(core::settings::key::disposition_hostile_color, m_hostile_reset_button); + bind_setting(core::settings::key::disposition_hostile_color, m_hostile_color_button); + bind_reset(core::settings::key::disposition_secret_color, m_secret_reset_button); + bind_setting(core::settings::key::disposition_secret_color, m_secret_color_button); + + m_settings->bind(core::settings::key::skip_defeated, m_skip_defeated->property_active()); + } + + auto Preferences::bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void + { + m_settings->signal_changed(key).connect([=, this](auto) { update_sensitive(key, button); }); + update_sensitive(key, button); + button->signal_clicked().connect(sigc::bind(sigc::mem_fun(*m_settings, &Gio::Settings::reset), key)); + } + + auto Preferences::bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void + { + m_settings->bind(key, button->property_rgba(), Gio::Settings::BindFlags::DEFAULT, [](auto value) { + return Gdk::RGBA{value}; + }, [](auto color) { return color.to_string(); }); + } + + auto Preferences::update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void + { + auto v = Glib::Variant{}; + button->set_sensitive(m_settings->get_user_value(key, v)); + } + +} // namespace turns::ui::widgets \ No newline at end of file diff --git a/gui/ui/src/preferences.ui b/gui/ui/src/preferences.ui new file mode 100644 index 0000000..0ee2699 --- /dev/null +++ b/gui/ui/src/preferences.ui @@ -0,0 +1,104 @@ + + + + + + + + diff --git a/gui/ui/src/tracker.cpp b/gui/ui/src/tracker.cpp new file mode 100644 index 0000000..d67a6e0 --- /dev/null +++ b/gui/ui/src/tracker.cpp @@ -0,0 +1,255 @@ +#include "turns/ui/tracker.hpp" + +#include "turns/core/settings.hpp" +#include "turns/core/turn_order_model.hpp" +#include "turns/lang/messages.hpp" +#include "turns/ui/template_widget.hpp" +#include "turns/ui/turn_order_view.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace turns::ui +{ + namespace + { + auto constexpr static TYPE_NAME = "Tracker"; + auto constexpr static TEMPLATE = "/ch/arknet/Turns/tracker.ui"; + } // namespace + + Tracker::Tracker() + : Tracker{{}, core::get_settings()} + { + } + + Tracker::Tracker(Glib::RefPtr const & app, Glib::RefPtr const & settings) + : Glib::ObjectBase{TYPE_NAME} + , template_widget{TEMPLATE, app} + , m_controls{get_widget("controls")} + , m_empty{get_widget("empty")} + , m_overlay{get_widget("overlay")} + , m_stack{get_widget("stack")} + , m_start{get_widget("start")} + , m_title{get_widget("title")} + , m_turn_order{core::TurnOderModel::create()} + , m_turn_order_view{Gtk::make_managed(m_turn_order)} + , m_settings{std::move(settings)} + , m_subtitle{m_title->property_subtitle()} + , m_css{Gtk::CssProvider::create()} + { + setup_colors(); + setup_actions(); + + m_stack->add(*m_turn_order_view); + + m_turn_order->is_empty().signal_changed().connect(sigc::mem_fun(*this, &Tracker::update_subtitle)); + m_turn_order->round_number().signal_changed().connect(sigc::mem_fun(*this, &Tracker::update_subtitle)); + update_subtitle(); + + // clang-format off + Glib::Binding::bind_property(m_turn_order->is_empty(), + m_stack->property_visible_child(), + Glib::Binding::Flags::SYNC_CREATE, + [this](auto empty) { return empty ? m_empty : m_turn_order_view; }); + + Glib::Binding::bind_property(m_turn_order->is_running(), + m_controls->property_reveal_child(), + Glib::Binding::Flags::SYNC_CREATE); + // clang-format on + + m_settings->bind("skip-defeated", m_turn_order->skip_defeated()); + } + + auto Tracker::setup_actions() -> void + { + // win.add_participant + // depends-on: turn_order:state == stopped + { + auto action = add_action("add_participant", sigc::mem_fun(*this, &Tracker::add_participant)); + + Glib::Binding::bind_property(m_turn_order->is_running(), + action->property_enabled(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + } + + // win.clear + // depends-on: turn_order:is_empty == false + { + auto action = add_action("clear", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::clear)); + + Glib::Binding::bind_property(m_turn_order->is_empty(), + action->property_enabled(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + } + + // win.next + // depends-on: turn_order:state == running + { + auto action = add_action("next", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::next)); + + Glib::Binding::bind_property(m_turn_order->is_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); + } + + // win.previous + // depends-on: turn_order:has_previous == true + { + auto action = add_action("previous", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::previous)); + + Glib::Binding::bind_property(m_turn_order->has_previous(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); + } + + // win.start + // depends-on: turn_order:is_empty == false + { + auto action = add_action("start", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::start)); + + Glib::Binding::bind_property(m_turn_order->is_empty(), + action->property_enabled(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + + Glib::Binding::bind_property(m_turn_order->is_running(), + m_start->property_visible(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + } + + // win.stop + // depends-on: turn_order:running == true + { + auto action = add_action("stop", sigc::mem_fun(*this, &Tracker::stop)); + + Glib::Binding::bind_property(m_turn_order->is_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); + } + + // win.delete + // win.edit + // win.open + // win.preferences + { + add_action_with_parameter("delete", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &Tracker::delete_participant)); + add_action_with_parameter("edit", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &Tracker::edit_participant)); + add_action("open", sigc::mem_fun(*this, &Tracker::open)); + add_action("preferences", sigc::mem_fun(*this, &Tracker::preferences)); + } + + // win.save + // depends-on: turn_order:is_empty == false + { + auto action = add_action("save", sigc::bind(sigc::mem_fun(*this, &Tracker::save), false)); + + Glib::Binding::bind_property(m_turn_order->is_empty(), + action->property_enabled(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + } + + // win.save-as + // depends-on: turn_order:is_empty == false + { + auto action = add_action("save-as", sigc::bind(sigc::mem_fun(*this, &Tracker::save), true)); + + Glib::Binding::bind_property(m_turn_order->is_empty(), + action->property_enabled(), + Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); + } + } + + auto Tracker::setup_colors() -> void + { + Gtk::CssProvider::add_provider_for_display(get_display(), m_css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + m_settings->signal_changed().connect(sigc::mem_fun(*this, &Tracker::on_settings_changed)); + update_colors(); + } + + auto Tracker::start_replace_content() -> void + { + m_file_buffer = m_turn_order->serialize().dump(2); + m_file->replace_contents_async(sigc::mem_fun(*this, &Tracker::on_replace_content_done), m_file_buffer, m_file_etag); + } + + auto Tracker::show_error(std::exception const & e) -> void + { + auto error = e.what(); + show_toast(std::vformat(_(lang::saving_failed_format), std::make_format_args(error))); + } + + auto Tracker::show_toast(std::string const & message) -> void + { + m_overlay->add_toast(*Adwaita::Toast::create(message)); + } + + auto Tracker::update_colors() -> void + { + auto friendly_color = m_settings->get_string("disposition-color-friendly"); + auto hostile_color = m_settings->get_string("disposition-color-hostile"); + auto secret_color = m_settings->get_string("disposition-color-secret"); + m_css->load_from_string(std::format("@define-color friendly {};\n" + "@define-color hostile {};\n" + "@define-color secret {};\n", + friendly_color.c_str(), + hostile_color.c_str(), + secret_color.c_str())); + } + + auto Tracker::update_subtitle() -> void + { + if (m_turn_order->is_empty()) + { + m_subtitle = _(lang::no_active_turn_order); + } + else + { + auto round_number = m_turn_order->round_number() + 1; + m_subtitle = round_number == 0 ? "" : std::vformat(_(lang::round_number), std::make_format_args(round_number)); + } + } + + auto Tracker::load(Glib::RefPtr file) -> void + { + if (file->query_exists()) + { + m_file = file; + m_file->load_contents_async(sigc::mem_fun(*this, &Tracker::on_load_content_done)); + set_sensitive(false); + } + } + +} // namespace turns::ui diff --git a/gui/ui/src/tracker.ui b/gui/ui/src/tracker.ui new file mode 100644 index 0000000..c4fe324 --- /dev/null +++ b/gui/ui/src/tracker.ui @@ -0,0 +1,153 @@ + + + + + + + + + diff --git a/gui/ui/tests/gtk_test_init.cpp b/gui/ui/tests/gtk_test_init.cpp new file mode 100644 index 0000000..bfa885f --- /dev/null +++ b/gui/ui/tests/gtk_test_init.cpp @@ -0,0 +1,41 @@ +#include "turns/core/init.hpp" +#include "turns/ui/init.hpp" + +#include +#include + +#include + +#include + +#include +#include + +#include + +#include + +namespace turns::ui::tests +{ + + struct gtk_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"); + + [[maybe_unused]] auto app = Adwaita::Application::create("ch.arknet.turns.tests.ui"); + + core::register_types(); + ui::register_types(); + } + }; + + CATCH_REGISTER_LISTENER(gtk_test_init); + +} // namespace turns::ui::tests \ No newline at end of file diff --git a/gui/ui/tests/participant_editor.cpp b/gui/ui/tests/participant_editor.cpp new file mode 100644 index 0000000..fee0313 --- /dev/null +++ b/gui/ui/tests/participant_editor.cpp @@ -0,0 +1,150 @@ +#include "turns/ui/participant_editor.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" +#include "turns/lang/messages.hpp" + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed participant editor without a participant", "[windows]") + { + auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); + setlocale(LC_ALL, locale); + + auto participant = core::Participant::create("Frederick Thumblewackle", 7.2, core::Disposition::Friendly); + auto instance = std::make_shared(nullptr); + auto window = Gtk::Window{}; + + SECTION("was successfully constructed") + { + REQUIRE(instance); + } + + SECTION("has a non-empty title") + { + REQUIRE_FALSE(instance->get_title().empty()); + } + + SECTION("has its title set according to the active language") + { + REQUIRE(instance->get_title() == _(lang::add_participant)); + } + + SECTION("has an empty name") + { + REQUIRE(instance->get_name().empty()); + } + + SECTION("has a zero priority") + { + REQUIRE(instance->get_priority() == 0); + } + + SECTION("has neutral disposition") + { + REQUIRE(instance->get_disposition() == core::Disposition::Neutral); + } + + SECTION("has a null participant") + { + REQUIRE_FALSE(instance->get_participant()); + } + + WHEN("setting a new participant") + { + instance->set_participant(participant); + + THEN("getting the participant returns the new one") + { + REQUIRE(instance->get_participant() == participant); + } + + THEN("changes to the name propagate to the participant") + { + CHECK(participant->get_name() != "REPLACED"); + instance->set_name("REPLACED"); + REQUIRE(participant->get_name() == "REPLACED"); + } + + THEN("changes to the priority propagate to the participant") + { + CHECK(participant->get_priority() != 0); + instance->set_priority(0); + REQUIRE(participant->get_priority() == 0); + } + + THEN("changes to the disposition propagate to the participant") + { + CHECK(participant->get_disposition() != core::Disposition::Secret); + instance->set_disposition(core::Disposition::Secret); + REQUIRE(participant->get_disposition() == core::Disposition::Secret); + } + } + + SECTION("allows binding to the finished signal") + { + REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected()); + } + } + + TEST_CASE("A freshly constructed participant editor with a participant", "[windows]") + { + auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); + setlocale(LC_ALL, locale); + + auto participant = core::Participant::create("Qibi Babblebranch", 12, core::Disposition::Neutral); + auto instance = std::make_shared(participant); + auto window = Gtk::Window{}; + + SECTION("was successfully constructed") + { + REQUIRE(instance); + } + + SECTION("has a non-empty title") + { + REQUIRE_FALSE(instance->get_title().empty()); + } + + SECTION("has its title set according to the active language") + { + REQUIRE(instance->get_title() == _(lang::edit_participant)); + } + + SECTION("has its name field set according to its participant") + { + REQUIRE(instance->get_name() == participant->property_name().get_value()); + } + + SECTION("has its priority field set according to its participant") + { + REQUIRE(instance->get_priority() == participant->property_priority()); + } + + SECTION("allows binding to the finished signal") + { + REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected()); + } + } + +} // namespace turns::ui::tests \ No newline at end of file diff --git a/gui/ui/tests/participant_row.cpp b/gui/ui/tests/participant_row.cpp new file mode 100644 index 0000000..20eaa5c --- /dev/null +++ b/gui/ui/tests/participant_row.cpp @@ -0,0 +1,30 @@ +#include "turns/ui/participant_row.hpp" + +#include "turns/core/disposition.hpp" +#include "turns/core/participant.hpp" + +#include + +#include + +#include + +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed participant row") + { + SECTION("can be created without a participant") + { + REQUIRE(std::make_shared(Glib::RefPtr{})); + } + + SECTION("can be created with a participant") + { + REQUIRE(std::make_shared(core::Participant::create("Tazmyla Fireforge", 13, core::Disposition::Secret))); + } + } + +} // namespace turns::ui::widgets::tests \ No newline at end of file diff --git a/gui/ui/tests/resources.cpp b/gui/ui/tests/resources.cpp new file mode 100644 index 0000000..a091266 --- /dev/null +++ b/gui/ui/tests/resources.cpp @@ -0,0 +1,21 @@ +#include +#include + +#include + +#include + +TEST_CASE("UI resources") +{ + + auto file = GENERATE("/ch/arknet/Turns/participant_editor.ui", + "/ch/arknet/Turns/participant_row.ui", + "/ch/arknet/Turns/preferences.ui", + "/ch/arknet/Turns/tracker.ui", + "/ch/arknet/Turns/turn_order_view.ui"); + + SECTION(std::format("contains {}", file)) + { + REQUIRE(Gio::Resource::get_file_exists_global_nothrow(file)); + } +} diff --git a/gui/ui/tests/tracker.cpp b/gui/ui/tests/tracker.cpp new file mode 100644 index 0000000..0d5e983 --- /dev/null +++ b/gui/ui/tests/tracker.cpp @@ -0,0 +1,79 @@ +#include "turns/ui/tracker.hpp" + +#include "turns/core/settings.hpp" +#include "turns/lang/messages.hpp" + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +namespace turns::ui::tests +{ + + TEST_CASE("A freshly constructed tracker window", "[windows]") + { + auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); + setlocale(LC_ALL, locale); + + auto app = Adwaita::Application::create("ch.arknet.Turns.test"); + auto instance = std::make_shared(app, core::get_settings()); + + SECTION("was successfully constructed") + { + REQUIRE(instance); + } + + // SECTION("has a non-empty subtitle") + // { + // auto widget = instance->get_ builder->get_widget("title"); + // REQUIRE_FALSE(widget->get_subtitle().empty()); + // } + + // SECTION("has its subtitle set according to the active language") + // { + // auto widget = builder->get_widget("title"); + // REQUIRE(widget->get_subtitle() == _(lang::no_active_turn_order)); + // } + + // SECTION("has a non-empty title") + // { + // auto widget = builder->get_widget("title"); + // REQUIRE_FALSE(widget->get_title().empty()); + // } + + // SECTION("has its title set according to the active language") + // { + // auto widget = builder->get_widget("title"); + // REQUIRE(widget->get_title() == _(lang::turns)); + // } + + // SECTION("has its add_participant button's tooltip set according to the active language") + // { + // auto widget = builder->get_widget("add_participant"); + // REQUIRE(widget->get_tooltip_text() == _(lang::add_participant)); + // } + + // SECTION("as its open_main_menu button's tooltip set according to the active language") + // { + // auto widget = builder->get_widget("open_main_menu"); + // REQUIRE(widget->get_tooltip_text() == _(lang::main_menu)); + // } + + // instance->destroy(); + // delete instance; + } + +} // namespace turns::ui::tests \ No newline at end of file diff --git a/gui/ui/ui.cmb b/gui/ui/ui.cmb new file mode 100644 index 0000000..b246448 --- /dev/null +++ b/gui/ui/ui.cmb @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt deleted file mode 100644 index 1842615..0000000 --- a/lang/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -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 - "$<$,$>:--coverage>" -) - -catch_discover_tests("lang-tests") \ No newline at end of file diff --git a/lang/include/turns/lang/messages.hpp b/lang/include/turns/lang/messages.hpp deleted file mode 100644 index e57fce4..0000000 --- a/lang/include/turns/lang/messages.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#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/lang/po/de.po b/lang/po/de.po deleted file mode 100644 index 15c2d72..0000000 --- a/lang/po/de.po +++ /dev/null @@ -1,132 +0,0 @@ -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/lang/po/de_CH.po b/lang/po/de_CH.po deleted file mode 100644 index e79f91e..0000000 --- a/lang/po/de_CH.po +++ /dev/null @@ -1,12 +0,0 @@ -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/lang/po/en.po b/lang/po/en.po deleted file mode 100644 index 54df09f..0000000 --- a/lang/po/en.po +++ /dev/null @@ -1,132 +0,0 @@ -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/lang/tests/intl_test_init.cpp b/lang/tests/intl_test_init.cpp deleted file mode 100644 index 5438179..0000000 --- a/lang/tests/intl_test_init.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -#include - -#include - -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/lang/tests/messages.cpp b/lang/tests/messages.cpp deleted file mode 100644 index cecb038..0000000 --- a/lang/tests/messages.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "turns/lang/messages.hpp" - -#include -#include - -#include - -#include -#include -#include - -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/lib/LICENSES/LGPL-2.1-only.txt b/lib/LICENSES/LGPL-2.1-only.txt deleted file mode 100644 index c6487f4..0000000 --- a/lib/LICENSES/LGPL-2.1-only.txt +++ /dev/null @@ -1,176 +0,0 @@ -GNU LESSER GENERAL PUBLIC LICENSE - -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. - -When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. - -For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. - -In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. - -The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - -GNU LESSER GENERAL PUBLIC LICENSE -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". - -A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. - -The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) - -"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. - -(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - -Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. - -This option is useful when you wish to copy part of the code of the Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. - -If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. - -However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. - -When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. - -If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) - -Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. - -You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. - - e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. - -For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. - -10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - -14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - one line to give the library's name and an idea of what it does. - Copyright (C) year name of author - - This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/style/CMakeLists.txt b/style/CMakeLists.txt deleted file mode 100644 index 8ddbae8..0000000 --- a/style/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_library("style") - -add_library("turns::style" ALIAS "style") - -target_add_glib_resources("style" - PREFIX "ch/arknet/Turns" - CSS_FILES - "style.css" - "style-dark.css" -) - -target_link_libraries("style" PUBLIC - "PkgConfig::giomm" - PRIVATE - "$<$,$>:gcov>" -) - -enable_coverage("style") diff --git a/style/style-dark.css b/style/style-dark.css deleted file mode 100644 index 928264a..0000000 --- a/style/style-dark.css +++ /dev/null @@ -1,32 +0,0 @@ -@define-color hostile #e01b24; -@define-color friendly #33d17a; -@define-color secret #9141ac; - - -.disposition-hostile { - background-color: mix(shade(@hostile, 0.8), @window_bg_color, 0.5); -} - -:checked.disposition-hostile { - background-color: mix(shade(@hostile, 0.5), @window_bg_color, 0.5); -} - -.disposition-friendly { - background-color: mix(shade(@friendly, 0.8), @window_bg_color, 0.5); -} - -:checked.disposition-friendly { - background-color: mix(shade(@friendly, 0.5), @window_bg_color, 0.5); -} - -.disposition-secret { - background-color: mix(shade(@secret, 0.8), @window_bg_color, 0.5); -} - -:checked.disposition-secret { - background-color: mix(shade(@secret, 0.5), @window_bg_color, 0.5); -} - -.active-participant { - background-color: mix(shade(@accent_bg_color, 0.5), @card_bg_color, 0.5); -} \ No newline at end of file diff --git a/style/style.css b/style/style.css deleted file mode 100644 index a185c9b..0000000 --- a/style/style.css +++ /dev/null @@ -1,31 +0,0 @@ -@define-color hostile #e01b24; -@define-color friendly #33d17a; -@define-color secret #9141ac; - -.disposition-hostile { - background-color: mix(shade(@hostile, 1.6), @window_bg_color, 0.5); -} - -:checked.disposition-hostile { - background-color: mix(shade(@hostile, 1), @window_bg_color, 0.5); -} - -.disposition-friendly { - background-color: mix(shade(@friendly, 1.6), @window_bg_color, 0.5); -} - -:checked.disposition-friendly { - background-color: mix(shade(@friendly, 1), @window_bg_color, 0.5); -} - -.disposition-secret { - background-color: mix(shade(@secret, 1.6), @window_bg_color, 0.5); -} - -:checked.disposition-secret { - background-color: mix(shade(@secret, 1), @window_bg_color, 0.5); -} - -.active-participant { - background-color: mix(shade(@accent_bg_color, 1.5), @card_bg_color, 0.5); -} \ No newline at end of file diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt deleted file mode 100644 index 1584479..0000000 --- a/ui/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Library - -file(GLOB_RECURSE UI_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src" CONFIGURE_DEPENDS "*.ui") -file(GLOB_RECURSE UI_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "src/*.cpp") -file(GLOB_RECURSE UI_TESTS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" CONFIGURE_DEPENDS "tests/*.cpp") - -add_library("ui" ${UI_SOURCES}) -add_library("turns::ui" ALIAS "ui") - -target_compile_options("ui" PUBLIC - "$<$:-Wall>" - "$<$:-Wextra>" - "$<$:-Werror>" - "$<$:-pedantic-errors>" -) - -target_include_directories("ui" PUBLIC - "include" -) - -target_link_libraries("ui" PUBLIC - "turns::core" - "turns::lang" - - "adwaitamm::adwaitamm" - "PkgConfig::gtkmm" -) - -target_add_glib_resources("ui" - PREFIX "/ch/arknet/Turns/" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" - UI_FILES ${UI_FILES} -) - -enable_coverage("ui") - -# Tests - -get_target_property(TRANSLATIONS_BINARY_DIR "lang" BINARY_DIR) - -add_executable("ui-tests" ${UI_TESTS}) - -target_compile_definitions("ui-tests" PUBLIC - "TESTLOCALEDIR=\"${TRANSLATIONS_BINARY_DIR}\"" -) - -target_link_libraries("ui-tests" PRIVATE - "Catch2::Catch2WithMain" - - "$<$:-Wl,--whole-archive>" - "turns::ui" - "$<$:-Wl,--no-whole-archive>" -) - -target_link_options("ui-tests" PRIVATE - "$<$,$>:--coverage>" -) - -catch_discover_tests("ui-tests") diff --git a/ui/include/turns/ui/fwd.hpp b/ui/include/turns/ui/fwd.hpp deleted file mode 100644 index 69dc0b5..0000000 --- a/ui/include/turns/ui/fwd.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef TURNS_UI_WIDGETS_FWD_HPP -#define TURNS_UI_WIDGETS_FWD_HPP - -namespace turns::ui::widgets -{ - struct participant_editor; - struct participant_row; - struct preferences; - struct tracker; - struct turn_order_view; - struct preferences; -} // namespace turns::ui::widgets - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/init.hpp b/ui/include/turns/ui/init.hpp deleted file mode 100644 index 77bd009..0000000 --- a/ui/include/turns/ui/init.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef TURNS_UI_INIT_HPP -#define TURNS_UI_INIT_HPP - -#include - -#include - -namespace turns::ui -{ - - auto register_types() -> void; - -} // namespace turns::ui - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/participant_editor.hpp b/ui/include/turns/ui/participant_editor.hpp deleted file mode 100644 index 0fbc504..0000000 --- a/ui/include/turns/ui/participant_editor.hpp +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef TURNS_UI_PARTICIPANT_EDITOR_HPP -#define TURNS_UI_PARTICIPANT_EDITOR_HPP - -#include "turns/core/disposition.hpp" -#include "turns/core/fwd.hpp" -#include "turns/core/participant.hpp" -#include "turns/ui/template_widget.hpp" - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace turns::ui -{ - - struct ParticipantEditor : template_widget - { - using SignalFinishedType = sigc::signal; - - auto constexpr inline static children = std::array{ - "disposition", - "finish", - "name", - "priority", - }; - - explicit ParticipantEditor(Glib::RefPtr participant); - - [[nodiscard]] auto get_disposition() const -> core::Disposition; - [[nodiscard]] auto get_name() const -> Glib::ustring; - [[nodiscard]] auto get_participant() const -> Glib::RefPtr; - [[nodiscard]] auto get_priority() const -> double; - - auto set_disposition(core::Disposition value) -> void; - auto set_name(Glib::ustring const & value) -> void; - auto set_participant(Glib::RefPtr const & value) -> void; - auto set_priority(double value) -> void; - - [[nodiscard]] auto property_participant() -> Glib::PropertyProxy>; - [[nodiscard]] auto property_participant() const -> Glib::PropertyProxy_ReadOnly>; - - auto signal_finished() -> SignalFinishedType; - - private: - auto handle_finish_clicked() -> void; - auto handle_item_bind(Glib::RefPtr item) -> void; - auto handle_item_setup(Glib::RefPtr item) -> void; - auto handle_participant_changed() -> void; - - Adwaita::ComboRow * m_disposition; - Gtk::Button * m_finish; - Adwaita::EntryRow * m_name; - Adwaita::SpinRow * m_priority; - - Glib::RefPtr m_disposition_factory; - Glib::RefPtr m_disposition_model; - - Glib::Property> m_participant; - - SignalFinishedType m_signal_finished{}; - }; - -} // namespace turns::ui - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/participant_row.hpp b/ui/include/turns/ui/participant_row.hpp deleted file mode 100644 index 561214b..0000000 --- a/ui/include/turns/ui/participant_row.hpp +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef TURNS_UI_PARTICIPANT_ROW_HPP -#define TURNS_UI_PARTICIPANT_ROW_HPP - -#include "turns/core/fwd.hpp" -#include "turns/ui/template_widget.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace turns::ui -{ - struct ParticipantRow : template_widget - { - auto constexpr inline static children = std::array{ - "delete", - "edit", - "subtitle", - "title", - "toggle_defeated", - }; - - ParticipantRow(Glib::RefPtr participant); - - auto delete_enabled() -> Glib::PropertyProxy; - auto edit_enabled() -> Glib::PropertyProxy; - - private: - auto handle_delete() -> void; - auto handle_edit() -> void; - - Gtk::Button * m_delete; - Gtk::Button * m_edit; - Gtk::Label * m_subtitle; - Gtk::Label * m_title; - Gtk::ToggleButton * m_toggle_defeated; - - Glib::Property m_delete_enabled; - Glib::Property m_edit_enabled; - }; -} // namespace turns::ui::widgets - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/preferences.hpp b/ui/include/turns/ui/preferences.hpp deleted file mode 100644 index b68b91c..0000000 --- a/ui/include/turns/ui/preferences.hpp +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef TURNS_UI_PREFERENCES_HPP -#define TURNS_UI_PREFERENCES_HPP - -#include "turns/ui/template_widget.hpp" - -#include -#include - -#include - -#include -#include - -#include -#include - -#include - -namespace turns::ui -{ - struct Preferences : template_widget - { - - auto constexpr inline static children = std::array{ - "friendly_reset_button", - "hostile_reset_button", - "secret_reset_button", - "friendly_color_button", - "hostile_color_button", - "secret_color_button", - "skip_defeated", - }; - - explicit Preferences(Glib::RefPtr settings = {}); - - private: - auto bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void; - auto bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void; - auto update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void; - - Glib::RefPtr m_settings; - - Gtk::Button * m_friendly_reset_button{}; - Gtk::Button * m_hostile_reset_button{}; - Gtk::Button * m_secret_reset_button{}; - Gtk::ColorDialogButton * m_friendly_color_button{}; - Gtk::ColorDialogButton * m_hostile_color_button{}; - Gtk::ColorDialogButton * m_secret_color_button{}; - Adwaita::SwitchRow * m_skip_defeated{}; - }; -} // namespace turns::ui::widgets - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/template_widget.hpp b/ui/include/turns/ui/template_widget.hpp deleted file mode 100644 index 7147560..0000000 --- a/ui/include/turns/ui/template_widget.hpp +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef TURNS_UI_TEMPLATE_WIDGET_HPP -#define TURNS_UI_TEMPLATE_WIDGET_HPP - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -namespace turns::ui -{ - - template - struct template_widget : Glib::ExtraClassInit, - BaseWidgetType - { - template - template_widget(Glib::ustring && resource_path, BaseWidgetCtorArgTypes &&... base_widget_ctor_args) - : Glib::ExtraClassInit{class_init, &resource_path, instance_init} - , BaseWidgetType{std::forward(base_widget_ctor_args)...} - { - } - - protected: - template - auto get_widget(char const * name) -> WidgetType * - { - auto self = static_cast(this); - auto widget = GTK_WIDGET(Glib::unwrap(self)); - auto type = G_OBJECT_TYPE(Glib::unwrap(self)); - auto child = GTK_WIDGET(gtk_widget_get_template_child(widget, type, name)); - g_assert_nonnull(child); - return dynamic_cast(Glib::wrap(child)); - } - - private: - auto static class_init(void * g_class, void * g_class_data) -> void - { - g_return_if_fail(GTK_IS_WIDGET_CLASS(g_class)); - - auto resource_path = static_cast(g_class_data); - - gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(g_class), resource_path->c_str()); - - std::ranges::for_each(CustomWidgetType::children, [g_class](auto const & child) { - gtk_widget_class_bind_template_child_full(GTK_WIDGET_CLASS(g_class), child, false, 0); - }); - } - - auto static instance_init(GTypeInstance * instance, void * /* type_class */) -> void - { - g_return_if_fail(GTK_IS_WIDGET(instance)); - - gtk_widget_init_template(GTK_WIDGET(instance)); - } - }; - -} // namespace turns::ui::widgets - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/tracker.hpp b/ui/include/turns/ui/tracker.hpp deleted file mode 100644 index 2e3adf5..0000000 --- a/ui/include/turns/ui/tracker.hpp +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef TURNS_UI_TRACKER_HPP -#define TURNS_UI_TRACKER_HPP - -#include "turns/core/turn_order_model.hpp" -#include "turns/ui/template_widget.hpp" -#include "turns/ui/turn_order_view.hpp" - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace turns::ui -{ - - struct Tracker : template_widget - { - auto constexpr inline static children = std::array{ - "controls", - "empty", - "overlay", - "stack", - "start", - "title", - }; - - Tracker(Glib::RefPtr const & app, Glib::RefPtr const & settings); - - auto load(Glib::RefPtr file) -> void; - - private: - friend auto register_types() -> void; - Tracker(); - - /** Setup */ - auto setup_actions() -> void; - auto setup_colors() -> void; - - /** Actions */ - auto add_participant() -> void; - auto delete_participant(Glib::VariantBase param) -> void; - auto edit_participant(Glib::VariantBase param) -> void; - auto open() -> void; - auto preferences() -> void; - auto save(bool force_ask) -> void; - auto stop() -> void; - - /** Event Handlers */ - auto on_open_response(Glib::RefPtr result, Glib::RefPtr dialog) -> void; - auto on_save_response(Glib::RefPtr result, Glib::RefPtr dialog) -> void; - auto on_load_content_done(Glib::RefPtr result) -> void; - auto on_replace_content_done(Glib::RefPtr result) -> void; - auto on_settings_changed(Glib::ustring key) -> void; - - /** Helpers */ - auto show_error(std::exception const & e) -> void; - auto show_toast(std::string const & message) -> void; - auto start_replace_content() -> void; - auto update_colors() -> void; - auto update_subtitle() -> void; - - Gtk::Revealer * m_controls; - Gtk::Widget * m_empty; - Adwaita::ToastOverlay * m_overlay; - Gtk::Stack * m_stack; - Gtk::Button * m_start; - Adwaita::WindowTitle * m_title; - Glib::RefPtr m_turn_order; - TurnOrderView * m_turn_order_view; - Glib::RefPtr m_settings{}; - Glib::PropertyProxy m_subtitle; - - Glib::RefPtr m_file{}; - std::string m_file_etag{}; - std::string m_file_buffer{}; - - Glib::RefPtr m_css{}; - }; - -} // namespace turns::ui - -#endif \ No newline at end of file diff --git a/ui/include/turns/ui/turn_order_view.hpp b/ui/include/turns/ui/turn_order_view.hpp deleted file mode 100644 index 8dae4e4..0000000 --- a/ui/include/turns/ui/turn_order_view.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef TURNS_UI_TURN_ORDER_VIEW_HPP -#define TURNS_UI_TURN_ORDER_VIEW_HPP - -#include "turns/core/fwd.hpp" -#include "turns/core/turn_order_model.hpp" -#include "turns/ui/template_widget.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace turns::ui -{ - struct TurnOrderView : template_widget - { - using model_type = core::TurnOderModel; - - auto constexpr inline static children = std::array{ - "progress", - "view", - }; - - explicit TurnOrderView(Glib::RefPtr model = {}); - - private: - auto handle_create_row(Glib::RefPtr const item) -> Gtk::Widget *; - - Glib::RefPtr m_model; - Gtk::ProgressBar * m_progress; - Gtk::ListBox * m_view; - }; -} // namespace turns::ui::widgets - -#endif \ No newline at end of file diff --git a/ui/src/init.cpp b/ui/src/init.cpp deleted file mode 100644 index 1c0295a..0000000 --- a/ui/src/init.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "turns/ui/init.hpp" - -#include "turns/ui/participant_editor.hpp" -#include "turns/ui/participant_row.hpp" -#include "turns/ui/preferences.hpp" -#include "turns/ui/tracker.hpp" -#include "turns/ui/turn_order_view.hpp" -#include -#include - -namespace turns::ui -{ - - auto register_types() -> void - { - static_cast(ParticipantEditor{{}}); - static_cast(ParticipantRow{{}}); - static_cast(Preferences{{}}); - static_cast(Tracker{}); - static_cast(TurnOrderView{{}}); - } - -} // namespace turns::ui \ No newline at end of file diff --git a/ui/src/participant_editor.cpp b/ui/src/participant_editor.cpp deleted file mode 100644 index 8c83559..0000000 --- a/ui/src/participant_editor.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "turns/ui/participant_editor.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" -#include "turns/lang/messages.hpp" -#include "turns/ui/template_widget.hpp" - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace turns::ui -{ - namespace - { - auto constexpr static TYPE_NAME = "ParticipantEditor"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_editor.ui"; - } // namespace - - ParticipantEditor::ParticipantEditor(Glib::RefPtr participant) - : Glib::ObjectBase{TYPE_NAME} - , template_widget{TEMPLATE} - , m_disposition{get_widget("disposition")} - , m_finish{get_widget("finish")} - , m_name{get_widget("name")} - , m_priority{get_widget("priority")} - , m_disposition_factory{Gtk::SignalListItemFactory::create()} - , m_disposition_model{Gtk::StringList::create()} - , m_participant{*this, "participant", nullptr} - { - m_finish->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_finish_clicked)); - - for (auto n : std::views::iota(std::uint8_t{}, static_cast(core::Disposition::END))) - { - m_disposition_model->append(presentation_name_for(core::Disposition{n})); - } - - m_disposition_factory->signal_bind().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_item_bind)); - m_disposition_factory->signal_setup().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_item_setup)); - - m_disposition->set_factory(m_disposition_factory); - m_disposition->set_model(m_disposition_model); - - property_participant().signal_changed().connect(sigc::mem_fun(*this, &ParticipantEditor::handle_participant_changed)); - - set_participant(participant); - } - - auto ParticipantEditor::get_disposition() const -> core::Disposition - { - return static_cast(m_disposition->get_selected()); - } - - auto ParticipantEditor::get_name() const -> Glib::ustring - { - return m_name->get_text(); - } - - auto ParticipantEditor::get_participant() const -> Glib::RefPtr - { - return m_participant.get_value(); - } - - auto ParticipantEditor::get_priority() const -> double - { - return m_priority->get_value(); - } - - auto ParticipantEditor::set_disposition(core::Disposition value) -> void - { - m_disposition->set_selected(static_cast(value)); - } - - auto ParticipantEditor::set_name(Glib::ustring const & value) -> void - { - m_name->set_text(value); - } - - auto ParticipantEditor::set_participant(Glib::RefPtr const & value) -> void - { - m_participant.set_value(value); - } - - auto ParticipantEditor::set_priority(double value) -> void - { - m_priority->set_value(value); - } - - auto ParticipantEditor::property_participant() -> Glib::PropertyProxy> - { - return m_participant.get_proxy(); - } - - auto ParticipantEditor::property_participant() const -> Glib::PropertyProxy_ReadOnly> - { - return m_participant.get_proxy(); - } - - auto ParticipantEditor::signal_finished() -> SignalFinishedType - { - return m_signal_finished; - } - - auto ParticipantEditor::handle_finish_clicked() -> void - { - m_signal_finished.emit(m_name->get_text(), m_priority->get_value(), static_cast(m_disposition->get_selected())); - close(); - } - - auto ParticipantEditor::handle_item_bind(Glib::RefPtr item) -> void - { - auto value = std::dynamic_pointer_cast(item->get_item())->get_string(); - dynamic_cast(item->get_child())->set_label(value); - } - - auto ParticipantEditor::handle_item_setup(Glib::RefPtr item) -> void - { - item->set_child(*Gtk::make_managed()); - } - - auto ParticipantEditor::handle_participant_changed() -> void - { - auto value = m_participant.get_value(); - set_title(_(value ? lang::edit_participant : lang::add_participant)); - if (value) - { - Glib::Binding::bind_property(value->property_name(), - m_name->property_text(), - Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE); - Glib::Binding::bind_property(value->property_priority(), - m_priority->property_value(), - Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE); - Glib::Binding::bind_property(value->property_disposition(), - m_disposition->property_selected(), - Glib::Binding::Flags::BIDIRECTIONAL | Glib::Binding::Flags::SYNC_CREATE, - [](auto value) { return static_cast(value); }, - [](auto value) { return static_cast(value); }); - } - } - -} // namespace turns::ui \ No newline at end of file diff --git a/ui/src/participant_editor.ui b/ui/src/participant_editor.ui deleted file mode 100644 index 6bcf83e..0000000 --- a/ui/src/participant_editor.ui +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - diff --git a/ui/src/participant_row.cpp b/ui/src/participant_row.cpp deleted file mode 100644 index 7ce8e53..0000000 --- a/ui/src/participant_row.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "turns/ui/participant_row.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" -#include "turns/lang/messages.hpp" -#include "turns/ui/template_widget.hpp" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -namespace turns::ui -{ - namespace - { - auto constexpr static TYPE_NAME = "ParticipantRow"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/participant_row.ui"; - - auto css_class_for(core::Disposition value) -> Glib::ustring - { - switch (value) - { - case core::Disposition::Friendly: - return "disposition-friendly"; - case core::Disposition::Hostile: - return "disposition-hostile"; - case core::Disposition::Secret: - return "disposition-secret"; - default: - return ""; - } - } - } // namespace - - ParticipantRow::ParticipantRow(Glib::RefPtr participant) - : Glib::ObjectBase(TYPE_NAME) - , template_widget{TEMPLATE} - , m_delete{get_widget("delete")} - , m_edit{get_widget("edit")} - , m_subtitle{get_widget("subtitle")} - , m_title{get_widget("title")} - , m_toggle_defeated{get_widget("toggle_defeated")} - , m_delete_enabled{*this, "delete-enabled", true} - , m_edit_enabled{*this, "edit-enabled", true} - - { - m_delete->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantRow::handle_delete)); - m_edit->signal_clicked().connect(sigc::mem_fun(*this, &ParticipantRow::handle_edit)); - - Glib::Binding::bind_property(m_subtitle->property_label(), - m_subtitle->property_visible(), - Glib::Binding::Flags::DEFAULT, - sigc::mem_fun(&Glib::ustring::size)); - Glib::Binding::bind_property(m_title->property_label(), - m_title->property_visible(), - Glib::Binding::Flags::INVERT_BOOLEAN, - sigc::mem_fun(&Glib::ustring::size)); - Glib::Binding::bind_property(m_toggle_defeated->property_active(), - m_toggle_defeated->property_icon_name(), - Glib::Binding::Flags::SYNC_CREATE, - [](auto active) { return active ? "face-sick-symbolic" : "face-smile-symbolic"; }); - - // clang-format off - Glib::Binding::bind_property(delete_enabled(), - m_delete->property_sensitive(), - Glib::Binding::Flags::SYNC_CREATE); - Glib::Binding::bind_property(edit_enabled(), - m_edit->property_sensitive(), - Glib::Binding::Flags::SYNC_CREATE); - // clang-format on - - if (participant) - { - Glib::Binding::bind_property(participant->property_name(), m_title->property_label(), Glib::Binding::Flags::SYNC_CREATE); - - Glib::Binding::bind_property(participant->property_priority(), - m_subtitle->property_label(), - Glib::Binding::Flags::SYNC_CREATE, - [](auto n) { return std::vformat(_(lang::priority_number), std::make_format_args(n)); }); - - Glib::Binding::bind_property(participant->property_disposition(), - m_toggle_defeated->property_css_classes(), - Glib::Binding::Flags::SYNC_CREATE, - [this](auto value) { - auto classes = m_toggle_defeated->get_css_classes(); - auto removed = std::ranges::remove_if(classes, [](auto cls) { - return (cls == "disposition-friendly") | (cls == "disposition-hostile") || (cls == "disposition-secret"); - }); - classes.erase(removed.begin(), removed.end()); - classes.push_back(css_class_for(value)); - return classes; - }); - - Glib::Binding::bind_property(participant->property_is_active(), - property_css_classes(), - Glib::Binding::Flags::SYNC_CREATE, - [this](auto value) { - auto classes = get_css_classes(); - if (!value) - { - std::erase(classes, "active-participant"); - } - else - { - classes.push_back("active-participant"); - } - return classes; - }); - } - } - - auto ParticipantRow::delete_enabled() -> Glib::PropertyProxy - { - return m_delete_enabled.get_proxy(); - } - - auto ParticipantRow::edit_enabled() -> Glib::PropertyProxy - { - return m_edit_enabled.get_proxy(); - } - - auto ParticipantRow::handle_delete() -> void - { - auto index = Glib::Variant::create(get_index()); - activate_action("win.delete", index); - } - - auto ParticipantRow::handle_edit() -> void - { - auto index = Glib::Variant::create(get_index()); - activate_action("win.edit", index); - } - -} // namespace turns::ui \ No newline at end of file diff --git a/ui/src/participant_row.ui b/ui/src/participant_row.ui deleted file mode 100644 index b53cc53..0000000 --- a/ui/src/participant_row.ui +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - diff --git a/ui/src/preferences.cpp b/ui/src/preferences.cpp deleted file mode 100644 index 88e6d0f..0000000 --- a/ui/src/preferences.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "turns/ui/preferences.hpp" - -#include "turns/core/settings.hpp" -#include "turns/ui/template_widget.hpp" - -#include -#include - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -namespace turns::ui -{ - namespace - { - auto constexpr static TYPE_NAME = "Preferences"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/preferences.ui"; - } // namespace - - Preferences::Preferences(Glib::RefPtr settings) - : Glib::ObjectBase{TYPE_NAME} - , template_widget{TEMPLATE} - , m_settings{settings} - , m_friendly_reset_button{get_widget("friendly_reset_button")} - , m_hostile_reset_button{get_widget("hostile_reset_button")} - , m_secret_reset_button{get_widget("secret_reset_button")} - , m_friendly_color_button{get_widget("friendly_color_button")} - , m_hostile_color_button{get_widget("hostile_color_button")} - , m_secret_color_button{get_widget("secret_color_button")} - , m_skip_defeated{get_widget("skip_defeated")} - { - if (!m_settings) - { - return; - } - - bind_reset(core::settings::key::disposition_friendly_color, m_friendly_reset_button); - bind_setting(core::settings::key::disposition_friendly_color, m_friendly_color_button); - bind_reset(core::settings::key::disposition_hostile_color, m_hostile_reset_button); - bind_setting(core::settings::key::disposition_hostile_color, m_hostile_color_button); - bind_reset(core::settings::key::disposition_secret_color, m_secret_reset_button); - bind_setting(core::settings::key::disposition_secret_color, m_secret_color_button); - - m_settings->bind(core::settings::key::skip_defeated, m_skip_defeated->property_active()); - } - - auto Preferences::bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void - { - m_settings->signal_changed(key).connect([=, this](auto) { update_sensitive(key, button); }); - update_sensitive(key, button); - button->signal_clicked().connect(sigc::bind(sigc::mem_fun(*m_settings, &Gio::Settings::reset), key)); - } - - auto Preferences::bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void - { - m_settings->bind(key, button->property_rgba(), Gio::Settings::BindFlags::DEFAULT, [](auto value) { - return Gdk::RGBA{value}; - }, [](auto color) { return color.to_string(); }); - } - - auto Preferences::update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void - { - auto v = Glib::Variant{}; - button->set_sensitive(m_settings->get_user_value(key, v)); - } - -} // namespace turns::ui::widgets \ No newline at end of file diff --git a/ui/src/preferences.ui b/ui/src/preferences.ui deleted file mode 100644 index 0ee2699..0000000 --- a/ui/src/preferences.ui +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - diff --git a/ui/src/tracker.cpp b/ui/src/tracker.cpp deleted file mode 100644 index d67a6e0..0000000 --- a/ui/src/tracker.cpp +++ /dev/null @@ -1,255 +0,0 @@ -#include "turns/ui/tracker.hpp" - -#include "turns/core/settings.hpp" -#include "turns/core/turn_order_model.hpp" -#include "turns/lang/messages.hpp" -#include "turns/ui/template_widget.hpp" -#include "turns/ui/turn_order_view.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace turns::ui -{ - namespace - { - auto constexpr static TYPE_NAME = "Tracker"; - auto constexpr static TEMPLATE = "/ch/arknet/Turns/tracker.ui"; - } // namespace - - Tracker::Tracker() - : Tracker{{}, core::get_settings()} - { - } - - Tracker::Tracker(Glib::RefPtr const & app, Glib::RefPtr const & settings) - : Glib::ObjectBase{TYPE_NAME} - , template_widget{TEMPLATE, app} - , m_controls{get_widget("controls")} - , m_empty{get_widget("empty")} - , m_overlay{get_widget("overlay")} - , m_stack{get_widget("stack")} - , m_start{get_widget("start")} - , m_title{get_widget("title")} - , m_turn_order{core::TurnOderModel::create()} - , m_turn_order_view{Gtk::make_managed(m_turn_order)} - , m_settings{std::move(settings)} - , m_subtitle{m_title->property_subtitle()} - , m_css{Gtk::CssProvider::create()} - { - setup_colors(); - setup_actions(); - - m_stack->add(*m_turn_order_view); - - m_turn_order->is_empty().signal_changed().connect(sigc::mem_fun(*this, &Tracker::update_subtitle)); - m_turn_order->round_number().signal_changed().connect(sigc::mem_fun(*this, &Tracker::update_subtitle)); - update_subtitle(); - - // clang-format off - Glib::Binding::bind_property(m_turn_order->is_empty(), - m_stack->property_visible_child(), - Glib::Binding::Flags::SYNC_CREATE, - [this](auto empty) { return empty ? m_empty : m_turn_order_view; }); - - Glib::Binding::bind_property(m_turn_order->is_running(), - m_controls->property_reveal_child(), - Glib::Binding::Flags::SYNC_CREATE); - // clang-format on - - m_settings->bind("skip-defeated", m_turn_order->skip_defeated()); - } - - auto Tracker::setup_actions() -> void - { - // win.add_participant - // depends-on: turn_order:state == stopped - { - auto action = add_action("add_participant", sigc::mem_fun(*this, &Tracker::add_participant)); - - Glib::Binding::bind_property(m_turn_order->is_running(), - action->property_enabled(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - } - - // win.clear - // depends-on: turn_order:is_empty == false - { - auto action = add_action("clear", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::clear)); - - Glib::Binding::bind_property(m_turn_order->is_empty(), - action->property_enabled(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - } - - // win.next - // depends-on: turn_order:state == running - { - auto action = add_action("next", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::next)); - - Glib::Binding::bind_property(m_turn_order->is_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); - } - - // win.previous - // depends-on: turn_order:has_previous == true - { - auto action = add_action("previous", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::previous)); - - Glib::Binding::bind_property(m_turn_order->has_previous(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); - } - - // win.start - // depends-on: turn_order:is_empty == false - { - auto action = add_action("start", sigc::mem_fun(*m_turn_order, &core::TurnOderModel::start)); - - Glib::Binding::bind_property(m_turn_order->is_empty(), - action->property_enabled(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - - Glib::Binding::bind_property(m_turn_order->is_running(), - m_start->property_visible(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - } - - // win.stop - // depends-on: turn_order:running == true - { - auto action = add_action("stop", sigc::mem_fun(*this, &Tracker::stop)); - - Glib::Binding::bind_property(m_turn_order->is_running(), action->property_enabled(), Glib::Binding::Flags::SYNC_CREATE); - } - - // win.delete - // win.edit - // win.open - // win.preferences - { - add_action_with_parameter("delete", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &Tracker::delete_participant)); - add_action_with_parameter("edit", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &Tracker::edit_participant)); - add_action("open", sigc::mem_fun(*this, &Tracker::open)); - add_action("preferences", sigc::mem_fun(*this, &Tracker::preferences)); - } - - // win.save - // depends-on: turn_order:is_empty == false - { - auto action = add_action("save", sigc::bind(sigc::mem_fun(*this, &Tracker::save), false)); - - Glib::Binding::bind_property(m_turn_order->is_empty(), - action->property_enabled(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - } - - // win.save-as - // depends-on: turn_order:is_empty == false - { - auto action = add_action("save-as", sigc::bind(sigc::mem_fun(*this, &Tracker::save), true)); - - Glib::Binding::bind_property(m_turn_order->is_empty(), - action->property_enabled(), - Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN); - } - } - - auto Tracker::setup_colors() -> void - { - Gtk::CssProvider::add_provider_for_display(get_display(), m_css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - m_settings->signal_changed().connect(sigc::mem_fun(*this, &Tracker::on_settings_changed)); - update_colors(); - } - - auto Tracker::start_replace_content() -> void - { - m_file_buffer = m_turn_order->serialize().dump(2); - m_file->replace_contents_async(sigc::mem_fun(*this, &Tracker::on_replace_content_done), m_file_buffer, m_file_etag); - } - - auto Tracker::show_error(std::exception const & e) -> void - { - auto error = e.what(); - show_toast(std::vformat(_(lang::saving_failed_format), std::make_format_args(error))); - } - - auto Tracker::show_toast(std::string const & message) -> void - { - m_overlay->add_toast(*Adwaita::Toast::create(message)); - } - - auto Tracker::update_colors() -> void - { - auto friendly_color = m_settings->get_string("disposition-color-friendly"); - auto hostile_color = m_settings->get_string("disposition-color-hostile"); - auto secret_color = m_settings->get_string("disposition-color-secret"); - m_css->load_from_string(std::format("@define-color friendly {};\n" - "@define-color hostile {};\n" - "@define-color secret {};\n", - friendly_color.c_str(), - hostile_color.c_str(), - secret_color.c_str())); - } - - auto Tracker::update_subtitle() -> void - { - if (m_turn_order->is_empty()) - { - m_subtitle = _(lang::no_active_turn_order); - } - else - { - auto round_number = m_turn_order->round_number() + 1; - m_subtitle = round_number == 0 ? "" : std::vformat(_(lang::round_number), std::make_format_args(round_number)); - } - } - - auto Tracker::load(Glib::RefPtr file) -> void - { - if (file->query_exists()) - { - m_file = file; - m_file->load_contents_async(sigc::mem_fun(*this, &Tracker::on_load_content_done)); - set_sensitive(false); - } - } - -} // namespace turns::ui diff --git a/ui/src/tracker.ui b/ui/src/tracker.ui deleted file mode 100644 index c4fe324..0000000 --- a/ui/src/tracker.ui +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - diff --git a/ui/tests/gtk_test_init.cpp b/ui/tests/gtk_test_init.cpp deleted file mode 100644 index bfa885f..0000000 --- a/ui/tests/gtk_test_init.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "turns/core/init.hpp" -#include "turns/ui/init.hpp" - -#include -#include - -#include - -#include - -#include -#include - -#include - -#include - -namespace turns::ui::tests -{ - - struct gtk_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"); - - [[maybe_unused]] auto app = Adwaita::Application::create("ch.arknet.turns.tests.ui"); - - core::register_types(); - ui::register_types(); - } - }; - - CATCH_REGISTER_LISTENER(gtk_test_init); - -} // namespace turns::ui::tests \ No newline at end of file diff --git a/ui/tests/participant_editor.cpp b/ui/tests/participant_editor.cpp deleted file mode 100644 index fee0313..0000000 --- a/ui/tests/participant_editor.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "turns/ui/participant_editor.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" -#include "turns/lang/messages.hpp" - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -namespace turns::ui::tests -{ - - TEST_CASE("A freshly constructed participant editor without a participant", "[windows]") - { - auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); - setlocale(LC_ALL, locale); - - auto participant = core::Participant::create("Frederick Thumblewackle", 7.2, core::Disposition::Friendly); - auto instance = std::make_shared(nullptr); - auto window = Gtk::Window{}; - - SECTION("was successfully constructed") - { - REQUIRE(instance); - } - - SECTION("has a non-empty title") - { - REQUIRE_FALSE(instance->get_title().empty()); - } - - SECTION("has its title set according to the active language") - { - REQUIRE(instance->get_title() == _(lang::add_participant)); - } - - SECTION("has an empty name") - { - REQUIRE(instance->get_name().empty()); - } - - SECTION("has a zero priority") - { - REQUIRE(instance->get_priority() == 0); - } - - SECTION("has neutral disposition") - { - REQUIRE(instance->get_disposition() == core::Disposition::Neutral); - } - - SECTION("has a null participant") - { - REQUIRE_FALSE(instance->get_participant()); - } - - WHEN("setting a new participant") - { - instance->set_participant(participant); - - THEN("getting the participant returns the new one") - { - REQUIRE(instance->get_participant() == participant); - } - - THEN("changes to the name propagate to the participant") - { - CHECK(participant->get_name() != "REPLACED"); - instance->set_name("REPLACED"); - REQUIRE(participant->get_name() == "REPLACED"); - } - - THEN("changes to the priority propagate to the participant") - { - CHECK(participant->get_priority() != 0); - instance->set_priority(0); - REQUIRE(participant->get_priority() == 0); - } - - THEN("changes to the disposition propagate to the participant") - { - CHECK(participant->get_disposition() != core::Disposition::Secret); - instance->set_disposition(core::Disposition::Secret); - REQUIRE(participant->get_disposition() == core::Disposition::Secret); - } - } - - SECTION("allows binding to the finished signal") - { - REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected()); - } - } - - TEST_CASE("A freshly constructed participant editor with a participant", "[windows]") - { - auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); - setlocale(LC_ALL, locale); - - auto participant = core::Participant::create("Qibi Babblebranch", 12, core::Disposition::Neutral); - auto instance = std::make_shared(participant); - auto window = Gtk::Window{}; - - SECTION("was successfully constructed") - { - REQUIRE(instance); - } - - SECTION("has a non-empty title") - { - REQUIRE_FALSE(instance->get_title().empty()); - } - - SECTION("has its title set according to the active language") - { - REQUIRE(instance->get_title() == _(lang::edit_participant)); - } - - SECTION("has its name field set according to its participant") - { - REQUIRE(instance->get_name() == participant->property_name().get_value()); - } - - SECTION("has its priority field set according to its participant") - { - REQUIRE(instance->get_priority() == participant->property_priority()); - } - - SECTION("allows binding to the finished signal") - { - REQUIRE((instance->signal_finished().connect([](auto, auto, auto) {})).connected()); - } - } - -} // namespace turns::ui::tests \ No newline at end of file diff --git a/ui/tests/participant_row.cpp b/ui/tests/participant_row.cpp deleted file mode 100644 index 20eaa5c..0000000 --- a/ui/tests/participant_row.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "turns/ui/participant_row.hpp" - -#include "turns/core/disposition.hpp" -#include "turns/core/participant.hpp" - -#include - -#include - -#include - -#include - -namespace turns::ui::tests -{ - - TEST_CASE("A freshly constructed participant row") - { - SECTION("can be created without a participant") - { - REQUIRE(std::make_shared(Glib::RefPtr{})); - } - - SECTION("can be created with a participant") - { - REQUIRE(std::make_shared(core::Participant::create("Tazmyla Fireforge", 13, core::Disposition::Secret))); - } - } - -} // namespace turns::ui::widgets::tests \ No newline at end of file diff --git a/ui/tests/resources.cpp b/ui/tests/resources.cpp deleted file mode 100644 index a091266..0000000 --- a/ui/tests/resources.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include - -#include - -#include - -TEST_CASE("UI resources") -{ - - auto file = GENERATE("/ch/arknet/Turns/participant_editor.ui", - "/ch/arknet/Turns/participant_row.ui", - "/ch/arknet/Turns/preferences.ui", - "/ch/arknet/Turns/tracker.ui", - "/ch/arknet/Turns/turn_order_view.ui"); - - SECTION(std::format("contains {}", file)) - { - REQUIRE(Gio::Resource::get_file_exists_global_nothrow(file)); - } -} diff --git a/ui/tests/tracker.cpp b/ui/tests/tracker.cpp deleted file mode 100644 index 0d5e983..0000000 --- a/ui/tests/tracker.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "turns/ui/tracker.hpp" - -#include "turns/core/settings.hpp" -#include "turns/lang/messages.hpp" - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace turns::ui::tests -{ - - TEST_CASE("A freshly constructed tracker window", "[windows]") - { - auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8"); - setlocale(LC_ALL, locale); - - auto app = Adwaita::Application::create("ch.arknet.Turns.test"); - auto instance = std::make_shared(app, core::get_settings()); - - SECTION("was successfully constructed") - { - REQUIRE(instance); - } - - // SECTION("has a non-empty subtitle") - // { - // auto widget = instance->get_ builder->get_widget("title"); - // REQUIRE_FALSE(widget->get_subtitle().empty()); - // } - - // SECTION("has its subtitle set according to the active language") - // { - // auto widget = builder->get_widget("title"); - // REQUIRE(widget->get_subtitle() == _(lang::no_active_turn_order)); - // } - - // SECTION("has a non-empty title") - // { - // auto widget = builder->get_widget("title"); - // REQUIRE_FALSE(widget->get_title().empty()); - // } - - // SECTION("has its title set according to the active language") - // { - // auto widget = builder->get_widget("title"); - // REQUIRE(widget->get_title() == _(lang::turns)); - // } - - // SECTION("has its add_participant button's tooltip set according to the active language") - // { - // auto widget = builder->get_widget("add_participant"); - // REQUIRE(widget->get_tooltip_text() == _(lang::add_participant)); - // } - - // SECTION("as its open_main_menu button's tooltip set according to the active language") - // { - // auto widget = builder->get_widget("open_main_menu"); - // REQUIRE(widget->get_tooltip_text() == _(lang::main_menu)); - // } - - // instance->destroy(); - // delete instance; - } - -} // namespace turns::ui::tests \ No newline at end of file diff --git a/ui/ui.cmb b/ui/ui.cmb deleted file mode 100644 index b246448..0000000 --- a/ui/ui.cmb +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - -- cgit v1.2.3