mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Changed config type of Whitelist to use custom class
This commit is contained in:
parent
a74bc2dc78
commit
197fd1a811
11 changed files with 34 additions and 52 deletions
|
|
@ -849,11 +849,6 @@
|
|||
<setting name="ServerMonitorWindow_Top" serializeAs="String">
|
||||
<value>50</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotWhitelist" serializeAs="Xml">
|
||||
<value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
|
||||
</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotPrefixFixed" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ namespace ServerManagerTool
|
|||
};
|
||||
if (Config.Default.DiscordBotWhitelist != null)
|
||||
{
|
||||
config.DiscordBotWhitelist.AddRange(Config.Default.DiscordBotWhitelist.Cast<string>());
|
||||
config.DiscordBotWhitelist.AddRange(Config.Default.DiscordBotWhitelist);
|
||||
}
|
||||
|
||||
await ServerManagerBotFactory.GetServerManagerBot().RunAsync(config, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSourceDiscordBot.Token);
|
||||
|
|
|
|||
6
src/ARKServerManager/Config.Designer.cs
generated
6
src/ARKServerManager/Config.Designer.cs
generated
|
|
@ -2977,11 +2977,9 @@ namespace ServerManagerTool {
|
|||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />")]
|
||||
public global::System.Collections.Specialized.StringCollection DiscordBotWhitelist {
|
||||
public global::ServerManagerTool.DiscordBot.Models.DiscordBotWhitelist DiscordBotWhitelist {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["DiscordBotWhitelist"]));
|
||||
return ((global::ServerManagerTool.DiscordBot.Models.DiscordBotWhitelist)(this["DiscordBotWhitelist"]));
|
||||
}
|
||||
set {
|
||||
this["DiscordBotWhitelist"] = value;
|
||||
|
|
|
|||
|
|
@ -821,9 +821,8 @@
|
|||
<Setting Name="ServerMonitorWindow_Top" Type="System.Double" Scope="User">
|
||||
<Value Profile="(Default)">50</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotWhitelist" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /></Value>
|
||||
<Setting Name="DiscordBotWhitelist" Type="ServerManagerTool.DiscordBot.Models.DiscordBotWhitelist" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotPrefixFixed" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace ServerManagerTool
|
|||
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelist>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelistItem>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
|
||||
public GlobalSettingsControl()
|
||||
{
|
||||
|
|
@ -51,13 +51,10 @@ namespace ServerManagerTool
|
|||
PopulateWindowsStatesComboBox();
|
||||
PopulateDiscordBotLogLevelsComboBox();
|
||||
|
||||
DiscordBotWhitelist = new List<DiscordBotWhitelist>();
|
||||
DiscordBotWhitelist = new List<DiscordBotWhitelistItem>();
|
||||
if (Config.DiscordBotWhitelist != null)
|
||||
{
|
||||
foreach (var item in Config.DiscordBotWhitelist)
|
||||
{
|
||||
DiscordBotWhitelist.Add(new DiscordBotWhitelist() { BotId = item });
|
||||
}
|
||||
DiscordBotWhitelist.AddRange(Config.DiscordBotWhitelist.Select(i => new DiscordBotWhitelistItem() { BotId = i }));
|
||||
}
|
||||
|
||||
this.DataContext = this;
|
||||
|
|
@ -105,19 +102,21 @@ namespace ServerManagerTool
|
|||
set { SetValue(DiscordBotLogLevelsProperty, value); }
|
||||
}
|
||||
|
||||
public List<DiscordBotWhitelist> DiscordBotWhitelist
|
||||
public List<DiscordBotWhitelistItem> DiscordBotWhitelist
|
||||
{
|
||||
get { return (List<DiscordBotWhitelist>)GetValue(DiscordBotWhitelistProperty); }
|
||||
get { return (List<DiscordBotWhitelistItem>)GetValue(DiscordBotWhitelistProperty); }
|
||||
set { SetValue(DiscordBotWhitelistProperty, value); }
|
||||
}
|
||||
|
||||
public void ApplyChangesToConfig()
|
||||
{
|
||||
if (Config.DiscordBotWhitelist is null)
|
||||
Config.DiscordBotWhitelist = new System.Collections.Specialized.StringCollection();
|
||||
{
|
||||
Config.DiscordBotWhitelist = new DiscordBot.Models.DiscordBotWhitelist();
|
||||
}
|
||||
|
||||
Config.DiscordBotWhitelist.Clear();
|
||||
Config.DiscordBotWhitelist.AddRange(DiscordBotWhitelist.Select(i => i.BotId).ToArray());
|
||||
Config.DiscordBotWhitelist.AddRange(DiscordBotWhitelist.Select(i => i.BotId));
|
||||
|
||||
App.ReconfigureLogging();
|
||||
}
|
||||
|
|
@ -529,7 +528,7 @@ namespace ServerManagerTool
|
|||
#region Discord Bot Whitelist
|
||||
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DiscordBotWhitelist.Add(new DiscordBotWhitelist());
|
||||
DiscordBotWhitelist.Add(new DiscordBotWhitelistItem());
|
||||
|
||||
CollectionViewSource.GetDefaultView(DiscordBotWhitelistGrid.ItemsSource).Refresh();
|
||||
}
|
||||
|
|
@ -549,7 +548,7 @@ namespace ServerManagerTool
|
|||
if (MessageBox.Show(_globalizer.GetResourceString("ServerSettings_DeleteLabel"), _globalizer.GetResourceString("ServerSettings_DeleteTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
var item = ((DiscordBotWhitelist)((Button)e.Source).DataContext);
|
||||
var item = ((DiscordBotWhitelistItem)((Button)e.Source).DataContext);
|
||||
DiscordBotWhitelist.Remove(item);
|
||||
|
||||
CollectionViewSource.GetDefaultView(DiscordBotWhitelistGrid.ItemsSource).Refresh();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue