From 279c15e34ce786f978c88bbc042b1211c00234d9 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Wed, 11 Jan 2023 21:10:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0UI=E5=92=8C=E8=AF=B4=E8=AF=9D?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/Main.xaml.cs | 22 ++- VPet-Simulator.Core/Display/MainLogic.cs | 1 + VPet-Simulator.Core/Display/MessageBar.xaml | 13 +- .../Display/MessageBar.xaml.cs | 33 ++++ VPet-Simulator.Core/Display/Theme.xaml | 170 ++++++++++++++---- VPet-Simulator.Core/Display/ToolBar.xaml | 29 +-- VPet-Simulator.Core/Display/ToolBar.xaml.cs | 35 +++- VPet-Simulator.Core/Handle/IController.cs | 16 +- VPet-Simulator.Core/Handle/Save.cs | 34 +++- .../Design/Theme/basestyle.xaml | 108 ----------- .../Function/MWController.cs | 3 - VPet-Simulator.Windows/MainWindow.xaml.cs | 2 +- .../WinDesign/winCharacterPanel.xaml | 2 +- 13 files changed, 288 insertions(+), 180 deletions(-) diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index 112010d..829d93e 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -28,7 +28,11 @@ namespace VPet_Simulator.Core /// /// 菜单栏 /// - public ToolBar Bar; + public ToolBar ToolBar; + /// + /// 菜单栏 + /// + public MessageBar MsgBar; /// /// 刷新时间时会调用该方法 /// @@ -42,9 +46,12 @@ namespace VPet_Simulator.Core InitializeComponent(); Core = core; - Bar = new ToolBar(this); - Bar.Visibility = Visibility.Collapsed; - UIGrid.Children.Add(Bar); + ToolBar = new ToolBar(this); + ToolBar.Visibility = Visibility.Collapsed; + UIGrid.Children.Add(ToolBar); + MsgBar = new MessageBar(); + MsgBar.Visibility = Visibility.Collapsed; + UIGrid.Children.Add(MsgBar); //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)); @@ -55,7 +62,10 @@ namespace VPet_Simulator.Core EventTimer.Elapsed += EventTimer_Elapsed; MoveTimer.Elapsed += MoveTimer_Elapsed; } - + public void Say(string text) + { + MsgBar.Show(Core.Save.Name, text); + } private void MoveTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Core.Controller.MoveWindows(MoveTimerPoint.X, MoveTimerPoint.Y); @@ -87,7 +97,7 @@ namespace VPet_Simulator.Core if (act != null) Dispatcher.Invoke(act.DoAction); else - Dispatcher.Invoke(Bar.Show); + Dispatcher.Invoke(ToolBar.Show); } }); } diff --git a/VPet-Simulator.Core/Display/MainLogic.cs b/VPet-Simulator.Core/Display/MainLogic.cs index ccf6538..cc5e614 100644 --- a/VPet-Simulator.Core/Display/MainLogic.cs +++ b/VPet-Simulator.Core/Display/MainLogic.cs @@ -27,6 +27,7 @@ namespace VPet_Simulator.Core TimeHandle?.Invoke(this); //TODO:饮食等乱七八糟的消耗 + //UIHandle Dispatcher.Invoke(() => TimeUIHandle.Invoke(this)); diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml b/VPet-Simulator.Core/Display/MessageBar.xaml index 2585451..16464ef 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml +++ b/VPet-Simulator.Core/Display/MessageBar.xaml @@ -4,16 +4,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:VPet_Simulator.Core" mc:Ignorable="d" Height="500" - Width="500"> + Width="500" MouseDoubleClick="UserControl_MouseDoubleClick"> + VerticalAlignment="Bottom" Padding="10" Margin="5" CornerRadius="5" MouseEnter="Border_MouseEnter" + MouseLeave="Border_MouseLeave"> - diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml.cs b/VPet-Simulator.Core/Display/MessageBar.xaml.cs index 5b6705f..2b26744 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml.cs +++ b/VPet-Simulator.Core/Display/MessageBar.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Timers; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -23,6 +24,38 @@ namespace VPet_Simulator.Core public MessageBar() { InitializeComponent(); + ShowTimer.Elapsed += ShowTimer_Elapsed; + } + + private void ShowTimer_Elapsed(object sender, ElapsedEventArgs e) + { + Dispatcher.Invoke(() => this.Visibility = Visibility.Collapsed); + } + + public Timer ShowTimer = new Timer(); + public void Show(string name, string text) + { + TText.Text = text; + LName.Content = name; + ShowTimer.Interval = text.Length * 200 + 1000; + ShowTimer.Start(); + this.Visibility = Visibility.Visible; + } + + private void Border_MouseEnter(object sender, MouseEventArgs e) + { + ShowTimer.Stop(); + } + + private void Border_MouseLeave(object sender, MouseEventArgs e) + { + ShowTimer.Start(); + } + + private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e) + { + ShowTimer.Stop(); + this.Visibility = Visibility.Collapsed; } } } diff --git a/VPet-Simulator.Core/Display/Theme.xaml b/VPet-Simulator.Core/Display/Theme.xaml index b06e3b2..44757f1 100644 --- a/VPet-Simulator.Core/Display/Theme.xaml +++ b/VPet-Simulator.Core/Display/Theme.xaml @@ -1,40 +1,146 @@  - - - - - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" + xmlns:pucore="clr-namespace:Panuon.WPF;assembly=Panuon.WPF"> + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + - #90caf9 + #90caf9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml b/VPet-Simulator.Core/Display/ToolBar.xaml index bb8953b..c092e51 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml +++ b/VPet-Simulator.Core/Display/ToolBar.xaml @@ -8,9 +8,10 @@ - + @@ -93,15 +94,21 @@ - - - - + + + + - - - - + + + + + + + + + diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml.cs b/VPet-Simulator.Core/Display/ToolBar.xaml.cs index dd89532..f5dabc3 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml.cs +++ b/VPet-Simulator.Core/Display/ToolBar.xaml.cs @@ -114,14 +114,32 @@ namespace VPet_Simulator.Core { m.Core.Controller.ShowPanel(); } - - public void AddMenuButton(string parentMenu, + /// + /// 窗口类型 + /// + public enum MenuType + { + /// + /// 投喂 + /// + Feed, + /// + /// 互动 + /// + Interact, + /// + /// 自定 + /// + DIY, + } + public void AddMenuButton(MenuType parentMenu, string displayName, Action clickCallback) { var menuItem = new MenuItem() { Header = displayName, + HorizontalContentAlignment = HorizontalAlignment.Center }; menuItem.Click += delegate { @@ -129,9 +147,15 @@ namespace VPet_Simulator.Core }; switch (parentMenu) { - case "投喂": + case MenuType.Feed: MenuFeed.Items.Add(menuItem); break; + case MenuType.Interact: + MenuInteract.Items.Add(menuItem); + break; + case MenuType.DIY: + MenuDIY.Items.Add(menuItem); + break; } } @@ -196,5 +220,10 @@ namespace VPet_Simulator.Core { closePanelTimer.Start(); } + + private void MenuDIY_Click(object sender, RoutedEventArgs e) + { + m.Say("private void MenuDIY_Click(object sender, RoutedEventArgs e)\r\n {\r\n m.Say(\"\");\r\n }"); + } } } diff --git a/VPet-Simulator.Core/Handle/IController.cs b/VPet-Simulator.Core/Handle/IController.cs index 1ad9e48..ef1e681 100644 --- a/VPet-Simulator.Core/Handle/IController.cs +++ b/VPet-Simulator.Core/Handle/IController.cs @@ -35,14 +35,14 @@ namespace VPet_Simulator.Core /// 获取桌宠距离下方的位置 /// double GetWindowsDistanceDown(); - /// - /// 窗体宽度 - /// - double WindowsWidth { get; set; } - /// - /// 窗体高度 - /// - double WindowsHight { get; set; } + ///// + ///// 窗体宽度 + ///// + //double WindowsWidth { get; set; } + ///// + ///// 窗体高度 + ///// + //double WindowsHight { get; set; } /// /// 缩放比例 /// diff --git a/VPet-Simulator.Core/Handle/Save.cs b/VPet-Simulator.Core/Handle/Save.cs index 68a70d5..eb0a3cf 100644 --- a/VPet-Simulator.Core/Handle/Save.cs +++ b/VPet-Simulator.Core/Handle/Save.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace VPet_Simulator.Core { @@ -12,6 +13,11 @@ namespace VPet_Simulator.Core /// public class Save { + /// + /// 宠物名字 + /// + public string Name; + /// /// 金钱 /// @@ -122,8 +128,9 @@ namespace VPet_Simulator.Core /// /// 新游戏 /// - public Save() + public Save(string name) { + Name = name; Money = 100; Exp = 0; Strength = 100; @@ -140,6 +147,7 @@ namespace VPet_Simulator.Core public Save(Line line) { Money = line.GetFloat("money"); + Name = line.Info; Exp = line.GetInt("exp"); Strength = line.GetFloat("strength"); StrengthDrink = line.GetFloat("strengthdrink"); @@ -155,7 +163,7 @@ namespace VPet_Simulator.Core /// 存档行 public Line ToLine() { - Line save = new Line("vpet", ""); + Line save = new Line("vpet", Name); save.SetFloat("money", Money); save.SetInt("exp", Exp); save.SetFloat("strength", Strength); @@ -166,5 +174,27 @@ namespace VPet_Simulator.Core save.SetFloat("Likability", Likability); return save; } + /// + /// 当前正在的状态 + /// + public enum WorkingState + { + /// + /// 默认:啥都没干 + /// + Nomal, + /// + /// 正在干活, workingobj指示正在干啥活 + /// + Working, + /// + /// 学习中 + /// + Studying, + /// + /// 玩耍中 + /// + Playing, + } } } diff --git a/VPet-Simulator.Windows/Design/Theme/basestyle.xaml b/VPet-Simulator.Windows/Design/Theme/basestyle.xaml index c6a270d..5d47f92 100644 --- a/VPet-Simulator.Windows/Design/Theme/basestyle.xaml +++ b/VPet-Simulator.Windows/Design/Theme/basestyle.xaml @@ -6,114 +6,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -