Add a reset to default button to discord bot section.

Added Discord Bot section to the profile sync list.
This commit is contained in:
Brett Hewitson 2021-12-18 12:17:58 +10:00
parent fd0c04db9d
commit a6f2b6f912
19 changed files with 254 additions and 118 deletions

View file

@ -160,6 +160,7 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Delegates\ServerStatusChangeDelegate.cs" />
<Compile Include="Enums\ServerSettingsResetAction.cs" />
<Compile Include="Lib\Model\PlayerListParameters.cs" />
<Compile Include="Lib\Model\RconParameters.cs" />
<Compile Include="Lib\Serialization\IniFileEntryAttribute.cs" />

View file

@ -4,6 +4,7 @@
{
Administration,
AutomaticManagement,
DiscordBot,
ServerFiles,
}
}

View file

@ -0,0 +1,14 @@
namespace ServerManagerTool.Enums
{
public enum ServerSettingsResetAction
{
// Sections
AdministrationSection,
DiscordBotSection,
// Properties
RconWindowExtents,
PlayerMaxXpProperty,
ServerOptions,
}
}

View file

@ -1451,6 +1451,19 @@ namespace ServerManagerTool.Lib
this.ClearValue(LauncherArgsProperty);
this.ClearValue(AdditionalArgsProperty);
}
public void ResetDiscordBotSection()
{
this.ClearValue(DiscordChannelIdProperty);
this.ClearValue(DiscordAliasProperty);
this.ClearValue(AllowDiscordBackupProperty);
this.ClearValue(AllowDiscordRestartProperty);
this.ClearValue(AllowDiscordShutdownProperty);
this.ClearValue(AllowDiscordStartProperty);
this.ClearValue(AllowDiscordStopProperty);
this.ClearValue(AllowDiscordUpdateProperty);
}
#endregion
#region Sync Methods
@ -1467,6 +1480,9 @@ namespace ServerManagerTool.Lib
case ServerProfileCategory.AutomaticManagement:
SyncAutomaticManagement(sourceProfile);
break;
case ServerProfileCategory.DiscordBot:
SyncDiscordBot(sourceProfile);
break;
case ServerProfileCategory.ServerFiles:
SyncServerFiles(sourceProfile);
break;
@ -1516,6 +1532,19 @@ namespace ServerManagerTool.Lib
this.SetValue(AutoRestartIfShutdownProperty, sourceProfile.AutoRestartIfShutdown);
}
private void SyncDiscordBot(ServerProfile sourceProfile)
{
this.SetValue(DiscordChannelIdProperty, sourceProfile.DiscordChannelId);
this.SetValue(DiscordAliasProperty, sourceProfile.DiscordAlias);
this.SetValue(AllowDiscordBackupProperty, sourceProfile.AllowDiscordBackup);
this.SetValue(AllowDiscordRestartProperty, sourceProfile.AllowDiscordRestart);
this.SetValue(AllowDiscordShutdownProperty, sourceProfile.AllowDiscordShutdown);
this.SetValue(AllowDiscordStartProperty, sourceProfile.AllowDiscordStart);
this.SetValue(AllowDiscordStopProperty, sourceProfile.AllowDiscordStop);
this.SetValue(AllowDiscordUpdateProperty, sourceProfile.AllowDiscordUpdate);
}
private void SyncServerFiles(ServerProfile sourceProfile)
{
this.SetValue(ServerFilesBlacklistedProperty, sourceProfile.ServerFilesBlacklisted);

View file

@ -4,7 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mts="clr-namespace:Microsoft.Win32.TaskScheduler;assembly=Microsoft.Win32.TaskScheduler"
xmlns:sm="clr-namespace:ServerManagerTool"
xmlns:cctl="clr-namespace:ServerManagerTool.Common.Controls;assembly=ServerManager.Common"
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
@ -397,7 +396,7 @@
<TextBlock Text="{DynamicResource ServerSettings_AdministrationSectionLabel}" Style="{StaticResource ExpanderHeaderTextStyle}"/>
<Button Margin="20,0,0,0" ToolTip="{DynamicResource ServerSettings_ResetSectionTooltip}" Style="{StaticResource ButtonStyle1}"
IsEnabled="{Binding ElementName=SectionAdministration, Path=IsExpanded}"
Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static sm:ServerSettingsResetAction.AdministrationSection}">
Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static enum:ServerSettingsResetAction.AdministrationSection}">
<Image Source="{com:Icon Path=/ConanServerManager;component/Art/Refresh.ico,Size=32}"/>
</Button>
</StackPanel>
@ -557,7 +556,7 @@
<TextBox Grid.Row="0" Grid.Column="3" Margin="1" VerticalContentAlignment="Center" Name="HideRconPasswordTextBox" Style="{StaticResource HiddenTextBoxStyle}" IsEnabled="{Binding RconEnabled}" GotFocus="HiddenField_GotFocus" Text="{DynamicResource ServerSettings_HidePasswordText}" ToolTip="{DynamicResource ServerSettings_HidePasswordTooltip}"/>
<TextBox Grid.Row="0" Grid.Column="3" Margin="1" VerticalContentAlignment="Center" Name="RconPasswordTextBox" Visibility="Collapsed" LostFocus="HiddenField_LostFocus" Text="{Binding RconPassword}" ToolTip="{DynamicResource ServerSettings_RconPasswordTooltip}"/>
<Button Grid.Row="0" Grid.Column="5" Margin="1" Content="{StaticResource ResetRconButtonContent}" ToolTip="{DynamicResource ServerSettings_RconResetTooltip}" Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static sm:ServerSettingsResetAction.RconWindowExtents}" HorizontalAlignment="Right"/>
<Button Grid.Row="0" Grid.Column="5" Margin="1" Content="{StaticResource ResetRconButtonContent}" ToolTip="{DynamicResource ServerSettings_RconResetTooltip}" Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static enum:ServerSettingsResetAction.RconWindowExtents}" HorizontalAlignment="Right"/>
</Grid>
</GroupBox>
@ -760,7 +759,7 @@
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource ServerSettings_ServerOptionsLabel}"/>
<Button Width="22" Height="22" Margin="20,0,0,0" Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static sm:ServerSettingsResetAction.ServerOptions}" ToolTip="{DynamicResource ServerSettings_ResetServerOptionsTooltip}" Style="{StaticResource ButtonStyle1}">
<Button Width="22" Height="22" Margin="20,0,0,0" Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static enum:ServerSettingsResetAction.ServerOptions}" ToolTip="{DynamicResource ServerSettings_ResetServerOptionsTooltip}" Style="{StaticResource ButtonStyle1}">
<Image Source="{com:Icon Path=/ConanServerManager;component/Art/Refresh.ico,Size=32}"/>
</Button>
</StackPanel>
@ -1066,6 +1065,11 @@
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource ServerSettings_DiscordBotLabel}" Style="{StaticResource ExpanderHeaderTextStyle}"/>
<Button Margin="20,0,0,0" ToolTip="{DynamicResource ServerSettings_ResetSectionTooltip}" Style="{StaticResource ButtonStyle1}"
IsEnabled="{Binding ElementName=SectionDiscordBot, Path=IsExpanded}"
Command="{Binding ResetActionCommand, ElementName=SettingsControl}" CommandParameter="{x:Static enum:ServerSettingsResetAction.DiscordBotSection}">
<Image Source="{com:Icon Path=/ConanServerManager;component/Art/Refresh.ico,Size=32}"/>
</Button>
</StackPanel>
</Expander.Header>

