diff --git a/CHANGELOG.md b/CHANGELOG.md index b8966e7..3d05ec6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog Conspiratio.Lib +## 3.1.0 + +_01.01.2026_ + +**[DE]** +- Kleinere Refaktorisierungen des `NewGameManagers` +- Refaktorisierung: Benenne `ITextAnzeigen` um in `IShowText` +- Füge Resource Datei für statische, übersetzbare Texte hinzu (bisher mit deutsch und englisch als Sprache) + +**[EN]** +- Small refactorings of `NewGameManagers` +- Refactoring: Rename `ITextAnzeigen` to `IShowText` +- Added a resource file for static localizable text (until now with german and english as languages) + ## 3.0.0 _23.12.2024_ diff --git a/Conspiratio.Lib/Allgemein/IShowText.cs b/Conspiratio.Lib/Allgemein/IShowText.cs new file mode 100644 index 0000000..639ffa9 --- /dev/null +++ b/Conspiratio.Lib/Allgemein/IShowText.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Conspiratio.Lib.Allgemein +{ + public interface IShowText + { + Task ShowDialog(string text); + } +} \ No newline at end of file diff --git a/Conspiratio.Lib/Allgemein/ITextAnzeigen.cs b/Conspiratio.Lib/Allgemein/ITextAnzeigen.cs deleted file mode 100644 index 3a9ac12..0000000 --- a/Conspiratio.Lib/Allgemein/ITextAnzeigen.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Conspiratio.Lib.Allgemein -{ - public interface ITextAnzeigen - { - void ShowDialog(string text); - } -} \ No newline at end of file diff --git a/Conspiratio.Lib/Allgemein/NewGameManager.cs b/Conspiratio.Lib/Allgemein/NewGameManager.cs index 99ed7bc..795f43b 100644 --- a/Conspiratio.Lib/Allgemein/NewGameManager.cs +++ b/Conspiratio.Lib/Allgemein/NewGameManager.cs @@ -2,17 +2,35 @@ using Conspiratio.Lib.Gameplay.Spielwelt; +using JetBrains.Annotations; + namespace Conspiratio.Lib.Allgemein { public class NewGameManager { - private string _savegamePath; + private readonly string _savegamePath; public NewGameManager(string savegamePath) { _savegamePath = savegamePath; } + [PublicAPI] + public int MaxLengthOfGameName + { + get + { + string savegamePathWithFilename = Path.Combine(_savegamePath, "_1600.dat"); + int savegamePathLength = savegamePathWithFilename.Length; + int maxlength = 256 - savegamePathLength; + + if (maxlength < 0) // fallback from settings (standard: 12), if savegame path is longer then 256 chars + maxlength = SW.Statisch.GetMaxNameLength(); + + return maxlength; + } + } + public bool CreateNewGame(string name, int playerCount, bool cheating, bool showDeaths, bool testmode, out string error) { if (!ValidateName(name, out error)) @@ -27,9 +45,10 @@ public bool CreateNewGame(string name, int playerCount, bool cheating, bool show return true; } + [PublicAPI] public bool ValidateName(string name, out string error) { - error = "Der Spielname muss aus mindestens drei Zeichen bestehen"; + error = Resources.The_game_name_must_consist_of_at_least_three_characters; if (string.IsNullOrEmpty(name)) return false; @@ -40,25 +59,19 @@ public bool ValidateName(string name, out string error) error = ""; return true; } - + + [PublicAPI] public string SanitizeName(string name) { - string savegamePathWithFilename = Path.Combine(_savegamePath, "_1600.dat"); - int savegamePathLength = savegamePathWithFilename.Length; - int maxlength = 256 - savegamePathLength; - - if (maxlength < 0) // fallback from settings (standard: 12), if savegame path is longer then 256 chars - maxlength = SW.Statisch.GetMaxNameLength(); - name = RemoveInvalidChars(name); - if (name.Length > maxlength) - return name.Substring(0, maxlength); + if (name.Length > MaxLengthOfGameName) + return name.Substring(0, MaxLengthOfGameName); return name; } - private string RemoveInvalidChars(string filename) + private static string RemoveInvalidChars(string filename) { return string.Concat(filename.Split(Path.GetInvalidFileNameChars())); } diff --git a/Conspiratio.Lib/Allgemein/UIHelper.cs b/Conspiratio.Lib/Allgemein/UIHelper.cs index 7bf93b6..fb94a38 100644 --- a/Conspiratio.Lib/Allgemein/UIHelper.cs +++ b/Conspiratio.Lib/Allgemein/UIHelper.cs @@ -6,7 +6,7 @@ public class UIHelper { public IYesNoQuestion YesNoQuestion { get; private set; } - public ITextAnzeigen TextAnzeigen { get; private set; } + public IShowText ShowText { get; private set; } public IBeziehungPflegen BeziehungPflegen { get; private set; } @@ -22,12 +22,12 @@ public class UIHelper public IUntergebeneDialog UntergebeneDialog { get; private set; } - public void Initialisieren(IYesNoQuestion yesNoQuestion, ITextAnzeigen textAnzeigen, IBeziehungPflegen beziehungPflegen, IBauwerkStiftenDialog bauwerkStiftenDialog, + public void Initialisieren(IYesNoQuestion yesNoQuestion, IShowText showText, IBeziehungPflegen beziehungPflegen, IBauwerkStiftenDialog bauwerkStiftenDialog, IFestGebenDialog festGebenDialog, IPolitischeWeltkarteDialog politischeWeltkarteDialog, ITestamentAnzeigenDialog testamentAnzeigenDialog, IProzentwertFestlegenDialog prozentwertFestlegenDialog, IUntergebeneDialog untergebeneDialog) { YesNoQuestion = yesNoQuestion; - TextAnzeigen = textAnzeigen; + ShowText = showText; BeziehungPflegen = beziehungPflegen; BauwerkStiftenDialog = bauwerkStiftenDialog; FestGebenDialog = festGebenDialog; diff --git a/Conspiratio.Lib/Conspiratio.Lib.csproj b/Conspiratio.Lib/Conspiratio.Lib.csproj index 9c85d27..d17fb76 100644 --- a/Conspiratio.Lib/Conspiratio.Lib.csproj +++ b/Conspiratio.Lib/Conspiratio.Lib.csproj @@ -13,15 +13,31 @@ \ + + + ResXFileCodeGenerator + Resources.de.Designer.cs + + + + + True + True + Resources.resx + + + + + - 3.0.0 - 3.0.0 + 3.1.0 + 3.1.0 A library with gameplay logic for the free and open-source game Conspiratio True - $(AssemblyVersion) + 3.1.0 $(AssemblyName) Conspiratio - Copyright © 2011-2024 + Copyright © 2011-2025 https://www.conspiratio.net icon.png conspiratio;game;library diff --git a/Conspiratio.Lib/Gameplay/Spielwelt/DynamischeSpieldaten.cs b/Conspiratio.Lib/Gameplay/Spielwelt/DynamischeSpieldaten.cs index 7997ac8..3597f30 100644 --- a/Conspiratio.Lib/Gameplay/Spielwelt/DynamischeSpieldaten.cs +++ b/Conspiratio.Lib/Gameplay/Spielwelt/DynamischeSpieldaten.cs @@ -2791,7 +2791,7 @@ private void SpielerKlagtXAn(int iAngeklagter) #region BelTextAnzeigen public void BelTextAnzeigen(string text) { - SW.UI.TextAnzeigen.ShowDialog(text); + SW.UI.ShowText.ShowDialog(text); } #endregion diff --git a/Conspiratio.Lib/Resources.Designer.cs b/Conspiratio.Lib/Resources.Designer.cs new file mode 100644 index 0000000..23915aa --- /dev/null +++ b/Conspiratio.Lib/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Conspiratio.Lib { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Conspiratio.Lib.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Der Spielname muss aus mindestens drei Zeichen bestehen. + /// + internal static string The_game_name_must_consist_of_at_least_three_characters { + get { + return ResourceManager.GetString("The game name must consist of at least three characters", resourceCulture); + } + } + } +} diff --git a/Conspiratio.Lib/Resources.en.resx b/Conspiratio.Lib/Resources.en.resx new file mode 100644 index 0000000..bd01558 --- /dev/null +++ b/Conspiratio.Lib/Resources.en.resx @@ -0,0 +1,17 @@ + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The game name must consist of at least three characters + + \ No newline at end of file diff --git a/Conspiratio.Lib/Resources.resx b/Conspiratio.Lib/Resources.resx new file mode 100644 index 0000000..d87f721 --- /dev/null +++ b/Conspiratio.Lib/Resources.resx @@ -0,0 +1,24 @@ + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Der Spielname muss aus mindestens drei Zeichen bestehen + + \ No newline at end of file