更新MOD结构

This commit is contained in:
ZouJin 2023-01-09 00:57:10 +08:00
parent d3673f70df
commit 03193bdc8e
16 changed files with 636 additions and 161 deletions

View File

@ -21,16 +21,30 @@ namespace VPet_Simulator.Core
/// </summary>
public partial class Main : UserControl
{
/// <summary>
/// 游戏核心
/// </summary>
public GameCore Core;
/// <summary>
/// 菜单栏
/// </summary>
public ToolBar Bar;
/// <summary>
/// 刷新时间时会调用该方法
/// </summary>
public event Action<Main> TimeHandle;
/// <summary>
/// 刷新时间时会调用该方法,在所有任务处理完之后
/// </summary>
public event Action<Main> TimeUIHandle;
public Main(GameCore core)
{
InitializeComponent();
Core = core;
Bar = new ToolBar(this);
UIGrid.Children.Add(Bar);
Bar.Visibility = Visibility.Collapsed;
UIGrid.Children.Add(Bar);
//TODO:锚定设置
Core.TouchEvent.Add(new TouchArea(new Point(138, 12), new Size(224, 176), DisplayTouchHead));
Core.TouchEvent.Add(new TouchArea(new Point(0, 0), new Size(500, 180), DisplayRaised, true));
@ -58,7 +72,7 @@ namespace VPet_Simulator.Core
}
Task.Run(() =>
{
Thread.Sleep(Core.Setting.PressLength);
Thread.Sleep(Core.Controller.PressLength);
Point mp = default;
Dispatcher.BeginInvoke(new Action(() => mp = Mouse.GetPosition(MainGrid))).Wait();
if (isPress)

View File

@ -23,8 +23,14 @@ namespace VPet_Simulator.Core
private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
//所有Handle
TimeHandle?.Invoke(this);
//TODO:饮食等乱七八糟的消耗
//UIHandle
Dispatcher.Invoke(() => TimeUIHandle.Invoke(this));
if (IsNomal)
switch (1)//Function.Rnd.Next(10))
{
@ -34,7 +40,7 @@ namespace VPet_Simulator.Core
break;
case 1:
DisplayClimb_Left_UP();
break;
break;
case 2:
DisplayClimb_Left_DOWN();
break;
@ -45,7 +51,7 @@ namespace VPet_Simulator.Core
DisplayClimb_Right_DOWN();
break;
case 10:
DisplayClimb_Top_Right();
DisplayClimb_Top_Right();
break;
default:
break;

View File

@ -8,8 +8,8 @@
<ResourceDictionary Source="Theme.xaml" />
</UserControl.Resources>
<Grid>
<Border x:Name="BdrPanel" Visibility="Collapsed" VerticalAlignment="Bottom" Margin="0,0,0,55" TextBlock.FontSize="24" TextElement.FontSize="24"
BorderBrush="{DynamicResource DARKPrimaryDarker}" BorderThickness="1"
<Border x:Name="BdrPanel" VerticalAlignment="Bottom" Margin="0,0,0,55" TextBlock.FontSize="24"
TextElement.FontSize="24" BorderBrush="{DynamicResource DARKPrimaryDarker}" BorderThickness="1"
Background="{DynamicResource DARKPrimaryText}" CornerRadius="5" MouseLeave="MenuPanel_MouseLeave">
<Grid Margin="15">
<Grid.ColumnDefinitions>
@ -29,62 +29,79 @@
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<TextBlock Text="Lv 14" VerticalAlignment="Center" Foreground="{DynamicResource DARKPrimary}"/>
<Button Grid.Column="4" VerticalAlignment="Center" Background="Transparent" Foreground="{DynamicResource DARKPrimary}" Content="详细" Cursor="Hand" Click="MenuPanel_Click">
<TextBlock x:Name="Tlv" Text="Lv 14" VerticalAlignment="Center"
Foreground="{DynamicResource DARKPrimary}" Grid.ColumnSpan="3" />
<Button Grid.Column="4" VerticalAlignment="Center" Background="Transparent"
Foreground="{DynamicResource DARKPrimary}" Content="详细" Cursor="Hand" Click="MenuPanel_Click">
<Button.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
TextDecorations="Underline" />
<TextBlock Text="{Binding}" TextDecorations="Underline" />
</DataTemplate>
</Button.ContentTemplate>
</Button>
<TextBlock x:Name="txtHearth" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#FF4C4C" TextWrapping="Wrap" Text="宠物已经生病。通过服用药物可以恢复。" />
<TextBlock x:Name="till" Grid.Row="1" Grid.ColumnSpan="5" Foreground="#FF4C4C" TextWrapping="Wrap"
Text="宠物已经生病。通过服用药物可以恢复。" />
<TextBlock Grid.Row="2" Text="金钱" VerticalAlignment="Center" />
<TextBlock Grid.Row="2" Grid.Column="2" Foreground="{DynamicResource DARKPrimary}" Text="¥100,000" />
<TextBlock x:Name="tMoney" Grid.Row="2" Grid.Column="2" Foreground="{DynamicResource DARKPrimary}"
Text="¥100,000" />
<TextBlock Grid.Row="3" Text="经验" VerticalAlignment="Center" />
<ProgressBar Grid.Row="3" Grid.Column="2" Value="40" FontSize="20" Height="20" VerticalAlignment="Center"
pu:ProgressBarHelper.CornerRadius="10" Foreground="{DynamicResource ProgressBarForeground}" pu:ProgressBarHelper.IsPercentVisible="True" pu:ProgressBarHelper.GeneratingPercentText="PgbExperience_GeneratingPercentText" />
<TextBlock Grid.Row="3" Grid.Column="4" HorizontalAlignment="Right" Text="x2倍" Foreground="{DynamicResource DARKPrimary}" />
<ProgressBar x:Name="pExp" Grid.Row="3" Grid.Column="2" Value="40" FontSize="20" Height="20"
VerticalAlignment="Center" pu:ProgressBarHelper.CornerRadius="10"
Foreground="{DynamicResource ProgressBarForeground}"
pu:ProgressBarHelper.IsPercentVisible="True"
pu:ProgressBarHelper.GeneratingPercentText="PgbExperience_GeneratingPercentText" />
<TextBlock x:Name="tExp" Grid.Row="3" Grid.Column="4" HorizontalAlignment="Right" Text="x1倍"
Foreground="{DynamicResource DARKPrimary}" />
<TextBlock Grid.Row="4" Text="体力" VerticalAlignment="Center" />
<ProgressBar Grid.Row="4" Grid.Column="2" Value="40" FontSize="20" Height="20" VerticalAlignment="Center"
pu:ProgressBarHelper.CornerRadius="10" Foreground="{DynamicResource ProgressBarForeground}" pu:ProgressBarHelper.IsPercentVisible="True" pu:ProgressBarHelper.GeneratingPercentText="PgbStrength_GeneratingPercentText" />
<TextBlock Grid.Row="4" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m" Foreground="{DynamicResource DARKPrimary}" />
<ProgressBar x:Name="pStrength" Grid.Row="4" Grid.Column="2" Value="40" FontSize="20" Height="20"
VerticalAlignment="Center" Maximum="100" pu:ProgressBarHelper.CornerRadius="10"
Foreground="{DynamicResource ProgressBarForeground}"
pu:ProgressBarHelper.IsPercentVisible="True"
pu:ProgressBarHelper.GeneratingPercentText="PgbStrength_GeneratingPercentText" />
<TextBlock x:Name="tStrength" Grid.Row="4" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
Foreground="{DynamicResource DARKPrimary}" />
<TextBlock Grid.Row="5" Text="心情" VerticalAlignment="Center" />
<ProgressBar Grid.Row="5" Grid.Column="2" Value="60" FontSize="20" Height="20" VerticalAlignment="Center"
pu:ProgressBarHelper.CornerRadius="10" Foreground="{DynamicResource ProgressBarForeground}" pu:ProgressBarHelper.IsPercentVisible="True" pu:ProgressBarHelper.GeneratingPercentText="PgbSpirit_GeneratingPercentText" />
<TextBlock Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m" Foreground="{DynamicResource DARKPrimary}" />
<ProgressBar x:Name="pFeeling" Grid.Row="5" Grid.Column="2" Value="60" FontSize="20" Height="20"
VerticalAlignment="Center" Maximum="100" pu:ProgressBarHelper.CornerRadius="10"
Foreground="{DynamicResource ProgressBarForeground}"
pu:ProgressBarHelper.IsPercentVisible="True"
pu:ProgressBarHelper.GeneratingPercentText="PgbSpirit_GeneratingPercentText" />
<TextBlock x:Name="tFeeling" Grid.Row="5" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
Foreground="{DynamicResource DARKPrimary}" />
<TextBlock Grid.Row="6" Text="饱腹度" VerticalAlignment="Center" />
<ProgressBar Grid.Row="6" Grid.Column="2" Value="80" FontSize="20" Height="20" VerticalAlignment="Center"
pu:ProgressBarHelper.CornerRadius="10" Foreground="{DynamicResource ProgressBarForeground}" pu:ProgressBarHelper.IsPercentVisible="True" pu:ProgressBarHelper.GeneratingPercentText="PgbHunger_GeneratingPercentText" />
<TextBlock Grid.Row="6" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m" Foreground="{DynamicResource DARKPrimary}" />
<ProgressBar x:Name="pStrengthFood" Grid.Row="6" Grid.Column="2" Value="80" FontSize="20" Height="20"
VerticalAlignment="Center" Maximum="100" pu:ProgressBarHelper.CornerRadius="10"
Foreground="{DynamicResource ProgressBarForeground}"
pu:ProgressBarHelper.IsPercentVisible="True"
pu:ProgressBarHelper.GeneratingPercentText="PgbHunger_GeneratingPercentText" />
<TextBlock x:Name="tStrengthFood" Grid.Row="6" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
Foreground="{DynamicResource DARKPrimary}" />
<TextBlock Grid.Row="7" Text="口渴度" VerticalAlignment="Center" />
<ProgressBar Grid.Row="7" Grid.Column="2" Value="20" FontSize="20" Height="20" VerticalAlignment="Center"
pu:ProgressBarHelper.CornerRadius="10" Foreground="{DynamicResource ProgressBarForeground}" pu:ProgressBarHelper.IsPercentVisible="True" pu:ProgressBarHelper.GeneratingPercentText="PgbThirsty_GeneratingPercentText" />
<TextBlock Grid.Row="7" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m" Foreground="{DynamicResource DARKPrimary}" />
<ProgressBar x:Name="pStrengthDrink" Grid.Row="7" Grid.Column="2" Value="20" FontSize="20" Height="20"
VerticalAlignment="Center" Maximum="100" pu:ProgressBarHelper.CornerRadius="10"
Foreground="{DynamicResource ProgressBarForeground}"
pu:ProgressBarHelper.IsPercentVisible="True"
pu:ProgressBarHelper.GeneratingPercentText="PgbThirsty_GeneratingPercentText" />
<TextBlock x:Name="tStrengthDrink" Grid.Row="7" Grid.Column="4" HorizontalAlignment="Right" Text="+1/m"
Foreground="{DynamicResource DARKPrimary}" />
</Grid>
</Border>
<Menu Width="500"
VerticalAlignment="Bottom"
Style="{DynamicResource ToolBarMenuStyle}">
<Menu Width="500" VerticalAlignment="Bottom" Style="{DynamicResource ToolBarMenuStyle}">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="5"/>
<UniformGrid Columns="5" />
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem x:Name="MenuFeed"
Header="投喂">
<MenuItem x:Name="MenuFeed" Header="投喂">
<MenuItem Header="食物" />
<MenuItem Header="饮料" />
<MenuItem Header="药品" />
</MenuItem>
<MenuItem x:Name="MenuPanel" Header="面板"
MouseEnter="MenuPanel_MouseEnter"
MouseLeave="MenuPanel_MouseLeave"/>
<MenuItem x:Name="MenuPanel" Header="面板" MouseEnter="MenuPanel_MouseEnter" MouseLeave="MenuPanel_MouseLeave" />
<MenuItem Header="打工" />
<MenuItem Header="睡觉" />
<MenuItem Header="设置"
Click="MenuSetting_Click"/>
<MenuItem Header="设置" Click="MenuSetting_Click" />
</Menu>
</Grid>
</UserControl>

View File

@ -45,6 +45,23 @@ namespace VPet_Simulator.Core
Interval = TimeSpan.FromSeconds(0.1),
};
closePanelTimer.Tick += ClosePanelTimer_Tick;
m.TimeUIHandle += M_TimeUIHandle;
}
private void M_TimeUIHandle(Main m)
{
if (BdrPanel.Visibility == Visibility.Visible)
{
Tlv.Text = "Lv " + m.Core.Save.Level.ToString();
tMoney.Text = "$ " + m.Core.Save.Money.ToString("N2");
till.Visibility = m.Core.Save.Mode == Save.ModeType.Ill ? Visibility.Visible : Visibility.Collapsed;
pExp.Maximum = m.Core.Save.LevelUpNeed();
pExp.Value = m.Core.Save.Exp;
pStrength.Value = m.Core.Save.Strength;
pFeeling.Value = m.Core.Save.Feeling;
pStrengthFood.Value = m.Core.Save.StrengthFood;
pStrengthDrink.Value = m.Core.Save.StrengthDrink;
}
}
private void ClosePanelTimer_Tick(object sender, EventArgs e)
@ -120,7 +137,7 @@ namespace VPet_Simulator.Core
private void PgbExperience_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
{
e.Text = $"{e.Value * 10} / {100 * 10}";
e.Text = $"{e.Value} / {pExp.Maximum}";
}
private void PgbStrength_GeneratingPercentText(object sender, GeneratingPercentTextRoutedEventArgs e)
@ -147,10 +164,10 @@ namespace VPet_Simulator.Core
var progressBar = (ProgressBar)sender;
progressBar.Foreground = GetForeground(e.Value);
e.Text = $"{e.Value} / 100";
if (e.Value <= 20)
{
txtHearth.Visibility = Visibility.Visible;
}
//if (e.Value <= 20)
//{
// tHearth.Visibility = Visibility.Visible;
//}
}
private Brush GetForeground(double value)
@ -172,6 +189,7 @@ namespace VPet_Simulator.Core
private void MenuPanel_MouseEnter(object sender, MouseEventArgs e)
{
BdrPanel.Visibility = Visibility.Visible;
M_TimeUIHandle(m);
}
private void MenuPanel_MouseLeave(object sender, MouseEventArgs e)

View File

@ -19,11 +19,7 @@ namespace VPet_Simulator.Core
/// <summary>
/// 触摸范围和事件列表
/// </summary>
public List<TouchArea> TouchEvent = new List<TouchArea>();
/// <summary>
/// 游戏设置
/// </summary>
public Setting Setting;
public List<TouchArea> TouchEvent = new List<TouchArea>();
/// <summary>
/// 图形核心
/// </summary>

View File

@ -48,6 +48,10 @@ namespace VPet_Simulator.Core
/// </summary>
double ZoomRatio { get; }
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
int PressLength { get; }
/// <summary>
/// 显示设置窗体
/// </summary>
void ShowSetting();
@ -55,5 +59,6 @@ namespace VPet_Simulator.Core
/// 显示面板窗体
/// </summary>
void ShowPanel();
}
}

