diff --git a/Plugins/Discord/source/Plugin.Common/PluginHelper.cs b/Plugins/Discord/source/Plugin.Common/PluginHelper.cs index 962f105e..7319b613 100644 --- a/Plugins/Discord/source/Plugin.Common/PluginHelper.cs +++ b/Plugins/Discord/source/Plugin.Common/PluginHelper.cs @@ -148,7 +148,7 @@ namespace ServerManagerTool.Plugin.Common File.Delete(pluginFile); } - internal IList FetchProfileList() + public IList FetchProfileList() { lock (_syncLockFetchProfiles) { diff --git a/Plugins/Discord/source/Plugin.Common/Properties/AssemblyInfo.cs b/Plugins/Discord/source/Plugin.Common/Properties/AssemblyInfo.cs index a2f6d9b1..85c7ac95 100644 --- a/Plugins/Discord/source/Plugin.Common/Properties/AssemblyInfo.cs +++ b/Plugins/Discord/source/Plugin.Common/Properties/AssemblyInfo.cs @@ -33,8 +33,3 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.1.0")] [assembly: AssemblyFileVersion("1.0.1.0")] - -[assembly: InternalsVisibleTo("ARK Server Manager")] -[assembly: InternalsVisibleTo("ConanServerManager")] -[assembly: InternalsVisibleTo("ServerManager")] -[assembly: InternalsVisibleTo("ServerManager.Plugin.Common.UnitTests")] diff --git a/Plugins/Discord/source/Plugin.Discord/Globalization/en-US/en-US.xaml b/Plugins/Discord/source/Plugin.Discord/Globalization/en-US/en-US.xaml index 8b6f079e..7e86cb25 100644 --- a/Plugins/Discord/source/Plugin.Discord/Globalization/en-US/en-US.xaml +++ b/Plugins/Discord/source/Plugin.Discord/Globalization/en-US/en-US.xaml @@ -61,7 +61,7 @@ This will override the name you setup in your webhook. Leave blank to use default. Use Text to Speech (TTS) If enabled, will make the bot announce with Text to Speech, otherwise will turn off Text to Speech. - Prefix Message with Server Manager Profile Name + Prefix Message with Profile Name If enabled, the alert message will be sent prefixed with the server manager profile name. Message Options Bold diff --git a/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItem.cs b/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItem.cs new file mode 100644 index 00000000..8cc71d5d --- /dev/null +++ b/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItem.cs @@ -0,0 +1,56 @@ +using System.Windows; + +namespace ServerManagerTool.Plugin.Discord +{ + public class ComboBoxItem : DependencyObject + { + public static readonly DependencyProperty ValueMemberProperty = DependencyProperty.Register(nameof(ValueMember), typeof(string), typeof(ComboBoxItem), new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty DisplayMemberProperty = DependencyProperty.Register(nameof(DisplayMember), typeof(string), typeof(ComboBoxItem), new PropertyMetadata(string.Empty)); + public static readonly DependencyProperty GroupMemberProperty = DependencyProperty.Register(nameof(GroupMember), typeof(string), typeof(ComboBoxItem), new PropertyMetadata(string.Empty)); + + public ComboBoxItem() + { + } + + public ComboBoxItem(string valueMember, string displayMember) + { + ValueMember = valueMember; + DisplayMember = displayMember; + } + + public ComboBoxItem(string valueMember, string displayMember, string groupMember) + { + ValueMember = valueMember; + DisplayMember = displayMember; + GroupMember = groupMember; + } + + public string ValueMember + { + get { return (string)GetValue(ValueMemberProperty); } + set { SetValue(ValueMemberProperty, value); } + } + + public string DisplayMember + { + get { return (string)GetValue(DisplayMemberProperty); } + set { SetValue(DisplayMemberProperty, value); } + } + + public string GroupMember + { + get { return (string)GetValue(GroupMemberProperty); } + set { SetValue(GroupMemberProperty, value); } + } + + public ComboBoxItem Duplicate() + { + return new ComboBoxItem + { + DisplayMember = this.DisplayMember, + ValueMember = this.ValueMember, + GroupMember = this.GroupMember, + }; + } + } +} diff --git a/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItemList.cs b/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItemList.cs new file mode 100644 index 00000000..eb0c490c --- /dev/null +++ b/Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItemList.cs @@ -0,0 +1,11 @@ +using System.Collections.ObjectModel; + +namespace ServerManagerTool.Plugin.Discord +{ + public class ComboBoxItemList : ObservableCollection + { + public ComboBoxItemList() + { + } + } +} diff --git a/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs b/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs index e63e3f68..6cfb03ee 100644 --- a/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs +++ b/Plugins/Discord/source/Plugin.Discord/Properties/AssemblyInfo.cs @@ -30,5 +30,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.16.1")] -[assembly: AssemblyFileVersion("1.0.16.1")] +[assembly: AssemblyVersion("1.0.17.1")] +[assembly: AssemblyFileVersion("1.0.17.1")] diff --git a/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml b/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml index d2ece481..9b8651ab 100644 --- a/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml +++ b/Plugins/Discord/source/Plugin.Discord/VersionFeed.xml @@ -5,7 +5,30 @@ Discord Plugin Version Feed This is the Discord Plugin release version feed. - 2020-06-12T00:00:01Z + 2020-07-13T00:00:00Z + + + urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8 + 1.0.17 (1.0.17.1) + 1.0.17.1 + + 2020-07-13T00:00:00Z + +
+

+ CHANGE +
+

    +
  • Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.
  • +
+

