Arg0 support, single instance, cleanup, Projects

This commit is contained in:
Gericom 2014-11-06 18:04:05 +01:00
parent b35408ffc6
commit 5daa139d6f
18 changed files with 229 additions and 65 deletions

View File

@ -79,7 +79,7 @@
<Compile Include="NintendoWare\LYT\txt1.cs" />
<Compile Include="NintendoWare\LYT\wnd1.cs" />
<Compile Include="NintendoWare\SND\CSTM.cs" />
<Compile Include="DARC.cs" />
<Compile Include="NintendoWare\LYT\DARC.cs" />
<Compile Include="DSP\ADPCM.cs" />
<Compile Include="DVLB.cs" />
<Compile Include="Extensions.cs" />

View File

@ -8,7 +8,7 @@ using System.IO;
using LibEveryFileExplorer.Files.SimpleFileSystem;
using _3DS.UI;
namespace _3DS
namespace _3DS.NintendoWare.LYT
{
public class DARC : FileFormat<DARC.darcIdentifier>, IViewable
{
@ -55,7 +55,7 @@ namespace _3DS
if (Signature != "darc") throw new SignatureNotCorrectException(Signature, "darc", er.BaseStream.Position - 4);
Endianness = er.ReadUInt16();
HeaderSize = er.ReadUInt16();
Unknown = er.ReadUInt32();
Version = er.ReadUInt32();
FileSize = er.ReadUInt32();
FileTableOffset = er.ReadUInt32();
FileTableLength = er.ReadUInt32();
@ -64,7 +64,7 @@ namespace _3DS
public String Signature;
public UInt16 Endianness;
public UInt16 HeaderSize;
public UInt32 Unknown;
public UInt32 Version;
public UInt32 FileSize;
public UInt32 FileTableOffset;
public UInt32 FileTableLength;

View File

@ -68,46 +68,6 @@ namespace _3DS.UI
if (cgfx.Data.Textures != null && cgfx.Data.Models != null)
{
//int i = 1;
/*foreach (_3DS.CGFX.DATA.TXOB t in cgfx.Data.Textures)
{
//int S = (int)((t.Unknown7 >> 8) & 0x3);
//int T = (int)((t.Unknown7 >> 12) & 0x3);
//if (S == 0) S = Gl.GL_REPEAT;
//else S = Gl.GL_MIRRORED_REPEAT;
//if (T == 0) T = Gl.GL_REPEAT;
//else T = Gl.GL_MIRRORED_REPEAT;
int S = Gl.GL_REPEAT;
int T = Gl.GL_REPEAT;
/*if ((t.Unknown4 & 0x7) == 0x3)
{
S = Gl.GL_MIRRORED_REPEAT;
T = Gl.GL_MIRRORED_REPEAT;
}*/
//if ((t.Unknown4 & 0x1) == 1) S = Gl.GL_MIRRORED_REPEAT;
//if (((t.Unknown4 >> 1) & 0x1) == 1) T = Gl.GL_MIRRORED_REPEAT;
/*uint _s = (t.Unknown8 >> 16) & 0xFF;
uint _t = (t.Unknown8 >> 24) & 0xFF;
if (_s == 2) S = Gl.GL_REPEAT;
else if (_s == 3) S = Gl.GL_MIRRORED_REPEAT;
else S = Gl.GL_CLAMP_TO_EDGE;
if (_t == 2) T = Gl.GL_REPEAT;
else if (_t == 3) T = Gl.GL_MIRRORED_REPEAT;
else T = Gl.GL_CLAMP_TO_EDGE;/
//GlNitro.glNitroTexImage2D(t.GetBitmap(), i, S, T, Gl.GL_LINEAR, Gl.GL_LINEAR);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, i);
Gl.glColor3f(1, 1, 1);
Bitmap b = t.GetBitmap();
BitmapData d = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, b.Width, b.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, d.Scan0);
b.UnlockBits(d);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, S);
Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, T);
i++;
}*/
int i = 0;
foreach (var v in cgfx.Data.Models[0].Materials)
{
@ -482,6 +442,10 @@ namespace _3DS.UI
Render();
}
private void CGFXViewer_Activated(object sender, EventArgs e)
{
for (int i = 0; i < 8; i++) Render();
}
}
}

View File

@ -123,6 +123,7 @@
this.Controls.Add(this.tabControl1);
this.Name = "CGFXViewer";
this.Text = "CGFX";
this.Activated += new System.EventHandler(this.CGFXViewer_Activated);
this.Load += new System.EventHandler(this.CGFX_Load);
this.Layout += new System.Windows.Forms.LayoutEventHandler(this.CGFX_Layout);
this.Resize += new System.EventHandler(this.CGFX_Resize);

View File

@ -71,7 +71,7 @@
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuExportDir});
this.menuItem2.MergeOrder = 2;
this.menuItem2.MergeOrder = 3;
this.menuItem2.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
this.menuItem2.Text = "Tools";
//

View File

