From 8947f2ce8beaae1c2b64cac5d193783d1eb2dd00 Mon Sep 17 00:00:00 2001 From: "SND\\eagleeyestudios_cp" Date: Sat, 8 Sep 2012 22:03:13 +0000 Subject: [PATCH] Content Compiler: - Added Folder Feature -> You can now add Folders to a project (this was a hard, buggy one *phew*) - Set Enter-Key as default for OK or Next in Dialogues - Added missing Open/Add functionality in the Menustate --- .../ANX.ContentCompiler.GUI.csproj | 9 +++ .../Dialogues/OpenProjectScreen.Designer.cs | 39 ++++----- .../Dialogues/OpenProjectScreen.resx | 4 +- Tools/ANXContentCompilerGUI/MainWindow.cs | 74 ++++++++++++++---- .../Resources/appbar.new.png | Bin 0 -> 953 bytes .../Resources/appbar.new.window.png | Bin 0 -> 402 bytes .../States/EditingState.Designer.cs | 1 + .../States/EditingState.cs | 12 +++ .../States/MenuState.Designer.cs | 2 +- .../ANXContentCompilerGUI/States/MenuState.cs | 29 +++++-- .../States/MenuState.resx | 4 +- .../TreeViewExtensions.cs | 3 - 12 files changed, 130 insertions(+), 47 deletions(-) create mode 100644 Tools/ANXContentCompilerGUI/Resources/appbar.new.png create mode 100644 Tools/ANXContentCompilerGUI/Resources/appbar.new.window.png diff --git a/Tools/ANXContentCompilerGUI/ANX.ContentCompiler.GUI.csproj b/Tools/ANXContentCompilerGUI/ANX.ContentCompiler.GUI.csproj index 166e62bc..9cdf8e61 100644 --- a/Tools/ANXContentCompilerGUI/ANX.ContentCompiler.GUI.csproj +++ b/Tools/ANXContentCompilerGUI/ANX.ContentCompiler.GUI.csproj @@ -61,6 +61,12 @@ RibbonButton.cs + + Form + + + NewFolderScreen.cs + Form @@ -131,6 +137,9 @@ RibbonButton.cs + + NewFolderScreen.cs + OpenProjectScreen.cs diff --git a/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.Designer.cs b/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.Designer.cs index 263c01ab..76d2f0b2 100644 --- a/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.Designer.cs +++ b/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.Designer.cs @@ -32,12 +32,12 @@ this.buttonNext = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.listBoxRecentProjects = new System.Windows.Forms.ListBox(); this.buttonBrowse = new System.Windows.Forms.Button(); this.textBoxLocation = new System.Windows.Forms.TextBox(); this.labelManualSearch = new System.Windows.Forms.Label(); this.labelHeading = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.listBoxRecentProjects = new System.Windows.Forms.ListBox(); this.panel1.SuspendLayout(); this.SuspendLayout(); // @@ -104,6 +104,24 @@ this.panel1.Size = new System.Drawing.Size(600, 359); this.panel1.TabIndex = 14; // + // listBoxRecentProjects + // + this.listBoxRecentProjects.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.listBoxRecentProjects.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.listBoxRecentProjects.ForeColor = System.Drawing.Color.LightGray; + this.listBoxRecentProjects.FormattingEnabled = true; + this.listBoxRecentProjects.Items.AddRange(new object[] { + "Test", + "Blubb", + "Put", + "Recent", + "Projects", + "here"}); + this.listBoxRecentProjects.Location = new System.Drawing.Point(71, 96); + this.listBoxRecentProjects.Name = "listBoxRecentProjects"; + this.listBoxRecentProjects.Size = new System.Drawing.Size(443, 119); + this.listBoxRecentProjects.TabIndex = 21; + // // buttonBrowse // this.buttonBrowse.DialogResult = System.Windows.Forms.DialogResult.OK; @@ -158,26 +176,9 @@ this.label1.Text = "New Project"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // listBoxRecentProjects - // - this.listBoxRecentProjects.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.listBoxRecentProjects.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.listBoxRecentProjects.ForeColor = System.Drawing.Color.LightGray; - this.listBoxRecentProjects.FormattingEnabled = true; - this.listBoxRecentProjects.Items.AddRange(new object[] { - "Test", - "Blubb", - "Put", - "Recent", - "Projects", - "here"}); - this.listBoxRecentProjects.Location = new System.Drawing.Point(71, 96); - this.listBoxRecentProjects.Name = "listBoxRecentProjects"; - this.listBoxRecentProjects.Size = new System.Drawing.Size(443, 119); - this.listBoxRecentProjects.TabIndex = 21; - // // OpenProjectScreen // + this.AcceptButton = this.buttonNext; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); diff --git a/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.resx b/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.resx index 5ea0895e..29dcb1b3 100644 --- a/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.resx +++ b/Tools/ANXContentCompilerGUI/Dialogues/OpenProjectScreen.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/Tools/ANXContentCompilerGUI/MainWindow.cs b/Tools/ANXContentCompilerGUI/MainWindow.cs index 34433800..c797f346 100644 --- a/Tools/ANXContentCompilerGUI/MainWindow.cs +++ b/Tools/ANXContentCompilerGUI/MainWindow.cs @@ -184,10 +184,10 @@ namespace ANX.ContentCompiler.GUI var absPath = ProjectFolder + Path.DirectorySeparatorChar + folder + Path.DirectorySeparatorChar + Path.GetFileName(file); if (!Directory.Exists(Path.Combine(ProjectFolder, folder))) Directory.CreateDirectory(Path.Combine(ProjectFolder, folder)); - File.Copy(file, absPath); + File.Copy(file, absPath, true); var item = new BuildItem { - AssetName = String.IsNullOrEmpty(folder) ? folder.Replace(_contentProject.ContentRoot, "") + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file) : Path.GetFileNameWithoutExtension(file), + AssetName = !String.IsNullOrEmpty(folder) ? folder.Replace(_contentProject.ContentRoot + Path.DirectorySeparatorChar, "") + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file) : Path.GetFileNameWithoutExtension(file), SourceFilename = absPath, OutputFilename = ProjectOutputDir + Path.DirectorySeparatorChar + folder + Path.DirectorySeparatorChar + Path.GetFileName(file), ImporterName = ImporterManager.GuessImporterByFileExtension(file) @@ -203,6 +203,35 @@ namespace ANX.ContentCompiler.GUI } ChangeEnvironmentOpenProject(); } + + public void AddFolder(string name) + { + string folder = _contentProject.ContentRoot; + var node = treeView.SelectedNode; + if (node != null) + folder = node.Name; + else + node = treeView.Nodes[0]; + + var newFolder = new TreeNode(name) { Name = folder + Path.DirectorySeparatorChar + name}; + node.Nodes.Add(newFolder); + + } + + public void RemoveFile(string name) + { + + } + + public void RemoveFiles(string[] files) + { + + } + + public void RemoveFolder(string name) + { + + } #endregion #region EnvironmentStates @@ -228,20 +257,29 @@ namespace ANX.ContentCompiler.GUI var rootNode = new TreeNode(ProjectName + "(" + _contentProject.ContentRoot + ")") {Name = _contentProject.ContentRoot}; treeView.Nodes.Add(rootNode); var lastNode = rootNode; - foreach (var parts in _contentProject.BuildItems.Select(buildItem => buildItem.AssetName.Split('/')).Where(parts => parts.Length >= 2)) + foreach (var parts in _contentProject.BuildItems.Select(buildItem => buildItem.AssetName.Split(Path.DirectorySeparatorChar)).Where(parts => parts.Length >= 2)) { + string folder = ""; + string parent = _contentProject.ContentRoot; for (int i=0; i < parts.Length - 1; i++) { - var node = new TreeNode(parts[i]) {Name = lastNode.Name + "/" + parts[i] + "/"}; - if (!lastNode.Nodes.Contains(node)) - { - lastNode.Nodes.Add(node); - lastNode = node; - } + if (parts[i] == null) continue; + if (i > 0) + folder += Path.DirectorySeparatorChar + parts[i]; else - { - lastNode = lastNode.Nodes[parts[i]]; - } + folder = parts[0]; + + + if (parts.Length > 2 && i < parts.Length -2) + parent += Path.DirectorySeparatorChar + parts[i]; + //else if (parts.Length == 2) + // parent += Path.DirectorySeparatorChar + parts[0]; + } + lastNode = treeView.RecursiveSearch(parent); + var node = new TreeNode(parts[parts.Length - 2]) { Name = _contentProject.ContentRoot + Path.DirectorySeparatorChar + folder }; + if (!ContainsTreeNode(lastNode, node)) + { + lastNode.Nodes.Add(node); } lastNode = rootNode; } @@ -261,15 +299,15 @@ namespace ANX.ContentCompiler.GUI lastNode = lastNode.Nodes[parts[i]]; } }*/ - string path = ""; + string path = _contentProject.ContentRoot; if (parts != null) { for (int i = 0; i < parts.Length - 1; i++) { - path = parts[i]; + path += String.IsNullOrEmpty(path) ? parts[i] : Path.DirectorySeparatorChar + parts[i]; } } - if (!String.IsNullOrEmpty(path)) + if (parts != null) { var node = treeView.RecursiveSearch(path); if (node == null) throw new ArgumentNullException("Node not found!"); @@ -412,6 +450,12 @@ namespace ANX.ContentCompiler.GUI } } } + + private bool ContainsTreeNode(TreeNode haystack, TreeNode needle) + { + return haystack.Nodes.Cast().Any(node => node.Name.Equals(needle.Name)); + } + #endregion #region PropertyGridEvents diff --git a/Tools/ANXContentCompilerGUI/Resources/appbar.new.png b/Tools/ANXContentCompilerGUI/Resources/appbar.new.png new file mode 100644 index 0000000000000000000000000000000000000000..efe8a35eb56a930ae510bf0835246a0756bb9509 GIT binary patch literal 953 zcmV;q14jIbP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D15QaqK~!i%?U+qy z6G0Tmn-G*zB~?W5pccUo6hy_M9+cu$5D^8vMG!$xBK6`a2SHHqR28rFAnL_~fYx}%)7*p=c*StK=pEki_tdmS8qkwv-^D67p@+&#U zv)SxGD_q*d$%Q+{AUajd=kv=!^j1fL{5a&;XFuUVbh7L5uZis;y!+J+P)e#oAm!di z=e=p%ck1{yed_vdrHnSQO2|m)FqPWB;Aw@}=Fow3Vi1JKHDQu)YQM7w_$u=Qot$N) z3y@Lb`eeCW-t@Odr4X55o>7Tm!QN@cNFTm#X%js!NY_k;ikU+}r}BsF>R*hhY}t0Y=+|Jn-> z>q8m>y6d)+55^z$#>7*pR7|eDgvNIlk(ACTGV-4c`Bqk+0yfUeo-vS46*+uRDvr{? z5?(f)o*?;v&aK(m*;SpMADX^&Soubf&qyBv!^lijDwS=a9c&F*4_FUa4_FUa4_FWM b&;!2#s^!stI$uJp00000NkvXXu0mjfrh>9h literal 0 HcmV?d00001 diff --git a/Tools/ANXContentCompilerGUI/Resources/appbar.new.window.png b/Tools/ANXContentCompilerGUI/Resources/appbar.new.window.png new file mode 100644 index 0000000000000000000000000000000000000000..235cbf2d2f7e732ec4edfdb1fd473319a4a855b3 GIT binary patch literal 402 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!26ayt$B+!?x6=&ynhkhd7YdiZxL5rpV6RL6 ziFRHaIY_z>yEfo8SLFgcr`_$gJdauPL}T zDcZJ8``;F}Ag9xtV&)bXubZxuaqZTR7e9?Vv^&jLIxPO>{BfVqdW+|h+5sZ_*S&t5 z&$eSrQLgX__K%9kSMpvtqRzJOYEZ0Dl0Mu zUmj0C6&Dqh_TK5;qCZb&ar~tUD`t`Fvzi};o_FZB%;e$m==^$5|J}oT@&0of@2R@l g2{16iku{TiO0)0E22.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 If you want to use your existing XNA Contentproject you need to choose the Import option. Also the Import option is required when trying to open files created by the EES Content Compiler 3. diff --git a/Tools/ANXContentCompilerGUI/TreeViewExtensions.cs b/Tools/ANXContentCompilerGUI/TreeViewExtensions.cs index 9ce8bc9c..89f6a67a 100644 --- a/Tools/ANXContentCompilerGUI/TreeViewExtensions.cs +++ b/Tools/ANXContentCompilerGUI/TreeViewExtensions.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Windows.Forms; namespace ANX.ContentCompiler.GUI