BCFNT Viewer and more stuff

- Named some fields for themes
- Added Microsoft.VisualBasic.PowerPacks.VS.dll
This commit is contained in:
Gericom 2014-11-19 17:33:25 +01:00
parent a0a4ba3ce8
commit 744b3f1b2b
13 changed files with 641 additions and 77 deletions

View File

@ -97,6 +97,12 @@
<Compile Include="SMDH.cs" />
<Compile Include="ThemeFile.cs" />
<Compile Include="ThemeIconFile.cs" />
<Compile Include="UI\CFNTViewer.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\CFNTViewer.Designer.cs">
<DependentUpon>CFNTViewer.cs</DependentUpon>
</Compile>
<Compile Include="UI\CGFXViewer.cs">
<SubType>Form</SubType>
</Compile>
@ -167,6 +173,9 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UI\CFNTViewer.resx">
<DependentUpon>CFNTViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\CGFXViewer.resx">
<DependentUpon>CGFXViewer.cs</DependentUpon>
</EmbeddedResource>

View File

@ -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<ushort, ushort>();
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<UInt16, UInt16> 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;
}

View File

@ -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;

View File

@ -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;

160
3DS/UI/CFNTViewer.Designer.cs generated Normal file
View File

@ -0,0 +1,160 @@
namespace _3DS.UI
{
partial class CFNTViewer
{
/// <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.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;
}
}

31
3DS/UI/CFNTViewer.cs Normal file
View File

@ -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());
}
}
}

120
3DS/UI/CFNTViewer.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<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">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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" 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">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -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;
}
}

View File

@ -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]);

View File

@ -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<char, Character>();
}
public Dictionary<char, Character> 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
}
}
}
}

View File

@ -52,6 +52,7 @@
<Compile Include="Collections\Vector2.cs" />
<Compile Include="Files\EFEDiskFile.cs" />
<Compile Include="Files\IChildReactive.cs" />
<Compile Include="GFX\BitmapFont.cs" />
<Compile Include="GFX\ETC1.cs" />
<Compile Include="GFX\PaletteUtil.cs" />
<Compile Include="Collections\Vector3.cs" />

Binary file not shown.

View File

@ -34,6 +34,7 @@
<Reference Include="Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\MKDS Course Modifier\MKDS Course Modifier\bin\x86\Debug_new\Microsoft.VisualBasic.PowerPacks.Vs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />