asm: add NewYear setting

This commit is contained in:
Lacoi 2023-11-03 16:13:34 +01:00
parent c9e6f2ec26
commit 70ed633bc0
4 changed files with 158 additions and 1 deletions

View file

@ -1228,6 +1228,22 @@ namespace ServerManagerTool.Lib
get { return (float)GetValue(EventColorsChanceOverrideProperty); }
set { SetValue(EventColorsChanceOverrideProperty, value); }
}
public static readonly DependencyProperty NewYear1UTCProperty = DependencyProperty.Register(nameof(NewYear1UTC), typeof(DateTime), typeof(ServerProfile), new PropertyMetadata(DateTime.MinValue));
[DataMember]
public DateTime NewYear1UTC
{
get { return (DateTime)GetValue(NewYear1UTCProperty); }
set { SetValue(NewYear1UTCProperty, value); }
}
public static readonly DependencyProperty NewYear2UTCProperty = DependencyProperty.Register(nameof(NewYear2UTC), typeof(DateTime), typeof(ServerProfile), new PropertyMetadata(DateTime.MinValue));
[DataMember]
public DateTime NewYear2UTC
{
get { return (DateTime)GetValue(NewYear2UTCProperty); }
set { SetValue(NewYear2UTCProperty, value); }
}
#endregion
#region Rules
@ -4116,6 +4132,16 @@ namespace ServerManagerTool.Lib
serverArgs.Append("?EventColorsChanceOverride=").Append(this.EventColorsChanceOverride);
}
if (this.NewYear1UTC != DateTime.MinValue)
{
serverArgs.Append("?NewYear1UTC=").Append((new DateTimeOffset(this.NewYear1UTC.ToUniversalTime())).ToUnixTimeSeconds().ToString());
}
if (this.NewYear2UTC != DateTime.MinValue)
{
serverArgs.Append("?NewYear2UTC=").Append((new DateTimeOffset(this.NewYear2UTC.ToUniversalTime())).ToUnixTimeSeconds().ToString());
}
if (!string.IsNullOrWhiteSpace(this.AdditionalArgs))
{
var addArgs = this.AdditionalArgs.TrimStart();
@ -4423,6 +4449,11 @@ namespace ServerManagerTool.Lib
serverArgs.Append(" -MaxNumOfSaveBackups=").Append(this.MaxNumOfSaveBackups);
}
if (this.NewYear1UTC != DateTime.MinValue || this.NewYear2UTC != DateTime.MinValue)
{
serverArgs.Append(" -NewYearEvent");
}
return serverArgs.ToString();
}
@ -6136,6 +6167,8 @@ namespace ServerManagerTool.Lib
this.ClearValue(EventNameProperty);
this.ClearValue(EventColorsChanceOverrideProperty);
this.ClearValue(NewYear1UTCProperty);
this.ClearValue(NewYear2UTCProperty);
}
public void ResetSOTFSection()
@ -6923,6 +6956,8 @@ namespace ServerManagerTool.Lib
this.SetValue(EventNameProperty, sourceProfile.EventName);
this.SetValue(EventColorsChanceOverrideProperty, sourceProfile.EventColorsChanceOverride);
this.SetValue(NewYear1UTCProperty, sourceProfile.NewYear1UTC);
this.SetValue(NewYear2UTCProperty, sourceProfile.NewYear2UTC);
}
private void SyncServerFiles(ServerProfile sourceProfile)

View file

@ -1817,6 +1817,7 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
@ -1832,7 +1833,53 @@
<cctl:AnnotatedSlider Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Label="{DynamicResource ServerSettings_EventColorsChanceOverrideLabel}" Value="{Binding EventColorsChanceOverride}" Suffix="{Binding EventColorsChanceOverride, Converter={StaticResource FloatToPercentageConverter}}" Minimum="0" Maximum="1" SmallChange="0.05" LargeChange="0.1" TickFrequency="0.1" ToolTip="{DynamicResource ServerSettings_EventColorsChanceOverrideTooltip}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="6" Margin="5,0,5,0" Text="{DynamicResource ServerSettings_EventNote}" FontWeight="Bold" TextWrapping="WrapWithOverflow" IsEnabled="False"/>
<Label Grid.Row="2" Grid.Column="0" Content="{DynamicResource ServerSettings_NewYear1UTCLabel}" ToolTip="{DynamicResource ServerSettings_NewYear1UTCTooltip}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" ToolTip="{DynamicResource ServerSettings_NewYear1UTCTooltip}">
<Validation.ErrorTemplate>
<ControlTemplate>
<StackPanel>
<!-- Placeholder for the TextBox itself -->
<AdornedElementPlaceholder x:Name="textBox"/>
<TextBlock Text="{Binding [0].ErrorContent}" Background="Red" Foreground="White"/>
</StackPanel>
</ControlTemplate>
</Validation.ErrorTemplate>
<TextBox.Text>
<Binding Path="NewYear1UTC">
<Binding.Converter>
<cc:DateTimeToStringConverter />
</Binding.Converter>
<Binding.ValidationRules>
<cvr:DateTimeValidationRule ValidatesOnTargetUpdated="true" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<Label Grid.Row="2" Grid.Column="2" Content="{DynamicResource ServerSettings_NewYear2UTCLabel}" ToolTip="{DynamicResource ServerSettings_NewYear2UTCTooltip}" VerticalAlignment="Center"/>
<TextBox Grid.Row="2" Grid.Column="3" VerticalAlignment="Center" ToolTip="{DynamicResource ServerSettings_NewYear2UTCTooltip}">
<Validation.ErrorTemplate>
<ControlTemplate>
<StackPanel>
<!-- Placeholder for the TextBox itself -->
<AdornedElementPlaceholder x:Name="textBox"/>
<TextBlock Text="{Binding [0].ErrorContent}" Background="Red" Foreground="White"/>
</StackPanel>
</ControlTemplate>
</Validation.ErrorTemplate>
<TextBox.Text>
<Binding Path="NewYear2UTC">
<Binding.Converter>
<cc:DateTimeToStringConverter />
</Binding.Converter>
<Binding.ValidationRules>
<cvr:DateTimeValidationRule ValidatesOnTargetUpdated="true" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="6" Margin="5,0,5,0" Text="{DynamicResource ServerSettings_EventNote}" FontWeight="Bold" TextWrapping="WrapWithOverflow" IsEnabled="False"/>
</Grid>
</GroupBox>
</Grid>