@ -9,6 +9,7 @@ using System.Windows.Forms;
using LibEveryFileExplorer.Files.SimpleFileSystem;
using LibEveryFileExplorer.Files;
using LibEveryFileExplorer;
using _3DS.NintendoWare.LYT;
namespace _3DS.UI
{

View File

@ -90,7 +90,7 @@
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuExportDir});
this.menuItem2.MergeOrder = 2;
this.menuItem2.MergeOrder = 3;
this.menuItem2.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
this.menuItem2.Text = "Tools";
//

View File

@ -18,7 +18,7 @@
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
@ -49,7 +49,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Files\EFEDiskFile.cs" />
<Compile Include="Files\FileManager.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
@ -61,6 +60,7 @@
<Compile Include="Plugins\PluginManager.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Win32MessageHelper.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>

View File

@ -57,6 +57,11 @@
this.buttonOpen = new System.Windows.Forms.ToolStripButton();
this.buttonSave = new System.Windows.Forms.ToolStripButton();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.panel2 = new System.Windows.Forms.Panel();
this.splitter1 = new System.Windows.Forms.Splitter();
this.menuProject = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.panel1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
@ -66,6 +71,7 @@
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuFile,
this.menuEdit,
this.menuProject,
this.menuTools,
this.menuWindow,
this.menuHelp});
@ -147,12 +153,12 @@
//
// menuTools
//
this.menuTools.Index = 2;
this.menuTools.Index = 3;
this.menuTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuCompression,
this.menuItem2,
this.menuItemOptions});
this.menuTools.MergeOrder = 2;
this.menuTools.MergeOrder = 3;
this.menuTools.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
this.menuTools.Text = "Tools";
//
@ -173,12 +179,12 @@
//
// menuWindow
//
this.menuWindow.Index = 3;
this.menuWindow.Index = 4;
this.menuWindow.MdiList = true;
this.menuWindow.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuTile,
this.menuCascade});
this.menuWindow.MergeOrder = 3;
this.menuWindow.MergeOrder = 4;
this.menuWindow.Text = "Window";
//
// menuTile
@ -195,10 +201,10 @@
//
// menuHelp
//
this.menuHelp.Index = 4;
this.menuHelp.Index = 5;
this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4});
this.menuHelp.MergeOrder = 4;
this.menuHelp.MergeOrder = 5;
this.menuHelp.Text = "Help";
//
// menuItem4
@ -252,12 +258,55 @@
this.buttonSave.Text = "Save";
this.buttonSave.Click += new System.EventHandler(this.SaveFile);
//
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Left;
this.panel2.Location = new System.Drawing.Point(0, 25);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(200, 418);
this.panel2.TabIndex = 5;
this.panel2.Visible = false;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(200, 25);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 418);
this.splitter1.TabIndex = 7;
this.splitter1.TabStop = false;
this.splitter1.Visible = false;
//
// menuProject
//
this.menuProject.Index = 2;
this.menuProject.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3,
this.menuItem6});
this.menuProject.MergeOrder = 2;
this.menuProject.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
this.menuProject.Text = "Project";
this.menuProject.Visible = false;
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.F6;
this.menuItem3.Text = "Build";
//
// menuItem6
//
this.menuItem6.Index = 1;
this.menuItem6.Shortcut = System.Windows.Forms.Shortcut.F5;
this.menuItem6.Text = "Build and Run";
//
// Form1
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(804, 443);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.DoubleBuffered = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -307,6 +356,11 @@
private System.Windows.Forms.MenuItem menuFileNew;
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;
}
}

View File

@ -50,6 +50,15 @@ namespace EveryFileExplorer
InitializeComponent();
}
private String PendingPath = null;
public Form1(String Path)
{
InitializeComponent();
if (Path.Length < 1 || !System.IO.File.Exists(Path)) return;
PendingPath = Path;
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < this.Controls.Count; i++)
@ -114,6 +123,8 @@ namespace EveryFileExplorer
}
}
}
if (PendingPath != null) Program.FileManager.OpenFile(new EFEDiskFile(PendingPath));
PendingPath = null;
}
private void SetMDIBorderStyle(MdiClient mdiClient, BorderStyle value)
@ -355,5 +366,38 @@ namespace EveryFileExplorer
{
Program.FileManager.CreateFileFromFileWithType((Type)(((MenuItem)sender).Tag));
}
private void EnableProjectMode()
{
menuProject.Visible = splitter1.Visible = panel2.Visible = true;
menuNew.Enabled = menuFileNew.Enabled = menuOpen.Enabled = buttonOpen.Enabled = false;
}
private void DisableProjectMode()
{
menuProject.Visible = splitter1.Visible = panel2.Visible = false;
menuNew.Enabled = menuFileNew.Enabled = menuOpen.Enabled = buttonOpen.Enabled = true;
panel2.Controls.Clear();
}
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
private const int SW_RESTORE = 0x09;
protected override void WndProc(ref Message m)
{
if (m.Msg == Win32MessageHelper.WM_COPYDATA)
{
if (WindowState == FormWindowState.Minimized) ShowWindowAsync(Handle, SW_RESTORE);
TopMost = true;
TopMost = false;
String path = Win32MessageHelper.GetStringFromMessage(m);
if (path.Length < 1 || !System.IO.File.Exists(path)) return;
Program.FileManager.OpenFile(new EFEDiskFile(path));
return;
}
base.WndProc(ref m);
}
}
}

