Content Compiler 3:

- Added ability to save project using CTRL+S
- Fixed version label in menu state
- Added Preview screen (empty for now)
- Improved selection & folder handling
This commit is contained in:
SND\eagleeyestudios_cp 2012-09-22 17:44:30 +00:00 committed by Konstantin Koch
parent 6aea2f0fc4
commit 4c50fcd91d
8 changed files with 226 additions and 13 deletions

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@ -138,6 +142,12 @@
<Compile Include="Dialogues\FirstStartScreen.Designer.cs">
<DependentUpon>FirstStartScreen.cs</DependentUpon>
</Compile>
<Compile Include="Dialogues\PreviewScreen.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Dialogues\PreviewScreen.Designer.cs">
<DependentUpon>PreviewScreen.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -177,6 +187,12 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TreeViewExtensions.cs" />
<EmbeddedResource Include="Dialogues\PreviewScreen.resx">
<DependentUpon>PreviewScreen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainWindow.resx">
<DependentUpon>MainWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
@ -186,6 +202,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ShowStrings.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="States\EditingState.resx">
<DependentUpon>EditingState.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View File

@ -0,0 +1,103 @@
namespace ANX.ContentCompiler.GUI.Dialogues
{
partial class PreviewScreen
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonQuit = new System.Windows.Forms.Button();
this.labelTitle = new System.Windows.Forms.Label();
this.drawSurface = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// buttonQuit
//
this.buttonQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonQuit.FlatAppearance.BorderSize = 0;
this.buttonQuit.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.buttonQuit.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Gray;
this.buttonQuit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonQuit.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.buttonQuit.ForeColor = System.Drawing.Color.White;
this.buttonQuit.Location = new System.Drawing.Point(591, 0);
this.buttonQuit.Name = "buttonQuit";
this.buttonQuit.Size = new System.Drawing.Size(26, 23);
this.buttonQuit.TabIndex = 2;
this.buttonQuit.Text = "X";
this.buttonQuit.UseVisualStyleBackColor = true;
this.buttonQuit.Click += new System.EventHandler(this.ButtonQuitClick);
//
// labelTitle
//
this.labelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.labelTitle.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTitle.ForeColor = System.Drawing.Color.Silver;
this.labelTitle.Location = new System.Drawing.Point(-1, 0);
this.labelTitle.Name = "labelTitle";
this.labelTitle.Size = new System.Drawing.Size(618, 24);
this.labelTitle.TabIndex = 3;
this.labelTitle.Text = "Preview";
this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelTitle.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelTitleMouseDown);
this.labelTitle.MouseMove += new System.Windows.Forms.MouseEventHandler(this.LabelTitleMouseMove);
this.labelTitle.MouseUp += new System.Windows.Forms.MouseEventHandler(this.LabelTitleMouseUp);
//
// drawSurface
//
this.drawSurface.Location = new System.Drawing.Point(12, 27);
this.drawSurface.Name = "drawSurface";
this.drawSurface.Size = new System.Drawing.Size(595, 410);
this.drawSurface.TabIndex = 4;
//
// PreviewScreen
//
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)))));
this.ClientSize = new System.Drawing.Size(619, 449);
this.Controls.Add(this.drawSurface);
this.Controls.Add(this.buttonQuit);
this.Controls.Add(this.labelTitle);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "PreviewScreen";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Preview";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonQuit;
private System.Windows.Forms.Label labelTitle;
private System.Windows.Forms.Panel drawSurface;
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ANX.ContentCompiler.GUI.Dialogues
{
public partial class PreviewScreen : Form
{
#region Fields
private Point _lastPos;
private bool _mouseDown;
#endregion
public PreviewScreen()
{
InitializeComponent();
}
#region WindowMoveMethods
private void LabelTitleMouseMove(object sender, MouseEventArgs e)
{
if (!_mouseDown) return;
int xoffset = MousePosition.X - _lastPos.X;
int yoffset = MousePosition.Y - _lastPos.Y;
Left += xoffset;
Top += yoffset;
_lastPos = MousePosition;
}
private void LabelTitleMouseDown(object sender, MouseEventArgs e)
{
_mouseDown = true;
_lastPos = MousePosition;
}
private void LabelTitleMouseUp(object sender, MouseEventArgs e)
{
_mouseDown = false;
}
#endregion
private void ButtonQuitClick(object sender, EventArgs e)
{
Close();
DialogResult = DialogResult.Cancel;
}
}
}

View File

@ -32,7 +32,6 @@ namespace ANX.ContentCompiler.GUI
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
this.splitContainerMenuLayout = new System.Windows.Forms.SplitContainer();
this.show_pictureBoxRibbon = new System.Windows.Forms.PictureBox();
this.show_pictureBoxMenu = new System.Windows.Forms.PictureBox();

View File

