diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml.cs b/VPet-Simulator.Core/Display/MessageBar.xaml.cs index 8f2f9668..ecd36ed0 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml.cs +++ b/VPet-Simulator.Core/Display/MessageBar.xaml.cs @@ -59,7 +59,7 @@ private void ShowTimer_Elapsed(object sender, ElapsedEventArgs e) { Task.Run(() => { - Thread.Sleep(timeleft * 100); + Thread.Sleep(timeleft * 50); if (m.DisplayType == GraphCore.GraphType.Default || m.DisplayType.ToString().Contains("Say")) m.Display(GraphCore.GraphType.Say_C_End, m.DisplayNomal); }); @@ -77,9 +77,9 @@ private void EndTimer_Elapsed(object sender, ElapsedEventArgs e) } } - public Timer EndTimer = new Timer() { Interval = 100 }; + public Timer EndTimer = new Timer() { Interval = 200 }; public Timer ShowTimer = new Timer() { Interval = 40 }; - public Timer CloseTimer = new Timer() { Interval = 10 }; + public Timer CloseTimer = new Timer() { Interval = 20 }; int timeleft; /// <summary> /// 显示消息 diff --git a/VPet-Simulator.Core/Graph/GraphCore.cs b/VPet-Simulator.Core/Graph/GraphCore.cs index c87bbb54..ac9a2fcb 100644 --- a/VPet-Simulator.Core/Graph/GraphCore.cs +++ b/VPet-Simulator.Core/Graph/GraphCore.cs @@ -9,8 +9,17 @@ namespace VPet_Simulator.Core { + /// <summary> + /// 图像显示核心 + /// </summary> public class GraphCore { + public GraphCore() + { + if (!Directory.Exists(CachePath)) + Directory.CreateDirectory(CachePath); + } + public static string CachePath = AppDomain.CurrentDomain.BaseDirectory + @"\cache"; /// <summary> /// 动画类型 diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.xaml b/VPet-Simulator.Core/Graph/PNGAnimation.xaml index f32e6e78..107a039d 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.xaml +++ b/VPet-Simulator.Core/Graph/PNGAnimation.xaml @@ -1,4 +1,5 @@ -<UserControl x:Class="VPet_Simulator.Core.PNGAnimation" +<pu:ContentControlX x:Class="VPet_Simulator.Core.PNGAnimation" + xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -8,4 +9,4 @@ d:DesignHeight="500" d:DesignWidth="500"> <Grid x:Name="MainGrid"> </Grid> -</UserControl> +</pu:ContentControlX> diff --git a/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs b/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs index 79859fac..4cbdc8ad 100644 --- a/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs +++ b/VPet-Simulator.Core/Graph/PNGAnimation.xaml.cs @@ -18,13 +18,14 @@ using System.Drawing; using LinePutScript; using static System.Windows.Forms.VisualStyles.VisualStyleElement.TreeView; +using Panuon.WPF.UI; namespace VPet_Simulator.Core { /// <summary> /// PNGAnimation.xaml 的交互逻辑 /// </summary> - public partial class PNGAnimation : UserControl, IGraph + public partial class PNGAnimation : ContentControlX, IGraph { /// <summary> /// 所有动画帧 diff --git a/VPet-Simulator.Windows/Function/Setting.cs b/VPet-Simulator.Windows/Function/Setting.cs index 6e561d55..8ebe8751 100644 --- a/VPet-Simulator.Windows/Function/Setting.cs +++ b/VPet-Simulator.Windows/Function/Setting.cs @@ -248,8 +248,24 @@ public bool EnableFunction /// </summary> public int SmartMoveInterval { - get => this["gameconfig"].GetInt("smartmoveinterval", 20*60); + get => this["gameconfig"].GetInt("smartmoveinterval", 20 * 60); set => this["gameconfig"].SetInt("smartmoveinterval", value); } + /// <summary> + /// 开机启动 + /// </summary> + public bool StartUPBoot + { + get => this["gameconfig"].GetBool("startboot"); + set => this["gameconfig"].SetBool("startboot", value); + } + /// <summary> + /// 开机启动 Steam + /// </summary> + public bool StartUPBootSteam + { + get => !this["gameconfig"].GetBool("startbootsteam"); + set => this["gameconfig"].SetBool("startbootsteam", !value); + } } } diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 948e540d..5cdaeb5e 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -73,10 +73,6 @@ public MainWindow() else Set = new Setting("Setting#VPET:|\n"); - if (!Directory.Exists(GraphCore.CachePath)) - { - Directory.CreateDirectory(GraphCore.CachePath); - } //this.Width = 400 * ZoomSlider.Value; //this.Height = 450 * ZoomSlider.Value; @@ -160,7 +156,9 @@ public void GameLoad() Dispatcher.Invoke(new Action(() => { + LoadingText.Content = "尝试加载动画和生成缓存"; Core.Graph = Pets[0].Graph(); + LoadingText.Content = "正在加载游戏"; winSetting = new winGameSetting(this); Main = new Main(Core) { }; Main.DefaultClickAction = () => @@ -173,7 +171,7 @@ public void GameLoad() }; DisplayGrid.Child = Main; Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "退出桌宠", () => { Close(); }); - Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "管理控制台", () => { new winConsole(this).Show(); }); + Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "开发控制台", () => { new winConsole(this).Show(); }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "反馈中心", () => { new winReport(this).Show(); }); Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "设置面板", () => { @@ -211,7 +209,7 @@ public void GameLoad() notifyIcon.Visible = true; - if (Set["SingleTips"].GetBool("helloworld")) + if (!Set["SingleTips"].GetBool("helloworld")) { Set["SingleTips"].SetBool("helloworld", true); notifyIcon.ShowBalloonTip(10, "你好 " + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName), @@ -222,11 +220,11 @@ public void GameLoad() Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议"); }); } - else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 2, 13)) + else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 2, 17)) { Set["SingleTips"].SetDateTime("update", DateTime.Now); - notifyIcon.ShowBalloonTip(10, "更新通知 02/13", - "现在使用缓存机制,不仅占用小,而且再也不会有那种闪闪的问题了!", ToolTipIcon.Info); + notifyIcon.ShowBalloonTip(10, "更新通知 02/17", + "现在使用缓存机制,不仅占用小,而且再也不会有那种闪闪的问题了!\n现已支持开机启动功能,前往设置设置开机启动", ToolTipIcon.Info); } })); } diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index fab01def..f7bd51a5 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -216,5 +216,16 @@ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> + <ItemGroup> + <COMReference Include="IWshRuntimeLibrary"> + <Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid> + <VersionMajor>1</VersionMajor> + <VersionMinor>0</VersionMinor> + <Lcid>0</Lcid> + <WrapperTool>tlbimp</WrapperTool> + <Isolated>False</Isolated> + <EmbedInteropTypes>True</EmbedInteropTypes> + </COMReference> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project> \ No newline at end of file diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index e7cd47d0..bc0216ad 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -90,11 +90,12 @@ <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <pu:Switch x:Name="StartUpBox" BorderBrush="{DynamicResource PrimaryDark}" - CheckedBackground="{DynamicResource Primary}" IsEnabled="False" + CheckedBackground="{DynamicResource Primary}" CheckedBorderBrush="{DynamicResource Primary}" Background="Transparent" BoxWidth="35" BoxHeight="18" ToggleSize="14" ToggleShadowColor="{x:Null}" ToggleBrush="{DynamicResource PrimaryDark}" Content="开机启动" - CheckedToggleBrush="{DynamicResource DARKPrimaryText}" ToolTip="该游戏随着开机启动该程序" /> + CheckedToggleBrush="{DynamicResource DARKPrimaryText}" ToolTip="该游戏随着开机启动该程序" + Checked="StartUpBox_Checked" Unchecked="StartUpBox_Checked" /> <pu:Switch x:Name="StartUpSteamBox" BorderBrush="{DynamicResource PrimaryDark}" CheckedBackground="{DynamicResource Primary}" IsEnabled="{Binding ElementName=StartUpBox,Path=IsChecked}" @@ -102,7 +103,8 @@ BoxWidth="35" BoxHeight="18" ToggleSize="14" ToggleShadowColor="{x:Null}" ToggleBrush="{DynamicResource PrimaryDark}" Content="从Steam启动" CheckedToggleBrush="{DynamicResource DARKPrimaryText}" - ToolTip="从Steam启动该游戏, 统计时长不能停" Grid.Column="1" /> + ToolTip="从Steam启动该游戏, 统计时长不能停" Grid.Column="1" Checked="StartUpSteamBox_Checked" + Unchecked="StartUpSteamBox_Checked" /> </Grid> <TextBlock Grid.Row="6" Text="宠物动画" VerticalAlignment="Center" FontSize="14" /> <ComboBox x:Name="PetBox" Grid.Row="6" Grid.Column="2" ToolTip="加载的宠物动画,重启后生效" diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index f955ee2a..c1a5af99 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -52,6 +53,9 @@ public winGameSetting(MainWindow mw) SmartMoveEventBox.IsChecked = mw.Set.SmartMove; PressLengthSlider.Value = mw.Set.PressLength / 1000.0; + StartUpBox.IsChecked = mw.Set.StartUPBoot; + StartUpSteamBox.IsChecked = mw.Set.StartUPBootSteam; + foreach (PetLoader pl in mw.Pets) { PetBox.Items.Add(pl.Name); @@ -534,7 +538,51 @@ public void SetSmartMove() { mw.Main.SetMoveMode(mw.Set.AllowMove, mw.Set.SmartMove, mw.Set.SmartMoveInterval * 1000); } + private void GenStartUP() + { + var path = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\VPET_Simulator.lnk"; + if (mw.Set.StartUPBoot) + { + if (File.Exists(path)) + { + return; + } + IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell(); + string shortcutAddress; + if (mw.Set.StartUPBootSteam) +#if DEMO + shortcutAddress = "steam://rungameid/2293870"; +#else + shortcutAddress = "steam://rungameid/1920960"; +#endif + else + shortcutAddress = System.Reflection.Assembly.GetExecutingAssembly().Location; + + IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(path); + shortcut.Description = "VPet Simulator"; + shortcut.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; + shortcut.TargetPath = shortcutAddress; + shortcut.IconLocation = AppDomain.CurrentDomain.BaseDirectory + @"vpeticon.ico"; + shortcut.Save(); + } + else + { + if (File.Exists(path)) + { + File.Delete(path); + } + } + } + private void StartUpBox_Checked(object sender, RoutedEventArgs e) + { + mw.Set.StartUPBoot = StartUpBox.IsChecked == true; + GenStartUP(); + } - + private void StartUpSteamBox_Checked(object sender, RoutedEventArgs e) + { + mw.Set.StartUPBootSteam = StartUpSteamBox.IsChecked == true; + GenStartUP(); + } } }