迁移好用的功能到接口

This commit is contained in:
ZouJin 2024-04-18 05:13:51 +08:00
parent e197115a70
commit b54df8fae4
4 changed files with 75 additions and 72 deletions

View File

@ -1,6 +1,7 @@
using LinePutScript.Localization.WPF;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using VPet_Simulator.Core;
@ -212,6 +213,54 @@ namespace VPet_Simulator.Windows.Interface
return new string('+', v);
}
/// <summary>
/// 启动URL
/// </summary>
public static void StartURL(string url)
{
try
{
var psi = new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
};
Process.Start(psi);
}
catch
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "explorer.exe";
startInfo.UseShellExecute = false;
startInfo.Arguments = url;
Process.Start(startInfo);
}
}
/// <summary>
/// 吃食物 附带倍率
/// </summary>
/// <param name="save">存档</param>
/// <param name="food">食物</param>
/// <param name="buff">默认1倍</param>
public static void EatFood(this IGameSave save, IFood food, double buff)
{
save.Exp += food.Exp * buff;
var tmp = food.Strength / 2 * buff;
save.StrengthChange(tmp);
save.StoreStrength += tmp;
tmp = food.StrengthFood / 2 * buff;
save.StrengthChangeFood(tmp);
save.StoreStrengthFood += tmp;
tmp = food.StrengthDrink / 2 * buff;
save.StrengthChangeDrink(tmp);
save.StoreStrengthDrink += tmp;
tmp = food.Feeling / 2 * buff;
save.FeelingChange(tmp);
save.StoreFeeling += tmp * buff;
save.Health += food.Health * buff;
save.Likability += food.Likability * buff;
}
}
public static partial class ExtensionValue
{

View File

@ -380,52 +380,6 @@ namespace VPet_Simulator.Windows
}
public static class ExtensionSetting
{
public static void StartURL(string url)
{
try
{
var psi = new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
};
Process.Start(psi);
}
catch
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "explorer.exe";
startInfo.UseShellExecute = false;
startInfo.Arguments = url;
Process.Start(startInfo);
}
}
/// <summary>
/// 吃食物 附带倍率
/// </summary>
/// <param name="save">存档</param>
/// <param name="food">食物</param>
/// <param name="buff">默认1倍</param>
public static void EatFood(this IGameSave save, IFood food, double buff)
{
save.Exp += food.Exp * buff;
var tmp = food.Strength / 2 * buff;
save.StrengthChange(tmp);
save.StoreStrength += tmp;
tmp = food.StrengthFood / 2 * buff;
save.StrengthChangeFood(tmp);
save.StoreStrengthFood += tmp;
tmp = food.StrengthDrink / 2 * buff;
save.StrengthChangeDrink(tmp);
save.StoreStrengthDrink += tmp;
tmp = food.Feeling / 2 * buff;
save.FeelingChange(tmp);
save.StoreFeeling += tmp * buff;
save.Health += food.Health * buff;
save.Likability += food.Likability * buff;
}
internal static bool IsOnMod(this Setting t, string ModName)
{
if (CoreMOD.OnModDefList.Contains(ModName))

View File

@ -388,7 +388,7 @@ namespace VPet_Simulator.Windows
{
try
{
ExtensionSetting.StartURL(content);
ExtensionFunction.StartURL(content);
}
catch (Exception e)
{
@ -1838,11 +1838,11 @@ namespace VPet_Simulator.Windows
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "操作教程".Translate(), () =>
{
if (LocalizeCore.CurrentCulture == "zh-Hans")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
else if (LocalizeCore.CurrentCulture == "zh-Hant")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
else
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
});
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "反馈中心".Translate(), () => { Main.ToolBar.Visibility = Visibility.Collapsed; new winReport(this).Show(); });
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "设置面板".Translate(), () =>
@ -1919,11 +1919,11 @@ namespace VPet_Simulator.Windows
m_menu.Items.Add(new MenuItem("操作教程".Translate(), null, (x, y) =>
{
if (LocalizeCore.CurrentCulture == "zh-Hans")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
else if (LocalizeCore.CurrentCulture == "zh-Hant")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
else
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
}));
m_menu.Items.Add(new MenuItem("重置位置与状态".Translate(), null, (x, y) =>
{
@ -2000,11 +2000,11 @@ namespace VPet_Simulator.Windows
{
Set["SingleTips"].SetDateTime("tutorial", DateTime.Now);
if (LocalizeCore.CurrentCulture == "zh-Hans")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial.html");
else if (LocalizeCore.CurrentCulture == "zh-Hant")
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_zht.html");
else
ExtensionSetting.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
ExtensionFunction.StartURL(ExtensionValue.BaseDirectory + @"\Tutorial_en.html");
}
if (!Set["SingleTips"].GetBool("helloworld"))
{

View File

@ -656,7 +656,7 @@ namespace VPet_Simulator.Windows
//await result.SubmitAsync(new ProgressClass(ProgressBarUpload));
if (MessageBoxX.Show("{0} 成功上传至WorkShop服务器\n是否跳转至创意工坊页面进行编辑详细介绍和图标?".Translate(mods.Name), "MOD上传成功".Translate(), MessageBoxButton.YesNo, MessageBoxIcon.Success) == MessageBoxResult.Yes)
{
ExtensionSetting.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + r.FileId);
ExtensionFunction.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + r.FileId);
}
}
else
@ -697,7 +697,7 @@ namespace VPet_Simulator.Windows
mods.WriteFile();
if (MessageBoxX.Show("{0} 成功上传至WorkShop服务器\n是否跳转至创意工坊页面进行编辑新内容?".Translate(mods.Name)
, "MOD更新成功".Translate(), MessageBoxButton.YesNo, MessageBoxIcon.Success) == MessageBoxResult.Yes)
ExtensionSetting.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + r.FileId);
ExtensionFunction.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + r.FileId);
}
else
MessageBoxX.Show("{0} 上传至WorkShop服务器失败\n请检查网络后重试\n请注意:上传和下载工坊物品可能需要良好的网络条件\n失败原因:{1}"
@ -712,7 +712,7 @@ namespace VPet_Simulator.Windows
{
if (!AllowChange)
return;
ExtensionSetting.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + mod.ItemID);
ExtensionFunction.StartURL("https://steamcommunity.com/sharedfiles/filedetails/?id=" + mod.ItemID);
}
private void ButtonAllow_Click(object sender, RoutedEventArgs e)
@ -780,7 +780,7 @@ namespace VPet_Simulator.Windows
private void hyper_moreInfo(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://www.exlb.net/Diagnosis");
ExtensionFunction.StartURL("https://www.exlb.net/Diagnosis");
}
public new void Show()
@ -846,48 +846,48 @@ namespace VPet_Simulator.Windows
#region Link
private void Git_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://github.com/LorisYounger/VPet/graphs/contributors");
ExtensionFunction.StartURL("https://github.com/LorisYounger/VPet/graphs/contributors");
}
private void Steam_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://store.steampowered.com/app/1920960/_/");
ExtensionFunction.StartURL("https://store.steampowered.com/app/1920960/_/");
}
private void Github_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://github.com/LorisYounger/VPet");
ExtensionFunction.StartURL("https://github.com/LorisYounger/VPet");
}
private void LB_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://space.bilibili.com/609610777");
ExtensionFunction.StartURL("https://space.bilibili.com/609610777");
}
private void VPET_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://www.exlb.net/");
ExtensionFunction.StartURL("https://www.exlb.net/");
}
private void VUP_Click(object sender, RoutedEventArgs e)
{
ExtensionSetting.StartURL("https://store.steampowered.com/app/1352140/_/");
ExtensionFunction.StartURL("https://store.steampowered.com/app/1352140/_/");
}
private void Group_Click(object sender, RoutedEventArgs e)
{
if (LocalizeCore.CurrentCulture.StartsWith("zh"))
ExtensionSetting.StartURL("https://space.bilibili.com/690425399");
ExtensionFunction.StartURL("https://space.bilibili.com/690425399");
else
ExtensionSetting.StartURL("https://github.com/LorisYounger/VPet");
ExtensionFunction.StartURL("https://github.com/LorisYounger/VPet");
}
private void sendkey_click(object sender, RoutedEventArgs e)
{
if (LocalizeCore.CurrentCulture.StartsWith("zh"))
ExtensionSetting.StartURL("https://www.exlb.net/SendKeys");
ExtensionFunction.StartURL("https://www.exlb.net/SendKeys");
else if (LocalizeCore.CurrentCulture == "null")
ExtensionSetting.StartURL("https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys?view=windowsdesktop-7.0#remarks");
ExtensionFunction.StartURL("https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys?view=windowsdesktop-7.0#remarks");
else
ExtensionSetting.StartURL($"https://learn.microsoft.com/{LocalizeCore.CurrentCulture}/dotnet/api/system.windows.forms.sendkeys?view=windowsdesktop-7.0#remarks");
ExtensionFunction.StartURL($"https://learn.microsoft.com/{LocalizeCore.CurrentCulture}/dotnet/api/system.windows.forms.sendkeys?view=windowsdesktop-7.0#remarks");
}
#endregion
@ -1101,7 +1101,7 @@ namespace VPet_Simulator.Windows
if (mw.TalkBoxCurr != null)
mw.TalkBoxCurr.Setting();
else
ExtensionSetting.StartURL("https://steamcommunity.com/app/1920960/workshop/");
ExtensionFunction.StartURL("https://steamcommunity.com/app/1920960/workshop/");
break;
case "LB":
//Task.Run(() =>