diff --git a/3DS/3DS.csproj b/3DS/3DS.csproj
index c190884..f7e991f 100644
--- a/3DS/3DS.csproj
+++ b/3DS/3DS.csproj
@@ -97,6 +97,12 @@
+
+ Form
+
+
+ CFNTViewer.cs
+
Form
@@ -167,6 +173,9 @@
ResXFileCodeGenerator
Resource.Designer.cs
+
+ CFNTViewer.cs
+
CGFXViewer.cs
diff --git a/3DS/NintendoWare/FONT/CFNT.cs b/3DS/NintendoWare/FONT/CFNT.cs
index 16214e8..769b74f 100644
--- a/3DS/NintendoWare/FONT/CFNT.cs
+++ b/3DS/NintendoWare/FONT/CFNT.cs
@@ -7,6 +7,10 @@ using System.Drawing;
using System.IO;
using System.Windows.Forms;
using _3DS.GPU;
+using LibEveryFileExplorer.GFX;
+using System.Drawing.Imaging;
+using System.Runtime.InteropServices;
+using _3DS.UI;
namespace _3DS.NintendoWare.FONT
{
@@ -54,7 +58,7 @@ namespace _3DS.NintendoWare.FONT
public Form GetDialog()
{
- return new Form();
+ return new CFNTViewer(this);
}
public CFNTHeader Header;
@@ -130,8 +134,8 @@ namespace _3DS.NintendoWare.FONT
SheetSize = er.ReadUInt32();
NrSheets = er.ReadUInt16();
SheetFormat = (Textures.ImageFormat)er.ReadUInt16();
- SheetRow = er.ReadUInt16();
- SheetLine = er.ReadUInt16();
+ SheetNrRows = er.ReadUInt16();
+ SheetNrLines = er.ReadUInt16();
SheetWidth = er.ReadUInt16();
SheetHeight = er.ReadUInt16();
SheetDataOffset = er.ReadUInt32();
@@ -149,8 +153,8 @@ namespace _3DS.NintendoWare.FONT
public UInt32 SheetSize;
public UInt16 NrSheets;
public Textures.ImageFormat SheetFormat;
- public UInt16 SheetRow;
- public UInt16 SheetLine;
+ public UInt16 SheetNrRows;
+ public UInt16 SheetNrLines;
public UInt16 SheetWidth;
public UInt16 SheetHeight;
public UInt32 SheetDataOffset;
@@ -176,8 +180,8 @@ namespace _3DS.NintendoWare.FONT
EndIndex = er.ReadUInt16();
NextCWDHOffset = er.ReadUInt32();
- CharWidths = new CharWidthInfo[EndIndex - StartIndex];
- for (int i = 0; i < EndIndex - StartIndex; i++) CharWidths[i] = new CharWidthInfo(er);
+ CharWidths = new CharWidthInfo[EndIndex - StartIndex + 1];
+ for (int i = 0; i < EndIndex - StartIndex + 1; i++) CharWidths[i] = new CharWidthInfo(er);
}
public String Signature;
public UInt32 SectionSize;
@@ -191,6 +195,13 @@ namespace _3DS.NintendoWare.FONT
public CMAP[] CharMaps;
public class CMAP
{
+ public enum CMAPMappingMethod : ushort
+ {
+ Direct = 0,
+ Table = 1,
+ Scan = 2
+ }
+
public CMAP(EndianBinaryReader er)
{
Signature = er.ReadString(Encoding.ASCII, 4);
@@ -198,28 +209,136 @@ namespace _3DS.NintendoWare.FONT
SectionSize = er.ReadUInt32();
CodeBegin = er.ReadUInt16();
CodeEnd = er.ReadUInt16();
- MappingMethod = er.ReadUInt16();
+ MappingMethod = (CMAPMappingMethod)er.ReadUInt16();
Reserved = er.ReadUInt16();
NextCMAPOffset = er.ReadUInt32();
+
+ switch (MappingMethod)
+ {
+ case CMAPMappingMethod.Direct:
+ IndexOffset = er.ReadUInt16();
+ break;
+ case CMAPMappingMethod.Table:
+ IndexTable = er.ReadUInt16s(CodeEnd - CodeBegin + 1);
+ break;
+ case CMAPMappingMethod.Scan:
+ ScanEntries = new Dictionary();
+ NrScanEntries = er.ReadUInt16();
+ for (int i = 0; i < NrScanEntries; i++) ScanEntries.Add(er.ReadUInt16(), er.ReadUInt16());
+ break;
+ }
}
public String Signature;
public UInt32 SectionSize;
public UInt16 CodeBegin;
public UInt16 CodeEnd;
- public UInt16 MappingMethod;
+ public CMAPMappingMethod MappingMethod;
public UInt16 Reserved;
public UInt32 NextCMAPOffset;
+
+ //Direct
+ public UInt16 IndexOffset;
+
+ //Table
+ public UInt16[] IndexTable;
+
+ //Scan
+ public UInt16 NrScanEntries;
+ public Dictionary ScanEntries;
+
+ public UInt16 GetIndexFromCode(UInt16 Code)
+ {
+ if (Code < CodeBegin || Code > CodeEnd) return 0xFFFF;
+ switch (MappingMethod)
+ {
+ case CMAPMappingMethod.Direct:
+ return (UInt16)(Code - CodeBegin + IndexOffset);
+ case CMAPMappingMethod.Table:
+ return IndexTable[Code - CodeBegin];
+ case CMAPMappingMethod.Scan:
+ if (!ScanEntries.ContainsKey(Code)) return 0xFFFF;
+ return ScanEntries[Code];
+ }
+ return 0xFFFF;
+ }
+ }
+
+ private CharWidthInfo GetCharWidthInfoByIndex(UInt16 Index)
+ {
+ foreach (var v in CharWidths)
+ {
+ if (Index < v.StartIndex || Index > v.EndIndex) continue;
+ return v.CharWidths[Index - v.StartIndex];
+ }
+ return null;
+ }
+
+ private UInt16 GetIndexFromCode(UInt16 Code)
+ {
+ foreach (var v in CharMaps)
+ {
+ UInt16 result = v.GetIndexFromCode(Code);
+ if (result != 0xFFFF) return result;
+ }
+ return 0xFFFF;
+ }
+
+ public BitmapFont GetBitmapFont()
+ {
+ BitmapFont f = new BitmapFont();
+ f.LineHeight = FontInfo.LineFeed;
+ Bitmap[] Chars = new Bitmap[TextureGlyph.SheetNrLines * TextureGlyph.SheetNrRows * TextureGlyph.NrSheets];
+
+ float realcellwidth = TextureGlyph.CellWidth + 1;
+ float realcellheight = TextureGlyph.CellHeight + 1;
+
+ int j = 0;
+ for (int sheet = 0; sheet < TextureGlyph.NrSheets; sheet++)
+ {
+ Bitmap SheetBM = TextureGlyph.GetSheet(sheet);
+ BitmapData bd = SheetBM.LockBits(new Rectangle(0, 0, SheetBM.Width, SheetBM.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ for (int y = 0; y < TextureGlyph.SheetNrLines; y++)
+ {
+ for (int x = 0; x < TextureGlyph.SheetNrRows; x++)
+ {
+ Bitmap b = new Bitmap(TextureGlyph.CellWidth, TextureGlyph.CellHeight);
+ BitmapData bd2 = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ for (int y2 = 0; y2 < TextureGlyph.CellHeight; y2++)
+ {
+ for (int x2 = 0; x2 < TextureGlyph.CellWidth; x2++)
+ {
+ Marshal.WriteInt32(bd2.Scan0, y2 * bd2.Stride + x2 * 4, Marshal.ReadInt32(bd.Scan0, (int)(y * realcellheight + y2 + 1) * bd.Stride + (int)(x * realcellwidth + x2 + 1) * 4));
+ }
+ }
+ b.UnlockBits(bd2);
+ Chars[j++] = b;
+ }
+ }
+ SheetBM.UnlockBits(bd);
+ }
+
+ foreach (var v in CharMaps)
+ {
+ for (int i = v.CodeBegin; i < v.CodeEnd + 1; i++)
+ {
+ ushort idx = v.GetIndexFromCode((ushort)i);
+ if (idx == 0xFFFF) continue;
+ var info = GetCharWidthInfoByIndex(idx);
+ f.Characters.Add((char)i, new BitmapFont.Character(Chars[idx], info.Left, info.GlyphWidth, info.CharWidth));
+ }
+ }
+ return f;
}
public class CharWidthInfo
{
public CharWidthInfo(EndianBinaryReader er)
{
- Left = er.ReadByte();
+ Left = er.ReadSByte();
GlyphWidth = er.ReadByte();
CharWidth = er.ReadByte();
}
- public Byte Left;
+ public SByte Left;
public Byte GlyphWidth;
public Byte CharWidth;
}
diff --git a/3DS/NintendoWare/LYT1/txt1.cs b/3DS/NintendoWare/LYT1/txt1.cs
index f9e0e75..a69b30d 100644
--- a/3DS/NintendoWare/LYT1/txt1.cs
+++ b/3DS/NintendoWare/LYT1/txt1.cs
@@ -27,8 +27,8 @@ namespace _3DS.NintendoWare.LYT1
TopColor = er.ReadColor8();
BottomColor = er.ReadColor8();
FontSize = er.ReadVector2();
- CharSize = er.ReadSingle();
- LineSize = er.ReadSingle();
+ CharSpace = er.ReadSingle();
+ LineSpace = er.ReadSingle();
er.BaseStream.Position = baseoffset + StringOffset;
Text = er.ReadStringNT(Encoding.Unicode);
er.BaseStream.Position = baseoffset + SectionSize;
@@ -45,8 +45,8 @@ namespace _3DS.NintendoWare.LYT1
public Color TopColor;
public Color BottomColor;
public Vector2 FontSize;
- public Single CharSize;
- public Single LineSize;
+ public Single CharSpace;
+ public Single LineSpace;
public String Text;
diff --git a/3DS/ThemeFile.cs b/3DS/ThemeFile.cs
index 8f3b84a..a887231 100644
--- a/3DS/ThemeFile.cs
+++ b/3DS/ThemeFile.cs
@@ -93,9 +93,9 @@ namespace _3DS
er.BaseStream.Position = header.bottomScreenSolidOrTextureOffset;
bottomScreenTexture = er.ReadBytes((bottomHeight * bottomWidth) * 2);
- er.BaseStream.Position = header.openedFolderTextureOffset;
+ er.BaseStream.Position = header.FolderOpenedTexOffset;
openFolderTexture = er.ReadBytes((folderWidth * folderHeight) * 4);
- er.BaseStream.Position = header.closedFolderTextureOffset;
+ er.BaseStream.Position = header.FolderClosedTexOffset;
closedFolderTexture = er.ReadBytes((folderWidth * folderHeight) * 4);
er.BaseStream.Position = header.iconBorder48pxOffset;
@@ -127,10 +127,10 @@ namespace _3DS
header.bottomScreenSolidOrTextureOffset = (uint)er.BaseStream.Position;
er.Write(bottomScreenTexture, 0, bottomScreenTexture.Length);
- header.openedFolderTextureOffset = (uint)er.BaseStream.Position;
+ header.FolderOpenedTexOffset = (uint)er.BaseStream.Position;
er.Write(openFolderTexture, 0, openFolderTexture.Length);
- header.closedFolderTextureOffset = (uint)er.BaseStream.Position;
+ header.FolderClosedTexOffset = (uint)er.BaseStream.Position;
er.Write(closedFolderTexture, 0, closedFolderTexture.Length);
header.iconBorder48pxOffset = (uint)er.BaseStream.Position;
@@ -227,14 +227,11 @@ namespace _3DS
public ThemeHeader(EndianBinaryReader er)
{
//offset 0x0
- version = er.ReadUInt32();
+ Version = er.ReadUInt32();
- unknownByte1 = er.ReadByte();
- backgroundMusicEnabled = er.ReadByte() == 1;
- unknownByte2 = er.ReadByte();
- unknownByte3 = er.ReadByte();
-
- unknownInt2 = er.ReadUInt32();
+ Unknown1 = er.ReadByte();
+ UseBGMusic = er.ReadByte() == 1;
+ Padding = er.ReadBytes(6);
//offset 0xC
topScreenDrawType = er.ReadUInt32();// 0 = none, 1 = solid colour, 2 = extension of val1, 3 = texture
@@ -243,32 +240,23 @@ namespace _3DS
topScreenTextureOffset = er.ReadUInt32();
topScreenAdditionalTextureOffset = er.ReadUInt32();//used with draw type val2, optional when using draw type val2
- System.Console.WriteLine("topScreenDrawType " + topScreenDrawType);
- System.Console.WriteLine("topScreenFrameType " + topScreenFrameType);
- System.Console.WriteLine("topScreenAdditionalTextureOffset " + topScreenAdditionalTextureOffset);
-
-
//offset 0x20
bottomScreenDrawType = er.ReadUInt32();
bottomScreenFrameType = er.ReadUInt32();
bottomScreenSolidOrTextureOffset = er.ReadUInt32();
- System.Console.WriteLine("bottomScreenDrawType " + bottomScreenDrawType);
- System.Console.WriteLine("bottomScreenFrameType " + bottomScreenFrameType);
- System.Console.WriteLine("bottomScreenSolidOrTextureOffset " + bottomScreenSolidOrTextureOffset);
-
//offset 0x2C
- useUnknownBlock0 = er.ReadUInt32() == 1;
- unknownBlock0Offset = er.ReadUInt32();//0xC length
+ UseSelectorColor = er.ReadUInt32() == 1;
+ SelectorColorBlockOffset = er.ReadUInt32();//0xC length
//offset 0x34
- useUnknownBlock1 = er.ReadUInt32() == 1;
- unknownBlock1Offset = er.ReadUInt32();//0xC length
+ UseFolderColor = er.ReadUInt32() == 1;
+ FolderColorBlockOffset = er.ReadUInt32();//0xC length
//offset 0x3C
- useFolderTextures = er.ReadUInt32() == 1;
- closedFolderTextureOffset = er.ReadUInt32();//texture 6
- openedFolderTextureOffset = er.ReadUInt32();//texture 7
+ UseFolderTex = er.ReadUInt32() == 1;
+ FolderClosedTexOffset = er.ReadUInt32();//texture 6
+ FolderOpenedTexOffset = er.ReadUInt32();//texture 7
//offset 0x48
useUnknownBlock2 = er.ReadUInt32() == 1;
@@ -317,27 +305,17 @@ namespace _3DS
useAudioSection = er.ReadUInt32() == 1;
audioSectionSize = er.ReadUInt32();
audioSectionOffset = er.ReadUInt32();
-
- System.Console.WriteLine("useFolderTextures " + useFolderTextures);
- System.Console.WriteLine("useIconBorders " + useIconBorders);
- System.Console.WriteLine("useAudioSection " + useAudioSection);
- System.Console.WriteLine("audioSectionSize " + audioSectionSize);
- System.Console.WriteLine("audioSectionOffset " + audioSectionOffset);
-
}
public void Write(EndianBinaryWriter er)
{
er.BaseStream.Position = 0;
//write header data
- er.Write(version);
+ er.Write(Version);
- er.Write(unknownByte1);
- er.Write((byte)(backgroundMusicEnabled ? 1 : 0));
- er.Write(unknownByte2);
- er.Write(unknownByte3);
-
- er.Write(unknownInt2);
+ er.Write(Unknown1);
+ er.Write((byte)(UseBGMusic ? 1 : 0));
+ er.Write(Padding, 0, 6);
er.Write(topScreenDrawType);
er.Write(topScreenFrameType);
@@ -356,9 +334,9 @@ namespace _3DS
er.Write((UInt32)0);
er.Write((UInt32)0);
- er.Write(useFolderTextures ? 1u : 0u);//TODO write 0 instead or somethign when this is disabled?
- er.Write(closedFolderTextureOffset);
- er.Write(openedFolderTextureOffset);
+ er.Write(UseFolderTex ? 1u : 0u);//TODO write 0 instead or somethign when this is disabled?
+ er.Write(FolderClosedTexOffset);
+ er.Write(FolderOpenedTexOffset);
er.Write((UInt32)0);
er.Write((UInt32)0);
@@ -406,14 +384,10 @@ namespace _3DS
er.Write((UInt32)0);
}
- public UInt32 version;
- public Byte unknownByte1;
- public bool backgroundMusicEnabled;
- public Byte unknownByte2;
- public Byte unknownByte3;
-
- public UInt32 unknownInt2;
-
+ public UInt32 Version;
+ public Byte Unknown1;
+ public bool UseBGMusic;
+ public Byte[] Padding;//6
public UInt32 topScreenDrawType;
public UInt32 topScreenFrameType;
@@ -425,15 +399,15 @@ namespace _3DS
public UInt32 bottomScreenFrameType;
public UInt32 bottomScreenSolidOrTextureOffset;
- public bool useUnknownBlock0;
- public UInt32 unknownBlock0Offset;
+ public bool UseSelectorColor;
+ public UInt32 SelectorColorBlockOffset;
- public bool useUnknownBlock1;
- public UInt32 unknownBlock1Offset;
+ public bool UseFolderColor;
+ public UInt32 FolderColorBlockOffset;
- public bool useFolderTextures;//6 and 7
- public UInt32 closedFolderTextureOffset;
- public UInt32 openedFolderTextureOffset;
+ public bool UseFolderTex;//6 and 7
+ public UInt32 FolderClosedTexOffset;
+ public UInt32 FolderOpenedTexOffset;
public bool useUnknownBlock2;
public UInt32 unknownBlock2Offset;
diff --git a/3DS/UI/CFNTViewer.Designer.cs b/3DS/UI/CFNTViewer.Designer.cs
new file mode 100644
index 0000000..02e2f98
--- /dev/null
+++ b/3DS/UI/CFNTViewer.Designer.cs
@@ -0,0 +1,160 @@
+namespace _3DS.UI
+{
+ partial class CFNTViewer
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.tabControl1 = new System.Windows.Forms.TabControl();
+ this.tabPage1 = new System.Windows.Forms.TabPage();
+ this.tabPage2 = new System.Windows.Forms.TabPage();
+ this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.textBox1 = new System.Windows.Forms.TextBox();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.tabControl1.SuspendLayout();
+ this.tabPage1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
+ this.splitContainer1.Panel1.SuspendLayout();
+ this.splitContainer1.Panel2.SuspendLayout();
+ this.splitContainer1.SuspendLayout();
+ this.panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.SuspendLayout();
+ //
+ // tabControl1
+ //
+ this.tabControl1.Controls.Add(this.tabPage1);
+ this.tabControl1.Controls.Add(this.tabPage2);
+ this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControl1.Location = new System.Drawing.Point(0, 0);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(580, 380);
+ this.tabControl1.TabIndex = 0;
+ //
+ // tabPage1
+ //
+ this.tabPage1.Controls.Add(this.splitContainer1);
+ this.tabPage1.Location = new System.Drawing.Point(4, 22);
+ this.tabPage1.Name = "tabPage1";
+ this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage1.Size = new System.Drawing.Size(572, 354);
+ this.tabPage1.TabIndex = 0;
+ this.tabPage1.Text = "Font";
+ this.tabPage1.UseVisualStyleBackColor = true;
+ //
+ // tabPage2
+ //
+ this.tabPage2.Location = new System.Drawing.Point(4, 22);
+ this.tabPage2.Name = "tabPage2";
+ this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage2.Size = new System.Drawing.Size(572, 354);
+ this.tabPage2.TabIndex = 1;
+ this.tabPage2.Text = "Character Map";
+ this.tabPage2.UseVisualStyleBackColor = true;
+ //
+ // splitContainer1
+ //
+ this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.Location = new System.Drawing.Point(3, 3);
+ this.splitContainer1.Name = "splitContainer1";
+ this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
+ //
+ // splitContainer1.Panel1
+ //
+ this.splitContainer1.Panel1.Controls.Add(this.textBox1);
+ //
+ // splitContainer1.Panel2
+ //
+ this.splitContainer1.Panel2.Controls.Add(this.panel1);
+ this.splitContainer1.Size = new System.Drawing.Size(566, 348);
+ this.splitContainer1.SplitterDistance = 168;
+ this.splitContainer1.TabIndex = 0;
+ //
+ // textBox1
+ //
+ this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.textBox1.Location = new System.Drawing.Point(0, 0);
+ this.textBox1.Multiline = true;
+ this.textBox1.Name = "textBox1";
+ this.textBox1.Size = new System.Drawing.Size(566, 168);
+ this.textBox1.TabIndex = 0;
+ this.textBox1.Text = "The quick brown fox jumps over the lazy dog!";
+ this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
+ //
+ // panel1
+ //
+ this.panel1.BackColor = System.Drawing.SystemColors.Control;
+ this.panel1.Controls.Add(this.pictureBox1);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(0, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(566, 176);
+ this.panel1.TabIndex = 0;
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.BackColor = System.Drawing.SystemColors.AppWorkspace;
+ this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBox1.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(566, 176);
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ //
+ // CFNTViewer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(580, 380);
+ this.Controls.Add(this.tabControl1);
+ this.Name = "CFNTViewer";
+ this.Text = "CFNTViewer";
+ this.tabControl1.ResumeLayout(false);
+ this.tabPage1.ResumeLayout(false);
+ this.splitContainer1.Panel1.ResumeLayout(false);
+ this.splitContainer1.Panel1.PerformLayout();
+ this.splitContainer1.Panel2.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
+ this.splitContainer1.ResumeLayout(false);
+ this.panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TabControl tabControl1;
+ private System.Windows.Forms.TabPage tabPage1;
+ private System.Windows.Forms.SplitContainer splitContainer1;
+ private System.Windows.Forms.TextBox textBox1;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.TabPage tabPage2;
+ }
+}
\ No newline at end of file
diff --git a/3DS/UI/CFNTViewer.cs b/3DS/UI/CFNTViewer.cs
new file mode 100644
index 0000000..e5c9e8e
--- /dev/null
+++ b/3DS/UI/CFNTViewer.cs
@@ -0,0 +1,31 @@
+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;
+using _3DS.NintendoWare.FONT;
+using LibEveryFileExplorer.GFX;
+
+namespace _3DS.UI
+{
+ public partial class CFNTViewer : Form
+ {
+ CFNT Font;
+ BitmapFont f;
+ public CFNTViewer(CFNT Font)
+ {
+ this.Font = Font;
+ f = Font.GetBitmapFont();
+ InitializeComponent();
+ pictureBox1.Image = f.PrintToBitmap(textBox1.Text, new BitmapFont.FontRenderSettings());
+ }
+
+ private void textBox1_TextChanged(object sender, EventArgs e)
+ {
+ pictureBox1.Image = f.PrintToBitmap(textBox1.Text, new BitmapFont.FontRenderSettings());
+ }
+ }
+}
diff --git a/3DS/UI/CFNTViewer.resx b/3DS/UI/CFNTViewer.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/3DS/UI/CFNTViewer.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.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/3DS/UI/ThemeViewer.cs b/3DS/UI/ThemeViewer.cs
index 04e1af3..20878bc 100644
--- a/3DS/UI/ThemeViewer.cs
+++ b/3DS/UI/ThemeViewer.cs
@@ -32,7 +32,7 @@ namespace _3DS.UI
private void ThemeViewer_Load(object sender, EventArgs e)
{
LoadImages();
- backgroundMusicCheckbox.Checked = theme.header.backgroundMusicEnabled;
+ backgroundMusicCheckbox.Checked = theme.header.UseBGMusic;
}
private void LoadImages()
@@ -103,7 +103,7 @@ namespace _3DS.UI
private void backgroundMusicCheckbox_CheckedChanged(object sender, EventArgs e)
{
- theme.header.backgroundMusicEnabled = backgroundMusicCheckbox.Checked;
+ theme.header.UseBGMusic = backgroundMusicCheckbox.Checked;
}
}
diff --git a/EveryFileExplorer/Files/FileManager.cs b/EveryFileExplorer/Files/FileManager.cs
index e987700..68f5153 100644
--- a/EveryFileExplorer/Files/FileManager.cs
+++ b/EveryFileExplorer/Files/FileManager.cs
@@ -40,7 +40,17 @@ namespace EveryFileExplorer.Files
return false;
}
- ViewableFile vv = new ViewableFile(File, tt);
+ ViewableFile vv;
+ try
+ {
+ vv = new ViewableFile(File, tt);
+ }
+ catch (Exception e)
+ {
+ MessageBox.Show("An error occured while opening the file:\n" + e);
+ return false;
+ }
+
ViewedFiles.Add(vv);
vv.DialogClosing += new ViewableFile.DialogClosingEventHandler(v_DialogClosing);
vv.ShowDialog(Application.OpenForms[0]);
diff --git a/LibEveryFileExplorer/GFX/BitmapFont.cs b/LibEveryFileExplorer/GFX/BitmapFont.cs
new file mode 100644
index 0000000..3bb0109
--- /dev/null
+++ b/LibEveryFileExplorer/GFX/BitmapFont.cs
@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Drawing;
+
+namespace LibEveryFileExplorer.GFX
+{
+ public class BitmapFont
+ {
+ public BitmapFont()
+ {
+ Characters = new Dictionary();
+ }
+
+ public Dictionary Characters { get; private set; }
+ public int LineHeight { get; set; }
+
+ public int GetLineWidth(String Text, FontRenderSettings Settings, out int LineEnd)
+ {
+ LineEnd = -1;
+ int result = 0;
+ int i = 0;
+ foreach (char c in Text)
+ {
+ if (c == '\n')
+ {
+ if (Text.Length > i + 1) LineEnd = i + 1;
+ break;
+ }
+ else if (c == '\r') { i++; continue; }
+ if (!Characters.ContainsKey(c)) result += Settings.CharSpacing * 4;
+ else
+ {
+ Character info = Characters[c];
+ result += (int)(info.CharWidth * Settings.XScale) + Settings.CharSpacing;
+ }
+ i++;
+ }
+ if (result > 0) result -= Settings.CharSpacing;
+ return result;
+ }
+
+ public Bitmap PrintToBitmap(String Text, FontRenderSettings Settings)
+ {
+ int Width = 0;
+ int Height = 0;
+
+ int linestart = 0;
+ do
+ {
+ int lns;
+ int linewidth = GetLineWidth(Text.Substring(linestart), Settings, out lns);
+ if (lns != -1) linestart += lns;
+ else linestart = -1;
+ if (linewidth > Width) Width = linewidth;
+ Height += (int)(LineHeight * Settings.YScale) + Settings.LineSpacing;
+ }
+ while (linestart != -1);
+ Height -= Settings.LineSpacing;
+ if (Width == 0 || Height == 0) return null;
+ Bitmap b = new Bitmap(Width, Height);
+ using (Graphics g = Graphics.FromImage(b))
+ {
+ g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
+ g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
+ int X = 0;
+ int Y = 0;
+ foreach (char c in Text)
+ {
+ if (c == '\n')
+ {
+ X = 0;
+ Y += (int)(LineHeight * Settings.YScale) + Settings.LineSpacing;
+ continue;
+ }
+ else if (c == '\r') continue;
+ if (!Characters.ContainsKey(c)) X += Settings.CharSpacing * 4;
+ else
+ {
+ Character info = Characters[c];
+ g.DrawImage(info.CharBitmap,
+ new RectangleF(X + info.LeftOffset, Y, info.GlyphWidth * Settings.XScale, LineHeight * Settings.YScale),
+ new Rectangle(0, 0, info.GlyphWidth, LineHeight),
+ GraphicsUnit.Pixel);
+ X += (int)(info.CharWidth * Settings.XScale) + Settings.CharSpacing;
+ }
+ }
+ }
+ return b;
+ }
+
+ public class Character
+ {
+ public Character(Bitmap CharBitmap, int LeftOffset, int GlyphWidth, int CharWidth)
+ {
+ this.CharBitmap = CharBitmap;
+ this.LeftOffset = LeftOffset;
+ this.GlyphWidth = GlyphWidth;
+ this.CharWidth = CharWidth;
+ }
+ public Bitmap CharBitmap { get; set; }
+ public int LeftOffset { get; set; }
+ public int GlyphWidth { get; set; }
+ public int CharWidth { get; set; }
+ }
+
+ public class FontRenderSettings
+ {
+ public FontRenderSettings()
+ {
+ CharSpacing = 3;
+ XScale = YScale = 1;
+ HAlignment = XAlignment.Left;
+ VAlignment = YAlignment.Top;
+ }
+
+ public int CharSpacing { get; set; }
+ public int LineSpacing { get; set; }
+
+ public float XScale { get; set; }
+ public float YScale { get; set; }
+
+ public XAlignment HAlignment { get; set; }
+ public YAlignment VAlignment { get; set; }
+
+ public enum XAlignment
+ {
+ Left, Center, Right
+ }
+
+ public enum YAlignment
+ {
+ Top, Center, Bottom
+ }
+ }
+ }
+}
diff --git a/LibEveryFileExplorer/LibEveryFileExplorer.csproj b/LibEveryFileExplorer/LibEveryFileExplorer.csproj
index 6bc2520..fc9af98 100644
--- a/LibEveryFileExplorer/LibEveryFileExplorer.csproj
+++ b/LibEveryFileExplorer/LibEveryFileExplorer.csproj
@@ -52,6 +52,7 @@
+
diff --git a/Libraries/Microsoft.VisualBasic.PowerPacks.Vs.dll b/Libraries/Microsoft.VisualBasic.PowerPacks.Vs.dll
new file mode 100644
index 0000000..77fa750
Binary files /dev/null and b/Libraries/Microsoft.VisualBasic.PowerPacks.Vs.dll differ
diff --git a/MarioKart/MarioKart.csproj b/MarioKart/MarioKart.csproj
index fb5527c..d0c414a 100644
--- a/MarioKart/MarioKart.csproj
+++ b/MarioKart/MarioKart.csproj
@@ -34,6 +34,7 @@
False
..\..\MKDS Course Modifier\MKDS Course Modifier\bin\x86\Debug_new\Microsoft.VisualBasic.PowerPacks.Vs.dll
+ True