+
+
+ + bletch + bletch1971@hotmail.com + +
urn:uuid:A7158CB1-C5B2-4505-B171-CDD54918B227 diff --git a/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml b/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml index 1c08b222..eae3c759 100644 --- a/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml +++ b/Plugins/Discord/source/Plugin.Discord/VersionFeedBeta.xml @@ -5,22 +5,21 @@ Discord Plugin Version Feed This is the Discord Plugin beta version feed. - 2020-06-12T00:00:01Z + 2020-07-13T00:00:00Z - urn:uuid:A7158CB1-C5B2-4505-B171-CDD54918B227 - 1.0.16 (1.0.16.1) - 1.0.16.1 + urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8 + 1.0.17 (1.0.17.1) + 1.0.17.1 - 2020-06-12T00:00:01Z + 2020-07-13T00:00:00Z

- BUGFIX + CHANGE

    -
  • Added url encoding so that special characters are sent to the webhook correctly.
  • -
  • Changed the text encoding from ASCII to UTF8, so that unicode languages should work correctly.
  • +
  • Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.

diff --git a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml index d28bd268..7b2b4b4d 100644 --- a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml +++ b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:pc="clr-namespace:ServerManagerTool.Plugin.Common;assembly=ServerManager.Plugin.Common" - Title="{DynamicResource ConfigProfileWindow_Title}" + Name="ConfigProfileUI" Title="{DynamicResource ConfigProfileWindow_Title}" Icon="/ServerManager.Plugin.Discord;component/Art/favicon.ico" Width="640" Height="520" MinWidth="640" MinHeight="480" ResizeMode="CanResizeWithGrip" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" Closing="ConfigProfileWindow_Closing"> @@ -150,11 +150,17 @@ - - - - - + + + + + + + + + + + @@ -210,6 +216,7 @@ + diff --git a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml.cs b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml.cs index 4199e97f..1a9d84da 100644 --- a/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml.cs +++ b/Plugins/Discord/source/Plugin.Discord/Windows/ConfigProfileWindow.xaml.cs @@ -2,9 +2,11 @@ using System; using System.ComponentModel; using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Input; namespace ServerManagerTool.Plugin.Discord.Windows @@ -15,6 +17,7 @@ namespace ServerManagerTool.Plugin.Discord.Windows public partial class ConfigProfileWindow : Window { private static readonly DependencyProperty ProfileProperty = DependencyProperty.Register(nameof(Profile), typeof(ConfigProfile), typeof(ConfigProfileWindow)); + private static readonly DependencyProperty ProfileListProperty = DependencyProperty.Register(nameof(ProfileList), typeof(ComboBoxItemList), typeof(ConfigProfileWindow)); internal ConfigProfileWindow(DiscordPlugin plugin, ConfigProfile profile) { @@ -23,6 +26,8 @@ namespace ServerManagerTool.Plugin.Discord.Windows this.Profile = profile.Clone(); this.Profile.CommitChanges(); + RefreshProfileList(); + InitializeComponent(); if (plugin.BetaEnabled) @@ -49,6 +54,12 @@ namespace ServerManagerTool.Plugin.Discord.Windows set; } + private ComboBoxItemList ProfileList + { + get { return GetValue(ProfileListProperty) as ComboBoxItemList; } + set { SetValue(ProfileListProperty, value); } + } + private void ConfigProfileWindow_Closing(object sender, CancelEventArgs e) { if (DialogResult.HasValue && DialogResult.Value) @@ -219,5 +230,91 @@ namespace ServerManagerTool.Plugin.Discord.Windows MessageBox.Show(ResourceUtils.GetResourceString(this.Resources, "ConfigProfileWindow_DeleteProfileNameErrorLabel"), ResourceUtils.GetResourceString(this.Resources, "ConfigProfileWindow_DeleteErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error); } } + + private void ComboBox_GotFocus(object sender, RoutedEventArgs e) + { + var comboBox = sender as ComboBox; + if (comboBox == null) + return; + + try + { + comboBox.BeginInit(); + } + finally + { + comboBox.EndInit(); + } + } + + private void ComboBox_LostFocus(object sender, RoutedEventArgs e) + { + var comboBox = sender as ComboBox; + if (comboBox == null) + return; + + if (comboBox.SelectedItem == null) + { + var text = comboBox.Text; + + if (!string.IsNullOrWhiteSpace(text)) + { + var source = comboBox.ItemsSource as ComboBoxItemList; + source?.Add(new ComboBoxItem + { + ValueMember = text, + DisplayMember = text, + }); + } + + comboBox.SelectedValue = text; + } + + var expression = comboBox.GetBindingExpression(Selector.SelectedValueProperty); + expression?.UpdateSource(); + + expression = comboBox.GetBindingExpression(ComboBox.TextProperty); + expression?.UpdateSource(); + } + + private void RefreshProfileList() + { + var newList = new ComboBoxItemList(); + newList.Add(new ComboBoxItem + { + ValueMember = string.Empty, + DisplayMember = string.Empty, + }); + + try + { + foreach (var profile in PluginHelper.Instance.FetchProfileList()) + { + newList.Add(new ComboBoxItem + { + ValueMember = profile.ProfileName, + DisplayMember = $"* {profile.ProfileName}", + }); + } + } + catch + { + // do nothing, most likely they are using an older version of a server manager + } + + foreach (var profile in Profile.ProfileNames) + { + if (!newList.Any(p => p.ValueMember.Equals(profile.Value, StringComparison.OrdinalIgnoreCase))) + { + newList.Add(new ComboBoxItem + { + ValueMember = profile.Value, + DisplayMember = profile.Value, + }); + } + } + + this.ProfileList = newList; + } } }