View File

@ -126,6 +126,9 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>379, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>379, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonOpen.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@ -6,25 +6,39 @@ using EveryFileExplorer.Plugins;
using EveryFileExplorer.Files;
using System.Reflection;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
namespace EveryFileExplorer
{
static class Program
{
private static Mutex mutex = new Mutex(true, "{069E262C-2440-4AFA-87AA-5CDE18753101}");
public static PluginManager PluginManager { get; private set; }
public static FileManager FileManager { get; private set; }
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] Arguments)
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
PluginManager = new PluginManager();
FileManager = new FileManager();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
if (mutex.WaitOne(TimeSpan.Zero, true))
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
PluginManager = new PluginManager();
FileManager = new FileManager();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (Arguments.Length > 0) Application.Run(new Form1(Arguments[0]));
else Application.Run(new Form1());
}
else
{
String arg0 = "";
if (Arguments.Length > 0) arg0 = Arguments[0];
Win32MessageHelper.SendString((IntPtr)Win32MessageHelper.HWND_BROADCAST, arg0);
}
}
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
@ -32,7 +46,23 @@ namespace EveryFileExplorer
string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Plugins\\";
string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
if (File.Exists(assemblyPath) == false) return null;
Assembly assembly = Assembly.LoadFrom(assemblyPath);
try
{
AssemblyName.GetAssemblyName(assemblyPath);
}
catch (BadImageFormatException)
{
return null;//This is not a .net assembly
}
Assembly assembly = null;
try
{
assembly = Assembly.LoadFrom(assemblyPath);
}
catch(NotSupportedException e)
{
MessageBox.Show("Unblock " + AssemblyName.GetAssemblyName(assemblyPath) + " from external sources!");
}
return assembly;
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace EveryFileExplorer
{
class Win32MessageHelper
{
public const int HWND_BROADCAST = 0xffff;
public const int WM_COPYDATA = 0x004A;
[DllImport("user32")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, ref COPYDATASTRUCT lParam);
[StructLayout(LayoutKind.Sequential)]
private struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cbData;
[MarshalAs(UnmanagedType.LPWStr)]
public String lpData;
}
public static bool SendString(IntPtr Handle, String Data)
{
COPYDATASTRUCT c = new COPYDATASTRUCT() { lpData = Data, cbData = Data.Length * 2 + 2 };
return SendMessage(Handle, WM_COPYDATA, IntPtr.Zero, ref c) == IntPtr.Zero;
}
public static String GetStringFromMessage(Message m)
{
COPYDATASTRUCT c = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT));
return c.lpData;
}
}
}

View File

@ -3,9 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using LibEveryFileExplorer.Files;
namespace EveryFileExplorer.Files
namespace LibEveryFileExplorer.Files
{
public class EFEDiskFile : EFEFile
{

View File

@ -50,6 +50,7 @@
<Compile Include="Collections\Matrix34.cs" />
<Compile Include="Collections\Matrix44.cs" />
<Compile Include="Collections\Vector2.cs" />
<Compile Include="Files\EFEDiskFile.cs" />
<Compile Include="Files\IChildReactive.cs" />
<Compile Include="GFX\ETC1.cs" />
<Compile Include="GFX\ETC1_new.cs" />
@ -77,6 +78,7 @@
<Compile Include="IO\EndianBinaryWriter.cs" />
<Compile Include="IO\IOUtil.cs" />
<Compile Include="Math\MathUtil.cs" />
<Compile Include="Projects\Project.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resource.Designer.cs">
<AutoGen>True</AutoGen>

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LibEveryFileExplorer.Projects
{
public abstract class Project
{
public Project(String ProjectDir)
{
ProjectDirectory = ProjectDir;
}
public String ProjectDirectory { get; private set; }
public abstract bool CanRun { get; }
public abstract Control GetProjectControl();
public abstract void Build();
public abstract void Run();
}
}

View File

@ -155,7 +155,7 @@
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6,
this.menuItem7});
this.menuItem5.MergeOrder = 2;
this.menuItem5.MergeOrder = 3;
this.menuItem5.MergeType = System.Windows.Forms.MenuMerge.MergeItems;
this.menuItem5.Text = "Tools";
//

View File

@ -221,6 +221,7 @@ namespace NDS.UI
public void FileOpened(ViewableFile File)
{
if (!(File.FileFormat is NSBTX)) return;
ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(NSBTX));
menuItem1.MenuItems.Clear();
bool curavab = false;
@ -273,6 +274,8 @@ namespace NDS.UI
//otherwise the nsbtx menu is not refreshed!
mainMenu1.MenuItems.Clear();
mainMenu1.MenuItems.Add(menuItem1);
//render it multiple times to avoid glitches!
for (int i = 0; i < 8; i++) ModViewer.Render();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)