View file

@ -26,20 +26,6 @@ using WPFSharp.Globalizer;
namespace ServerManagerTool
{
public enum ServerSettingsResetAction
{
// Sections
AdministrationSection,
// Properties
RconWindowExtents,
PlayerMaxXpProperty,
ServerOptions,
}
/// <summary>
/// Interaction logic for ServerSettings.xaml
/// </summary>
partial class ServerSettingsControl : UserControl
{
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
@ -1354,6 +1340,9 @@ namespace ServerManagerTool
RefreshServerRegionsList();
break;
case ServerSettingsResetAction.DiscordBotSection:
this.Settings.ResetDiscordBotSection();
break;
// Properties
case ServerSettingsResetAction.RconWindowExtents:

View file

@ -9,8 +9,8 @@
<entry>
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
<title>1.1.58 (1.1.58.9)</title>
<summary>1.1.58.9</summary>
<title>1.1.58 (1.1.58.10)</title>
<summary>1.1.58.10</summary>
<link href="" />
<updated>2021-12-18T00:00:00Z</updated>
<content type="xhtml">
@ -30,6 +30,8 @@
<ul>
<li>Discord Bot - all commands are now case INsensitive, along with the profile id and the alias.</li>
<li>Discord Bot - removed the mandatory requirement to enter the '!' after the discord prefix. The '!' has been added to the existing prefix so no change to existing functionality, but you can now change it.</li>
<li>Server Settings - Discord Bot section - Add a reset to default button.</li>
<li>Profile Sync - Added Discord Bot section to the list.</li>
<li>Made changes to the code to help improve performance.</li>
</ul>
</p>

View file

@ -8,7 +8,31 @@
<updated>2021-12-17T00:00:00Z</updated>
<entry>
<id>urn:uuid:9A427D82-9904-44F5-8C1E-7C943049869A</id>
<id>urn:uuid:6EF11E7A-65D0-481E-A712-71CDB6C3F23F</id>
<title>1.1.58 (1.1.58.10)</title>
<summary>1.1.58.10</summary>
<link href="" />
<updated>2021-12-18T00: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>Server Settings - Discord Bot section - Add a reset to default button.</li>
<li>Profile Sync - Added Discord Bot section to the list.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:970CFB45-B99A-4F12-9135-1E5763D1B2F6</id>
<title>1.1.58 (1.1.58.9)</title>
<summary>1.1.58.9</summary>
<link href="" />

View file

@ -215,6 +215,8 @@ namespace ServerManagerTool
SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.Administration, SectionName = _globalizer.GetResourceString("ServerSettings_AdministrationSectionLabel") });
SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.AutomaticManagement, SectionName = _globalizer.GetResourceString("ServerSettings_AutomaticManagementLabel") });
if (Config.Default.DiscordBotEnabled)
SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.DiscordBot, SectionName = _globalizer.GetResourceString("ServerSettings_DiscordBotLabel") });
SyncSections.Add(new SyncSection() { Selected = false, Category = ServerProfileCategory.ServerFiles, SectionName = _globalizer.GetResourceString("ServerSettings_ServerFilesLabel") });
}