Broadcast Message Changes

1. Added config option for auto processes to use broadcast keyword
2. Added config to global settings
This commit is contained in:
Brett Hewitson 2022-03-22 22:20:37 +10:00
parent 220b3d9c77
commit fc658b04dd
22 changed files with 196 additions and 55 deletions

View file

@ -743,6 +743,11 @@
<cctl:AnnotatedSlider Grid.Row="6" Grid.Column="0" Margin="0" Label="{DynamicResource GlobalSettings_LoggingMaxArchiveDaysLabel}" Value="{Binding Config.LoggingMaxArchiveDays}" Minimum="1" Maximum="365" SmallChange="1" LargeChange="5" TickFrequency="5" LabelRelativeWidth="Auto" SliderRelativeWidth="15*" SuffixRelativeWidth="Auto" SuffixRelativeMinWidth="40" Suffix="{DynamicResource SliderUnits_Days}" ToolTip="{DynamicResource GlobalSettings_LoggingMaxArchiveDaysTooltip}" IsEnabled="{Binding Config.LoggingEnabled}"/>
<cctl:AnnotatedSlider Grid.Row="7" Grid.Column="0" Margin="0" Label="{DynamicResource GlobalSettings_LoggingMaxArchiveFilesLabel}" Value="{Binding Config.LoggingMaxArchiveFiles}" Minimum="1" Maximum="1000" SmallChange="1" LargeChange="5" TickFrequency="5" LabelRelativeWidth="Auto" SliderRelativeWidth="15*" SuffixRelativeWidth="Auto" SuffixRelativeMinWidth="40" Suffix="{DynamicResource SliderUnits_Files}" ToolTip="{DynamicResource GlobalSettings_LoggingMaxArchiveFilesTooltip}" IsEnabled="{Binding Config.LoggingEnabled}"/>
<StackPanel Grid.Row="7" Grid.Column="1" Margin="0" Orientation="Horizontal">
<Label Content="{DynamicResource GlobalSettings_RCON_ModeLabel}" VerticalAlignment="Center"/>
<ComboBox Name="RconMessageModesComboBox" Margin="5" ItemsSource="{Binding ElementName=GlobalSettings, Path=RconMessageModes}" SelectedValue="{Binding Config.RCON_MessageCommand}" ToolTip="{DynamicResource GlobalSettings_RCON_ModeTooltip}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
</StackPanel>
</Grid>
</GroupBox>
</Grid>

View file

@ -35,6 +35,7 @@ namespace ServerManagerTool
public static readonly DependencyProperty WindowStatesServerMonitorProperty = DependencyProperty.Register(nameof(WindowStatesServerMonitor), 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<DiscordBotWhitelistItem>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public static readonly DependencyProperty RconMessageModesProperty = DependencyProperty.Register(nameof(RconMessageModes), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
public GlobalSettingsControl()
{
@ -50,6 +51,7 @@ namespace ServerManagerTool
PopulateWindowsStatesMainWindowComboBox();
PopulateWindowsStatesServerMonitorWindowComboBox();
PopulateDiscordBotLogLevelsComboBox();
PopulateRconMessageModesComboBox();
DiscordBotWhitelist = new List<DiscordBotWhitelistItem>();
if (Config.DiscordBotWhitelist != null)
@ -114,6 +116,12 @@ namespace ServerManagerTool
set { SetValue(DiscordBotWhitelistProperty, value); }
}
public ComboBoxItemList RconMessageModes
{
get { return (ComboBoxItemList)GetValue(RconMessageModesProperty); }
set { SetValue(RconMessageModesProperty, value); }
}
public void ApplyChangesToConfig()
{
if (Config.DiscordBotWhitelist is null)
@ -414,6 +422,7 @@ namespace ServerManagerTool
PopulateWindowsStatesMainWindowComboBox();
PopulateWindowsStatesServerMonitorWindowComboBox();
PopulateRconMessageModesComboBox();
App.Instance.OnResourceDictionaryChanged(Config.CultureName);
}
@ -554,6 +563,27 @@ namespace ServerManagerTool
}
}
private void PopulateRconMessageModesComboBox()
{
var selectedValue = this.RconMessageModesComboBox?.SelectedValue ?? Config.RCON_MessageCommand;
var list = new ComboBoxItemList();
foreach (InputMode inputMode in Enum.GetValues(typeof(InputMode)))
{
if (inputMode == InputMode.Command)
continue;
var displayMember = _globalizer.GetResourceString($"InputMode_{inputMode}") ?? inputMode.ToString();
list.Add(new Common.Model.ComboBoxItem(inputMode.ToString(), displayMember));
}
this.RconMessageModes = list;
if (this.RconMessageModesComboBox != null)
{
this.RconMessageModesComboBox.SelectedValue = selectedValue;
}
}
#region Discord Bot Whitelist
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
{