2024-03-30 07:00:02 +00:00
|
|
|
|
using LinePutScript;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
using LinePutScript.Dictionary;
|
2023-07-01 07:46:08 +00:00
|
|
|
|
using LinePutScript.Localization.WPF;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using NAudio.CoreAudioApi;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
using Panuon.WPF.UI;
|
2024-05-13 16:55:27 +00:00
|
|
|
|
using Panuon.WPF.UI.Configurations;
|
2023-08-12 16:01:34 +00:00
|
|
|
|
using Steamworks;
|
2023-02-27 12:29:40 +00:00
|
|
|
|
using System;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
using System.Collections.Generic;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using System.Data;
|
2023-02-27 12:29:40 +00:00
|
|
|
|
using System.Diagnostics;
|
2023-01-24 06:56:16 +00:00
|
|
|
|
using System.IO;
|
2023-09-10 13:52:02 +00:00
|
|
|
|
using System.Linq;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
using System.Threading;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
using System.Timers;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
using System.Web;
|
2023-04-01 19:31:28 +00:00
|
|
|
|
using System.Windows;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
using System.Windows.Controls;
|
2023-10-11 17:24:35 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Windows.Interop;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Threading;
|
2023-01-10 10:43:32 +00:00
|
|
|
|
using VPet_Simulator.Core;
|
2023-04-01 15:15:50 +00:00
|
|
|
|
using VPet_Simulator.Windows.Interface;
|
2023-08-25 22:08:13 +00:00
|
|
|
|
using static VPet_Simulator.Core.GraphHelper;
|
2023-07-16 23:58:09 +00:00
|
|
|
|
using static VPet_Simulator.Core.GraphInfo;
|
2023-10-11 17:24:35 +00:00
|
|
|
|
using static VPet_Simulator.Windows.Interface.ExtensionFunction;
|
2024-04-17 07:04:17 +00:00
|
|
|
|
using static VPet_Simulator.Windows.Interface.Food;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using Application = System.Windows.Application;
|
|
|
|
|
using ContextMenu = System.Windows.Forms.ContextMenuStrip;
|
2023-10-11 17:24:35 +00:00
|
|
|
|
using Image = System.Windows.Controls.Image;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using Line = LinePutScript.Line;
|
|
|
|
|
using MenuItem = System.Windows.Forms.ToolStripMenuItem;
|
2024-03-26 11:27:37 +00:00
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
2024-03-30 07:00:02 +00:00
|
|
|
|
using Timer = System.Timers.Timer;
|
|
|
|
|
using ToolBar = VPet_Simulator.Core.ToolBar;
|
2024-03-11 08:01:33 +00:00
|
|
|
|
|
2023-01-10 10:43:32 +00:00
|
|
|
|
namespace VPet_Simulator.Windows
|
|
|
|
|
{
|
2023-04-01 15:15:50 +00:00
|
|
|
|
public partial class MainWindow : IMainWindow
|
2023-01-10 10:43:32 +00:00
|
|
|
|
{
|
2024-04-02 16:20:06 +00:00
|
|
|
|
|
2024-02-28 14:02:28 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载主题
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="themename">主题名称</param>
|
|
|
|
|
public void LoadTheme(string themename)
|
|
|
|
|
{
|
2024-03-30 09:59:45 +00:00
|
|
|
|
Theme ctheme = Themes.Find(x => x.xName == themename);
|
2024-02-28 14:02:28 +00:00
|
|
|
|
if (ctheme == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Theme = ctheme;
|
|
|
|
|
|
|
|
|
|
//加载图片包
|
|
|
|
|
ImageSources.AddSources(ctheme.Images);
|
|
|
|
|
|
|
|
|
|
//阴影颜色
|
|
|
|
|
Application.Current.Resources["ShadowColor"] = Function.HEXToColor('#' + ctheme.ThemeColor[(gstr)"ShadowColor"]);
|
|
|
|
|
|
|
|
|
|
foreach (ILine lin in ctheme.ThemeColor.Assemblage.FindAll(x => !x.Name.Contains("Color")))
|
|
|
|
|
Application.Current.Resources[lin.Name] = new SolidColorBrush(Function.HEXToColor('#' + lin.info));
|
|
|
|
|
|
|
|
|
|
//系统生成部分颜色
|
|
|
|
|
Color c = Function.HEXToColor('#' + ctheme.ThemeColor["Primary"].info);
|
|
|
|
|
c.A = 204;
|
|
|
|
|
Application.Current.Resources["PrimaryTrans"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 44;
|
|
|
|
|
Application.Current.Resources["PrimaryTrans4"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 170;
|
|
|
|
|
Application.Current.Resources["PrimaryTransA"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 238;
|
|
|
|
|
Application.Current.Resources["PrimaryTransE"] = new SolidColorBrush(c);
|
|
|
|
|
|
|
|
|
|
c = Function.HEXToColor('#' + ctheme.ThemeColor["Secondary"].info);
|
|
|
|
|
c.A = 204;
|
|
|
|
|
Application.Current.Resources["SecondaryTrans"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 44;
|
|
|
|
|
Application.Current.Resources["SecondaryTrans4"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 170;
|
|
|
|
|
Application.Current.Resources["SecondaryTransA"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 238;
|
|
|
|
|
Application.Current.Resources["SecondaryTransE"] = new SolidColorBrush(c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c = Function.HEXToColor('#' + ctheme.ThemeColor["DARKPrimary"].info);
|
|
|
|
|
c.A = 204;
|
|
|
|
|
Application.Current.Resources["DARKPrimaryTrans"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 44;
|
|
|
|
|
Application.Current.Resources["DARKPrimaryTrans4"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 170;
|
|
|
|
|
Application.Current.Resources["DARKPrimaryTransA"] = new SolidColorBrush(c);
|
|
|
|
|
c.A = 238;
|
|
|
|
|
Application.Current.Resources["DARKPrimaryTransE"] = new SolidColorBrush(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void LoadFont(string fontname)
|
|
|
|
|
{
|
|
|
|
|
IFont cfont = Fonts.Find(x => x.Name == fontname);
|
|
|
|
|
if (cfont == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-30 09:59:45 +00:00
|
|
|
|
var font = cfont.Font;
|
|
|
|
|
Application.Current.Resources["MainFont"] = font;
|
|
|
|
|
Panuon.WPF.UI.GlobalSettings.Setting.FontFamily = font;
|
2024-02-28 14:02:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-02 16:20:06 +00:00
|
|
|
|
|
2023-08-13 14:39:46 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得自动点击的文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>说话内容</returns>
|
|
|
|
|
public ClickText GetClickText()
|
|
|
|
|
{
|
|
|
|
|
ClickText.DayTime dt;
|
|
|
|
|
var now = DateTime.Now.Hour;
|
|
|
|
|
if (now < 6)
|
|
|
|
|
dt = ClickText.DayTime.Midnight;
|
|
|
|
|
else if (now < 12)
|
|
|
|
|
dt = ClickText.DayTime.Morning;
|
|
|
|
|
else if (now < 18)
|
|
|
|
|
dt = ClickText.DayTime.Afternoon;
|
|
|
|
|
else
|
|
|
|
|
dt = ClickText.DayTime.Night;
|
|
|
|
|
|
|
|
|
|
ClickText.ModeType mt;
|
|
|
|
|
switch (Core.Save.Mode)
|
|
|
|
|
{
|
2023-11-24 04:16:29 +00:00
|
|
|
|
case IGameSave.ModeType.PoorCondition:
|
2023-08-13 14:39:46 +00:00
|
|
|
|
mt = ClickText.ModeType.PoorCondition;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-11-24 04:16:29 +00:00
|
|
|
|
case IGameSave.ModeType.Nomal:
|
2023-08-13 14:39:46 +00:00
|
|
|
|
mt = ClickText.ModeType.Nomal;
|
|
|
|
|
break;
|
2023-11-24 04:16:29 +00:00
|
|
|
|
case IGameSave.ModeType.Happy:
|
2023-08-13 14:39:46 +00:00
|
|
|
|
mt = ClickText.ModeType.Happy;
|
|
|
|
|
break;
|
2023-11-24 04:16:29 +00:00
|
|
|
|
case IGameSave.ModeType.Ill:
|
2023-08-13 14:39:46 +00:00
|
|
|
|
mt = ClickText.ModeType.Ill;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var list = ClickTexts.FindAll(x => x.DaiTime.HasFlag(dt) && x.Mode.HasFlag(mt) && x.CheckState(Main));
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
|
return null;
|
|
|
|
|
return list[Function.Rnd.Next(list.Count)];
|
|
|
|
|
}
|
2023-08-25 22:31:44 +00:00
|
|
|
|
private Image hashcheckimg;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭该玩家的HashCheck检查
|
|
|
|
|
/// 如果你的mod属于作弊mod/有作弊内容,请在作弊前调用这个方法
|
|
|
|
|
/// </summary>
|
2023-08-25 22:31:44 +00:00
|
|
|
|
public void HashCheckOff()
|
|
|
|
|
{
|
|
|
|
|
HashCheck = false;
|
|
|
|
|
}
|
2023-08-06 02:00:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 存档 Hash检查 是否通过
|
|
|
|
|
/// </summary>
|
2023-08-25 22:31:44 +00:00
|
|
|
|
public bool HashCheck
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
get => GameSavesData.HashCheck;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-09-22 16:18:24 +00:00
|
|
|
|
if (!value)
|
2023-09-22 13:24:02 +00:00
|
|
|
|
{
|
|
|
|
|
GameSavesData.HashCheckOff();
|
|
|
|
|
}
|
2023-08-25 22:31:44 +00:00
|
|
|
|
Main?.Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (GameSavesData.HashCheck)
|
2023-08-25 22:31:44 +00:00
|
|
|
|
{
|
|
|
|
|
if (hashcheckimg == null)
|
|
|
|
|
{
|
|
|
|
|
hashcheckimg = new Image();
|
2023-10-13 12:02:48 +00:00
|
|
|
|
hashcheckimg.Source = ImageResources.NewSafeBitmapImage("pack://application:,,,/Res/hash.png");
|
2023-10-11 17:24:35 +00:00
|
|
|
|
hashcheckimg.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
hashcheckimg.ToolTip = "是没有修改过存档/使用超模MOD的玩家专属标志".Translate();
|
|
|
|
|
Grid.SetColumn(hashcheckimg, 4);
|
|
|
|
|
Grid.SetRowSpan(hashcheckimg, 2);
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Add(hashcheckimg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (hashcheckimg != null)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Remove(hashcheckimg);
|
|
|
|
|
hashcheckimg = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-10 10:43:32 +00:00
|
|
|
|
public void SetZoomLevel(double zl)
|
|
|
|
|
{
|
|
|
|
|
Set.ZoomLevel = zl;
|
2023-05-27 10:37:15 +00:00
|
|
|
|
//this.Height = 500 * zl;
|
2024-03-12 11:36:47 +00:00
|
|
|
|
MGrid.Width = 500 * zl;
|
2023-07-03 11:41:02 +00:00
|
|
|
|
if (petHelper != null)
|
|
|
|
|
{
|
|
|
|
|
petHelper.Width = 50 * zl;
|
|
|
|
|
petHelper.Height = 50 * zl;
|
|
|
|
|
petHelper.ReloadLocation();
|
|
|
|
|
}
|
2023-01-10 10:43:32 +00:00
|
|
|
|
}
|
2024-03-12 16:38:23 +00:00
|
|
|
|
|
2024-03-14 06:15:08 +00:00
|
|
|
|
|
2024-03-12 16:38:23 +00:00
|
|
|
|
|
2023-07-23 20:46:21 +00:00
|
|
|
|
//private DateTime timecount = DateTime.Now;
|
2023-01-24 06:56:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存设置
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Save()
|
|
|
|
|
{
|
2024-05-25 16:52:42 +00:00
|
|
|
|
//保存日程表
|
|
|
|
|
ScheduleTask?.Save();
|
|
|
|
|
//保存插件
|
2023-04-01 19:31:28 +00:00
|
|
|
|
foreach (MainPlugin mp in Plugins)
|
|
|
|
|
mp.Save();
|
2023-01-24 06:56:16 +00:00
|
|
|
|
//游戏存档
|
|
|
|
|
if (Set != null)
|
2023-05-25 17:50:38 +00:00
|
|
|
|
{
|
2023-09-22 16:59:41 +00:00
|
|
|
|
var st = Set.SaveTimesPP;
|
2023-05-27 10:37:15 +00:00
|
|
|
|
if (Main != null)
|
2023-06-08 11:44:41 +00:00
|
|
|
|
{
|
2023-05-27 10:37:15 +00:00
|
|
|
|
Set.VoiceVolume = Main.PlayVoiceVolume;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
List<string> list = new List<string>();
|
|
|
|
|
Foods.FindAll(x => x.Star).ForEach(x => list.Add(x.Name));
|
|
|
|
|
Set["betterbuy"]["star"].info = string.Join(",", list);
|
2023-09-22 13:24:02 +00:00
|
|
|
|
//GameSavesData.Statistics[(gint)"stat_time"] = (int)(DateTime.Now - timecount).TotalMinutes;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
//timecount = DateTime.Now;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
}
|
2023-09-14 11:50:36 +00:00
|
|
|
|
Set.StartRecordLastPoint = new Point(Dispatcher.Invoke(() => Left), Dispatcher.Invoke(() => Top));
|
2024-04-17 10:49:10 +00:00
|
|
|
|
if (PrefixSave == "" && File.Exists(ExtensionValue.BaseDirectory + @"\Setting.lps"))
|
2024-04-17 08:38:52 +00:00
|
|
|
|
{//对于主设置的备份
|
2024-07-04 07:31:34 +00:00
|
|
|
|
if (new FileInfo(ExtensionValue.BaseDirectory + @"\Setting.lps").Length < 10)
|
|
|
|
|
{//文件大小小于10字节,可能是损坏的文件
|
|
|
|
|
File.Delete(ExtensionValue.BaseDirectory + @"\Setting.lps");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Setting.bkp"))
|
|
|
|
|
File.Delete(ExtensionValue.BaseDirectory + @"\Setting.bkp");
|
|
|
|
|
File.Move(ExtensionValue.BaseDirectory + @"\Setting.lps", ExtensionValue.BaseDirectory + @"\Setting.bkp");
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 08:38:52 +00:00
|
|
|
|
}
|
2023-10-10 17:03:23 +00:00
|
|
|
|
File.WriteAllText(ExtensionValue.BaseDirectory + @$"\Setting{PrefixSave}.lps", Set.ToString());
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-09-24 13:17:48 +00:00
|
|
|
|
if (!Directory.Exists(ExtensionValue.BaseDirectory + @"\Saves"))
|
|
|
|
|
Directory.CreateDirectory(ExtensionValue.BaseDirectory + @"\Saves");
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-06-22 22:09:26 +00:00
|
|
|
|
if (Core != null && Core.Save != null)
|
2023-06-23 13:15:57 +00:00
|
|
|
|
{
|
2023-10-10 17:03:23 +00:00
|
|
|
|
var ds = new List<string>(Directory.GetFiles(ExtensionValue.BaseDirectory + @"\Saves", $"Save{PrefixSave}_*.lps")).OrderBy(x =>
|
2023-09-10 13:52:02 +00:00
|
|
|
|
{
|
2023-10-10 17:03:23 +00:00
|
|
|
|
if (int.TryParse(x.Split('_').Last().Split('.')[0], out int i))
|
2023-09-10 13:52:02 +00:00
|
|
|
|
return i;
|
|
|
|
|
return 0;
|
|
|
|
|
}).ToList();
|
2023-06-23 20:08:08 +00:00
|
|
|
|
while (ds.Count > Set.BackupSaveMaxNum)
|
|
|
|
|
{
|
2023-06-23 13:15:57 +00:00
|
|
|
|
File.Delete(ds[0]);
|
2023-06-23 20:08:08 +00:00
|
|
|
|
ds.RemoveAt(0);
|
|
|
|
|
}
|
2023-10-10 17:03:23 +00:00
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + $"\\Saves\\Save{PrefixSave}_{st}.lps"))
|
|
|
|
|
File.Delete(ExtensionValue.BaseDirectory + $"\\Saves\\Save{PrefixSave}_{st}.lps");
|
2023-06-23 13:15:57 +00:00
|
|
|
|
|
2023-10-10 17:03:23 +00:00
|
|
|
|
File.WriteAllText(ExtensionValue.BaseDirectory + $"\\Saves\\Save{PrefixSave}_{st}.lps", GameSavesData.ToLPS().ToString());
|
2023-09-27 04:17:27 +00:00
|
|
|
|
|
2023-09-10 14:03:47 +00:00
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps"))
|
2023-10-10 17:03:23 +00:00
|
|
|
|
{
|
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.bkp"))
|
|
|
|
|
File.Delete(ExtensionValue.BaseDirectory + @"\Save.bkp");
|
2023-09-24 13:17:48 +00:00
|
|
|
|
File.Move(ExtensionValue.BaseDirectory + @"\Save.lps", ExtensionValue.BaseDirectory + @"\Save.bkp");
|
2023-10-10 17:03:23 +00:00
|
|
|
|
}
|
2023-09-25 08:52:20 +00:00
|
|
|
|
|
2023-06-23 13:15:57 +00:00
|
|
|
|
}
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-01-24 06:56:16 +00:00
|
|
|
|
}
|
2023-04-01 19:31:28 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 重载DIY按钮区域
|
|
|
|
|
/// </summary>
|
2023-02-27 12:29:40 +00:00
|
|
|
|
public void LoadDIY()
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuDIY.Items.Clear();
|
2023-10-31 07:25:23 +00:00
|
|
|
|
|
2023-10-31 07:26:01 +00:00
|
|
|
|
if (App.MutiSaves.Count > 1)
|
2023-10-31 07:25:23 +00:00
|
|
|
|
{
|
|
|
|
|
var list = App.MutiSaves.ToList();
|
|
|
|
|
foreach (var win in App.MainWindows)
|
|
|
|
|
{
|
|
|
|
|
list.Remove(win.PrefixSave);
|
|
|
|
|
}
|
|
|
|
|
list.Remove(PrefixSave);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var menuItem = new System.Windows.Controls.MenuItem()
|
|
|
|
|
{
|
|
|
|
|
Header = "桌宠多开".Translate(),
|
|
|
|
|
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center,
|
|
|
|
|
};
|
|
|
|
|
foreach (var win in list)
|
|
|
|
|
{
|
|
|
|
|
var mo = new System.Windows.Controls.MenuItem()
|
|
|
|
|
{
|
|
|
|
|
Header = win.Translate(),
|
|
|
|
|
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center,
|
|
|
|
|
};
|
|
|
|
|
mo.Click += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
if (App.MainWindows.FirstOrDefault(x => x.PrefixSave.Trim('-') == win) == null)
|
|
|
|
|
{
|
|
|
|
|
new MainWindow(win).Show();
|
|
|
|
|
}
|
|
|
|
|
menuItem.Items.Remove(s);
|
|
|
|
|
};
|
|
|
|
|
menuItem.Items.Add(mo);
|
|
|
|
|
}
|
|
|
|
|
Main.ToolBar.MenuDIY.Items.Add(menuItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-17 16:25:04 +00:00
|
|
|
|
foreach (ISub sub in Set["diy"])
|
2023-05-19 08:17:51 +00:00
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.DIY, sub.Name, () =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
RunDIY(sub.Info);
|
|
|
|
|
});
|
2023-04-01 19:31:28 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//加载游戏创意工坊插件
|
|
|
|
|
foreach (MainPlugin mp in Plugins)
|
2023-04-04 16:21:46 +00:00
|
|
|
|
mp.LoadDIY();
|
2023-04-01 19:31:28 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2023-11-02 16:01:18 +00:00
|
|
|
|
MessageBoxX.Show(e.ToString(), "由于插件引起的自定按钮加载错误".Translate());
|
2023-04-01 19:31:28 +00:00
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
2023-07-03 11:41:02 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载帮助器
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void LoadPetHelper()
|
2023-07-03 22:48:13 +00:00
|
|
|
|
{
|
2023-07-03 11:41:02 +00:00
|
|
|
|
petHelper = new PetHelper(this);
|
|
|
|
|
petHelper.Show();
|
|
|
|
|
}
|
2023-07-03 22:48:13 +00:00
|
|
|
|
|
2024-01-17 16:01:59 +00:00
|
|
|
|
public void RunDIY(string content)
|
2023-02-27 12:29:40 +00:00
|
|
|
|
{
|
2024-01-17 16:01:59 +00:00
|
|
|
|
if (content.Contains(@":\"))
|
2023-02-27 12:29:40 +00:00
|
|
|
|
{
|
2023-07-03 22:48:13 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-01-17 16:01:59 +00:00
|
|
|
|
if (!Set["v"][(gbol)"rundiy"])
|
|
|
|
|
{
|
|
|
|
|
MessageBoxX.Show("由于操作系统的设计,通过我们软件启动的程序可能会在任务管理器中归类为我们软件的子进程,这可能导致CPU/内存占用显示较高".Translate(),
|
|
|
|
|
"关于CPU/内存占用显示较高的一次性提示".Translate());
|
|
|
|
|
Set["v"][(gbol)"rundiy"] = true;
|
|
|
|
|
}
|
|
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo();
|
|
|
|
|
startInfo.FileName = content;
|
|
|
|
|
startInfo.UseShellExecute = false;
|
|
|
|
|
Process.Start(startInfo);
|
|
|
|
|
}
|
2024-02-22 14:05:59 +00:00
|
|
|
|
catch
|
2024-01-17 16:01:59 +00:00
|
|
|
|
{
|
2024-02-22 14:05:59 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-03-09 18:15:46 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Process.Start(content);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
var psi = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = content,
|
|
|
|
|
UseShellExecute = true
|
|
|
|
|
};
|
|
|
|
|
Process.Start(psi);
|
|
|
|
|
}
|
2024-02-22 14:05:59 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxX.Show("快捷键运行失败:无法运行指定内容".Translate() + '\n' + e.Message);
|
|
|
|
|
}
|
2024-01-17 16:01:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (content.Contains("://"))
|
2023-02-27 12:29:40 +00:00
|
|
|
|
{
|
2023-07-03 22:48:13 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(content);
|
2023-07-03 22:48:13 +00:00
|
|
|
|
}
|
2023-07-12 08:37:43 +00:00
|
|
|
|
catch (Exception e)
|
2023-07-03 22:48:13 +00:00
|
|
|
|
{
|
2024-01-17 16:01:59 +00:00
|
|
|
|
MessageBoxX.Show("快捷键运行失败:无法运行指定内容".Translate() + '\n' + e.Message);
|
2023-07-03 22:48:13 +00:00
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-16 10:12:25 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2023-11-24 07:10:30 +00:00
|
|
|
|
SendKeys.SendWait(content);
|
2023-08-16 10:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2024-01-17 16:01:59 +00:00
|
|
|
|
MessageBoxX.Show("快捷键运行失败:无法运行指定内容".Translate() + '\n' + e.Message);
|
2023-08-16 10:12:25 +00:00
|
|
|
|
}
|
2023-02-27 12:29:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-01 15:15:50 +00:00
|
|
|
|
|
2023-07-16 23:58:09 +00:00
|
|
|
|
public void ShowSetting(int page = -1)
|
2023-04-01 15:15:50 +00:00
|
|
|
|
{
|
2023-07-16 23:58:09 +00:00
|
|
|
|
if (page >= 0 && page <= 6)
|
|
|
|
|
winSetting.MainTab.SelectedIndex = page;
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
}
|
2024-03-14 11:31:34 +00:00
|
|
|
|
public void ShowWorkMenu(Work.WorkType type)
|
|
|
|
|
{
|
|
|
|
|
if (winWorkMenu == null)
|
|
|
|
|
{
|
|
|
|
|
winWorkMenu = new winWorkMenu(this, type);
|
|
|
|
|
winWorkMenu.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-27 16:45:14 +00:00
|
|
|
|
winWorkMenu.LsbCategory.SelectedIndex = (int)type;
|
2024-03-14 11:31:34 +00:00
|
|
|
|
winWorkMenu.Focus();
|
|
|
|
|
winWorkMenu.Topmost = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-16 23:58:09 +00:00
|
|
|
|
public void ShowBetterBuy(Food.FoodType type)
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(type);
|
2023-04-01 15:15:50 +00:00
|
|
|
|
}
|
2023-07-12 08:37:43 +00:00
|
|
|
|
int lowstrengthAskCountFood = 20;
|
|
|
|
|
int lowstrengthAskCountDrink = 20;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
private void lowStrength()
|
|
|
|
|
{
|
2024-03-19 11:29:23 +00:00
|
|
|
|
var sm = Core.Save.StrengthMax;
|
2024-05-08 13:01:44 +00:00
|
|
|
|
var sm75 = sm * 0.70;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
if (Set.AutoBuy && Core.Save.Money >= 100)
|
|
|
|
|
{
|
2024-02-04 09:58:34 +00:00
|
|
|
|
var havemoney = Core.Save.Money * 0.8;
|
2024-04-17 06:58:39 +00:00
|
|
|
|
List<Food> food = Foods.FindAll(x => x.Price >= 2 && x.Health >= -5 && x.Exp >= -10 && x.Likability >= 0 && x.Price < havemoney //桌宠不吃负面的食物
|
2023-08-23 19:50:31 +00:00
|
|
|
|
&& !x.IsOverLoad() // 不吃超模食物
|
2023-08-23 19:49:16 +00:00
|
|
|
|
);
|
|
|
|
|
|
2024-05-05 08:38:11 +00:00
|
|
|
|
if ((Core.Save.StrengthFood + Core.Save.StoreStrengthFood) < sm75)
|
|
|
|
|
{//饿了就该吃正餐
|
|
|
|
|
food = food.FindAll(x => x.Type == Food.FoodType.Meal && x.StrengthFood > Math.Min(sm * 0.20, 100));
|
2023-08-23 19:49:16 +00:00
|
|
|
|
if (food.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
var item = food[Function.Rnd.Next(food.Count)];
|
2023-08-24 20:22:09 +00:00
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
TakeItem(item);
|
2023-09-25 07:50:41 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)"stat_autobuy"]++;
|
2023-08-30 15:14:41 +00:00
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
2024-05-05 08:38:11 +00:00
|
|
|
|
else if ((Core.Save.StrengthDrink + Core.Save.StoreStrengthDrink) < sm75)
|
2023-08-23 19:49:16 +00:00
|
|
|
|
{
|
2024-05-05 08:38:11 +00:00
|
|
|
|
food = food.FindAll(x => x.Type == Food.FoodType.Drink && x.StrengthDrink > Math.Min(sm * 0.20, 50));
|
2023-08-23 19:49:16 +00:00
|
|
|
|
if (food.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
var item = food[Function.Rnd.Next(food.Count)];
|
2023-08-24 20:22:09 +00:00
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-09-12 04:51:49 +00:00
|
|
|
|
TakeItem(item);
|
2023-09-25 07:50:41 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)"stat_autobuy"]++;
|
2023-09-12 04:51:49 +00:00
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
|
|
|
|
}
|
2024-03-31 14:29:45 +00:00
|
|
|
|
else if (Core.Save.Feeling < Core.Save.FeelingMax * 0.50)
|
2023-09-12 04:51:49 +00:00
|
|
|
|
{
|
2024-03-31 14:29:45 +00:00
|
|
|
|
if (Set.AutoGift)
|
|
|
|
|
{
|
|
|
|
|
food = food.FindAll(x => x.Type == Food.FoodType.Gift && x.Feeling > Math.Min(Core.Save.FeelingMax * 0.10, 50));
|
|
|
|
|
if (food.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else // 没有自动购买礼物的可以试试自动购买零食能加点是一点
|
|
|
|
|
{
|
2024-07-04 07:16:04 +00:00
|
|
|
|
food = food.FindAll(x => x.Type == Food.FoodType.Snack && x.Feeling > Math.Min(Core.Save.FeelingMax * 0.10, 40));
|
2024-03-31 14:29:45 +00:00
|
|
|
|
if (food.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-09-12 04:51:49 +00:00
|
|
|
|
var item = food[Function.Rnd.Next(food.Count)];
|
|
|
|
|
Core.Save.Money -= item.Price * 0.2;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
TakeItem(item);
|
2023-09-25 07:50:41 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)"stat_autogift"]++;
|
2023-08-30 15:14:41 +00:00
|
|
|
|
Main.Display(item.GetGraph(), item.ImageSource, Main.DisplayToNomal);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-24 04:16:29 +00:00
|
|
|
|
else if (Core.Save.Mode == IGameSave.ModeType.Happy || Core.Save.Mode == IGameSave.ModeType.Nomal)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthFood < sm75 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountFood = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var txt = LowFoodText.FindAll(x => x.Mode == LowText.ModeType.H && (int)x.Like <= like);
|
|
|
|
|
if (txt.Count != 0)
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthFood > sm * 0.60)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
else if (Core.Save.StrengthFood > sm * 0.40)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Hunger, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthDrink < sm75 && Function.Rnd.Next(lowstrengthAskCountDrink--) == 0)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountDrink = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var txt = LowDrinkText.FindAll(x => x.Mode == LowText.ModeType.H && (int)x.Like <= like);
|
|
|
|
|
if (txt.Count != 0)
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthDrink > sm * 0.60)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
else if (Core.Save.StrengthDrink > sm * 0.40)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Thirsty, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-19 11:29:23 +00:00
|
|
|
|
var sm20 = sm * 0.20;
|
|
|
|
|
if (Core.Save.StrengthFood < sm * 0.60 && Function.Rnd.Next(lowstrengthAskCountFood--) == 0)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountFood = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
|
|
|
|
var txt = LowFoodText.FindAll(x => x.Mode == LowText.ModeType.L && (int)x.Like < like);
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthFood > sm * 0.40)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
else if (Core.Save.StrengthFood > sm20)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Hunger, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthDrink < sm * 0.60 && Function.Rnd.Next(lowstrengthAskCountDrink--) == 0)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
2023-07-12 08:37:43 +00:00
|
|
|
|
lowstrengthAskCountDrink = Set.InteractionCycle;
|
2023-06-18 22:20:06 +00:00
|
|
|
|
var like = Core.Save.Likability < 40 ? 0 : (Core.Save.Likability < 70 ? 1 : (Core.Save.Likability < 100 ? 2 : 3));
|
|
|
|
|
var txt = LowDrinkText.FindAll(x => x.Mode == LowText.ModeType.L && (int)x.Like < like);
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Save.StrengthDrink > sm * 0.40)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.L);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2024-03-19 11:29:23 +00:00
|
|
|
|
else if (Core.Save.StrengthDrink > sm20)
|
2023-06-18 22:20:06 +00:00
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.M);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt = txt.FindAll(x => x.Strength == LowText.StrengthType.S);
|
2024-03-28 07:28:31 +00:00
|
|
|
|
if (txt.Count != 0)
|
|
|
|
|
Main.Say(txt[Function.Rnd.Next(txt.Count)].TranslateText);
|
2023-06-18 22:20:06 +00:00
|
|
|
|
}
|
2023-07-18 18:09:51 +00:00
|
|
|
|
Main.DisplayStopForce(() => Main.Display(GraphType.Switch_Thirsty, AnimatType.Single, Main.DisplayToNomal));
|
2023-06-18 22:20:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-06-20 19:30:26 +00:00
|
|
|
|
}
|
2023-08-23 19:49:16 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 使用/食用物品 (不包括显示动画)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">物品</param>
|
|
|
|
|
public void TakeItem(Food item)
|
|
|
|
|
{
|
|
|
|
|
//获取吃腻时间
|
2023-10-12 16:06:14 +00:00
|
|
|
|
Main.LastInteractionTime = DateTime.Now;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
DateTime now = DateTime.Now;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
DateTime eattime = GameSavesData["buytime"].GetDateTime(item.Name, now);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
double eattimes = 0;
|
|
|
|
|
if (eattime > now)
|
|
|
|
|
{
|
|
|
|
|
eattimes = (eattime - now).TotalHours;
|
|
|
|
|
}
|
2024-04-17 07:04:17 +00:00
|
|
|
|
double eatuseps;
|
|
|
|
|
if (item.Type == FoodType.Gift)
|
2024-04-20 15:38:11 +00:00
|
|
|
|
eatuseps = Math.Max(0.5, 1 - eattimes * eattimes * 0.01);
|
2024-04-17 07:04:17 +00:00
|
|
|
|
else
|
2024-04-20 15:38:11 +00:00
|
|
|
|
eatuseps = Math.Max(0.5, 1 - eattimes * eattimes * 0.02);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
//开始加点
|
2024-04-20 15:38:11 +00:00
|
|
|
|
Core.Save.EatFood(item, eatuseps);
|
2023-08-23 19:49:16 +00:00
|
|
|
|
//吃腻了
|
2024-04-17 07:04:17 +00:00
|
|
|
|
eattimes += Math.Max(0.5, Math.Min(4, 2 - (item.Likability + item.Feeling / 2) / 5));
|
2023-09-22 16:18:24 +00:00
|
|
|
|
GameSavesData["buytime"].SetDateTime(item.Name, now.AddHours(eattimes));
|
2023-08-23 19:49:16 +00:00
|
|
|
|
//通知
|
|
|
|
|
item.LoadEatTimeSource(this);
|
2023-09-06 15:23:32 +00:00
|
|
|
|
item.NotifyOfPropertyChange("Description");
|
2023-08-23 19:49:16 +00:00
|
|
|
|
|
|
|
|
|
Core.Save.Money -= item.Price;
|
2024-04-15 06:06:05 +00:00
|
|
|
|
////吃完东西记得计算下状态
|
|
|
|
|
//Core.Save.Mode = Core.Save.CalMode();
|
2023-08-23 19:49:16 +00:00
|
|
|
|
//统计
|
2023-09-24 15:35:49 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)"stat_buytimes"]++;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gint)("buy_" + item.Name)]++;
|
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_betterbuy"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
switch (item.Type)
|
|
|
|
|
{
|
|
|
|
|
case Food.FoodType.Food:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_food"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Drink:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_drink"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Drug:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_drug"] += item.Price;
|
2023-09-24 15:35:49 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_drug_exp"] += item.Exp;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Snack:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_snack"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Functional:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_functional"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Meal:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_meal"] += item.Price;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Gift:
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_gift"] += item.Price;
|
2023-09-24 15:35:49 +00:00
|
|
|
|
GameSavesData.Statistics[(gdbe)"stat_bb_gift_like"] += item.Likability;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 18:09:51 +00:00
|
|
|
|
public void RunAction(string action)
|
|
|
|
|
{
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case "DisplayNomal":
|
|
|
|
|
Main.DisplayNomal();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayToNomal":
|
|
|
|
|
Main.DisplayToNomal();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayTouchHead":
|
|
|
|
|
Main.DisplayTouchHead();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayTouchBody":
|
|
|
|
|
Main.DisplayTouchBody();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayIdel":
|
|
|
|
|
Main.DisplayIdel();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayIdel_StateONE":
|
|
|
|
|
Main.DisplayIdel_StateONE();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplaySleep":
|
|
|
|
|
Main.DisplaySleep();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayRaised":
|
|
|
|
|
Main.DisplayRaised();
|
|
|
|
|
break;
|
|
|
|
|
case "DisplayMove":
|
|
|
|
|
Main.DisplayMove();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-23 20:46:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Steam统计相关变化
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Statistics_StatisticChanged(Statistics sender, string name, SetObject value)
|
|
|
|
|
{
|
|
|
|
|
if (name.StartsWith("stat_"))
|
|
|
|
|
{
|
2023-11-24 07:10:30 +00:00
|
|
|
|
SteamUserStats.SetStat(name, (int)value);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 计算统计数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void StatisticsCalHandle()
|
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
var stat = GameSavesData.Statistics;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
var save = Core.Save;
|
2024-02-02 13:42:23 +00:00
|
|
|
|
stat["stat_money"] = (SetObject)save.Money;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat["stat_level"] = save.Level;
|
|
|
|
|
stat["stat_likability"] = save.Likability;
|
|
|
|
|
|
|
|
|
|
stat[(gi64)"stat_total_time"] += (int)Set.LogicInterval;
|
|
|
|
|
switch (Main.State)
|
|
|
|
|
{
|
|
|
|
|
case Main.WorkingState.Work:
|
2024-03-15 10:25:40 +00:00
|
|
|
|
if (Main.NowWork.Type == Work.WorkType.Work)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat[(gi64)"stat_work_time"] += (int)Set.LogicInterval;
|
|
|
|
|
else
|
|
|
|
|
stat[(gi64)"stat_study_time"] += (int)Set.LogicInterval;
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Sleep:
|
2023-08-16 04:46:20 +00:00
|
|
|
|
stat[(gi64)"stat_sleep_time"] += (int)Set.LogicInterval;
|
2023-07-23 20:46:21 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-11-24 04:16:29 +00:00
|
|
|
|
if (save.Mode == IGameSave.ModeType.Ill)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
{
|
2023-08-15 07:47:49 +00:00
|
|
|
|
if (save.Money < 100)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat["stat_ill_nomoney"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Money < save.Level)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_level_g_money"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Feeling < 1)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_0_feel"] = 1;
|
|
|
|
|
if (save.StrengthDrink < 1)
|
|
|
|
|
stat["stat_0_f_sd"] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (save.Strength < 1 && save.Feeling < 1 && save.StrengthFood < 1 && save.StrengthDrink < 1)
|
|
|
|
|
stat["stat_0_all"] = 1;
|
|
|
|
|
if (save.StrengthFood < 1)
|
|
|
|
|
stat["stat_0_strengthfood"] = 1;
|
|
|
|
|
if (save.StrengthDrink < 1)
|
|
|
|
|
{
|
|
|
|
|
stat["stat_0_strengthdrink"] = 1;
|
|
|
|
|
if (save.StrengthFood < 1)
|
|
|
|
|
stat["stat_0_sd_sf"] = 1;
|
|
|
|
|
}
|
2024-07-04 07:15:16 +00:00
|
|
|
|
var smm = save.StrengthMax - 1;
|
2024-07-16 08:53:43 +00:00
|
|
|
|
if (save.Strength > smm && save.Feeling > save.FeelingMax - 1 && save.StrengthFood > smm && save.StrengthDrink > smm)
|
2023-07-23 20:46:21 +00:00
|
|
|
|
stat[(gint)"stat_100_all"]++;
|
|
|
|
|
|
|
|
|
|
if (IsSteamUser)
|
|
|
|
|
{
|
2023-11-24 07:10:30 +00:00
|
|
|
|
Task.Run(SteamUserStats.StoreStats);
|
2023-07-23 20:46:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-30 17:44:38 +00:00
|
|
|
|
/// <summary>
|
2023-11-14 12:33:44 +00:00
|
|
|
|
/// 加载游戏存档
|
2023-08-30 17:44:38 +00:00
|
|
|
|
/// </summary>
|
2023-11-14 12:33:44 +00:00
|
|
|
|
public bool SavesLoad(ILPS lps)
|
2023-08-06 02:00:03 +00:00
|
|
|
|
{
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (lps == null)
|
2023-08-12 06:09:20 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(lps.ToString()))
|
2023-08-16 18:16:42 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSave_v2 tmp;
|
|
|
|
|
if (GameSavesData != null)
|
|
|
|
|
tmp = new GameSave_v2(lps, GameSavesData);
|
|
|
|
|
else
|
2023-09-22 16:18:24 +00:00
|
|
|
|
{
|
|
|
|
|
var data = new LPS_D();
|
|
|
|
|
foreach (var item in Set.PetData_OLD)
|
|
|
|
|
{
|
|
|
|
|
if (item.Name.Contains("_"))
|
|
|
|
|
{
|
|
|
|
|
var strs = Sub.Split(item.Name, "_", 1);
|
|
|
|
|
data[strs[0]][(gstr)strs[1]] = item.Info;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
data.Add(new Line(item.Name, item.Info));
|
|
|
|
|
}
|
2024-02-02 16:48:20 +00:00
|
|
|
|
tmp = new GameSave_v2(lps, null, olddata: data);
|
2023-09-22 16:18:24 +00:00
|
|
|
|
}
|
|
|
|
|
if (tmp.GameSave == null)
|
2023-08-25 22:34:31 +00:00
|
|
|
|
return false;
|
2023-09-22 13:24:02 +00:00
|
|
|
|
if (tmp.GameSave.Money == 0 && tmp.GameSave.Likability == 0 && tmp.GameSave.Exp == 0
|
|
|
|
|
&& tmp.GameSave.StrengthDrink == 0 && tmp.GameSave.StrengthFood == 0)//数据全是0,可能是bug
|
|
|
|
|
return false;
|
2024-02-04 09:10:01 +00:00
|
|
|
|
if (tmp.GameSave.Exp < -1000000000)
|
|
|
|
|
{
|
|
|
|
|
tmp.GameSave.Exp = 1000000;
|
|
|
|
|
tmp.Data[(gbol)"round"] = true;
|
|
|
|
|
Dispatcher.Invoke(() => MessageBoxX.Show("检测到经验值超过 9,223,372,036 导致算数溢出\n已经自动回正".Translate(), "数据溢出警告".Translate()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (tmp.GameSave.Money < -1000000000)
|
|
|
|
|
{
|
|
|
|
|
tmp.GameSave.Money = 100000;
|
|
|
|
|
Dispatcher.Invoke(() => MessageBoxX.Show("检测到金钱超过 9,223,372,036 导致算数溢出\n已经自动回正".Translate(), "数据溢出警告".Translate()));
|
|
|
|
|
}
|
2024-04-01 10:21:42 +00:00
|
|
|
|
|
2024-03-22 08:02:47 +00:00
|
|
|
|
if (tmp.Data[(gbol)"round"])
|
|
|
|
|
{//根据游玩时间补偿数据溢出
|
2024-03-22 15:41:37 +00:00
|
|
|
|
Dispatcher.Invoke(() => MessageBoxX.Show("您以前遭遇过数据溢出, 已根据游戏时长自动添加进当前数值".Translate(), "数据溢出恢复".Translate()));
|
2024-03-22 08:02:47 +00:00
|
|
|
|
var totalhour = (int)(tmp.Statistics[(gint)"stat_total_time"] / 3600);//总计游玩时间/小时
|
|
|
|
|
if (totalhour < 500)
|
|
|
|
|
{
|
|
|
|
|
tmp.GameSave.Exp += totalhour * 200;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
double lm = Math.Sqrt(totalhour / 500);
|
2024-03-22 15:41:37 +00:00
|
|
|
|
tmp.GameSave.LevelMax += (int)lm;
|
2024-03-22 08:02:47 +00:00
|
|
|
|
tmp.GameSave.Exp += (totalhour % 500 + (lm - (int)lm) * 500) * 200;
|
2024-03-22 15:41:37 +00:00
|
|
|
|
|
2024-03-22 08:02:47 +00:00
|
|
|
|
}
|
2024-03-22 15:41:37 +00:00
|
|
|
|
tmp.GameSave.LikabilityMax += totalhour / 10;
|
|
|
|
|
tmp.Data[(gbol)"round"] = false;
|
2024-03-22 08:02:47 +00:00
|
|
|
|
}
|
2023-09-22 13:24:02 +00:00
|
|
|
|
GameSavesData = tmp;
|
|
|
|
|
Core.Save = tmp.GameSave;
|
2023-09-22 16:37:23 +00:00
|
|
|
|
HashCheck = HashCheck;
|
2024-08-14 04:55:10 +00:00
|
|
|
|
GameSavesData.GameSave.Event_LevelUp += LevelUP;
|
2023-08-12 06:09:20 +00:00
|
|
|
|
return true;
|
2023-08-06 02:00:03 +00:00
|
|
|
|
}
|
2023-11-17 08:08:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-12 16:01:34 +00:00
|
|
|
|
private void Handle_Steam(Main obj)
|
|
|
|
|
{
|
2024-03-21 07:53:03 +00:00
|
|
|
|
string jointab = " ";
|
|
|
|
|
if (winMutiPlayer != null)
|
|
|
|
|
{
|
|
|
|
|
if (winMutiPlayer.Joinable)
|
|
|
|
|
jointab += "可加入".Translate();
|
|
|
|
|
SteamFriends.SetRichPresence("steam_player_group", winMutiPlayer.LobbyID.ToString("x"));
|
|
|
|
|
SteamFriends.SetRichPresence("steam_player_group_size", winMutiPlayer.lb.MemberCount.ToString());
|
|
|
|
|
}
|
2024-03-21 08:24:07 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_player_group_size", "0");
|
|
|
|
|
}
|
2023-11-17 08:08:31 +00:00
|
|
|
|
if (App.MainWindows.Count > 1)
|
2023-09-25 08:52:20 +00:00
|
|
|
|
{
|
2023-11-17 08:08:31 +00:00
|
|
|
|
if (App.MainWindows.FirstOrDefault() != this)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string str = "";
|
|
|
|
|
int lv = 0;
|
|
|
|
|
int workcount = 0;
|
|
|
|
|
int sleepcount = 0;
|
|
|
|
|
int musiccount = 0;
|
|
|
|
|
int allcount = App.MainWindows.Count * 2 / 3;
|
|
|
|
|
foreach (var item in App.MainWindows)
|
|
|
|
|
{
|
|
|
|
|
str += item.GameSavesData.GameSave.Name + ",";
|
|
|
|
|
if (item.HashCheck)
|
|
|
|
|
{
|
|
|
|
|
lv += item.GameSavesData.GameSave.Level;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
lv = int.MinValue;
|
|
|
|
|
switch (item.Main.State)
|
|
|
|
|
{
|
|
|
|
|
case Main.WorkingState.Work:
|
|
|
|
|
workcount++;
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Sleep:
|
|
|
|
|
sleepcount++;
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Nomal:
|
|
|
|
|
if (item.Main.DisplayType.Name == "music")
|
|
|
|
|
musiccount++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SteamFriends.SetRichPresence("usernames", str.Trim(','));
|
|
|
|
|
if (lv > 0)
|
|
|
|
|
{
|
2024-03-21 07:53:03 +00:00
|
|
|
|
SteamFriends.SetRichPresence("lv", $" (lv{lv}/{App.MainWindows.Count})" + jointab);
|
2023-11-17 08:08:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-21 07:53:03 +00:00
|
|
|
|
SteamFriends.SetRichPresence("lv", " " + jointab);
|
2023-11-17 08:08:31 +00:00
|
|
|
|
}
|
|
|
|
|
if (workcount > allcount)
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_MUTI_Work");
|
|
|
|
|
}
|
|
|
|
|
else if (sleepcount > allcount)
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_MUTI_Sleep");
|
|
|
|
|
}
|
|
|
|
|
else if (musiccount > allcount)
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_MUTI_Music");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_MUTI_Play");
|
|
|
|
|
}
|
2023-08-12 16:01:34 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-11-17 08:08:31 +00:00
|
|
|
|
if (HashCheck)
|
2023-08-12 16:01:34 +00:00
|
|
|
|
{
|
2024-03-21 07:53:03 +00:00
|
|
|
|
SteamFriends.SetRichPresence("lv", $" (lv{GameSavesData.GameSave.Level})" + jointab);
|
2023-11-17 08:08:31 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2024-03-21 07:53:03 +00:00
|
|
|
|
SteamFriends.SetRichPresence("lv", " " + jointab);
|
2023-11-17 08:08:31 +00:00
|
|
|
|
}
|
2023-11-24 04:16:29 +00:00
|
|
|
|
if (Core.Save.Mode == IGameSave.ModeType.Ill)
|
2023-11-17 08:08:31 +00:00
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Ill");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("mode", (Core.Save.Mode.ToString() + "ly").Translate());
|
|
|
|
|
switch (obj.State)
|
|
|
|
|
{
|
|
|
|
|
case Main.WorkingState.Work:
|
2024-03-15 10:25:40 +00:00
|
|
|
|
SteamFriends.SetRichPresence("work", obj.NowWork.Name.Translate());
|
2023-11-17 08:08:31 +00:00
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Work");
|
|
|
|
|
break;
|
|
|
|
|
case Main.WorkingState.Sleep:
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Sleep");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (obj.DisplayType.Name == "music")
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_Music");
|
|
|
|
|
else
|
2023-09-25 08:52:20 +00:00
|
|
|
|
{
|
2023-11-17 08:08:31 +00:00
|
|
|
|
switch (obj.DisplayType.Type)
|
|
|
|
|
{
|
|
|
|
|
case GraphType.Move:
|
|
|
|
|
SteamFriends.SetRichPresence("idel", "乱爬".Translate());
|
|
|
|
|
break;
|
|
|
|
|
case GraphType.Idel:
|
|
|
|
|
case GraphType.StateONE:
|
|
|
|
|
case GraphType.StateTWO:
|
|
|
|
|
SteamFriends.SetRichPresence("idel", "发呆".Translate());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
SteamFriends.SetRichPresence("idel", "闲逛".Translate());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_IDLE");
|
2023-09-25 08:52:20 +00:00
|
|
|
|
}
|
2023-11-17 08:08:31 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-08-12 16:01:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-15 04:04:08 +00:00
|
|
|
|
private bool? AudioPlayingVolumeOK = null;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获得当前系统音乐播放音量
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float AudioPlayingVolume()
|
|
|
|
|
{
|
2024-04-07 07:00:34 +00:00
|
|
|
|
if (AudioPlayingVolumeOK == null)
|
|
|
|
|
{//第一调用检查是否支持
|
|
|
|
|
try
|
|
|
|
|
{//后续容错可能是偶发性
|
|
|
|
|
using (var enumerator = new MMDeviceEnumerator())
|
|
|
|
|
{
|
|
|
|
|
if (enumerator.HasDefaultAudioEndpoint(DataFlow.Render, Role.Console))
|
|
|
|
|
{
|
|
|
|
|
var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
|
|
|
|
|
AudioPlayingVolumeOK = true;
|
|
|
|
|
return device.AudioMeterInformation.MasterPeakValue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AudioPlayingVolumeOK = false;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
AudioPlayingVolumeOK = false;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (AudioPlayingVolumeOK == false)
|
2024-04-01 10:21:42 +00:00
|
|
|
|
{
|
2024-04-07 07:00:34 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{//后续容错可能是偶发性
|
2024-04-01 10:21:42 +00:00
|
|
|
|
using (var enumerator = new MMDeviceEnumerator())
|
|
|
|
|
{
|
2024-04-03 05:48:48 +00:00
|
|
|
|
if (enumerator.HasDefaultAudioEndpoint(DataFlow.Render, Role.Console))
|
|
|
|
|
{
|
|
|
|
|
var device = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
|
|
|
|
|
return device.AudioMeterInformation.MasterPeakValue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2024-04-01 10:21:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
2023-08-15 06:09:48 +00:00
|
|
|
|
{
|
2024-04-01 10:21:42 +00:00
|
|
|
|
return -1;
|
2023-08-15 06:09:48 +00:00
|
|
|
|
}
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 音乐检测器
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Handle_Music(Main obj)
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (MusicTimer.Enabled == false && Core.Graph.FindGraphs("music", AnimatType.B_Loop, Core.Save.Mode) != null &&
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Main.IsIdel && AudioPlayingVolume() > Set.MusicCatch)
|
|
|
|
|
{
|
|
|
|
|
catch_MusicVolSum = 0;
|
|
|
|
|
catch_MusicVolCount = 0;
|
|
|
|
|
CurrMusicType = null;
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
Task.Run(() =>
|
2024-02-04 08:58:09 +00:00
|
|
|
|
{//等3秒看看识别结果
|
|
|
|
|
Thread.Sleep(3000);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
|
|
|
|
|
if (CurrMusicType != null && Main.IsIdel)
|
|
|
|
|
{//识别通过,开始跑跳舞动画
|
2023-09-24 15:35:49 +00:00
|
|
|
|
//先统计下
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_music"]++;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display(Core.Graph.FindGraph("music", AnimatType.A_Start, Core.Save.Mode), Display_Music);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ //失败或有东西阻塞,停止检测
|
|
|
|
|
MusicTimer.Stop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Display_Music()
|
|
|
|
|
{
|
|
|
|
|
if (CurrMusicType.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (CurrMusicType.Value)
|
|
|
|
|
{//播放更刺激的
|
2023-08-11 02:47:09 +00:00
|
|
|
|
var mg = Core.Graph.FindGraph("music", AnimatType.Single, Core.Save.Mode);
|
|
|
|
|
mg ??= Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Main.Display(mg, Display_Music);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display(Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode), Display_Music);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
Main.Display("music", AnimatType.C_End, Main.DisplayToNomal);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void MusicTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
|
|
|
{
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (!(Main.IsIdel || Main.DisplayType.Name == "music"))//不是音乐,被掐断
|
|
|
|
|
return;
|
2023-08-10 15:48:27 +00:00
|
|
|
|
catch_MusicVolSum += AudioPlayingVolume();
|
|
|
|
|
catch_MusicVolCount++;
|
2024-02-04 09:08:01 +00:00
|
|
|
|
if (catch_MusicVolCount >= 10)
|
2023-08-10 11:34:11 +00:00
|
|
|
|
{
|
|
|
|
|
double ans = catch_MusicVolSum / catch_MusicVolCount;
|
2023-08-10 15:48:27 +00:00
|
|
|
|
catch_MusicVolSum /= 4;
|
|
|
|
|
catch_MusicVolCount /= 4;
|
2023-08-10 11:34:11 +00:00
|
|
|
|
if (ans > Set.MusicCatch)
|
|
|
|
|
{
|
|
|
|
|
var bef = CurrMusicType;
|
|
|
|
|
CurrMusicType = ans > Set.MusicMax;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (bef != null && bef != CurrMusicType)
|
2023-08-10 11:34:11 +00:00
|
|
|
|
Display_Music();
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurrMusicType = null;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
if (Main.DisplayType.Name == "music")
|
|
|
|
|
Main.Display("music", AnimatType.C_End, Main.DisplayToNomal);
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-11 02:47:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MusicTimer.Start();
|
|
|
|
|
}
|
2023-08-10 11:34:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Timer MusicTimer;
|
|
|
|
|
private double catch_MusicVolSum;
|
|
|
|
|
private int catch_MusicVolCount;
|
2023-08-11 02:47:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前音乐播放状态
|
|
|
|
|
/// </summary>
|
2023-08-10 11:34:11 +00:00
|
|
|
|
public bool? CurrMusicType { get; private set; }
|
2023-08-11 02:47:09 +00:00
|
|
|
|
|
|
|
|
|
int LastDiagnosisTime = 0;
|
2023-08-25 22:31:44 +00:00
|
|
|
|
|
2023-08-11 02:47:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上传遥测文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DiagnosisUPLoad()
|
|
|
|
|
{
|
|
|
|
|
if (!IsSteamUser)
|
|
|
|
|
return;//不遥测非Steam用户
|
|
|
|
|
if (!Set.DiagnosisDayEnable)
|
|
|
|
|
return;//不遥测不参加遥测的用户
|
|
|
|
|
if (!Set.Diagnosis)
|
|
|
|
|
return;//不遥测不参加遥测的用户
|
|
|
|
|
if (!HashCheck)
|
|
|
|
|
return;//不遥测数据修改过的用户
|
|
|
|
|
if (LastDiagnosisTime++ < Set.DiagnosisInterval)
|
|
|
|
|
return;//等待间隔
|
|
|
|
|
LastDiagnosisTime = 0;
|
2024-06-13 12:48:14 +00:00
|
|
|
|
string _url = "https://report.exlb.net/VPET/Report";
|
2023-08-11 02:47:09 +00:00
|
|
|
|
//参数
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.Append("action=data");
|
2023-11-24 07:10:30 +00:00
|
|
|
|
sb.Append($"&steamid={SteamClient.SteamId.Value}");
|
2023-08-21 04:34:50 +00:00
|
|
|
|
sb.Append($"&ver={version}");
|
2023-08-11 02:47:09 +00:00
|
|
|
|
sb.Append("&save=");
|
|
|
|
|
sb.AppendLine(HttpUtility.UrlEncode(Core.Save.ToLine().ToString() + Set.ToString()));
|
|
|
|
|
//游戏设置比存档更重要,桌宠大部分内容存设置里了,所以一起上传
|
2024-03-19 11:29:23 +00:00
|
|
|
|
#pragma warning disable SYSLIB0014 // 类型或成员已过时
|
2023-08-11 02:47:09 +00:00
|
|
|
|
var request = (HttpWebRequest)WebRequest.Create(_url);
|
2024-03-19 11:29:23 +00:00
|
|
|
|
#pragma warning restore SYSLIB0014 // 类型或成员已过时
|
2023-08-11 02:47:09 +00:00
|
|
|
|
request.Method = "POST";
|
|
|
|
|
request.ContentType = "application/x-www-form-urlencoded";//ContentType
|
|
|
|
|
byte[] byteData = Encoding.UTF8.GetBytes(sb.ToString());
|
|
|
|
|
int length = byteData.Length;
|
|
|
|
|
request.ContentLength = length;
|
|
|
|
|
using (Stream writer = request.GetRequestStream())
|
|
|
|
|
{
|
|
|
|
|
writer.Write(byteData, 0, length);
|
|
|
|
|
writer.Close();
|
|
|
|
|
writer.Dispose();
|
|
|
|
|
}
|
|
|
|
|
string responseString;
|
|
|
|
|
using (var response = (HttpWebResponse)request.GetResponse())
|
|
|
|
|
{
|
|
|
|
|
responseString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
|
|
|
|
response.Dispose();
|
|
|
|
|
}
|
|
|
|
|
if (responseString == "IP times Max")
|
|
|
|
|
{
|
|
|
|
|
Set.DiagnosisDayEnable = false;
|
|
|
|
|
}
|
|
|
|
|
#if DEBUG
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("诊断上传失败");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
2023-08-12 07:13:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭指示器,默认为true
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool CloseConfirm { get; private set; } = true;
|
2023-09-03 18:55:41 +00:00
|
|
|
|
|
2023-09-04 08:45:32 +00:00
|
|
|
|
public List<ITalkAPI> TalkAPI { get; } = new List<ITalkAPI>();
|
2023-09-03 18:55:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前选择的对话框index
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int TalkAPIIndex = -1;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前对话框
|
|
|
|
|
/// </summary>
|
2023-09-04 08:45:32 +00:00
|
|
|
|
public ITalkAPI TalkBoxCurr
|
2023-09-03 18:55:41 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return null;
|
|
|
|
|
return TalkAPI[TalkAPIIndex];
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-09 18:05:27 +00:00
|
|
|
|
|
2024-03-12 16:38:23 +00:00
|
|
|
|
Grid IMainWindow.MGHost => MGHost;
|
|
|
|
|
|
|
|
|
|
Grid IMainWindow.PetGrid => MGrid;
|
2024-03-15 17:33:56 +00:00
|
|
|
|
internal MWController MWController { get; set; }
|
2023-09-04 08:45:32 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 移除所有聊天对话框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void RemoveTalkBox()
|
|
|
|
|
{
|
|
|
|
|
if (TalkBox != null)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Remove(TalkBox);
|
|
|
|
|
TalkBox = null;
|
|
|
|
|
}
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return;
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Remove(TalkAPI[TalkAPIIndex].This);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载自定义对话框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void LoadTalkDIY()
|
|
|
|
|
{
|
|
|
|
|
RemoveTalkBox();
|
|
|
|
|
if (TalkAPIIndex == -1)
|
|
|
|
|
return;
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Add(TalkAPI[TalkAPIIndex].This);
|
|
|
|
|
}
|
2023-08-25 22:08:13 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 超模工作检查
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool WorkCheck(Work work)
|
|
|
|
|
{
|
|
|
|
|
//看看是否超模
|
|
|
|
|
if (HashCheck && work.IsOverLoad())
|
|
|
|
|
{
|
2024-04-03 05:48:48 +00:00
|
|
|
|
if (Set["gameconfig"].GetBool("noAutoCal"))
|
|
|
|
|
{
|
|
|
|
|
if (MessageBoxX.Show("当前工作数据属性超模,是否继续工作?\n超模工作可能会导致游戏发生不可预料的错误\n超模工作不影响大部分成就解锁\n可以在设置中开启自动计算自动为工作设置合理数值"
|
|
|
|
|
.Translate(), "超模工作提醒".Translate(), MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
HashCheck = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
2023-08-25 22:08:13 +00:00
|
|
|
|
{
|
2024-04-03 05:48:48 +00:00
|
|
|
|
MessageBoxX.Show("当前工作数据属性超模,已自动取消".Translate(), "超模工作提醒".Translate());
|
2023-08-25 22:08:13 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-10-11 17:24:35 +00:00
|
|
|
|
/// <summary>
|
2023-11-14 12:33:44 +00:00
|
|
|
|
/// 游戏加载
|
2023-10-11 17:24:35 +00:00
|
|
|
|
/// </summary>
|
2023-11-14 12:33:44 +00:00
|
|
|
|
public void GameInitialization()
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
|
|
|
|
App.MainWindows.Add(this);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//加载游戏设置
|
|
|
|
|
if (new FileInfo(ExtensionValue.BaseDirectory + @$"\Setting{PrefixSave}.lps").Exists)
|
|
|
|
|
{
|
2024-03-09 18:15:46 +00:00
|
|
|
|
Set = new Setting(this, File.ReadAllText(ExtensionValue.BaseDirectory + @$"\Setting{PrefixSave}.lps"));
|
2023-10-11 17:24:35 +00:00
|
|
|
|
}
|
2024-07-04 07:47:06 +00:00
|
|
|
|
if (PrefixSave == "" && (Set == null || (Set != null && !Set["SingleTips"].GetBool("helloworld"))) && File.Exists(ExtensionValue.BaseDirectory + @"\Setting.bkp"))
|
2024-07-04 07:31:34 +00:00
|
|
|
|
{//如果设置是损坏的, 读取备份设置
|
2024-05-05 08:41:55 +00:00
|
|
|
|
Set = new Setting(this, File.ReadAllText(ExtensionValue.BaseDirectory + @"\Setting.bkp"));
|
2024-04-17 08:38:52 +00:00
|
|
|
|
}
|
2024-07-04 07:47:06 +00:00
|
|
|
|
|
|
|
|
|
Set ??= new Setting(this, "Setting#VPET:|\n");
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
var visualTree = new FrameworkElementFactory(typeof(Border));
|
2023-11-24 07:10:30 +00:00
|
|
|
|
visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(BackgroundProperty));
|
2023-10-11 17:24:35 +00:00
|
|
|
|
var childVisualTree = new FrameworkElementFactory(typeof(ContentPresenter));
|
2023-11-24 07:10:30 +00:00
|
|
|
|
childVisualTree.SetValue(ClipToBoundsProperty, true);
|
2023-10-11 17:24:35 +00:00
|
|
|
|
visualTree.AppendChild(childVisualTree);
|
|
|
|
|
|
|
|
|
|
Template = new ControlTemplate
|
|
|
|
|
{
|
|
|
|
|
TargetType = typeof(Window),
|
|
|
|
|
VisualTree = visualTree,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2024-03-12 11:36:47 +00:00
|
|
|
|
//MGrid.Height = 500 * Set.ZoomLevel;
|
|
|
|
|
MGrid.Width = 500 * Set.ZoomLevel;
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
double L = 0, T = 0;
|
|
|
|
|
if (Set.StartRecordLast)
|
|
|
|
|
{
|
|
|
|
|
var point = Set.StartRecordLastPoint;
|
|
|
|
|
if (point.X != 0 || point.Y != 0)
|
|
|
|
|
{
|
|
|
|
|
L = point.X;
|
|
|
|
|
T = point.Y;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var point = Set.StartRecordPoint;
|
|
|
|
|
L = point.X; T = point.Y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Left = L;
|
|
|
|
|
Top = T;
|
|
|
|
|
|
|
|
|
|
// control position inside bounds
|
2024-03-15 17:33:56 +00:00
|
|
|
|
MWController = new MWController(this);
|
|
|
|
|
Core.Controller = MWController;
|
2024-03-12 11:36:47 +00:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
double dist;
|
|
|
|
|
if ((dist = Core.Controller.GetWindowsDistanceLeft()) < 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
Dispatcher.Invoke(() => Left -= dist);
|
|
|
|
|
}
|
|
|
|
|
if ((dist = Core.Controller.GetWindowsDistanceRight()) < 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
Dispatcher.Invoke(() => Left += dist);
|
|
|
|
|
}
|
|
|
|
|
if ((dist = Core.Controller.GetWindowsDistanceUp()) < 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
Dispatcher.Invoke(() => Top -= dist);
|
|
|
|
|
}
|
|
|
|
|
if ((dist = Core.Controller.GetWindowsDistanceDown()) < 0)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
Dispatcher.Invoke(() => Top += dist);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-10-11 17:24:35 +00:00
|
|
|
|
if (Set.TopMost)
|
|
|
|
|
{
|
|
|
|
|
Topmost = true;
|
|
|
|
|
}
|
2023-10-31 07:25:23 +00:00
|
|
|
|
|
2023-10-11 17:24:35 +00:00
|
|
|
|
//不存在就关掉
|
|
|
|
|
var modpath = new DirectoryInfo(ModPath + @"\0000_core\pet\vup");
|
|
|
|
|
if (!modpath.Exists)
|
|
|
|
|
{
|
2023-11-14 13:24:57 +00:00
|
|
|
|
MessageBoxX.Show("缺少模组Core,无法启动桌宠\nMissing module Core, can't start up", "启动错误 boot error", Panuon.WPF.UI.MessageBoxIcon.Error);
|
2023-10-13 15:31:52 +00:00
|
|
|
|
Close();
|
2023-10-11 17:24:35 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
string errstr = "游戏发生错误,可能是".Translate() + (string.IsNullOrWhiteSpace(CoreMOD.NowLoading) ?
|
|
|
|
|
"游戏或者MOD".Translate() : $"MOD({CoreMOD.NowLoading})") +
|
|
|
|
|
"导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n".Translate()
|
|
|
|
|
+ e.ToString();
|
|
|
|
|
MessageBoxX.Show(errstr, "游戏致命性错误".Translate() + ' ' + "启动错误".Translate(), Panuon.WPF.UI.MessageBoxIcon.Error);
|
2023-11-14 12:33:44 +00:00
|
|
|
|
Close();
|
2023-10-11 17:24:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-14 12:33:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 支持多开的启动方式
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="prefixsave">存档前缀</param>
|
|
|
|
|
public MainWindow(string prefixsave)
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
2023-11-14 12:33:44 +00:00
|
|
|
|
PrefixSave = prefixsave;
|
|
|
|
|
if (prefixsave != string.Empty && !PrefixSave.StartsWith("-"))
|
|
|
|
|
PrefixSave = '-' + prefixsave;
|
|
|
|
|
|
2023-11-17 17:27:49 +00:00
|
|
|
|
IsSteamUser = App.MainWindows[0].IsSteamUser;
|
|
|
|
|
|
2023-11-14 12:33:44 +00:00
|
|
|
|
//处理ARGS
|
|
|
|
|
Args = new LPS_D();
|
|
|
|
|
foreach (var str in App.Args)
|
|
|
|
|
{
|
|
|
|
|
Args.Add(new Line(str));
|
|
|
|
|
}
|
|
|
|
|
_dwmEnabled = Win32.Dwmapi.DwmIsCompositionEnabled();
|
|
|
|
|
_hwnd = new WindowInteropHelper(this).EnsureHandle();
|
|
|
|
|
|
|
|
|
|
GameInitialization();
|
|
|
|
|
|
2023-10-11 17:24:35 +00:00
|
|
|
|
//加载所有MOD
|
|
|
|
|
List<DirectoryInfo> Path = new List<DirectoryInfo>();
|
|
|
|
|
Path.AddRange(new DirectoryInfo(ModPath).EnumerateDirectories());
|
|
|
|
|
|
|
|
|
|
var workshop = Set["workshop"];
|
2024-03-17 16:25:04 +00:00
|
|
|
|
foreach (ISub ws in workshop)
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
|
|
|
|
Path.Add(new DirectoryInfo(ws.Name));
|
|
|
|
|
}
|
2023-11-17 08:08:31 +00:00
|
|
|
|
|
|
|
|
|
|
2023-11-14 12:33:44 +00:00
|
|
|
|
Task.Run(() => GameLoad(Path));
|
|
|
|
|
}
|
2024-05-10 08:04:08 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// MOD地址
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<DirectoryInfo> MODPath { get; private set; }
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IModInfo> ModInfo => CoreMODs;
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IModInfo> OnModInfo => CoreMODs.FindAll(x => x.IsOnMOD(this));
|
|
|
|
|
|
2023-11-14 12:33:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载游戏
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Path">MOD地址</param>
|
2024-03-15 10:25:40 +00:00
|
|
|
|
public async Task GameLoad(List<DirectoryInfo> Path)
|
2023-11-14 12:33:44 +00:00
|
|
|
|
{
|
2024-05-12 05:48:23 +00:00
|
|
|
|
MODPath = Path.GroupBy(x => x.FullName).Select(group => group.First()).ToList();
|
2023-10-11 17:24:35 +00:00
|
|
|
|
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD"));
|
|
|
|
|
//加载mod
|
2024-05-10 08:04:08 +00:00
|
|
|
|
foreach (DirectoryInfo di in MODPath)
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(di.FullName + @"\info.lps"))
|
|
|
|
|
continue;
|
|
|
|
|
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = $"Loading MOD: {di.Name}"));
|
|
|
|
|
CoreMODs.Add(new CoreMOD(di, this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CoreMOD.NowLoading = null;
|
|
|
|
|
|
2023-11-24 07:10:30 +00:00
|
|
|
|
//判断是否需要清空缓存
|
|
|
|
|
if (App.MainWindows.Count == 1 && Set.LastCacheDate < CoreMODs.Max(x => x.CacheDate))
|
|
|
|
|
{//需要清理缓存
|
|
|
|
|
Set.LastCacheDate = DateTime.Now;
|
|
|
|
|
if (Directory.Exists(GraphCore.CachePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(GraphCore.CachePath, true);
|
|
|
|
|
Directory.CreateDirectory(GraphCore.CachePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-05-13 16:55:27 +00:00
|
|
|
|
|
|
|
|
|
await Dispatcher.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
MessageBoxXSettings.Setting.OKButtonContent = "好的".Translate();
|
|
|
|
|
MessageBoxXSettings.Setting.CancelButtonContent = "取消".Translate();
|
|
|
|
|
MessageBoxXSettings.Setting.YesButtonContent = "是".Translate();
|
|
|
|
|
MessageBoxXSettings.Setting.NoButtonContent = "否".Translate();
|
|
|
|
|
PendingBoxSettings.Setting.CancelButtonContent = "取消".Translate();
|
|
|
|
|
LoadingText.Content = "尝试加载游戏MOD".Translate();
|
|
|
|
|
});
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
2024-03-21 08:44:07 +00:00
|
|
|
|
//旧版本设置兼容
|
2024-03-22 08:02:47 +00:00
|
|
|
|
if (Set.PetGraph == "默认虚拟桌宠")
|
2024-03-21 08:44:07 +00:00
|
|
|
|
Set.PetGraph = "vup";
|
|
|
|
|
|
2023-10-11 17:24:35 +00:00
|
|
|
|
//当前桌宠动画
|
|
|
|
|
var petloader = Pets.Find(x => x.Name == Set.PetGraph);
|
|
|
|
|
petloader ??= Pets[0];
|
2024-03-19 10:54:20 +00:00
|
|
|
|
//去除其他语言内容
|
|
|
|
|
var tag = petloader.Config.Data.GetString("tag", "all").Split(',');
|
|
|
|
|
LowDrinkText.RemoveAll(x => !x.FindTag(tag));
|
|
|
|
|
LowFoodText.RemoveAll(x => !x.FindTag(tag));
|
|
|
|
|
ClickTexts.RemoveAll(x => !x.FindTag(tag));
|
|
|
|
|
SelectTexts.RemoveAll(x => !x.FindTag(tag));
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏存档".Translate()));
|
|
|
|
|
//加载存档
|
2023-11-14 12:33:44 +00:00
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Save.lps")) //有老的旧存档,优先旧存档
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!SavesLoad(new LpsDocument(File.ReadAllText(ExtensionValue.BaseDirectory + @"\Save.lps"))))
|
|
|
|
|
{
|
|
|
|
|
//如果加载存档失败了,试试加载备份,如果没备份,就新建一个
|
|
|
|
|
LoadLatestSave(petloader.PetName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBoxX.Show("存档损毁,无法加载该存档\n可能是数据溢出/超模导致的" + '\n' + ex.Message, "存档损毁".Translate());
|
|
|
|
|
//如果加载存档失败了,试试加载备份,如果没备份,就新建一个
|
|
|
|
|
LoadLatestSave(petloader.PetName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
//如果加载存档失败了,试试加载备份,如果没备份,就新建一个
|
|
|
|
|
LoadLatestSave(petloader.PetName);
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
//加载数据合理化:食物
|
|
|
|
|
if (!Set["gameconfig"].GetBool("noAutoCal"))
|
|
|
|
|
{
|
|
|
|
|
foreach (Food f in Foods)
|
|
|
|
|
{
|
|
|
|
|
if (f.IsOverLoad())
|
|
|
|
|
{
|
|
|
|
|
f.Price = Math.Max((int)f.RealPrice, 1);
|
|
|
|
|
f.isoverload = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//var food = new Food();
|
|
|
|
|
foreach (var selet in SelectTexts)
|
|
|
|
|
{
|
|
|
|
|
selet.Exp = Math.Max(Math.Min(selet.Exp, 1000), -1000);
|
2024-04-22 08:38:01 +00:00
|
|
|
|
selet.Feeling = Math.Max(Math.Min(selet.Feeling, 100), -100);
|
|
|
|
|
selet.Health = Math.Max(Math.Min(selet.Health, 100), -100);
|
2023-10-11 17:24:35 +00:00
|
|
|
|
selet.Likability = Math.Max(Math.Min(selet.Likability, 50), -50);
|
|
|
|
|
selet.Money = Math.Max(Math.Min(selet.Money, 1000), -1000);
|
|
|
|
|
selet.Strength = Math.Max(Math.Min(selet.Strength, 1000), -1000);
|
|
|
|
|
selet.StrengthDrink = Math.Max(Math.Min(selet.StrengthDrink, 1000), -1000);
|
|
|
|
|
selet.StrengthFood = Math.Max(Math.Min(selet.StrengthFood, 1000), -1000);
|
|
|
|
|
}
|
|
|
|
|
foreach (var selet in ClickTexts)
|
|
|
|
|
{
|
|
|
|
|
selet.Exp = Math.Max(Math.Min(selet.Exp, 1000), -1000);
|
|
|
|
|
selet.Feeling = Math.Max(Math.Min(selet.Feeling, 1000), -1000);
|
2024-04-22 08:38:01 +00:00
|
|
|
|
selet.Health = Math.Max(Math.Min(selet.Health, 100), -100);
|
2023-10-11 17:24:35 +00:00
|
|
|
|
selet.Likability = Math.Max(Math.Min(selet.Likability, 50), -50);
|
|
|
|
|
selet.Money = Math.Max(Math.Min(selet.Money, 1000), -1000);
|
|
|
|
|
selet.Strength = Math.Max(Math.Min(selet.Strength, 1000), -1000);
|
|
|
|
|
selet.StrengthDrink = Math.Max(Math.Min(selet.StrengthDrink, 1000), -1000);
|
|
|
|
|
selet.StrengthFood = Math.Max(Math.Min(selet.StrengthFood, 1000), -1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-13 19:43:54 +00:00
|
|
|
|
//生日蛋糕默认为加满的
|
|
|
|
|
var food = new Food()
|
|
|
|
|
{
|
|
|
|
|
Name = "生日蛋糕",
|
|
|
|
|
Likability = 5,
|
|
|
|
|
Exp = 1000,
|
|
|
|
|
Feeling = 100,
|
|
|
|
|
StrengthDrink = Core.Save.StrengthMax,
|
|
|
|
|
StrengthFood = Core.Save.StrengthMax,
|
|
|
|
|
Type = FoodType.Food,
|
|
|
|
|
isoverload = false,
|
|
|
|
|
Desc = "萝莉丝的专属生日蛋糕,由3桶牛奶+2份糖+1个鸡蛋+3份小麦合。制作而成。营养丰富,可使所有状态回满。只有在萝莉丝生日才能吃的到哦。"
|
|
|
|
|
};
|
|
|
|
|
food.LoadImageSource(this);
|
|
|
|
|
food.Price = (int)Math.Max(0, food.RealPrice * .5);
|
|
|
|
|
Foods.Add(food);
|
|
|
|
|
|
|
|
|
|
//第一次启动日期
|
2023-10-11 17:24:35 +00:00
|
|
|
|
if (GameSavesData.Data.FindLine("birthday") == null)
|
|
|
|
|
{
|
|
|
|
|
var sf = new FileInfo(ExtensionValue.BaseDirectory + @$"\Setting{PrefixSave}.lps");
|
|
|
|
|
if (sf.Exists)
|
|
|
|
|
{
|
|
|
|
|
GameSavesData[(gdat)"birthday"] = sf.CreationTime.Date;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
GameSavesData[(gdat)"birthday"] = DateTime.Now.Date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AutoSaveTimer.Elapsed += AutoSaveTimer_Elapsed;
|
|
|
|
|
|
|
|
|
|
if (GameSavesData.Statistics[(gdbe)"stat_bb_food"] < 0 || GameSavesData.Statistics[(gdbe)"stat_bb_drink"] < 0 || GameSavesData.Statistics[(gdbe)"stat_bb_drug"] < 0
|
|
|
|
|
|| GameSavesData.Statistics[(gdbe)"stat_bb_snack"] < 0 || GameSavesData.Statistics[(gdbe)"stat_bb_functional"] < 0 || GameSavesData.Statistics[(gdbe)"stat_bb_meal"] < 0
|
|
|
|
|
|| GameSavesData.Statistics[(gdbe)"stat_bb_gift"] < 0)
|
|
|
|
|
{
|
|
|
|
|
HashCheck = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Set.AutoSaveInterval > 0)
|
|
|
|
|
{
|
|
|
|
|
AutoSaveTimer.Interval = Set.AutoSaveInterval * 60000;
|
|
|
|
|
AutoSaveTimer.Start();
|
|
|
|
|
}
|
|
|
|
|
ClickTexts.Add(new ClickText("你知道吗? 鼠标右键可以打开菜单栏"));
|
|
|
|
|
ClickTexts.Add(new ClickText("你知道吗? 你可以在设置里面修改游戏的缩放比例"));
|
|
|
|
|
ClickTexts.Add(new ClickText("想要宠物不乱动? 设置里可以设置智能移动或者关闭移动"));
|
2023-11-14 13:24:57 +00:00
|
|
|
|
ClickTexts.Add(new ClickText("这游戏开发这么慢,都怪画师太咕了"));
|
|
|
|
|
//ClickTexts.Add(new ClickText("有建议/游玩反馈? 来 菜单-系统-反馈中心 反馈吧"));
|
2023-10-11 17:24:35 +00:00
|
|
|
|
ClickTexts.Add(new ClickText("长按脑袋拖动桌宠到你喜欢的任意位置"));
|
2023-11-20 17:43:34 +00:00
|
|
|
|
|
2023-11-28 18:50:51 +00:00
|
|
|
|
////临时聊天内容
|
|
|
|
|
//ClickTexts.Add(new ClickText("主人,sbema秋季促销开始了哦,还有游戏大奖赛,快去给{name}去投一票吧。"));
|
|
|
|
|
//ClickTexts.Add(new ClickText("主人主人,{name}参加了sbeam大奖赛哦,给人家投一票喵"));
|
|
|
|
|
//ClickTexts.Add(new ClickText("那个。。主人。。\n人家参加了sbeam大奖赛哦。能不能。。给{name}投一票呢~"));
|
|
|
|
|
//ClickTexts.Add(new ClickText("电脑里有一款《虚拟桌宠模拟器》的游戏正在参加2023的sbeam大奖赛,快来给桌宠投一票吧"));
|
2023-11-14 12:33:44 +00:00
|
|
|
|
//"如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的".Translate(),
|
|
|
|
|
//"你知道吗? 你可以在设置里面修改游戏的缩放比例".Translate(),
|
|
|
|
|
//"你现在乱点说话是说话系统的一部分,不过还没做,在做了在做了ing".Translate(),
|
|
|
|
|
//"你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧".Translate(),
|
|
|
|
|
//"这游戏开发这么慢,都怪画师太咕了".Translate(),
|
|
|
|
|
//"欢迎加入 虚拟主播模拟器群 430081239".Translate()
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载Steam内容".Translate()));
|
|
|
|
|
//给正在玩这个游戏的主播/游戏up主做个小功能
|
|
|
|
|
if (IsSteamUser)
|
|
|
|
|
{
|
|
|
|
|
ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
|
|
|
|
|
{
|
|
|
|
|
TranslateText = "关注 {0} 谢谢喵".Translate(SteamClient.Name)
|
|
|
|
|
});
|
|
|
|
|
//Steam成就
|
|
|
|
|
GameSavesData.Statistics.StatisticChanged += Statistics_StatisticChanged;
|
|
|
|
|
//Steam通知
|
|
|
|
|
SteamFriends.SetRichPresence("username", Core.Save.Name);
|
|
|
|
|
SteamFriends.SetRichPresence("mode", (Core.Save.Mode.ToString() + "ly").Translate());
|
|
|
|
|
SteamFriends.SetRichPresence("steam_display", "#Status_IDLE");
|
|
|
|
|
SteamFriends.SetRichPresence("idel", "闲逛".Translate());
|
|
|
|
|
if (HashCheck)
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("lv", $" (lv{GameSavesData.GameSave.Level})");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SteamFriends.SetRichPresence("lv", " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
|
|
|
|
|
{
|
|
|
|
|
TranslateText = "关注 {0} 谢谢喵".Translate(Environment.UserName)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//音乐识别timer加载
|
2024-02-04 09:08:01 +00:00
|
|
|
|
MusicTimer = new System.Timers.Timer(200)
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
|
|
|
|
AutoReset = false
|
|
|
|
|
};
|
|
|
|
|
MusicTimer.Elapsed += MusicTimer_Elapsed;
|
|
|
|
|
|
2023-11-14 12:33:44 +00:00
|
|
|
|
|
2024-03-19 09:20:07 +00:00
|
|
|
|
//await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载游戏动画".Translate()));
|
2023-10-11 17:24:35 +00:00
|
|
|
|
await Dispatcher.InvokeAsync(new Action(() =>
|
|
|
|
|
{
|
2024-02-02 13:42:23 +00:00
|
|
|
|
LoadingText.Content = "尝试加载动画和生成缓存\n该步骤可能会耗时比较长\n请耐心等待".Translate();
|
2023-09-04 08:45:32 +00:00
|
|
|
|
|
2023-10-11 17:24:35 +00:00
|
|
|
|
Core.Graph = petloader.Graph(Set.Resolution);
|
2024-02-09 13:30:11 +00:00
|
|
|
|
#if NewYear
|
|
|
|
|
//临时更新:新年进入动画,
|
|
|
|
|
if (DateTime.Now < new DateTime(2024, 2, 19))
|
|
|
|
|
{
|
2024-02-16 02:33:23 +00:00
|
|
|
|
Main = new Main(Core, startUPGraph: Core.Graph.FindGraph("newyear", AnimatType.Single, Core.Save.Mode));
|
2024-02-09 13:30:11 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
2023-10-11 17:24:35 +00:00
|
|
|
|
Main = new Main(Core);
|
2024-03-19 09:20:07 +00:00
|
|
|
|
}));
|
|
|
|
|
Main.LoadALL();
|
|
|
|
|
Main.NoFunctionMOD = Set.CalFunState;
|
|
|
|
|
await Dispatcher.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
//清空资源
|
|
|
|
|
Main.Resources = Application.Current.Resources;
|
|
|
|
|
Main.MsgBar.This.Resources = Application.Current.Resources;
|
|
|
|
|
Main.ToolBar.Resources = Application.Current.Resources;
|
|
|
|
|
Main.ToolBar.LoadClean();
|
|
|
|
|
Main.WorkList(out List<Work> ws, out List<Work> ss, out List<Work> ps);
|
2024-03-26 13:10:09 +00:00
|
|
|
|
|
2024-05-27 18:02:26 +00:00
|
|
|
|
//日程表加载
|
|
|
|
|
ScheduleTask = new ScheduleTask(this);
|
|
|
|
|
|
2024-03-19 09:20:07 +00:00
|
|
|
|
if (ws.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuWork.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuWork.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
ShowWorkMenu(Work.WorkType.Work);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (ss.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuStudy.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuStudy.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
ShowWorkMenu(Work.WorkType.Study);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (ps.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuPlay.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.MenuPlay.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
ShowWorkMenu(Work.WorkType.Play);
|
|
|
|
|
};
|
|
|
|
|
}
|
2024-03-26 13:10:09 +00:00
|
|
|
|
WorkStarMenu = new System.Windows.Controls.MenuItem()
|
|
|
|
|
{
|
|
|
|
|
Header = "收藏".Translate(),
|
|
|
|
|
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center,
|
|
|
|
|
};
|
|
|
|
|
foreach (var w in WorkStar())
|
|
|
|
|
{
|
|
|
|
|
var mi = new System.Windows.Controls.MenuItem()
|
|
|
|
|
{
|
|
|
|
|
Header = w.NameTrans
|
|
|
|
|
};
|
|
|
|
|
mi.Click += (s, e) => Main.ToolBar.StartWork(w.Double(Set["workmenu"].GetInt("double_" + w.Name, 1)));
|
|
|
|
|
WorkStarMenu.Items.Add(mi);
|
|
|
|
|
}
|
|
|
|
|
Main.ToolBar.MenuInteract.Items.Add(WorkStarMenu);
|
2024-03-19 09:20:07 +00:00
|
|
|
|
|
|
|
|
|
//加载主题:
|
|
|
|
|
LoadTheme(Set.Theme);
|
|
|
|
|
//加载字体
|
|
|
|
|
LoadFont(Set.Font);
|
|
|
|
|
|
|
|
|
|
LoadingText.Content = "正在加载游戏\n该步骤可能会耗时比较长\n请耐心等待".Translate();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//加载数据合理化:工作
|
|
|
|
|
if (!Set["gameconfig"].GetBool("noAutoCal"))
|
|
|
|
|
{
|
|
|
|
|
foreach (var work in Core.Graph.GraphConfig.Works)
|
|
|
|
|
{
|
2024-03-31 14:08:05 +00:00
|
|
|
|
if (work.LevelLimit > 200)//导入的最大合理工作不能超过200级
|
|
|
|
|
work.LevelLimit = 200;
|
2024-05-17 09:09:05 +00:00
|
|
|
|
work.FixOverLoad();//导入的工作默认1.2倍
|
2024-03-19 09:20:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-31 08:28:47 +00:00
|
|
|
|
//加载数据合理化:自动工作
|
|
|
|
|
foreach (var stp in SchedulePackage)
|
|
|
|
|
stp.FixOverLoad();
|
2024-03-19 09:20:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var m = new System.Windows.Controls.MenuItem()
|
|
|
|
|
{
|
|
|
|
|
Header = "MOD管理".Translate(),
|
|
|
|
|
HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center,
|
|
|
|
|
};
|
|
|
|
|
m.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
winSetting.MainTab.SelectedIndex = 5;
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
};
|
|
|
|
|
Main.FunctionSpendHandle += lowStrength;
|
|
|
|
|
Main.WorkTimer.E_FinishWork += WorkTimer_E_FinishWork;
|
|
|
|
|
Main.ToolBar.MenuMODConfig.Items.Add(m);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//加载游戏创意工坊插件
|
|
|
|
|
foreach (MainPlugin mp in Plugins)
|
|
|
|
|
mp.LoadPlugin();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2024-03-26 11:27:37 +00:00
|
|
|
|
Task.Run(() => MessageBox.Show(this, "由于插件引起的游戏启动错误".Translate() + "\n" + e.ToString()));
|
2024-03-19 09:20:07 +00:00
|
|
|
|
}
|
|
|
|
|
Foods.ForEach(item => item.LoadImageSource(this));
|
|
|
|
|
Main.TimeHandle += Handle_Music;
|
|
|
|
|
if (IsSteamUser)
|
|
|
|
|
Main.TimeHandle += Handle_Steam;
|
|
|
|
|
Main.TimeHandle += (x) => DiagnosisUPLoad();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tlv = Main.ToolBar.Tlv;
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Remove(tlv);
|
|
|
|
|
var sp = new StackPanel();
|
|
|
|
|
Grid.SetColumnSpan(sp, 3);
|
|
|
|
|
sp.Orientation = System.Windows.Controls.Orientation.Horizontal;
|
|
|
|
|
sp.Children.Add(tlv);
|
|
|
|
|
tlvplus = new TextBlock();
|
|
|
|
|
tlvplus.Margin = new Thickness(1);
|
|
|
|
|
tlvplus.VerticalAlignment = VerticalAlignment.Bottom;
|
|
|
|
|
tlvplus.FontSize = 18;
|
|
|
|
|
tlvplus.Foreground = Function.ResourcesBrush(Function.BrushType.PrimaryText);
|
|
|
|
|
sp.Children.Add(tlvplus);
|
|
|
|
|
Main.ToolBar.gdPanel.Children.Add(sp);
|
|
|
|
|
Main.TimeUIHandle += MWUIHandle;
|
|
|
|
|
Main.ToolBar.EventMenuPanelShow += () => MWUIHandle(Main);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (Set["CGPT"][(gstr)"type"])
|
|
|
|
|
{
|
|
|
|
|
case "DIY":
|
|
|
|
|
TalkAPIIndex = TalkAPI.FindIndex(x => x.APIName == Set["CGPT"][(gstr)"DIY"]);
|
|
|
|
|
LoadTalkDIY();
|
|
|
|
|
break;
|
|
|
|
|
//case "API":
|
|
|
|
|
// TalkBox = new TalkBoxAPI(this);
|
|
|
|
|
// Main.ToolBar.MainGrid.Children.Add(TalkBox);
|
|
|
|
|
// break;
|
|
|
|
|
case "LB":
|
|
|
|
|
//if (IsSteamUser)
|
|
|
|
|
//{
|
|
|
|
|
// TalkBox = new TalkSelect(this);
|
|
|
|
|
// Main.ToolBar.MainGrid.Children.Add(TalkBox);
|
|
|
|
|
//}
|
|
|
|
|
TalkBox = new TalkSelect(this);
|
|
|
|
|
Main.ToolBar.MainGrid.Children.Add(TalkBox);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//窗口部件
|
|
|
|
|
winSetting = new winGameSetting(this);
|
|
|
|
|
winBetterBuy = new winBetterBuy(this);
|
|
|
|
|
|
|
|
|
|
Main.DefaultClickAction = () =>
|
|
|
|
|
{
|
|
|
|
|
if (new TimeSpan(DateTime.Now.Ticks - lastclicktime).TotalSeconds > 20)
|
|
|
|
|
{
|
|
|
|
|
lastclicktime = DateTime.Now.Ticks;
|
|
|
|
|
var rt = GetClickText();
|
|
|
|
|
if (rt != null)
|
|
|
|
|
{
|
|
|
|
|
//聊天效果
|
|
|
|
|
if (rt.Exp != 0)
|
|
|
|
|
{
|
|
|
|
|
if (rt.Exp > 0)
|
|
|
|
|
{
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_exp_p"]++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_exp_d"]++;
|
|
|
|
|
}
|
|
|
|
|
if (rt.Likability != 0)
|
|
|
|
|
{
|
|
|
|
|
if (rt.Likability > 0)
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_like_p"]++;
|
|
|
|
|
else
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_like_d"]++;
|
|
|
|
|
}
|
|
|
|
|
if (rt.Money != 0)
|
|
|
|
|
{
|
|
|
|
|
if (rt.Money > 0)
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_money_p"]++;
|
|
|
|
|
else
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_say_money_d"]++;
|
|
|
|
|
}
|
|
|
|
|
Main.Core.Save.EatFood(rt);
|
|
|
|
|
Main.Core.Save.Money += rt.Money;
|
|
|
|
|
Main.SayRnd(rt.TranslateText, desc: rt.FoodToDescription());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Main.PlayVoiceVolume = Set.VoiceVolume;
|
|
|
|
|
Main.FunctionSpendHandle += StatisticsCalHandle;
|
|
|
|
|
DisplayGrid.Child = Main;
|
|
|
|
|
Task.Run(async () =>
|
|
|
|
|
{
|
|
|
|
|
while (Main.IsWorking)
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
}
|
|
|
|
|
await Dispatcher.InvokeAsync(() => LoadingText.Visibility = Visibility.Collapsed);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "退出桌宠".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; Close(); });
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "开发控制台".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winConsole(this).Show(); });
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "操作教程".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
if (LocalizeCore.CurrentCulture == "zh-Hans")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else if (LocalizeCore.CurrentCulture == "zh-Hant")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
});
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "反馈中心".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winReport(this).Show(); });
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "设置面板".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//this.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Res/TopLogo2019.PNG")));
|
|
|
|
|
|
|
|
|
|
//Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Feed, "喂食测试", () =>
|
|
|
|
|
// {
|
|
|
|
|
// Main.ToolBar.Visibility = Visibility.Collapsed;
|
|
|
|
|
// IRunImage eat = (IRunImage)Core.Graph.FindGraph(GraphType.Eat, GameSave.ModeType.Nomal);
|
|
|
|
|
// var b = Main.FindDisplayBorder(eat);
|
|
|
|
|
// eat.Run(b, new BitmapImage(new Uri("pack://application:,,,/Res/汉堡.png")), Main.DisplayToNomal);
|
|
|
|
|
// }
|
|
|
|
|
//);
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "吃饭".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(Food.FoodType.Meal);
|
|
|
|
|
});
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "喝水".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(Food.FoodType.Drink);
|
|
|
|
|
});
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "收藏".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(Food.FoodType.Star);
|
|
|
|
|
});
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "药品".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(Food.FoodType.Drug);
|
|
|
|
|
});
|
|
|
|
|
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Feed, "礼品".Translate(), () =>
|
|
|
|
|
{
|
|
|
|
|
winBetterBuy.Show(Food.FoodType.Gift);
|
|
|
|
|
});
|
|
|
|
|
Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000);
|
|
|
|
|
Main.SetLogicInterval((int)(Set.LogicInterval * 1000));
|
|
|
|
|
if (Set.MessageBarOutside)
|
|
|
|
|
Main.MsgBar.SetPlaceOUT();
|
|
|
|
|
|
|
|
|
|
Main.WorkCheck = WorkCheck;
|
|
|
|
|
|
|
|
|
|
//加载图标
|
|
|
|
|
notifyIcon = new NotifyIcon();
|
|
|
|
|
notifyIcon.Text = "虚拟桌宠模拟器".Translate() + PrefixSave;
|
|
|
|
|
ContextMenu m_menu;
|
|
|
|
|
|
|
|
|
|
if (Set.PetHelper)
|
|
|
|
|
LoadPetHelper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_menu = new ContextMenu();
|
|
|
|
|
m_menu.Opening += (x, y) => { GameSavesData.Statistics[(gint)"stat_menu_pop"]++; };
|
|
|
|
|
var hitThrough = new MenuItem("鼠标穿透".Translate(), null, (x, y) => { SetTransparentHitThrough(); })
|
|
|
|
|
{
|
|
|
|
|
Name = "NotifyIcon_HitThrough",
|
|
|
|
|
Checked = HitThrough
|
|
|
|
|
};
|
|
|
|
|
m_menu.Items.Add(hitThrough);
|
2024-04-12 15:08:00 +00:00
|
|
|
|
var topmost = new MenuItem("置于顶层".Translate(), null, (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Topmost = ((MenuItem)x).Checked;
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Name = "NotifyIcon_TopMost",
|
|
|
|
|
CheckOnClick = true,
|
|
|
|
|
Checked = Topmost
|
|
|
|
|
};
|
|
|
|
|
m_menu.Items.Add(topmost);
|
2024-03-19 09:20:07 +00:00
|
|
|
|
m_menu.Items.Add(new MenuItem("操作教程".Translate(), null, (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
if (LocalizeCore.CurrentCulture == "zh-Hans")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else if (LocalizeCore.CurrentCulture == "zh-Hant")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
}));
|
|
|
|
|
m_menu.Items.Add(new MenuItem("重置位置与状态".Translate(), null, (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
Main.CleanState();
|
|
|
|
|
Main.DisplayToNomal();
|
|
|
|
|
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
|
|
|
|
|
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
|
|
|
|
|
}));
|
|
|
|
|
m_menu.Items.Add(new MenuItem("反馈中心".Translate(), null, (x, y) => { new winReport(this).Show(); }));
|
|
|
|
|
m_menu.Items.Add(new MenuItem("开发控制台".Translate(), null, (x, y) => { new winConsole(this).Show(); }));
|
|
|
|
|
|
|
|
|
|
m_menu.Items.Add(new MenuItem("设置面板".Translate(), null, (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
}));
|
|
|
|
|
m_menu.Items.Add(new MenuItem("退出桌宠".Translate(), null, (x, y) => Close()));
|
|
|
|
|
|
|
|
|
|
LoadDIY();
|
|
|
|
|
|
|
|
|
|
notifyIcon.ContextMenuStrip = m_menu;
|
|
|
|
|
|
|
|
|
|
notifyIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/vpeticon.ico")).Stream);
|
|
|
|
|
|
|
|
|
|
notifyIcon.Visible = true;
|
|
|
|
|
notifyIcon.BalloonTipClicked += (a, b) =>
|
|
|
|
|
{
|
|
|
|
|
winSetting.Show();
|
|
|
|
|
};
|
|
|
|
|
if (Set.StartUPBoot == true && !Set["v"][(gbol)"newverstartup"])
|
|
|
|
|
{//更新到最新版开机启动方式
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
winSetting.GenStartUP();
|
|
|
|
|
Set["v"][(gbol)"newverstartup"] = true;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//成就和统计
|
|
|
|
|
GameSavesData.Statistics[(gint)"stat_open_times"]++;
|
|
|
|
|
Main.MoveTimer.Elapsed += MoveTimer_Elapsed;
|
|
|
|
|
Main.OnSay += Main_OnSay;
|
|
|
|
|
Main.Event_TouchHead += Main_Event_TouchHead;
|
|
|
|
|
Main.Event_TouchBody += Main_Event_TouchBody;
|
|
|
|
|
|
|
|
|
|
HashCheck = HashCheck;
|
|
|
|
|
|
|
|
|
|
//添加捏脸动画(若有)
|
|
|
|
|
if (Core.Graph.GraphConfig.Data.ContainsLine("pinch"))
|
|
|
|
|
{
|
|
|
|
|
var pin = Core.Graph.GraphConfig.Data["pinch"];
|
|
|
|
|
Main.Core.TouchEvent.Insert(0, new TouchArea(
|
|
|
|
|
new Point(pin[(gdbe)"px"], pin[(gdbe)"py"]), new Size(pin[(gdbe)"sw"], pin[(gdbe)"sh"])
|
|
|
|
|
, DisplayPinch, true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Set.HitThrough)
|
|
|
|
|
{
|
|
|
|
|
if (!Set["v"][(gbol)"HitThrough"])
|
|
|
|
|
{
|
|
|
|
|
Set["v"][(gbol)"HitThrough"] = true;
|
|
|
|
|
Set.HitThrough = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
SetTransparentHitThrough();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (File.Exists(ExtensionValue.BaseDirectory + @"\Tutorial.html") && Set["SingleTips"].GetDateTime("tutorial") <= new DateTime(2023, 10, 20) && App.MainWindows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
Set["SingleTips"].SetDateTime("tutorial", DateTime.Now);
|
|
|
|
|
if (LocalizeCore.CurrentCulture == "zh-Hans")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else if (LocalizeCore.CurrentCulture == "zh-Hant")
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else
|
2024-04-17 21:13:51 +00:00
|
|
|
|
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
|
2024-03-19 09:20:07 +00:00
|
|
|
|
}
|
|
|
|
|
if (!Set["SingleTips"].GetBool("helloworld"))
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(2000);
|
|
|
|
|
Set["SingleTips"].SetBool("helloworld", true);
|
|
|
|
|
NoticeBox.Show("欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠".Translate(),
|
|
|
|
|
"你好".Translate() + (IsSteamUser ? SteamClient.Name : Environment.UserName), Panuon.WPF.UI.MessageBoxIcon.Info, true, 5000);
|
|
|
|
|
//Thread.Sleep(2000);
|
|
|
|
|
//Main.SayRnd("欢迎使用虚拟桌宠模拟器\n这是个中期的测试版,若有bug请多多包涵\n欢迎加群虚拟主播模拟器430081239或在菜单栏-管理-反馈中提交bug或建议".Translate());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (Set["v"][(gint)"rank"] != DateTime.Now.Year && GameSavesData.Statistics[(gint)"stat_total_time"] > 3600)
|
|
|
|
|
{//年度报告提醒
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(120000);
|
|
|
|
|
Set["v"][(gint)"rank"] = DateTime.Now.Year;
|
|
|
|
|
var btn = Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
var button = new System.Windows.Controls.Button()
|
|
|
|
|
{
|
|
|
|
|
Content = "点击前往查看".Translate(),
|
|
|
|
|
FontSize = 20,
|
|
|
|
|
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
|
2024-08-13 19:43:54 +00:00
|
|
|
|
Background = Function.ResourcesBrush(Function.BrushType.PrimaryDark),
|
2024-03-19 09:20:07 +00:00
|
|
|
|
Foreground = Function.ResourcesBrush(Function.BrushType.PrimaryText),
|
|
|
|
|
};
|
|
|
|
|
button.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
var panelWindow = new winCharacterPanel(this);
|
|
|
|
|
panelWindow.MainTab.SelectedIndex = 2;
|
|
|
|
|
panelWindow.Show();
|
|
|
|
|
Main.MsgBar.ForceClose();
|
|
|
|
|
};
|
|
|
|
|
return button;
|
|
|
|
|
});
|
|
|
|
|
Main.Say("哼哼~主人,我的考试成绩出炉了哦,快来和我一起看我的成绩单喵".Translate(), btn, "shining");
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-08-13 19:43:54 +00:00
|
|
|
|
if (DateTime.Now < new DateTime(2024, 8, 22))
|
|
|
|
|
{
|
|
|
|
|
food.Star = true;
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(10000);
|
|
|
|
|
var btn = Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
var button = new System.Windows.Controls.Button()
|
|
|
|
|
{
|
|
|
|
|
Content = "查看生日公告/视频".Translate(),
|
|
|
|
|
FontSize = 20,
|
|
|
|
|
HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
|
|
|
|
|
Background = Function.ResourcesBrush(Function.BrushType.PrimaryDark),
|
|
|
|
|
Foreground = Function.ResourcesBrush(Function.BrushType.PrimaryText),
|
|
|
|
|
};
|
|
|
|
|
button.Click += (x, y) =>
|
|
|
|
|
{
|
|
|
|
|
if (LocalizeCore.CurrentCulture.StartsWith("zh"))
|
|
|
|
|
ExtensionFunction.StartURL("https://www.bilibili.com/opus/965218905364627474");
|
|
|
|
|
else
|
|
|
|
|
ExtensionFunction.StartURL("https://store.steampowered.com/news/app/1920960/view/4374769594847756449");
|
|
|
|
|
};
|
|
|
|
|
return button;
|
|
|
|
|
});
|
|
|
|
|
string bdt;
|
|
|
|
|
switch (DateTime.Now.Day)
|
|
|
|
|
{
|
|
|
|
|
case 14:
|
|
|
|
|
bdt = "祝我生日快乐~♪祝我生日快乐~♪,主人猜猜今天是什么日子?我的生日!主人真聪明!我就知道主人一定会记得我的生日的!谢谢主人!快来和我一起过生日吧~主人给我买的蛋糕真香啊~首先是是吹蜡烛许愿,我看看我的愿望清单: 一台5090电脑,嗨神话:吗喽 数字豪华版,还有...";
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
bdt = "昨天生日过得真开心啊!谢谢主人陪我!什么?冰箱里还有剩蛋糕?太可恶了!马上拿嘴巴去吃!";
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
bdt = "嗯。。生日蛋糕真好吃啊。。还想吃。。什么?今天也可以当生日过?!谢谢主人!";
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
bdt = "虽然生日已经过去了好几天,但是生日那天的气氛一直影响到现在呢。我才不是又想吃生日蛋糕了呢!哼!";
|
|
|
|
|
break;
|
|
|
|
|
case 18:
|
|
|
|
|
bdt = "过生日什么的太幼稚辣。人家也老大不小了,怎么可以去学小孩子过生日呢。和体重没关系!我被蛋糕所伤,今日起,戒蛋糕!";
|
|
|
|
|
break;
|
|
|
|
|
case 19:
|
|
|
|
|
bdt = "是突然发现一个哲学问题,只要我把每天都当生日,那我就可以每天都过生日了!这可是辩证唯物主义的大发现啊!";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
bdt = "转眼之间已经过去一周了呢。生日的感觉也在慢慢淡忘。主人,明年你还愿意陪我一起过生日吗?";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Main.Say(bdt.Translate(), btn, "self");
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-02-09 13:30:11 +00:00
|
|
|
|
#if NewYear
|
|
|
|
|
//仅新年功能
|
|
|
|
|
if (DateTime.Now < new DateTime(2024, 2, 18))
|
2023-10-11 17:24:35 +00:00
|
|
|
|
{
|
2024-02-18 05:30:25 +00:00
|
|
|
|
Main.TimeHandle += NewYearHandle;
|
2024-02-09 13:30:11 +00:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
2024-02-09 14:00:47 +00:00
|
|
|
|
NewYearSay();
|
2024-02-09 13:30:11 +00:00
|
|
|
|
});
|
2023-10-11 17:24:35 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2024-03-19 09:20:07 +00:00
|
|
|
|
//MOD报错
|
|
|
|
|
foreach (CoreMOD cm in CoreMODs)
|
|
|
|
|
if (!cm.SuccessLoad)
|
|
|
|
|
if (cm.Tag.Contains("该模组已损坏"))
|
2024-05-10 09:12:43 +00:00
|
|
|
|
MessageBoxX.Show("模组 {0} 插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系MOD作者修复该问题".Translate(cm.Name) + '\n' + cm.ErrorMessage, "该模组已损坏".Translate());
|
2024-03-30 09:08:50 +00:00
|
|
|
|
else if (Set.IsPassMOD(cm.Name) || !string.IsNullOrEmpty(cm.ErrorMessage))
|
2024-05-10 09:12:43 +00:00
|
|
|
|
MessageBoxX.Show("模组 {0} 的代码插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系MOD作者修复该问题".Translate(cm.Name) + '\n' + cm.ErrorMessage, "{0} 未加载代码插件".Translate(cm.Name));
|
2024-03-19 09:20:07 +00:00
|
|
|
|
else if (Set.IsMSGMOD(cm.Name))
|
|
|
|
|
MessageBoxX.Show("由于 {0} 包含代码插件\n虚拟桌宠模拟器已自动停止加载该插件\n请手动前往设置允许启用该mod 代码插件".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));
|
2024-05-10 09:12:43 +00:00
|
|
|
|
//动画错误
|
|
|
|
|
if (Main.ErrorMessage.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var errstr = string.Join("\n------\n", Main.ErrorMessage);
|
|
|
|
|
if (errstr.Contains("0000_core"))
|
|
|
|
|
{
|
|
|
|
|
var winrep = new winReport(this, errstr);
|
|
|
|
|
winrep.tDescription.Text = "动画加载错误".Translate();
|
|
|
|
|
winrep.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
MessageBoxX.Show("动画加载错误\n虚拟桌宠模拟器未能成功加载该动画\n请联系MOD作者修复该问题".Translate() + '\n' + errstr, "动画加载错误".Translate());
|
2024-03-19 09:20:07 +00:00
|
|
|
|
|
2024-05-10 09:12:43 +00:00
|
|
|
|
Main.ErrorMessage.Clear();
|
|
|
|
|
}
|
2024-03-19 09:20:07 +00:00
|
|
|
|
});
|
2023-10-11 17:24:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////游戏提示
|
|
|
|
|
//if (Set["SingleTips"][(gint)"open"] == 0 && Set.StartUPBoot == true && Set.StartUPBootSteam == true)
|
|
|
|
|
//{
|
|
|
|
|
// await Dispatcher.InvokeAsync(new Action(() =>
|
|
|
|
|
// {
|
|
|
|
|
// MessageBoxX.Show("检测到您开启了开机启动, 以下是开机启动相关提示信息: (仅显示一次)".Translate() + "\n------\n" +
|
|
|
|
|
// "游戏开机启动的实现方式是创建快捷方式,不是注册表,更健康,所以游戏卸了也不知道\n如果游戏打不开,可以去这里手动删除游戏开机启动快捷方式:\n%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\".Translate()
|
|
|
|
|
// , "关于卸载不掉的问题是因为开启了开机启动".Translate(), Panuon.WPF.UI.MessageBoxIcon.Info);
|
|
|
|
|
// Set["SingleTips"][(gint)"open"] = 1;
|
|
|
|
|
// }));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
2024-03-14 11:31:34 +00:00
|
|
|
|
|
2024-03-11 17:35:52 +00:00
|
|
|
|
TextBlock tlvplus;
|
2024-03-19 15:14:19 +00:00
|
|
|
|
|
|
|
|
|
public event Action<IMPWindows> MutiPlayerHandle;
|
2024-04-08 12:12:43 +00:00
|
|
|
|
public void MutiPlayerStart(IMPWindows mp)
|
2024-03-19 15:14:19 +00:00
|
|
|
|
{
|
|
|
|
|
MutiPlayerHandle?.Invoke(mp);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-11 17:35:52 +00:00
|
|
|
|
private void MWUIHandle(Main main)
|
|
|
|
|
{
|
|
|
|
|
if (Main.ToolBar.BdrPanel.Visibility == Visibility.Visible)
|
|
|
|
|
{
|
2024-03-12 11:36:47 +00:00
|
|
|
|
if (GameSavesData.GameSave.LevelMax != 0)
|
|
|
|
|
tlvplus.Text = $" / {1000 + GameSavesData.GameSave.LevelMax * 100} x{GameSavesData.GameSave.LevelMax}";
|
2024-03-11 17:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-15 10:25:40 +00:00
|
|
|
|
|
2024-03-20 18:59:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否显示吃东西动画
|
|
|
|
|
/// </summary>
|
|
|
|
|
bool showeatanm = true;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示吃东西(夹层)动画
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="graphName">夹层动画名</param>
|
|
|
|
|
/// <param name="imageSource">被夹在中间的图片</param>
|
|
|
|
|
public void DisplayFoodAnimation(string graphName, ImageSource imageSource)
|
|
|
|
|
{
|
|
|
|
|
if (showeatanm)
|
|
|
|
|
{//显示动画
|
|
|
|
|
showeatanm = false;
|
|
|
|
|
Main.Display(graphName, imageSource, () =>
|
|
|
|
|
{
|
|
|
|
|
showeatanm = true;
|
2024-05-08 14:31:29 +00:00
|
|
|
|
if (Core.Controller.EnableFunction)
|
2024-04-17 10:11:06 +00:00
|
|
|
|
{
|
2024-05-08 14:31:29 +00:00
|
|
|
|
var newmod = Core.Save.CalMode();
|
|
|
|
|
if (Core.Save.Mode != newmod)
|
|
|
|
|
{
|
|
|
|
|
//魔改下参数以免不播放切换动画
|
|
|
|
|
Main.DisplayType.Type = GraphType.Default;
|
|
|
|
|
//切换显示动画
|
|
|
|
|
Main.PlaySwitchAnimat(Core.Save.Mode, newmod);
|
|
|
|
|
Core.Save.Mode = newmod;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Main.DisplayToNomal();
|
2024-04-17 10:11:06 +00:00
|
|
|
|
}
|
2024-05-08 15:00:07 +00:00
|
|
|
|
else
|
|
|
|
|
Main.DisplayToNomal();
|
2024-03-20 18:59:11 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
2024-04-15 06:06:05 +00:00
|
|
|
|
else
|
|
|
|
|
{//如果不显示动画, 则看看是不是有覆盖
|
|
|
|
|
if (Main.DisplayType.Animat != AnimatType.Single && Main.DisplayType.Name != graphName)
|
|
|
|
|
{
|
|
|
|
|
showeatanm = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-20 18:59:11 +00:00
|
|
|
|
}
|
2024-03-15 17:33:56 +00:00
|
|
|
|
|
2024-03-15 10:25:40 +00:00
|
|
|
|
|
2024-02-09 14:00:47 +00:00
|
|
|
|
#if NewYear
|
|
|
|
|
int newyearsay = 0;
|
|
|
|
|
private void NewYearHandle(Main main)
|
|
|
|
|
{
|
|
|
|
|
if (DateTime.Now.Hour == 0 && newyearsay != DateTime.Now.Day)
|
|
|
|
|
{//跨时间
|
|
|
|
|
NewYearSay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新年说
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void NewYearSay()
|
|
|
|
|
{
|
|
|
|
|
newyearsay = DateTime.Now.Day;
|
|
|
|
|
string sayny;
|
|
|
|
|
switch (newyearsay)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 9:
|
|
|
|
|
sayny = "除夕除夕,燃炮祭祖,贴春联,换窗花,主人来一起吃年夜饭!一起包饺砸!{0}祝主人新年快乐!饺子饺子饺饺子!".Translate(GameSavesData.GameSave.Name);
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
sayny = "初一初一,开门炮仗,主人~恭喜发财,红包拿来~".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
sayny = "初二初二,回娘家去,左手一只鸡,右手一只鸭,一起回家吧主人~".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 12:
|
|
|
|
|
sayny = "初三初三,晚起早睡,不待客,过年辛苦了主人,好好休息吧~".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 13:
|
|
|
|
|
sayny = "初四初四,接五路,迎灶神,吃折箩,恭迎灶神爷!绝对不是肚子饿了!".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
sayny = "初五初五,赶五穷!拿扫帚把垃圾清扫出去!把脏东西都赶出去!今日宜,清屏工作。".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
sayny = "初六初六,送穷鬼,辞旧迎新,送走旧日贫穷困苦,迎接新一年!诶诶,别赶我啊。".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 16:
|
|
|
|
|
sayny = "初七初七,登高出游,戴人胜,人胜是一种头饰,又叫彩胜,华胜,从晋朝开始有剪彩为花、剪彩戴在头发上哦。主人我好看吗~".Translate();
|
|
|
|
|
break;
|
|
|
|
|
case 17:
|
|
|
|
|
sayny = "初八初八,放生祈福,拜谷神,今天是假期最后一天了,和主人过年很开心哦,最后~主人~您还有许多事需要处理,现在还不能休息哦~".Translate();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Main.SayRnd(sayny);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2023-11-20 15:44:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示捏脸情况
|
|
|
|
|
/// </summary>
|
2023-11-24 05:36:45 +00:00
|
|
|
|
public bool DisplayPinch()
|
2023-11-20 15:44:24 +00:00
|
|
|
|
{
|
2023-11-24 05:36:45 +00:00
|
|
|
|
if (Core.Graph.FindGraphs("pinch", AnimatType.A_Start, Core.Save.Mode) == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-11-20 15:44:24 +00:00
|
|
|
|
Main.CountNomal = 0;
|
2023-11-24 07:10:30 +00:00
|
|
|
|
|
2024-03-19 11:29:23 +00:00
|
|
|
|
if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < Core.Save.FeelingMax)
|
2023-11-20 15:44:24 +00:00
|
|
|
|
{
|
|
|
|
|
Core.Save.StrengthChange(-2);
|
|
|
|
|
Core.Save.FeelingChange(1);
|
|
|
|
|
Core.Save.Mode = Core.Save.CalMode();
|
|
|
|
|
Main.LabelDisplayShowChangeNumber(LocalizeCore.Translate("体力-{0:f0} 心情+{1:f0}"), 2, 1);
|
|
|
|
|
}
|
|
|
|
|
if (Main.DisplayType.Name == "pinch")
|
|
|
|
|
{
|
|
|
|
|
if (Main.DisplayType.Animat == AnimatType.A_Start)
|
2023-11-24 05:36:45 +00:00
|
|
|
|
return false;
|
2023-11-20 15:44:24 +00:00
|
|
|
|
else if (Main.DisplayType.Animat == AnimatType.B_Loop)
|
|
|
|
|
if (Dispatcher.Invoke(() => Main.PetGrid.Tag) is IGraph ig && ig.GraphInfo.Name == "pinch" && ig.GraphInfo.Animat == AnimatType.B_Loop)
|
|
|
|
|
{
|
2024-04-17 04:48:07 +00:00
|
|
|
|
ig.SetContinue();
|
2023-11-24 05:36:45 +00:00
|
|
|
|
return true;
|
2023-11-20 15:44:24 +00:00
|
|
|
|
}
|
|
|
|
|
else if (Dispatcher.Invoke(() => Main.PetGrid2.Tag) is IGraph ig2 && ig2.GraphInfo.Name == "pinch" && ig2.GraphInfo.Animat == AnimatType.B_Loop)
|
|
|
|
|
{
|
2024-04-17 04:48:07 +00:00
|
|
|
|
ig2.SetContinue();
|
2023-11-24 05:36:45 +00:00
|
|
|
|
return true;
|
2023-11-20 15:44:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Main_Event_TouchHead();
|
|
|
|
|
Main_Event_TouchBody();
|
|
|
|
|
Main.Display("pinch", AnimatType.A_Start, () =>
|
|
|
|
|
Main.Display("pinch", AnimatType.B_Loop, DisplayPinch_loop));
|
2023-11-24 05:36:45 +00:00
|
|
|
|
return true;
|
2023-11-20 15:44:24 +00:00
|
|
|
|
}
|
|
|
|
|
private void DisplayPinch_loop()
|
|
|
|
|
{
|
|
|
|
|
if (Main.isPress && Main.DisplayType.Name == "pinch" && Main.DisplayType.Animat == AnimatType.B_Loop)
|
|
|
|
|
{
|
2024-05-15 07:33:21 +00:00
|
|
|
|
if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < Core.Save.FeelingMax)
|
2023-11-24 05:36:45 +00:00
|
|
|
|
{
|
|
|
|
|
Core.Save.StrengthChange(-2);
|
|
|
|
|
Core.Save.FeelingChange(1);
|
|
|
|
|
Core.Save.Mode = Core.Save.CalMode();
|
|
|
|
|
Main.LabelDisplayShowChangeNumber(LocalizeCore.Translate("体力-{0:f0} 心情+{1:f0}"), 2, 1);
|
|
|
|
|
}
|
2023-11-20 15:44:24 +00:00
|
|
|
|
Main.Display("pinch", AnimatType.B_Loop, DisplayPinch_loop);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Main.DisplayCEndtoNomal("pinch");
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-26 13:10:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取收藏的工作
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<Work> WorkStar()
|
|
|
|
|
{
|
|
|
|
|
List<Work> works = new List<Work>();
|
|
|
|
|
foreach (var work in Core.Graph.GraphConfig.Works)
|
|
|
|
|
{
|
|
|
|
|
if (Set["work_star"].GetBool(work.Name))
|
|
|
|
|
works.Add(work);
|
|
|
|
|
}
|
|
|
|
|
return works;
|
|
|
|
|
}
|
|
|
|
|
public System.Windows.Controls.MenuItem WorkStarMenu;
|
2024-08-14 04:29:30 +00:00
|
|
|
|
|
|
|
|
|
public void LevelUP(GameSave_VPet.LevelUpEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
var gf = Core.Graph.FindGraph("levelup", GraphInfo.AnimatType.Single, GameSavesData.GameSave.Mode);
|
|
|
|
|
if (gf != null)
|
|
|
|
|
{
|
2024-08-14 05:01:11 +00:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
Main.Display(gf, Main.DisplayToNomal);
|
|
|
|
|
});
|
2024-08-14 04:29:30 +00:00
|
|
|
|
}
|
|
|
|
|
if (args.IsLevelMaxUp)
|
|
|
|
|
{//告知用户上限等级上升
|
2024-08-14 05:01:11 +00:00
|
|
|
|
Task.Run(() =>
|
2024-08-14 04:29:30 +00:00
|
|
|
|
{
|
2024-08-14 05:01:11 +00:00
|
|
|
|
Thread.Sleep(5000);
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
Main.Say("邦邦咔邦,{0}等级突破了!".Translate(Name));
|
|
|
|
|
MessageBoxX.Show("系统提示\n您的桌宠等级已经突破\nLv{0}→LV{1} x{2}\n已突破为尊贵的x{3}阶".Translate(
|
|
|
|
|
1000 + args.BeforeLevelMax * 100, 100 * GameSavesData.GameSave.LevelMax, GameSavesData.GameSave.LevelMax),
|
|
|
|
|
"桌宠等级突破".Translate());
|
|
|
|
|
});
|
2024-08-14 04:29:30 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-10 10:43:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|