Project Tree and opening files in a project

This commit is contained in:
Gericom 2014-12-02 17:25:28 +01:00
parent 1fed715787
commit 6da06ffc4e
10 changed files with 255 additions and 47 deletions

View File

@ -70,11 +70,17 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
@ -92,6 +98,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Propeller_Box_Artwork_-_Super_Mario_3D_World.ico" />
<None Include="Resources\document.png" />
<None Include="Resources\folder-open.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@ -66,9 +66,15 @@
this.buttonSave = new System.Windows.Forms.ToolStripButton();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.panel2 = new System.Windows.Forms.Panel();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.treeView1 = new System.Windows.Forms.TreeView();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.panel2.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.SuspendLayout();
//
// mainMenu1
@ -212,6 +218,7 @@
this.menuItem6.Index = 1;
this.menuItem6.Shortcut = System.Windows.Forms.Shortcut.F5;
this.menuItem6.Text = "Build and Run";
this.menuItem6.Visible = false;
//
// menuTools
//
@ -323,6 +330,7 @@
//
// panel2
//
this.panel2.Controls.Add(this.tabControl1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Left;
this.panel2.Location = new System.Drawing.Point(0, 25);
this.panel2.Name = "panel2";
@ -330,12 +338,46 @@
this.panel2.TabIndex = 5;
this.panel2.Visible = false;
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Multiline = true;
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(200, 376);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.treeView1);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Size = new System.Drawing.Size(192, 350);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Project Explorer";
this.tabPage1.UseVisualStyleBackColor = true;
//
// treeView1
//
this.treeView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView1.HotTracking = true;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Margin = new System.Windows.Forms.Padding(0);
this.treeView1.Name = "treeView1";
this.treeView1.ShowLines = false;
this.treeView1.Size = new System.Drawing.Size(192, 350);
this.treeView1.TabIndex = 0;
this.treeView1.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(200, 25);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 376);
this.splitter1.TabIndex = 7;
this.splitter1.TabIndex = 9;
this.splitter1.TabStop = false;
this.splitter1.Visible = false;
//
@ -362,6 +404,9 @@
this.panel1.PerformLayout();
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.panel2.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -397,7 +442,6 @@
private System.Windows.Forms.MenuItem menuCompression;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.MenuItem menuProject;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem6;
@ -406,6 +450,10 @@
private System.Windows.Forms.MenuItem menuCloseProject;
private System.Windows.Forms.MenuItem menuProjectNew;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.Splitter splitter1;
}
}

View File

@ -15,6 +15,7 @@ using System.Reflection;
using LibEveryFileExplorer.Compression;
using LibEveryFileExplorer.Projects;
using System.IO;
using EveryFileExplorer.Properties;
namespace EveryFileExplorer
{
@ -23,21 +24,29 @@ namespace EveryFileExplorer
public Form1()
{
InitializeComponent();
Win32Util.SetWindowTheme(treeView1.Handle, "explorer", null);
}
private String PendingPath = null;
private ProjectBase Project = null;
public Form1(String Path)
: this()
{
InitializeComponent();
if (Path.Length < 1 || !System.IO.File.Exists(Path)) return;
PendingPath = Path;
}
private ImageList ProjectTreeIL = null;
private ProjectBase Project = null;
private void Form1_Load(object sender, EventArgs e)
{
ProjectTreeIL = new ImageList();
ProjectTreeIL.ColorDepth = ColorDepth.Depth32Bit;
ProjectTreeIL.ImageSize = new Size(16, 16);
ProjectTreeIL.Images.Add(Resources.document);
ProjectTreeIL.Images.Add(Resources.folder_open);
treeView1.ImageList = ProjectTreeIL;
for (int i = 0; i < this.Controls.Count; i++)
{
MdiClient mdiClient = this.Controls[i] as MdiClient;
@ -340,7 +349,13 @@ namespace EveryFileExplorer
{
//Close all files
Program.FileManager.CloseAllFiles();
menuProject.Visible = splitter1.Visible = panel2.Visible = menuCloseProject.Enabled = true;
treeView1.BeginUpdate();
treeView1.Nodes.Clear();
treeView1.Nodes.AddRange(Project.GetProjectTree());
treeView1.EndUpdate();
menuProject.Visible = panel2.Visible = splitter1.Visible = menuCloseProject.Enabled = true;
menuNew.Enabled = menuFileNew.Enabled = menuOpen.Enabled = buttonOpen.Enabled = false;
}
@ -350,7 +365,6 @@ namespace EveryFileExplorer
Project = null;
menuProject.Visible = splitter1.Visible = panel2.Visible = menuCloseProject.Enabled = false;
menuNew.Enabled = menuFileNew.Enabled = menuOpen.Enabled = buttonOpen.Enabled = true;
panel2.Controls.Clear();
}
protected override void WndProc(ref Message m)
@ -389,5 +403,12 @@ namespace EveryFileExplorer
{
Project.Build();
}
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
String Path = Project.ProjectDir + "\\" + e.Node.FullPath;
if ((new FileInfo(Path).Attributes & FileAttributes.Directory) != 0) return;
Program.FileManager.OpenFile(new EFEDiskFile(Path));
}
}
}

View File

@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace EveryFileExplorer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EveryFileExplorer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap document {
get {
object obj = ResourceManager.GetObject("document", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap folder_open {
get {
object obj = ResourceManager.GetObject("folder_open", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@ -109,9 +112,16 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="document" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\document.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="folder_open" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\folder-open.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

View File

@ -17,6 +17,10 @@ namespace LibEveryFileExplorer.Projects
void Save();
void Build();
TreeNode[] GetProjectTree();
String ProjectDir { get; }
}
public abstract class Project<T, U> : ProjectBase
@ -45,6 +49,8 @@ namespace LibEveryFileExplorer.Projects
public abstract void Build();
public abstract TreeNode[] GetProjectTree();
public U ProjectFile { get; protected set; }
public String ProjectDir { get; protected set; }
}

View File

@ -89,6 +89,34 @@ namespace NDS
File.WriteAllBytes(ProjectDir + "\\" + ProjectFile.ProjectName + ".nds", data);
}
public override TreeNode[] GetProjectTree()
{
List<TreeNode> Nodes = new List<TreeNode>();
var dataNode = new TreeNode("data", 1, 1);
Nodes.Add(dataNode);
PopulateTreeNodeFromDisk(new DirectoryInfo(ProjectDir + "\\data"), dataNode);
var overlayNode = new TreeNode("overlay", 1, 1);
Nodes.Add(overlayNode);
PopulateTreeNodeFromDisk(new DirectoryInfo(ProjectDir + "\\overlay"), overlayNode);
Nodes.Add(new TreeNode("arm9.bin"));
Nodes.Add(new TreeNode("arm7.bin"));
return Nodes.ToArray();
}
private void PopulateTreeNodeFromDisk(DirectoryInfo Dir, TreeNode Dst)
{
foreach (var v in Dir.EnumerateDirectories())
{
var t = new TreeNode(v.Name, 1, 1);
Dst.Nodes.Add(t);
PopulateTreeNodeFromDisk(v, t);
}
foreach (var v in Dir.EnumerateFiles())
{
Dst.Nodes.Add(v.Name);
}
}
public class NDSProjectIdentifier : ProjectIdentifier
{
public override string GetProjectDescription()

View File

@ -99,53 +99,57 @@ namespace NDS.UI
private void LoadTex()
{
TEX0 tt;
if (mod.TexPlttSet != null) tt = mod.TexPlttSet;
else if (tex != null) tt = tex.TexPlttSet;
else return;
for (int i = 0; i < mod.ModelSet.models.Length; i++)
try
{
for (int j = 0; j < mod.ModelSet.models[i].materials.materials.Length; j++)
TEX0 tt;
if (mod.TexPlttSet != null) tt = mod.TexPlttSet;
else if (tex != null) tt = tex.TexPlttSet;
else return;
for (int i = 0; i < mod.ModelSet.models.Length; i++)
{
TEX0.DictTexData t = null;
for (int k = 0; k < mod.ModelSet.models[i].materials.dictTexToMatList.numEntry; k++)
for (int j = 0; j < mod.ModelSet.models[i].materials.materials.Length; j++)
{
if (mod.ModelSet.models[i].materials.dictTexToMatList[k].Value.Materials.Contains((byte)j))
TEX0.DictTexData t = null;
for (int k = 0; k < mod.ModelSet.models[i].materials.dictTexToMatList.numEntry; k++)
{
int texid = k;
for (int l = 0; l < tt.dictTex.numEntry; l++)
if (mod.ModelSet.models[i].materials.dictTexToMatList[k].Value.Materials.Contains((byte)j))
{
if (tt.dictTex[l].Key == mod.ModelSet.models[i].materials.dictTexToMatList[k].Key) { texid = l; break; }
}
t = tt.dictTex[texid].Value;
break;
}
}
if (t == null)
continue;
mod.ModelSet.models[i].materials.materials[j].Fmt = t.Fmt;
mod.ModelSet.models[i].materials.materials[j].origHeight = t.T;
mod.ModelSet.models[i].materials.materials[j].origWidth = t.S;
TEX0.DictPlttData p = null;
if (t.Fmt != Textures.ImageFormat.DIRECT)
{
for (int k = 0; k < mod.ModelSet.models[i].materials.dictPlttToMatList.numEntry; k++)
{
if (mod.ModelSet.models[i].materials.dictPlttToMatList[k].Value.Materials.Contains((byte)j))
{
int palid = k;
for (int l = 0; l < tt.dictPltt.numEntry; l++)
int texid = k;
for (int l = 0; l < tt.dictTex.numEntry; l++)
{
if (tt.dictPltt[l].Key == mod.ModelSet.models[i].materials.dictPlttToMatList[k].Key) { palid = l; break; }
if (tt.dictTex[l].Key == mod.ModelSet.models[i].materials.dictTexToMatList[k].Key) { texid = l; break; }
}
p = tt.dictPltt[palid].Value;
t = tt.dictTex[texid].Value;
break;
}
}
if (t == null)
continue;
mod.ModelSet.models[i].materials.materials[j].Fmt = t.Fmt;
mod.ModelSet.models[i].materials.materials[j].origHeight = t.T;
mod.ModelSet.models[i].materials.materials[j].origWidth = t.S;
TEX0.DictPlttData p = null;
if (t.Fmt != Textures.ImageFormat.DIRECT)
{
for (int k = 0; k < mod.ModelSet.models[i].materials.dictPlttToMatList.numEntry; k++)
{
if (mod.ModelSet.models[i].materials.dictPlttToMatList[k].Value.Materials.Contains((byte)j))
{
int palid = k;
for (int l = 0; l < tt.dictPltt.numEntry; l++)
{
if (tt.dictPltt[l].Key == mod.ModelSet.models[i].materials.dictPlttToMatList[k].Key) { palid = l; break; }
}
p = tt.dictPltt[palid].Value;
break;
}
}
}
UploadTex(t.ToBitmap(p), mod.ModelSet.models[i].materials.materials[j], j + 1);//+ offset);
}
UploadTex(t.ToBitmap(p), mod.ModelSet.models[i].materials.materials[j], j + 1);//+ offset);
}
}
catch { }
}
private void UploadTex(Bitmap b, MDL0.Model.MaterialSet.Material m, int Id)