diff --git a/src/MaaWpfGui/Constants/ConfigurationKeys.cs b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
index 5ee825ba97..f403667c33 100644
--- a/src/MaaWpfGui/Constants/ConfigurationKeys.cs
+++ b/src/MaaWpfGui/Constants/ConfigurationKeys.cs
@@ -175,5 +175,6 @@ namespace MaaWpfGui.Constants
public const string GuideStepIndex = "Guide.StepIndex";
public const string ForceScheduledStart = "Timer.ForceScheduledStart";
+ public const string CustomConfig = "Timer.CustomConfig";
}
}
diff --git a/src/MaaWpfGui/Helper/ConfigurationHelper.cs b/src/MaaWpfGui/Helper/ConfigurationHelper.cs
index 72481005cc..4a0939e022 100644
--- a/src/MaaWpfGui/Helper/ConfigurationHelper.cs
+++ b/src/MaaWpfGui/Helper/ConfigurationHelper.cs
@@ -273,6 +273,16 @@ namespace MaaWpfGui.Helper
return SetValue("TaskQueue.Order." + task, value);
}
+ public static string GetTimerConfig(int i, string defaultValue)
+ {
+ return GetValue($"Timer.Timer{i + 1}.Config", defaultValue);
+ }
+
+ public static bool SetTimerConfig(int i, string value)
+ {
+ return SetValue($"Timer.Timer{i + 1}.Config", value);
+ }
+
public static void Release()
{
lock (_lock)
diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index 4f179814a7..7638aef5d5 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -1651,12 +1651,20 @@ namespace MaaWpfGui.ViewModels.UI
{
public event PropertyChangedEventHandler PropertyChanged;
- public TimerProperties(int timeId, bool isOn, int hour, int min)
+ public TimerProperties(int timeId, bool isOn, int hour, int min, string timerConfig)
{
TimerId = timeId;
_isOn = isOn;
_hour = hour;
_min = min;
+ if (timerConfig == null || !ConfigurationHelper.GetConfigurationList().Contains(timerConfig))
+ {
+ _timerConfig = ConfigurationHelper.GetCurrentConfiguration();
+ }
+ else
+ {
+ _timerConfig = timerConfig;
+ }
}
protected void OnPropertyChanged([CallerMemberName] string name = null)
@@ -1714,6 +1722,22 @@ namespace MaaWpfGui.ViewModels.UI
}
}
+ private string _timerConfig;
+
+ ///
+ /// Gets or sets the config of the timer.
+ ///
+ public string TimerConfig
+ {
+ get => _timerConfig;
+ set
+ {
+ _timerConfig = value ?? ConfigurationHelper.GetCurrentConfiguration();
+ OnPropertyChanged();
+ ConfigurationHelper.SetTimerConfig(TimerId, value.ToString());
+ }
+ }
+
public TimerProperties()
{
PropertyChanged += (sender, args) => { };
@@ -1730,7 +1754,8 @@ namespace MaaWpfGui.ViewModels.UI
i,
ConfigurationHelper.GetTimer(i, bool.FalseString) == bool.TrueString,
int.Parse(ConfigurationHelper.GetTimerHour(i, $"{i * 3}")),
- int.Parse(ConfigurationHelper.GetTimerMin(i, "0")));
+ int.Parse(ConfigurationHelper.GetTimerMin(i, "0")),
+ ConfigurationHelper.GetTimerConfig(i, ConfigurationHelper.GetCurrentConfiguration()));
}
}
}
@@ -1752,6 +1777,21 @@ namespace MaaWpfGui.ViewModels.UI
}
}
+ private bool _customConfig = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomConfig, bool.FalseString));
+
+ ///
+ /// Gets or sets a value indicating whether to use custom config.
+ ///
+ public bool CustomConfig
+ {
+ get => _customConfig;
+ set
+ {
+ SetAndNotify(ref _customConfig, value);
+ ConfigurationHelper.SetValue(ConfigurationKeys.CustomConfig, value.ToString());
+ }
+ }
+
/* 刷理智设置 */
private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty);
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index 7d9b4fc517..f177404e19 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -210,8 +210,8 @@ namespace MaaWpfGui.ViewModels.UI
private async void Timer1_Elapsed(object sender, EventArgs e)
{
// 提前记录时间,避免等待超过定时时间
- int intHour = DateTime.Now.Hour;
- int intMinute = DateTime.Now.Minute;
+ DateTime currentTime = DateTime.Now;
+ currentTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, currentTime.Hour, currentTime.Minute, 0);
if (NeedToUpdateDatePrompt())
{
@@ -251,17 +251,38 @@ namespace MaaWpfGui.ViewModels.UI
}
var timeToStart = false;
+ var timeToChangeConfig = false;
+ var configIndex = 0;
for (int i = 0; i < 8; ++i)
{
- if (Instances.SettingsViewModel.TimerModels.Timers[i].IsOn &&
- Instances.SettingsViewModel.TimerModels.Timers[i].Hour == intHour &&
- Instances.SettingsViewModel.TimerModels.Timers[i].Min == intMinute)
+ if (Instances.SettingsViewModel.TimerModels.Timers[i].IsOn)
{
- timeToStart = true;
- break;
+ DateTime startTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day,
+ Instances.SettingsViewModel.TimerModels.Timers[i].Hour,
+ Instances.SettingsViewModel.TimerModels.Timers[i].Min,
+ 0);
+ DateTime restartDateTime = startTime.AddMinutes(-2);
+ if (currentTime == restartDateTime)
+ {
+ timeToChangeConfig = true;
+ configIndex = i;
+ break;
+ }
+ else if (currentTime == startTime)
+ {
+ timeToStart = true;
+ break;
+ }
}
}
+ if (timeToChangeConfig)
+ {
+ // CurrentConfiguration设置后会重启
+ Instances.SettingsViewModel.CurrentConfiguration = Instances.SettingsViewModel.TimerModels.Timers[2].TimerConfig;
+ return;
+ }
+
if (timeToStart)
{
if (Instances.SettingsViewModel.ForceScheduledStart)
diff --git a/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml
index 3d6270e866..f9185c68c6 100644
--- a/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/TimerSettingsUserControl.xaml
@@ -13,22 +13,34 @@
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
xmlns:vm="clr-namespace:MaaWpfGui"
d:DataContext="{d:DesignInstance {x:Type ui:SettingsViewModel}}"
- d:DesignHeight="300"
- d:DesignWidth="400"
+ d:DesignHeight="450"
+ d:DesignWidth="800"
mc:Ignorable="d">
-
+
+
+
+
+
@@ -37,296 +49,384 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+