View File

@ -30,7 +30,7 @@ namespace VPet_Simulator.Core
/// 升级所需经验值
/// </summary>
/// <returns></returns>
public int LevelUpNeed() => (int)(Math.Pow((Level - 1) * 5, 2));
public int LevelUpNeed() => (int)(Math.Pow((Level) * 5, 2));
/// <summary>
/// 体力 0-100
/// </summary>
@ -93,7 +93,7 @@ namespace VPet_Simulator.Core
/// <summary>
/// 计算宠物当前状态
/// </summary>
public void CalMode()
public ModeType CalMode()
{
int realhel = 60 - (Feeling >= 80 ? 20 : 0) - (Likability >= 80 ? 20 : (Likability >= 40 ? 10 : 0));
//先从最次的开始
@ -102,21 +102,21 @@ namespace VPet_Simulator.Core
//可以确认从状态不佳和生病二选一
if (Health <= realhel / 2)
{//生病
Mode = ModeType.Ill;
return ModeType.Ill;
}
else
{
Mode = ModeType.PoorCondition;
return ModeType.PoorCondition;
}
}
//然后判断是高兴还是普通
else if (Feeling >= 80 - (Likability >= 80 ? 20 : (Likability >= 40 ? 10 : 0)))
{
Mode = ModeType.Happy;
return ModeType.Happy;
}
else
{
Mode = ModeType.Nomal;
return ModeType.Nomal;
}
}
/// <summary>
@ -132,7 +132,7 @@ namespace VPet_Simulator.Core
Feeling = 60;
Health = 100;
Likability = 0;
CalMode();
Mode = CalMode();
}
/// <summary>
/// 读档
@ -147,7 +147,7 @@ namespace VPet_Simulator.Core
Feeling = line.GetFloat("feeling");
Health = line.GetFloat("health");
Likability = line.GetFloat("likability");
CalMode();
Mode = CalMode();
}
/// <summary>
/// 存档

