diff --git a/VPet-Simulator.Windows.Interface/ScheduleTask.cs b/VPet-Simulator.Windows.Interface/ScheduleTask.cs index 98e563a..ce21138 100644 --- a/VPet-Simulator.Windows.Interface/ScheduleTask.cs +++ b/VPet-Simulator.Windows.Interface/ScheduleTask.cs @@ -1,4 +1,6 @@ using LinePutScript; +using LinePutScript.Converter; +using LinePutScript.Localization.WPF; using Panuon.WPF; using System; using System.Collections.Generic; @@ -21,6 +23,7 @@ public class ScheduleTask public ObservableCollection ScheduleItems { get; set; } = []; private IMainWindow mw; public int NowIndex { get; set; } = 0; + public bool IsOn { get; set; } = false; /// /// 根据设置获取日程表 /// @@ -58,17 +61,29 @@ public class ScheduleTask } } } + i++; + } + if (mw.GameSavesData.Data.ContainsLine("schedule_work")) + { + PackageWork = LPSConvert.DeserializeObject(mw.GameSavesData.Data["schedule_work"]); + } + if (mw.GameSavesData.Data.ContainsLine("schedule_study")) + { + PackageStudy = LPSConvert.DeserializeObject(mw.GameSavesData.Data["schedule_study"]); } NowIndex = schedule[(gint)"now"]; + IsOn = schedule[(gbol)"ison"]; } imw.Main.WorkTimer.E_FinishWork += WorkTimer_E_FinishWork; RestTimer.Elapsed += RestTimer_Elapsed; - RestTimer.Start(); + if (IsOn) + RestTimer.Start(); } public void Save() { mw.GameSavesData.Data["schedule"].Clear(); mw.GameSavesData.Data["schedule"][(gint)"now"] = NowIndex; + mw.GameSavesData.Data["schedule"][(gbol)"ison"] = IsOn; for (int i = 0; i < ScheduleItems.Count; i++) { if (ScheduleItems[i] is RestScheduleItem rsi) @@ -80,6 +95,22 @@ public class ScheduleTask mw.GameSavesData.Data["schedule"][(gstr)i.ToString()] = $"{wsi.Work.Name},{wsi.DBL}"; } } + if (PackageWork == null) + { + mw.GameSavesData.Data.Remove("schedule_work"); + } + else + { + mw.GameSavesData.Data["schedule_work"] = LPSConvert.SerializeObject(PackageWork, "schedule_work"); + } + if (PackageStudy == null) + { + mw.GameSavesData.Data.Remove("schedule_study"); + } + else + { + mw.GameSavesData.Data["schedule_study"] = LPSConvert.SerializeObject(PackageStudy, "schedule_study"); + } } private void RestTimer_Elapsed(object sender, ElapsedEventArgs e) @@ -99,6 +130,8 @@ public class ScheduleTask public void StartWork() { RestTime = -100; + if (!IsOn) + return; if (ScheduleItems.Count > 0) { if (NowIndex >= ScheduleItems.Count) @@ -127,6 +160,8 @@ public class ScheduleTask private void WorkTimer_E_FinishWork(Core.WorkTimer.FinishWorkInfo obj) => StartWork(); + public Package PackageWork { get; set; } + public Package PackageStudy { get; set; } /// /// 日程表日程 /// @@ -178,18 +213,17 @@ public class ScheduleTask { this.Work = work; string source = task.mw.ImageSources.FindSource("work_" + task.mw.Set.PetGraph + "_" + work.Graph) ?? task.mw.ImageSources.FindSource("work_" + task.mw.Set.PetGraph + "_" + work.Name); - task.mw.Dispatcher.Invoke(() => + + if (source == null) { - if (source == null) - { - //尝试显示默认图像 - Image = task.mw.ImageSources.FindImage("work_" + task.mw.Set.PetGraph + "_t_" + work.Type.ToString(), "work_" + work.Type.ToString()); - } - else - { - Image = ImageResources.NewSafeBitmapImage(source); - } - }); + //尝试显示默认图像 + Image = task.mw.ImageSources.FindImage("work_" + task.mw.Set.PetGraph + "_t_" + work.Type.ToString(), "work_" + work.Type.ToString()); + } + else + { + Image = ImageResources.NewSafeBitmapImage(source); + } + } public ImageSource Image { get; set; } @@ -237,5 +271,103 @@ public class ScheduleTask public override int RestTime { get => _restTime; set => Set(ref _restTime, value); } private int _restTime; } + /// + /// 套餐信息 + /// + public class Package + { + /// + /// 协议名称 (已翻译) + /// + public string NameTrans { get; set; } + /// + /// 抽成 + /// + [Line] public double Commissions { get; set; } + /// + /// 办理费用 + /// + [Line] public double Price { get; set; } + /// + /// 截止时间 + /// + [Line] public DateTime EndTime { get; set; } + /// + /// 可用等级 + /// + [Line] public int Level { get; set; } + } + /// + /// 套餐详细 + /// + public class PackageFull : Package + { + /// + /// 套餐名称 + /// + [Line] public string Name { get; set; } + /// + /// 协议名称 (已翻译) + /// + public new string NameTrans + { + get + { + if (string.IsNullOrEmpty(base.NameTrans)) + { + base.NameTrans = Name.Translate(); + } + return base.NameTrans; + } + set => base.NameTrans = value; + } + /// + /// 持续时间 + /// + [Line] public int Duration { get; set; } + /// + /// 等级需求 + /// + [Line] public double LevelInNeed { get; set; } + + /// + /// 工作类型 + /// + [Line] public Work.WorkType WorkType { get; set; } + } + /// + /// 所有可用套餐 + /// + public List PackageFulls { get; set; } + /// + /// 获取基本可用套餐 + /// + public static List GetBasePackageFulls() + { + return new List + { + new PackageFull + { + Name = "work", + Duration = 1, + LevelInNeed = 0, + WorkType = Work.WorkType.Work + }, + new PackageFull + { + Name = "study", + Duration = 1, + LevelInNeed = 0, + WorkType = Work.WorkType.Study + }, + new PackageFull + { + Name = "play", + Duration = 1, + LevelInNeed = 0, + WorkType = Work.WorkType.Play + } + }; + } } diff --git a/VPet-Simulator.Windows.Interface/TalkBox.xaml b/VPet-Simulator.Windows.Interface/TalkBox.xaml index 0a97e02..326e631 100644 --- a/VPet-Simulator.Windows.Interface/TalkBox.xaml +++ b/VPet-Simulator.Windows.Interface/TalkBox.xaml @@ -20,7 +20,7 @@ + TextWrapping="WrapWithOverflow" PreviewKeyDown="tbTalk_KeyDown" InputMethod.IsInputMethodEnabled="True" />