代码优化

This commit is contained in:
ZouJin 2023-05-26 04:44:31 +10:00
parent 49d1049fc2
commit 9d2594d057
11 changed files with 71 additions and 66 deletions

View File

@ -369,13 +369,13 @@ namespace VPet_Simulator.Core
/// 随机数字典(用于确保随机动画不会错位) /// 随机数字典(用于确保随机动画不会错位)
/// </summary> /// </summary>
public Dictionary<int, int> RndGraph = new Dictionary<int, int>(); public Dictionary<int, int> RndGraph = new Dictionary<int, int>();
/// <summary> /// <summary>
/// 查找动画 /// 查找动画
/// </summary> /// </summary>
/// <param name="type">动画类型</param> /// <param name="type">动画类型</param>
/// <param name="mode">状态类型,找不到就找相同动画类型</param> /// <param name="mode">状态类型,找不到就找相同动画类型</param>
///// <param name="storernd">是否储存随机数字典</param> ///// <param name="storernd">是否储存随机数字典</param>
/// <returns></returns>
public IGraph FindGraph(GraphType type, GameSave.ModeType mode) public IGraph FindGraph(GraphType type, GameSave.ModeType mode)
{ {
if (Graphs.ContainsKey(type)) if (Graphs.ContainsKey(type))

View File

@ -79,8 +79,8 @@
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath> <HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
</Reference> </Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF.UI, Version=1.1.11.8, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll</HintPath> <HintPath>..\packages\Panuon.WPF.UI.1.1.11.8\lib\net462\Panuon.WPF.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />

View File

@ -2,5 +2,5 @@
<packages> <packages>
<package id="LinePutScript" version="1.8.0" targetFramework="net462" /> <package id="LinePutScript" version="1.8.0" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" /> <package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net462" /> <package id="Panuon.WPF.UI" version="1.1.11.8" targetFramework="net462" />
</packages> </packages>

View File

@ -9,6 +9,9 @@ using VPet_Simulator.Core;
namespace VPet_Simulator.Windows.Interface namespace VPet_Simulator.Windows.Interface
{ {
/// <summary>
/// 游戏主窗体
/// </summary>
public interface IMainWindow public interface IMainWindow
{ {
/// <summary> /// <summary>
@ -18,19 +21,19 @@ namespace VPet_Simulator.Windows.Interface
/// <summary> /// <summary>
/// 游戏设置 /// 游戏设置
/// </summary> /// </summary>
Setting Set { get; set; } Setting Set { get; }
/// <summary> /// <summary>
/// 宠物加载器列表 /// 宠物加载器列表
/// </summary> /// </summary>
List<PetLoader> Pets { get; set; } List<PetLoader> Pets { get; }
/// <summary> /// <summary>
/// 桌宠数据核心 /// 桌宠数据核心
/// </summary> /// </summary>
GameCore Core { get; set; } GameCore Core { get; }
/// <summary> /// <summary>
/// 桌宠主要部件 /// 桌宠主要部件
/// </summary> /// </summary>
Main Main { get; set; } Main Main { get; }
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>
@ -38,7 +41,7 @@ namespace VPet_Simulator.Windows.Interface
/// <summary> /// <summary>
/// 版本号 /// 版本号
/// </summary> /// </summary>
string Verison { get; } string Verison { get; }
/// <summary> /// <summary>
/// 上次点击时间 (Tick) /// 上次点击时间 (Tick)
/// </summary> /// </summary>
@ -48,8 +51,6 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
List<MainPlugin> Plugins { get; } List<MainPlugin> Plugins { get; }
Dispatcher Dispatcher { get; }
/// <summary> /// <summary>
/// 设置游戏缩放倍率 /// 设置游戏缩放倍率
/// </summary> /// </summary>

View File

@ -6,11 +6,18 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using VPet_Simulator.Core;
namespace VPet_Simulator.Windows.Interface namespace VPet_Simulator.Windows.Interface
{ {
/// <summary>
/// 游戏设置
/// </summary>
public class Setting : LpsDocument public class Setting : LpsDocument
{ {
/// <summary>
/// 游戏设置
/// </summary>
public Setting(string lps) : base(lps) public Setting(string lps) : base(lps)
{ {
var line = FindLine("zoomlevel"); var line = FindLine("zoomlevel");
@ -31,11 +38,6 @@ namespace VPet_Simulator.Windows.Interface
enablefunction = !this["gameconfig"].GetBool("enablefunction"); enablefunction = !this["gameconfig"].GetBool("enablefunction");
} }
public void Save()
{
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", ToString());
}
//public Size WindowsSize //public Size WindowsSize
//{ //{
// get // get
@ -133,8 +135,6 @@ namespace VPet_Simulator.Windows.Interface
public bool DiagnosisDayEnable = true; public bool DiagnosisDayEnable = true;
public string Font public string Font
{ {
get => GetString("font", "OPPOSans R"); get => GetString("font", "OPPOSans R");
@ -154,46 +154,6 @@ namespace VPet_Simulator.Windows.Interface
FindorAddLine("theme").Info = value; FindorAddLine("theme").Info = value;
} }
} }
public bool IsBanMod(string ModName)
{
var line = FindLine("banmod");
if (line == null)
return false;
return line.Find(ModName.ToLower()) != null;
}
public bool IsPassMOD(string ModName)
{
var line = FindLine("passmod");
if (line == null)
return false;
return line.Find(ModName.ToLower()) != null;
}
public bool IsMSGMOD(string ModName)
{
var line = FindorAddLine("msgmod");
if (line.GetBool(ModName))
return false;
line.SetBool(ModName, true);
return true;
}
public void BanMod(string ModName)
{
if (string.IsNullOrWhiteSpace(ModName))
return;
FindorAddLine("banmod").AddorReplaceSub(new Sub(ModName.ToLower()));
}
public void BanModRemove(string ModName)
{
FindorAddLine("banmod").Remove(ModName.ToLower());
}
public void PassMod(string ModName)
{
FindorAddLine("passmod").AddorReplaceSub(new Sub(ModName.ToLower()));
}
public void PassModRemove(string ModName)
{
FindorAddLine("passmod").Remove(ModName.ToLower());
}
private int presslength; private int presslength;
private int intercycle; private int intercycle;

View File

@ -94,8 +94,8 @@
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath> <HintPath>..\packages\Panuon.WPF.1.0.1\lib\net462\Panuon.WPF.dll</HintPath>
</Reference> </Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF.UI, Version=1.1.11.8, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net462\Panuon.WPF.UI.dll</HintPath> <HintPath>..\packages\Panuon.WPF.UI.1.1.11.8\lib\net462\Panuon.WPF.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />

View File

@ -2,5 +2,5 @@
<packages> <packages>
<package id="LinePutScript" version="1.8.0" targetFramework="net462" /> <package id="LinePutScript" version="1.8.0" targetFramework="net462" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net462" /> <package id="Panuon.WPF" version="1.0.1" targetFramework="net462" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net462" /> <package id="Panuon.WPF.UI" version="1.1.11.8" targetFramework="net462" />
</packages> </packages>

View File

@ -121,7 +121,6 @@ namespace VPet_Simulator.Windows
} }
} }
SuccessLoad = true; SuccessLoad = true;
break; break;
} }
@ -141,6 +140,49 @@ namespace VPet_Simulator.Windows
modlps.FindorAddLine("authorid").InfoToInt64 = AuthorID; modlps.FindorAddLine("authorid").InfoToInt64 = AuthorID;
modlps.FindorAddLine("itemid").info = ItemID.ToString(); modlps.FindorAddLine("itemid").info = ItemID.ToString();
File.WriteAllText(Path.FullName + @"\info.lps", modlps.ToString()); File.WriteAllText(Path.FullName + @"\info.lps", modlps.ToString());
}
}
public static class ExtensionSetting
{
public static bool IsBanMod(this Setting t, string ModName)
{
var line = t.FindLine("banmod");
if (line == null)
return false;
return line.Find(ModName.ToLower()) != null;
}
public static bool IsPassMOD(this Setting t, string ModName)
{
var line = t.FindLine("passmod");
if (line == null)
return false;
return line.Find(ModName.ToLower()) != null;
}
public static bool IsMSGMOD(this Setting t, string ModName)
{
var line = t.FindorAddLine("msgmod");
if (line.GetBool(ModName))
return false;
line.SetBool(ModName, true);
return true;
}
public static void BanMod(this Setting t, string ModName)
{
if (string.IsNullOrWhiteSpace(ModName))
return;
t.FindorAddLine("banmod").AddorReplaceSub(new Sub(ModName.ToLower()));
}
public static void BanModRemove(this Setting t, string ModName)
{
t.FindorAddLine("banmod").Remove(ModName.ToLower());
}
public static void PassMod(this Setting t, string ModName)
{
t.FindorAddLine("passmod").AddorReplaceSub(new Sub(ModName.ToLower()));
}
public static void PassModRemove(this Setting t, string ModName)
{
t.FindorAddLine("passmod").Remove(ModName.ToLower());
} }
} }
} }

View File

@ -90,8 +90,8 @@
<Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll</HintPath> <HintPath>..\packages\Panuon.WPF.1.0.1\lib\net48\Panuon.WPF.dll</HintPath>
</Reference> </Reference>
<Reference Include="Panuon.WPF.UI, Version=1.1.11.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Panuon.WPF.UI, Version=1.1.11.8, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Panuon.WPF.UI.1.1.11-beta\lib\net48\Panuon.WPF.UI.dll</HintPath> <HintPath>..\packages\Panuon.WPF.UI.1.1.11.8\lib\net48\Panuon.WPF.UI.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />

View File

@ -35,12 +35,14 @@ namespace VPet_Simulator.Windows
{ {
Main m; Main m;
Setting set; Setting set;
MainWindow mw;
public TalkBox(MainWindow mw) public TalkBox(MainWindow mw)
{ {
InitializeComponent(); InitializeComponent();
this.m = mw.Main; this.m = mw.Main;
set = mw.Set; set = mw.Set;
this.mw = mw;
this.IsEnabled = false; this.IsEnabled = false;
var sid = Steamworks.SteamClient.SteamId.Value; var sid = Steamworks.SteamClient.SteamId.Value;
Task.Run(() => PetLifeDisplay(sid)); Task.Run(() => PetLifeDisplay(sid));
@ -214,7 +216,7 @@ namespace VPet_Simulator.Windows
private void StartUP_Click(object sender, RoutedEventArgs e) private void StartUP_Click(object sender, RoutedEventArgs e)
{ {
set["aiopen"][(gbol)"startup"] = true; set["aiopen"][(gbol)"startup"] = true;
set.Save(); mw.Save();
btn_startup.Content = "初始化桌宠聊天程序中..."; btn_startup.Content = "初始化桌宠聊天程序中...";
var sid = Steamworks.SteamClient.SteamId.Value; var sid = Steamworks.SteamClient.SteamId.Value;
var cont = $"请使用口语化的、可爱的、女性化的、调皮的语言风格和我交流\n你是一只桌宠, 你的名字叫{m.Core.Save.Name}, 你喜欢玩 <虚拟主播模拟器>"; var cont = $"请使用口语化的、可爱的、女性化的、调皮的语言风格和我交流\n你是一只桌宠, 你的名字叫{m.Core.Save.Name}, 你喜欢玩 <虚拟主播模拟器>";

View File

@ -6,5 +6,5 @@
<package id="LinePutScript" version="1.8.0" targetFramework="net48" /> <package id="LinePutScript" version="1.8.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" /> <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="Panuon.WPF" version="1.0.1" targetFramework="net48" /> <package id="Panuon.WPF" version="1.0.1" targetFramework="net48" />
<package id="Panuon.WPF.UI" version="1.1.11-beta" targetFramework="net48" /> <package id="Panuon.WPF.UI" version="1.1.11.8" targetFramework="net48" />
</packages> </packages>