mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Discord Plugin Profile Name Column Changes
1. Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.
This commit is contained in:
parent
eaa7876ab4
commit
fce9a3e65f
10 changed files with 212 additions and 24 deletions
|
|
@ -148,7 +148,7 @@ namespace ServerManagerTool.Plugin.Common
|
|||
File.Delete(pluginFile);
|
||||
}
|
||||
|
||||
internal IList<Profile> FetchProfileList()
|
||||
public IList<Profile> FetchProfileList()
|
||||
{
|
||||
lock (_syncLockFetchProfiles)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
<sys:String x:Key="ConfigProfileWindow_BotNameTooltip">This will override the name you setup in your webhook. Leave blank to use default.</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_UseTTSLabel">Use Text to Speech (TTS)</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_UseTTSTooltip">If enabled, will make the bot announce with Text to Speech, otherwise will turn off Text to Speech.</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_PrefixMessageWithProfileNameLabel">Prefix Message with Server Manager Profile Name</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_PrefixMessageWithProfileNameLabel">Prefix Message with Profile Name</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_PrefixMessageWithProfileNameTooltip">If enabled, the alert message will be sent prefixed with the server manager profile name.</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_MessageOptionsLabel">Message Options</sys:String>
|
||||
<sys:String x:Key="ConfigProfileWindow_MessageOptionsBoldLabel">Bold</sys:String>
|
||||
|
|
|
|||
56
Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItem.cs
Normal file
56
Plugins/Discord/source/Plugin.Discord/Models/ComboBoxItem.cs
Normal file
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace ServerManagerTool.Plugin.Discord
|
||||
{
|
||||
public class ComboBoxItemList : ObservableCollection<ComboBoxItem>
|
||||
{
|
||||
public ComboBoxItemList()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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")]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,30 @@
|
|||
<title>Discord Plugin Version Feed</title>
|
||||
<subtitle>This is the Discord Plugin release version feed.</subtitle>
|
||||
<link href="" />
|
||||
<updated>2020-06-12T00:00:01Z</updated>
|
||||
<updated>2020-07-13T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8</id>
|
||||
<title>1.0.17 (1.0.17.1)</title>
|
||||
<summary>1.0.17.1</summary>
|
||||
<link href="" />
|
||||
<updated>2020-07-13T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||
<p>
|
||||
<u style="font-size: .9em;">CHANGE</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:A7158CB1-C5B2-4505-B171-CDD54918B227</id>
|
||||
|
|
|
|||
|
|
@ -5,22 +5,21 @@
|
|||
<title>Discord Plugin Version Feed</title>
|
||||
<subtitle>This is the Discord Plugin beta version feed.</subtitle>
|
||||
<link href="" />
|
||||
<updated>2020-06-12T00:00:01Z</updated>
|
||||
<updated>2020-07-13T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:A7158CB1-C5B2-4505-B171-CDD54918B227</id>
|
||||
<title>1.0.16 (1.0.16.1)</title>
|
||||
<summary>1.0.16.1</summary>
|
||||
<id>urn:uuid:D8974ABF-8444-4D40-A594-D4443921B3B8</id>
|
||||
<title>1.0.17 (1.0.17.1)</title>
|
||||
<summary>1.0.17.1</summary>
|
||||
<link href="" />
|
||||
<updated>2020-06-12T00:00:01Z</updated>
|
||||
<updated>2020-07-13T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||
<p>
|
||||
<u style="font-size: .9em;">BUGFIX</u>
|
||||
<u style="font-size: .9em;">CHANGE</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Added url encoding so that special characters are sent to the webhook correctly.</li>
|
||||
<li>Changed the text encoding from ASCII to UTF8, so that unicode languages should work correctly.</li>
|
||||
<li>Profile name has been converted to a droplist and is now populated with the Server Manager Profile Names for selection.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<Window.Resources>
|
||||
|
|
@ -150,11 +150,17 @@
|
|||
</DataGrid.VerticalGridLinesBrush>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Width="*" Binding="{Binding Value}">
|
||||
<DataGridTextColumn.Header>
|
||||
<TextBlock Text="{DynamicResource ConfigProfileWindow_ProfileNameColumnLabel}"/>
|
||||
</DataGridTextColumn.Header>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTemplateColumn Width="*" CanUserSort="True" SortMemberPath="DisplayName">
|
||||
<DataGridTemplateColumn.Header>
|
||||
<TextBlock Text="{DynamicResource ConfigProfileWindow_ProfileNameColumnLabel}" />
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox IsEditable="True" ItemsSource="{Binding ProfileList, ElementName=ConfigProfileUI}" SelectedValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=Explicit}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" GotFocus="ComboBox_GotFocus" LostFocus="ComboBox_LostFocus" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="30" CanUserReorder="False" IsReadOnly="True">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -210,6 +216,7 @@
|
|||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="30" CanUserReorder="False" IsReadOnly="True">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue