diff --git a/CLEditor/CLEditor.csproj b/CLEditor/CLEditor.csproj index 8d4dfbcedc8db33d0c2b98a555bc0eb769d4b70f..41a90a7bd474e01e61829e89b451ca08e88998e0 100644 --- a/CLEditor/CLEditor.csproj +++ b/CLEditor/CLEditor.csproj @@ -204,6 +204,7 @@ ResourceManagerView.xaml + SceneManageView.xaml diff --git a/CLEditor/Core/EditorUtil.cs b/CLEditor/Core/EditorUtil.cs index c2d22ba7b0bc76f3d071e79c0ee23cc26500b6f8..fd5846033cd54e9407f3614694c96d989cfc7718 100644 --- a/CLEditor/Core/EditorUtil.cs +++ b/CLEditor/Core/EditorUtil.cs @@ -22,19 +22,8 @@ namespace CLEditor.Core "libbulletc-linux-x86.so", "libbulletc-windows-x64.dll", "libbulletc-windows-x86.dll", - "MonoGame.Framework.Content.Pipeline.dll", - "MonoGame.Framework.dll", "Newtonsoft.Json.dll", "NLua.dll", - "SharpDX.Direct2D1.dll", - "SharpDX.Direct3D9.dll", - "SharpDX.Direct3D11.dll", - "SharpDX.dll", - "SharpDX.DXGI.dll", - "SharpDX.MediaFoundation.dll", - "SharpDX.RawInput.dll", - "SharpDX.XAudio2.dll", - "SharpDX.XInput.dll", "x86/lua52.dll", "x64/lua52.dll", }; @@ -46,15 +35,6 @@ namespace CLEditor.Core "libbulletc-windows-x86.dll", "x86/lua52.dll", "x64/lua52.dll", - "SharpDX.Direct2D1.dll", - "SharpDX.Direct3D9.dll", - "SharpDX.Direct3D11.dll", - "SharpDX.dll", - "SharpDX.DXGI.dll", - "SharpDX.MediaFoundation.dll", - "SharpDX.RawInput.dll", - "SharpDX.XAudio2.dll", - "SharpDX.XInput.dll", }; public static List ContentList = new List diff --git a/CLEditor/CreateProjectView.xaml b/CLEditor/CreateProjectView.xaml index 6e356f645b62190e1246f8db788256e504490f97..bb2e185f1083cdc7218725b3b386cb0be9b57dbd 100644 --- a/CLEditor/CreateProjectView.xaml +++ b/CLEditor/CreateProjectView.xaml @@ -3,6 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:rules="clr-namespace:CLEditor.Rules" mc:Ignorable="d" Style="{StaticResource {x:Type Window}}" DataContext="{Binding Source={StaticResource Locator}, Path=Project}" @@ -33,6 +34,32 @@ Height="25" Command="{Binding SelectProejctPathCommand}"> + + + + + + + + + + + + + + + + + + diff --git a/CLEditor/EditorSettings/IPublishSettings.cs b/CLEditor/EditorSettings/IPublishSettings.cs index a1baad97321701aa0393ff004f7653429485dca5..fd0b51a285b65ebb23396980868817181267ac02 100644 --- a/CLEditor/EditorSettings/IPublishSettings.cs +++ b/CLEditor/EditorSettings/IPublishSettings.cs @@ -3,9 +3,11 @@ public enum Platform { Windows, - DestopGL, + DesktopGL, Android, - IOS, + Windows8, + WindowsPhone81, + WindowsUniversal } public interface IPublishSettings diff --git a/CLEditor/EditorSettings/PublishSetting.cs b/CLEditor/EditorSettings/PublishSetting.cs index 7c44c115fb54e00fce56f9b43ec5c2298a80e1a3..859778cf8e05900f2db84c2d4771ef1377905761 100644 --- a/CLEditor/EditorSettings/PublishSetting.cs +++ b/CLEditor/EditorSettings/PublishSetting.cs @@ -11,7 +11,7 @@ namespace CLEditor.EditorSettings { if (string.IsNullOrEmpty(Settings.Default.platform)) { - Settings.Default.platform = Platform.DestopGL.ToString(); + Settings.Default.platform = Platform.DesktopGL.ToString(); } return (Platform) Enum.Parse(typeof(Platform), Settings.Default.platform); diff --git a/CLEditor/Rules/MonoGameDirectoryExistRule.cs b/CLEditor/Rules/MonoGameDirectoryExistRule.cs new file mode 100644 index 0000000000000000000000000000000000000000..d364f9e02a46ba4fb497bea41e1da53262788649 --- /dev/null +++ b/CLEditor/Rules/MonoGameDirectoryExistRule.cs @@ -0,0 +1,42 @@ +using System.Globalization; +using System.IO; +using System.Windows.Controls; + +namespace CLEditor.Rules +{ + public class MonoGameDirectoryExistRule : ValidationRule + { + public override ValidationResult Validate(object value, CultureInfo cultureInfo) + { + if (value == null) + { + return new ValidationResult(false, "路径为空"); + } + + value = Path.Combine(value.ToString(), "Assemblies", "DesktopGL"); + + if (!Directory.Exists(value.ToString())) + { + return new ValidationResult(false, "不存在文件夹"); + } + + var fileInfo = new FileInfo(value.ToString()); + + if (fileInfo.Attributes != FileAttributes.Directory) + { + return new ValidationResult(false, "这不是一个有效文件夹"); + } + + foreach (var file in Directory.GetFiles(value.ToString(), "*.dll", SearchOption.AllDirectories)) + { + var info = new FileInfo(file); + if (info.Name.Contains("MonoGame.Framework.dll")) + { + return new ValidationResult(true, null); + } + } + + return new ValidationResult(false, "未找到monogame的有效文件"); + } + } +} \ No newline at end of file diff --git a/CLEditor/Themes/Styles.xaml b/CLEditor/Themes/Styles.xaml index 07d410d97fce0859bd015e544d88bca4b7a2eada..4b1471aab458d6e174a2c2f134dc4d5cb1fa52d8 100644 --- a/CLEditor/Themes/Styles.xaml +++ b/CLEditor/Themes/Styles.xaml @@ -805,6 +805,12 @@ + + + + + + diff --git a/CLEditor/ViewModel/ProjectViewModel.cs b/CLEditor/ViewModel/ProjectViewModel.cs index 92188b1824b4ecfeb65d17dfb54c29c8cb7b3f5e..d54decc8acfd8b23fe8bc23f52df527b56f46346 100644 --- a/CLEditor/ViewModel/ProjectViewModel.cs +++ b/CLEditor/ViewModel/ProjectViewModel.cs @@ -4,10 +4,13 @@ using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Threading; +using System.Windows.Controls; using System.Windows.Forms; using System.Windows.Input; using CLEditor.CodeGenerator; using CLEditor.Core; +using CLEditor.EditorSettings; +using CLEditor.Properties; using CommonServiceLocator; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.CommandWpf; @@ -25,6 +28,19 @@ namespace CLEditor.ViewModel { public ICommand CreateProejctCommand { get; set; } public ICommand SelectProejctPathCommand { get; set; } + public ICommand SelectMonoGamePathCommand { get; set; } + + private string _monoGamePath; + + public string MonoGamePath + { + get { return _monoGamePath; } + set + { + _monoGamePath = value; + RaisePropertyChanged(() => MonoGamePath); + } + } private string _projectPath; public string ProjectPath @@ -52,8 +68,20 @@ namespace CLEditor.ViewModel { CreateProejctCommand = new RelayCommand(CreateProejctExecute); SelectProejctPathCommand = new RelayCommand(SelectProjectExecute); + SelectMonoGamePathCommand = new RelayCommand(SelectMonoGameExeceute); ProjectName = "CLGame"; + MonoGamePath = "C:\\Program Files (x86)\\MonoGame\\v3.0"; + } + + private void SelectMonoGameExeceute() + { + var folderSelect = new FolderBrowserDialog(); + var result = folderSelect.ShowDialog(); + if (result == DialogResult.OK) + { + MonoGamePath = folderSelect.SelectedPath; + } } private void SelectProjectExecute() @@ -68,6 +96,11 @@ namespace CLEditor.ViewModel private void CreateProejctExecute() { + if (Validation.GetHasError(CreateProjectView.GetInstance().MonoGameTextBox)) + { + return; + } + try { if (string.IsNullOrEmpty(ProjectPath)) @@ -88,16 +121,18 @@ namespace CLEditor.ViewModel project.FullPath = projectFile; project.SetProperty("RootNamespace", ProjectName); - project.SetProperty("ProjectGuid", Guid.NewGuid().ToString()); + project.SetProperty("ProjectGuid", string.Concat("{", Guid.NewGuid().ToString(), "}")); project.SetProperty("OutputType", "WinExe"); project.SetProperty("AssemblyName", ProjectName); + project.SetProperty("ProductVersion", "8.0.30703"); + project.SetProperty("SchemaVersion", "2.0"); project.SetProperty("TargetFrameworkVersion", "v4.5"); + project.SetProperty("AppDesignerFolder", "Properties"); project.SetProperty("MonoGamePlatform", "DesktopGL"); - project.SetProperty("ProjectTypeGuids", Guid.NewGuid().ToString()); project.SetProperty("WarningLevel", "4"); var debugConfig = project.SetProperty("Configuration", "Debug"); debugConfig.Xml.Condition = "'$(Configuration)' == ''"; - var platformProperty = project.SetProperty("Platform", "AnyCPU"); + var platformProperty = project.SetProperty("Platform", "x86"); platformProperty.Xml.Condition = "'$(Platform)' == ''"; project.AddItem("Reference", "System"); @@ -109,6 +144,7 @@ namespace CLEditor.ViewModel CopyReference(ref project); ChangeMgcbResource(); GenerateMainCode(ref project); + GenerateMonoGameReference(ref project); model.Project = project; // 初始化工程 @@ -122,21 +158,32 @@ namespace CLEditor.ViewModel { projectElement.AddImport("$(MSBuildToolsPath)\\Microsoft.CSharp.targets"); projectElement.AddImport("$(MSBuildExtensionsPath)\\MonoGame\\v3.0\\MonoGame.Content.Builder.targets"); - var element = projectElement.AddImport("$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props"); - element.Condition = "Exists('$(MSBuildExtensionsPath)\\$(MSBuildToolsVersion)\\Microsoft.Common.props')"; + var element = projectElement.AddImport("$(MSBuildExtensionsPath)\\MonoGame\\v3.0\\MonoGame.Common.props"); + element.Condition = "Exists('$(MSBuildExtensionsPath)\\MonoGame\v3.0\\MonoGame.Common.props')"; var platGroup = projectElement.AddPropertyGroup(); - platGroup.Condition = "'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"; + platGroup.Condition = "'$(Configuration)|$(Platform)' == 'Debug|x86'"; - platGroup.AddProperty("PlatformTarget", "AnyCPU"); + platGroup.AddProperty("PlatformTarget", "x86"); platGroup.AddProperty("DebugSymbols", "true"); platGroup.AddProperty("DebugType", "full"); platGroup.AddProperty("Optimize", "false"); platGroup.AddProperty("OutputPath", "Build\\"); - platGroup.AddProperty("DefineConstants", "DEBUG;TRACE"); + platGroup.AddProperty("DefineConstants", "DEBUG;TRACE;WINDOWS"); platGroup.AddProperty("ErrorReport", "prompt"); platGroup.AddProperty("WarningLevel", "4"); + var releaseGroup = projectElement.AddPropertyGroup(); + releaseGroup.Condition = "'$(Configuration)|$(Platform)' == 'Release|x86'"; + + releaseGroup.AddProperty("PlatformTarget", "x86"); + releaseGroup.AddProperty("DebugType", "pdbonly"); + releaseGroup.AddProperty("Optimize", "true"); + releaseGroup.AddProperty("OutputPath", "Build\\"); + releaseGroup.AddProperty("DefineConstants", "TRACE;WINDOWS"); + releaseGroup.AddProperty("ErrorReport", "prompt"); + releaseGroup.AddProperty("WarningLevel", "4"); + var iconGroup = projectElement.AddPropertyGroup(); iconGroup.AddProperty("ApplicationIcon", "logo64-64.ico"); } @@ -155,6 +202,18 @@ namespace CLEditor.ViewModel } } + private void GenerateMonoGameReference(ref Project project) + { + var platform = Settings.Default.platform ?? Platform.DesktopGL.ToString(); + var monogameContent = Path.Combine(MonoGamePath, "Assemblies", platform); + if (Directory.Exists(monogameContent)) + { + //EditorUtil.CopyDirectory(monogameContent, project.DirectoryPath); + // TODO: 拷贝文件至目录 CopyDirectory不满足 需要新方法 + // TODO: 文件添加至项目引用 + } + } + private void CopyOtherContent(ref Project project) { foreach (var otherContent in EditorUtil.OtherContentList) @@ -269,6 +328,16 @@ namespace CLEditor.ViewModel initMethod.Statements.Add(new CodeSnippetStatement("Script.DoFile(\"Scripts / core.lua\");")); cla.Members.Add(initMethod); + var updateMethod = generate.GeneratorMethod("Update"); + updateMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public; + updateMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(GameTime), "gameTime")); + cla.Members.Add(updateMethod); + + var drawMethod = generate.GeneratorMethod("Draw"); + drawMethod.Attributes = MemberAttributes.Override | MemberAttributes.Public; + drawMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(GameTime), "gameTime")); + cla.Members.Add(drawMethod); + var importAssemblyMethod = generate.GeneratorMethod("ImportAssembly"); importAssemblyMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "assembly")); importAssemblyMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(string), "nameSpace")); diff --git a/CLPipleline/bin/Debug/CLPipleline.dll b/CLPipleline/bin/Debug/CLPipleline.dll index d7532c8f8e5e5f70da55b6d5192f7879a35c481b..fc7d59d8464e3f7dc51e0027204b8eec3bb58ed2 100644 Binary files a/CLPipleline/bin/Debug/CLPipleline.dll and b/CLPipleline/bin/Debug/CLPipleline.dll differ diff --git a/CLPipleline/bin/Debug/CLPipleline.pdb b/CLPipleline/bin/Debug/CLPipleline.pdb index ff42f2a19a92c13aabc656cd8c41a6de1093d55f..1cc70eb1f2c9dbdbfc3fdee974df47cfc68ec2fb 100644 Binary files a/CLPipleline/bin/Debug/CLPipleline.pdb and b/CLPipleline/bin/Debug/CLPipleline.pdb differ diff --git a/SceneEditor/SceneEditor.csproj b/SceneEditor/SceneEditor.csproj index 4b9363bb973779a644567051ce5adb21ce84cc85..380f132fd2272890b8d39df2ed6b22e7900ccc1f 100644 --- a/SceneEditor/SceneEditor.csproj +++ b/SceneEditor/SceneEditor.csproj @@ -12,7 +12,7 @@ SceneEditor SceneEditor 512 - Windows + DesktopGL v4.5