From bad56b15f4a94fb281f43976964b4995b13fcc08 Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Tue, 23 Jul 2019 11:17:51 +0800
Subject: [PATCH 01/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=BE=91?=
=?UTF-8?q?=E5=99=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/core/EditorCommands.cs | 203 +++++++++---------
CLEditor/core/EditorHandler.cs | 25 +--
CLEditor/core/EditorUtils.cs | 110 ++++------
CLEditor/core/InsertionAdorner.cs | 31 ++-
CLEditor/core/LayoutHelper.cs | 12 +-
CLEditor/core/Page.cs | 10 +-
CLEditor/core/TreeViewExtension.cs | 72 +++----
.../graphics_device/SceneViewGameControl.cs | 110 +++++-----
CLEditor/model/ErrorLog.cs | 5 +-
CLEditor/model/FileHelper.cs | 2 +-
CLEditor/model/ScaleCommand.cs | 1 +
CLEditor/model/ScriptsBuilder.cs | 96 +++++----
CLEditor/model/TilesetCommand.cs | 3 +-
CLEditor/model/commands/MoveCommand.cs | 1 +
CLEditor/model/commands/RotateCommand.cs | 1 +
.../viewmodel/ButtonVisibilityViewModel.cs | 1 -
Engine/CLEngine.Core/Audio.cs | 21 +-
WebPage/index.html | 35 +++
18 files changed, 366 insertions(+), 373 deletions(-)
create mode 100644 WebPage/index.html
diff --git a/CLEditor/core/EditorCommands.cs b/CLEditor/core/EditorCommands.cs
index e07809f..8ec6bdb 100644
--- a/CLEditor/core/EditorCommands.cs
+++ b/CLEditor/core/EditorCommands.cs
@@ -1,20 +1,20 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;
-using System.Windows.Threading;
-using CLEngine.Editor.controls;
using CLEngine.Editor.model;
using CLEngine.Editor.windows;
using CLEngine.Core;
using CLEngine.Core.framework;
+using EnvDTE;
using Clipboard = System.Windows.Clipboard;
using MessageBox = System.Windows.Forms.MessageBox;
+using Process = System.Diagnostics.Process;
+using Thread = System.Threading.Thread;
namespace CLEngine.Editor.core
{
@@ -26,25 +26,14 @@ namespace CLEngine.Editor.core
{
Directory.Delete(path, true);
}
- catch (Exception ex)
+ catch (Exception)
{
Thread.Sleep(1);
DeleteDirectoryRecursively(path);
}
}
- internal static void UpdatePropertyGrid()
- {
- if (EditorHandler.SelectedObjectPG != null)
- {
- EditorHandler.SelectedObjectPG.Dispatcher.BeginInvoke((Action)(() =>
- {
- EditorHandler.SelectedObjectPG.Update();
- }));
- }
- }
-
- static object lockPaste = new object();
+ static readonly object lockPaste = new object();
internal static void CopySelectedObjects()
{
lock (lockPaste)
@@ -59,8 +48,19 @@ namespace CLEngine.Editor.core
}
}
+ internal static void UpdatePropertyGrid()
+ {
+ if (EditorHandler.SelectedObjectPG != null)
+ {
+ EditorHandler.SelectedObjectPG.Dispatcher.BeginInvoke((Action)(() =>
+ {
+ EditorHandler.SelectedObjectPG.Update();
+ }));
+ }
+ }
+
- internal static void PasteSelectedObjects()
+ internal static void PasteSelectedObjects()
{
lock (lockPaste)
{
@@ -70,7 +70,7 @@ namespace CLEngine.Editor.core
if (list == null || list.Count == 0) return;
EditorHandler.SelectedGameObjects.Clear();
- // verificar se tem um pai
+
foreach (var obj in list)
{
var parent = obj.Transform.Parent;
@@ -83,8 +83,7 @@ namespace CLEngine.Editor.core
}
else
{
- var selected = EditorHandler.SceneTreeView.SelectedItem as DragDropTreeViewItem;
- EditorHandler.SceneTreeView.AddGameObject(obj, string.Empty, false, true);
+ EditorHandler.SceneTreeView.AddGameObject(obj, string.Empty, false, true);
}
EditorHandler.SelectedGameObjects.Add(obj);
@@ -103,23 +102,19 @@ namespace CLEngine.Editor.core
// TODO: handle multiple selection
if (EditorHandler.SelectedGameObjects.Count == 1)
{
- PropertyBox properties;
+ var properties = new PropertyBox {SelectedObject = EditorHandler.SelectedGameObjects[0]};
- properties = new PropertyBox();
-
- properties.SelectedObject = EditorHandler.SelectedGameObjects[0] as GameObject;
- EditorHandler.SelectedObjectPG = properties.PropertyGrid;
+ EditorHandler.SelectedObjectPG = properties.PropertyGrid;
properties.ToggleExpand();
EditorHandler.PropertyGridContainer.Children.Add(properties);
- if (EditorHandler.SelectedGameObjects[0] is GameObject)
+ if (EditorHandler.SelectedGameObjects[0] != null)
{
foreach (var component in EditorHandler.SelectedGameObjects[0].GetComponents())
{
- properties = new PropertyBox();
- properties.SelectedObject = component;
- properties.Title.Content += " (Component)";
+ properties = new PropertyBox {SelectedObject = component};
+ properties.Title.Content += " (Component)";
if (component.EditorExpanded)
properties.ToggleExpand();
@@ -135,11 +130,9 @@ namespace CLEngine.Editor.core
{
for (int i = EditorHandler.PropertyGridContainer.Children.Count - 1; i >= 0; i--)
{
- if ((EditorHandler.PropertyGridContainer.Children[i] as PropertyBox).SelectedObject is ObjectComponent)
+ if ((EditorHandler.PropertyGridContainer.Children[i] as PropertyBox)?.SelectedObject is ObjectComponent)
{
- ObjectComponent component = (EditorHandler.PropertyGridContainer.Children[i] as PropertyBox).SelectedObject as ObjectComponent;
-
- if (component.Transform.GameObject.GetComponents().Find(o => o == component) == null)
+ if (((PropertyBox) EditorHandler.PropertyGridContainer.Children[i]).SelectedObject is ObjectComponent component && component.Transform.GameObject.GetComponents().Find(o => o == component) == null)
EditorHandler.PropertyGridContainer.Children.RemoveAt(i);
}
}
@@ -148,23 +141,25 @@ namespace CLEngine.Editor.core
///
/// Loads a saved project
///
+ [SuppressMessage("ReSharper", "LocalizableElement")]
+ [SuppressMessage("ReSharper", "StringLiteralTypo")]
internal static bool LoadProject()
{
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Title = "打开工程";
- ofd.Filter = @"(*.clengine)|*.clengine";
+ OpenFileDialog ofd = new OpenFileDialog {Title = "打开工程", Filter = @"(*.clengine)|*.clengine"};
- if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ if (ofd.ShowDialog() == DialogResult.OK)
{
LoadProject(ofd.FileName);
- EditorCommands.AddToProjectHistory(ofd.FileName);
+ AddToProjectHistory(ofd.FileName);
}
- EditorCommands.ShowOutputMessage("工程加载成功");
+ ShowOutputMessage("工程加载成功");
return false;
}
+ [SuppressMessage("ReSharper", "LocalizableElement")]
+ [SuppressMessage("ReSharper", "StringLiteralTypo")]
internal static bool LoadProject(string filename)
{
try
@@ -263,7 +258,7 @@ namespace CLEngine.Editor.core
///
internal static void ShowOutputMessage(string message)
{
- EditorHandler.OutputMessages.Add(new OutputMessage() { Time = DateTime.Now.ToString("HH:mm:ss").ToString(), Message = message.ToString() });
+ EditorHandler.OutputMessages.Add(new OutputMessage() { Time = DateTime.Now.ToString("HH:mm:ss"), Message = message });
}
///
@@ -284,16 +279,18 @@ namespace CLEngine.Editor.core
///
///
///
+ [SuppressMessage("ReSharper", "LocalizableElement")]
internal static void SaveScene(bool saveAs)
{
if (SceneManager.ActiveScene == null) return;
if (!File.Exists(SceneManager.ActiveScenePath))
{
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.InitialDirectory = SceneManager.GameProject.ProjectPath;
- sfd.Filter = "(*.scene)|*.scene";
- DialogResult dr = sfd.ShowDialog();
+ SaveFileDialog sfd = new SaveFileDialog
+ {
+ InitialDirectory = SceneManager.GameProject.ProjectPath, Filter = "(*.scene)|*.scene"
+ };
+ DialogResult dr = sfd.ShowDialog();
if (dr == DialogResult.Yes || dr == DialogResult.OK)
{
@@ -320,6 +317,7 @@ namespace CLEngine.Editor.core
///
/// 使用不同的线程保存当前项目
///
+ [SuppressMessage("ReSharper", "StringLiteralTypo")]
internal static void SaveProject()
{
if (SceneManager.GameProject != null)
@@ -332,7 +330,7 @@ namespace CLEngine.Editor.core
CHelper.SerializeObject(SceneManager.GameProject.ProjectPath + "\\_userPrefs.pgb", UserPreferences.Instance);
});
- EditorCommands.ShowOutputMessage("Project Saved");
+ ShowOutputMessage("Project Saved");
saveThread.Start();
}
}
@@ -340,6 +338,7 @@ namespace CLEngine.Editor.core
///
///
///
+ [SuppressMessage("ReSharper", "LocalizableElement")]
internal static void DebugGame()
{
if (SceneManager.ActiveScene == null)
@@ -374,7 +373,7 @@ namespace CLEngine.Editor.core
CompilerWindow cf = new CompilerWindow();
cf.ShowDialog();
- if (cf.DialogResult.Value) return;
+ if (cf.DialogResult != null && cf.DialogResult.Value) return;
// Update path
dllpath = SceneManager.GameProject.ProjectPath + "\\bin\\" + (SceneManager.GameProject.Debug ? "Debug" : "Release") + "\\" + SceneManager.ScriptsAssembly.GetName().Name + ".dll";
@@ -384,19 +383,22 @@ namespace CLEngine.Editor.core
try
{
- Process debug = new Process();
- debug.StartInfo.WorkingDirectory = SceneManager.GameProject.ProjectPath;
- debug.StartInfo.FileName = SceneManager.GameProject.ProjectPath + "\\CLEngine.Windows.exe";
- debug.StartInfo.Arguments = "";
- debug.StartInfo.CreateNoWindow = true;
- debug.Start();
+ Process debug = new Process
+ {
+ StartInfo =
+ {
+ WorkingDirectory = SceneManager.GameProject.ProjectPath,
+ FileName = SceneManager.GameProject.ProjectPath + "\\CLEngine.Windows.exe",
+ Arguments = "",
+ CreateNoWindow = true
+ }
+ };
+ debug.Start();
if (Properties.Settings.Default.AttachVisualStudio)
{
- EnvDTE.DTE vsInstance;
-
- // Try to restore the current project visual studio solution instance, returning it if successful
- if (TryToRestoreSolution(out vsInstance))
+ // Try to restore the current project visual studio solution instance, returning it if successful
+ if (TryToRestoreSolution(out var vsInstance))
{
// Tries to attach the retrieved instance to the game debug process
debug.Attach(vsInstance);
@@ -448,7 +450,7 @@ namespace CLEngine.Editor.core
///
/// the visual studio solution instance
/// Whether the restore happened or not
- internal static bool RestoreSolution(EnvDTE.DTE instance)
+ internal static bool RestoreSolution(DTE instance)
{
// if the instance is valid
if (instance != null)
@@ -465,10 +467,10 @@ namespace CLEngine.Editor.core
///
/// The visual studio solution instance
/// Whether the restore was successful or not
- internal static bool TryToRestoreSolution(out EnvDTE.DTE instance)
+ internal static bool TryToRestoreSolution(out DTE instance)
{
// the visual studio instance
- EnvDTE.DTE vsInstance;
+ DTE vsInstance;
// if visual studio instance process Id is valid
if (VisualStudioInstancePID != 0)
@@ -512,18 +514,17 @@ namespace CLEngine.Editor.core
///
/// Apply Blur Effect on the window
///
- ///
+ ///
internal static void ApplyBlurEffect(System.Windows.Window win)
{
- System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
- objBlur.Radius = 4;
- win.Effect = objBlur;
+ System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect {Radius = 4};
+ win.Effect = objBlur;
}
///
/// Remove Blur Effects
///
- ///
+ ///
internal static void ClearEffect(System.Windows.Window win)
{
win.Effect = null;
@@ -532,41 +533,41 @@ namespace CLEngine.Editor.core
public static class Extensions
{
- internal static void Attach(this System.Diagnostics.Process process, EnvDTE.DTE dte)
+ internal static void Attach(this Process process, DTE dte)
{
int tryCount = 5;
while (tryCount-- > 0)
{
try
{
- EnvDTE.Processes processes = dte.Debugger.LocalProcesses;
+ var processes = dte.Debugger.LocalProcesses;
foreach (EnvDTE.Process proc in processes.Cast().Where(
- proc => proc.Name.IndexOf(process.ProcessName) != -1))
+ proc => proc.Name.IndexOf(process.ProcessName, StringComparison.Ordinal) != -1))
{
proc.Attach();
- Debug.WriteLine(String.Format
- ("Attached to process {0} successfully.", process.ProcessName));
+ Debug.WriteLine($"Attached to process {process.ProcessName} successfully.");
break;
}
break;
}
catch (System.Runtime.InteropServices.COMException)
{
- System.Threading.Thread.Sleep(1000);
+ Thread.Sleep(1000);
}
}
}
- internal static EnvDTE.DTE GetInstance(string displayName)
+ internal static DTE GetInstance(string displayName)
{
//List names = new List();
//names.AddRange(from i in GetVisualStudioInstances() select i.Solution.FullName);
- IEnumerable instances = GetVisualStudioInstances();
+ IEnumerable instances = GetVisualStudioInstances();
- bool exists = instances.Any(x => x.Solution.FullName.Equals(displayName));
+ var enumerable = instances as DTE[] ?? instances.ToArray();
+ bool exists = enumerable.Any(x => x.Solution.FullName.Equals(displayName));
if (exists)
- return instances.First(x => x.Solution.FullName.Equals(displayName));
+ return enumerable.First(x => x.Solution.FullName.Equals(displayName));
return null;
}
@@ -575,33 +576,26 @@ namespace CLEngine.Editor.core
/// Retrieve every visual studio instance
///
/// List of visual studio instances
- internal static IEnumerable GetVisualStudioInstances()
+ internal static IEnumerable GetVisualStudioInstances()
{
- System.Runtime.InteropServices.ComTypes.IRunningObjectTable rot;
- System.Runtime.InteropServices.ComTypes.IEnumMoniker enumMoniker;
- int retVal = GetRunningObjectTable(0, out rot);
+ int retVal = GetRunningObjectTable(0, out var rot);
if (retVal == 0)
{
- rot.EnumRunning(out enumMoniker);
+ rot.EnumRunning(out var enumMoniker);
IntPtr fetched = IntPtr.Zero;
- System.Runtime.InteropServices.ComTypes.IMoniker[] moniker = new System.Runtime.InteropServices.ComTypes.IMoniker[1];
+ var moniker = new IMoniker[1];
while (enumMoniker.Next(1, moniker, fetched) == 0)
{
- System.Runtime.InteropServices.ComTypes.IBindCtx bindCtx;
- CreateBindCtx(0, out bindCtx);
- string displayName;
- moniker[0].GetDisplayName(bindCtx, null, out displayName);
+ CreateBindCtx(0, out var bindCtx);
+ moniker[0].GetDisplayName(bindCtx, null, out var displayName);
//Console.Info("Display Name: {0}", displayName);
bool isVisualStudio = displayName.StartsWith("!VisualStudio");
if (isVisualStudio)
{
- int currentProcessId = int.Parse(displayName.Split(':')[1]);
-
- object obj;
- rot.GetObject(moniker[0], out obj);
- var dte = obj as EnvDTE.DTE;
+ rot.GetObject(moniker[0], out var obj);
+ var dte = obj as DTE;
yield return dte;
}
}
@@ -614,29 +608,24 @@ namespace CLEngine.Editor.core
/// Visual Studio instance PID
/// Visual Studio instance if able to found. Null otherwise.
/// Whether the visual studio instance was found or not.
- internal static bool TryToRetrieveVSInstance(int processId, out EnvDTE.DTE instance)
+ internal static bool TryToRetrieveVSInstance(int processId, out DTE instance)
{
IntPtr numFetched = IntPtr.Zero;
- System.Runtime.InteropServices.ComTypes.IRunningObjectTable runningObjectTable;
- System.Runtime.InteropServices.ComTypes.IEnumMoniker monikerEnumerator;
- System.Runtime.InteropServices.ComTypes.IMoniker[] monikers = new System.Runtime.InteropServices.ComTypes.IMoniker[1];
+ var monikers = new IMoniker[1];
- GetRunningObjectTable(0, out runningObjectTable);
- runningObjectTable.EnumRunning(out monikerEnumerator);
+ GetRunningObjectTable(0, out var runningObjectTable);
+ runningObjectTable.EnumRunning(out var monikerEnumerator);
monikerEnumerator.Reset();
while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
{
- System.Runtime.InteropServices.ComTypes.IBindCtx ctx;
- CreateBindCtx(0, out ctx);
+ CreateBindCtx(0, out var ctx);
- string runningObjectName;
- monikers[0].GetDisplayName(ctx, null, out runningObjectName);
+ monikers[0].GetDisplayName(ctx, null, out var runningObjectName);
- object runningObjectVal;
- runningObjectTable.GetObject(monikers[0], out runningObjectVal);
+ runningObjectTable.GetObject(monikers[0], out var runningObjectVal);
- if (runningObjectVal is EnvDTE.DTE && runningObjectName.StartsWith("!VisualStudio"))
+ if (runningObjectVal is DTE dte && runningObjectName.StartsWith("!VisualStudio"))
{
// retrieve process id - "process_name:pid"
int currentProcessId = int.Parse(runningObjectName.Split(':')[1]);
@@ -644,7 +633,7 @@ namespace CLEngine.Editor.core
// 如果它是匹配的
if (currentProcessId == processId)
{
- instance = (EnvDTE.DTE)runningObjectVal;
+ instance = dte;
return true;
}
}
@@ -655,9 +644,9 @@ namespace CLEngine.Editor.core
}
[System.Runtime.InteropServices.DllImport("ole32.dll")]
- private static extern void CreateBindCtx(int reserved, out System.Runtime.InteropServices.ComTypes.IBindCtx ppbc);
+ private static extern void CreateBindCtx(int reserved, out IBindCtx ppbc);
[System.Runtime.InteropServices.DllImport("ole32.dll")]
- private static extern int GetRunningObjectTable(int reserved, out System.Runtime.InteropServices.ComTypes.IRunningObjectTable prot);
+ private static extern int GetRunningObjectTable(int reserved, out IRunningObjectTable prot);
}
}
\ No newline at end of file
diff --git a/CLEditor/core/EditorHandler.cs b/CLEditor/core/EditorHandler.cs
index 63b4d9f..2ec3de0 100644
--- a/CLEditor/core/EditorHandler.cs
+++ b/CLEditor/core/EditorHandler.cs
@@ -1,12 +1,8 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
-using System.Windows.Media;
-using CLEngine.Editor.controls;
using CLEngine.Editor.graphics_device;
using CLEngine.Editor.model;
using CLEngine.Editor.windows;
@@ -17,16 +13,9 @@ namespace CLEngine.Editor.core
{
public static class EditorHandler
{
- internal static Xceed.Wpf.Toolkit.PropertyGrid.PropertyGrid SelectedObjectPG = null;
+ internal static PropertyGrid SelectedObjectPG = null;
- private static ObservableCollection outputMessages = new ObservableCollection();
- public static ObservableCollection OutputMessages
- {
- get
- {
- return outputMessages;
- }
- }
+ public static ObservableCollection OutputMessages { get; } = new ObservableCollection();
private static PicturePreview picturePreview;
internal static PicturePreview PicturePreview
@@ -35,9 +24,8 @@ namespace CLEngine.Editor.core
{
if (picturePreview == null)
{
- picturePreview = new PicturePreview();
- picturePreview.ShowInTaskbar = false;
- //picturePreview.Topmost = true;
+ picturePreview = new PicturePreview {ShowInTaskbar = false};
+ //picturePreview.Topmost = true;
}
return picturePreview;
@@ -65,8 +53,7 @@ namespace CLEngine.Editor.core
{
PropertyGridContainer.Children.Clear();
- PropertyBox properties = new PropertyBox();
- properties.SelectedObject = value;
+ PropertyBox properties = new PropertyBox {SelectedObject = value};
properties.ToggleExpand();
diff --git a/CLEditor/core/EditorUtils.cs b/CLEditor/core/EditorUtils.cs
index 8f68ac2..cf00a74 100644
--- a/CLEditor/core/EditorUtils.cs
+++ b/CLEditor/core/EditorUtils.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Windows;
using System.Windows.Controls;
@@ -13,20 +14,7 @@ namespace CLEngine.Editor.core
{
public static class EditorUtils
{
- public static BitmapSource ConvertBitmapToSource96DPI(BitmapImage bitmapImage)
- {
- double dpi = 96;
- int width = bitmapImage.PixelWidth;
- int height = bitmapImage.PixelHeight;
-
- int stride = width * 4; // 4 bytes per pixel
- byte[] pixelData = new byte[stride * height];
- bitmapImage.CopyPixels(pixelData, stride, 0);
-
- return BitmapSource.Create(width, height, dpi, dpi, PixelFormats.Bgra32, null, pixelData, stride);
- }
-
- public static BitmapImage ConvertBitmapToImage96DPI(BitmapImage bitmapImage)
+ public static BitmapImage ConvertBitmapToImage96DPI(BitmapImage bitmapImage)
{
double dpi = 96;
int width = bitmapImage.PixelWidth;
@@ -54,36 +42,38 @@ namespace CLEngine.Editor.core
return bImg;
}
- internal static CMenuItem CreateMenuItem(string text, ImageSource imageSource = null)
+ public static BitmapSource ConvertBitmapToSource96DPI(BitmapImage bitmapImage)
+ {
+ double dpi = 96;
+ int width = bitmapImage.PixelWidth;
+ int height = bitmapImage.PixelHeight;
+
+ int stride = width * 4; // 4 bytes per pixel
+ byte[] pixelData = new byte[stride * height];
+ bitmapImage.CopyPixels(pixelData, stride, 0);
+
+ return BitmapSource.Create(width, height, dpi, dpi, PixelFormats.Bgra32, null, pixelData, stride);
+ }
+
+ internal static CMenuItem CreateMenuItem(string text, ImageSource imageSource = null)
{
- CMenuItem menuItem = new CMenuItem();
+ CMenuItem menuItem = new CMenuItem {Header = text};
- menuItem.Header = text;
- if (imageSource != null)
+ if (imageSource != null)
menuItem.Icon = new Image() { Source = imageSource, HorizontalAlignment = HorizontalAlignment.Center };
return menuItem;
}
- internal static StackPanel CreateHeader(string text, ImageSource imageSource)
- {
- StackPanel stackPanel = new StackPanel();
- stackPanel.Orientation = Orientation.Horizontal;
- if (imageSource != null)
- stackPanel.Children.Add(new Image() { Source = imageSource, Margin = new Thickness(0, 0, 4, 0) });
- stackPanel.Children.Add(new TextBlock() { Text = text });
-
- return stackPanel;
- }
-
internal static DependencyObject GetParent(DependencyObject obj, int levels = 1)
{
- DependencyObject result = obj, t;
+ DependencyObject result = obj;
- for (int i = 0; i < levels; i++)
+ for (int i = 0; i < levels; i++)
{
- if ((t = VisualTreeHelper.GetParent(result)) == null)
+ DependencyObject t;
+ if ((t = VisualTreeHelper.GetParent(result)) == null)
break;
result = t;
@@ -103,8 +93,7 @@ namespace CLEngine.Editor.core
while (parent != null)
{
- TObject found = parent as TObject;
- if (found != null)
+ if (parent is TObject found)
{
return found;
}
@@ -124,9 +113,9 @@ namespace CLEngine.Editor.core
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
- if (child != null && child is T)
+ if (child is T dependencyObject)
{
- yield return (T)child;
+ yield return dependencyObject;
}
foreach (T childOfChild in FindVisualChildren(child))
@@ -138,20 +127,12 @@ namespace CLEngine.Editor.core
}
- private static Dictionary installedApps = new Dictionary();
- internal static Dictionary InstalledApps
- {
- get { return installedApps; }
-
- private set { installedApps = value; }
- }
+ internal static Dictionary InstalledApps { get; } = new Dictionary();
internal static void StoreInstalledApplications()
{
- string keyName;
-
- // store: CurrentUser
- keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
+ // store: CurrentUser
+ var keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
StoreSubKey(Registry.CurrentUser, keyName);
// store: LocalMachine_32
@@ -163,25 +144,23 @@ namespace CLEngine.Editor.core
StoreSubKey(Registry.LocalMachine, keyName);
}
+ [SuppressMessage("ReSharper", "ConvertToUsingDeclaration")]
private static void StoreSubKey(RegistryKey root, string subKeyName)
{
- RegistryKey subkey;
- string displayName;
- string pathName;
-
- using (RegistryKey key = root.OpenSubKey(subKeyName))
+ using (RegistryKey key = root.OpenSubKey(subKeyName))
{
if (key != null)
{
foreach (string kn in key.GetSubKeyNames())
{
- using (subkey = key.OpenSubKey(kn))
+ RegistryKey subkey;
+ using (subkey = key.OpenSubKey(kn))
{
- displayName = (subkey.GetValue("DisplayName") as string);
- pathName = (subkey.GetValue("InstallLocation") as string);
+ var displayName = (subkey?.GetValue("DisplayName") as string);
+ var pathName = (subkey?.GetValue("InstallLocation") as string);
- if (displayName != null && displayName != string.Empty && !installedApps.ContainsKey(displayName))
- installedApps.Add(displayName, pathName);
+ if (!string.IsNullOrEmpty(displayName) && !InstalledApps.ContainsKey(displayName))
+ InstalledApps.Add(displayName, pathName);
//if (displayName != null && displayName.Replace(" ", "").ToLower().Contains(p_name.ToLower()))
//return true;
@@ -199,7 +178,7 @@ namespace CLEngine.Editor.core
///
internal static bool CheckVisualStudioExistance(string version)
{
- string src = string.Empty;
+ string src;
switch (version)
{
case "VisualStudio2015":
@@ -221,7 +200,8 @@ namespace CLEngine.Editor.core
// break;
}
- using (Microsoft.Win32.RegistryKey Key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\" + src))
+ var Key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\" + src);
+ using (Key)
if (Key != null)
{
return true;
@@ -251,8 +231,8 @@ namespace CLEngine.Editor.core
}
else
{
- double ratioX = (double)maxWidth / (double)image.Width;
- double ratioY = (double)maxHeight / (double)image.Height;
+ double ratioX = maxWidth / image.Width;
+ double ratioY = maxHeight / image.Height;
// use whichever multiplier is smaller
double ratio = ratioX < ratioY ? ratioX : ratioY;
@@ -271,14 +251,14 @@ namespace CLEngine.Editor.core
internal static void SelectAnotherElement(DependencyObject obj) where T : FrameworkElement
{
- FrameworkElement parent = (FrameworkElement)(obj as T).Parent;
- while (parent != null && parent is IInputElement && !((IInputElement)parent).Focusable)
+ FrameworkElement parent = (FrameworkElement)(obj as T)?.Parent;
+ while (parent != null && !((IInputElement)parent).Focusable)
{
parent = (FrameworkElement)parent.Parent;
}
- DependencyObject scope = FocusManager.GetFocusScope((obj as T));
- FocusManager.SetFocusedElement(scope, parent as IInputElement);
+ DependencyObject scope = FocusManager.GetFocusScope((obj as T) ?? throw new InvalidOperationException());
+ FocusManager.SetFocusedElement(scope, parent);
}
internal static bool isDirectory(string fullPath)
diff --git a/CLEditor/core/InsertionAdorner.cs b/CLEditor/core/InsertionAdorner.cs
index 4e2ed3d..f61f71d 100644
--- a/CLEditor/core/InsertionAdorner.cs
+++ b/CLEditor/core/InsertionAdorner.cs
@@ -6,11 +6,11 @@ namespace CLEngine.Editor.core
{
public class InsertionAdorner : Adorner
{
- private bool isSeparatorHorizontal;
+ private readonly bool isSeparatorHorizontal;
public bool IsInFirstHalf { get; set; }
- private AdornerLayer adornerLayer;
- private static Pen pen;
- private static PathGeometry triangle;
+ private readonly AdornerLayer adornerLayer;
+ private static readonly Pen pen;
+ private static readonly PathGeometry triangle;
// Create the pen and triangle in a static constructor and freeze them to improve performance.
static InsertionAdorner()
@@ -37,9 +37,9 @@ namespace CLEngine.Editor.core
: base(adornedElement)
{
this.isSeparatorHorizontal = isSeparatorHorizontal;
- this.IsInFirstHalf = isInFirstHalf;
+ IsInFirstHalf = isInFirstHalf;
this.adornerLayer = adornerLayer;
- this.IsHitTestVisible = false;
+ IsHitTestVisible = false;
this.adornerLayer.Add(this);
}
@@ -47,13 +47,10 @@ namespace CLEngine.Editor.core
// This draws one line and two triangles at each end of the line.
protected override void OnRender(DrawingContext drawingContext)
{
- Point startPoint;
- Point endPoint;
-
- CalculateStartAndEndPoint(out startPoint, out endPoint);
+ CalculateStartAndEndPoint(out var startPoint, out var endPoint);
drawingContext.DrawLine(pen, startPoint, endPoint);
- if (this.isSeparatorHorizontal)
+ if (isSeparatorHorizontal)
{
DrawTriangle(drawingContext, startPoint, 0);
DrawTriangle(drawingContext, endPoint, 180);
@@ -81,13 +78,13 @@ namespace CLEngine.Editor.core
startPoint = new Point();
endPoint = new Point();
- double width = this.AdornedElement.RenderSize.Width;
- double height = this.AdornedElement.RenderSize.Height;
+ double width = AdornedElement.RenderSize.Width;
+ double height = AdornedElement.RenderSize.Height;
- if (this.isSeparatorHorizontal)
+ if (isSeparatorHorizontal)
{
endPoint.X = width;
- if (!this.IsInFirstHalf)
+ if (!IsInFirstHalf)
{
startPoint.Y = height;
endPoint.Y = height;
@@ -96,7 +93,7 @@ namespace CLEngine.Editor.core
else
{
endPoint.Y = height;
- if (!this.IsInFirstHalf)
+ if (!IsInFirstHalf)
{
startPoint.X = width;
endPoint.X = width;
@@ -106,7 +103,7 @@ namespace CLEngine.Editor.core
public void Detach()
{
- this.adornerLayer.Remove(this);
+ adornerLayer.Remove(this);
}
}
}
\ No newline at end of file
diff --git a/CLEditor/core/LayoutHelper.cs b/CLEditor/core/LayoutHelper.cs
index 2faf303..360a3bc 100644
--- a/CLEditor/core/LayoutHelper.cs
+++ b/CLEditor/core/LayoutHelper.cs
@@ -11,7 +11,7 @@ namespace CLEngine.Editor.core
private const string layoutPath = @".\Layout\";
private const string layoutExtension = ".layout";
- public static string LayoutExtension { get { return layoutExtension; } }
+ public static string LayoutExtension => layoutExtension;
public static DockingManager DockManager { get; set; }
@@ -51,7 +51,7 @@ namespace CLEngine.Editor.core
{
layoutName = layoutName.Trim();
string path = layoutPath + layoutName + layoutExtension;
- if (System.IO.File.Exists(path))
+ if (File.Exists(path))
return true;
return false;
}
@@ -87,7 +87,7 @@ namespace CLEngine.Editor.core
try
{
EditorCommands.ShowOutputMessage("试图保存布局");
- var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(DockManager);
+ var serializer = new XmlLayoutSerializer(DockManager);
using (var stream = new StreamWriter(layoutPath + layoutName + LayoutExtension))
serializer.Serialize(stream);
@@ -107,9 +107,9 @@ namespace CLEngine.Editor.core
{
List Layouts = new List();
- foreach (var layout in System.IO.Directory.GetFiles(layoutPath, "*.layout"))
+ foreach (var layout in Directory.GetFiles(layoutPath, "*.layout"))
{
- string name = System.IO.Path.GetFileNameWithoutExtension(layout);
+ string name = Path.GetFileNameWithoutExtension(layout);
if (!name.Equals("Default"))
Layouts.Add(name);
}
@@ -130,7 +130,7 @@ namespace CLEngine.Editor.core
if (LayoutExists(layoutName))
try
{
- System.IO.File.Delete(layoutPath + layoutName + layoutExtension);
+ File.Delete(layoutPath + layoutName + layoutExtension);
if (Properties.Settings.Default.Layout == layoutName)
{
Properties.Settings.Default.Layout = string.Empty;
diff --git a/CLEditor/core/Page.cs b/CLEditor/core/Page.cs
index 75d8bf6..f646579 100644
--- a/CLEditor/core/Page.cs
+++ b/CLEditor/core/Page.cs
@@ -14,14 +14,14 @@
public Page()
{
- this.Subtitle = string.Empty;
- this.Description = string.Empty;
+ Subtitle = string.Empty;
+ Description = string.Empty;
}
public Page(string subtitle, string description, string picturePath)
{
- this.Subtitle = subtitle;
- this.Description = description;
- this.PicturePath = picturePath;
+ Subtitle = subtitle;
+ Description = description;
+ PicturePath = picturePath;
}
#endregion
diff --git a/CLEditor/core/TreeViewExtension.cs b/CLEditor/core/TreeViewExtension.cs
index 300cbb3..21325b0 100644
--- a/CLEditor/core/TreeViewExtension.cs
+++ b/CLEditor/core/TreeViewExtension.cs
@@ -11,18 +11,18 @@ namespace CLEngine.Editor.core
{
public class TreeViewExtension : DependencyObject
{
- public static bool GetEnableMultiSelect(DependencyObject obj)
- {
- return (bool)obj.GetValue(EnableMultiSelectProperty);
- }
-
- public static void SetEnableMultiSelect(DependencyObject obj, bool value)
+ public static void SetEnableMultiSelect(DependencyObject obj, bool value)
{
obj.SetValue(EnableMultiSelectProperty, value);
}
- // Using a DependencyProperty as the backing store for EnableMultiSelect. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty EnableMultiSelectProperty =
+ public static bool GetEnableMultiSelect(DependencyObject obj)
+ {
+ return (bool)obj.GetValue(EnableMultiSelectProperty);
+ }
+
+ // Using a DependencyProperty as the backing store for EnableMultiSelect. This enables animation, styling, binding, etc...
+ public static readonly DependencyProperty EnableMultiSelectProperty =
DependencyProperty.RegisterAttached("EnableMultiSelect", typeof(bool), typeof(TreeViewExtension), new FrameworkPropertyMetadata(false)
{
PropertyChangedCallback = EnableMultiSelectChanged,
@@ -64,15 +64,15 @@ namespace CLEngine.Editor.core
var isEnabled = (bool)args.NewValue;
if (wasEnable)
{
- tree.RemoveHandler(TreeViewItem.PreviewMouseUpEvent, new MouseButtonEventHandler(ItemClicked));
- tree.RemoveHandler(TreeViewItem.PreviewMouseDownEvent, new MouseButtonEventHandler(ItemDown));
- tree.RemoveHandler(TreeView.KeyDownEvent, new KeyEventHandler(KeyDown));
+ tree.RemoveHandler(UIElement.PreviewMouseUpEvent, new MouseButtonEventHandler(ItemClicked));
+ tree.RemoveHandler(UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler(ItemDown));
+ tree.RemoveHandler(UIElement.KeyDownEvent, new KeyEventHandler(KeyDown));
}
if (isEnabled)
{
- tree.AddHandler(TreeViewItem.PreviewMouseUpEvent, new MouseButtonEventHandler(ItemClicked));
- tree.AddHandler(TreeViewItem.PreviewMouseDownEvent, new MouseButtonEventHandler(ItemDown), true);
- tree.AddHandler(TreeView.KeyDownEvent, new KeyEventHandler(KeyDown));
+ tree.AddHandler(UIElement.PreviewMouseUpEvent, new MouseButtonEventHandler(ItemClicked));
+ tree.AddHandler(UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler(ItemDown), true);
+ tree.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(KeyDown));
}
}
@@ -87,8 +87,6 @@ namespace CLEngine.Editor.core
{
TreeViewItem item = FindTreeViewItem(e.OriginalSource);
MakeSingleSelection(GetTree(item), item);
-
- return;
}
}
@@ -132,18 +130,16 @@ namespace CLEngine.Editor.core
if (!GetIsSelected(item)) // item is already selected?
MakeSingleSelection(tree, item);
-
- return;
}
}
public static TreeView GetTree(TreeViewItem item)
{
- Func getParent = (o) => VisualTreeHelper.GetParent(o);
- FrameworkElement currentItem = item;
- while (!(getParent(currentItem) is TreeView))
- currentItem = (FrameworkElement)getParent(currentItem);
- return (TreeView)getParent(currentItem);
+ DependencyObject GetParent(DependencyObject o) => VisualTreeHelper.GetParent(o);
+ FrameworkElement currentItem = item;
+ while (!(GetParent(currentItem) is TreeView))
+ currentItem = (FrameworkElement)GetParent(currentItem);
+ return (TreeView)GetParent(currentItem);
}
static void RealSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
@@ -188,8 +184,8 @@ namespace CLEngine.Editor.core
DependencyObject dpObj = obj as DependencyObject;
if (dpObj == null)
return null;
- if (dpObj is TreeViewItem)
- return (TreeViewItem)dpObj;
+ if (dpObj is TreeViewItem item)
+ return item;
return FindTreeViewItem(VisualTreeHelper.GetParent(dpObj));
}
@@ -212,14 +208,10 @@ namespace CLEngine.Editor.core
if (GetAnchorItem(tree) == null)
{
var selectedItems = GetSelectedTreeViewItems(tree);
- if (selectedItems.Count > 0)
- {
- SetAnchorItem(tree, selectedItems[selectedItems.Count - 1]);
- }
- else
- {
- SetAnchorItem(tree, GetExpandedTreeViewItems(tree).Skip(3).FirstOrDefault());
- }
+ SetAnchorItem(tree,
+ selectedItems.Count > 0
+ ? selectedItems[selectedItems.Count - 1]
+ : GetExpandedTreeViewItems(tree).Skip(3).FirstOrDefault());
if (GetAnchorItem(tree) == null)
{
return;
@@ -230,7 +222,6 @@ namespace CLEngine.Editor.core
var items = GetExpandedTreeViewItems(tree);
bool betweenBoundary = false;
- bool end = false;
foreach (var item in items)
{
bool isBoundary = item == anchor || item == actionItem;
@@ -242,7 +233,7 @@ namespace CLEngine.Editor.core
SetIsSelected(item, true);
else
if (clearCurrent)
- SetIsSelected(item, false);
+ SetIsSelected(item, false);
else
break;
@@ -251,21 +242,16 @@ namespace CLEngine.Editor.core
public static List GetSelectedTreeViewItems(TreeView tree)
{
- return GetExpandedTreeViewItems(tree).Where(i => GetIsSelected(i)).ToList();
+ return GetExpandedTreeViewItems(tree).Where(GetIsSelected).ToList();
}
private static void MakeSingleSelection(TreeView tree, TreeViewItem item)
{
foreach (TreeViewItem selectedItem in GetExpandedTreeViewItems(tree))
{
- if (selectedItem == null)
+ if (selectedItem == null)
continue;
- if (selectedItem != item)
- SetIsSelected(selectedItem, false);
- else
- {
- SetIsSelected(selectedItem, true);
- }
+ SetIsSelected(selectedItem, selectedItem == item);
}
UpdateAnchorAndActionItem(tree, item);
}
diff --git a/CLEditor/graphics_device/SceneViewGameControl.cs b/CLEditor/graphics_device/SceneViewGameControl.cs
index 42f331c..09eeb77 100644
--- a/CLEditor/graphics_device/SceneViewGameControl.cs
+++ b/CLEditor/graphics_device/SceneViewGameControl.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
-using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using CLEngine.Editor.core;
@@ -34,10 +34,10 @@ namespace CLEngine.Editor.graphics_device
private const int HANDLER_SIZE = 24;
private const int AXIS_OFFSET = 65;
private const int AXIS_OPT_SIZE = 18;
- private bool usingYAxis = false;
- private bool usingXAxis = false;
- private bool hoverYAxis = false;
- private bool hoverXAxis = false;
+ private bool usingYAxis;
+ private bool usingXAxis;
+ private bool hoverYAxis;
+ private bool hoverXAxis;
private EditorMapModes editorMapMode = EditorMapModes.None;
private EditorModes editorMode = EditorModes.Select;
@@ -48,24 +48,24 @@ namespace CLEngine.Editor.graphics_device
private Rectangle selectionArea;
private ContentManager content;
private SpriteBatch spriteBatch;
- private bool initialized = false;
+ private bool initialized;
private BitmapFontRenderer bmFontRenderer;
private Vector2 selectionStart;
private Vector2 selectionEnd;
private Vector2 mouseLastPosition = Vector2.Zero;
- private bool takingScreenshot = false;
+ private bool takingScreenshot;
private bool lastLeftKeyState;
private float delta;
private float scrollerValue;
- private bool tilesetDragStarted = false;
+ private bool tilesetDragStarted;
private Vector2 tilesetMouseDownPos;
private Rectangle tilesetSelectedArea;
private Vector2 panStart;
private Tile[,] memTiles;
private bool objectHandled;
- private bool mouseDragStarted = false;
+ private bool mouseDragStarted;
private Dictionary objectIcons = new Dictionary();
private List sceneGameObjects = new List();
@@ -125,10 +125,10 @@ namespace CLEngine.Editor.graphics_device
set { editorMapMode = value; }
}
- private bool selectionStarted = false;
+ private bool selectionStarted;
private Vector2 panMouseLastPos;
private bool panStarted;
- private bool leftMouseKeyStateChanged = false;
+ private bool leftMouseKeyStateChanged;
public bool LeftMouseKeyPressed { get; set; }
private Vector2 mouseClickPosition = Vector2.Zero;
@@ -191,7 +191,7 @@ namespace CLEngine.Editor.graphics_device
}
}
- Vector2 controlPosition;
+ public Vector2 controlPosition;
protected override void Update(GameTime gameTime)
{
@@ -226,7 +226,7 @@ namespace CLEngine.Editor.graphics_device
if (SceneManager.ActiveScene != null)
{
- if (this.Focusable)
+ if (Focusable)
{
// Update list of gameObjects:
sceneGameObjects = GameObject.GetAllGameObjects();
@@ -242,7 +242,7 @@ namespace CLEngine.Editor.graphics_device
public void Input(GameTime gameTime)
{
- delta = (float)gameTime.ElapsedGameTime.Milliseconds;
+ delta = gameTime.ElapsedGameTime.Milliseconds;
if (GameInput.IsKeyDown(Keys.LeftShift)) delta *= 3;
//Console.Info(MousePosition.X);
@@ -435,7 +435,7 @@ namespace CLEngine.Editor.graphics_device
{
foreach (GameObject gameObject in EditorHandler.SelectedGameObjects)
{
- beforeState[gameObject] = (Transform)gameObject.Transform.DeepCopy();
+ beforeState[gameObject] = gameObject.Transform.DeepCopy();
beforeState[gameObject].GameObject = new GameObject();
}
}
@@ -675,11 +675,7 @@ namespace CLEngine.Editor.graphics_device
}
else
{
- float dx = (gameObject.Transform.Position.X - mouseWorldPosition.X) - (gameObject.Transform.Position.X - mouseClickPosition.X);
- float dy = (gameObject.Transform.Position.Y - mouseWorldPosition.Y) - (gameObject.Transform.Position.Y - mouseClickPosition.Y);
- float h = (dx * dx) + (dy * dy);
-
- gameObject.Transform.Scale = new Vector2(Math.Abs((gameObject.Transform.Position.X - mouseWorldPosition.X) * beforeState[gameObject].Scale.X / (gameObject.Transform.Position.X - mouseClickPosition.X)),
+ gameObject.Transform.Scale = new Vector2(Math.Abs((gameObject.Transform.Position.X - mouseWorldPosition.X) * beforeState[gameObject].Scale.X / (gameObject.Transform.Position.X - mouseClickPosition.X)),
Math.Abs(((gameObject.Transform.Position.Y - mouseWorldPosition.Y) * beforeState[gameObject].Scale.Y / (gameObject.Transform.Position.Y - mouseClickPosition.Y))));
}
}
@@ -821,10 +817,10 @@ namespace CLEngine.Editor.graphics_device
{
if (!tilesetDragStarted)
{
- memTiles = (EditorHandler.SelectedGameObjects[0] as Tileset).DeepCopy();
+ memTiles = (EditorHandler.SelectedGameObjects[0] as Tileset)?.DeepCopy();
}
- (EditorHandler.SelectedGameObjects[0] as Tileset).PlaceTiles(EditorHandler.TilesetBrushControl.CurrentSelectionXNA, SnapToTilesetGrid(mouseWorldPosition));
+ (EditorHandler.SelectedGameObjects[0] as Tileset)?.PlaceTiles(EditorHandler.TilesetBrushControl.CurrentSelectionXNA, SnapToTilesetGrid(mouseWorldPosition));
tilesetDragStarted = true;
}
@@ -832,7 +828,7 @@ namespace CLEngine.Editor.graphics_device
{
if (tilesetDragStarted)
{
- TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset).Tiles, memTiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
+ TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset)?.Tiles, memTiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
EditorHandler.UnDoRedo.InsertUndoRedo(tc);
tilesetDragStarted = false;
@@ -852,8 +848,8 @@ namespace CLEngine.Editor.graphics_device
{
X = tilesetSelectedArea.X,
Y = tilesetSelectedArea.Y,
- Width = tilesetSelectedArea.Width + (EditorHandler.SelectedGameObjects[0] as Tileset).TileWidth,
- Height = tilesetSelectedArea.Height + (EditorHandler.SelectedGameObjects[0] as Tileset).TileHeight
+ Width = tilesetSelectedArea.Width + ((Tileset) EditorHandler.SelectedGameObjects[0]).TileWidth,
+ Height = tilesetSelectedArea.Height + ((Tileset) EditorHandler.SelectedGameObjects[0]).TileHeight
};
}
else
@@ -868,11 +864,11 @@ namespace CLEngine.Editor.graphics_device
{
if (EditorHandler.TilesetBrushControl.CurrentSelectionXNA != Rectangle.Empty)
{
- Tile[,] _tiles = (EditorHandler.SelectedGameObjects[0] as Tileset).DeepCopy();
+ Tile[,] _tiles = (EditorHandler.SelectedGameObjects[0] as Tileset)?.DeepCopy();
- (EditorHandler.SelectedGameObjects[0] as Tileset).PlaceTiles(EditorHandler.TilesetBrushControl.CurrentSelectionXNA, tilesetSelectedArea);
+ (EditorHandler.SelectedGameObjects[0] as Tileset)?.PlaceTiles(EditorHandler.TilesetBrushControl.CurrentSelectionXNA, tilesetSelectedArea);
- TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset).Tiles, _tiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
+ TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset)?.Tiles, _tiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
EditorHandler.UnDoRedo.InsertUndoRedo(tc);
}
}
@@ -894,8 +890,8 @@ namespace CLEngine.Editor.graphics_device
{
X = tilesetSelectedArea.X,
Y = tilesetSelectedArea.Y,
- Width = tilesetSelectedArea.Width + (EditorHandler.SelectedGameObjects[0] as Tileset).TileWidth,
- Height = tilesetSelectedArea.Height + (EditorHandler.SelectedGameObjects[0] as Tileset).TileHeight
+ Width = tilesetSelectedArea.Width + ((Tileset) EditorHandler.SelectedGameObjects[0]).TileWidth,
+ Height = tilesetSelectedArea.Height + ((Tileset) EditorHandler.SelectedGameObjects[0]).TileHeight
};
}
else
@@ -908,11 +904,11 @@ namespace CLEngine.Editor.graphics_device
{
if (tilesetDragStarted)
{
- Tile[,] _tiles = (EditorHandler.SelectedGameObjects[0] as Tileset).DeepCopy();
+ Tile[,] _tiles = (EditorHandler.SelectedGameObjects[0] as Tileset)?.DeepCopy();
- (EditorHandler.SelectedGameObjects[0] as Tileset).RemoveTiles(tilesetSelectedArea);
+ (EditorHandler.SelectedGameObjects[0] as Tileset)?.RemoveTiles(tilesetSelectedArea);
- TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset).Tiles, _tiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
+ TilesetCommand tc = new TilesetCommand((EditorHandler.SelectedGameObjects[0] as Tileset)?.Tiles, _tiles, (EditorHandler.SelectedGameObjects[0] as Tileset));
EditorHandler.UnDoRedo.InsertUndoRedo(tc);
}
@@ -978,6 +974,7 @@ namespace CLEngine.Editor.graphics_device
}
}
+ [SuppressMessage("ReSharper", "LocalizableElement")]
private void GlobalInput()
{
//if (GameInput.IsKeyPressed(Keys.F6))
@@ -1001,14 +998,17 @@ namespace CLEngine.Editor.graphics_device
}
}
}
- else if (GameInput.IsKeyPressed(Keys.F9) && !takingScreenshot)
+ else lock (this)
{
- lock (this)
- {
- takingScreenshot = true;
- TakeScreenshot();
- takingScreenshot = false;
- }
+ if (GameInput.IsKeyPressed(Keys.F9) && !takingScreenshot)
+ {
+ lock (this)
+ {
+ takingScreenshot = true;
+ TakeScreenshot();
+ takingScreenshot = false;
+ }
+ }
}
if (TileSetMode)
@@ -1023,12 +1023,13 @@ namespace CLEngine.Editor.graphics_device
//if (GameInput.IsKeyPressed(Keys.F5))
// EditorCommands.DebugGame();
- if (this.Focusable)
+ if (Focusable)
{
if (GameInput.IsKeyPressed(Keys.Delete))
{
if (EditorHandler.SelectedGameObjects.Count > 0 &&
- System.Windows.Forms.MessageBox.Show("您确定要删除所选的游戏对象吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
+ MessageBox.Show("您确定要删除所选的游戏对象吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
+ DialogResult.Yes)
{
foreach (GameObject gameObject in EditorHandler.SelectedGameObjects)
{
@@ -1078,7 +1079,8 @@ namespace CLEngine.Editor.graphics_device
{
ProcessStartInfo runExplorer = new ProcessStartInfo();
runExplorer.FileName = "explorer.exe";
- runExplorer.Arguments = System.IO.Path.GetDirectoryName(path);
+ runExplorer.Arguments = Path.GetDirectoryName(path) ??
+ throw new InvalidOperationException();
Process.Start(runExplorer);
}
}
@@ -1345,9 +1347,11 @@ namespace CLEngine.Editor.graphics_device
spriteBatch.End();
}
+ [SuppressMessage("ReSharper", "PossibleLossOfFraction")]
private void DrawSceneCamera()
{
- Vector2 vertex = new Vector2(-SceneManager.GameProject.Settings.ScreenWidth / 2 + SceneManager.ActiveScene.Camera.Position.X,
+ Vector2 vertex = new Vector2(
+ -SceneManager.GameProject.Settings.ScreenWidth / 2 + SceneManager.ActiveScene.Camera.Position.X,
-SceneManager.GameProject.Settings.ScreenHeight / 2 + SceneManager.ActiveScene.Camera.Position.Y);
vertex = Vector2.Transform(vertex, SceneManager.ActiveCamera.TransformMatrix);
@@ -1360,6 +1364,7 @@ namespace CLEngine.Editor.graphics_device
Primitives.DrawBox(spriteBatch, new Rectangle((int)vertex.X, (int)vertex.Y, (int)(SceneManager.GameProject.Settings.ScreenWidth * Camera.Zoom), (int)(SceneManager.GameProject.Settings.ScreenHeight * SceneManager.ActiveCamera.Zoom)), Color.Yellow, 2);
}
+ [SuppressMessage("ReSharper", "PossibleLossOfFraction")]
private void DrawCurrentObjectHandler()
{
foreach (GameObject gameObject in EditorHandler.SelectedGameObjects)
@@ -1374,8 +1379,6 @@ namespace CLEngine.Editor.graphics_device
//Vector2.Transform(EditorHandler.SelectedGameObject.Transform.Position,SceneManager.ActiveCamera.TransformMatrix);
// 画中心箭头
- Vector2 start = new Vector2(spos.X, spos.Y - HANDLER_SIZE);
- Vector2 end = new Vector2(spos.X, spos.Y + HANDLER_SIZE);
//start = new Vector2(spos.X - HANDLER_SIZE, spos.Y);
//end = new Vector2(spos.X + HANDLER_SIZE, spos.Y);
@@ -1383,7 +1386,9 @@ namespace CLEngine.Editor.graphics_device
if (editorMode == EditorModes.Move || editorMode == EditorModes.Scale)
{
- // Y axis:
+ Vector2 end;
+ Vector2 start;
+ // Y axis:
{
start = new Vector2(spos.X, spos.Y - AXIS_OFFSET);
end = new Vector2(spos.X, spos.Y);
@@ -1391,11 +1396,13 @@ namespace CLEngine.Editor.graphics_device
if (editorMode == EditorModes.Move)
{
- start = new Vector2(spos.X - AXIS_OPT_SIZE / 2, spos.Y - AXIS_OFFSET + AXIS_OPT_SIZE / 2);
+ start = new Vector2(spos.X - 9,
+ spos.Y - AXIS_OFFSET + 9);
end = new Vector2(spos.X + 1, spos.Y - AXIS_OFFSET);
Primitives.DrawLine(spriteBatch, start, end, Color.Green, 4);
- start = new Vector2(spos.X + AXIS_OPT_SIZE / 2, spos.Y - AXIS_OFFSET + AXIS_OPT_SIZE / 2);
+ start = new Vector2(spos.X + 9,
+ spos.Y - AXIS_OFFSET + 9);
end = new Vector2(spos.X - 1, spos.Y - AXIS_OFFSET);
Primitives.DrawLine(spriteBatch, start, end, Color.Green, 4);
@@ -1438,7 +1445,7 @@ namespace CLEngine.Editor.graphics_device
if (editorMode == EditorModes.Move)
{
- start = new Vector2(spos.X + AXIS_OFFSET - AXIS_OPT_SIZE / 2, spos.Y - AXIS_OPT_SIZE / 2);
+ start = new Vector2(spos.X + AXIS_OFFSET - 9, spos.Y - 9);
end = new Vector2(spos.X + AXIS_OFFSET, spos.Y + 1);
Primitives.DrawLine(spriteBatch, start, end, Color.Red, 4);
@@ -1479,6 +1486,7 @@ namespace CLEngine.Editor.graphics_device
}
}
+ [SuppressMessage("ReSharper", "PossibleLossOfFraction")]
private void DrawObjectIcons()
{
foreach (GameObject gameObject in sceneGameObjects)
@@ -1542,6 +1550,7 @@ namespace CLEngine.Editor.graphics_device
}
+ [SuppressMessage("ReSharper", "RedundantCheckBeforeAssignment")]
internal string Screenshot(int captureWidth = 0, int captureHeight = 0)
{
RenderTarget2D renderTarget = new RenderTarget2D(
@@ -1604,7 +1613,6 @@ namespace CLEngine.Editor.graphics_device
}
if (data != null)
{
- data = null;
}
}
diff --git a/CLEditor/model/ErrorLog.cs b/CLEditor/model/ErrorLog.cs
index 9754585..4b81ee7 100644
--- a/CLEditor/model/ErrorLog.cs
+++ b/CLEditor/model/ErrorLog.cs
@@ -61,10 +61,7 @@ namespace CLEngine.Editor.model
///
public void Initialize(IEventSource eventSource)
{
- if (eventSource != null)
- {
- eventSource.ErrorRaised += ErrorRaised;
- }
+ eventSource.ErrorRaised += ErrorRaised;
}
///
/// 关闭自定义记录器
diff --git a/CLEditor/model/FileHelper.cs b/CLEditor/model/FileHelper.cs
index 0fc7590..1d741aa 100644
--- a/CLEditor/model/FileHelper.cs
+++ b/CLEditor/model/FileHelper.cs
@@ -12,7 +12,7 @@ namespace CLEngine.Editor.model
path = ResolveFilename(path);
// 创建文件或追加
- using (System.IO.FileStream fs = new System.IO.FileStream(path, FileMode.Append))
+ using (new FileStream(path, FileMode.Append))
{
}
diff --git a/CLEditor/model/ScaleCommand.cs b/CLEditor/model/ScaleCommand.cs
index 90d41f2..6bc6162 100644
--- a/CLEditor/model/ScaleCommand.cs
+++ b/CLEditor/model/ScaleCommand.cs
@@ -19,6 +19,7 @@ namespace CLEngine.Editor.model
///
///
///
+ ///
///
public ScaleCommand(Vector2 change, Vector2 before, GameObject element)
{
diff --git a/CLEditor/model/ScriptsBuilder.cs b/CLEditor/model/ScriptsBuilder.cs
index bcd0f26..ff57c8a 100644
--- a/CLEditor/model/ScriptsBuilder.cs
+++ b/CLEditor/model/ScriptsBuilder.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
using System.IO;
using System.Reflection;
using System.Xml;
@@ -12,40 +14,42 @@ namespace CLEngine.Editor.model
{
public static class ScriptsBuilder
{
- private static object locker = new object();
+ private static readonly object locker = new object();
private static ErrorLogger logger;
- public static ErrorLogger Logger { get { return logger; } }
+ public static ErrorLogger Logger => logger;
public static bool IsFileLocked(FileInfo file)
{
- FileStream stream = null;
-
- try
- {
- stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
- }
- catch (IOException)
- {
- //该文件不可用,因为它是:
- //仍然被写入
- //或由另一个线程处理
- //或者不存在(已经处理过)
- return true;
- }
- finally
- {
- if (stream != null)
- stream.Close();
- }
-
- //file is not locked
- return false;
+ FileStream stream = null;
+
+ try
+ {
+ stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
+ }
+ catch (IOException)
+ {
+ //该文件不可用,因为它是:
+ //仍然被写入
+ //或由另一个线程处理
+ //或者不存在(已经处理过)
+ return true;
+ }
+ finally
+ {
+ if (stream != null)
+ stream.Close();
+ }
+
+ //file is not locked
+ return false;
}
- ///
- ///
- ///
+ ///
+ ///
+ ///
+ [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
+ [SuppressMessage("ReSharper", "CommentTypo")]
public static bool ReloadScripts()
{
if (SceneManager.GameProject == null) return false;
@@ -60,11 +64,11 @@ namespace CLEngine.Editor.model
//搜索.sln和.csproj文件
foreach (string filename in Directory.GetFiles(SceneManager.GameProject.ProjectPath))
{
- if (System.IO.Path.GetExtension(filename).ToLower().Equals(".csproj"))
+ if (Path.GetExtension(filename).ToLower().Equals(".csproj"))
{
UserPreferences.Instance.ProjectCsProjFilePath = filename;
}
- else if (System.IO.Path.GetExtension(filename).ToLower().Equals(".sln"))
+ else if (Path.GetExtension(filename).ToLower().Equals(".sln"))
{
UserPreferences.Instance.ProjectSlnFilePath = filename;
}
@@ -78,15 +82,15 @@ namespace CLEngine.Editor.model
doc.Load(projectFileName);
while (doc.GetElementsByTagName("ItemGroup").Count < 2)
- doc.GetElementsByTagName("Project").Item(0).AppendChild(doc.CreateElement("ItemGroup"));
+ doc.GetElementsByTagName("Project").Item(0)?.AppendChild(doc.CreateElement("ItemGroup"));
- foreach (XmlNode _node in doc.GetElementsByTagName("ItemGroup").Item(1).ChildNodes)
+ foreach (XmlNode _node in doc.GetElementsByTagName("ItemGroup").Item(1)?.ChildNodes)
{
if (_node.Name.ToLower().Equals("compile"))
{
- if (!File.Exists(SceneManager.GameProject.ProjectPath + "\\" + _node.Attributes.GetNamedItem("Include").Value))
+ if (_node.Attributes != null && !File.Exists(SceneManager.GameProject.ProjectPath + "\\" + _node.Attributes.GetNamedItem("Include").Value))
{
- doc.GetElementsByTagName("ItemGroup").Item(1).RemoveChild(_node);
+ doc.GetElementsByTagName("ItemGroup").Item(1)?.RemoveChild(_node);
removed = true;
}
}
@@ -96,9 +100,8 @@ namespace CLEngine.Editor.model
doc.Save(projectFileName);
string tmpProjectFileName = SceneManager.GameProject.ProjectPath + @"\_Scripts.csproj";
- string hash = string.Empty;
- hash = CHelper.EncryptMD5(DateTime.Now.ToString());
+ var hash = CHelper.EncryptMD5(DateTime.Now.ToString(CultureInfo.InvariantCulture));
//try
//{
@@ -115,21 +118,22 @@ namespace CLEngine.Editor.model
/* Compile project */
ProjectCollection projectCollection = new ProjectCollection();
- Dictionary GlobalProperty = new Dictionary();
- GlobalProperty.Add("Configuration", SceneManager.GameProject.Debug ? "Debug" : "Release");
- GlobalProperty.Add("Platform", "x86");
+ Dictionary GlobalProperty = new Dictionary
+ {
+ {"Configuration", SceneManager.GameProject.Debug ? "Debug" : "Release"}, {"Platform", "x86"}
+ };
//FileLogger logger = new FileLogger() { Parameters = @"logfile=C:\clengine_log.txt" };
logger = new ErrorLogger();
- BuildRequestData buildRequest = new BuildRequestData(tmpProjectFileName, GlobalProperty, null, new string[] { "Build" }, null);
- BuildResult buildResult = BuildManager.DefaultBuildManager.Build(
- new BuildParameters(projectCollection)
- {
- BuildThreadPriority = System.Threading.ThreadPriority.AboveNormal,
- Loggers = new List() { logger }
- },
- buildRequest);
+ BuildRequestData buildRequest = new BuildRequestData(tmpProjectFileName, GlobalProperty, null, new[] { "Build" }, null);
+ BuildManager.DefaultBuildManager.Build(
+ new BuildParameters(projectCollection)
+ {
+ BuildThreadPriority = System.Threading.ThreadPriority.AboveNormal,
+ Loggers = new List() { logger }
+ },
+ buildRequest);
//foreach (var tr in logger.Errors)
//{
diff --git a/CLEditor/model/TilesetCommand.cs b/CLEditor/model/TilesetCommand.cs
index 2f0e2d1..62e6f8a 100644
--- a/CLEditor/model/TilesetCommand.cs
+++ b/CLEditor/model/TilesetCommand.cs
@@ -1,5 +1,4 @@
-using System;
-using CLEngine.Core;
+using CLEngine.Core;
namespace CLEngine.Editor.model
{
diff --git a/CLEditor/model/commands/MoveCommand.cs b/CLEditor/model/commands/MoveCommand.cs
index 7fb07ca..054a4c1 100644
--- a/CLEditor/model/commands/MoveCommand.cs
+++ b/CLEditor/model/commands/MoveCommand.cs
@@ -19,6 +19,7 @@ namespace CLEngine.Editor.model.commands
///
///
///
+ ///
///
public MoveCommand(Vector2 change, Vector2 before, GameObject element)
{
diff --git a/CLEditor/model/commands/RotateCommand.cs b/CLEditor/model/commands/RotateCommand.cs
index 2e41f7e..81b334d 100644
--- a/CLEditor/model/commands/RotateCommand.cs
+++ b/CLEditor/model/commands/RotateCommand.cs
@@ -18,6 +18,7 @@ namespace CLEngine.Editor.model.commands
///
///
///
+ ///
///
public RotateCommand(float change, float before, GameObject element)
{
diff --git a/CLEditor/viewmodel/ButtonVisibilityViewModel.cs b/CLEditor/viewmodel/ButtonVisibilityViewModel.cs
index 1bcfbd1..4c25e29 100644
--- a/CLEditor/viewmodel/ButtonVisibilityViewModel.cs
+++ b/CLEditor/viewmodel/ButtonVisibilityViewModel.cs
@@ -26,7 +26,6 @@ namespace CLEngine.Editor.viewmodel
bar.MaximizeVisibility = Visibility.Visible;
bar.MaximizeVisibility = Visibility.Visible;
break;
- case ResizeMode.NoResize:
default:
bar.MaximizeVisibility = Visibility.Collapsed;
bar.MinimizeVisibility = Visibility.Collapsed;
diff --git a/Engine/CLEngine.Core/Audio.cs b/Engine/CLEngine.Core/Audio.cs
index 56f53ba..55f2a7d 100644
--- a/Engine/CLEngine.Core/Audio.cs
+++ b/Engine/CLEngine.Core/Audio.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
-using CLEngine.Core;
using NAudio.Wave;
+// ReSharper disable All
namespace CLEngine.Core
{
@@ -11,12 +11,15 @@ namespace CLEngine.Core
public long LastPosition { get; set; }
}
+ ///
+ ///
+ ///
public static class Audio
{
#region fields
- private static bool initialized = false;
- private static int bufferCount = 0;
+ private static bool initialized;
+ private static int bufferCount;
#if WIN
private static IWavePlayer waveOutDevice;
@@ -46,8 +49,7 @@ namespace CLEngine.Core
}
catch (Exception driverCreateException)
{
- Console.WriteLine(String.Format("{0}", driverCreateException.Message));
- return;
+ Console.WriteLine($"{driverCreateException.Message}");
}
#endif
}
@@ -114,7 +116,6 @@ namespace CLEngine.Core
///
///
///
- ///
public static void PlayFromBuffer(int key)
{
#if WIN
@@ -136,6 +137,10 @@ namespace CLEngine.Core
}
#endif
+ ///
+ ///
+ ///
+ ///
public static void StopFromBuffer(int key)
{
#if WIN
@@ -153,6 +158,10 @@ namespace CLEngine.Core
}
#endif
+ ///
+ ///
+ ///
+ ///
public static void PauseFromBuffer(int key)
{
#if WIN
diff --git a/WebPage/index.html b/WebPage/index.html
new file mode 100644
index 0000000..f3a3794
--- /dev/null
+++ b/WebPage/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ CLEngine首页
+
+
+
+
+
+ 当前任务
+ 更新4038版本
+
+
+
+
+
+
+
+
+
\ No newline at end of file
--
Gitee
From dd4f192fc931c41c94369ad03d3e1328a1a237d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com>
Date: Tue, 23 Jul 2019 16:21:14 +0800
Subject: [PATCH 02/13] =?UTF-8?q?=E5=B0=8F=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/framework/EventObject.cs | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/Engine/CLEngine.Core/framework/EventObject.cs b/Engine/CLEngine.Core/framework/EventObject.cs
index 988ac0a..a5c8508 100644
--- a/Engine/CLEngine.Core/framework/EventObject.cs
+++ b/Engine/CLEngine.Core/framework/EventObject.cs
@@ -30,6 +30,33 @@ namespace CLEngine.Core.framework
[DataMember] private Dictionary _state;
[DataMember] private SkillObject _onSkill;
+ ///
+ /// 触发使用技能事件,处理
+ ///
+ ///
+ public void UseSkill(string name){
+ var skill = _skill[name];
+ if(skill==null){
+ Console.WriteLine("技能"+name+"不存在");
+ return;
+ }
+ if(skill.CurrentTime>0){
+ Console.WriteLine("技能"+name+"冷却时间未到");
+ return;
+ }
+ if(_mp
/// 添加技能
///
--
Gitee
From 033c4220e7a7cca706ecbe26ee188cf1d82f77db Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Tue, 23 Jul 2019 17:37:10 +0800
Subject: [PATCH 03/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B8=B8=E6=88=8F?=
=?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/CLEngine.Core.csproj | 3 +
Engine/CLEngine.Core/framework/EventObject.cs | 35 +++++++---
Engine/CLEngine.Core/framework/GameEvent.cs | 66 +++++++++++++++++++
Engine/CLEngine.Core/framework/SkillObject.cs | 56 ++++++++++++++--
Engine/CLEngine.Core/gui/Core/Stage.cs | 49 +++++++-------
.../gui/Core/Text/IInputHandler.cs | 18 -----
Engine/CLEngine.Core/packages.config | 1 +
Game/Game.Desktop/MainGame.cs | 2 +-
8 files changed, 170 insertions(+), 60 deletions(-)
create mode 100644 Engine/CLEngine.Core/framework/GameEvent.cs
delete mode 100644 Engine/CLEngine.Core/gui/Core/Text/IInputHandler.cs
diff --git a/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index 95e34c7..8bd7409 100644
--- a/Engine/CLEngine.Core/CLEngine.Core.csproj
+++ b/Engine/CLEngine.Core/CLEngine.Core.csproj
@@ -70,6 +70,9 @@
False
..\..\packages\Lidgren.Network.1.0.2\lib\net451\Lidgren.Network.dll
+
+ ..\..\packages\MonoGame.IMEHelper.DesktopGL.0.1.0\lib\net45\MonoGame.IMEHelper.dll
+
False
.\NAudio.dll
diff --git a/Engine/CLEngine.Core/framework/EventObject.cs b/Engine/CLEngine.Core/framework/EventObject.cs
index a5c8508..4ac808c 100644
--- a/Engine/CLEngine.Core/framework/EventObject.cs
+++ b/Engine/CLEngine.Core/framework/EventObject.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
namespace CLEngine.Core.framework
@@ -11,6 +12,9 @@ namespace CLEngine.Core.framework
[Serializable]
#endif
[DataContract]
+ [SuppressMessage("ReSharper", "UnusedMember.Local")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class EventObject : GameObject
{
[DataMember] private string _name;
@@ -34,24 +38,35 @@ namespace CLEngine.Core.framework
/// 触发使用技能事件,处理
///
///
- public void UseSkill(string name){
+ public void UseSkill(string name)
+ {
var skill = _skill[name];
- if(skill==null){
- Console.WriteLine("技能"+name+"不存在");
+
+ if (skill == null)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.NotFound));
return;
}
- if(skill.CurrentTime>0){
- Console.WriteLine("技能"+name+"冷却时间未到");
+ if (skill.CurrentTime > 0)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.Cd));
return;
}
- if(_mp
/// 事件名
///
- public string Name { get { return _name; } set { _name = value; } }
+ public new string Name { get { return _name; } set { _name = value; } }
///
/// 绑定的物品
///
diff --git a/Engine/CLEngine.Core/framework/GameEvent.cs b/Engine/CLEngine.Core/framework/GameEvent.cs
new file mode 100644
index 0000000..8b32f97
--- /dev/null
+++ b/Engine/CLEngine.Core/framework/GameEvent.cs
@@ -0,0 +1,66 @@
+using System;
+
+namespace CLEngine.Core.framework
+{
+ ///
+ /// 技能事件类型
+ ///
+ public enum SkillEventType
+ {
+ ///
+ /// 普通事件
+ ///
+ None,
+ ///
+ /// 未找到技能
+ ///
+ NotFound,
+ ///
+ /// 冷却事件
+ ///
+ Cd,
+ ///
+ /// 无法力
+ ///
+ NoMp,
+ ///
+ /// 无生命值
+ ///
+ NoHp,
+ }
+
+ ///
+ /// 技能使用事件
+ ///
+ public class SkillUseEventArgs : EventArgs
+ {
+ ///
+ /// 技能名称
+ ///
+ public string name;
+ ///
+ /// 技能事件类型
+ ///
+ public SkillEventType type;
+
+ ///
+ ///
+ ///
+ public SkillUseEventArgs(string name, SkillEventType type = SkillEventType.None)
+ {
+ this.name = name;
+ this.type = type;
+ }
+ }
+
+ ///
+ /// 游戏事件类
+ ///
+ public class GameEvent
+ {
+ ///
+ /// 使用技能事件
+ ///
+ public static EventHandler UseSkill;
+ }
+}
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/framework/SkillObject.cs b/Engine/CLEngine.Core/framework/SkillObject.cs
index b2b1834..31cbd89 100644
--- a/Engine/CLEngine.Core/framework/SkillObject.cs
+++ b/Engine/CLEngine.Core/framework/SkillObject.cs
@@ -1,27 +1,49 @@
using FairyGUI;
using Microsoft.Xna.Framework.Graphics;
using System;
-using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
-using System.Linq;
using System.Runtime.Serialization;
-using System.Text;
-using System.Threading.Tasks;
namespace CLEngine.Core.framework
{
+ ///
+ ///
+ ///
#if WIN
[Serializable]
#endif
[DataContract]
public class SkillEventArgs : EventArgs
{
+ ///
+ ///
+ ///
public int userId;
+ ///
+ /// 技能是否可以使用
+ ///
+ public bool canUse;
+
+ ///
+ ///
+ ///
+ ///
public SkillEventArgs(int id)
{
userId = id;
}
}
+
+ ///
+ ///
+ ///
+#if WIN
+ [Serializable]
+#endif
+ [DataContract]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class SkillObject
{
///
@@ -40,7 +62,7 @@ namespace CLEngine.Core.framework
[DataMember] private string _name;
[DataMember] private string _iconPath;
[DataMember] private float _coolingTime;
- [DataMember] private float _currentTime = 0;
+ [DataMember] private float _currentTime;
[DataMember] private int _useHp;
[DataMember] private int _useMp;
[DataMember] private string _description;
@@ -151,7 +173,13 @@ namespace CLEngine.Core.framework
///
public enum SkillType
{
+ ///
+ ///
+ ///
Consumable,
+ ///
+ ///
+ ///
Bullet
}
///
@@ -159,8 +187,17 @@ namespace CLEngine.Core.framework
///
public enum TargetType
{
+ ///
+ ///
+ ///
Self,
+ ///
+ ///
+ ///
Enemy,
+ ///
+ ///
+ ///
Friendly
}
///
@@ -168,8 +205,17 @@ namespace CLEngine.Core.framework
///
public enum ReleasePosition
{
+ ///
+ ///
+ ///
Self,
+ ///
+ ///
+ ///
Target,
+ ///
+ ///
+ ///
Mouse
}
///
diff --git a/Engine/CLEngine.Core/gui/Core/Stage.cs b/Engine/CLEngine.Core/gui/Core/Stage.cs
index ec007de..89b3622 100644
--- a/Engine/CLEngine.Core/gui/Core/Stage.cs
+++ b/Engine/CLEngine.Core/gui/Core/Stage.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input;
+using MonoGame.IMEHelper;
namespace FairyGUI
{
@@ -13,6 +13,9 @@ namespace FairyGUI
///
public class Stage : Container, IGameComponent, IDrawable, IUpdateable
{
+ ///
+ ///
+ ///
public static Game game;
///
@@ -69,22 +72,29 @@ namespace FairyGUI
get { return false; }
}
- public IInputHandler _wic { get; }
+ ///
+ ///
+ ///
+ public static IMEHandler imeHandler;
+ ///
+ ///
+ ///
+ public static bool showIMEWin = true;
+
+ ///
+ ///
+ ///
public static readonly char[] SPECIAL_CHARACTERS = { '\a', '\b', '\n', '\r', '\f', '\t', '\v' };
///
///
///
- public Stage(Game game, IInputHandler handler)
+ public Stage(Game game)
{
_inst = this;
- _wic = handler;
Stage.game = game;
- if (handler == null)
- game.Window.TextInput += WindowOnTextInput;
-
soundVolume = 1;
_batch = new FairyBatch();
@@ -98,15 +108,19 @@ namespace FairyGUI
_rollOverChain = new List();
_focusRemovedDelegate = OnFocusRemoved;
+
+ imeHandler = IMEHandler.Create(game, showIMEWin);
+ imeHandler.TextInput += ImeHandlerOnTextInput;
+ // TextComposition事件仅适用于WindowsDX平台 我们默认不使用它
+ // imeHandler.TextComposition += (sender, args) => { };
}
- private void WindowOnTextInput(object sender, TextInputEventArgs e)
+ private void ImeHandlerOnTextInput(object sender, MonoGame.IMEHelper.TextInputEventArgs e)
{
if (!SPECIAL_CHARACTERS.Contains(e.Character))
{
IMEAdapter.compositionString += e.Character;
}
-
}
@@ -678,7 +692,6 @@ namespace FairyGUI
Timers.inst.Update(gameTime);
TweenManager.Update(gameTime);
- HandleInputCapturer();
HandleKeyEvents();
HandleMouseEvents();
if (_focused is InputTextField)
@@ -704,22 +717,6 @@ namespace FairyGUI
afterUpdate = null;
}
- public void HandleInputCapturer()
- {
- if (_wic == null)
- return;
-
- var getChars = _wic.myCharacters;
- foreach (var character in getChars)
- {
- if (!character.IsUsed && character.CharacterType == 0)
- {
- IMEAdapter.compositionString += character.Chars;
- character.IsUsed = true;
- }
- }
- }
-
///
///
///
diff --git a/Engine/CLEngine.Core/gui/Core/Text/IInputHandler.cs b/Engine/CLEngine.Core/gui/Core/Text/IInputHandler.cs
deleted file mode 100644
index 435d19b..0000000
--- a/Engine/CLEngine.Core/gui/Core/Text/IInputHandler.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Collections.Generic;
-
-namespace FairyGUI
-{
- public interface IInputHandler
- {
- List myCharacters { get; set; }
- }
-
- public interface ICharacter
- {
- bool IsUsed { get; set; }
-
- int CharacterType { get; set; }
-
- char Chars { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/packages.config b/Engine/CLEngine.Core/packages.config
index 6069e76..06b62c1 100644
--- a/Engine/CLEngine.Core/packages.config
+++ b/Engine/CLEngine.Core/packages.config
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/Game/Game.Desktop/MainGame.cs b/Game/Game.Desktop/MainGame.cs
index e0e7936..503a615 100644
--- a/Game/Game.Desktop/MainGame.cs
+++ b/Game/Game.Desktop/MainGame.cs
@@ -72,7 +72,7 @@ namespace game_win
Window.Title = SceneManager.GameProject.ProjectName;
originalTitle = SceneManager.GameProject.ProjectName;
- Components.Add(new Stage(this, null));
+ Components.Add(new Stage(this));
base.Initialize();
}
--
Gitee
From 9ed281f0cb6ce2b78a0f79bc7aa0f7d9a9fb0ca5 Mon Sep 17 00:00:00 2001
From: YHH <359807859@qq.com>
Date: Wed, 24 Jul 2019 08:05:06 +0800
Subject: [PATCH 04/13] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A7=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/CLEngine.Core.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index 8bd7409..b63b5a8 100644
--- a/Engine/CLEngine.Core/CLEngine.Core.csproj
+++ b/Engine/CLEngine.Core/CLEngine.Core.csproj
@@ -299,6 +299,7 @@
+
@@ -352,7 +353,6 @@
-
--
Gitee
From 2e20fa819a8ceebac42533fca070fb03ec99ffe1 Mon Sep 17 00:00:00 2001
From: YHH <359807859@qq.com>
Date: Wed, 24 Jul 2019 08:19:06 +0800
Subject: [PATCH 05/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E5=8D=A0=E7=94=A8=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/core/converts/EditorImageConvert.cs | 31 ++++++++++++++++++--
Engine/CLEngine.Core/network/ServerList.cs | 9 ------
2 files changed, 28 insertions(+), 12 deletions(-)
delete mode 100644 Engine/CLEngine.Core/network/ServerList.cs
diff --git a/CLEditor/core/converts/EditorImageConvert.cs b/CLEditor/core/converts/EditorImageConvert.cs
index 594f72a..5732ed8 100644
--- a/CLEditor/core/converts/EditorImageConvert.cs
+++ b/CLEditor/core/converts/EditorImageConvert.cs
@@ -18,13 +18,38 @@ namespace CLEngine.Editor.core.converts
{
// 先转绝对路径
var relativePath = Path.Combine(SceneManager.GameProject.ProjectPath, path);
- return new BitmapImage(new Uri(relativePath, UriKind.Absolute));
- }
+
+ return InitImage(relativePath);
+ }
return null;
}
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ ///
+ /// 解决不同进程读取同一张图片的问题
+ ///
+ ///
+ ///
+ private BitmapImage InitImage(string filePath)
+ {
+ BitmapImage bitmapImage;
+ using (var reader = new BinaryReader(File.Open(filePath, FileMode.Open)))
+ {
+ var fi = new FileInfo(filePath);
+ byte[] bytes = reader.ReadBytes((int)fi.Length);
+ reader.Close();
+
+ bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.StreamSource = new MemoryStream(bytes);
+ bitmapImage.EndInit();
+ bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
+ reader.Dispose();
+ }
+ return bitmapImage;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
diff --git a/Engine/CLEngine.Core/network/ServerList.cs b/Engine/CLEngine.Core/network/ServerList.cs
deleted file mode 100644
index 2b86d3c..0000000
--- a/Engine/CLEngine.Core/network/ServerList.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace CLEngine.Core.network
-{
- [Serializable]
- public class ServerList
- {
- }
-}
\ No newline at end of file
--
Gitee
From b4cd38ec718a05e3232cebdeac65c1449960a205 Mon Sep 17 00:00:00 2001
From: YHH <359807859@qq.com>
Date: Wed, 24 Jul 2019 08:20:06 +0800
Subject: [PATCH 06/13] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/CLEngine.Core.csproj | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index b63b5a8..330d10b 100644
--- a/Engine/CLEngine.Core/CLEngine.Core.csproj
+++ b/Engine/CLEngine.Core/CLEngine.Core.csproj
@@ -456,7 +456,6 @@
-
@@ -611,6 +610,8 @@
-
+
+
+
\ No newline at end of file
--
Gitee
From e2d7d235919bce45fb5eb5bab82e736bf71e4f7c Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Wed, 24 Jul 2019 10:36:40 +0800
Subject: [PATCH 07/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E9=A2=98?=
=?UTF-8?q?=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/CLEngine.Editor.csproj | 1 +
CLEditor/core/EditorUtils.cs | 13 +-
CLEditor/theme/IgniteDark.xaml | 2593 ++++++++++++++++-
.../theme/LeftMarginMultiplierConverter.cs | 28 +
CLEditor/viewmodel/DataBaseViewModel.cs | 8 +-
Engine/CLEngine.Core/CLEngine.Core.csproj | 2 +-
6 files changed, 2615 insertions(+), 30 deletions(-)
create mode 100644 CLEditor/theme/LeftMarginMultiplierConverter.cs
diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj
index 1063f37..113f1ba 100644
--- a/CLEditor/CLEngine.Editor.csproj
+++ b/CLEditor/CLEngine.Editor.csproj
@@ -433,6 +433,7 @@
NodeScriptWindow.xaml
+
diff --git a/CLEditor/core/EditorUtils.cs b/CLEditor/core/EditorUtils.cs
index cf00a74..58ec46a 100644
--- a/CLEditor/core/EditorUtils.cs
+++ b/CLEditor/core/EditorUtils.cs
@@ -42,7 +42,18 @@ namespace CLEngine.Editor.core
return bImg;
}
- public static BitmapSource ConvertBitmapToSource96DPI(BitmapImage bitmapImage)
+ internal static StackPanel CreateHeader(string text, ImageSource imageSource)
+ {
+ StackPanel stackPanel = new StackPanel();
+ stackPanel.Orientation = Orientation.Horizontal;
+ if (imageSource != null)
+ stackPanel.Children.Add(new Image() { Source = imageSource, Margin = new Thickness(0, 0, 4, 0) });
+ stackPanel.Children.Add(new TextBlock() { Text = text });
+
+ return stackPanel;
+ }
+
+ public static BitmapSource ConvertBitmapToSource96DPI(BitmapImage bitmapImage)
{
double dpi = 96;
int width = bitmapImage.PixelWidth;
diff --git a/CLEditor/theme/IgniteDark.xaml b/CLEditor/theme/IgniteDark.xaml
index d7654c7..aa4e9af 100644
--- a/CLEditor/theme/IgniteDark.xaml
+++ b/CLEditor/theme/IgniteDark.xaml
@@ -93,16 +93,129 @@
+ #444444
+ #333333
+ #595959
+ #3D3D3D
+ #424242
+ #666666
+ #EFEFEF
+
+ #BDBDBD
+ #525252
+
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ M-0.7,5.2 L-2.2,6.7 3.6,12.6 9.5,6.7 8,5.2 3.6,9.6 z
+ M-2.2,10.9 L-0.7,12.4 3.7,8 8,12.4 9.5,10.9 3.7,5 z
+ M1.0E-41,4.2 L0,2.1 2.5,4.5 6.7,4.4E-47 6.7,2.3 2.5,6.7 z
+ M7.2,5 L5.5,7.16 4.16,6.3 3.5,6.7 5.5,8.4 8.6,5.25 C8.6,5.25 8,4.7 7.22,5
+ M 0,0 L 4,3.5 L 0,7 Z
+ M 1,1.5 L 4.5,5 L 8,1.5
+ M 1,4.5 L 4.5,1 L 8,4.5
+ M6.5,2.6C4.767,0.973 2.509,0 0,0 0,0 0,19 0,19L23,19z
+ M3.5445026,0 L7.0890052,7.0890053 L3.0459049E-09,7.0890053 z
+ M-0,6 L-0,8 8,8 8,-0 6,-0 6,6 z
+ M5,-0 L9,5 1,5 z
@@ -149,7 +262,8 @@
-
+
+
@@ -1322,7 +1436,7 @@
-
+ -->
@@ -1584,7 +1698,9 @@
-
+
@@ -1598,29 +1714,13 @@
-
-
-
-
-
-
-
-
-
+
@@ -3041,8 +3141,6 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLEditor/theme/LeftMarginMultiplierConverter.cs b/CLEditor/theme/LeftMarginMultiplierConverter.cs
new file mode 100644
index 0000000..df6ab49
--- /dev/null
+++ b/CLEditor/theme/LeftMarginMultiplierConverter.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using CLEngine.Editor.core;
+
+namespace CLEngine.Editor.theme
+{
+ public class LeftMarginMultiplierConverter : IValueConverter
+ {
+ public double Length { get; set; }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ var item = value as TreeViewItem;
+ if (item == null)
+ return new Thickness(0);
+
+ return new Thickness(Length * item.GetDepth(), 0, 0, 0);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new System.NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 4f1c4b1..857297f 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -195,8 +195,12 @@ namespace CLEngine.Editor.viewmodel
///
///
public void ClearItemChildTypes(object value)
- {
- ItemChildTypes.Clear();
+ {
+ ItemChildTypes.Clear();
+
+ if (value == null)
+ return;
+
foreach (var itemType in FrameworkSettings.ItemTypes[value.ToString()])
ItemChildTypes.Add(itemType);
}
diff --git a/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index 8bd7409..b63b5a8 100644
--- a/Engine/CLEngine.Core/CLEngine.Core.csproj
+++ b/Engine/CLEngine.Core/CLEngine.Core.csproj
@@ -299,6 +299,7 @@
+
@@ -352,7 +353,6 @@
-
--
Gitee
From a858c9ef37c07e17289896dfbed3f0ba4709c0fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com>
Date: Wed, 24 Jul 2019 13:26:41 +0800
Subject: [PATCH 08/13] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=BC=80=E5=A4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/windows/DataBaseWindow.xaml | 12 +++++++-----
CLEditor/windows/DataBaseWindow.xaml.cs | 17 ++++++++++++++++-
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index a757d1a..1025e9d 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -79,12 +79,14 @@
-
-
-
-
+
+
+
+
+
+
-
+
diff --git a/CLEditor/windows/DataBaseWindow.xaml.cs b/CLEditor/windows/DataBaseWindow.xaml.cs
index b92d9a7..e87d509 100644
--- a/CLEditor/windows/DataBaseWindow.xaml.cs
+++ b/CLEditor/windows/DataBaseWindow.xaml.cs
@@ -1,5 +1,7 @@
-using System.Windows;
+using System.IO;
+using System.Windows;
using System.Windows.Controls;
+using CLEngine.Core;
using CLEngine.Core.framework;
using CLEngine.Editor.viewmodel;
@@ -43,5 +45,18 @@ namespace CLEngine.Editor.windows
{
(DataContext as DataBaseViewModel)?.ClearItemChildTypes(ClassificationComboBox.SelectedValue);
}
+ ///
+ /// 创建脚本
+ ///
+ private void CreateScript(){
+ string FileName = FileNameInput.Text;
+ string path = System.IO.Path.Combine(SceneManager.GameProject.ProjectPath,"\\\\Scripts\\\\");
+ string ScriptName = System.IO.Path.Combine(path, FileName);
+ if(!File.Exists(ScriptName)){
+ using(var sw=new StreamWriter(ScriptName)){
+
+ }
+ }
+ }
}
}
--
Gitee
From d60aba65a5eb5fadef95b494e87d47e7225d237a Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Wed, 24 Jul 2019 17:36:26 +0800
Subject: [PATCH 09/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?=
=?UTF-8?q?=E4=B9=89=E7=95=8C=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/CLEngine.Editor.csproj | 7 +
CLEditor/viewmodel/DataBaseViewModel.cs | 19 ++-
CLEditor/windows/CustomPropWindow.xaml | 16 +++
CLEditor/windows/CustomPropWindow.xaml.cs | 27 ++++
CLEditor/windows/DataBaseWindow.xaml | 152 +++++++++++-----------
5 files changed, 145 insertions(+), 76 deletions(-)
create mode 100644 CLEditor/windows/CustomPropWindow.xaml
create mode 100644 CLEditor/windows/CustomPropWindow.xaml.cs
diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj
index 113f1ba..e8ce653 100644
--- a/CLEditor/CLEngine.Editor.csproj
+++ b/CLEditor/CLEngine.Editor.csproj
@@ -447,6 +447,9 @@
CreateMapWindow.xaml
+
+ CustomPropWindow.xaml
+
DataBaseWindow.xaml
@@ -561,6 +564,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 857297f..b49bd0a 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -25,6 +25,10 @@ namespace CLEngine.Editor.viewmodel
/// 添加物品命令
///
public RelayCommand AddItemCommand { get; set; }
+ ///
+ /// 删除物品命令
+ ///
+ public RelayCommand RemoveItemCommand { get; set; }
///
/// 性别列表
///
@@ -63,6 +67,7 @@ namespace CLEngine.Editor.viewmodel
/// 保存数据按钮
///
public RelayCommand SaveCommand { get; set; }
+ public RelayCommand TestCustom { get; set; }
private string _iconPath;
@@ -99,7 +104,19 @@ namespace CLEngine.Editor.viewmodel
BagBrowserCommand = new RelayCommand(BagBrowserAction);
DropBrowserCommand = new RelayCommand(DropBrowserAction);
SaveCommand = new RelayCommand(SaveAction);
- }
+ RemoveItemCommand = new RelayCommand(RemoveItemAction);
+
+ }
+
+ private void RemoveItemAction()
+ {
+ var itemList = DataBaseWindow.ItemListInstance;
+ if (itemList.SelectedValue is ItemObject item)
+ {
+ ItemManager.RemoveItem(item);
+ ItemObjects.Remove(item);
+ }
+ }
private ObservableCollection GetItemObjects()
{
diff --git a/CLEditor/windows/CustomPropWindow.xaml b/CLEditor/windows/CustomPropWindow.xaml
new file mode 100644
index 0000000..e2eaf75
--- /dev/null
+++ b/CLEditor/windows/CustomPropWindow.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
diff --git a/CLEditor/windows/CustomPropWindow.xaml.cs b/CLEditor/windows/CustomPropWindow.xaml.cs
new file mode 100644
index 0000000..a461e78
--- /dev/null
+++ b/CLEditor/windows/CustomPropWindow.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace CLEngine.Editor.windows
+{
+ ///
+ /// CustomPropWindow.xaml 的交互逻辑
+ ///
+ public partial class CustomPropWindow : Window
+ {
+ public CustomPropWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index a757d1a..8079201 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -19,88 +19,90 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
--
Gitee
From 07b191c03179e85e7cee497cec031d0169d6152d Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Wed, 24 Jul 2019 18:32:17 +0800
Subject: [PATCH 10/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/windows/DataBaseWindow.xaml | 50 ++++++++++++++--------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index 20758d2..a88d79e 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -27,31 +27,31 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--
Gitee
From c34129441766a65737ff1a160893de37ea84d080 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com>
Date: Thu, 25 Jul 2019 07:55:06 +0800
Subject: [PATCH 11/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=84=9A=E6=9C=AC?=
=?UTF-8?q?=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/framework/ItemObject.cs | 5 +++++
Engine/CLEngine.Core/framework/SkillObject.cs | 6 ++++++
Engine/CLEngine.Core/framework/StateObject.cs | 5 +++++
3 files changed, 16 insertions(+)
diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs
index 52d15b1..f7ec76a 100644
--- a/Engine/CLEngine.Core/framework/ItemObject.cs
+++ b/Engine/CLEngine.Core/framework/ItemObject.cs
@@ -106,12 +106,17 @@ namespace CLEngine.Core.framework
[DataMember] private string _classification;
[DataMember] private bool _onlyStoreOne;
[DataMember] private string _dropIconPath;
+ [DataMember] private List _scriptList;
[NonSerialized] private Image _guiIcon;
[NonSerialized] private Texture2D _texture;
[NonSerialized] private Texture2D _dropIcon;
private int _positionInBag;
///
+ /// 脚本列表
+ ///
+ public List ScriptList { get { return _scriptList; } set { _scriptList = value; } }
+ ///
/// 掉落图标路径
///
public string DropIconPath
diff --git a/Engine/CLEngine.Core/framework/SkillObject.cs b/Engine/CLEngine.Core/framework/SkillObject.cs
index 31cbd89..a7a075d 100644
--- a/Engine/CLEngine.Core/framework/SkillObject.cs
+++ b/Engine/CLEngine.Core/framework/SkillObject.cs
@@ -1,6 +1,7 @@
using FairyGUI;
using Microsoft.Xna.Framework.Graphics;
using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.Serialization;
@@ -69,9 +70,14 @@ namespace CLEngine.Core.framework
[DataMember] private int _castingDistance;
[DataMember] private float _castingSpeed;
[DataMember] private int _userId;
+ [DataMember] private List _scriptList;
[NonSerialized] private Image _icon;
[NonSerialized] private Texture2D _iconTex;
///
+ /// 脚本列表
+ ///
+ public List ScriptList { get { return _scriptList; } set { _scriptList = value; } }
+ ///
/// 当前冷却时间
///
public float CurrentTime { get { return _currentTime; } set { _currentTime = value; } }
diff --git a/Engine/CLEngine.Core/framework/StateObject.cs b/Engine/CLEngine.Core/framework/StateObject.cs
index 73586c2..64b49c4 100644
--- a/Engine/CLEngine.Core/framework/StateObject.cs
+++ b/Engine/CLEngine.Core/framework/StateObject.cs
@@ -33,6 +33,11 @@ namespace CLEngine.Core.framework
[DataMember] private int _affectMp;
[DataMember] private int _affectSpeed;
[DataMember] private int _id;
+ [DataMember] private List _scriptList;
+ ///
+ /// 脚本列表
+ ///
+ public List ScriptList { get { return _scriptList; } set { _scriptList = value; } }
///
/// ID
///
--
Gitee
From 3947234fc8757b139816afe688b00b5ea08c3f8c Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Thu, 25 Jul 2019 16:07:35 +0800
Subject: [PATCH 12/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/CLEngine.Editor.csproj | 7 +
CLEditor/viewmodel/DataBaseViewModel.cs | 196 +++++++++++++++++-
CLEditor/windows/CustomPropWindow.xaml | 3 +-
CLEditor/windows/DataBaseWindow.xaml | 82 +++++---
CLEditor/windows/SelectScriptWindow.xaml | 18 ++
CLEditor/windows/SelectScriptWindow.xaml.cs | 26 +++
.../framework/FrameworkSettings.cs | 9 +
Engine/CLEngine.Core/framework/ItemObject.cs | 1 +
8 files changed, 304 insertions(+), 38 deletions(-)
create mode 100644 CLEditor/windows/SelectScriptWindow.xaml
create mode 100644 CLEditor/windows/SelectScriptWindow.xaml.cs
diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj
index e8ce653..e26fbdd 100644
--- a/CLEditor/CLEngine.Editor.csproj
+++ b/CLEditor/CLEngine.Editor.csproj
@@ -483,6 +483,9 @@
ScriptingEditorWindow.xaml
+
+ SelectScriptWindow.xaml
+
SettingsWindow.xaml
@@ -612,6 +615,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 15399e2..be84a77 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -10,6 +10,7 @@ using CLEngine.Core.framework;
using CLEngine.Editor.windows;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
+using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using MessageBox = System.Windows.Forms.MessageBox;
namespace CLEngine.Editor.viewmodel
@@ -45,6 +46,14 @@ namespace CLEngine.Editor.viewmodel
get { return FrameworkSettings.ItemTypes.Keys.ToList(); }
}
+ ///
+ /// 脚本分类
+ ///
+ public List ScriptTypes
+ {
+ get { return FrameworkSettings.ScriptTypes.ToList(); }
+ }
+
///
/// 物品子类
///
@@ -73,9 +82,25 @@ namespace CLEngine.Editor.viewmodel
/// 创建脚本按钮
///
public RelayCommand CreateScriptCommand { get; set; }
+ ///
+ /// 脚本选择按钮
+ ///
+ public RelayCommand ScriptSelectCommand { get; set; }
+ ///
+ /// 确认脚本选择
+ ///
+ public RelayCommand ConfirmScriptSelectCommand { get; set; }
+ ///
+ /// 移除脚本
+ ///
+ public RelayCommand RemoveScriptCommand { get; set; }
+ public RelayCommand UpScriptCommand { get; set; }
+ public RelayCommand DownScriptCommand { get; set; }
private string _iconPath;
-
+ ///
+ /// 背包图标路径
+ ///
public string IconPath
{
get { return _iconPath; }
@@ -87,7 +112,9 @@ namespace CLEngine.Editor.viewmodel
}
private string _dropIconPath;
-
+ ///
+ /// 掉落图标路径
+ ///
public string DropIconPath
{
get { return _dropIconPath; }
@@ -98,19 +125,182 @@ namespace CLEngine.Editor.viewmodel
}
}
+ private string _scriptType;
+ ///
+ /// 脚本类型
+ ///
+ public string ScriptType
+ {
+ get { return _scriptType; }
+ set
+ {
+ _scriptType = value;
+ RaisePropertyChanged(() => ScriptType);
+ }
+ }
+
+ public ObservableCollection CanSelectScriptCollection { get; set; }
+
+ private string _selectScript;
+ public string SelectScript
+ {
+ get { return _selectScript;}
+ set
+ {
+ _selectScript = value;
+ RaisePropertyChanged(() => SelectScript);
+ }
+ }
+
public DataBaseViewModel()
{
ItemObjects = GetItemObjects();
AddItemCommand = new RelayCommand(AddItemAction);
ItemChildTypes = new ObservableCollection();
+ CanSelectScriptCollection = new ObservableCollection();
// 我们需要数据通知子类发生变化
- ItemChildTypes.CollectionChanged += (sender, args) => { RaisePropertyChanged(() => ItemChildTypes); };
+ ItemChildTypes.CollectionChanged += (sender, args) => { RaisePropertyChanged(() => ItemChildTypes); };
BagBrowserCommand = new RelayCommand(BagBrowserAction);
DropBrowserCommand = new RelayCommand(DropBrowserAction);
SaveCommand = new RelayCommand(SaveAction);
RemoveItemCommand = new RelayCommand(RemoveItemAction);
CreateScriptCommand = new RelayCommand(CreateScriptAction);
+ ScriptSelectCommand = new RelayCommand(ScriptSelectAction);
+ ConfirmScriptSelectCommand = new RelayCommand(ConfirmScriptSelectAction);
+ RemoveScriptCommand = new RelayCommand(RemoveScriptAction);
+ UpScriptCommand = new RelayCommand(UpScriptAction);
+ DownScriptCommand = new RelayCommand(DownScriptAction);
+
+ ScriptType = "CSharp";
+ }
+
+ private void DownScriptAction()
+ {
+ if (DataBaseWindow.Instance.ScriptListBox.SelectedValue == null)
+ {
+ Logger.Error("请先选择一个脚本!");
+ return;
+ }
+
+ if (DataBaseWindow.Instance.ItemList.SelectedValue is ItemObject item)
+ {
+ var selectItem = DataBaseWindow.Instance.ScriptListBox.SelectedValue.ToString();
+ var index = item.ScriptList.IndexOf(selectItem);
+ item.ScriptList.Remove(selectItem);
+ item.ScriptList.Insert(index + 1 > item.ScriptList.Count ? item.ScriptList.Count : index + 1, selectItem);
+
+ // 刷新列表
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = null;
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = item.ScriptList;
+ }
+ }
+
+ private void UpScriptAction()
+ {
+ if (DataBaseWindow.Instance.ScriptListBox.SelectedValue == null)
+ {
+ Logger.Error("请先选择一个脚本!");
+ return;
+ }
+
+ if (DataBaseWindow.Instance.ItemList.SelectedValue is ItemObject item)
+ {
+ var selectItem = DataBaseWindow.Instance.ScriptListBox.SelectedValue.ToString();
+ var index = item.ScriptList.IndexOf(selectItem);
+ item.ScriptList.Remove(selectItem);
+ item.ScriptList.Insert(index - 1 < 0 ? 0 : index - 1, selectItem);
+
+ // 刷新列表
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = null;
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = item.ScriptList;
+ }
+ }
+
+ private void RemoveScriptAction()
+ {
+ if (DataBaseWindow.Instance.ScriptListBox.SelectedValue == null)
+ {
+ Logger.Error("请先选择一个脚本!");
+ return;
+ }
+
+ if (DataBaseWindow.Instance.ItemList.SelectedValue is ItemObject item)
+ {
+ var selectItem = DataBaseWindow.Instance.ScriptListBox.SelectedValue.ToString();
+ item.ScriptList.Remove(selectItem);
+
+ // 刷新列表
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = null;
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = item.ScriptList;
+ }
+ }
+
+ private void ConfirmScriptSelectAction()
+ {
+ if (string.IsNullOrEmpty(SelectScript))
+ {
+ Logger.Error("必须先选择一个脚本后才能确定!");
+ return;
+ }
+
+ if (DataBaseWindow.Instance.ItemList.SelectedValue == null)
+ {
+ Logger.Error("清先选择一个物品后再选择脚本!");
+ return;
+ }
+
+ if (DataBaseWindow.Instance.ItemList.SelectedValue is ItemObject item)
+ {
+ // 兼容4.0.3.8之前版本
+ if (item.ScriptList == null)
+ item.ScriptList = new List();
+
+ if (!item.ScriptList.Contains(SelectScript))
+ item.ScriptList.Add(SelectScript);
+ else
+ Logger.Warn("您已添加该脚本,已自动忽略该脚本");
+
+ // 刷新列表
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = null;
+ DataBaseWindow.Instance.ScriptListBox.ItemsSource = item.ScriptList;
+ }
+
+ SelectScriptWindow.Instance.Close();
+ }
+
+ private void ScriptSelectAction()
+ {
+ // 先设置内容再打开
+ SetScriptContent();
+
+ var scriptSelect = new SelectScriptWindow();
+ scriptSelect.ShowDialog();
+ }
+
+ ///
+ /// 设置脚本内容
+ ///
+ public void SetScriptContent()
+ {
+ string[] files = {};
+ if (ScriptType == "CSharp")
+ {
+ files = Directory.GetFiles(SceneManager.GameProject.ProjectPath, "*.cs", SearchOption.AllDirectories);
+ }
+ else if (ScriptType == "Lua")
+ {
+ files = Directory.GetFiles(SceneManager.GameProject.ProjectPath, "*.lua", SearchOption.AllDirectories);
+ }
+
+ CanSelectScriptCollection.Clear();
+
+ foreach (var file in files)
+ {
+ CanSelectScriptCollection.Add(file);
+ }
+
+ RaisePropertyChanged(() => CanSelectScriptCollection);
}
private void RemoveItemAction()
diff --git a/CLEditor/windows/CustomPropWindow.xaml b/CLEditor/windows/CustomPropWindow.xaml
index e2eaf75..49e1f98 100644
--- a/CLEditor/windows/CustomPropWindow.xaml
+++ b/CLEditor/windows/CustomPropWindow.xaml
@@ -3,8 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:CLEngine.Editor.windows"
- xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:controls="clr-namespace:CLEngine.Editor.controls" x:Class="CLEngine.Editor.windows.CustomPropWindow"
+ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Class="CLEngine.Editor.windows.CustomPropWindow"
mc:Ignorable="d" Background="{DynamicResource PanelBackground}"
Title="自定义" Height="600" Width="400">
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index a88d79e..24e8aba 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -3,15 +3,13 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:CLEngine.Editor.windows"
- xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:Options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
+ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:controls="clr-namespace:CLEngine.Editor.controls"
xmlns:framework="clr-namespace:CLEngine.Core.framework;assembly=CLEngine.Core"
- xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:converts="clr-namespace:CLEngine.Editor.core.converts"
x:Class="CLEngine.Editor.windows.DataBaseWindow"
mc:Ignorable="d" DataContext="{Binding DataBase, Source={StaticResource Locator}}"
- Title="游戏数据库" Height="800" Width="1366" Background="{DynamicResource PanelBackground}">
+ Title="游戏数据库" Height="800" Width="1366" Background="{DynamicResource PanelBackground}" ResizeMode="NoResize" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen">
@@ -49,22 +47,31 @@
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -80,22 +87,28 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -103,11 +116,14 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/CLEditor/windows/SelectScriptWindow.xaml b/CLEditor/windows/SelectScriptWindow.xaml
new file mode 100644
index 0000000..d1122b9
--- /dev/null
+++ b/CLEditor/windows/SelectScriptWindow.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
diff --git a/CLEditor/windows/SelectScriptWindow.xaml.cs b/CLEditor/windows/SelectScriptWindow.xaml.cs
new file mode 100644
index 0000000..78af43a
--- /dev/null
+++ b/CLEditor/windows/SelectScriptWindow.xaml.cs
@@ -0,0 +1,26 @@
+using System.Windows;
+using System.Windows.Controls;
+using CLEngine.Editor.viewmodel;
+
+namespace CLEngine.Editor.windows
+{
+ ///
+ /// SelectScriptWindow.xaml 的交互逻辑
+ ///
+ public partial class SelectScriptWindow : Window
+ {
+ public static SelectScriptWindow Instance;
+
+ public SelectScriptWindow()
+ {
+ InitializeComponent();
+ Instance = this;
+ ScriptTypeBox.SelectionChanged += ScriptTypeBoxOnSelectionChanged;
+ }
+
+ private void ScriptTypeBoxOnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ (DataContext as DataBaseViewModel)?.SetScriptContent();
+ }
+ }
+}
diff --git a/Engine/CLEngine.Core/framework/FrameworkSettings.cs b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
index 3a6db8c..31f8494 100644
--- a/Engine/CLEngine.Core/framework/FrameworkSettings.cs
+++ b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
@@ -48,6 +48,15 @@ namespace CLEngine.Core.framework
"女"
};
+ ///
+ /// 脚本列表
+ ///
+ public static List ScriptTypes = new List()
+ {
+ "CSharp",
+ "Lua",
+ };
+
///
/// 职业列表
///
diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs
index f7ec76a..c3905f7 100644
--- a/Engine/CLEngine.Core/framework/ItemObject.cs
+++ b/Engine/CLEngine.Core/framework/ItemObject.cs
@@ -388,6 +388,7 @@ namespace CLEngine.Core.framework
/// 物品名称
public ItemObject(string name = "")
{
+ ScriptList = new List();
BagPosition = Vector2.Zero;
Name = name;
}
--
Gitee
From 9a63a12e9f36934b13ea54a8f41d012459d06344 Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Mon, 29 Jul 2019 15:25:37 +0800
Subject: [PATCH 13/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A1=86=E6=9E=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/Project Templates/CLEngine.Core.xml | 4 +-
CLEditor/windows/DataBaseWindow.xaml | 24 ++--
CLEditor/windows/SettingsWindow.xaml.cs | 128 +++++++++++-------
Engine/CLEngine.Core/CLEngine.Core.csproj | 2 +
.../framework/FrameworkManager.cs | 27 ++++
.../CLEngine.Core/framework/IGlobalEvent.cs | 34 +++++
.../CLEngine.Core/framework/ItemEventArgs.cs | 24 ++++
Engine/CLEngine.Core/framework/ItemManager.cs | 46 +++----
Engine/CLEngine.Core/framework/ItemObject.cs | 59 +-------
.../CLEngine.Core/framework/SkillManager.cs | 2 +
.../CLEngine.Core/framework/StateManager.cs | 16 +--
Engine/CLEngine.Core/gameObjects/LuaObject.cs | 79 +++++++++--
12 files changed, 279 insertions(+), 166 deletions(-)
create mode 100644 Engine/CLEngine.Core/framework/IGlobalEvent.cs
create mode 100644 Engine/CLEngine.Core/framework/ItemEventArgs.cs
diff --git a/CLEditor/Project Templates/CLEngine.Core.xml b/CLEditor/Project Templates/CLEngine.Core.xml
index bdb31d2..19d2749 100644
--- a/CLEditor/Project Templates/CLEngine.Core.xml
+++ b/CLEditor/Project Templates/CLEngine.Core.xml
@@ -325,14 +325,14 @@
播放.mp3或.wav音频文件
- The relative path to the audio file
+ The relative path to the audio file
Determine if the sound should loop
播放.mp3或.wav音频文件
- The relative path to the audio file
+ The relative path to the audio file
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index 24e8aba..68d4e08 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -49,8 +49,8 @@
-
-
+
+
@@ -67,8 +67,8 @@
-
-
+
+
@@ -80,20 +80,20 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
diff --git a/CLEditor/windows/SettingsWindow.xaml.cs b/CLEditor/windows/SettingsWindow.xaml.cs
index aa52a0d..a6dff18 100644
--- a/CLEditor/windows/SettingsWindow.xaml.cs
+++ b/CLEditor/windows/SettingsWindow.xaml.cs
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Controls;
using CLEngine.Editor.core;
@@ -11,9 +12,11 @@ namespace CLEngine.Editor.windows
///
/// SettingsWindow.xaml 的交互逻辑
///
- public partial class SettingsWindow : Window
+ [SuppressMessage("ReSharper", "StringLiteralTypo")]
+ [SuppressMessage("ReSharper", "CommentTypo")]
+ public partial class SettingsWindow
{
- private IniFile iniSettings = new IniFile(SceneManager.GameProject.ProjectPath + "\\settings.ini");
+ private readonly IniFile iniSettings = new IniFile(SceneManager.GameProject.ProjectPath + "\\settings.ini");
public SettingsWindow()
{
@@ -30,49 +33,49 @@ namespace CLEngine.Editor.windows
{
case "clengine_general":
settings = new CGeneralSettingsDynamic();
- (settings as CGeneralSettingsDynamic).AutomaticProjectLoad = Properties.Settings.Default.LoadLastProject;
+ ((CGeneralSettingsDynamic) settings).AutomaticProjectLoad = Properties.Settings.Default.LoadLastProject;
try
{
- (settings as CGeneralSettingsDynamic).ScriptEditors = (CGeneralSettingsDynamic.ScriptingEditors)Enum.Parse(typeof(CGeneralSettingsDynamic.ScriptingEditors), Properties.Settings.Default.DefaultScriptEditor, true);
+ ((CGeneralSettingsDynamic) settings).ScriptEditors = (CGeneralSettingsDynamic.ScriptingEditors)Enum.Parse(typeof(CGeneralSettingsDynamic.ScriptingEditors), Properties.Settings.Default.DefaultScriptEditor, true);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
- (settings as CGeneralSettingsDynamic).StartOnFullScreen = Properties.Settings.Default.StartOnFullScreen;
- (settings as CGeneralSettingsDynamic).ShowDebugView = Properties.Settings.Default.ShowDebugView;
- (settings as CGeneralSettingsDynamic).ReduceConsumption = Properties.Settings.Default.ReduceConsumption;
+ ((CGeneralSettingsDynamic) settings).StartOnFullScreen = Properties.Settings.Default.StartOnFullScreen;
+ ((CGeneralSettingsDynamic) settings).ShowDebugView = Properties.Settings.Default.ShowDebugView;
+ ((CGeneralSettingsDynamic) settings).ReduceConsumption = Properties.Settings.Default.ReduceConsumption;
break;
case "clengine_tileset":
settings = new CTilesetSettingsDynamic();
- (settings as CTilesetSettingsDynamic).HighlightActiveTileset = Properties.Settings.Default.HighlightActiveTileset;
+ ((CTilesetSettingsDynamic) settings).HighlightActiveTileset = Properties.Settings.Default.HighlightActiveTileset;
break;
case "game_general":
settings = new GameGeneralSettingsDynamic();
- (settings as GameGeneralSettingsDynamic).ProjectName = SceneManager.GameProject.ProjectName;
- (settings as GameGeneralSettingsDynamic).CatchError =
+ ((GameGeneralSettingsDynamic) settings).ProjectName = SceneManager.GameProject.ProjectName;
+ ((GameGeneralSettingsDynamic) settings).CatchError =
SceneManager.GameProject.EditorSettings.CatchError;
- (settings as GameGeneralSettingsDynamic).NetworkCode = UserPreferences.Instance.NetworkCode;
+ ((GameGeneralSettingsDynamic) settings).NetworkCode = UserPreferences.Instance.NetworkCode;
break;
case "game_grid":
settings = new GameGridSettingsDynamic();
- (settings as GameGridSettingsDynamic).GridSpacing = SceneManager.GameProject.EditorSettings.GridSpacing;
- (settings as GameGridSettingsDynamic).GridThickness = SceneManager.GameProject.EditorSettings.GridThickness;
- (settings as GameGridSettingsDynamic).GridColor = SceneManager.GameProject.EditorSettings.GridColor;
- (settings as GameGridSettingsDynamic).DisplayLines = SceneManager.GameProject.EditorSettings.GridNumberOfLines;
+ ((GameGridSettingsDynamic) settings).GridSpacing = SceneManager.GameProject.EditorSettings.GridSpacing;
+ ((GameGridSettingsDynamic) settings).GridThickness = SceneManager.GameProject.EditorSettings.GridThickness;
+ ((GameGridSettingsDynamic) settings).GridColor = SceneManager.GameProject.EditorSettings.GridColor;
+ ((GameGridSettingsDynamic) settings).DisplayLines = SceneManager.GameProject.EditorSettings.GridNumberOfLines;
break;
case "game_debug":
settings = new GameDebugDynamic();
- (settings as GameDebugDynamic).ShowConsole = iniSettings.IniReadValue("Console", "Visible").ToLower().Trim().Equals("true") ? true : false;
- (settings as GameDebugDynamic).Attach = Properties.Settings.Default.AttachVisualStudio;
+ ((GameDebugDynamic) settings).ShowConsole = iniSettings.IniReadValue("Console", "Visible").ToLower().Trim().Equals("true");
+ ((GameDebugDynamic) settings).Attach = Properties.Settings.Default.AttachVisualStudio;
try
{
- (settings as GameDebugDynamic).DebugMode = (GameDebugDynamic.DebugModes)Enum.Parse(typeof(GameDebugDynamic.DebugModes), (SceneManager.GameProject.Debug ? "Debug" : "Release"), true);
+ ((GameDebugDynamic) settings).DebugMode = (GameDebugDynamic.DebugModes)Enum.Parse(typeof(GameDebugDynamic.DebugModes), (SceneManager.GameProject.Debug ? "Debug" : "Release"), true);
}
catch (Exception ex)
{
@@ -83,10 +86,10 @@ namespace CLEngine.Editor.windows
case "game_screen":
settings = new GameScreenDynamic();
- (settings as GameScreenDynamic).MouseVisible = iniSettings.IniReadValue("Mouse", "Visible").ToLower().Trim().Equals("true") ? true : false;
- (settings as GameScreenDynamic).StartOnFullScreen = iniSettings.IniReadValue("Window", "StartFullScreen").ToLower().Trim().Equals("true") ? true : false;
- (settings as GameScreenDynamic).ScreenWidth = SceneManager.GameProject.Settings.ScreenWidth;
- (settings as GameScreenDynamic).ScreenHeight = SceneManager.GameProject.Settings.ScreenHeight;
+ ((GameScreenDynamic) settings).MouseVisible = iniSettings.IniReadValue("Mouse", "Visible").ToLower().Trim().Equals("true");
+ ((GameScreenDynamic) settings).StartOnFullScreen = iniSettings.IniReadValue("Window", "StartFullScreen").ToLower().Trim().Equals("true");
+ ((GameScreenDynamic) settings).ScreenWidth = SceneManager.GameProject.Settings.ScreenWidth;
+ ((GameScreenDynamic) settings).ScreenHeight = SceneManager.GameProject.Settings.ScreenHeight;
//(settings as GameScreenDynamic).VSync = SceneManager.GameProject.ProjectSettings.VSyncEnabled;
break;
}
@@ -101,11 +104,11 @@ namespace CLEngine.Editor.windows
switch (propertyGrid.Tag.ToString())
{
case "clengine_general":
- Properties.Settings.Default.LoadLastProject = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).AutomaticProjectLoad;
- Properties.Settings.Default.StartOnFullScreen = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).StartOnFullScreen;
- Properties.Settings.Default.ShowDebugView = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ShowDebugView;
- Properties.Settings.Default.ReduceConsumption = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ReduceConsumption;
- string appName = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString();
+ Properties.Settings.Default.LoadLastProject = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).AutomaticProjectLoad;
+ Properties.Settings.Default.StartOnFullScreen = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).StartOnFullScreen;
+ Properties.Settings.Default.ShowDebugView = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).ShowDebugView;
+ Properties.Settings.Default.ReduceConsumption = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).ReduceConsumption;
+ string appName = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).ScriptEditors.ToString();
EditorUtils.StoreInstalledApplications();
@@ -132,51 +135,51 @@ namespace CLEngine.Editor.windows
if (appName.ToLower().Equals("lime"))
{
- Properties.Settings.Default.DefaultScriptEditor = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString();
+ Properties.Settings.Default.DefaultScriptEditor = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject)?.ScriptEditors.ToString();
}
- if ((propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString().ToLower() != "lime")
- if (EditorUtils.CheckVisualStudioExistance((propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString()))
- Properties.Settings.Default.DefaultScriptEditor = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString();
+ if (((CGeneralSettingsDynamic) propertyGrid.SelectedObject)?.ScriptEditors.ToString().ToLower() != "lime")
+ if (EditorUtils.CheckVisualStudioExistance(((CGeneralSettingsDynamic) propertyGrid.SelectedObject)?.ScriptEditors.ToString()))
+ Properties.Settings.Default.DefaultScriptEditor = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject)?.ScriptEditors.ToString();
else
MessageBox.Show("您没有选定的Visual Studio IDE");
else
- Properties.Settings.Default.DefaultScriptEditor = (propertyGrid.SelectedObject as CGeneralSettingsDynamic).ScriptEditors.ToString();
+ Properties.Settings.Default.DefaultScriptEditor = ((CGeneralSettingsDynamic) propertyGrid.SelectedObject).ScriptEditors.ToString();
Properties.Settings.Default.Save();
break;
case "clengine_tileset":
- Properties.Settings.Default.HighlightActiveTileset = (propertyGrid.SelectedObject as CTilesetSettingsDynamic).HighlightActiveTileset;
+ Properties.Settings.Default.HighlightActiveTileset = ((CTilesetSettingsDynamic) propertyGrid.SelectedObject).HighlightActiveTileset;
break;
case "game_general":
- SceneManager.GameProject.ProjectName = (propertyGrid.SelectedObject as GameGeneralSettingsDynamic).ProjectName;
- SceneManager.GameProject.EditorSettings.CatchError = (propertyGrid.SelectedObject as GameGeneralSettingsDynamic).CatchError;
+ SceneManager.GameProject.ProjectName = (propertyGrid.SelectedObject as GameGeneralSettingsDynamic)?.ProjectName;
+ SceneManager.GameProject.EditorSettings.CatchError = ((GameGeneralSettingsDynamic) propertyGrid.SelectedObject).CatchError;
UserPreferences.Instance.NetworkCode =
- (propertyGrid.SelectedObject as GameGeneralSettingsDynamic).NetworkCode;
+ (propertyGrid.SelectedObject as GameGeneralSettingsDynamic)?.NetworkCode;
break;
case "game_grid":
- SceneManager.GameProject.EditorSettings.GridSpacing = (propertyGrid.SelectedObject as GameGridSettingsDynamic).GridSpacing;
- SceneManager.GameProject.EditorSettings.GridThickness = (propertyGrid.SelectedObject as GameGridSettingsDynamic).GridThickness;
- SceneManager.GameProject.EditorSettings.GridColor = (propertyGrid.SelectedObject as GameGridSettingsDynamic).GridColor;
- SceneManager.GameProject.EditorSettings.GridNumberOfLines = (propertyGrid.SelectedObject as GameGridSettingsDynamic).DisplayLines;
+ SceneManager.GameProject.EditorSettings.GridSpacing = ((GameGridSettingsDynamic) propertyGrid.SelectedObject).GridSpacing;
+ SceneManager.GameProject.EditorSettings.GridThickness = ((GameGridSettingsDynamic) propertyGrid.SelectedObject).GridThickness;
+ SceneManager.GameProject.EditorSettings.GridColor = ((GameGridSettingsDynamic) propertyGrid.SelectedObject).GridColor;
+ SceneManager.GameProject.EditorSettings.GridNumberOfLines = ((GameGridSettingsDynamic) propertyGrid.SelectedObject).DisplayLines;
break;
case "game_debug":
- iniSettings.IniWriteValue("Console", "Visible", (propertyGrid.SelectedObject as GameDebugDynamic).ShowConsole.ToString());
- Properties.Settings.Default.AttachVisualStudio = (propertyGrid.SelectedObject as GameDebugDynamic).Attach;
+ iniSettings.IniWriteValue("Console", "Visible", (propertyGrid.SelectedObject as GameDebugDynamic)?.ShowConsole.ToString());
+ Properties.Settings.Default.AttachVisualStudio = ((GameDebugDynamic) propertyGrid.SelectedObject).Attach;
Properties.Settings.Default.Save();
- SceneManager.GameProject.Debug = (propertyGrid.SelectedObject as GameDebugDynamic).DebugMode == GameDebugDynamic.DebugModes.Debug ? true : false;
+ SceneManager.GameProject.Debug = ((GameDebugDynamic) propertyGrid.SelectedObject).DebugMode == GameDebugDynamic.DebugModes.Debug;
break;
case "game_screen":
- iniSettings.IniWriteValue("Mouse", "Visible", (propertyGrid.SelectedObject as GameScreenDynamic).MouseVisible.ToString());
- iniSettings.IniWriteValue("Window", "StartFullScreen", (propertyGrid.SelectedObject as GameScreenDynamic).StartOnFullScreen.ToString());
- SceneManager.GameProject.Settings.ScreenWidth = (propertyGrid.SelectedObject as GameScreenDynamic).ScreenWidth;
- SceneManager.GameProject.Settings.ScreenHeight = (propertyGrid.SelectedObject as GameScreenDynamic).ScreenHeight;
+ iniSettings.IniWriteValue("Mouse", "Visible", (propertyGrid.SelectedObject as GameScreenDynamic)?.MouseVisible.ToString());
+ iniSettings.IniWriteValue("Window", "StartFullScreen", (propertyGrid.SelectedObject as GameScreenDynamic)?.StartOnFullScreen.ToString());
+ SceneManager.GameProject.Settings.ScreenWidth = ((GameScreenDynamic) propertyGrid.SelectedObject).ScreenWidth;
+ SceneManager.GameProject.Settings.ScreenHeight = ((GameScreenDynamic) propertyGrid.SelectedObject).ScreenHeight;
//SceneManager.GameProject.ProjectSettings.VSyncEnabled = (propertyGrid.SelectedObject as GameScreenDynamic).VSync;
break;
}
@@ -184,11 +187,11 @@ namespace CLEngine.Editor.windows
private void ProjectsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if (ProjectsListBox.SelectedItem == null || (ProjectsListBox.SelectedItem as ListBoxItem).Tag == null) return;
+ if ((ProjectsListBox.SelectedItem as ListBoxItem)?.Tag == null) return;
SaveCurrent();
- propertyGrid.Tag = (ProjectsListBox.SelectedItem as ListBoxItem).Tag.ToString();
+ propertyGrid.Tag = ((ListBoxItem) ProjectsListBox.SelectedItem).Tag.ToString();
propertyGrid.SelectedObject = LoadProperties(propertyGrid.Tag.ToString());
}
@@ -200,9 +203,22 @@ namespace CLEngine.Editor.windows
interface ISettingsChannelA { }
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
class CGeneralSettingsDynamic : ISettingsChannelA
{
- public enum ScriptingEditors { None, Lime, VisualStudio2019, VisualStudio2017, VisualStudio2015, VisualStudio2013, VisualStudio2012, VisualStudio2010 } //CSExpress2010
+ public enum ScriptingEditors
+ {
+ None,
+ Lime,
+ VisualStudio2019,
+ VisualStudio2017,
+ VisualStudio2015,
+ VisualStudio2013,
+ VisualStudio2012,
+ VisualStudio2010
+ } //CSExpress2010
private bool automaticProjectLoad;
private bool startOnFullScreen;
@@ -251,6 +267,9 @@ namespace CLEngine.Editor.windows
}
}
+ [SuppressMessage("ReSharper", "StringLiteralTypo")]
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
class CTilesetSettingsDynamic : ISettingsChannelA
{
private bool highlightActiveTileset;
@@ -264,6 +283,8 @@ namespace CLEngine.Editor.windows
}
}
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
class GameGeneralSettingsDynamic : ISettingsChannelA
{
private string projectName;
@@ -297,6 +318,8 @@ namespace CLEngine.Editor.windows
}
}
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
class GameGridSettingsDynamic : ISettingsChannelA
{
private int gridSpacing;
@@ -338,6 +361,8 @@ namespace CLEngine.Editor.windows
}
}
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
class GameDebugDynamic : ISettingsChannelA
{
public enum DebugModes { Debug, Release }
@@ -372,6 +397,9 @@ namespace CLEngine.Editor.windows
}
}
+ [SuppressMessage("ReSharper", "CommentTypo")]
+ [SuppressMessage("ReSharper", "ConvertToAutoProperty")]
+ [SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
class GameScreenDynamic : ISettingsChannelA
{
private bool startOnFullScreen;
diff --git a/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index 330d10b..967fdd3 100644
--- a/Engine/CLEngine.Core/CLEngine.Core.csproj
+++ b/Engine/CLEngine.Core/CLEngine.Core.csproj
@@ -301,6 +301,8 @@
+
+
diff --git a/Engine/CLEngine.Core/framework/FrameworkManager.cs b/Engine/CLEngine.Core/framework/FrameworkManager.cs
index 8f14120..61c5481 100644
--- a/Engine/CLEngine.Core/framework/FrameworkManager.cs
+++ b/Engine/CLEngine.Core/framework/FrameworkManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
+using System.Reflection;
using System.Windows.Forms;
namespace CLEngine.Core.framework
@@ -142,5 +143,31 @@ namespace CLEngine.Core.framework
throw new Exception(e.Message, e);
}
}
+
+ ///
+ /// 获取全局事件
+ ///
+ ///
+ public static IGlobalEvent GetGlobalEvent()
+ {
+ var assembly = Assembly.GetAssembly(typeof(IGlobalEvent));
+ var types = assembly.GetTypes();
+ return (from item in types
+ where !item.IsInterface
+ from i in item.GetInterfaces()
+ where i == typeof(IGlobalEvent)
+ select (IGlobalEvent) Activator.CreateInstance(i)).FirstOrDefault();
+ }
+
+ ///
+ /// 执行Lua代码
+ ///
+ /// 文件名
+ /// 函数名
+ /// 参数
+ public static void DoLua(string fileName, string funcName, params object[] param)
+ {
+
+ }
}
}
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/framework/IGlobalEvent.cs b/Engine/CLEngine.Core/framework/IGlobalEvent.cs
new file mode 100644
index 0000000..d50f212
--- /dev/null
+++ b/Engine/CLEngine.Core/framework/IGlobalEvent.cs
@@ -0,0 +1,34 @@
+namespace CLEngine.Core.framework
+{
+ ///
+ /// 游戏全局事件
+ ///
+ public interface IGlobalEvent
+ {
+ #region 物品事件
+
+ ///
+ /// 使用物品事件
+ ///
+ void UseItem(int id);
+
+ ///
+ /// 获取物品事件
+ ///
+ void GetItem(int id);
+
+ ///
+ /// 丢弃物品事件
+ ///
+ ///
+ void ThrowItem(int id);
+
+ ///
+ /// 物品属性改变事件
+ ///
+ ///
+ void ChangePropItem(int id);
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/framework/ItemEventArgs.cs b/Engine/CLEngine.Core/framework/ItemEventArgs.cs
new file mode 100644
index 0000000..9abdc29
--- /dev/null
+++ b/Engine/CLEngine.Core/framework/ItemEventArgs.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace CLEngine.Core.framework
+{
+ ///
+ ///
+ ///
+ public class ItemEventArgs : EventArgs
+ {
+ ///
+ ///
+ ///
+ public int userId;
+
+ ///
+ ///
+ ///
+ ///
+ public ItemEventArgs(int user)
+ {
+ userId = user;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/framework/ItemManager.cs b/Engine/CLEngine.Core/framework/ItemManager.cs
index 169e638..616c182 100644
--- a/Engine/CLEngine.Core/framework/ItemManager.cs
+++ b/Engine/CLEngine.Core/framework/ItemManager.cs
@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
-using System.IO;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
-using Path = System.IO.Path;
namespace CLEngine.Core.framework
{
@@ -13,6 +12,7 @@ namespace CLEngine.Core.framework
[Serializable]
#endif
[DataContract]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class ItemManager : IDataFramework
{
///
@@ -140,10 +140,9 @@ namespace CLEngine.Core.framework
public static ItemObject BagFindItemByName(string name)
{
var max = _playerItem.Count;
- ItemObject item;
for (int i = 0; i < max; i++)
{
- item = _playerItem[i];
+ var item = _playerItem[i];
if (item.Name == name)
{
return item;
@@ -160,10 +159,9 @@ namespace CLEngine.Core.framework
{
var max = _playerItem.Count;
var itemlist = new List();
- ItemObject item;
for (int i = 0; i < max; i++)
{
- item = _playerItem[i];
+ var item = _playerItem[i];
if (item.Name == name)
{
itemlist.Add(item);
@@ -179,10 +177,9 @@ namespace CLEngine.Core.framework
public static ItemObject BagFindItemById(int id)
{
var max = _playerItem.Count;
- ItemObject item;
for (int i = 0; i < max; i++)
{
- item = _playerItem[i];
+ var item = _playerItem[i];
if (item.Id == id)
{
return item;
@@ -199,10 +196,9 @@ namespace CLEngine.Core.framework
{
var max = _playerItem.Count;
var itemlist = new List();
- ItemObject item;
for (int i = 0; i < max; i++)
{
- item = _playerItem[i];
+ var item = _playerItem[i];
if (item.Id == id)
{
itemlist.Add(item);
@@ -218,16 +214,13 @@ namespace CLEngine.Core.framework
public static void GetItemById(int id, int number)//需要注意检索是否装备唯一
{
var onget = WorldFindItemById(id);
- ItemObject item = null;
var max = _playerItem.Count;
var is_finish = false;
- var have = false;
for (var i = 0; i < max; i++)
{
- item = _playerItem[i];
+ var item = _playerItem[i];
if (item.Id == id)
{
- have = true;
if (item.Number + number <= item.MaxNumber)
{
item.Number += number;
@@ -236,7 +229,7 @@ namespace CLEngine.Core.framework
}
}
}
- if (!is_finish || (!have && item.OnlyGetOne))
+ if (!is_finish)
{
onget.Number = number;
_playerItem.Add(onget);
@@ -251,25 +244,18 @@ namespace CLEngine.Core.framework
public static void GetItemByName(string name, int number)
{
var onget = _worldItem[name];
- ItemObject item = null;
var max = _playerItem.Count;
var is_finish = false;
- var have = false;
- for (int i = 0; i < max; i++)
+ for (var i = 0; i < max; i++)
{
- item = _playerItem[i];
- if (item.Name == name)
- {
- have = true;
- if (item.Number + number <= item.MaxNumber)
- {
- item.Number += number;
- is_finish = true;
- break;
- }
- }
+ var item = _playerItem[i];
+ if (item.Name != name) continue;
+ if (item.Number + number > item.MaxNumber) continue;
+ item.Number += number;
+ is_finish = true;
+ break;
}
- if (!is_finish || (!have && item.OnlyGetOne))
+ if (!is_finish)
{
onget.Number = number;
_playerItem.Add(onget);
diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs
index c3905f7..a88cfde 100644
--- a/Engine/CLEngine.Core/framework/ItemObject.cs
+++ b/Engine/CLEngine.Core/framework/ItemObject.cs
@@ -12,50 +12,15 @@ namespace CLEngine.Core.framework
///
///
///
- public class ItemEventArgs : EventArgs
- {
- ///
- ///
- ///
- public int userId;
-
- ///
- ///
- ///
- ///
- public ItemEventArgs(int user)
- {
- userId = user;
- }
- }
-
- ///
- ///
- ///
#if WIN
[Serializable]
#endif
[DataContract]
[SuppressMessage("ReSharper", "ArrangeAccessorOwnerBody")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class ItemObject
{
- ///
- /// 使用事件
- ///
- public EventHandler Use;
- ///
- /// 获取事件
- ///
- public EventHandler Get;
- ///
- /// 丢弃事件
- ///
- public EventHandler Throw;
- ///
- /// 物品数量改变事件
- ///
- public EventHandler NumberChange;
-
[DataMember] private string _iconPath;
[DataMember] private string _name;
[DataMember] private string _showName;
@@ -420,40 +385,28 @@ namespace CLEngine.Core.framework
///
public void UseItem()
{
- if (Use != null)
- {
- Use.Invoke(this, new ItemEventArgs(userId));
- }
+ FrameworkManager.GetGlobalEvent()?.UseItem(userId);
}
///
/// 获取物品
///
public void GetItem()
{
- if (Get != null)
- {
- Get.Invoke(this, new ItemEventArgs(userId));
- }
+ FrameworkManager.GetGlobalEvent()?.GetItem(userId);
}
///
/// 丢掉物品
///
public void ThrowItem()
{
- if (Throw != null)
- {
- Throw.Invoke(this, new ItemEventArgs(userId));
- }
+ FrameworkManager.GetGlobalEvent()?.ThrowItem(userId);
}
///
/// 物品数量改变
///
public void ItemNumberChange()
{
- if (NumberChange != null)
- {
- NumberChange.Invoke(this, new ItemEventArgs(userId));
- }
+ FrameworkManager.GetGlobalEvent()?.ChangePropItem(userId);
}
///
/// 返回表示当前对象的字符串
diff --git a/Engine/CLEngine.Core/framework/SkillManager.cs b/Engine/CLEngine.Core/framework/SkillManager.cs
index b9d0092..a577e5c 100644
--- a/Engine/CLEngine.Core/framework/SkillManager.cs
+++ b/Engine/CLEngine.Core/framework/SkillManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
namespace CLEngine.Core.framework
@@ -11,6 +12,7 @@ namespace CLEngine.Core.framework
[Serializable]
#endif
[DataContract]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class SkillManager : IDataFramework
{
///
diff --git a/Engine/CLEngine.Core/framework/StateManager.cs b/Engine/CLEngine.Core/framework/StateManager.cs
index 34572bf..7ea38de 100644
--- a/Engine/CLEngine.Core/framework/StateManager.cs
+++ b/Engine/CLEngine.Core/framework/StateManager.cs
@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
-using System.IO;
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
-using Path = System.IO.Path;
namespace CLEngine.Core.framework
{
@@ -13,6 +12,7 @@ namespace CLEngine.Core.framework
[Serializable]
#endif
[DataContract]
+ [SuppressMessage("ReSharper", "UnusedMember.Global")]
public class StateManager : IDataFramework
{
///
@@ -140,10 +140,9 @@ namespace CLEngine.Core.framework
public static StateObject PlayerFindStateByName(string name)
{
var max = _playerState.Count;
- StateObject State;
for (int i = 0; i < max; i++)
{
- State = _playerState[i];
+ var State = _playerState[i];
if (State.Name == name)
{
return State;
@@ -160,10 +159,9 @@ namespace CLEngine.Core.framework
{
var max = _playerState.Count;
var Statelist = new List();
- StateObject State;
for (int i = 0; i < max; i++)
{
- State = _playerState[i];
+ var State = _playerState[i];
if (State.Name == name)
{
Statelist.Add(State);
@@ -179,10 +177,9 @@ namespace CLEngine.Core.framework
public static StateObject PlayerFindStateById(int id)
{
var max = _playerState.Count;
- StateObject State;
for (int i = 0; i < max; i++)
{
- State = _playerState[i];
+ var State = _playerState[i];
if (State.Id == id)
{
return State;
@@ -199,10 +196,9 @@ namespace CLEngine.Core.framework
{
var max = _playerState.Count;
var Statelist = new List();
- StateObject State;
for (int i = 0; i < max; i++)
{
- State = _playerState[i];
+ var State = _playerState[i];
if (State.Id == id)
{
Statelist.Add(State);
diff --git a/Engine/CLEngine.Core/gameObjects/LuaObject.cs b/Engine/CLEngine.Core/gameObjects/LuaObject.cs
index 07bc118..0988b4b 100644
--- a/Engine/CLEngine.Core/gameObjects/LuaObject.cs
+++ b/Engine/CLEngine.Core/gameObjects/LuaObject.cs
@@ -1,57 +1,79 @@
using System;
using System.ComponentModel;
-using System.IO;
using System.Runtime.Serialization;
-using System.Text;
using CLEngine.Core.design;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using NLua;
+// ReSharper disable once CheckNamespace
namespace CLEngine.Core
{
+ ///
+ ///
+ ///
#if WIN
- [Serializable]
+ [Serializable]
#endif
[DataContract]
public class LuaObject : ObjectComponent
{
+ ///
+ ///
+ ///
[DataMember]
- public string filePath;
+ public string _filePath;
+ ///
+ ///
+ ///
[NonSerialized]
public object[] LuaResult;
+ ///
+ ///
+ ///
#if WIN
- [Editor(typeof(ContentBrowserEditor), typeof(System.Drawing.Design.UITypeEditor))]
+ [Editor(typeof(ContentBrowserEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Category("脚本属性")]
[DisplayName("文件路径"), Description("脚本文件的相对路径")]
#endif
public string LuaFilePath
{
- get { return filePath; }
+ get { return _filePath; }
set
{
- filePath = value;
+ _filePath = value;
}
}
+
+ ///
+ ///
+ ///
#if WIN
- [NonSerialized]
+ [NonSerialized]
#endif
[Browsable(false)]
public ObjectComponent Object;
+
+ ///
+ ///
+ ///
public LuaObject()
{
Object = this;
}
+ ///
+ ///
+ ///
public override void Initialize()
{
Object = this;
- string _filePath = SceneManager.GameProject.ProjectPath + "//" + filePath;
+ string _filePath = SceneManager.GameProject.ProjectPath + "//" + this._filePath;
LuaResult = ScriptEngine.LuaEngine.LoadFile(_filePath).Call(this);
@@ -60,6 +82,10 @@ namespace CLEngine.Core
DoFile("Initialize", Object);
}
+ ///
+ ///
+ ///
+ ///
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
@@ -67,6 +93,11 @@ namespace CLEngine.Core
DoFile("Update", gameTime);
}
+ ///
+ ///
+ ///
+ ///
+ ///
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
base.Draw(gameTime, spriteBatch);
@@ -74,6 +105,10 @@ namespace CLEngine.Core
DoFile("Draw", gameTime, spriteBatch);
}
+ ///
+ ///
+ ///
+ ///
public override void OnCollisionEnter(GameObject other)
{
base.OnCollisionEnter(other);
@@ -81,6 +116,10 @@ namespace CLEngine.Core
DoFile("OnCollisionEnter", other);
}
+ ///
+ ///
+ ///
+ ///
public override void OnMouseDown(MouseEventButton buttonPressed)
{
base.OnMouseDown(buttonPressed);
@@ -88,6 +127,9 @@ namespace CLEngine.Core
DoFile("OnMouseDown", buttonPressed);
}
+ ///
+ ///
+ ///
public override void OnMouseMove()
{
base.OnMouseMove();
@@ -95,6 +137,9 @@ namespace CLEngine.Core
DoFile("OnMouseMove");
}
+ ///
+ ///
+ ///
public override void OnCollisionFree()
{
base.OnCollisionFree();
@@ -102,6 +147,10 @@ namespace CLEngine.Core
DoFile("OnCollisionFree");
}
+ ///
+ ///
+ ///
+ ///
public override void OnMouseClick(MouseEventButton buttonPressed)
{
base.OnMouseClick(buttonPressed);
@@ -109,6 +158,9 @@ namespace CLEngine.Core
DoFile("OnMouseClick", buttonPressed);
}
+ ///
+ ///
+ ///
public override void OnMouseEnter()
{
base.OnMouseEnter();
@@ -116,6 +168,9 @@ namespace CLEngine.Core
DoFile("OnMouseEnter");
}
+ ///
+ ///
+ ///
public override void OnMouseOut()
{
base.OnMouseOut();
@@ -123,6 +178,9 @@ namespace CLEngine.Core
DoFile("OnMouseOut");
}
+ ///
+ ///
+ ///
public override void OnMouseUp()
{
base.OnMouseUp();
@@ -130,6 +188,9 @@ namespace CLEngine.Core
DoFile("OnMouseUp");
}
+ ///
+ ///
+ ///
public override void Removed()
{
base.Removed();
--
Gitee