@ -191,6 +191,19 @@ namespace ANX.ContentCompiler.GUI
#region SaveProject
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData.HasFlag(Keys.Control))
{
if (keyData.HasFlag(Keys.S))
{
SaveProject(this, null);
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
public void SaveProject(object sender, EventArgs e)
{
if (_contentProject == null) return;
@ -344,11 +357,18 @@ namespace ANX.ContentCompiler.GUI
string folder = _contentProject.ContentRoot;
TreeNode node = treeView.SelectedNode;
if (node != null)
folder = node.Name;
if ((string)node.Tag == "Folder")
folder = node.Name;
else
{
MessageBox.Show("Can not add a file to a file!");
return;
}
else
node = treeView.Nodes[0];
var newFolder = new TreeNode(name) {Name = folder + Path.DirectorySeparatorChar + name};
var newFolder = new TreeNode(name) { Name = folder + Path.DirectorySeparatorChar + name };
node.Tag = "Folder";
node.Nodes.Add(newFolder);
}
@ -411,9 +431,9 @@ namespace ANX.ContentCompiler.GUI
ProjectFolder = _contentProject.InputDirectory;
treeView.Nodes.Clear();
var rootNode = new TreeNode(ProjectName + "(" + _contentProject.ContentRoot + ")")
{Name = _contentProject.ContentRoot};
var rootNode = new TreeNode(ProjectName + "(" + _contentProject.ContentRoot + ")") { Name = _contentProject.ContentRoot };
treeView.Nodes.Add(rootNode);
rootNode.Tag = "Folder";
TreeNode lastNode = rootNode;
//aaaand here comes the nasty part. Watch out, it bites...um bugs!
foreach (
@ -426,7 +446,7 @@ namespace ANX.ContentCompiler.GUI
string parent = _contentProject.ContentRoot;
for (int i = 0; i < parts.Length - 1; i++) //Examine everything between ContentRoot and fileName. If we find something, add a folder!
{
if (parts[i] == null) continue;
if (parts[i] == null) continue;
if (i > 0) //if there is already a path we need to add the new part with a SeperatorChar!
folder += Path.DirectorySeparatorChar + parts[i];
else
@ -439,8 +459,7 @@ namespace ANX.ContentCompiler.GUI
// parent += Path.DirectorySeparatorChar + parts[0];
}
lastNode = treeView.RecursiveSearch(parent); //Search for parent node! Often an Exception Candidate! Check the 'parent' var then.
var node = new TreeNode(parts[parts.Length - 2])
{Name = _contentProject.ContentRoot + Path.DirectorySeparatorChar + folder}; //Finally glue a new folder node together
var node = new TreeNode(parts[parts.Length - 2]) { Name = _contentProject.ContentRoot + Path.DirectorySeparatorChar + folder, Tag = "Folder" }; //Finally glue a new folder node together
if (!ContainsTreeNode(lastNode, node))
{
lastNode.Nodes.Add(node); // If the folder is new, add it - else it's just wasted memory :)
@ -465,7 +484,7 @@ namespace ANX.ContentCompiler.GUI
}*/
//Add the actual files to the tree in their apropriate subdirs
string path = _contentProject.ContentRoot;
if (parts != null)
if (parts != null)
{
for (int i = 0; i < parts.Length - 1; i++)
{
@ -476,18 +495,17 @@ namespace ANX.ContentCompiler.GUI
{
TreeNode node = treeView.RecursiveSearch(path);
if (node == null) throw new ArgumentNullException("Node not found!");
var item = new TreeNode(parts[parts.Length - 1]) {Name = buildItem.AssetName};
var item = new TreeNode(parts[parts.Length - 1]) { Name = buildItem.AssetName, Tag = "File" };
node.Nodes.Add(item);
}
else //if the node is "forever alone", put him into the rootNode to make some friends!
{
var item = new TreeNode(buildItem.AssetName) {Name = buildItem.AssetName};
var item = new TreeNode(buildItem.AssetName) { Name = buildItem.AssetName, Tag = "File" };
treeView.Nodes[0].Nodes.Add(item);
}
}
}
}
#endregion
#region ButtonHandlers
@ -836,5 +854,16 @@ namespace ANX.ContentCompiler.GUI
}
#endregion
#region ShowPreview
internal void ShowPreview()
{
using (var preview = new PreviewScreen())
{
if ((string)treeView.SelectedNode.Tag == "File")
preview.ShowDialog();
}
}
#endregion
}
}

View File

@ -84,6 +84,7 @@
this.arrowButtonPreview.Name = "arrowButtonPreview";
this.arrowButtonPreview.Size = new System.Drawing.Size(348, 64);
this.arrowButtonPreview.TabIndex = 7;
this.arrowButtonPreview.Click += new System.EventHandler(this.ArrowButtonPreviewClick);
//
// arrowButtonBuild
//

View File

@ -47,5 +47,10 @@ namespace ANX.ContentCompiler.GUI.States
{
MainWindow.Instance.BuildProject(sender, e);
}
private void ArrowButtonPreviewClick(object sender, EventArgs e)
{
MainWindow.Instance.ShowPreview();
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Reflection;
using System.Windows.Forms;
using ANX.ContentCompiler.GUI.Dialogues;
using ANX.Framework.NonXNA.Development;
@ -19,6 +20,7 @@ namespace ANX.ContentCompiler.GUI.States
private void SetUpColors()
{
labelVersion.Text = "ANX Content Compiler v" + Assembly.GetExecutingAssembly().GetName().Version;
BackColor = Settings.MainColor;
ForeColor = Settings.ForeColor;
panel1.BackColor = Settings.AccentColor3;