diff --git a/CLEditor/App.xaml.cs b/CLEditor/App.xaml.cs index 06d56c0cf355de6790eacab6f73b716e88b95c0c..e62c811af6f467b4deab8b84129580db8c64f789 100644 --- a/CLEditor/App.xaml.cs +++ b/CLEditor/App.xaml.cs @@ -17,7 +17,7 @@ namespace CLEngine.Editor { base.OnStartup(e); - if (SceneManager.GameProject != null && + if (SceneManager.GameProject != null && SceneManager.GameProject.EditorSettings != null && !SceneManager.GameProject.EditorSettings.CatchError) { diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj index 32d58d302ec4a03632ef4bb6124e2008032a8c3b..39785dd9ea2c4ffc348faac6adefde412b30ef27 100644 --- a/CLEditor/CLEngine.Editor.csproj +++ b/CLEditor/CLEngine.Editor.csproj @@ -433,6 +433,7 @@ + diff --git a/CLEditor/MainWindow.xaml.cs b/CLEditor/MainWindow.xaml.cs index 35051b97b6652ed4ed0517299f5e6d4d07121070..8f1524ecf47804a866fe8c4ac8fa6f20bfaadb9d 100644 --- a/CLEditor/MainWindow.xaml.cs +++ b/CLEditor/MainWindow.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.ComponentModel; using System.Deployment.Application; using System.Diagnostics; using System.Globalization; @@ -62,6 +63,8 @@ namespace CLEngine.Editor string versionInfo; ContextMenu gameViewContextMenu; + private BackgroundWorker backgroundWorker; + private void Initialize() { OutputDataGrid.ItemsSource = EditorHandler.OutputMessages; @@ -101,16 +104,58 @@ namespace CLEngine.Editor .Background("#333") .HasBadge("提示") .HasMessage("欢迎使用CL游戏引擎.") - .Dismiss().WithButton("检查更新", button => - { - // TODO: 检查更新 - }) - .Dismiss().WithButton("更新日志", button => + .Dismiss().WithButton("检查更新", button => { checkforUpdate(); }) + .Dismiss().WithButton("暂不检查", button => { - // TODO: 更新日志 - }) - .Dismiss().WithDelay(TimeSpan.FromSeconds(5)) + }).Dismiss().WithDelay(TimeSpan.FromSeconds(5)) .Queue(); + + backgroundWorker = new BackgroundWorker(); + backgroundWorker.DoWork += BackgroundWorkerOnDoWork; + backgroundWorker.RunWorkerAsync(); + } + + private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs e) + { + // 日志检查 + while (true) + { + if (Logger.Messages.Count > 0) + { + var log = Logger.Messages.Dequeue(); + Dispatcher.Invoke(() => + { + var message = App.Manager.CreateMessage(); + + if (log.Type == LogType.Info) + { + message.Accent("#1751C3") + .HasBadge("提示") + .Background("#333"); + } + else if (log.Type == LogType.Warn) + { + message.Accent("#E0A030") + .HasBadge("警告") + .Background("#333"); + } + else if (log.Type == LogType.Error) + { + message.Accent("#F15B19") + .HasBadge("错误") + .Background("#F15B19"); + } + + message.Animates(true) + .AnimationInDuration(0.75) + .AnimationOutDuration(2) + .HasMessage(log.Message) + .Dismiss().WithButton("确定", button => { }) + .Dismiss().WithDelay(TimeSpan.FromSeconds(10)) + .Queue(); + }); + } + } } private void SceneViewGameControlOnDragOver(object sender, DragEventArgs e) @@ -367,10 +412,39 @@ namespace CLEngine.Editor sceneViewGameControl.EditorMode = EditorModes.Select; } - private async void checkForUpdatesBtn_Click(object sender, RoutedEventArgs e) + private void checkForUpdatesBtn_Click(object sender, RoutedEventArgs e) { + checkforUpdate(); } + private void checkforUpdate() + { + int num = CHelper.CheckNewFiles(); + if (num > 0) + { + App.Manager.CreateMessage() + .Accent("#1751C3") + .Animates(true) + .AnimationInDuration(0.75) + .AnimationOutDuration(2) + .Background("#333") + .HasBadge("提示") + .HasMessage("在网站上发现的更新,现在进行升级?") + .Dismiss().WithButton("现在更新", button => + { + CHelper.RunUpdater(); + Application.Current.Shutdown(); + }).Dismiss().WithButton("稍后再说", button => + { + + }).Queue(); + } + else + { + Logger.Info("已是最新版本, 无需更新"); + } + } + private void websiteBtn_Click(object sender, RoutedEventArgs e) { Process.Start("http://www.hyuan.org/"); @@ -646,8 +720,8 @@ namespace CLEngine.Editor //循环遍历引用的程序集名称数组 foreach (AssemblyName strAssmbName in arrReferencedAssmbNames) { - //Console.WriteLine("search: " + SceneManager.GameProject.ProjectPath + "\\" + args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"); - //Console.WriteLine("aa: " + args.Name.Substring(0, args.Name.IndexOf(","))); + //Console.Info("search: " + SceneManager.GameProject.ProjectPath + "\\" + args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"); + //Console.Info("aa: " + args.Name.Substring(0, args.Name.IndexOf(","))); //检查引发“AssemblyResolve”事件的程序集名称 if (strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(",")) == args.Name.Substring(0, args.Name.IndexOf(","))) { @@ -663,10 +737,10 @@ namespace CLEngine.Editor foreach (string fileName in Directory.GetFiles(SceneManager.GameProject.ProjectPath + "\\libs\\")) { string asmName = Path.GetFileName(fileName); - //Console.WriteLine("search: " + asmName.Replace(".dll", "") + " == " + args.Name.Substring(0, args.Name.IndexOf(","))); + //Console.Info("search: " + asmName.Replace(".dll", "") + " == " + args.Name.Substring(0, args.Name.IndexOf(","))); if (asmName.Replace(".dll", "") == args.Name.Substring(0, args.Name.IndexOf(","))) { - // Console.WriteLine("entrei"); + // Console.Info("entrei"); strTempAssmbPath = SceneManager.GameProject.ProjectPath + "\\libs\\" + asmName; break; } @@ -695,7 +769,7 @@ namespace CLEngine.Editor gridSnappingBtn.IsChecked = SceneManager.GameProject.EditorSettings.SnapToGrid; showCollisionsBtn.IsChecked = SceneManager.GameProject.EditorSettings.ShowCollisions; debugViewBtn.IsChecked = Properties.Settings.Default.ShowDebugView; - // Console.WriteLine(sceneEditorControl1.EditorMode + ":" + lastEditorMode); + // Console.Info(sceneEditorControl1.EditorMode + ":" + lastEditorMode); if (sceneViewGameControl.EditorMode != lastEditorMode) { @@ -1116,8 +1190,9 @@ namespace CLEngine.Editor private void LoginOrRegisterBtn_Click(object sender, MouseButtonEventArgs e) { - var loginOrRegisteWin = new LoginOrRegister(); - loginOrRegisteWin.ShowDialog(); + //var loginOrRegisteWin = new LoginOrRegister(); + //loginOrRegisteWin.ShowDialog(); + Logger.Error("不允许登陆"); } private void QuickCreateCollision_Click(object sender, RoutedEventArgs e) diff --git a/CLEditor/Project Templates/CLEngine.Core.xml b/CLEditor/Project Templates/CLEngine.Core.xml index b28817e30669c9e82d26a0de53ee1f68dd824348..bdb31d28b3c591533cea892619798440633559ab 100644 --- a/CLEditor/Project Templates/CLEngine.Core.xml +++ b/CLEditor/Project Templates/CLEngine.Core.xml @@ -1666,7 +1666,7 @@ The context. 第一类参数. - + 获取或设置输出超时。 默认值:1000 = 1秒 @@ -10040,53 +10040,53 @@ if set to true [connect first and last]. if set to true [collide connected]. - + Contains filter data that can determine whether an object should be processed or not. - + Disable the logic on specific categories. Category.None by default. - + Disable the logic on specific groups - + Enable the logic on specific categories Category.All by default. - + Enable the logic on specific groups. - + - + Adds the category. The category. - + Removes the category. The category. - + Determines whether this body ignores the the specified controller. @@ -10095,19 +10095,19 @@ true if the object has the specified category; otherwise, false. - + Adds the category. The category. - + Removes the category. The category. - + Determines whether this body ignores the the specified controller. @@ -10116,19 +10116,19 @@ true if the object has the specified category; otherwise, false. - + Ignores the controller. The controller has no effect on this body. The logic type. - + Restore the controller. The controller affects this body. The logic type. - + Determines whether this body ignores the the specified controller. @@ -10137,55 +10137,55 @@ true if the body has the specified flag; otherwise, false. - + This is a comprarer used for detecting angle difference between rays - + Creates a realistic explosion based on raycasting. Objects in the open will be affected, but objects behind static bodies will not. A body that is half in cover, half in the open will get half the force applied to the end in the open. - + Two degrees: maximum angle from edges to first ray tested - + Ratio of arc length to angle from edges to first ray tested. Defaults to 1/40. - + Ignore Explosion if it happens inside a shape. Default value is false. - + Max angle between rays (used when segment is large). Defaults to 15 degrees - + Maximum number of shapes involved in the explosion. Defaults to 100 - + How many rays per shape/body/segment. Defaults to 5 - + Activate the explosion at the specified position. @@ -10194,18 +10194,18 @@ The explosion force at the explosion point (then is inversely proportional to the square of the distance) A list of bodies and the amount of force that was applied to them. - + Creates a simple explosion that ignores other bodies hiding behind static bodies. - + This is the power used in the power function. A value of 1 means the force applied to bodies in the explosion is linear. A value of 2 means it is exponential. - + Activate the explosion at the specified position. @@ -22360,7 +22360,7 @@ configuration on Steam. Ask Valve for help with this. - + Checks if the current user's Steam client is connected to the Steam servers. If it's not then no real-time services provided by the Steamworks API will be enabled. The Steam @@ -23118,20 +23118,20 @@ When querying the server list you can filter by these tags. - + - Log onto Steam anonymously. + Logger onto Steam anonymously. - + - Log onto Steam anonymously. + Logger onto Steam anonymously. - + Returns true if the server is connected and registered with the Steam master server - You should have called LogOnAnonymous etc on startup. + You should have called LoggerOnAnonymous etc on startup. diff --git a/CLEditor/controls/DragDropTreeViewItem.cs b/CLEditor/controls/DragDropTreeViewItem.cs index 3ebfdf4d571dfd2322719667fa895a2c62efb275..58e2b6b55905917991b34b344466bfd10227c93e 100644 --- a/CLEditor/controls/DragDropTreeViewItem.cs +++ b/CLEditor/controls/DragDropTreeViewItem.cs @@ -33,7 +33,7 @@ namespace CLEngine.Editor.controls DragDropTreeViewItem targetNode = GetNearestContainer(e.Source as UIElement); if (targetNode == null) DragDropHelper.RemoveInsertionAdorner(); - //Console.WriteLine(this.PointFromScreen(Mouse.GetPosition(targetNode))); + //Console.Info(this.PointFromScreen(Mouse.GetPosition(targetNode))); } protected override void OnDragOver(DragEventArgs e) @@ -49,19 +49,19 @@ namespace CLEngine.Editor.controls if (e.GetPosition(targetNode).Y < targetNode.ActualHeight * 0.2f) { // meter em cima - //Console.WriteLine("cima"); + //Console.Info("cima"); DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Top; DragDropHelper.CreateInsertionAdorner(targetNode, true); } else if (e.GetPosition(targetNode).Y > targetNode.ActualHeight * 0.8f) { - //Console.WriteLine("baixo"); + //Console.Info("baixo"); DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Bottom; DragDropHelper.CreateInsertionAdorner(targetNode, false); } else { - //Console.WriteLine("centro"); + //Console.Info("centro"); DragDropHelper.RemoveInsertionAdorner(); DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Center; var converter = new System.Windows.Media.BrushConverter(); @@ -83,19 +83,19 @@ namespace CLEngine.Editor.controls // if (e.GetPosition(targetNode).Y < targetNode.ActualHeight * 0.2f) // { // // meter em cima - // //Console.WriteLine("cima"); + // //Console.Info("cima"); // DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Top; // DragDropHelper.CreateInsertionAdorner(targetNode, true); // } // else if (e.GetPosition(targetNode).Y > targetNode.ActualHeight * 0.8f) // { - // //Console.WriteLine("baixo"); + // //Console.Info("baixo"); // DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Bottom; // DragDropHelper.CreateInsertionAdorner(targetNode, false); // } // else // { - // //Console.WriteLine("centro"); + // //Console.Info("centro"); // DragDropHelper.insertionPlace = DragDropHelper.InsertionPlace.Center; // var converter = new System.Windows.Media.BrushConverter(); // Background = (Brush)converter.ConvertFromString("#555"); @@ -103,10 +103,10 @@ namespace CLEngine.Editor.controls //} //DragDropTreeViewItem targetNode = GetNearestContainer(e.Source as UIElement); - //Console.WriteLine("op2: " + e.GetPosition(targetNode)); + //Console.Info("op2: " + e.GetPosition(targetNode)); //Mouse.GetPosition(this); ve se da algo de jeito deve dar, le a info eu sei fui eu que fiz -mas. a-cho qeu nao dava vou ver - //Console.WriteLine(this.PointToScreen(Mouse.GetPosition(targetNode))); - //Console.WriteLine("op: " + Mouse.GetPosition(targetNode)); + //Console.Info(this.PointToScreen(Mouse.GetPosition(targetNode))); + //Console.Info("op: " + Mouse.GetPosition(targetNode)); } diff --git a/CLEditor/core/EditorCommands.cs b/CLEditor/core/EditorCommands.cs index de416887b1ce90f2d87d3cae05c1592dfad847e4..8ccb3c69ffcd3e658d69d13cdca330609b120aa9 100644 --- a/CLEditor/core/EditorCommands.cs +++ b/CLEditor/core/EditorCommands.cs @@ -593,7 +593,7 @@ namespace CLEngine.Editor.core CreateBindCtx(0, out bindCtx); string displayName; moniker[0].GetDisplayName(bindCtx, null, out displayName); - //Console.WriteLine("Display Name: {0}", displayName); + //Console.Info("Display Name: {0}", displayName); bool isVisualStudio = displayName.StartsWith("!VisualStudio"); if (isVisualStudio) { diff --git a/CLEditor/graphics_device/SceneViewGameControl.cs b/CLEditor/graphics_device/SceneViewGameControl.cs index f4a62957bfcea426dd511873d341ef4093be82d9..42f331c77809790ee32560586344abb15fe1f9f1 100644 --- a/CLEditor/graphics_device/SceneViewGameControl.cs +++ b/CLEditor/graphics_device/SceneViewGameControl.cs @@ -245,7 +245,7 @@ namespace CLEngine.Editor.graphics_device delta = (float)gameTime.ElapsedGameTime.Milliseconds; if (GameInput.IsKeyDown(Keys.LeftShift)) delta *= 3; - //Console.WriteLine(MousePosition.X); + //Console.Info(MousePosition.X); if (leftMouseKeyDown) { @@ -781,7 +781,7 @@ namespace CLEngine.Editor.graphics_device selectionEnd = new Vector2(mouseWorldPosition.X, mouseWorldPosition.Y); } - //Console.WriteLine(selectionStart + ":" + selectionEnd); + //Console.Info(selectionStart + ":" + selectionEnd); selectionArea = MathExtension.RectangleFromVectors(selectionStart, selectionEnd); } diff --git a/CLEditor/model/ScriptsBuilder.cs b/CLEditor/model/ScriptsBuilder.cs index 8469ab8c13753d39c4e279e14cc85b9bca399f59..bcd0f264fb1d570745ca07603d99bda8f12362e5 100644 --- a/CLEditor/model/ScriptsBuilder.cs +++ b/CLEditor/model/ScriptsBuilder.cs @@ -110,7 +110,7 @@ namespace CLEngine.Editor.model //} //catch (Exception ex) //{ - // Console.WriteLine(ex.Message); + // Console.Info(ex.Message); //} /* Compile project */ @@ -133,10 +133,10 @@ namespace CLEngine.Editor.model //foreach (var tr in logger.Errors) //{ - // Console.WriteLine(tr.ToString()); + // Console.Info(tr.ToString()); //} - //Console.WriteLine(buildResult.OverallResult); + //Console.Info(buildResult.OverallResult); string cPath = SceneManager.GameProject.ProjectPath + @"\bin\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + hash + ".dll"; @@ -152,7 +152,7 @@ namespace CLEngine.Editor.model SceneManager.ActiveScene.Initialize(); } - //Console.WriteLine("Path: " + SceneManager.ScriptsAssembly.GetName().Name); + //Console.Info("Path: " + SceneManager.ScriptsAssembly.GetName().Name); } else { diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..888d480863a8c58be39b6c8d805f44b22ce96637 --- /dev/null +++ b/CLEditor/viewmodel/DataBaseViewModel.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using CLEngine.Core.framework; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; + +namespace CLEngine.Editor.viewmodel +{ + /// + /// 数据库视图模型层 + /// + public class DataBaseViewModel : ViewModelBase + { + /// + /// 物品列表 + /// + public ObservableCollection ItemObjects { get; set; } + /// + /// 添加物品命令 + /// + public RelayCommand AddItemCommand { get; set; } + /// + /// 性别列表 + /// + public List GenderTypes { + get { return FrameworkSettings.GenderTypes; } + } + + public DataBaseViewModel() + { + ItemObjects = new ObservableCollection(); + AddItemCommand = new RelayCommand(AddItemAction); + } + + private void AddItemAction() + { + var item = ItemManager.CreateItem("物品" + ItemManager.WorldId); + ItemObjects.Add(item); + } + } +} \ No newline at end of file diff --git a/CLEditor/viewmodel/MainViewModel.cs b/CLEditor/viewmodel/MainViewModel.cs index 46c79bca472a3e115b5a55ff58f10bb86a0b3c84..0c47662ce2651311c13d39b32c88eb5df4bdce3e 100644 --- a/CLEditor/viewmodel/MainViewModel.cs +++ b/CLEditor/viewmodel/MainViewModel.cs @@ -83,7 +83,7 @@ namespace CLEngine.Editor.ViewModel private bool CanDataBaseAction() { - return false; + return true; } private void ClearTextureBuffAction() diff --git a/CLEditor/viewmodel/ViewModelLocator.cs b/CLEditor/viewmodel/ViewModelLocator.cs index 57b0b37610ff55af7e2bed7cf2ac450da4d23035..aa54ae8db026ea2c94bab3f32322d2cf7f41d4d7 100644 --- a/CLEditor/viewmodel/ViewModelLocator.cs +++ b/CLEditor/viewmodel/ViewModelLocator.cs @@ -12,6 +12,7 @@ See http://www.galasoft.ch/mvvm */ +using CLEngine.Editor.viewmodel; using CommonServiceLocator; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Ioc; @@ -32,16 +33,19 @@ namespace CLEngine.Editor.ViewModel ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } public MainViewModel Main { - get - { - return ServiceLocator.Current.GetInstance(); - } + get { return ServiceLocator.Current.GetInstance(); } } - + + public DataBaseViewModel DataBase + { + get { return ServiceLocator.Current.GetInstance(); } + } + public static void Cleanup() { // TODO Clear the ViewModels diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml index 4ec111a5a340cfb95df0c4ac87caadd00be80b6e..6bb08a0933d92db120fb8121d8cffc15ebc09898 100644 --- a/CLEditor/windows/DataBaseWindow.xaml +++ b/CLEditor/windows/DataBaseWindow.xaml @@ -1,15 +1,150 @@ - - - + xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:Options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" + xmlns:controls="clr-namespace:CLEngine.Editor.controls" + xmlns:framework="clr-namespace:CLEngine.Core.framework;assembly=CLEngine.Core" + x:Class="CLEngine.Editor.windows.DataBaseWindow" + mc:Ignorable="d" DataContext="{Binding DataBase, Source={StaticResource Locator}}" + Title="游戏数据库" Height="768" Width="1366" Background="{DynamicResource PanelBackground}"> + + + + + + + + + + + + - - diff --git a/CLEditor/windows/DataBaseWindow.xaml.cs b/CLEditor/windows/DataBaseWindow.xaml.cs index 2503dccb42d5723805ea25265b447925742e5346..7206cae7058d8b97cb11297fbcf95018a28b1ef6 100644 --- a/CLEditor/windows/DataBaseWindow.xaml.cs +++ b/CLEditor/windows/DataBaseWindow.xaml.cs @@ -1,4 +1,5 @@ -using System; +using CLEngine.Core; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,5 +24,10 @@ namespace CLEngine.Editor.windows { InitializeComponent(); } + + private void CloseBtn_Click(object sender, RoutedEventArgs e) + { + this.Close(); + } } } diff --git a/CLEditor/windows/ManageTagsWindow.xaml b/CLEditor/windows/ManageTagsWindow.xaml index 1a3e415ac8202032cdd9c8bc966dbedefc30aaaf..4d30f348b7e68e246f38c63b73ad017db589e117 100644 --- a/CLEditor/windows/ManageTagsWindow.xaml +++ b/CLEditor/windows/ManageTagsWindow.xaml @@ -6,19 +6,20 @@ xmlns:local="clr-namespace:CLEngine.Editor.windows" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" - Title="管理场景标签" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" Icon="/CLEngine.Editor;component/content/logo_modern.png" Loaded="Window_Loaded"> + Title="管理场景标签" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" SizeToContent="WidthAndHeight" Icon="/CLEngine.Editor;component/content/logo_modern.png" Loaded="Window_Loaded" >