套餐方案相关后端

This commit is contained in:
ZouJin 2024-05-28 02:02:26 +08:00
parent 46dc67a7d8
commit 531c473f94
6 changed files with 177 additions and 31 deletions

View File

@ -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<ScheduleItemBase> ScheduleItems { get; set; } = [];
private IMainWindow mw;
public int NowIndex { get; set; } = 0;
public bool IsOn { get; set; } = false;
/// <summary>
/// 根据设置获取日程表
/// </summary>
@ -58,17 +61,29 @@ public class ScheduleTask
}
}
}
i++;
}
if (mw.GameSavesData.Data.ContainsLine("schedule_work"))
{
PackageWork = LPSConvert.DeserializeObject<Package>(mw.GameSavesData.Data["schedule_work"]);
}
if (mw.GameSavesData.Data.ContainsLine("schedule_study"))
{
PackageStudy = LPSConvert.DeserializeObject<Package>(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; }
/// <summary>
/// 日程表日程
/// </summary>
@ -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;
}
/// <summary>
/// 套餐信息
/// </summary>
public class Package
{
/// <summary>
/// 协议名称 (已翻译)
/// </summary>
public string NameTrans { get; set; }
/// <summary>
/// 抽成
/// </summary>
[Line] public double Commissions { get; set; }
/// <summary>
/// 办理费用
/// </summary>
[Line] public double Price { get; set; }
/// <summary>
/// 截止时间
/// </summary>
[Line] public DateTime EndTime { get; set; }
/// <summary>
/// 可用等级
/// </summary>
[Line] public int Level { get; set; }
}
/// <summary>
/// 套餐详细
/// </summary>
public class PackageFull : Package
{
/// <summary>
/// 套餐名称
/// </summary>
[Line] public string Name { get; set; }
/// <summary>
/// 协议名称 (已翻译)
/// </summary>
public new string NameTrans
{
get
{
if (string.IsNullOrEmpty(base.NameTrans))
{
base.NameTrans = Name.Translate();
}
return base.NameTrans;
}
set => base.NameTrans = value;
}
/// <summary>
/// 持续时间
/// </summary>
[Line] public int Duration { get; set; }
/// <summary>
/// 等级需求
/// </summary>
[Line] public double LevelInNeed { get; set; }
/// <summary>
/// 工作类型
/// </summary>
[Line] public Work.WorkType WorkType { get; set; }
}
/// <summary>
/// 所有可用套餐
/// </summary>
public List<PackageFull> PackageFulls { get; set; }
/// <summary>
/// 获取基本可用套餐
/// </summary>
public static List<PackageFull> GetBasePackageFulls()
{
return new List<PackageFull>
{
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
}
};
}
}

View File

@ -20,7 +20,7 @@
</Grid.RowDefinitions>
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
pu:TextBoxHelper.Watermark="{ll:Str 和桌宠说}" FontSize="30" AcceptsReturn="True"
TextWrapping="WrapWithOverflow" PreviewKeyDown="tbTalk_KeyDown" />
TextWrapping="WrapWithOverflow" PreviewKeyDown="tbTalk_KeyDown" InputMethod.IsInputMethodEnabled="True" />
<Button pu:ButtonHelper.CornerRadius="4" Content="{ll:Str '发送'}" BorderThickness="2"
Background="{DynamicResource SecondaryLight}" Grid.Column="2"
BorderBrush="{DynamicResource DARKPrimaryDarker}" FontSize="30"

View File

@ -1601,9 +1601,6 @@ namespace VPet_Simulator.Windows
};
MusicTimer.Elapsed += MusicTimer_Elapsed;
//日程表加载
ScheduleTask = new ScheduleTask(this);
//await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏动画".Translate()));
await Dispatcher.InvokeAsync(new Action(() =>
@ -1632,6 +1629,9 @@ namespace VPet_Simulator.Windows
Main.ToolBar.LoadClean();
Main.WorkList(out List<Work> ws, out List<Work> ss, out List<Work> ps);
//日程表加载
ScheduleTask = new ScheduleTask(this);
if (ws.Count == 0)
{
Main.ToolBar.MenuWork.Visibility = Visibility.Collapsed;

View File

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ResizeMode="NoResize"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" InputMethod.IsInputMethodEnabled="False"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ShowInTaskbar="False"
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" WindowStyle="None" Title="MainWindow"
Closed="Window_Closed" pu:WindowXCaption.Height="0" SizeToContent="WidthAndHeight" Foreground="{StaticResource PrimaryText}"

View File

@ -205,7 +205,7 @@
</Grid>
<Border Grid.Column="2" Background="White" CornerRadius="4" />
<Grid Grid.Column="2" Margin="7">
<Grid d:Visibility="Collapsed"
<Grid
Visibility="{Binding IsChecked, Converter={x:Static pu:Converters.TrueToCollapseConverter}, ElementName=tbtnCurrentPlan}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -223,7 +223,7 @@
<TextBlock Grid.Row="1" Margin="0,7,0,0" FontSize="16"
HorizontalAlignment="Right" Foreground="{DynamicResource DARKPrimary}">
<Run Text="Lv." />
<Run x:Name="rTaskLevel" Text="50" />
<Run Text="{Binding Value,ElementName=sliderTaskLevel}" />
</TextBlock>
<Slider x:Name="sliderTaskLevel" Grid.Row="2" pu:SliderHelper.ThumbWidth="10"
pu:SliderHelper.ThumbCornerRadius="2" pu:SliderHelper.ThumbHeight="16"
@ -264,9 +264,8 @@
Background="{DynamicResource PrimaryDarker}" Click="btnSignAgency_Click"
FontSize="16" FontWeight="Bold" />
</Grid>
<Grid
Visibility="{Binding IsChecked, Converter={x:Static pu:Converters.FalseToCollapseConverter}, ElementName=tbtnCurrentPlan}"
d:Visibility="Visible">
<Grid d:Visibility="Collapsed"
Visibility="{Binding IsChecked, Converter={x:Static pu:Converters.FalseToCollapseConverter}, ElementName=tbtnCurrentPlan}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@ -280,6 +279,7 @@
<RowDefinition Height="22" />
<RowDefinition Height="22" />
<RowDefinition Height="22" />
<RowDefinition Height="22" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
@ -291,14 +291,17 @@
<TextBlock Text="{Binding Text,ElementName=rTaskType}" />
<TextBlock Grid.Column="2" HorizontalAlignment="Right"
Foreground="{DynamicResource DARKPrimary}" Text="20%" />
<TextBlock Grid.Row="1" Text="{ll:Str '等级需求'}" />
<TextBlock Grid.Row="1" Text="{ll:Str '可用等级'}" />
<TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Right"
Foreground="{DynamicResource DARKPrimary}" Text="Lv 100" />
<TextBlock Grid.Row="2" Text="{ll:Str '合同剩余时间'}" />
<TextBlock Grid.Row="2" Text="{ll:Str '剩余时间'}" />
<TextBlock Grid.Row="2" Grid.Column="2" HorizontalAlignment="Right"
Foreground="{DynamicResource DARKPrimary}" Text="7 天" />
<TextBlock Grid.Row="4" Text="{ll:Str '办理费用'}" VerticalAlignment="Bottom" />
<TextBlock Grid.Row="4" Grid.Column="2" HorizontalAlignment="Right"
<TextBlock Grid.Row="3" Text="{ll:Str '截止日期'}" />
<TextBlock Grid.Row="3" Grid.Column="2" HorizontalAlignment="Right"
Foreground="{DynamicResource DARKPrimary}" Text="05/27" />
<TextBlock Grid.Row="5" Text="{ll:Str '办理费用'}" VerticalAlignment="Bottom" />
<TextBlock Grid.Row="5" Grid.Column="2" HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="{DynamicResource DARKPrimary}" Text="100000"
FontSize="26" />
@ -578,6 +581,9 @@
</Grid>
</TabItem>
</TabControl>
<Label x:Name="blockTask" Content="{ll:Str '日程表将在15级开放'}" Background="{DynamicResource DARKPrimaryTransA}"
Foreground="{DynamicResource DARKPrimaryText}" FontSize="36" FontWeight="Bold" Margin="-15"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" d:Visibility="Collapsed" />
</Grid>
</Grid>
</Grid>

View File

@ -74,10 +74,13 @@ public partial class winWorkMenu : WindowX
_starDetails.Add(v.NameTrans);
}
LsbCategory.SelectedIndex = (int)type;
_schedules = mw.ScheduleTask.ScheduleItems;
ShowImageDefault(type);
CalculateSceduleTime();
if (mw.Core.Save.Level > 15)
blockTask.Visibility = Visibility.Collapsed;
AllowChange = true;
_schedules = mw.ScheduleTask.ScheduleItems;
ComboBoxHelper.SetWatermark(detailTypes, "---" + "请选择".Translate() + "---");
@ -96,7 +99,7 @@ public partial class winWorkMenu : WindowX
//判断倍率
if (nowwork.LevelLimit > mw.GameSavesData.GameSave.Level)
{
wDouble.Visibility = Visibility.Collapsed;
wDouble.IsEnabled = false;
wDouble.Value = 1;
}
else
@ -104,12 +107,12 @@ public partial class winWorkMenu : WindowX
int max = Math.Min(4000, mw.GameSavesData.GameSave.Level) / (nowwork.LevelLimit + 10);
if (max <= 1)
{
wDouble.Visibility = Visibility.Collapsed;
wDouble.IsEnabled = false;
wDouble.Value = 1;
}
else
{
wDouble.Visibility = Visibility.Visible;
wDouble.IsEnabled = true;
wDouble.Maximum = max;
wDouble.Value = mw.Set["workmenu"].GetInt("double_" + nowwork.Name, 1);
}
@ -157,6 +160,11 @@ public partial class winWorkMenu : WindowX
tbtn_star.IsChecked = IsWorkStar(work);
}
public void LoadSchedule()
{
}
private void LsbCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Dispatcher.BeginInvoke(() =>
@ -456,7 +464,7 @@ internal class ScheduleItemTemplateSelector
{
var element = container as FrameworkElement;
return element.FindResource(item.GetType().ToString()) as DataTemplate;
return element.FindResource(item.GetType().Name) as DataTemplate;
//if (item is WorkScheduleItem)
//{
// return element.FindResource("WorkScheduleTemplate") as DataTemplate;