View File

@ -1,47 +0,0 @@
using LinePutScript;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VPet_Simulator.Core
{
/// <summary>
/// 游戏设置,例如窗体大小等
/// </summary>
public class Setting : LpsDocument
{
public Setting(string lps) : base(lps)
{
}
public Setting() : base()
{
}
/// <summary>
/// 窗体宽度
/// </summary>
public double Width
{
get => this["windows"].GetDouble("width", 250);
set => this["windows"].SetDouble("width", value);
}
/// <summary>
/// 窗体高度
/// </summary>
public double Heigh
{
get => this["windows"].GetDouble("heigh", 250);
set => this["windows"].SetDouble("heigh", value);
}
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
public int PressLength
{
get => this["windows"].GetInt("presslength", 500);
set => this["windows"].SetInt("presslength", value);
}
}
}

View File

@ -154,7 +154,6 @@
<Compile Include="Handle\GameCore.cs" />
<Compile Include="Handle\IController.cs" />
<Compile Include="Handle\Save.cs" />
<Compile Include="Handle\Setting.cs" />
<Compile Include="Item\Drink.cs" />
<Compile Include="Item\Food.cs" />
<Compile Include="Item\Item.cs" />

View File

@ -0,0 +1,96 @@
using LinePutScript;
using Steamworks.Ugc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.GraphCore;
namespace VPet_Simulator.Windows
{
public class CoreMOD
{
public static string NowLoading = null;
public string Name;
public string Author;
/// <summary>
/// 如果是上传至Steam,则为SteamUserID
/// </summary>
public long AuthorID;
/// <summary>
/// 上传至Steam的ItemID
/// </summary>
public ulong ItemID;
public string Intro;
public DirectoryInfo Path;
public int GameVer;
public int Ver;
public string Content = "";
public bool SuccessLoad = true;
public static string INTtoVER(int ver) => $"{ver / 100}.{ver % 100:00}";
public CoreMOD(DirectoryInfo directory, MainWindow mw)
{
Path = directory;
LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps"));
Name = modlps.FindLine("vupmod").Info;
NowLoading = Name;
Intro = modlps.FindLine("intro").Info;
GameVer = modlps.FindSub("gamever").InfoToInt;
Ver = modlps.FindSub("ver").InfoToInt;
Author = modlps.FindSub("author").Info;
if (modlps.FindLine("authorid") != null)
AuthorID = modlps.FindLine("authorid").InfoToInt64;
else
AuthorID = 0;
if (modlps.FindLine("itemid") != null)
ItemID = Convert.ToUInt64(modlps.FindLine("itemid").info);
else
ItemID = 0;
if (IsBanMOD(mw))
{
Content = "该模组已停用";
return;
}
foreach (DirectoryInfo di in Path.EnumerateDirectories())
{
switch (di.Name.ToLower())
{
case "pet":
//宠物模型
Content += "宠物形象\n";
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName));
if (lps.First().Name.ToLower() == "pet")
{
mw.Pets.Add(new CorePet(lps, di));
}
}
break;
}
}
}
public bool IsBanMOD(MainWindow mw) => mw.Set.IsBanMod(Name);
public bool IsPassMOD(MainWindow mw) => mw.Set.IsPassMOD(Name);
public void WriteFile()
{
LpsDocument modlps = new LpsDocument(File.ReadAllText(Path.FullName + @"\info.lps"));
modlps.FindLine("vupmod").Info = Name;
modlps.FindLine("intro").Info = Intro;
modlps.FindSub("gamever").InfoToInt = GameVer;
modlps.FindSub("ver").InfoToInt = Ver;
modlps.FindSub("author").Info = Author;
modlps.FindorAddLine("authorid").InfoToInt64 = AuthorID;
modlps.FindorAddLine("itemid").info = ItemID.ToString();
File.WriteAllText(Path.FullName + @"\info.lps", modlps.ToString());
}
}
}

