diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj
index 1063f3778ef0d2c546a653d9941edc6b6d402eac..e26fbdd581377a0a4cd8a74bc8082dd15920f55c 100644
--- a/CLEditor/CLEngine.Editor.csproj
+++ b/CLEditor/CLEngine.Editor.csproj
@@ -433,6 +433,7 @@
NodeScriptWindow.xaml
+
@@ -446,6 +447,9 @@
CreateMapWindow.xaml
+
+ CustomPropWindow.xaml
+
DataBaseWindow.xaml
@@ -479,6 +483,9 @@
ScriptingEditorWindow.xaml
+
+ SelectScriptWindow.xaml
+
SettingsWindow.xaml
@@ -560,6 +567,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -604,6 +615,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/CLEditor/Project Templates/CLEngine.Core.xml b/CLEditor/Project Templates/CLEngine.Core.xml
index bdb31d28b3c591533cea892619798440633559ab..19d274922a0cc593098719f2ba05f68f832945fb 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/core/EditorCommands.cs b/CLEditor/core/EditorCommands.cs
index e07809f70b087ec50fe38b6716f2750dd650afe2..8ec6bdb2cb251e08e040064e527da1bd8e5db7f8 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 63b4d9f750ebcf8ea543127347680ef431d24de3..2ec3de0a9499aedbf51e18568359c25faf1b48ae 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 8f68ac2019d3da5ca81a96a058220b2378bc31f7..58ec46a027e85e78af70967efda21399306a3832 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,49 @@ namespace CLEngine.Editor.core
return bImg;
}
- internal static CMenuItem CreateMenuItem(string text, ImageSource imageSource = null)
- {
- CMenuItem menuItem = new CMenuItem();
+ 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 });
- menuItem.Header = text;
+ return stackPanel;
+ }
- if (imageSource != null)
- menuItem.Icon = new Image() { Source = imageSource, HorizontalAlignment = HorizontalAlignment.Center };
+ public static BitmapSource ConvertBitmapToSource96DPI(BitmapImage bitmapImage)
+ {
+ double dpi = 96;
+ int width = bitmapImage.PixelWidth;
+ int height = bitmapImage.PixelHeight;
- return menuItem;
- }
+ int stride = width * 4; // 4 bytes per pixel
+ byte[] pixelData = new byte[stride * height];
+ bitmapImage.CopyPixels(pixelData, stride, 0);
- internal static StackPanel CreateHeader(string text, ImageSource imageSource)
+ return BitmapSource.Create(width, height, dpi, dpi, PixelFormats.Bgra32, null, pixelData, stride);
+ }
+
+ internal static CMenuItem CreateMenuItem(string text, ImageSource imageSource = null)
{
- 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 });
+ CMenuItem menuItem = new CMenuItem {Header = text};
+
- return stackPanel;
+ if (imageSource != null)
+ menuItem.Icon = new Image() { Source = imageSource, HorizontalAlignment = HorizontalAlignment.Center };
+
+ return menuItem;
}
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 +104,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 +124,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 +138,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 +155,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 +189,7 @@ namespace CLEngine.Editor.core
///
internal static bool CheckVisualStudioExistance(string version)
{
- string src = string.Empty;
+ string src;
switch (version)
{
case "VisualStudio2015":
@@ -221,7 +211,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 +242,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 +262,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 4e2ed3daebc33c0dbbb33303e4d1ee2349902a18..f61f71dc3341ea4c359e752cbaaad3601be4e1d6 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 2faf303bcbf40fe76a91409755b59e28cf45ff11..360a3bc070a1be76be8710d66ef3aa3a4cac3127 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 75d8bf63822356d365d022ad9eacdbf825247348..f64657947040ef84c75a86b9ea603a3ea1b663e3 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 300cbb300c8950881ed7040cf9fca6f30db99a5d..21325b07cb20e3b6900621605eb5f3f910e1e3d0 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/core/converts/EditorImageConvert.cs b/CLEditor/core/converts/EditorImageConvert.cs
index 594f72ab80e9d48c459a635757786719b1796d02..5732ed8461658d3a27945ade87516e89635963df 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/CLEditor/graphics_device/SceneViewGameControl.cs b/CLEditor/graphics_device/SceneViewGameControl.cs
index 42f331c77809790ee32560586344abb15fe1f9f1..09eeb777e9e7583652988a8bc7db3ffc7f28a69b 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 9754585ef7cc1ae539f7d4fefa1c8969020c80dd..4b81ee728edd9e191563c93f5898b78c491e26f9 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 0fc7590be797a936bb2fc1005a9332cb161f01fe..1d741aaabad29529615604df32536e30df681cb8 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 90d41f201bf6626d3387e2a725fc91b8c2a0e3ad..6bc6162ba0cbbd8ac096a7372e3ffba9752f6496 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 bcd0f264fb1d570745ca07603d99bda8f12362e5..ff57c8a8f3d9662664abb84aeddabd02c9e7871f 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 2f0e2d1455df1e7f489f5a2361f421c539b444f7..62e6f8a9d8ec7a3dfdee45bfc3d46e2e3cde40b7 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 7fb07caef577f3b6835c4b0fa2885a9b0ea02933..054a4c12b60b18f8352ed6a3b0761ad8df799978 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 2e41f7e855cf78e322f31211960411b54ddc62f3..81b334d3679bc0343989cc80fc6cf65acfe19290 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/theme/IgniteDark.xaml b/CLEditor/theme/IgniteDark.xaml
index d7654c7bf478457b3e76102612e6216360b13798..aa4e9af99369fd1eb359061fe9d8338743dbf7e3 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 0000000000000000000000000000000000000000..df6ab49bb4251ee4858f670be877e435cddad7e7
--- /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/ButtonVisibilityViewModel.cs b/CLEditor/viewmodel/ButtonVisibilityViewModel.cs
index 1bcfbd15be5525adbff49861927f859266738fc0..4c25e295e03dffb9a31a6458cb80e34c7f9f5ea9 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/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 4f1c4b13612025fb19bf4b9b11a3e6aeaec76e87..be84a77e6bcb581f90ff086748b646967e21433e 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
using System.Linq;
using System.Windows.Forms;
using CLEngine.Core;
@@ -8,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
@@ -25,6 +28,10 @@ namespace CLEngine.Editor.viewmodel
/// 添加物品命令
///
public RelayCommand AddItemCommand { get; set; }
+ ///
+ /// 删除物品命令
+ ///
+ public RelayCommand RemoveItemCommand { get; set; }
///
/// 性别列表
///
@@ -39,6 +46,14 @@ namespace CLEngine.Editor.viewmodel
get { return FrameworkSettings.ItemTypes.Keys.ToList(); }
}
+ ///
+ /// 脚本分类
+ ///
+ public List ScriptTypes
+ {
+ get { return FrameworkSettings.ScriptTypes.ToList(); }
+ }
+
///
/// 物品子类
///
@@ -63,9 +78,29 @@ namespace CLEngine.Editor.viewmodel
/// 保存数据按钮
///
public RelayCommand SaveCommand { get; set; }
+ ///
+ /// 创建脚本按钮
+ ///
+ 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; }
@@ -77,7 +112,9 @@ namespace CLEngine.Editor.viewmodel
}
private string _dropIconPath;
-
+ ///
+ /// 掉落图标路径
+ ///
public string DropIconPath
{
get { return _dropIconPath; }
@@ -88,19 +125,194 @@ 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()
+ {
+ var itemList = DataBaseWindow.Instance.ItemList;
+ if (itemList.SelectedValue is ItemObject item)
+ {
+ ItemManager.RemoveItem(item);
+ ItemObjects.Remove(item);
+ }
+ }
+
private ObservableCollection GetItemObjects()
{
var itemObjects = new ObservableCollection();
@@ -122,7 +334,7 @@ namespace CLEngine.Editor.viewmodel
private void DropBrowserAction()
{
var fileSelectDialog = new OpenFileDialog();
- var itemObject = (ItemObject)DataBaseWindow.ItemListInstance.SelectedItem;
+ var itemObject = (ItemObject)DataBaseWindow.Instance.ItemList.SelectedItem;
if (itemObject != null)
{
itemObject.DropIconPath = ProcessDialog(fileSelectDialog, "Icon\\");
@@ -133,7 +345,7 @@ namespace CLEngine.Editor.viewmodel
private void BagBrowserAction()
{
var fileSelectDialog = new OpenFileDialog();
- var itemObject = (ItemObject)DataBaseWindow.ItemListInstance.SelectedItem;
+ var itemObject = (ItemObject) DataBaseWindow.Instance.ItemList.SelectedItem;
if (itemObject != null)
{
itemObject.IconPath = ProcessDialog(fileSelectDialog, "Icon\\");
@@ -141,25 +353,26 @@ namespace CLEngine.Editor.viewmodel
}
}
+ [SuppressMessage("ReSharper", "LocalizableElement")]
private string ProcessDialog(OpenFileDialog ofd, string specificFolder = "")
{
var result = ofd.ShowDialog();
if (result == DialogResult.OK || result == DialogResult.Yes)
{
string destFolder = (SceneManager.GameProject.ProjectPath + "\\Content\\" + specificFolder).Trim();
- string filename = System.IO.Path.GetFileName(ofd.FileName);
+ string filename = Path.GetFileName(ofd.FileName);
bool fileOnDirectory = ofd.FileName.StartsWith(SceneManager.GameProject.ProjectPath);
- if (!System.IO.Directory.Exists(destFolder) && !fileOnDirectory)
- System.IO.Directory.CreateDirectory(destFolder);
+ if (!Directory.Exists(destFolder) && !fileOnDirectory)
+ Directory.CreateDirectory(destFolder);
- if (!System.IO.File.Exists(destFolder + filename) || fileOnDirectory)
- return this.SetNewPath(ofd.FileName, destFolder, specificFolder, filename);
+ if (!File.Exists(destFolder + filename) || fileOnDirectory)
+ return SetNewPath(ofd.FileName, destFolder, specificFolder, filename);
var overwriteResult = MessageBox.Show("带有名称的文件 " + filename + " 已经存在。 你想覆盖它吗?", "警告", MessageBoxButtons.YesNoCancel);
if (overwriteResult == DialogResult.Yes)
- return this.SetNewPath(ofd.FileName, destFolder, specificFolder, filename, true);
+ return SetNewPath(ofd.FileName, destFolder, specificFolder, filename, true);
}
return null;
@@ -172,7 +385,7 @@ namespace CLEngine.Editor.viewmodel
bool fileOnDirectory = srcPath.StartsWith(SceneManager.GameProject.ProjectPath);
if (!fileOnDirectory)
- System.IO.File.Copy(srcPath, destFolder + filename, overwrite);
+ File.Copy(srcPath, destFolder + filename, overwrite);
string relativePath = (@"\Content\" + specificFolder + filename).Trim();
if (fileOnDirectory)
@@ -195,8 +408,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);
}
@@ -206,5 +423,18 @@ namespace CLEngine.Editor.viewmodel
var item = ItemManager.CreateItem("物品" + ItemManager.WorldId);
ItemObjects.Add(item);
}
- }
+
+ ///
+ /// 创建脚本
+ ///
+ private void CreateScriptAction()
+ {
+ var FileName = DataBaseWindow.Instance.FileNameInput.Text;
+ var path = Path.Combine(SceneManager.GameProject.ProjectPath, "Scripts");
+ var ScriptName = Path.Combine(path, FileName);
+ if (!File.Exists(ScriptName))
+ {
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/CLEditor/windows/CustomPropWindow.xaml b/CLEditor/windows/CustomPropWindow.xaml
new file mode 100644
index 0000000000000000000000000000000000000000..49e1f981a745d1188f8fad57e2e9900582f0efd0
--- /dev/null
+++ b/CLEditor/windows/CustomPropWindow.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/CLEditor/windows/CustomPropWindow.xaml.cs b/CLEditor/windows/CustomPropWindow.xaml.cs
new file mode 100644
index 0000000000000000000000000000000000000000..a461e784f6a3ab20da3d56759a2dfd2d9f4e2e7d
--- /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 a757d1ac93e034e9517496f32b620b251bbc1872..68d4e08502a58b40a401d56226ab4c90a3c0cfa5 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">
@@ -19,88 +17,115 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CLEditor/windows/DataBaseWindow.xaml.cs b/CLEditor/windows/DataBaseWindow.xaml.cs
index b92d9a7d37ffb17798f34922be5c5a96134da1ce..ba40b4d3248c20e425b88b3e03005920671af03a 100644
--- a/CLEditor/windows/DataBaseWindow.xaml.cs
+++ b/CLEditor/windows/DataBaseWindow.xaml.cs
@@ -10,12 +10,12 @@ namespace CLEngine.Editor.windows
///
public partial class DataBaseWindow : Window
{
- public static ListBox ItemListInstance;
+ public static DataBaseWindow Instance;
public DataBaseWindow()
{
InitializeComponent();
- ItemListInstance = ItemList;
+ Instance = this;
ClassificationComboBox.SelectionChanged += ClassificationComboBoxOnSelectionChanged;
ItemList.SelectionChanged += ItemListOnSelectionChanged;
}
diff --git a/CLEditor/windows/SelectScriptWindow.xaml b/CLEditor/windows/SelectScriptWindow.xaml
new file mode 100644
index 0000000000000000000000000000000000000000..d1122b93b57997c2aa2e6f2871a52a0e54e86dc6
--- /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 0000000000000000000000000000000000000000..78af43af9ca983393cabb42b9339d2977951ecfd
--- /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/CLEditor/windows/SettingsWindow.xaml.cs b/CLEditor/windows/SettingsWindow.xaml.cs
index aa52a0d3af9a4324f5aef0b2356142621dd75f59..a6dff1886635cae293cad67d55932da5f14d7818 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/Audio.cs b/Engine/CLEngine.Core/Audio.cs
index 56f53ba7f7f8f22f3d3394923a67bcdb1d88cc60..55f2a7d8594a921d3de14a1c1ecbd23f42461296 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/Engine/CLEngine.Core/CLEngine.Core.csproj b/Engine/CLEngine.Core/CLEngine.Core.csproj
index 95e34c7299c659cdb82b296af9671c81f344b648..967fdd31c96a6af315d380d298f124ab50aed521 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
@@ -296,7 +299,10 @@
+
+
+
@@ -349,7 +355,6 @@
-
@@ -453,7 +458,6 @@
-
@@ -608,6 +612,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/Engine/CLEngine.Core/framework/EventObject.cs b/Engine/CLEngine.Core/framework/EventObject.cs
index 988ac0aba123b5b055190723d2e544adeb911108..4ac808cf99fe864f7f7ea36b180ec3c1d3c3db13 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;
@@ -30,6 +34,44 @@ namespace CLEngine.Core.framework
[DataMember] private Dictionary _state;
[DataMember] private SkillObject _onSkill;
+ ///
+ /// 触发使用技能事件,处理
+ ///
+ ///
+ public void UseSkill(string name)
+ {
+ var skill = _skill[name];
+
+ if (skill == null)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.NotFound));
+ return;
+ }
+ if (skill.CurrentTime > 0)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.Cd));
+ return;
+ }
+ if (_mp < skill.UseMp)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.NoMp));
+ return;
+ }
+ if (_hp < skill.UseHp)
+ {
+ if (GameEvent.UseSkill != null)
+ GameEvent.UseSkill.Invoke(this, new SkillUseEventArgs(name, SkillEventType.NoHp));
+ return;
+ }
+
+ _mp -= skill.UseMp;
+ _hp -= skill.UseHp;
+ skill.CurrentTime = skill.CoolingTime;
+ skill.TrigUse();
+ }
///
/// 添加技能
///
@@ -129,7 +171,7 @@ namespace CLEngine.Core.framework
///
/// 事件名
///
- 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/FrameworkManager.cs b/Engine/CLEngine.Core/framework/FrameworkManager.cs
index 8f141203f65ab8abe476aa60e9d560f8959836ec..61c54814cd516737d31a68d2955ff9c36258f862 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/FrameworkSettings.cs b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
index 3a6db8c47faa4247238a43c14d950598e9411636..31f8494a309e766b945cb468fc91b4a0ccb08518 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/GameEvent.cs b/Engine/CLEngine.Core/framework/GameEvent.cs
new file mode 100644
index 0000000000000000000000000000000000000000..8b32f9756c7e0c5a995bc8b275861f41e4b93c61
--- /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/IGlobalEvent.cs b/Engine/CLEngine.Core/framework/IGlobalEvent.cs
new file mode 100644
index 0000000000000000000000000000000000000000..d50f2126dfd3f14dcc66bf2dafff89cc04f52306
--- /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 0000000000000000000000000000000000000000..9abdc2988a9aeabb3e97a61f91158c25f079c1aa
--- /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 169e638045211ad2b9a857076726241e4014cc7b..616c182f711787bf21b2acbe7055a03e900a8db6 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 52d15b1f5b74ccd218a233dd361e187f4c712387..a88cfded691012d6f027d0c8317033a1ff4dc3c8 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;
@@ -106,12 +71,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
@@ -383,6 +353,7 @@ namespace CLEngine.Core.framework
/// 物品名称
public ItemObject(string name = "")
{
+ ScriptList = new List();
BagPosition = Vector2.Zero;
Name = name;
}
@@ -414,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 b9d00924b29fc3928d09441ce1c273e3a0574f8a..a577e5c287c2989fc202e64a7c52b2b882be481e 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/SkillObject.cs b/Engine/CLEngine.Core/framework/SkillObject.cs
index b2b1834db2cdd51d46107cbee11e847d5a742a7a..a7a075dea998f717b3af7e50f68e6548e3788c9e 100644
--- a/Engine/CLEngine.Core/framework/SkillObject.cs
+++ b/Engine/CLEngine.Core/framework/SkillObject.cs
@@ -2,26 +2,49 @@
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,16 +63,21 @@ 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;
[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; } }
@@ -151,7 +179,13 @@ namespace CLEngine.Core.framework
///
public enum SkillType
{
+ ///
+ ///
+ ///
Consumable,
+ ///
+ ///
+ ///
Bullet
}
///
@@ -159,8 +193,17 @@ namespace CLEngine.Core.framework
///
public enum TargetType
{
+ ///
+ ///
+ ///
Self,
+ ///
+ ///
+ ///
Enemy,
+ ///
+ ///
+ ///
Friendly
}
///
@@ -168,8 +211,17 @@ namespace CLEngine.Core.framework
///
public enum ReleasePosition
{
+ ///
+ ///
+ ///
Self,
+ ///
+ ///
+ ///
Target,
+ ///
+ ///
+ ///
Mouse
}
///
diff --git a/Engine/CLEngine.Core/framework/StateManager.cs b/Engine/CLEngine.Core/framework/StateManager.cs
index 34572bf3965c2438431ba4c9aa83c66b2e8d2318..7ea38de20c048fdb63d26ce842828bf75a32c036 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/framework/StateObject.cs b/Engine/CLEngine.Core/framework/StateObject.cs
index 73586c2052cc34f9af07a43e32187439ae642fe0..64b49c4d7b1263ae3c46fb6c5ba7b9fbd1fc4b5e 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
///
diff --git a/Engine/CLEngine.Core/gameObjects/LuaObject.cs b/Engine/CLEngine.Core/gameObjects/LuaObject.cs
index 07bc118096365c4b2a868468706ae203250d01c8..0988b4ba43eb976077335dba55355775de28b7c7 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();
diff --git a/Engine/CLEngine.Core/gui/Core/Stage.cs b/Engine/CLEngine.Core/gui/Core/Stage.cs
index ec007decacc4a8f7dea8e6c0decd526470659e6a..89b3622e33378f2cf3e1f51815762177b47eb12b 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 435d19b8d6fb709f923f304a0f9a2760823d2181..0000000000000000000000000000000000000000
--- 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/network/ServerList.cs b/Engine/CLEngine.Core/network/ServerList.cs
deleted file mode 100644
index 2b86d3c2eacc8664d87de1cc8786d0403fff4285..0000000000000000000000000000000000000000
--- 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
diff --git a/Engine/CLEngine.Core/packages.config b/Engine/CLEngine.Core/packages.config
index 6069e76b0c91737e7f0b7a334d6db1eba7ff02ab..06b62c15baf329e107e70de4e5c9bae02bcc83e7 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 e0e7936c6e0b745f04d22971ee50fccbe31108ce..503a61599fba47fa8fe1abe44e1f89f23885f363 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();
}
diff --git a/WebPage/index.html b/WebPage/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..f3a37947dbfd73dc8e50a387cea019f9a7f3ecfe
--- /dev/null
+++ b/WebPage/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ CLEngine首页
+
+
+
+
+
+ 当前任务
+ 更新4038版本
+
+
+
+
+
+
+
+
+
\ No newline at end of file