View File

@ -0,0 +1,97 @@
using LinePutScript;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.GraphCore;
namespace VPet_Simulator.Windows
{
/// <summary>
/// 宠物
/// </summary>
public class CorePet
{
/// <summary>
/// 宠物图像
/// </summary>
public GraphCore Graph
{
get
{
var g = new GraphCore();
LoadGraph(g, new DirectoryInfo(path), "");
return g;
}
}
public string path;
/// <summary>
/// 宠物名字
/// </summary>
public string Name;
/// <summary>
/// 宠物介绍
/// </summary>
public string Intor;
public Line GraphSetting;
public CorePet(LpsDocument lps, DirectoryInfo directory)
{
Name = lps.First().Info;
Intor = lps.First()["intor"].Info;
path = directory.FullName + "\\" + lps.First()["path"].Info;
GraphSetting = lps["graph"];
}
public static void LoadGraph(GraphCore graph, DirectoryInfo di, string path_name)
{
var list = di.EnumerateDirectories();
if (list.Count() == 0)
{
if (File.Exists(di.FullName + @"\info.lps"))
{//如果自带描述信息,则手动加载
//TODO:
}
else
{//自动加载 PNG ANMIN
path_name = path_name.Trim('_').ToLower();
for (int i = 0; i < GraphTypeValue.Length; i++)
{
if (path_name.StartsWith(GraphTypeValue[i][0]))
{
if (path_name.Contains("happy"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Happy, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("nomal"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Nomal, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("poorcondition"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.PoorCondition, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("ill"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Ill, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
return;
}
}
#if DEBUG
throw new Exception("未知的图像类型: " + path_name);
#endif
}
}
else
foreach (var p in list)
{
LoadGraph(graph, p, path_name + "_" + p.Name);
}
}
}
}

View File

@ -64,5 +64,7 @@ namespace VPet_Simulator.Windows
}
public double ZoomRatio => 0.5;
public int PressLength => 500;
}
}

View File

@ -0,0 +1,273 @@
using LinePutScript;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VPet_Simulator.Windows
{
public class Setting : LpsDocument
{
public Setting(string lps) : base(lps)
{
}
public void Save()
{
File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", ToString());
}
//public Size WindowsSize
//{
// get
// {
// var line = FindLine("windowssize");
// if (line == null)
// return new Size(1366, 799);
// var strs = line.GetInfos();
// if (int.TryParse(strs[0], out int x))
// x = 1366;
// if (int.TryParse(strs[0], out int y))
// y = 799;
// return new Size(x, y);
// }
// set
// {
// FindorAddLine("windowssize").info = $"{value.Width},{value.Height}";
// }
//}
public ResolutionType Resolution
{
get
{
var line = FindLine("windowssize");
if (line == null)
return ResolutionType.q1280x720;
return (ResolutionType)line.InfoToInt;
}
set
{
FindorAddLine("windowssize").InfoToInt = (int)value;
}
}
public int ZoomLevel
{
get
{
var line = FindLine("zoomlevel");
if (line == null)
return 75;
int zl = line.InfoToInt;
if (zl < 25 || zl > 100)
{
return 75;
}
return zl;
}
set
{
FindorAddLine("zoomlevel").InfoToInt = value;
}
}
/// <summary>
/// 分辨率类型,仅支持以下分辨率 q:1.77 l:1.6 s:1.33
/// </summary>
public enum ResolutionType
{
q1280x720,// = 128000720,
l1280x800,// = 128000800,
s1280x960,// = 128000960,
q1440x810,// = 144000810,
l1440x900,// = 144000900,
s1440x1080,// = 144001080,
q1600x900,// = 160000900,
l1600x1000,// = 160001000,
s1600x1200,// = 160001200,
q1680x945,// = 160000945,
l1680x1050,// = 160001050,
s1680x1260,// = 160001260,
q1920x1080,// = 192001080,
l1920x1200,// = 192001200,
s1920x1440,// = 192001440,
q2048x1152,// = 204801152,
l2048x1260,// = 204801260,
s2048x1536,// = 204801536,
q2560x1440,// = 256001440,
l2560x1600,// = 256001600,
s2560x1920,// = 256001920,
q3840x2160,// = 384002160,
l3840x2400,// = 384002400,
s3840x2880,// = 384002880,
}
/// <summary>
/// 分辨率表,快速查询分辨率
/// </summary>
public static readonly int[] ResolutionList = {
128000720,
128000800,
128000960,
144000810,
144000900,
144001080,
160000900,
160001000,
160001200,
160000945,
160001050,
160001260,
192001080,
192001200,
192001440,
204801152,
204801260,
204801536,
256001440,
256001600,
256001920,
384002160,
384002400,
384002880
};
//public static readonly Dictionary<int, int> ResolutionList = new Dictionary<int, int>()
//{
// {1, 128000720 },
// 128000800,
// 128000960,
// 144000810,
// 144000900,
// 144001080,
// 160000900,
// 160001000,
// 160001200,
// 160000945,
// 160001050,
// 160001260,
// 192001080,
// 192001200,
// 192001440,
// 204801152,
// 204801260,
// 204801536,
// 256001440,
// 256001600,
// 256001920,
// 384002160,
// 384002400,
// 384002880,
//};
public bool IsFullScreen
{
get => FindLine("fullscreen") != null;
set
{
if (value)
FindorAddLine("fullscreen");
else
RemoveAll("fullscreen");
}
}
/// <summary>
/// 是否启用数据收集 //TODO:判断游戏是否是原版的
/// </summary>
public bool Diagnosis
{
get => !this["diagnosis"].GetBool("disable");
set => this["diagnosis"].SetBool("disable", !value);
}
/// <summary>
/// 数据收集频率
/// </summary>
public int DiagnosisInterval
{
get => Math.Max(this["diagnosis"].GetInt("interval", 14), 7);
set => this["diagnosis"].SetInt("interval", value);
}
/// <summary>
/// 自动保存频率
/// </summary>
public int AutoSaveInterval
{
get => Math.Max(GetInt("autosave", 7), 0);
set => SetInt("autosave", value);
}
/// <summary>
/// 桌面图标是否自动对齐
/// </summary>
public bool ShortcutAlignment
{
get => !GetBool("shortcut_alignment");
set => SetBool("shortcut_alignment", !value);
}
/// <summary>
/// 数据收集是否被禁止(当日)
/// </summary>
public bool DiagnosisDayEnable = true;
public string Font
{
get => GetString("font", "OPPOSans R");
set => this[(gstr)"font"] = value;
}
public string Theme
{
get
{
var line = FindLine("theme");
if (line == null)
return "default";
return line.Info;
}
set
{
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 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());
}
/// <summary>
/// 按多久视为长按 单位毫秒
/// </summary>
public int PressLength
{
get => this["windows"].GetInt("presslength", 500);
set => this["windows"].SetInt("presslength", value);
}
}
}

View File

@ -7,7 +7,9 @@
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="-1" />
</WindowChrome.WindowChrome>
<Grid>
<Grid x:Name="DisplayGrid" />
<Grid><Label x:Name="LoadingText" HorizontalAlignment="Center" VerticalAlignment="Center"
Background="{DynamicResource DARKPrimaryLight}" Foreground="{DynamicResource DARKPrimaryText}"
Content="桌宠加载中" />
<Border x:Name="DisplayGrid" />
</Grid>
</Window>

View File

@ -28,6 +28,9 @@ namespace VPet_Simulator.Windows
public readonly string ModPath = Environment.CurrentDirectory + @"\mod";
public readonly bool IsSteamUser;
public Setting Set;
public List<CorePet> Pets = new List<CorePet>();
public List<CoreMOD> CoreMODs = new List<CoreMOD>();
public GameCore Core = new GameCore();
public MainWindow()
{
//判断是不是Steam用户,因为本软件会发布到Steam
@ -52,7 +55,7 @@ namespace VPet_Simulator.Windows
Set = new Setting(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps"));
}
else
Set = new Setting();
Set = new Setting("Setting#VPET:|\n");
InitializeComponent();
@ -64,15 +67,51 @@ namespace VPet_Simulator.Windows
Close();
return;
}
var core = new GameCore();
core.Setting = Set;
core.Controller = new MWController(this);
core.Graph = new GraphCore();
core.Save = new Save();
LoadGraph(core.Graph, modpath, "");
DisplayGrid.Children.Add(new Main(core));
Task.Run(GameLoad);
}
public void GameLoad()
{
//加载所有MOD
List<DirectoryInfo> Path = new List<DirectoryInfo>();
Path.AddRange(new DirectoryInfo(ModPath).EnumerateDirectories());
if (IsSteamUser)//如果是steam用户,尝试加载workshop
{
Dispatcher.Invoke(new Action(() => LoadingText.Content = "尝试加载 Steam Workshop"));
int i = 1;
while (true)
{
var page = Steamworks.Ugc.Query.ItemsReadyToUse.GetPageAsync(i++).Result;
if (page.HasValue && page.Value.ResultCount != 0)
{
foreach (Steamworks.Ugc.Item entry in page.Value.Entries)
{
if (entry.Directory != null)
Path.Add(new DirectoryInfo(entry.Directory));
}
}
else
{
break;
}
}
}
//加载mod
foreach (DirectoryInfo di in Path)
{
if (!File.Exists(di.FullName + @"\info.lps"))
continue;
Dispatcher.Invoke(new Action(() => LoadingText.Content = $"尝试加载 MOD数据: {di.Name}"));
CoreMODs.Add(new CoreMOD(di, this));
}
Dispatcher.Invoke(new Action(() => LoadingText.Content = "尝试加载游戏内容"));
//加载游戏内容
Core.Controller = new MWController(this);
Dispatcher.Invoke(new Action(() => Core.Graph = Pets[0].Graph));
Core.Save = new Save();
Dispatcher.Invoke(new Action(() => LoadingText.Visibility = Visibility.Collapsed));
Dispatcher.Invoke(new Action(() => DisplayGrid.Child = new Main(Core)));
}
//public void DEBUGValue()
//{
// Dispatcher.Invoke(() =>
@ -83,51 +122,6 @@ namespace VPet_Simulator.Windows
// Thread.Sleep(1000);
// DEBUGValue();
//}
public static void LoadGraph(GraphCore graph, DirectoryInfo di, string path_name)
{
var list = di.EnumerateDirectories();
if (list.Count() == 0)
{
if (File.Exists(di.FullName + @"\info.lps"))
{//如果自带描述信息,则手动加载
}
else
{//自动加载 PNG ANMIN
path_name = path_name.Trim('_').ToLower();
for (int i = 0; i < GraphTypeValue.Length; i++)
{
if (path_name.StartsWith(GraphTypeValue[i][0]))
{
if (path_name.Contains("happy"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Happy, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("nomal"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Nomal, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("poorcondition"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.PoorCondition, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
if (path_name.Contains("ill"))
{
graph.AddGraph(new PNGAnimation(di.FullName, Save.ModeType.Ill, (GraphType)i, GraphTypeValue[i][1], GraphTypeValue[i][2]), (GraphType)i);
}
return;
}
}
#if DEBUG
throw new Exception("未知的图像类型: " + path_name);
#endif
}
}
else
foreach (var p in list)
{
LoadGraph(graph, p, path_name + "_" + p.Name);
}
}
}
}

View File

@ -109,6 +109,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Function\CoreMOD.cs" />
<Compile Include="Function\CorePet.cs" />
<Compile Include="Function\Setting.cs" />
<Compile Include="WinDesign\winCharacterPanel.xaml.cs">
<DependentUpon>winCharacterPanel.xaml</DependentUpon>
</Compile>
@ -127,7 +130,7 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MWController.cs" />
<Compile Include="Function\MWController.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>