Add SRC
This commit is contained in:
parent
7f6734fa01
commit
ad02725efa
|
@ -0,0 +1,624 @@
|
||||||
|
namespace ChovyUI
|
||||||
|
{
|
||||||
|
partial class ChovyUI
|
||||||
|
{
|
||||||
|
/// <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.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.LBumper = new System.Windows.Forms.TextBox();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.StartButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label13 = new System.Windows.Forms.Label();
|
||||||
|
this.SelectButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label12 = new System.Windows.Forms.Label();
|
||||||
|
this.TriangleButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label11 = new System.Windows.Forms.Label();
|
||||||
|
this.SquareButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label10 = new System.Windows.Forms.Label();
|
||||||
|
this.CrossButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
|
this.CircleButton = new System.Windows.Forms.TextBox();
|
||||||
|
this.label8 = new System.Windows.Forms.Label();
|
||||||
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
|
this.DownDPAD = new System.Windows.Forms.TextBox();
|
||||||
|
this.UpDPAD = new System.Windows.Forms.TextBox();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.RightDPAD = new System.Windows.Forms.TextBox();
|
||||||
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.LeftDPAD = new System.Windows.Forms.TextBox();
|
||||||
|
this.RBumper = new System.Windows.Forms.TextBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.GMPath = new System.Windows.Forms.TextBox();
|
||||||
|
this.label14 = new System.Windows.Forms.Label();
|
||||||
|
this.BrowseEXE = new System.Windows.Forms.Button();
|
||||||
|
this.BuildISO = new System.Windows.Forms.Button();
|
||||||
|
this.label15 = new System.Windows.Forms.Label();
|
||||||
|
this.IconPath = new System.Windows.Forms.TextBox();
|
||||||
|
this.BrowseIcon = new System.Windows.Forms.Button();
|
||||||
|
this.label16 = new System.Windows.Forms.Label();
|
||||||
|
this.PicPath = new System.Windows.Forms.TextBox();
|
||||||
|
this.BrowsePic = new System.Windows.Forms.Button();
|
||||||
|
this.label17 = new System.Windows.Forms.Label();
|
||||||
|
this.TitleId = new System.Windows.Forms.TextBox();
|
||||||
|
this.label18 = new System.Windows.Forms.Label();
|
||||||
|
this.Title = new System.Windows.Forms.TextBox();
|
||||||
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.ForeColor = System.Drawing.Color.Cyan;
|
||||||
|
this.label1.Location = new System.Drawing.Point(309, 9);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(92, 13);
|
||||||
|
this.label1.TabIndex = 0;
|
||||||
|
this.label1.Text = "GameMaker: PSP";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.ForeColor = System.Drawing.Color.Cyan;
|
||||||
|
this.label2.Location = new System.Drawing.Point(6, 16);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(74, 13);
|
||||||
|
this.label2.TabIndex = 1;
|
||||||
|
this.label2.Text = "SCE_CTRL_L";
|
||||||
|
//
|
||||||
|
// LBumper
|
||||||
|
//
|
||||||
|
this.LBumper.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.LBumper.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.LBumper.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.LBumper.Location = new System.Drawing.Point(158, 16);
|
||||||
|
this.LBumper.Multiline = true;
|
||||||
|
this.LBumper.Name = "LBumper";
|
||||||
|
this.LBumper.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.LBumper.TabIndex = 4;
|
||||||
|
this.LBumper.Text = "mb_left";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.StartButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label13);
|
||||||
|
this.groupBox1.Controls.Add(this.SelectButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label12);
|
||||||
|
this.groupBox1.Controls.Add(this.TriangleButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label11);
|
||||||
|
this.groupBox1.Controls.Add(this.SquareButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label10);
|
||||||
|
this.groupBox1.Controls.Add(this.CrossButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label9);
|
||||||
|
this.groupBox1.Controls.Add(this.CircleButton);
|
||||||
|
this.groupBox1.Controls.Add(this.label8);
|
||||||
|
this.groupBox1.Controls.Add(this.label7);
|
||||||
|
this.groupBox1.Controls.Add(this.DownDPAD);
|
||||||
|
this.groupBox1.Controls.Add(this.UpDPAD);
|
||||||
|
this.groupBox1.Controls.Add(this.label6);
|
||||||
|
this.groupBox1.Controls.Add(this.RightDPAD);
|
||||||
|
this.groupBox1.Controls.Add(this.label5);
|
||||||
|
this.groupBox1.Controls.Add(this.label4);
|
||||||
|
this.groupBox1.Controls.Add(this.LeftDPAD);
|
||||||
|
this.groupBox1.Controls.Add(this.RBumper);
|
||||||
|
this.groupBox1.Controls.Add(this.label3);
|
||||||
|
this.groupBox1.Controls.Add(this.label2);
|
||||||
|
this.groupBox1.Controls.Add(this.LBumper);
|
||||||
|
this.groupBox1.ForeColor = System.Drawing.Color.Cyan;
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(194, 197);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(356, 252);
|
||||||
|
this.groupBox1.TabIndex = 3;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Control Mapping";
|
||||||
|
//
|
||||||
|
// StartButton
|
||||||
|
//
|
||||||
|
this.StartButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.StartButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.StartButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.StartButton.Location = new System.Drawing.Point(158, 225);
|
||||||
|
this.StartButton.Multiline = true;
|
||||||
|
this.StartButton.Name = "StartButton";
|
||||||
|
this.StartButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.StartButton.TabIndex = 23;
|
||||||
|
this.StartButton.Text = "vk_shift";
|
||||||
|
//
|
||||||
|
// label13
|
||||||
|
//
|
||||||
|
this.label13.AutoSize = true;
|
||||||
|
this.label13.Location = new System.Drawing.Point(6, 225);
|
||||||
|
this.label13.Name = "label13";
|
||||||
|
this.label13.Size = new System.Drawing.Size(104, 13);
|
||||||
|
this.label13.TabIndex = 22;
|
||||||
|
this.label13.Text = "SCE_CTRL_START";
|
||||||
|
//
|
||||||
|
// SelectButton
|
||||||
|
//
|
||||||
|
this.SelectButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.SelectButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.SelectButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.SelectButton.Location = new System.Drawing.Point(158, 206);
|
||||||
|
this.SelectButton.Multiline = true;
|
||||||
|
this.SelectButton.Name = "SelectButton";
|
||||||
|
this.SelectButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.SelectButton.TabIndex = 21;
|
||||||
|
this.SelectButton.Text = "vk_pause";
|
||||||
|
//
|
||||||
|
// label12
|
||||||
|
//
|
||||||
|
this.label12.AutoSize = true;
|
||||||
|
this.label12.Location = new System.Drawing.Point(6, 206);
|
||||||
|
this.label12.Name = "label12";
|
||||||
|
this.label12.Size = new System.Drawing.Size(109, 13);
|
||||||
|
this.label12.TabIndex = 20;
|
||||||
|
this.label12.Text = "SCE_CTRL_SELECT";
|
||||||
|
//
|
||||||
|
// TriangleButton
|
||||||
|
//
|
||||||
|
this.TriangleButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.TriangleButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.TriangleButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.TriangleButton.Location = new System.Drawing.Point(158, 187);
|
||||||
|
this.TriangleButton.Multiline = true;
|
||||||
|
this.TriangleButton.Name = "TriangleButton";
|
||||||
|
this.TriangleButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.TriangleButton.TabIndex = 19;
|
||||||
|
this.TriangleButton.Text = "D";
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
this.label11.AutoSize = true;
|
||||||
|
this.label11.Location = new System.Drawing.Point(6, 187);
|
||||||
|
this.label11.Name = "label11";
|
||||||
|
this.label11.Size = new System.Drawing.Size(122, 13);
|
||||||
|
this.label11.TabIndex = 18;
|
||||||
|
this.label11.Text = "SCE_CTRL_TRIANGLE";
|
||||||
|
//
|
||||||
|
// SquareButton
|
||||||
|
//
|
||||||
|
this.SquareButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.SquareButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.SquareButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.SquareButton.Location = new System.Drawing.Point(158, 168);
|
||||||
|
this.SquareButton.Multiline = true;
|
||||||
|
this.SquareButton.Name = "SquareButton";
|
||||||
|
this.SquareButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.SquareButton.TabIndex = 17;
|
||||||
|
this.SquareButton.Text = "A";
|
||||||
|
//
|
||||||
|
// label10
|
||||||
|
//
|
||||||
|
this.label10.AutoSize = true;
|
||||||
|
this.label10.Location = new System.Drawing.Point(6, 168);
|
||||||
|
this.label10.Name = "label10";
|
||||||
|
this.label10.Size = new System.Drawing.Size(113, 13);
|
||||||
|
this.label10.TabIndex = 16;
|
||||||
|
this.label10.Text = "SCE_CTRL_SQUARE";
|
||||||
|
//
|
||||||
|
// CrossButton
|
||||||
|
//
|
||||||
|
this.CrossButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.CrossButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.CrossButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.CrossButton.Location = new System.Drawing.Point(158, 149);
|
||||||
|
this.CrossButton.Multiline = true;
|
||||||
|
this.CrossButton.Name = "CrossButton";
|
||||||
|
this.CrossButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.CrossButton.TabIndex = 15;
|
||||||
|
this.CrossButton.Text = "Z";
|
||||||
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
this.label9.AutoSize = true;
|
||||||
|
this.label9.Location = new System.Drawing.Point(6, 149);
|
||||||
|
this.label9.Name = "label9";
|
||||||
|
this.label9.Size = new System.Drawing.Size(105, 13);
|
||||||
|
this.label9.TabIndex = 14;
|
||||||
|
this.label9.Text = "SCE_CTRL_CROSS";
|
||||||
|
//
|
||||||
|
// CircleButton
|
||||||
|
//
|
||||||
|
this.CircleButton.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.CircleButton.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.CircleButton.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.CircleButton.Location = new System.Drawing.Point(158, 130);
|
||||||
|
this.CircleButton.Multiline = true;
|
||||||
|
this.CircleButton.Name = "CircleButton";
|
||||||
|
this.CircleButton.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.CircleButton.TabIndex = 13;
|
||||||
|
this.CircleButton.Text = "X";
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
this.label8.AutoSize = true;
|
||||||
|
this.label8.Location = new System.Drawing.Point(6, 130);
|
||||||
|
this.label8.Name = "label8";
|
||||||
|
this.label8.Size = new System.Drawing.Size(109, 13);
|
||||||
|
this.label8.TabIndex = 12;
|
||||||
|
this.label8.Text = "SCE_CTRL_CIRCLE ";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
this.label7.AutoSize = true;
|
||||||
|
this.label7.Location = new System.Drawing.Point(6, 111);
|
||||||
|
this.label7.Name = "label7";
|
||||||
|
this.label7.Size = new System.Drawing.Size(103, 13);
|
||||||
|
this.label7.TabIndex = 11;
|
||||||
|
this.label7.Text = "SCE_CTRL_DOWN";
|
||||||
|
//
|
||||||
|
// DownDPAD
|
||||||
|
//
|
||||||
|
this.DownDPAD.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.DownDPAD.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.DownDPAD.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.DownDPAD.Location = new System.Drawing.Point(158, 111);
|
||||||
|
this.DownDPAD.Multiline = true;
|
||||||
|
this.DownDPAD.Name = "DownDPAD";
|
||||||
|
this.DownDPAD.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.DownDPAD.TabIndex = 10;
|
||||||
|
this.DownDPAD.Text = "vk_down";
|
||||||
|
//
|
||||||
|
// UpDPAD
|
||||||
|
//
|
||||||
|
this.UpDPAD.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.UpDPAD.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.UpDPAD.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.UpDPAD.Location = new System.Drawing.Point(158, 92);
|
||||||
|
this.UpDPAD.Multiline = true;
|
||||||
|
this.UpDPAD.Name = "UpDPAD";
|
||||||
|
this.UpDPAD.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.UpDPAD.TabIndex = 9;
|
||||||
|
this.UpDPAD.Text = "vk_up";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(6, 92);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(83, 13);
|
||||||
|
this.label6.TabIndex = 8;
|
||||||
|
this.label6.Text = "SCE_CTRL_UP";
|
||||||
|
//
|
||||||
|
// RightDPAD
|
||||||
|
//
|
||||||
|
this.RightDPAD.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.RightDPAD.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.RightDPAD.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.RightDPAD.Location = new System.Drawing.Point(158, 73);
|
||||||
|
this.RightDPAD.Multiline = true;
|
||||||
|
this.RightDPAD.Name = "RightDPAD";
|
||||||
|
this.RightDPAD.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.RightDPAD.TabIndex = 7;
|
||||||
|
this.RightDPAD.Text = "vk_right";
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
this.label5.AutoSize = true;
|
||||||
|
this.label5.Location = new System.Drawing.Point(6, 73);
|
||||||
|
this.label5.Name = "label5";
|
||||||
|
this.label5.Size = new System.Drawing.Size(102, 13);
|
||||||
|
this.label5.TabIndex = 6;
|
||||||
|
this.label5.Text = "SCE_CTRL_RIGHT";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.ForeColor = System.Drawing.Color.Cyan;
|
||||||
|
this.label4.Location = new System.Drawing.Point(6, 54);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(94, 13);
|
||||||
|
this.label4.TabIndex = 4;
|
||||||
|
this.label4.Text = "SCE_CTRL_LEFT";
|
||||||
|
//
|
||||||
|
// LeftDPAD
|
||||||
|
//
|
||||||
|
this.LeftDPAD.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.LeftDPAD.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.LeftDPAD.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.LeftDPAD.Location = new System.Drawing.Point(158, 54);
|
||||||
|
this.LeftDPAD.Multiline = true;
|
||||||
|
this.LeftDPAD.Name = "LeftDPAD";
|
||||||
|
this.LeftDPAD.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.LeftDPAD.TabIndex = 5;
|
||||||
|
this.LeftDPAD.Text = "vk_left";
|
||||||
|
//
|
||||||
|
// RBumper
|
||||||
|
//
|
||||||
|
this.RBumper.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.RBumper.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.RBumper.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.RBumper.Location = new System.Drawing.Point(158, 35);
|
||||||
|
this.RBumper.Multiline = true;
|
||||||
|
this.RBumper.Name = "RBumper";
|
||||||
|
this.RBumper.Size = new System.Drawing.Size(192, 13);
|
||||||
|
this.RBumper.TabIndex = 4;
|
||||||
|
this.RBumper.Text = "mb_right";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.ForeColor = System.Drawing.Color.Cyan;
|
||||||
|
this.label3.Location = new System.Drawing.Point(6, 35);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(76, 13);
|
||||||
|
this.label3.TabIndex = 3;
|
||||||
|
this.label3.Text = "SCE_CTRL_R";
|
||||||
|
//
|
||||||
|
// GMPath
|
||||||
|
//
|
||||||
|
this.GMPath.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.GMPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.GMPath.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.GMPath.Location = new System.Drawing.Point(238, 30);
|
||||||
|
this.GMPath.Name = "GMPath";
|
||||||
|
this.GMPath.Size = new System.Drawing.Size(259, 20);
|
||||||
|
this.GMPath.TabIndex = 0;
|
||||||
|
this.GMPath.TextChanged += new System.EventHandler(this.GMPath_TextChanged);
|
||||||
|
//
|
||||||
|
// label14
|
||||||
|
//
|
||||||
|
this.label14.AutoSize = true;
|
||||||
|
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||||
|
this.label14.Location = new System.Drawing.Point(176, 33);
|
||||||
|
this.label14.Name = "label14";
|
||||||
|
this.label14.Size = new System.Drawing.Size(56, 13);
|
||||||
|
this.label14.TabIndex = 5;
|
||||||
|
this.label14.Text = "GM81 exe";
|
||||||
|
//
|
||||||
|
// BrowseEXE
|
||||||
|
//
|
||||||
|
this.BrowseEXE.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.BrowseEXE.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.BrowseEXE.Location = new System.Drawing.Point(503, 29);
|
||||||
|
this.BrowseEXE.Name = "BrowseEXE";
|
||||||
|
this.BrowseEXE.Size = new System.Drawing.Size(54, 21);
|
||||||
|
this.BrowseEXE.TabIndex = 6;
|
||||||
|
this.BrowseEXE.Text = "Browse";
|
||||||
|
this.BrowseEXE.UseVisualStyleBackColor = true;
|
||||||
|
this.BrowseEXE.Click += new System.EventHandler(this.Browse_Click);
|
||||||
|
//
|
||||||
|
// BuildISO
|
||||||
|
//
|
||||||
|
this.BuildISO.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.BuildISO.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.BuildISO.Location = new System.Drawing.Point(190, 455);
|
||||||
|
this.BuildISO.Name = "BuildISO";
|
||||||
|
this.BuildISO.Size = new System.Drawing.Size(356, 23);
|
||||||
|
this.BuildISO.TabIndex = 7;
|
||||||
|
this.BuildISO.Text = "Build ISO";
|
||||||
|
this.BuildISO.UseVisualStyleBackColor = true;
|
||||||
|
this.BuildISO.Click += new System.EventHandler(this.BuildISO_Click);
|
||||||
|
//
|
||||||
|
// label15
|
||||||
|
//
|
||||||
|
this.label15.AutoSize = true;
|
||||||
|
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||||
|
this.label15.Location = new System.Drawing.Point(178, 57);
|
||||||
|
this.label15.Name = "label15";
|
||||||
|
this.label15.Size = new System.Drawing.Size(54, 13);
|
||||||
|
this.label15.TabIndex = 8;
|
||||||
|
this.label15.Text = "icon0.png";
|
||||||
|
//
|
||||||
|
// IconPath
|
||||||
|
//
|
||||||
|
this.IconPath.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.IconPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.IconPath.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.IconPath.Location = new System.Drawing.Point(238, 55);
|
||||||
|
this.IconPath.Name = "IconPath";
|
||||||
|
this.IconPath.Size = new System.Drawing.Size(259, 20);
|
||||||
|
this.IconPath.TabIndex = 9;
|
||||||
|
this.IconPath.Text = "IMG\\ICON0.PNG";
|
||||||
|
this.IconPath.TextChanged += new System.EventHandler(this.IconPath_TextChanged);
|
||||||
|
//
|
||||||
|
// BrowseIcon
|
||||||
|
//
|
||||||
|
this.BrowseIcon.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.BrowseIcon.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.BrowseIcon.Location = new System.Drawing.Point(503, 53);
|
||||||
|
this.BrowseIcon.Name = "BrowseIcon";
|
||||||
|
this.BrowseIcon.Size = new System.Drawing.Size(54, 21);
|
||||||
|
this.BrowseIcon.TabIndex = 10;
|
||||||
|
this.BrowseIcon.Text = "Browse";
|
||||||
|
this.BrowseIcon.UseVisualStyleBackColor = true;
|
||||||
|
this.BrowseIcon.Click += new System.EventHandler(this.BrowseIcon_Click);
|
||||||
|
//
|
||||||
|
// label16
|
||||||
|
//
|
||||||
|
this.label16.AutoSize = true;
|
||||||
|
this.label16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||||
|
this.label16.Location = new System.Drawing.Point(187, 81);
|
||||||
|
this.label16.Name = "label16";
|
||||||
|
this.label16.Size = new System.Drawing.Size(48, 13);
|
||||||
|
this.label16.TabIndex = 11;
|
||||||
|
this.label16.Text = "pic0.png";
|
||||||
|
//
|
||||||
|
// PicPath
|
||||||
|
//
|
||||||
|
this.PicPath.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.PicPath.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.PicPath.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.PicPath.Location = new System.Drawing.Point(238, 79);
|
||||||
|
this.PicPath.Name = "PicPath";
|
||||||
|
this.PicPath.Size = new System.Drawing.Size(259, 20);
|
||||||
|
this.PicPath.TabIndex = 12;
|
||||||
|
this.PicPath.Text = "IMG\\PIC0.PNG";
|
||||||
|
this.PicPath.TextChanged += new System.EventHandler(this.PicPath_TextChanged);
|
||||||
|
//
|
||||||
|
// BrowsePic
|
||||||
|
//
|
||||||
|
this.BrowsePic.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||||
|
this.BrowsePic.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.BrowsePic.Location = new System.Drawing.Point(503, 78);
|
||||||
|
this.BrowsePic.Name = "BrowsePic";
|
||||||
|
this.BrowsePic.Size = new System.Drawing.Size(54, 21);
|
||||||
|
this.BrowsePic.TabIndex = 13;
|
||||||
|
this.BrowsePic.Text = "Browse";
|
||||||
|
this.BrowsePic.UseVisualStyleBackColor = true;
|
||||||
|
this.BrowsePic.Click += new System.EventHandler(this.BrowsePic_Click);
|
||||||
|
//
|
||||||
|
// label17
|
||||||
|
//
|
||||||
|
this.label17.AutoSize = true;
|
||||||
|
this.label17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||||
|
this.label17.Location = new System.Drawing.Point(191, 173);
|
||||||
|
this.label17.Name = "label17";
|
||||||
|
this.label17.Size = new System.Drawing.Size(44, 13);
|
||||||
|
this.label17.TabIndex = 14;
|
||||||
|
this.label17.Text = "Title ID:";
|
||||||
|
//
|
||||||
|
// TitleId
|
||||||
|
//
|
||||||
|
this.TitleId.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.TitleId.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.TitleId.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.TitleId.Location = new System.Drawing.Point(238, 171);
|
||||||
|
this.TitleId.MaxLength = 9;
|
||||||
|
this.TitleId.Name = "TitleId";
|
||||||
|
this.TitleId.Size = new System.Drawing.Size(319, 20);
|
||||||
|
this.TitleId.TabIndex = 15;
|
||||||
|
this.TitleId.Text = "ULES99999";
|
||||||
|
this.TitleId.TextChanged += new System.EventHandler(this.TitleId_TextChanged);
|
||||||
|
//
|
||||||
|
// label18
|
||||||
|
//
|
||||||
|
this.label18.AutoSize = true;
|
||||||
|
this.label18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||||
|
this.label18.Location = new System.Drawing.Point(205, 107);
|
||||||
|
this.label18.Name = "label18";
|
||||||
|
this.label18.Size = new System.Drawing.Size(30, 13);
|
||||||
|
this.label18.TabIndex = 16;
|
||||||
|
this.label18.Text = "Title:";
|
||||||
|
//
|
||||||
|
// Title
|
||||||
|
//
|
||||||
|
this.Title.BackColor = System.Drawing.Color.Black;
|
||||||
|
this.Title.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.Title.ForeColor = System.Drawing.Color.Lime;
|
||||||
|
this.Title.Location = new System.Drawing.Point(238, 105);
|
||||||
|
this.Title.MaxLength = 64;
|
||||||
|
this.Title.Multiline = true;
|
||||||
|
this.Title.Name = "Title";
|
||||||
|
this.Title.Size = new System.Drawing.Size(319, 60);
|
||||||
|
this.Title.TabIndex = 17;
|
||||||
|
this.Title.Text = "GameMaker: PSP";
|
||||||
|
//
|
||||||
|
// pictureBox1
|
||||||
|
//
|
||||||
|
this.pictureBox1.BackgroundImage = global::ChovyUI.Properties.Resources.psmkun;
|
||||||
|
this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
|
this.pictureBox1.Size = new System.Drawing.Size(160, 473);
|
||||||
|
this.pictureBox1.TabIndex = 18;
|
||||||
|
this.pictureBox1.TabStop = false;
|
||||||
|
//
|
||||||
|
// ChovyUI
|
||||||
|
//
|
||||||
|
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(569, 494);
|
||||||
|
this.Controls.Add(this.pictureBox1);
|
||||||
|
this.Controls.Add(this.Title);
|
||||||
|
this.Controls.Add(this.label18);
|
||||||
|
this.Controls.Add(this.TitleId);
|
||||||
|
this.Controls.Add(this.label17);
|
||||||
|
this.Controls.Add(this.BrowsePic);
|
||||||
|
this.Controls.Add(this.PicPath);
|
||||||
|
this.Controls.Add(this.label16);
|
||||||
|
this.Controls.Add(this.BrowseIcon);
|
||||||
|
this.Controls.Add(this.IconPath);
|
||||||
|
this.Controls.Add(this.label15);
|
||||||
|
this.Controls.Add(this.BuildISO);
|
||||||
|
this.Controls.Add(this.BrowseEXE);
|
||||||
|
this.Controls.Add(this.label14);
|
||||||
|
this.Controls.Add(this.GMPath);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.Name = "ChovyUI";
|
||||||
|
this.Text = "CHOVY-GM";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ChovyUI_FormClosing);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label label2;
|
||||||
|
private System.Windows.Forms.TextBox LBumper;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
private System.Windows.Forms.TextBox CircleButton;
|
||||||
|
private System.Windows.Forms.Label label8;
|
||||||
|
private System.Windows.Forms.Label label7;
|
||||||
|
private System.Windows.Forms.TextBox DownDPAD;
|
||||||
|
private System.Windows.Forms.TextBox UpDPAD;
|
||||||
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.TextBox RightDPAD;
|
||||||
|
private System.Windows.Forms.Label label5;
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.TextBox LeftDPAD;
|
||||||
|
private System.Windows.Forms.TextBox RBumper;
|
||||||
|
private System.Windows.Forms.Label label3;
|
||||||
|
private System.Windows.Forms.TextBox TriangleButton;
|
||||||
|
private System.Windows.Forms.Label label11;
|
||||||
|
private System.Windows.Forms.TextBox SquareButton;
|
||||||
|
private System.Windows.Forms.Label label10;
|
||||||
|
private System.Windows.Forms.TextBox CrossButton;
|
||||||
|
private System.Windows.Forms.Label label9;
|
||||||
|
private System.Windows.Forms.Label label12;
|
||||||
|
private System.Windows.Forms.TextBox StartButton;
|
||||||
|
private System.Windows.Forms.Label label13;
|
||||||
|
private System.Windows.Forms.TextBox SelectButton;
|
||||||
|
private System.Windows.Forms.TextBox GMPath;
|
||||||
|
private System.Windows.Forms.Label label14;
|
||||||
|
private System.Windows.Forms.Button BrowseEXE;
|
||||||
|
private System.Windows.Forms.Button BuildISO;
|
||||||
|
private System.Windows.Forms.Label label15;
|
||||||
|
private System.Windows.Forms.TextBox IconPath;
|
||||||
|
private System.Windows.Forms.Button BrowseIcon;
|
||||||
|
private System.Windows.Forms.Label label16;
|
||||||
|
private System.Windows.Forms.TextBox PicPath;
|
||||||
|
private System.Windows.Forms.Button BrowsePic;
|
||||||
|
private System.Windows.Forms.Label label17;
|
||||||
|
private System.Windows.Forms.TextBox TitleId;
|
||||||
|
private System.Windows.Forms.Label label18;
|
||||||
|
private System.Windows.Forms.TextBox Title;
|
||||||
|
private System.Windows.Forms.PictureBox pictureBox1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,319 @@
|
||||||
|
using GMAssetCompiler;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ChovyUI
|
||||||
|
{
|
||||||
|
public partial class ChovyUI : Form
|
||||||
|
{
|
||||||
|
bool wasClicked = false;
|
||||||
|
public ChovyUI()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
IconPath.Text = Path.Combine(Application.StartupPath, "IMG", "ICON0.PNG");
|
||||||
|
PicPath.Text = Path.Combine(Application.StartupPath, "IMG", "PIC0.PNG");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Microsoft.Win32.RegistryKey key;
|
||||||
|
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\CHOVYProject\Chovy-GM");
|
||||||
|
|
||||||
|
TitleId.Text = key.GetValue("TITLEID", TitleId.Text).ToString();
|
||||||
|
Title.Text = key.GetValue("TITLE", Title.Text).ToString();
|
||||||
|
GMPath.Text = key.GetValue("GMEXE", GMPath.Text).ToString();
|
||||||
|
IconPath.Text = key.GetValue("ICONPATH", IconPath.Text).ToString();
|
||||||
|
PicPath.Text = key.GetValue("PICPATH", PicPath.Text).ToString();
|
||||||
|
|
||||||
|
|
||||||
|
LBumper.Text = key.GetValue("SCE_CTRL_L", LBumper.Text.ToUpper()).ToString();
|
||||||
|
RBumper.Text = key.GetValue("SCE_CTRL_R", RBumper.Text.ToUpper()).ToString();
|
||||||
|
LeftDPAD.Text = key.GetValue("SCE_CTRL_LEFT", LeftDPAD.Text.ToUpper()).ToString();
|
||||||
|
RightDPAD.Text = key.GetValue("SCE_CTRL_RIGHT", RightDPAD.Text.ToUpper()).ToString();
|
||||||
|
UpDPAD.Text = key.GetValue("SCE_CTRL_UP", UpDPAD.Text.ToUpper()).ToString();
|
||||||
|
DownDPAD.Text = key.GetValue("SCE_CTRL_DOWN", DownDPAD.Text.ToUpper()).ToString();
|
||||||
|
|
||||||
|
CircleButton.Text = key.GetValue("SCE_CTRL_CIRCLE", CircleButton.Text.ToUpper()).ToString();
|
||||||
|
CrossButton.Text = key.GetValue("SCE_CTRL_CROSS", CrossButton.Text.ToUpper()).ToString();
|
||||||
|
SquareButton.Text = key.GetValue("SCE_CTRL_SQUARE", SquareButton.Text.ToUpper()).ToString();
|
||||||
|
TriangleButton.Text = key.GetValue("SCE_CTRL_TRIANGLE", TriangleButton.Text.ToUpper()).ToString();
|
||||||
|
|
||||||
|
SelectButton.Text = key.GetValue("SCE_CTRL_SELECT", SelectButton.Text.ToUpper()).ToString();
|
||||||
|
StartButton.Text = key.GetValue("SCE_CTRL_START", StartButton.Text.ToUpper()).ToString();
|
||||||
|
key.Close();
|
||||||
|
}
|
||||||
|
catch (Exception) { };
|
||||||
|
Check();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BrowseIcon_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "PNG files (*.png)|*.png;";
|
||||||
|
openFileDialog.FilterIndex = 1;
|
||||||
|
openFileDialog.RestoreDirectory = true;
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
IconPath.Text = openFileDialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BrowsePic_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "PNG files (*.png)|*.png;";
|
||||||
|
openFileDialog.FilterIndex = 1;
|
||||||
|
openFileDialog.RestoreDirectory = true;
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
PicPath.Text = openFileDialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Browse_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "GameMaker 7/8/8.1 Executable files (*.exe)|*.exe;";
|
||||||
|
openFileDialog.FilterIndex = 1;
|
||||||
|
openFileDialog.RestoreDirectory = true;
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
GMPath.Text = openFileDialog.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CopyDirTree(string SourcePath, string DestinationPath)
|
||||||
|
{
|
||||||
|
//Now Create all of the directories
|
||||||
|
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*",
|
||||||
|
SearchOption.AllDirectories))
|
||||||
|
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath));
|
||||||
|
|
||||||
|
//Copy all the files & Replaces any files with the same name
|
||||||
|
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*",
|
||||||
|
SearchOption.AllDirectories))
|
||||||
|
File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteString(Stream s, string Str)
|
||||||
|
{
|
||||||
|
char[] carr = Str.ToCharArray();
|
||||||
|
foreach (char c in carr)
|
||||||
|
{
|
||||||
|
s.WriteByte((byte)c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void WriteValueStr(Stream s, string Key, string Value)
|
||||||
|
{
|
||||||
|
WriteString(s, Key + " = ");
|
||||||
|
WriteString(s, Value);
|
||||||
|
WriteString(s, "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildISO_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
wasClicked = true;
|
||||||
|
Program.OutputDir = Path.GetDirectoryName(GMPath.Text);
|
||||||
|
|
||||||
|
String InputFolder = Path.Combine(Program.OutputDir, "_iso_temp");
|
||||||
|
if (Directory.Exists(InputFolder))
|
||||||
|
{
|
||||||
|
Directory.Delete(InputFolder, true);
|
||||||
|
}
|
||||||
|
CopyDirTree(Path.Combine(Application.StartupPath, "RUNNER"), InputFolder);
|
||||||
|
|
||||||
|
//Write to PARAM.SFO:
|
||||||
|
FileStream sfo = new FileStream(Path.Combine(InputFolder, "PSP_GAME", "PARAM.SFO"),FileMode.OpenOrCreate,FileAccess.ReadWrite);
|
||||||
|
sfo.Seek(0x128, SeekOrigin.Begin);
|
||||||
|
WriteString(sfo, TitleId.Text);
|
||||||
|
sfo.Seek(0x158, SeekOrigin.Begin);
|
||||||
|
WriteString(sfo, Title.Text);
|
||||||
|
sfo.Close();
|
||||||
|
|
||||||
|
//Copy icon and pic0:
|
||||||
|
File.Copy(IconPath.Text, Path.Combine(InputFolder, "PSP_GAME", "ICON0.PNG"), true);
|
||||||
|
File.Copy(PicPath.Text, Path.Combine(InputFolder, "PSP_GAME", "PIC0.PNG"), true);
|
||||||
|
File.Copy(PicPath.Text, Path.Combine(InputFolder, "PSP_GAME", "USRDIR", "games","ICON0.PNG"), true);
|
||||||
|
|
||||||
|
//Write game.ini
|
||||||
|
FileStream ini = new FileStream(Path.Combine(InputFolder, "PSP_GAME", "USRDIR","games","game.ini"), FileMode.OpenOrCreate, FileAccess.ReadWrite);
|
||||||
|
ini.SetLength(0);
|
||||||
|
|
||||||
|
WriteString(ini, "[PSP_LOADSAVE]\r\n");
|
||||||
|
WriteValueStr(ini, "ICON","games /ICON0.PNG");
|
||||||
|
WriteValueStr(ini, "TITLEID", TitleId.Text);
|
||||||
|
WriteValueStr(ini, "SHORT_NAME", Title.Text);
|
||||||
|
WriteValueStr(ini, "DESC_NAME", Title.Text+ " save game.");
|
||||||
|
WriteValueStr(ini, "PARENTAL_LEVEL", "0");
|
||||||
|
|
||||||
|
WriteString(ini, "[PSP_IO]\r\n");
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_L", LBumper.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_R", RBumper.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_LEFT", LeftDPAD.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_RIGHT", RightDPAD.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_UP", UpDPAD.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_DOWN", DownDPAD.Text.ToUpper());
|
||||||
|
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_CIRCLE", CircleButton.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_CROSS", CrossButton.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_SQUARE", SquareButton.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_TRIANGLE", TriangleButton.Text.ToUpper());
|
||||||
|
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_SELECT", SelectButton.Text.ToUpper());
|
||||||
|
WriteValueStr(ini, "SCE_CTRL_START", StartButton.Text.ToUpper());
|
||||||
|
|
||||||
|
ini.Close();
|
||||||
|
|
||||||
|
this.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetGMPath()
|
||||||
|
{
|
||||||
|
return GMPath.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTitleID()
|
||||||
|
{
|
||||||
|
return TitleId.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WasClicked()
|
||||||
|
{
|
||||||
|
return wasClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Check()
|
||||||
|
{
|
||||||
|
if (File.Exists(GMPath.Text))
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(IconPath.Text))
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Bitmap bmp = new Bitmap(IconPath.Text);
|
||||||
|
if(bmp.Width != 144 || bmp.Height != 80)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BuildISO.Enabled = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(PicPath.Text))
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BuildISO.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildISO.Enabled = false;
|
||||||
|
|
||||||
|
if (TitleId.Text.Length == 9)
|
||||||
|
{
|
||||||
|
char[] TitleArray = TitleId.Text.ToArray();
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (!Char.IsLetter(TitleArray[i]))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 4; i < 9; i++)
|
||||||
|
{
|
||||||
|
if (!Char.IsNumber(TitleArray[i]))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildISO.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void GMPath_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Check();
|
||||||
|
}
|
||||||
|
private void IconPath_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PicPath_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Check();
|
||||||
|
}
|
||||||
|
private void TitleId_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int Cursor = TitleId.SelectionStart;
|
||||||
|
TitleId.Text = TitleId.Text.ToUpper();
|
||||||
|
TitleId.SelectionStart = Cursor;
|
||||||
|
|
||||||
|
Check();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChovyUI_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Microsoft.Win32.RegistryKey key;
|
||||||
|
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\CHOVYProject\Chovy-GM");
|
||||||
|
|
||||||
|
key.SetValue("TITLEID", TitleId.Text);
|
||||||
|
key.SetValue("TITLE", Title.Text);
|
||||||
|
key.SetValue("GMEXE", GMPath.Text);
|
||||||
|
key.SetValue("ICONPATH", IconPath.Text);
|
||||||
|
key.SetValue("PICPATH", PicPath.Text);
|
||||||
|
|
||||||
|
|
||||||
|
key.SetValue("SCE_CTRL_L", LBumper.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_R", RBumper.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_LEFT", LeftDPAD.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_RIGHT", RightDPAD.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_UP", UpDPAD.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_DOWN", DownDPAD.Text.ToUpper());
|
||||||
|
|
||||||
|
key.SetValue("SCE_CTRL_CIRCLE", CircleButton.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_CROSS", CrossButton.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_SQUARE", SquareButton.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_TRIANGLE", TriangleButton.Text.ToUpper());
|
||||||
|
|
||||||
|
key.SetValue("SCE_CTRL_SELECT", SelectButton.Text.ToUpper());
|
||||||
|
key.SetValue("SCE_CTRL_START", StartButton.Text.ToUpper());
|
||||||
|
key.Close();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Failed to save settings to registry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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>
|
|
@ -0,0 +1,431 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing.Design;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertyBag : ICustomTypeDescriptor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class PropertySpecCollection : IList, ICollection, IEnumerable
|
||||||
|
{
|
||||||
|
private ArrayList innerArray;
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerArray.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsFixedSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsReadOnly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSynchronized
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICollection.SyncRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (PropertySpec)innerArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
innerArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object IList.this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[index] = (PropertySpec)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecCollection()
|
||||||
|
{
|
||||||
|
innerArray = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Add(PropertySpec value)
|
||||||
|
{
|
||||||
|
return innerArray.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRange(PropertySpec[] array)
|
||||||
|
{
|
||||||
|
innerArray.AddRange(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
innerArray.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(PropertySpec item)
|
||||||
|
{
|
||||||
|
return innerArray.Contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(string name)
|
||||||
|
{
|
||||||
|
foreach (PropertySpec item in innerArray)
|
||||||
|
{
|
||||||
|
if (item.Name == name)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(PropertySpec[] array)
|
||||||
|
{
|
||||||
|
innerArray.CopyTo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(PropertySpec[] array, int index)
|
||||||
|
{
|
||||||
|
innerArray.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return innerArray.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(PropertySpec value)
|
||||||
|
{
|
||||||
|
return innerArray.IndexOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(string name)
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
foreach (PropertySpec item in innerArray)
|
||||||
|
{
|
||||||
|
if (item.Name == name)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, PropertySpec value)
|
||||||
|
{
|
||||||
|
innerArray.Insert(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(PropertySpec obj)
|
||||||
|
{
|
||||||
|
innerArray.Remove(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string name)
|
||||||
|
{
|
||||||
|
int index = IndexOf(name);
|
||||||
|
RemoveAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAt(int index)
|
||||||
|
{
|
||||||
|
innerArray.RemoveAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec[] ToArray()
|
||||||
|
{
|
||||||
|
return (PropertySpec[])innerArray.ToArray(typeof(PropertySpec));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICollection.CopyTo(Array array, int index)
|
||||||
|
{
|
||||||
|
CopyTo((PropertySpec[])array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IList.Add(object value)
|
||||||
|
{
|
||||||
|
return Add((PropertySpec)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IList.Contains(object obj)
|
||||||
|
{
|
||||||
|
return Contains((PropertySpec)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IList.IndexOf(object obj)
|
||||||
|
{
|
||||||
|
return IndexOf((PropertySpec)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IList.Insert(int index, object value)
|
||||||
|
{
|
||||||
|
Insert(index, (PropertySpec)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IList.Remove(object value)
|
||||||
|
{
|
||||||
|
Remove((PropertySpec)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PropertySpecDescriptor : PropertyDescriptor
|
||||||
|
{
|
||||||
|
private PropertyBag bag;
|
||||||
|
|
||||||
|
private PropertySpec item;
|
||||||
|
|
||||||
|
public override Type ComponentType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return item.GetType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsReadOnly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Attributes.Matches(ReadOnlyAttribute.Yes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type PropertyType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Type.GetType(item.TypeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecDescriptor(PropertySpec item, PropertyBag bag, string name, Attribute[] attrs)
|
||||||
|
: base(name, attrs)
|
||||||
|
{
|
||||||
|
this.bag = bag;
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanResetValue(object component)
|
||||||
|
{
|
||||||
|
if (item.DefaultValue == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !GetValue(component).Equals(item.DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object GetValue(object component)
|
||||||
|
{
|
||||||
|
PropertySpecEventArgs propertySpecEventArgs = new PropertySpecEventArgs(item, null);
|
||||||
|
bag.OnGetValue(propertySpecEventArgs);
|
||||||
|
return propertySpecEventArgs.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ResetValue(object component)
|
||||||
|
{
|
||||||
|
SetValue(component, item.DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetValue(object component, object value)
|
||||||
|
{
|
||||||
|
PropertySpecEventArgs e = new PropertySpecEventArgs(item, value);
|
||||||
|
bag.OnSetValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool ShouldSerializeValue(object component)
|
||||||
|
{
|
||||||
|
object value = GetValue(component);
|
||||||
|
if (item.DefaultValue == null && value == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !value.Equals(item.DefaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string defaultProperty;
|
||||||
|
|
||||||
|
private PropertySpecCollection properties;
|
||||||
|
|
||||||
|
public string DefaultProperty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultProperty;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
defaultProperty = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecCollection Properties
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertySpecEventHandler GetValue;
|
||||||
|
|
||||||
|
public event PropertySpecEventHandler SetValue;
|
||||||
|
|
||||||
|
public PropertyBag()
|
||||||
|
{
|
||||||
|
defaultProperty = null;
|
||||||
|
properties = new PropertySpecCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnGetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.GetValue != null)
|
||||||
|
{
|
||||||
|
this.GetValue(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.SetValue != null)
|
||||||
|
{
|
||||||
|
this.SetValue(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AttributeCollection ICustomTypeDescriptor.GetAttributes()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetAttributes(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ICustomTypeDescriptor.GetClassName()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetClassName(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ICustomTypeDescriptor.GetComponentName()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetComponentName(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeConverter ICustomTypeDescriptor.GetConverter()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetConverter(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
|
||||||
|
{
|
||||||
|
PropertySpec propertySpec = null;
|
||||||
|
if (defaultProperty != null)
|
||||||
|
{
|
||||||
|
int index = properties.IndexOf(defaultProperty);
|
||||||
|
propertySpec = properties[index];
|
||||||
|
}
|
||||||
|
if (propertySpec != null)
|
||||||
|
{
|
||||||
|
return new PropertySpecDescriptor(propertySpec, this, propertySpec.Name, null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEvents(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
|
||||||
|
{
|
||||||
|
return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
|
||||||
|
{
|
||||||
|
ArrayList arrayList = new ArrayList();
|
||||||
|
foreach (PropertySpec property in properties)
|
||||||
|
{
|
||||||
|
ArrayList arrayList2 = new ArrayList();
|
||||||
|
if (property.Category != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new CategoryAttribute(property.Category));
|
||||||
|
}
|
||||||
|
if (property.Description != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new DescriptionAttribute(property.Description));
|
||||||
|
}
|
||||||
|
if (property.EditorTypeName != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new EditorAttribute(property.EditorTypeName, typeof(UITypeEditor)));
|
||||||
|
}
|
||||||
|
if (property.ConverterTypeName != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new TypeConverterAttribute(property.ConverterTypeName));
|
||||||
|
}
|
||||||
|
if (property.Attributes != null)
|
||||||
|
{
|
||||||
|
arrayList2.AddRange(property.Attributes);
|
||||||
|
}
|
||||||
|
Attribute[] attrs = (Attribute[])arrayList2.ToArray(typeof(Attribute));
|
||||||
|
PropertySpecDescriptor value = new PropertySpecDescriptor(property, this, property.Name, attrs);
|
||||||
|
arrayList.Add(value);
|
||||||
|
}
|
||||||
|
PropertyDescriptor[] array = (PropertyDescriptor[])arrayList.ToArray(typeof(PropertyDescriptor));
|
||||||
|
return new PropertyDescriptorCollection(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertySpec
|
||||||
|
{
|
||||||
|
private Attribute[] attributes;
|
||||||
|
|
||||||
|
private string category;
|
||||||
|
|
||||||
|
private object defaultValue;
|
||||||
|
|
||||||
|
private string description;
|
||||||
|
|
||||||
|
private string editor;
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
|
||||||
|
private string type;
|
||||||
|
|
||||||
|
private string typeConverter;
|
||||||
|
|
||||||
|
public Attribute[] Attributes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
attributes = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Category
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
category = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConverterTypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return typeConverter;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
typeConverter = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object DefaultValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
defaultValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
description = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EditorTypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
editor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
type = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type)
|
||||||
|
: this(name, type, null, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type)
|
||||||
|
: this(name, type.AssemblyQualifiedName, null, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category)
|
||||||
|
: this(name, type, category, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description)
|
||||||
|
: this(name, type, category, description, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
this.category = category;
|
||||||
|
this.description = description;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
attributes = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, string editor, string typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue)
|
||||||
|
{
|
||||||
|
this.editor = editor;
|
||||||
|
this.typeConverter = typeConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, string editor, string typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, Type editor, string typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, Type editor, string typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, string editor, Type typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, string editor, Type typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, Type editor, Type typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, Type editor, Type typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertySpecEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private PropertySpec property;
|
||||||
|
|
||||||
|
private object val;
|
||||||
|
|
||||||
|
public PropertySpec Property
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
val = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecEventArgs(PropertySpec property, object val)
|
||||||
|
{
|
||||||
|
this.property = property;
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertyTable : PropertyBag
|
||||||
|
{
|
||||||
|
private Hashtable propValues;
|
||||||
|
|
||||||
|
public object this[string key]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return propValues[key];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
propValues[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyTable()
|
||||||
|
{
|
||||||
|
propValues = new Hashtable();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnGetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
e.Value = propValues[e.Property.Name];
|
||||||
|
base.OnGetValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnSetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
propValues[e.Property.Name] = e.Value;
|
||||||
|
base.OnSetValue(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,431 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing.Design;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertyBag : ICustomTypeDescriptor
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class PropertySpecCollection : IList, ICollection, IEnumerable
|
||||||
|
{
|
||||||
|
private ArrayList innerArray;
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerArray.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsFixedSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsReadOnly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSynchronized
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICollection.SyncRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (PropertySpec)innerArray[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
innerArray[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object IList.this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this[index];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[index] = (PropertySpec)value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecCollection()
|
||||||
|
{
|
||||||
|
innerArray = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Add(PropertySpec value)
|
||||||
|
{
|
||||||
|
return innerArray.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRange(PropertySpec[] array)
|
||||||
|
{
|
||||||
|
innerArray.AddRange(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
innerArray.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(PropertySpec item)
|
||||||
|
{
|
||||||
|
return innerArray.Contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(string name)
|
||||||
|
{
|
||||||
|
foreach (PropertySpec item in innerArray)
|
||||||
|
{
|
||||||
|
if (item.Name == name)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(PropertySpec[] array)
|
||||||
|
{
|
||||||
|
innerArray.CopyTo(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(PropertySpec[] array, int index)
|
||||||
|
{
|
||||||
|
innerArray.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return innerArray.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(PropertySpec value)
|
||||||
|
{
|
||||||
|
return innerArray.IndexOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(string name)
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
foreach (PropertySpec item in innerArray)
|
||||||
|
{
|
||||||
|
if (item.Name == name)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, PropertySpec value)
|
||||||
|
{
|
||||||
|
innerArray.Insert(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(PropertySpec obj)
|
||||||
|
{
|
||||||
|
innerArray.Remove(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string name)
|
||||||
|
{
|
||||||
|
int index = IndexOf(name);
|
||||||
|
RemoveAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAt(int index)
|
||||||
|
{
|
||||||
|
innerArray.RemoveAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec[] ToArray()
|
||||||
|
{
|
||||||
|
return (PropertySpec[])innerArray.ToArray(typeof(PropertySpec));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ICollection.CopyTo(Array array, int index)
|
||||||
|
{
|
||||||
|
CopyTo((PropertySpec[])array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IList.Add(object value)
|
||||||
|
{
|
||||||
|
return Add((PropertySpec)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IList.Contains(object obj)
|
||||||
|
{
|
||||||
|
return Contains((PropertySpec)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IList.IndexOf(object obj)
|
||||||
|
{
|
||||||
|
return IndexOf((PropertySpec)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IList.Insert(int index, object value)
|
||||||
|
{
|
||||||
|
Insert(index, (PropertySpec)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IList.Remove(object value)
|
||||||
|
{
|
||||||
|
Remove((PropertySpec)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PropertySpecDescriptor : PropertyDescriptor
|
||||||
|
{
|
||||||
|
private PropertyBag bag;
|
||||||
|
|
||||||
|
private PropertySpec item;
|
||||||
|
|
||||||
|
public override Type ComponentType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return item.GetType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsReadOnly
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Attributes.Matches(ReadOnlyAttribute.Yes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Type PropertyType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Type.GetType(item.TypeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecDescriptor(PropertySpec item, PropertyBag bag, string name, Attribute[] attrs)
|
||||||
|
: base(name, attrs)
|
||||||
|
{
|
||||||
|
this.bag = bag;
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanResetValue(object component)
|
||||||
|
{
|
||||||
|
if (item.DefaultValue == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !GetValue(component).Equals(item.DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object GetValue(object component)
|
||||||
|
{
|
||||||
|
PropertySpecEventArgs propertySpecEventArgs = new PropertySpecEventArgs(item, null);
|
||||||
|
bag.OnGetValue(propertySpecEventArgs);
|
||||||
|
return propertySpecEventArgs.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ResetValue(object component)
|
||||||
|
{
|
||||||
|
SetValue(component, item.DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetValue(object component, object value)
|
||||||
|
{
|
||||||
|
PropertySpecEventArgs e = new PropertySpecEventArgs(item, value);
|
||||||
|
bag.OnSetValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool ShouldSerializeValue(object component)
|
||||||
|
{
|
||||||
|
object value = GetValue(component);
|
||||||
|
if (item.DefaultValue == null && value == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !value.Equals(item.DefaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string defaultProperty;
|
||||||
|
|
||||||
|
private PropertySpecCollection properties;
|
||||||
|
|
||||||
|
public string DefaultProperty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultProperty;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
defaultProperty = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecCollection Properties
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertySpecEventHandler GetValue;
|
||||||
|
|
||||||
|
public event PropertySpecEventHandler SetValue;
|
||||||
|
|
||||||
|
public PropertyBag()
|
||||||
|
{
|
||||||
|
defaultProperty = null;
|
||||||
|
properties = new PropertySpecCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnGetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.GetValue != null)
|
||||||
|
{
|
||||||
|
this.GetValue(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnSetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.SetValue != null)
|
||||||
|
{
|
||||||
|
this.SetValue(this, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AttributeCollection ICustomTypeDescriptor.GetAttributes()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetAttributes(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ICustomTypeDescriptor.GetClassName()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetClassName(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ICustomTypeDescriptor.GetComponentName()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetComponentName(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeConverter ICustomTypeDescriptor.GetConverter()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetConverter(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetDefaultEvent(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptor ICustomTypeDescriptor.GetDefaultProperty()
|
||||||
|
{
|
||||||
|
PropertySpec propertySpec = null;
|
||||||
|
if (defaultProperty != null)
|
||||||
|
{
|
||||||
|
int index = properties.IndexOf(defaultProperty);
|
||||||
|
propertySpec = properties[index];
|
||||||
|
}
|
||||||
|
if (propertySpec != null)
|
||||||
|
{
|
||||||
|
return new PropertySpecDescriptor(propertySpec, this, propertySpec.Name, null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEvents(this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
|
||||||
|
{
|
||||||
|
return TypeDescriptor.GetEvents(this, attributes, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties()
|
||||||
|
{
|
||||||
|
return ((ICustomTypeDescriptor)this).GetProperties(new Attribute[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
|
||||||
|
{
|
||||||
|
ArrayList arrayList = new ArrayList();
|
||||||
|
foreach (PropertySpec property in properties)
|
||||||
|
{
|
||||||
|
ArrayList arrayList2 = new ArrayList();
|
||||||
|
if (property.Category != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new CategoryAttribute(property.Category));
|
||||||
|
}
|
||||||
|
if (property.Description != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new DescriptionAttribute(property.Description));
|
||||||
|
}
|
||||||
|
if (property.EditorTypeName != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new EditorAttribute(property.EditorTypeName, typeof(UITypeEditor)));
|
||||||
|
}
|
||||||
|
if (property.ConverterTypeName != null)
|
||||||
|
{
|
||||||
|
arrayList2.Add(new TypeConverterAttribute(property.ConverterTypeName));
|
||||||
|
}
|
||||||
|
if (property.Attributes != null)
|
||||||
|
{
|
||||||
|
arrayList2.AddRange(property.Attributes);
|
||||||
|
}
|
||||||
|
Attribute[] attrs = (Attribute[])arrayList2.ToArray(typeof(Attribute));
|
||||||
|
PropertySpecDescriptor value = new PropertySpecDescriptor(property, this, property.Name, attrs);
|
||||||
|
arrayList.Add(value);
|
||||||
|
}
|
||||||
|
PropertyDescriptor[] array = (PropertyDescriptor[])arrayList.ToArray(typeof(PropertyDescriptor));
|
||||||
|
return new PropertyDescriptorCollection(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor pd)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertySpec
|
||||||
|
{
|
||||||
|
private Attribute[] attributes;
|
||||||
|
|
||||||
|
private string category;
|
||||||
|
|
||||||
|
private object defaultValue;
|
||||||
|
|
||||||
|
private string description;
|
||||||
|
|
||||||
|
private string editor;
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
|
||||||
|
private string type;
|
||||||
|
|
||||||
|
private string typeConverter;
|
||||||
|
|
||||||
|
public Attribute[] Attributes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
attributes = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Category
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
category = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConverterTypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return typeConverter;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
typeConverter = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object DefaultValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
defaultValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
description = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EditorTypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
editor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
name = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TypeName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
type = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type)
|
||||||
|
: this(name, type, null, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type)
|
||||||
|
: this(name, type.AssemblyQualifiedName, null, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category)
|
||||||
|
: this(name, type, category, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, null, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description)
|
||||||
|
: this(name, type, category, description, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
this.category = category;
|
||||||
|
this.description = description;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
attributes = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, string editor, string typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue)
|
||||||
|
{
|
||||||
|
this.editor = editor;
|
||||||
|
this.typeConverter = typeConverter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, string editor, string typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, Type editor, string typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, Type editor, string typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, string editor, Type typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, string editor, Type typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, string type, string category, string description, object defaultValue, Type editor, Type typeConverter)
|
||||||
|
: this(name, type, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpec(string name, Type type, string category, string description, object defaultValue, Type editor, Type typeConverter)
|
||||||
|
: this(name, type.AssemblyQualifiedName, category, description, defaultValue, editor.AssemblyQualifiedName, typeConverter.AssemblyQualifiedName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertySpecEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private PropertySpec property;
|
||||||
|
|
||||||
|
private object val;
|
||||||
|
|
||||||
|
public PropertySpec Property
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
val = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertySpecEventArgs(PropertySpec property, object val)
|
||||||
|
{
|
||||||
|
this.property = property;
|
||||||
|
this.val = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Flobbster.Windows.Forms
|
||||||
|
{
|
||||||
|
public class PropertyTable : PropertyBag
|
||||||
|
{
|
||||||
|
private Hashtable propValues;
|
||||||
|
|
||||||
|
public object this[string key]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return propValues[key];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
propValues[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyTable()
|
||||||
|
{
|
||||||
|
propValues = new Hashtable();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnGetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
e.Value = propValues[e.Property.Name];
|
||||||
|
base.OnGetValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnSetValue(PropertySpecEventArgs e)
|
||||||
|
{
|
||||||
|
propValues[e.Property.Name] = e.Value;
|
||||||
|
base.OnSetValue(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class Android : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Android";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Android";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eWAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".droid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) >> 4) | (_r & 0xF0) | ((_g & 0xF0) << 4) | ((_b & 0xF0) << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class HTML5 : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "HTML5";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "HTML5 - web target";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eHTML5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".js";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 2048;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 2048;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) << 8) | ((_r & 0xF0) << 4) | (_g & 0xF0) | ((_b & 0xF0) >> 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class IOS : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "iOS";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "iPod Touch, iPhone, iPad";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eWAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".ios";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) >> 4) | (_r & 0xF0) | ((_g & 0xF0) << 4) | ((_b & 0xF0) << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class PSP : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "PSP";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Sony PSP Minis";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eWAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".psp";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 512;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 512;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.eDXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.eDXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) << 8) | ((_r & 0xF0) << 4) | (_g & 0xF0) | ((_b & 0xF0) >> 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class Symbian : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Symbian";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Symbian";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eWAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".symbian";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.ePNG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) >> 4) | (_r & 0xF0) | ((_g & 0xF0) << 4) | ((_b & 0xF0) << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,111 @@
|
||||||
|
namespace GMAssetCompiler.Machines
|
||||||
|
{
|
||||||
|
internal class Windows : IMachineType
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Windows";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Windows OS platform, targeting Direct X";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eOutputType OutputType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eOutputType.eWAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ".win";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageWidth
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderTop
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TPageBorderRight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.eDXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return eTexType.eDXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ushort Convert4444(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (ushort)(((_a & 0xF0) << 8) | ((_r & 0xF0) << 4) | (_g & 0xF0) | ((_b & 0xF0) >> 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Convert8888(int _a, int _r, int _g, int _b)
|
||||||
|
{
|
||||||
|
return (uint)((_a << 24) | (_r << 16) | (_g << 8) | _b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler.Output
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.All)]
|
||||||
|
internal class TextureOptionAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Description = string.Empty;
|
||||||
|
|
||||||
|
public TextureOptionAttribute(string _description)
|
||||||
|
{
|
||||||
|
Description = _description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler.Output
|
||||||
|
{
|
||||||
|
internal class TextureOptions
|
||||||
|
{
|
||||||
|
private static Dictionary<string, List<string>> TextureResourcesOptions
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ValidTextureOptions()
|
||||||
|
{
|
||||||
|
string text = "";
|
||||||
|
MemberInfo[] members = typeof(TexturePageEntry).GetMembers();
|
||||||
|
MemberInfo[] array = members;
|
||||||
|
foreach (MemberInfo memberInfo in array)
|
||||||
|
{
|
||||||
|
object[] customAttributes = memberInfo.GetCustomAttributes(typeof(TextureOptionAttribute), true);
|
||||||
|
object[] array2 = customAttributes;
|
||||||
|
foreach (object obj in array2)
|
||||||
|
{
|
||||||
|
TextureOptionAttribute textureOptionAttribute = obj as TextureOptionAttribute;
|
||||||
|
text = text + memberInfo.Name + ": " + textureOptionAttribute.Description + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PopulateResourceOptions()
|
||||||
|
{
|
||||||
|
if (TextureResourcesOptions != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TextureResourcesOptions = new Dictionary<string, List<string>>();
|
||||||
|
MemberInfo[] members = typeof(TexturePageEntry).GetMembers();
|
||||||
|
MemberInfo[] array = members;
|
||||||
|
foreach (MemberInfo memberInfo in array)
|
||||||
|
{
|
||||||
|
object[] customAttributes = memberInfo.GetCustomAttributes(typeof(TextureOptionAttribute), true);
|
||||||
|
object[] array2 = customAttributes;
|
||||||
|
for (int j = 0; j < array2.Length; j++)
|
||||||
|
{
|
||||||
|
object obj = array2[j];
|
||||||
|
TextureResourcesOptions.Add(memberInfo.Name, new List<string>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddResourceOptions(string _optionName, List<string> _resources)
|
||||||
|
{
|
||||||
|
PopulateResourceOptions();
|
||||||
|
if (TextureResourcesOptions.ContainsKey(_optionName))
|
||||||
|
{
|
||||||
|
TextureResourcesOptions[_optionName].AddRange(_resources);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetTextureOptions(string _GMResourceName, TexturePageEntry _tpageEntry)
|
||||||
|
{
|
||||||
|
if (TextureResourcesOptions != null)
|
||||||
|
{
|
||||||
|
Type type = _tpageEntry.GetType();
|
||||||
|
foreach (KeyValuePair<string, List<string>> textureResourcesOption in TextureResourcesOptions)
|
||||||
|
{
|
||||||
|
if (textureResourcesOption.Value.Contains(_GMResourceName))
|
||||||
|
{
|
||||||
|
type.GetProperty(textureResourcesOption.Key).SetValue(_tpageEntry, true, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler.Properties
|
||||||
|
{
|
||||||
|
[DebuggerNonUserCode]
|
||||||
|
[CompilerGenerated]
|
||||||
|
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
private static ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||||
|
internal static ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (resourceMan == null)
|
||||||
|
{
|
||||||
|
ResourceManager resourceManager = resourceMan = new ResourceManager("GMAssetCompiler.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||||
|
internal static CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.CodeDom.Compiler;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler.Properties
|
||||||
|
{
|
||||||
|
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
||||||
|
[CompilerGenerated]
|
||||||
|
internal sealed class Settings : ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
private static Settings defaultInstance = (Settings)SettingsBase.Synchronized(new Settings());
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,217 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectGuid>{9448EC1D-1983-4043-ACE5-94049A822CD7}</ProjectGuid>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<LangVersion>5</LangVersion>
|
||||||
|
<AssemblyName>SilicaAssetCompiler</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="NAudio, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\NAudio.1.9.0\lib\net35\NAudio.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Windows.Forms">
|
||||||
|
<HintPath>C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System">
|
||||||
|
<HintPath>C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing">
|
||||||
|
<HintPath>C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<HintPath>C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Ionic.Zip.Reduced">
|
||||||
|
<HintPath>C:\Users\Nik\AppData\Roaming\GameMaker-Studio\Ionic.Zip.Reduced.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Flobbster.Windows.Forms\PropertyBag.cs" />
|
||||||
|
<Compile Include="Flobbster.Windows.Forms\PropertySpec.cs" />
|
||||||
|
<Compile Include="Flobbster.Windows.Forms\PropertySpecEventArgs.cs" />
|
||||||
|
<Compile Include="Flobbster.Windows.Forms\PropertySpecEventHandler.cs" />
|
||||||
|
<Compile Include="Flobbster.Windows.Forms\PropertyTable.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\Android.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\HTML5.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\IOS.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\PSP.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\Symbian.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Machines\Windows.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Output\TextureOptionAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Output\TextureOptions.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Properties\Resources.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler.Properties\Settings.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\DDS.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\DummyStream.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eAction.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eArgTypes.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eErrorKind.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eExecuteTypes.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eGMLCodeType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eKind.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eLex.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eObject.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eOutputType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eSquishCPU.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eSquishFlags.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eTexType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eToken.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eVM_ConditionCode.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eVM_Instruction.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eVM_InstructionBase.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\eVM_Type.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\ExtensionKind.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Form1.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="GMAssetCompiler\GMAction.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMAssets.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMBack.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMBackground.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMBitmap32.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMDataFile.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMEvent.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMExtension.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMExtensionConstant.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMExtensionFunction.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMExtensionInclude.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMFont.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMGlyph.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMHelp.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMInstance.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GML2JavaScript.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GML2VM.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLCode.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLCompile.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLError.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLFunction.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLToken.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLValue.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMLVariable.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMObject.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMOptions.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMPath.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMPathPoint.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMRoom.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMScript.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMSound.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMSprite.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMTile.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMTimeLine.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMTrigger.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\GMView.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\HTML5Saver.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFF.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFChunkHandler.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFChunkSaver.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFChunkType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFPatchEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFSaver.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IFFString.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IIFFChunkHandler.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IMachineType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\IPropertyGrid.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Lex.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\LexTree.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Loader.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Program.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\PropertyAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Squish.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\StreamHelper.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Texture.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\TexturePage.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\TexturePageEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Trace.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\VAG.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\VFNode.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\View.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\ViewBackground.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\ViewFont.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\ViewSprite.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\VMBuffer.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\VMLabel.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\Wave.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYArgEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYArgName.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYArgType.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYArrayCountAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYBackground.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYEvent.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYFixedArrayCountAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYFont.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYGlyph.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYHeader.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYObfuscate.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYObject.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYObjectEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYObjectEntryLevel2.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYOffsetToAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYOptionKVP.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYOptions.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYPath.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYPathPoint.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\yyRect.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoom.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomBackground.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomBackgrounds.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomInstance.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomInstances.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomOrderEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomTile.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomTiles.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomView.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYRoomViews.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYScript.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYSound.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYSprite.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYStringOffsetAttribute.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYTimeline.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYTimelineEntry.cs" />
|
||||||
|
<Compile Include="GMAssetCompiler\YYTPageEntry.cs" />
|
||||||
|
<Compile Include="NDesk.Options\Option.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionAction.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionContext.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionException.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionSet.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionValueCollection.cs" />
|
||||||
|
<Compile Include="NDesk.Options\OptionValueType.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="GMAssetCompiler\Form1.resx" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Express 2013 for Windows Desktop
|
||||||
|
VisualStudioVersion = 12.0.40629.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GMAssetCompiler", "GMAssetCompiler.csproj", "{9448EC1D-1983-4043-ACE5-94049A822CD7}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{9448EC1D-1983-4043-ACE5-94049A822CD7}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{9448EC1D-1983-4043-ACE5-94049A822CD7}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{9448EC1D-1983-4043-ACE5-94049A822CD7}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{9448EC1D-1983-4043-ACE5-94049A822CD7}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
Binary file not shown.
|
@ -0,0 +1,126 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class DDS
|
||||||
|
{
|
||||||
|
public struct SDDPIXELFORMAT
|
||||||
|
{
|
||||||
|
public uint dwSize;
|
||||||
|
|
||||||
|
public uint dwFlags;
|
||||||
|
|
||||||
|
public uint dwFourCC;
|
||||||
|
|
||||||
|
public uint dwRGBBitCount;
|
||||||
|
|
||||||
|
public uint dwRBitMask;
|
||||||
|
|
||||||
|
public uint dwGBitMask;
|
||||||
|
|
||||||
|
public uint dwBBitMask;
|
||||||
|
|
||||||
|
public uint dwRGBAlphaBitMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct SDDCAPS2
|
||||||
|
{
|
||||||
|
public uint dwCaps1;
|
||||||
|
|
||||||
|
public uint dwCaps2;
|
||||||
|
|
||||||
|
public uint Reserved1;
|
||||||
|
|
||||||
|
public uint Reserved2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct SDDSHeader
|
||||||
|
{
|
||||||
|
public uint Magic;
|
||||||
|
|
||||||
|
public uint dwSize;
|
||||||
|
|
||||||
|
public uint dwFlags;
|
||||||
|
|
||||||
|
public uint dwHeight;
|
||||||
|
|
||||||
|
public uint dwWidth;
|
||||||
|
|
||||||
|
public uint dwPitchOrLinearSize;
|
||||||
|
|
||||||
|
public uint dwDepth;
|
||||||
|
|
||||||
|
public uint dwMipMapCount;
|
||||||
|
|
||||||
|
public uint dwReserved1;
|
||||||
|
|
||||||
|
public uint dwReserved1_2;
|
||||||
|
|
||||||
|
public uint dwReserved1_3;
|
||||||
|
|
||||||
|
public uint dwReserved1_4;
|
||||||
|
|
||||||
|
public uint dwReserved1_5;
|
||||||
|
|
||||||
|
public uint dwReserved1_6;
|
||||||
|
|
||||||
|
public uint dwReserved1_7;
|
||||||
|
|
||||||
|
public uint dwReserved1_8;
|
||||||
|
|
||||||
|
public uint dwReserved1_9;
|
||||||
|
|
||||||
|
public uint dwReserved1_10;
|
||||||
|
|
||||||
|
public uint dwReserved1_11;
|
||||||
|
|
||||||
|
public SDDPIXELFORMAT ddpfPixelFormat;
|
||||||
|
|
||||||
|
public SDDCAPS2 ddsCaps;
|
||||||
|
|
||||||
|
public uint dwReserved2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public const uint DDSD_CAPS = 1u;
|
||||||
|
|
||||||
|
public const uint DDSD_HEIGHT = 2u;
|
||||||
|
|
||||||
|
public const uint DDSD_WIDTH = 4u;
|
||||||
|
|
||||||
|
public const uint DDSD_PITCH = 8u;
|
||||||
|
|
||||||
|
public const uint DDSD_PIXELFORMAT = 4096u;
|
||||||
|
|
||||||
|
public const uint DDSD_MIPMAPCOUNT = 131072u;
|
||||||
|
|
||||||
|
public const uint DDSD_LINEARSIZE = 524288u;
|
||||||
|
|
||||||
|
public const uint DDSD_DEPTH = 8388608u;
|
||||||
|
|
||||||
|
public const uint DDPF_ALPHAPIXELS = 1u;
|
||||||
|
|
||||||
|
public const uint DDPF_FOURCC = 4u;
|
||||||
|
|
||||||
|
public const uint DDPF_RGB = 64u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS_COMPLEX = 8u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS_TEXTURE = 4096u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS_MIPMAP = 4194304u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP = 512u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_POSITIVEX = 1024u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_NEGATIVEX = 2048u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_POSITIVEY = 4096u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_NEGATIVEY = 8192u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_POSITIVEZ = 16384u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_CUBEMAP_NEGATIVEZ = 32768u;
|
||||||
|
|
||||||
|
public const uint DDSCAPS2_VOLUME = 2097152u;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class DummyStream : Stream
|
||||||
|
{
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal enum ExtensionKind
|
||||||
|
{
|
||||||
|
Error = -1,
|
||||||
|
Undefined = 0,
|
||||||
|
Dll = 1,
|
||||||
|
Gml = 2,
|
||||||
|
Lib = 3,
|
||||||
|
Other = 4,
|
||||||
|
Stdcall = 11,
|
||||||
|
Cdecl = 12
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,203 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMAction
|
||||||
|
{
|
||||||
|
private static int countScript;
|
||||||
|
|
||||||
|
public int LibID
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ID
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eAction Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseRelative
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsQuestion
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseApplyTo
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eExecuteTypes ExeType
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ArgumentCount
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<eArgTypes> ArgTypes
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Who
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Relative
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<string> Args
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsNot
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMAction(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
LibID = _stream.ReadInteger();
|
||||||
|
ID = _stream.ReadInteger();
|
||||||
|
Kind = (eAction)_stream.ReadInteger();
|
||||||
|
UseRelative = _stream.ReadBoolean();
|
||||||
|
IsQuestion = _stream.ReadBoolean();
|
||||||
|
UseApplyTo = _stream.ReadBoolean();
|
||||||
|
ExeType = (eExecuteTypes)_stream.ReadInteger();
|
||||||
|
Name = _stream.ReadString();
|
||||||
|
Code = _stream.ReadString();
|
||||||
|
ArgumentCount = _stream.ReadInteger();
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
ArgTypes = new List<eArgTypes>(num);
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
ArgTypes.Add((eArgTypes)_stream.ReadInteger());
|
||||||
|
}
|
||||||
|
Who = _stream.ReadInteger();
|
||||||
|
Relative = _stream.ReadBoolean();
|
||||||
|
num = _stream.ReadInteger();
|
||||||
|
Args = new List<string>(num);
|
||||||
|
for (int j = 0; j < num; j++)
|
||||||
|
{
|
||||||
|
Args.Add(_stream.ReadString());
|
||||||
|
}
|
||||||
|
IsNot = _stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMAction(int _id, string _code)
|
||||||
|
{
|
||||||
|
LibID = 1;
|
||||||
|
ID = _id;
|
||||||
|
Kind = eAction.ACT_CODE;
|
||||||
|
UseRelative = false;
|
||||||
|
IsQuestion = false;
|
||||||
|
UseApplyTo = true;
|
||||||
|
ExeType = eExecuteTypes.EXE_CODE;
|
||||||
|
Name = string.Empty;
|
||||||
|
Code = string.Empty;
|
||||||
|
ArgumentCount = 1;
|
||||||
|
ArgTypes = new List<eArgTypes>(1);
|
||||||
|
ArgTypes.Add(eArgTypes.ARG_STRING);
|
||||||
|
Who = -1;
|
||||||
|
Relative = false;
|
||||||
|
Args = new List<string>(1);
|
||||||
|
Args.Add(_code);
|
||||||
|
IsNot = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Compile(GMAssets _assets)
|
||||||
|
{
|
||||||
|
switch (Kind)
|
||||||
|
{
|
||||||
|
case eAction.ACT_VARIABLE:
|
||||||
|
if (Relative)
|
||||||
|
{
|
||||||
|
Code = Code + Args[0] + " += " + Args[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Code = Code + Args[0] + " = " + Args[1];
|
||||||
|
}
|
||||||
|
Kind = eAction.ACT_NORMAL;
|
||||||
|
Args.Clear();
|
||||||
|
break;
|
||||||
|
case eAction.ACT_CODE:
|
||||||
|
Code = Args[0];
|
||||||
|
Kind = eAction.ACT_NORMAL;
|
||||||
|
Args.Clear();
|
||||||
|
if (Program.RemoveDND)
|
||||||
|
{
|
||||||
|
List<GMLError> _errors = null;
|
||||||
|
bool inhibitErrorOutput = Program.InhibitErrorOutput;
|
||||||
|
Program.InhibitErrorOutput = true;
|
||||||
|
GMLCompile.Compile(_assets, "test_compile", Code, out _errors);
|
||||||
|
Program.InhibitErrorOutput = inhibitErrorOutput;
|
||||||
|
if (_errors.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (GMLError item2 in _errors)
|
||||||
|
{
|
||||||
|
eErrorKind kind = item2.Kind;
|
||||||
|
if (kind == eErrorKind.Warning_Unclosed_Comment)
|
||||||
|
{
|
||||||
|
Code += "*/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (IsQuestion && ExeType == eExecuteTypes.EXE_CODE)
|
||||||
|
{
|
||||||
|
Name = string.Format("__script{0}__", countScript);
|
||||||
|
GMScript value = new GMScript(Code);
|
||||||
|
KeyValuePair<string, GMScript> item = new KeyValuePair<string, GMScript>(Name, value);
|
||||||
|
_assets.Scripts.Add(item);
|
||||||
|
countScript++;
|
||||||
|
ExeType = eExecuteTypes.EXE_FUNCTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,779 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMAssets
|
||||||
|
{
|
||||||
|
private delegate T Factory<T>(GMAssets _this, Stream _s);
|
||||||
|
|
||||||
|
private static byte[] map1 = new byte[256];
|
||||||
|
|
||||||
|
private static byte[] map2 = new byte[256];
|
||||||
|
|
||||||
|
public int Magic
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Version
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Debug
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GameID
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid GameGUID
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMExtension> Extensions
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMTrigger> Triggers
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMSound>> Sounds
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMSprite>> Sprites
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMBackground>> Backgrounds
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMPath>> Paths
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMScript>> Scripts
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMFont>> Fonts
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMTimeLine>> TimeLines
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMObject>> Objects
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMRoom>> Rooms
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<KeyValuePair<string, GMDataFile>> DataFiles
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<string> Libraries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<int> RoomOrder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMHelp Help
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RoomMaxId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RoomMaxTileId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FileName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMOptions Options
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DNDRemoved
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GMAssets(Stream _s, bool _gmk)
|
||||||
|
{
|
||||||
|
Magic = _s.ReadInteger();
|
||||||
|
Version = _s.ReadInteger();
|
||||||
|
Stream stream = _s;
|
||||||
|
byte[] array = null;
|
||||||
|
if (Version >= 701)
|
||||||
|
{
|
||||||
|
int num = stream.ReadInteger();
|
||||||
|
int num2 = stream.ReadInteger();
|
||||||
|
for (int i = 0; i <= num - 1; i++)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
int key = stream.ReadInteger();
|
||||||
|
for (int j = 0; j <= num2 - 1; j++)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
long position = stream.Position;
|
||||||
|
array = new byte[stream.Length];
|
||||||
|
stream.Position = 0L;
|
||||||
|
stream.Read(array, 0, (int)stream.Length);
|
||||||
|
Decrypt2(key, array, position + 1);
|
||||||
|
MemoryStream memoryStream = new MemoryStream(array, false);
|
||||||
|
stream = memoryStream;
|
||||||
|
stream.Position = position;
|
||||||
|
}
|
||||||
|
if (Version < 600)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
GameID = stream.ReadInteger();
|
||||||
|
GameGUID = stream.ReadGuid();
|
||||||
|
Extensions = new List<GMExtension>();
|
||||||
|
Triggers = new List<GMTrigger>();
|
||||||
|
Sounds = new List<KeyValuePair<string, GMSound>>();
|
||||||
|
Sprites = new List<KeyValuePair<string, GMSprite>>();
|
||||||
|
Backgrounds = new List<KeyValuePair<string, GMBackground>>();
|
||||||
|
Paths = new List<KeyValuePair<string, GMPath>>();
|
||||||
|
Scripts = new List<KeyValuePair<string, GMScript>>();
|
||||||
|
Fonts = new List<KeyValuePair<string, GMFont>>();
|
||||||
|
TimeLines = new List<KeyValuePair<string, GMTimeLine>>();
|
||||||
|
Objects = new List<KeyValuePair<string, GMObject>>();
|
||||||
|
Rooms = new List<KeyValuePair<string, GMRoom>>();
|
||||||
|
DataFiles = new List<KeyValuePair<string, GMDataFile>>();
|
||||||
|
Libraries = new List<string>();
|
||||||
|
RoomOrder = new List<int>();
|
||||||
|
Options = new GMOptions(this, stream, true);
|
||||||
|
LoadGMK(Sounds, stream, (GMAssets _t, Stream _st) => new GMSound(_t, _st));
|
||||||
|
LoadGMK(Sprites, stream, (GMAssets _t, Stream _st) => new GMSprite(_t, _st));
|
||||||
|
LoadGMK(Backgrounds, stream, (GMAssets _t, Stream _st) => new GMBackground(_t, _st));
|
||||||
|
LoadGMK(Paths, stream, (GMAssets _t, Stream _st) => new GMPath(_t, _st));
|
||||||
|
LoadGMK(Scripts, stream, (GMAssets _t, Stream _st) => new GMScript(_t, _st));
|
||||||
|
LoadGMK(Fonts, stream, (GMAssets _t, Stream _st) => new GMFont(_t, _st));
|
||||||
|
LoadGMK(TimeLines, stream, (GMAssets _t, Stream _st) => new GMTimeLine(_t, _st));
|
||||||
|
LoadGMK(Objects, stream, (GMAssets _t, Stream _st) => new GMObject(_t, _st));
|
||||||
|
LoadGMK(Rooms, stream, (GMAssets _t, Stream _st) => new GMRoom(_t, _st, true));
|
||||||
|
RoomMaxId = stream.ReadInteger();
|
||||||
|
RoomMaxTileId = stream.ReadInteger();
|
||||||
|
LoadGMK_GMDataFile(DataFiles, stream);
|
||||||
|
LoadGMK_GMExtension(Extensions, stream);
|
||||||
|
Help = new GMHelp(this, stream);
|
||||||
|
Library_Load(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadGMK<T>(IList<KeyValuePair<string, T>> _list, Stream _s, Factory<T> _factory)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
if (_s.ReadBoolean())
|
||||||
|
{
|
||||||
|
string key = _s.ReadString();
|
||||||
|
T value = _factory(this, _s);
|
||||||
|
_list.Add(new KeyValuePair<string, T>(key, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadGMK_GMDataFile(IList<KeyValuePair<string, GMDataFile>> _list, Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
string key = _s.ReadString();
|
||||||
|
GMDataFile value = new GMDataFile(this, _s);
|
||||||
|
_list.Add(new KeyValuePair<string, GMDataFile>(key, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadGMK_GMExtension(IList<GMExtension> _list, Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
_s.ReadString();
|
||||||
|
GMExtension item = new GMExtension(this, _s);
|
||||||
|
_list.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GMAssets(Stream _s)
|
||||||
|
{
|
||||||
|
Magic = _s.ReadInteger();
|
||||||
|
Version = _s.ReadInteger();
|
||||||
|
if (Version == 810)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
Debug = _s.ReadBoolean();
|
||||||
|
if (Version == 810)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
Options = new GMOptions(this, _s);
|
||||||
|
Name = _s.ReadString();
|
||||||
|
_s.ReadCompressedStream();
|
||||||
|
Stream stream = null;
|
||||||
|
byte[] array = null;
|
||||||
|
if (Version != 800 && Version != 810)
|
||||||
|
{
|
||||||
|
array = _s.ReadCompressedStream();
|
||||||
|
stream = new MemoryStream(array);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stream = _s;
|
||||||
|
}
|
||||||
|
if (Version == 800 || Version == 810)
|
||||||
|
{
|
||||||
|
stream = stream.ReadStreamE();
|
||||||
|
int num = stream.ReadInteger();
|
||||||
|
for (int i = 1; i <= num; i++)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num2 = stream.ReadInteger();
|
||||||
|
int num3 = stream.ReadInteger();
|
||||||
|
for (int j = 0; j <= num2 - 1; j++)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
int key = stream.ReadInteger();
|
||||||
|
for (int k = 0; k <= num3 - 1; k++)
|
||||||
|
{
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
long position = stream.Position;
|
||||||
|
Decrypt2(key, array, position + 1);
|
||||||
|
stream.ReadInteger();
|
||||||
|
}
|
||||||
|
GameID = stream.ReadInteger();
|
||||||
|
GameGUID = stream.ReadGuid();
|
||||||
|
Extensions = new List<GMExtension>();
|
||||||
|
Triggers = new List<GMTrigger>();
|
||||||
|
Sounds = new List<KeyValuePair<string, GMSound>>();
|
||||||
|
Sprites = new List<KeyValuePair<string, GMSprite>>();
|
||||||
|
Backgrounds = new List<KeyValuePair<string, GMBackground>>();
|
||||||
|
Paths = new List<KeyValuePair<string, GMPath>>();
|
||||||
|
Scripts = new List<KeyValuePair<string, GMScript>>();
|
||||||
|
Fonts = new List<KeyValuePair<string, GMFont>>();
|
||||||
|
TimeLines = new List<KeyValuePair<string, GMTimeLine>>();
|
||||||
|
Objects = new List<KeyValuePair<string, GMObject>>();
|
||||||
|
Rooms = new List<KeyValuePair<string, GMRoom>>();
|
||||||
|
DataFiles = new List<KeyValuePair<string, GMDataFile>>();
|
||||||
|
Libraries = new List<string>();
|
||||||
|
RoomOrder = new List<int>();
|
||||||
|
Extensions_Load(stream);
|
||||||
|
if (Version == 800 || Version == 810)
|
||||||
|
{
|
||||||
|
Trigger_Load(stream);
|
||||||
|
Constant_Load(stream);
|
||||||
|
}
|
||||||
|
Sound_Load(stream);
|
||||||
|
Sprite_Load(stream);
|
||||||
|
Background_Load(stream);
|
||||||
|
Path_Load(stream);
|
||||||
|
Script_Load(stream);
|
||||||
|
Font_Load(stream);
|
||||||
|
TimeLine_Load(stream);
|
||||||
|
Object_Load(stream);
|
||||||
|
Room_Load(stream);
|
||||||
|
DataFile_Load(stream);
|
||||||
|
Help = new GMHelp(this, stream);
|
||||||
|
Library_Load(stream);
|
||||||
|
Room_LoadOrder(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Extensions_Load(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
GMExtension item = new GMExtension(this, _s);
|
||||||
|
Extensions.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Trigger_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num != 800)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s.ReadStreamC();
|
||||||
|
if (s.ReadBoolean())
|
||||||
|
{
|
||||||
|
Triggers.Add(new GMTrigger(this, s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Constant_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
string key = _s.ReadString();
|
||||||
|
string value = _s.ReadString();
|
||||||
|
Options.Constants[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sound_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMSound> item = default(KeyValuePair<string, GMSound>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMSound value = new GMSound(this, s);
|
||||||
|
item = new KeyValuePair<string, GMSound>(key, value);
|
||||||
|
}
|
||||||
|
Sounds.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Sprite_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMSprite> item = default(KeyValuePair<string, GMSprite>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMSprite value = new GMSprite(this, s);
|
||||||
|
item = new KeyValuePair<string, GMSprite>(key, value);
|
||||||
|
}
|
||||||
|
Sprites.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Background_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMBackground> item = default(KeyValuePair<string, GMBackground>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMBackground value = new GMBackground(this, s);
|
||||||
|
item = new KeyValuePair<string, GMBackground>(key, value);
|
||||||
|
}
|
||||||
|
Backgrounds.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Path_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMPath> item = default(KeyValuePair<string, GMPath>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMPath value = new GMPath(this, s);
|
||||||
|
item = new KeyValuePair<string, GMPath>(key, value);
|
||||||
|
}
|
||||||
|
Paths.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Script_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMScript> item = default(KeyValuePair<string, GMScript>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMScript value = new GMScript(this, s);
|
||||||
|
item = new KeyValuePair<string, GMScript>(key, value);
|
||||||
|
}
|
||||||
|
Scripts.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Font_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream s = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = s.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMFont> item = default(KeyValuePair<string, GMFont>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = s.ReadString();
|
||||||
|
GMFont value = new GMFont(this, s);
|
||||||
|
item = new KeyValuePair<string, GMFont>(key, value);
|
||||||
|
}
|
||||||
|
Fonts.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TimeLine_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream stream = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
stream = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = stream.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMTimeLine> item = default(KeyValuePair<string, GMTimeLine>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = stream.ReadString();
|
||||||
|
GMTimeLine value = new GMTimeLine(this, stream);
|
||||||
|
item = new KeyValuePair<string, GMTimeLine>(key, value);
|
||||||
|
}
|
||||||
|
TimeLines.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Object_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream stream = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
stream = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = stream.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMObject> item = default(KeyValuePair<string, GMObject>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = stream.ReadString();
|
||||||
|
GMObject value = new GMObject(this, stream);
|
||||||
|
item = new KeyValuePair<string, GMObject>(key, value);
|
||||||
|
}
|
||||||
|
Objects.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Room_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream stream = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
stream = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
bool flag = stream.ReadBoolean();
|
||||||
|
KeyValuePair<string, GMRoom> item = default(KeyValuePair<string, GMRoom>);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
string key = stream.ReadString();
|
||||||
|
GMRoom value = new GMRoom(this, stream);
|
||||||
|
item = new KeyValuePair<string, GMRoom>(key, value);
|
||||||
|
}
|
||||||
|
Rooms.Add(item);
|
||||||
|
}
|
||||||
|
RoomMaxId = _s.ReadInteger();
|
||||||
|
RoomMaxTileId = _s.ReadInteger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DataFile_Load(Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
Stream stream = _s;
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
stream = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
KeyValuePair<string, GMDataFile> keyValuePair = default(KeyValuePair<string, GMDataFile>);
|
||||||
|
GMDataFile value = new GMDataFile(this, stream);
|
||||||
|
keyValuePair = new KeyValuePair<string, GMDataFile>("datafile" + i, value);
|
||||||
|
DataFiles.Add(keyValuePair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Library_Load(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
Libraries.Add(_s.ReadString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Room_LoadOrder(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num >= 0)
|
||||||
|
{
|
||||||
|
RoomOrder = new List<int>(num);
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
RoomOrder.Add(_s.ReadInteger());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetKey(int _key)
|
||||||
|
{
|
||||||
|
int num = 6 + _key % 250;
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
|
num += 256;
|
||||||
|
}
|
||||||
|
int num2 = _key / 250;
|
||||||
|
if (num2 < 0)
|
||||||
|
{
|
||||||
|
num2 += 256;
|
||||||
|
}
|
||||||
|
for (int i = 0; i <= 255; i++)
|
||||||
|
{
|
||||||
|
map1[i] = (byte)i;
|
||||||
|
}
|
||||||
|
for (int j = 0; j <= 255; j++)
|
||||||
|
{
|
||||||
|
map2[j] = (byte)j;
|
||||||
|
}
|
||||||
|
for (int k = 1; k <= 10000; k++)
|
||||||
|
{
|
||||||
|
int num3 = 1 + (k * num + num2) % 254;
|
||||||
|
byte b = map1[num3];
|
||||||
|
map1[num3] = map1[num3 + 1];
|
||||||
|
map1[num3 + 1] = b;
|
||||||
|
}
|
||||||
|
for (int l = 1; l <= 255; l++)
|
||||||
|
{
|
||||||
|
map2[map1[l]] = (byte)l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Decrypt(int _key, byte[] _b, long _pos)
|
||||||
|
{
|
||||||
|
SetKey(_key);
|
||||||
|
long num = _b.LongLength - _pos;
|
||||||
|
for (long num2 = _pos; num2 <= _pos + num - 1; num2++)
|
||||||
|
{
|
||||||
|
_b[num2] = map2[_b[num2]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Decrypt2(int _key, byte[] _b, long _pos)
|
||||||
|
{
|
||||||
|
SetKey(_key);
|
||||||
|
long num = _b.LongLength - _pos;
|
||||||
|
for (long num2 = _pos; num2 <= _pos + num - 1; num2++)
|
||||||
|
{
|
||||||
|
byte b = _b[num2];
|
||||||
|
int num3 = (int)(map2[b] - num2 % 256);
|
||||||
|
if (num3 < 0)
|
||||||
|
{
|
||||||
|
num3 += 256;
|
||||||
|
}
|
||||||
|
_b[num2] = (byte)num3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveDND()
|
||||||
|
{
|
||||||
|
if (!DNDRemoved)
|
||||||
|
{
|
||||||
|
DNDRemoved = true;
|
||||||
|
foreach (KeyValuePair<string, GMObject> @object in Objects)
|
||||||
|
{
|
||||||
|
GMObject value = @object.Value;
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
foreach (IList<KeyValuePair<int, GMEvent>> @event in value.Events)
|
||||||
|
{
|
||||||
|
using (IEnumerator<KeyValuePair<int, GMEvent>> enumerator3 = @event.GetEnumerator())
|
||||||
|
{
|
||||||
|
while (enumerator3.MoveNext())
|
||||||
|
{
|
||||||
|
RemoveEventDND(_ev: enumerator3.Current.Value, _name: @object.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string, GMTimeLine> timeLine in TimeLines)
|
||||||
|
{
|
||||||
|
GMTimeLine value3 = timeLine.Value;
|
||||||
|
if (value3 != null)
|
||||||
|
{
|
||||||
|
using (IEnumerator<KeyValuePair<int, GMEvent>> enumerator5 = value3.Entries.GetEnumerator())
|
||||||
|
{
|
||||||
|
while (enumerator5.MoveNext())
|
||||||
|
{
|
||||||
|
RemoveEventDND(_ev: enumerator5.Current.Value, _name: timeLine.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveEventDND(string _name, GMEvent _ev)
|
||||||
|
{
|
||||||
|
if (_ev.Actions.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (GMAction action in _ev.Actions)
|
||||||
|
{
|
||||||
|
action.Compile(this);
|
||||||
|
}
|
||||||
|
string text = _ev.CompressEvent(Scripts);
|
||||||
|
if (Program.CompileVerbose)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Compressed event for {0} - {1}", _name, text);
|
||||||
|
}
|
||||||
|
GMAction item = new GMAction(_ev.Actions[0].ID, text);
|
||||||
|
_ev.Actions.Clear();
|
||||||
|
_ev.Actions.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,107 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMBack
|
||||||
|
{
|
||||||
|
public bool Visible
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Foreground
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HTiled
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VTiled
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HSpeed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VSpeed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double XScale
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double YScale
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Blend
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Alpha
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Stretch
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMBack(Stream _stream)
|
||||||
|
{
|
||||||
|
Visible = _stream.ReadBoolean();
|
||||||
|
Foreground = _stream.ReadBoolean();
|
||||||
|
Index = _stream.ReadInteger();
|
||||||
|
X = _stream.ReadInteger();
|
||||||
|
Y = _stream.ReadInteger();
|
||||||
|
HTiled = _stream.ReadBoolean();
|
||||||
|
VTiled = _stream.ReadBoolean();
|
||||||
|
HSpeed = _stream.ReadInteger();
|
||||||
|
VSpeed = _stream.ReadInteger();
|
||||||
|
Blend = 16777215;
|
||||||
|
Alpha = 1.0;
|
||||||
|
Stretch = _stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMBackground
|
||||||
|
{
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Transparent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Smooth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Preload
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Tileset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMBitmap32 Bitmap
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMBackground(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
switch (_s.ReadInteger())
|
||||||
|
{
|
||||||
|
case 543:
|
||||||
|
Width = _s.ReadInteger();
|
||||||
|
Height = _s.ReadInteger();
|
||||||
|
Transparent = _s.ReadBoolean();
|
||||||
|
Smooth = _s.ReadBoolean();
|
||||||
|
Preload = _s.ReadBoolean();
|
||||||
|
Tileset = false;
|
||||||
|
if (_s.ReadBoolean())
|
||||||
|
{
|
||||||
|
Bitmap = new GMBitmap32(_s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 710:
|
||||||
|
Bitmap = new GMBitmap32(_s);
|
||||||
|
Width = _s.ReadInteger();
|
||||||
|
Height = _s.ReadInteger();
|
||||||
|
Width = Bitmap.Width;
|
||||||
|
Height = Bitmap.Height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMBitmap32
|
||||||
|
{
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Data
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap Bitmap
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb);
|
||||||
|
Rectangle rect = new Rectangle(0, 0, Width, Height);
|
||||||
|
BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
IntPtr intPtr = bitmapData.Scan0;
|
||||||
|
int num = 0;
|
||||||
|
int num2 = 0;
|
||||||
|
while (num2 < Height)
|
||||||
|
{
|
||||||
|
int num3 = num;
|
||||||
|
IntPtr ptr = intPtr;
|
||||||
|
int num4 = 0;
|
||||||
|
while (num4 < Width)
|
||||||
|
{
|
||||||
|
int val = Data[num3] + (Data[num3 + 1] << 8) + (Data[num3 + 2] << 16) + (Data[num3 + 3] << 24);
|
||||||
|
Marshal.WriteInt32(ptr, val);
|
||||||
|
num4++;
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + 4);
|
||||||
|
num3 += 4;
|
||||||
|
}
|
||||||
|
num2++;
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride);
|
||||||
|
num += Width * 4;
|
||||||
|
}
|
||||||
|
bitmap.UnlockBits(bitmapData);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMBitmap32(Stream _s)
|
||||||
|
{
|
||||||
|
switch (_s.ReadInteger())
|
||||||
|
{
|
||||||
|
case 540:
|
||||||
|
if (_s.ReadBoolean())
|
||||||
|
{
|
||||||
|
Width = _s.ReadInteger();
|
||||||
|
Height = _s.ReadInteger();
|
||||||
|
int width = Width;
|
||||||
|
int height = Height;
|
||||||
|
Data = _s.ReadCompressedStream();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 800:
|
||||||
|
Width = _s.ReadInteger();
|
||||||
|
Height = _s.ReadInteger();
|
||||||
|
Data = _s.ReadStream();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetAlphaFromBitmap(GMBitmap32 _other)
|
||||||
|
{
|
||||||
|
int num = Math.Min(Width, _other.Width);
|
||||||
|
int num2 = Math.Min(Height, _other.Height);
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < num; j++)
|
||||||
|
{
|
||||||
|
int num3 = j * 4 + i * _other.Width * 4;
|
||||||
|
int num4 = j * 4 + i * Width * 4;
|
||||||
|
int val = (_other.Data[num4] + _other.Data[num4 + 1] + _other.Data[num4 + 2]) / 3;
|
||||||
|
Data[num3 + 3] = (byte)Math.Min(_other.Data[num4 + 3], val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMDataFile
|
||||||
|
{
|
||||||
|
public string FileName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string OrigName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Size
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Store
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Data
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ExportAction
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExportDir
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Overwrite
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool FreeData
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RemoveEnd
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMDataFile(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
FileName = _stream.ReadString();
|
||||||
|
OrigName = _stream.ReadString();
|
||||||
|
Exists = _stream.ReadBoolean();
|
||||||
|
Size = _stream.ReadInteger();
|
||||||
|
Store = _stream.ReadBoolean();
|
||||||
|
if (Exists && Store)
|
||||||
|
{
|
||||||
|
switch (num)
|
||||||
|
{
|
||||||
|
case 620:
|
||||||
|
Data = _stream.ReadCompressedStream();
|
||||||
|
break;
|
||||||
|
case 800:
|
||||||
|
Data = _stream.ReadStream();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExportAction = _stream.ReadInteger();
|
||||||
|
ExportDir = _stream.ReadString();
|
||||||
|
Overwrite = _stream.ReadBoolean();
|
||||||
|
FreeData = _stream.ReadBoolean();
|
||||||
|
RemoveEnd = _stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,380 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMEvent
|
||||||
|
{
|
||||||
|
private static Stack<bool> RelativeStack = new Stack<bool>();
|
||||||
|
|
||||||
|
private static bool conditionVar = false;
|
||||||
|
|
||||||
|
public List<GMAction> Actions
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMEvent(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
Actions = new List<GMAction>(num);
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
Actions.Add(new GMAction(_a, _stream));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressExit(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
if (RelativeStack.Count > 0)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("action_set_relative( 0 );");
|
||||||
|
}
|
||||||
|
_sb.AppendLine("exit;");
|
||||||
|
return n + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressBlock(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("{");
|
||||||
|
for (n++; n < Actions.Count; n = CompressAction(n, _sb))
|
||||||
|
{
|
||||||
|
GMAction gMAction = Actions[n];
|
||||||
|
if (gMAction.Kind == eAction.ACT_END)
|
||||||
|
{
|
||||||
|
n++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_sb.AppendLine("}");
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressRepeat(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
GMAction gMAction = Actions[n];
|
||||||
|
_sb.AppendFormat("repeat( {0} )", gMAction.Args[0]);
|
||||||
|
return CompressAction(n + 1, _sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressCondition(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
GMAction gMAction = Actions[n];
|
||||||
|
bool flag = false;
|
||||||
|
bool flag2 = false;
|
||||||
|
if (gMAction.UseApplyTo)
|
||||||
|
{
|
||||||
|
switch (gMAction.Who)
|
||||||
|
{
|
||||||
|
case -2:
|
||||||
|
_sb.AppendLine("with( other ) ");
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_sb.AppendLine(string.Format("with( {0} ) ", gMAction.Who));
|
||||||
|
flag = true;
|
||||||
|
flag2 = true;
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flag = (flag || (gMAction.UseRelative && RelativeStack.Count > 0 && RelativeStack.Peek() != gMAction.Relative));
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("{");
|
||||||
|
}
|
||||||
|
if (!conditionVar)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("var __b__;");
|
||||||
|
conditionVar = true;
|
||||||
|
}
|
||||||
|
bool flag3 = PushRelativeness(_sb, gMAction);
|
||||||
|
switch (gMAction.ExeType)
|
||||||
|
{
|
||||||
|
case eExecuteTypes.EXE_FUNCTION:
|
||||||
|
if (gMAction.Name == "action_execute_script")
|
||||||
|
{
|
||||||
|
_sb.AppendFormat("__b__ = ");
|
||||||
|
CompressExecuteScriptAction(n, gMAction, _sb);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sb.AppendFormat("__b__ = {0}( ", gMAction.Name);
|
||||||
|
CompressFunctionArguments(_sb, gMAction);
|
||||||
|
_sb.AppendLine(" );");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case eExecuteTypes.EXE_CODE:
|
||||||
|
_sb.AppendFormat("__b__ = {0};", gMAction.Code);
|
||||||
|
_sb.AppendLine("");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
_sb.AppendFormat("if {0}__b__ break;", gMAction.IsNot ? "!" : "");
|
||||||
|
_sb.AppendLine("");
|
||||||
|
}
|
||||||
|
if (flag3)
|
||||||
|
{
|
||||||
|
PopRelativeness(_sb);
|
||||||
|
}
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("}");
|
||||||
|
}
|
||||||
|
if (gMAction.IsNot)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("if !__b__");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sb.AppendLine("if __b__");
|
||||||
|
}
|
||||||
|
_sb.AppendLine("{");
|
||||||
|
n = CompressAction(n + 1, _sb);
|
||||||
|
_sb.AppendLine("}");
|
||||||
|
if (n < Actions.Count && Actions[n].Kind == eAction.ACT_ELSE)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("else");
|
||||||
|
_sb.AppendLine("{");
|
||||||
|
n = CompressAction(n + 1, _sb);
|
||||||
|
_sb.AppendLine("}");
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PopRelativeness(StringBuilder _sb)
|
||||||
|
{
|
||||||
|
bool flag = RelativeStack.Pop();
|
||||||
|
if (RelativeStack.Peek() != flag)
|
||||||
|
{
|
||||||
|
_sb.AppendLine(string.Format("action_set_relative( {0} );", RelativeStack.Peek() ? 1 : 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool PushRelativeness(StringBuilder _sb, GMAction action)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (action.UseRelative && RelativeStack.Count > 0 && RelativeStack.Peek() != action.Relative)
|
||||||
|
{
|
||||||
|
_sb.AppendLine(string.Format("action_set_relative( {0} );", action.Relative ? 1 : 0));
|
||||||
|
RelativeStack.Push(action.Relative);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressNormalAction(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
GMAction gMAction = Actions[n];
|
||||||
|
if (gMAction.ExeType != 0)
|
||||||
|
{
|
||||||
|
bool flag = false;
|
||||||
|
if (gMAction.UseApplyTo)
|
||||||
|
{
|
||||||
|
switch (gMAction.Who)
|
||||||
|
{
|
||||||
|
case -2:
|
||||||
|
_sb.AppendLine("with( other ) ");
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_sb.AppendLine(string.Format("with( {0} ) ", gMAction.Who));
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
flag = (flag || (gMAction.UseRelative && RelativeStack.Count > 0 && RelativeStack.Peek() != gMAction.Relative));
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("{");
|
||||||
|
}
|
||||||
|
bool flag2 = PushRelativeness(_sb, gMAction);
|
||||||
|
switch (gMAction.ExeType)
|
||||||
|
{
|
||||||
|
case eExecuteTypes.EXE_FUNCTION:
|
||||||
|
if (gMAction.Name == "action_execute_script")
|
||||||
|
{
|
||||||
|
CompressExecuteScriptAction(n, gMAction, _sb);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_sb.AppendFormat("{0}( ", gMAction.Name);
|
||||||
|
CompressFunctionArguments(_sb, gMAction);
|
||||||
|
_sb.AppendLine(" );");
|
||||||
|
break;
|
||||||
|
case eExecuteTypes.EXE_CODE:
|
||||||
|
_sb.AppendLine(gMAction.Code);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
PopRelativeness(_sb);
|
||||||
|
}
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
_sb.AppendLine("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CompressFunctionArguments(StringBuilder _sb, GMAction action)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < action.ArgumentCount; i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
_sb.Append(", ");
|
||||||
|
}
|
||||||
|
switch (action.ArgTypes[i])
|
||||||
|
{
|
||||||
|
case eArgTypes.ARG_STRING:
|
||||||
|
case eArgTypes.ARG_STRINGEXP:
|
||||||
|
if (action.Args[i].StartsWith("'") || action.Args[i].StartsWith("\""))
|
||||||
|
{
|
||||||
|
_sb.AppendFormat("{0}", action.Args[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sb.AppendFormat("\"{0}\"", action.Args[i]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case eArgTypes.ARG_CONSTANT:
|
||||||
|
case eArgTypes.ARG_EXPRESSION:
|
||||||
|
case eArgTypes.ARG_BOOLEAN:
|
||||||
|
case eArgTypes.ARG_MENU:
|
||||||
|
case eArgTypes.ARG_SPRITE:
|
||||||
|
case eArgTypes.ARG_SOUND:
|
||||||
|
case eArgTypes.ARG_BACKGROUND:
|
||||||
|
case eArgTypes.ARG_PATH:
|
||||||
|
case eArgTypes.ARG_SCRIPT:
|
||||||
|
case eArgTypes.ARG_OBJECT:
|
||||||
|
case eArgTypes.ARG_ROOM:
|
||||||
|
case eArgTypes.ARG_FONTR:
|
||||||
|
case eArgTypes.ARG_COLOR:
|
||||||
|
case eArgTypes.ARG_TIMELINE:
|
||||||
|
case eArgTypes.ARG_FONT:
|
||||||
|
_sb.Append(action.Args[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressAction(int n, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
if (n < Actions.Count)
|
||||||
|
{
|
||||||
|
GMAction gMAction = Actions[n];
|
||||||
|
switch (gMAction.Kind)
|
||||||
|
{
|
||||||
|
case eAction.ACT_EXIT:
|
||||||
|
return CompressExit(n, _sb);
|
||||||
|
case eAction.ACT_BEGIN:
|
||||||
|
return CompressBlock(n, _sb);
|
||||||
|
case eAction.ACT_REPEAT:
|
||||||
|
return CompressRepeat(n, _sb);
|
||||||
|
default:
|
||||||
|
if (gMAction.IsQuestion)
|
||||||
|
{
|
||||||
|
return CompressCondition(n, _sb);
|
||||||
|
}
|
||||||
|
return CompressNormalAction(n, _sb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CompressExecuteScriptAction(int n, GMAction _action, StringBuilder _sb)
|
||||||
|
{
|
||||||
|
if (_action.Args.Count == 8)
|
||||||
|
{
|
||||||
|
int num = int.Parse(_action.Args[0]);
|
||||||
|
if (num >= 0)
|
||||||
|
{
|
||||||
|
string key = Program.Assets.Scripts[num].Key;
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.AppendFormat("{0}(", key);
|
||||||
|
for (int i = 1; i < 6; i++)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(_action.Args[i]))
|
||||||
|
{
|
||||||
|
if (i >= 2)
|
||||||
|
{
|
||||||
|
stringBuilder.Append(",");
|
||||||
|
}
|
||||||
|
stringBuilder.AppendFormat("{0}", _action.Args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stringBuilder.Append(");");
|
||||||
|
_sb.AppendLine(stringBuilder.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Execute script action is not bound to a script");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Failed to parse action_execute_script() - incorrect number of arguments received\n");
|
||||||
|
}
|
||||||
|
return n + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CompressEvent(IList<KeyValuePair<string, GMScript>> _scripts)
|
||||||
|
{
|
||||||
|
RelativeStack.Clear();
|
||||||
|
conditionVar = false;
|
||||||
|
int num = 0;
|
||||||
|
bool flag = false;
|
||||||
|
for (int i = 0; i < Actions.Count; i++)
|
||||||
|
{
|
||||||
|
if (Actions[i].UseRelative)
|
||||||
|
{
|
||||||
|
if (flag != Actions[i].Relative)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
flag = Actions[i].Relative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (num > 0)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < Actions.Count; j++)
|
||||||
|
{
|
||||||
|
if (Actions[j].UseRelative)
|
||||||
|
{
|
||||||
|
RelativeStack.Push(Actions[j].Relative);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.AppendLine("{");
|
||||||
|
if (RelativeStack.Count > 0)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendLine(string.Format("action_set_relative( {0} );", RelativeStack.Peek() ? 1 : 0));
|
||||||
|
}
|
||||||
|
for (int num2 = 0; num2 < Actions.Count; num2 = ((!(Actions[num2].Name == "action_execute_script")) ? CompressAction(num2, stringBuilder) : CompressExecuteScriptAction(num2, Actions[num2], stringBuilder)))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
if (RelativeStack.Count > 0)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendLine("action_set_relative( 0 );");
|
||||||
|
RelativeStack.Pop();
|
||||||
|
}
|
||||||
|
if (RelativeStack.Count != 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Unbalanced RelativeStack... need to rebalance now\n");
|
||||||
|
}
|
||||||
|
stringBuilder.AppendLine("}");
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMExtension
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Folder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMExtensionInclude> Includes
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<byte[]> ExtensionDLL
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMExtension(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
Name = _s.ReadString();
|
||||||
|
Folder = _s.ReadString();
|
||||||
|
Includes = new List<GMExtensionInclude>();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
Includes.Add(new GMExtensionInclude(_s));
|
||||||
|
}
|
||||||
|
byte[] array = _s.ReadStream();
|
||||||
|
if (array == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MemoryStream memoryStream = new MemoryStream(array);
|
||||||
|
int key = memoryStream.ReadInteger();
|
||||||
|
GMAssets.Decrypt(key, array, memoryStream.Position + 1);
|
||||||
|
ExtensionDLL = new List<byte[]>();
|
||||||
|
for (int j = 0; j < Includes.Count; j++)
|
||||||
|
{
|
||||||
|
if (Includes[j].Kind != 3)
|
||||||
|
{
|
||||||
|
ExtensionDLL.Add(memoryStream.ReadCompressedStream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMExtensionConstant
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMExtensionConstant(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
Name = _s.ReadString();
|
||||||
|
Value = _s.ReadString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMExtensionFunction
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ExtName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<int> Args
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReturnType
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMExtensionFunction(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
Name = _s.ReadString();
|
||||||
|
ExtName = _s.ReadString();
|
||||||
|
Kind = _s.ReadInteger();
|
||||||
|
Id = _s.ReadInteger();
|
||||||
|
Args = new List<int>();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i <= 16; i++)
|
||||||
|
{
|
||||||
|
int item = _s.ReadInteger();
|
||||||
|
if (i < num)
|
||||||
|
{
|
||||||
|
Args.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ReturnType = _s.ReadInteger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMExtensionInclude
|
||||||
|
{
|
||||||
|
public string Filename
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Init
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Final
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMExtensionFunction> Functions
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMExtensionConstant> Constants
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMExtensionInclude(Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
Filename = _s.ReadString();
|
||||||
|
Kind = _s.ReadInteger();
|
||||||
|
Init = _s.ReadString();
|
||||||
|
Final = _s.ReadString();
|
||||||
|
Functions = new List<GMExtensionFunction>();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
Functions.Add(new GMExtensionFunction(_s));
|
||||||
|
}
|
||||||
|
Constants = new List<GMExtensionConstant>();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int j = 0; j < num2; j++)
|
||||||
|
{
|
||||||
|
Constants.Add(new GMExtensionConstant(_s));
|
||||||
|
}
|
||||||
|
switch (Path.GetExtension(Filename).ToLower())
|
||||||
|
{
|
||||||
|
case ".gml":
|
||||||
|
Kind = 2;
|
||||||
|
break;
|
||||||
|
case ".dll":
|
||||||
|
Kind = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Kind = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMFont
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Size
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Bold
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Italic
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int First
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Last
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CharSet
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AntiAlias
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMGlyph> Glyphs
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap Bitmap
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMFont(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
Name = _s.ReadString();
|
||||||
|
Size = _s.ReadInteger();
|
||||||
|
Bold = _s.ReadBoolean();
|
||||||
|
Italic = _s.ReadBoolean();
|
||||||
|
First = _s.ReadInteger();
|
||||||
|
Last = _s.ReadInteger();
|
||||||
|
CharSet = ((First >> 16) & 0xFF);
|
||||||
|
AntiAlias = ((First >> 24) & 0xFF);
|
||||||
|
First &= 65535;
|
||||||
|
Glyphs = new List<GMGlyph>();
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
int x = _s.ReadInteger();
|
||||||
|
int y = _s.ReadInteger();
|
||||||
|
int w = _s.ReadInteger();
|
||||||
|
int h = _s.ReadInteger();
|
||||||
|
int shift = _s.ReadInteger();
|
||||||
|
int offset = _s.ReadInteger();
|
||||||
|
Glyphs.Add(new GMGlyph(x, y, w, h, shift, offset));
|
||||||
|
}
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
int num3 = _s.ReadInteger();
|
||||||
|
byte[] array = null;
|
||||||
|
array = ((num != 540) ? _s.ReadStream() : _s.ReadCompressedStream());
|
||||||
|
Bitmap = new Bitmap(num2, num3, PixelFormat.Format32bppArgb);
|
||||||
|
Rectangle rect = new Rectangle(0, 0, Bitmap.Width, Bitmap.Height);
|
||||||
|
BitmapData bitmapData = Bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
IntPtr intPtr = new IntPtr(bitmapData.Scan0.ToInt64());
|
||||||
|
int num4 = 0;
|
||||||
|
int num5 = 0;
|
||||||
|
while (num5 < num3)
|
||||||
|
{
|
||||||
|
int num6 = num4;
|
||||||
|
IntPtr ptr = intPtr;
|
||||||
|
int num7 = 0;
|
||||||
|
while (num7 < num2)
|
||||||
|
{
|
||||||
|
int val = 16777215 + (array[num6] << 24);
|
||||||
|
Marshal.WriteInt32(ptr, val);
|
||||||
|
num7++;
|
||||||
|
num6++;
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num5++;
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride);
|
||||||
|
num4 += num2;
|
||||||
|
}
|
||||||
|
Bitmap.UnlockBits(bitmapData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMGlyph
|
||||||
|
{
|
||||||
|
public int X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int W
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int H
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Shift
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Offset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMGlyph(int _x, int _y, int _w, int _h, int _shift, int _offset)
|
||||||
|
{
|
||||||
|
X = _x;
|
||||||
|
Y = _y;
|
||||||
|
W = _w;
|
||||||
|
H = _h;
|
||||||
|
Shift = _shift;
|
||||||
|
Offset = _offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMHelp
|
||||||
|
{
|
||||||
|
public int BackgroundColour
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Mimic
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Caption
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Left
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Top
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Border
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sizable
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnTop
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Modal
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMHelp(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
_stream = _stream.ReadStreamC();
|
||||||
|
}
|
||||||
|
BackgroundColour = _stream.ReadInteger();
|
||||||
|
Mimic = _stream.ReadBoolean();
|
||||||
|
Caption = _stream.ReadString();
|
||||||
|
Left = _stream.ReadInteger();
|
||||||
|
Top = _stream.ReadInteger();
|
||||||
|
Width = _stream.ReadInteger();
|
||||||
|
Height = _stream.ReadInteger();
|
||||||
|
Border = _stream.ReadBoolean();
|
||||||
|
Sizable = _stream.ReadBoolean();
|
||||||
|
OnTop = _stream.ReadBoolean();
|
||||||
|
Modal = _stream.ReadBoolean();
|
||||||
|
byte[] array = null;
|
||||||
|
switch (num)
|
||||||
|
{
|
||||||
|
case 600:
|
||||||
|
array = _stream.ReadCompressedStream();
|
||||||
|
break;
|
||||||
|
case 800:
|
||||||
|
array = _stream.ReadStream();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (array != null)
|
||||||
|
{
|
||||||
|
MemoryStream memoryStream = new MemoryStream(array);
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
while (memoryStream.Position != memoryStream.Length)
|
||||||
|
{
|
||||||
|
char value = (char)memoryStream.ReadByte();
|
||||||
|
stringBuilder.Append(value);
|
||||||
|
}
|
||||||
|
Text = stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMInstance
|
||||||
|
{
|
||||||
|
public int X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ScaleX
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ScaleY
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Colour
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Rotation
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMInstance(Stream _stream, int _version)
|
||||||
|
{
|
||||||
|
X = _stream.ReadInteger();
|
||||||
|
Y = _stream.ReadInteger();
|
||||||
|
Index = _stream.ReadInteger();
|
||||||
|
Id = _stream.ReadInteger();
|
||||||
|
Code = _stream.ReadString();
|
||||||
|
if (_version >= 810)
|
||||||
|
{
|
||||||
|
ScaleX = _stream.ReadDouble();
|
||||||
|
ScaleY = _stream.ReadDouble();
|
||||||
|
Colour = (uint)_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ScaleX = 1.0;
|
||||||
|
ScaleY = 1.0;
|
||||||
|
Colour = uint.MaxValue;
|
||||||
|
}
|
||||||
|
if (_version >= 811)
|
||||||
|
{
|
||||||
|
Rotation = _stream.ReadDouble();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Rotation = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMInstance(Stream _stream, bool _gmk)
|
||||||
|
{
|
||||||
|
X = _stream.ReadInteger();
|
||||||
|
Y = _stream.ReadInteger();
|
||||||
|
Index = _stream.ReadInteger();
|
||||||
|
Id = _stream.ReadInteger();
|
||||||
|
Code = _stream.ReadString();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
ScaleX = 1.0;
|
||||||
|
ScaleY = 1.0;
|
||||||
|
Colour = uint.MaxValue;
|
||||||
|
Rotation = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,47 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLCode
|
||||||
|
{
|
||||||
|
public eGMLCodeType Type
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken Token
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GMLError> Errors
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLCode(GMAssets _assets, string _name, string _code, eGMLCodeType _type)
|
||||||
|
{
|
||||||
|
Name = _name.Replace(' ', '_').Replace('\t', '_');
|
||||||
|
Code = _code;
|
||||||
|
Type = _type;
|
||||||
|
List<GMLError> _errors = null;
|
||||||
|
Token = GMLCompile.Compile(_assets, Name, Code, out _errors);
|
||||||
|
Errors = _errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLError
|
||||||
|
{
|
||||||
|
public eErrorKind Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Error
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<object> Params
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken Token
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLError(eErrorKind _kind, string _error, GMLToken _token, params object[] _others)
|
||||||
|
{
|
||||||
|
Kind = _kind;
|
||||||
|
Error = _error;
|
||||||
|
Token = _token;
|
||||||
|
Params = new List<object>(_others);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLFunction
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumArgs7
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumArgs8
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Pro
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool InstanceFirstParam
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OtherSecondParam
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLToken
|
||||||
|
{
|
||||||
|
private static int ms_tabcount;
|
||||||
|
|
||||||
|
public eToken Token
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLValue Value
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GMLToken> Children
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken(eToken _tok, int _index, string _text)
|
||||||
|
{
|
||||||
|
Token = _tok;
|
||||||
|
Index = _index;
|
||||||
|
Text = _text;
|
||||||
|
Children = new List<GMLToken>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken(eToken _tok, GMLToken _pass1, int _id)
|
||||||
|
{
|
||||||
|
Token = _tok;
|
||||||
|
Index = _pass1.Index;
|
||||||
|
Text = _pass1.Text;
|
||||||
|
Id = _id;
|
||||||
|
Value = new GMLValue();
|
||||||
|
Children = new List<GMLToken>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken(eToken _tok, GMLToken _pass1, int _id, GMLValue _value)
|
||||||
|
{
|
||||||
|
Token = _tok;
|
||||||
|
Index = _pass1.Index;
|
||||||
|
Text = _pass1.Text;
|
||||||
|
Id = _id;
|
||||||
|
Value = new GMLValue(_value);
|
||||||
|
Children = new List<GMLToken>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLToken(GMLToken _tok)
|
||||||
|
{
|
||||||
|
Token = _tok.Token;
|
||||||
|
Index = _tok.Index;
|
||||||
|
Text = _tok.Text;
|
||||||
|
Id = _tok.Id;
|
||||||
|
Value = new GMLValue(_tok.Value);
|
||||||
|
Children = new List<GMLToken>(_tok.Children);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.AppendFormat("< tok={0:G}, index={1}, id={3}, text=\"{2}\", value={4} ", Token, Index, Text, Id, (Value != null) ? Value.ToString() : "null");
|
||||||
|
if (Children.Count > 0)
|
||||||
|
{
|
||||||
|
stringBuilder.Append("Children=[ \n");
|
||||||
|
ms_tabcount++;
|
||||||
|
foreach (GMLToken child in Children)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ms_tabcount; i++)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendFormat(" ");
|
||||||
|
}
|
||||||
|
stringBuilder.Append(child.ToString());
|
||||||
|
stringBuilder.Append(",\n");
|
||||||
|
}
|
||||||
|
ms_tabcount--;
|
||||||
|
for (int j = 0; j < ms_tabcount; j++)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendFormat(" ");
|
||||||
|
}
|
||||||
|
stringBuilder.Append("]");
|
||||||
|
}
|
||||||
|
stringBuilder.Append('>');
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLValue
|
||||||
|
{
|
||||||
|
public eKind Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ValueI
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ValueS
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLValue()
|
||||||
|
{
|
||||||
|
Kind = eKind.eNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLValue(double _value)
|
||||||
|
{
|
||||||
|
ValueI = _value;
|
||||||
|
Kind = eKind.eNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLValue(string _value)
|
||||||
|
{
|
||||||
|
Kind = eKind.eString;
|
||||||
|
ValueS = _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMLValue(GMLValue _value)
|
||||||
|
{
|
||||||
|
Kind = _value.Kind;
|
||||||
|
ValueI = _value.ValueI;
|
||||||
|
ValueS = _value.ValueS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("[ kind={0:G}, val={1}]", Kind, (Kind == eKind.eNone) ? "none" : ((Kind == eKind.eNumber) ? ValueI.ToString() : ValueS.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMLVariable
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string setFunction
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getFunction
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Get
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Set
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Pro
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMObject
|
||||||
|
{
|
||||||
|
public int SpriteIndex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Solid
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Visible
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Depth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Persistent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Parent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Mask
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<IList<KeyValuePair<int, GMEvent>>> Events
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GMObject(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
if (num != 400 && num != 430 && num != 820)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SpriteIndex = _stream.ReadInteger();
|
||||||
|
Solid = _stream.ReadBoolean();
|
||||||
|
Visible = _stream.ReadBoolean();
|
||||||
|
Depth = _stream.ReadInteger();
|
||||||
|
Persistent = _stream.ReadBoolean();
|
||||||
|
Parent = _stream.ReadInteger();
|
||||||
|
Mask = _stream.ReadInteger();
|
||||||
|
int num2 = 8;
|
||||||
|
if (num == 430 || num >= 820)
|
||||||
|
{
|
||||||
|
num2 = _stream.ReadInteger();
|
||||||
|
}
|
||||||
|
Events = new List<IList<KeyValuePair<int, GMEvent>>>(num2);
|
||||||
|
for (int i = 0; i <= num2; i++)
|
||||||
|
{
|
||||||
|
List<KeyValuePair<int, GMEvent>> list = new List<KeyValuePair<int, GMEvent>>();
|
||||||
|
int num3;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
num3 = _stream.ReadInteger();
|
||||||
|
if (num3 >= 0)
|
||||||
|
{
|
||||||
|
GMEvent value = new GMEvent(_a, _stream);
|
||||||
|
KeyValuePair<int, GMEvent> item = new KeyValuePair<int, GMEvent>(num3, value);
|
||||||
|
list.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (num3 >= 0);
|
||||||
|
Events.Add(list);
|
||||||
|
}
|
||||||
|
Console.WriteLine("DEBUG: num var: " + num.ToString() + " !");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,469 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMOptions
|
||||||
|
{
|
||||||
|
public bool FullScreen
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool InterpolatePixels
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool NoBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowCursor
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Scale
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sizeable
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StayOnTop
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int WindowColour
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ChangeResolution
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ColorDepth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Resolution
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Frequency
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool NoButtons
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Sync_Vertex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool NoScreenSaver
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ScreenKey
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HelpKey
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QuitKey
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveKey
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ScreenShotKey
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CloseSec
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Priority
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Freeze
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowProgress
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap BackImage
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap FrontImage
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap LoadImage
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LoadTransparent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int LoadAlpha
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ScaleProgress
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DisplayErrors
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WriteErrors
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AbortErrors
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VariableErrors
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int WebGL
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreationEventOrder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, string> Constants
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GMOptions(GMAssets _a, Stream _s, bool _gmk)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
FullScreen = _s.ReadBoolean();
|
||||||
|
if (num >= 600)
|
||||||
|
{
|
||||||
|
InterpolatePixels = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
NoBorder = _s.ReadBoolean();
|
||||||
|
ShowCursor = _s.ReadBoolean();
|
||||||
|
Scale = _s.ReadInteger();
|
||||||
|
if (num >= 540)
|
||||||
|
{
|
||||||
|
Sizeable = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num >= 540)
|
||||||
|
{
|
||||||
|
StayOnTop = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num >= 540)
|
||||||
|
{
|
||||||
|
WindowColour = _s.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadBoolean();
|
||||||
|
}
|
||||||
|
ChangeResolution = _s.ReadBoolean();
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
ColorDepth = _s.ReadInteger();
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
ColorDepth = 0;
|
||||||
|
}
|
||||||
|
Resolution = _s.ReadInteger();
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
Resolution = 0;
|
||||||
|
}
|
||||||
|
Frequency = _s.ReadInteger();
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
Frequency = 0;
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadBoolean();
|
||||||
|
}
|
||||||
|
NoButtons = _s.ReadBoolean();
|
||||||
|
if (num >= 542)
|
||||||
|
{
|
||||||
|
Sync_Vertex = _s.ReadInteger();
|
||||||
|
}
|
||||||
|
ScreenKey = _s.ReadBoolean();
|
||||||
|
HelpKey = _s.ReadBoolean();
|
||||||
|
QuitKey = _s.ReadBoolean();
|
||||||
|
SaveKey = _s.ReadBoolean();
|
||||||
|
if (num >= 701)
|
||||||
|
{
|
||||||
|
ScreenShotKey = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num >= 620)
|
||||||
|
{
|
||||||
|
CloseSec = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num >= 520)
|
||||||
|
{
|
||||||
|
Priority = _s.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num < 540)
|
||||||
|
{
|
||||||
|
_s.ReadBoolean();
|
||||||
|
}
|
||||||
|
Freeze = _s.ReadBoolean();
|
||||||
|
ShowProgress = (_s.ReadInteger() == 2);
|
||||||
|
if (ShowProgress)
|
||||||
|
{
|
||||||
|
BackImage = null;
|
||||||
|
FrontImage = null;
|
||||||
|
Image image = _s.ReadBitmap();
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
BackImage = new Bitmap(image);
|
||||||
|
}
|
||||||
|
image = _s.ReadBitmap();
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
FrontImage = new Bitmap(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_s.ReadBoolean())
|
||||||
|
{
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
if (num2 != -1)
|
||||||
|
{
|
||||||
|
byte[] buffer = _s.ReadCompressedStream();
|
||||||
|
MemoryStream stream = new MemoryStream(buffer);
|
||||||
|
LoadImage = (Bitmap)Image.FromStream(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (num >= 510)
|
||||||
|
{
|
||||||
|
LoadTransparent = _s.ReadBoolean();
|
||||||
|
LoadAlpha = _s.ReadInteger();
|
||||||
|
ScaleProgress = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
_s.ReadStream();
|
||||||
|
DisplayErrors = _s.ReadBoolean();
|
||||||
|
WriteErrors = _s.ReadBoolean();
|
||||||
|
AbortErrors = _s.ReadBoolean();
|
||||||
|
VariableErrors = _s.ReadBoolean();
|
||||||
|
_s.ReadString();
|
||||||
|
string empty = string.Empty;
|
||||||
|
if (num < 700)
|
||||||
|
{
|
||||||
|
_s.ReadInteger().ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_s.ReadString();
|
||||||
|
}
|
||||||
|
_s.ReadDouble();
|
||||||
|
_s.ReadString();
|
||||||
|
Constants = new Dictionary<string, string>();
|
||||||
|
if (num >= 530)
|
||||||
|
{
|
||||||
|
for (int num3 = _s.ReadInteger(); num3 > 0; num3--)
|
||||||
|
{
|
||||||
|
string key = _s.ReadString();
|
||||||
|
string value = _s.ReadString();
|
||||||
|
Constants.Add(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (num >= 702)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
_s.ReadInteger();
|
||||||
|
_s.ReadInteger();
|
||||||
|
_s.ReadInteger();
|
||||||
|
_s.ReadString();
|
||||||
|
_s.ReadString();
|
||||||
|
_s.ReadString();
|
||||||
|
_s.ReadString();
|
||||||
|
}
|
||||||
|
WebGL = _s.ReadInteger();
|
||||||
|
CreationEventOrder = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal GMOptions(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num >= 800)
|
||||||
|
{
|
||||||
|
_s = _s.ReadStreamC();
|
||||||
|
}
|
||||||
|
FullScreen = _s.ReadBoolean();
|
||||||
|
InterpolatePixels = _s.ReadBoolean();
|
||||||
|
NoBorder = _s.ReadBoolean();
|
||||||
|
ShowCursor = _s.ReadBoolean();
|
||||||
|
Scale = _s.ReadInteger();
|
||||||
|
Sizeable = _s.ReadBoolean();
|
||||||
|
StayOnTop = _s.ReadBoolean();
|
||||||
|
WindowColour = _s.ReadInteger();
|
||||||
|
ChangeResolution = _s.ReadBoolean();
|
||||||
|
ColorDepth = _s.ReadInteger();
|
||||||
|
Resolution = _s.ReadInteger();
|
||||||
|
Frequency = _s.ReadInteger();
|
||||||
|
NoButtons = _s.ReadBoolean();
|
||||||
|
Sync_Vertex = _s.ReadInteger();
|
||||||
|
if (num >= 800)
|
||||||
|
{
|
||||||
|
NoScreenSaver = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
ScreenKey = _s.ReadBoolean();
|
||||||
|
HelpKey = _s.ReadBoolean();
|
||||||
|
QuitKey = _s.ReadBoolean();
|
||||||
|
SaveKey = _s.ReadBoolean();
|
||||||
|
ScreenShotKey = _s.ReadBoolean();
|
||||||
|
CloseSec = _s.ReadBoolean();
|
||||||
|
Priority = _s.ReadInteger();
|
||||||
|
Freeze = _s.ReadBoolean();
|
||||||
|
ShowProgress = _s.ReadBoolean();
|
||||||
|
if (ShowProgress)
|
||||||
|
{
|
||||||
|
BackImage = null;
|
||||||
|
FrontImage = null;
|
||||||
|
Image image = _s.ReadBitmap();
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
BackImage = new Bitmap(image);
|
||||||
|
}
|
||||||
|
image = _s.ReadBitmap();
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
FrontImage = new Bitmap(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Image image2 = _s.ReadBitmap();
|
||||||
|
LoadImage = ((image2 != null) ? new Bitmap(image2) : null);
|
||||||
|
LoadTransparent = _s.ReadBoolean();
|
||||||
|
LoadAlpha = _s.ReadInteger();
|
||||||
|
ScaleProgress = _s.ReadBoolean();
|
||||||
|
DisplayErrors = _s.ReadBoolean();
|
||||||
|
WriteErrors = _s.ReadBoolean();
|
||||||
|
AbortErrors = _s.ReadBoolean();
|
||||||
|
VariableErrors = _s.ReadBoolean();
|
||||||
|
if (num >= 820)
|
||||||
|
{
|
||||||
|
WebGL = _s.ReadInteger();
|
||||||
|
CreationEventOrder = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
Constants = new Dictionary<string, string>();
|
||||||
|
if (num != 800)
|
||||||
|
{
|
||||||
|
for (int num2 = _s.ReadInteger(); num2 > 0; num2--)
|
||||||
|
{
|
||||||
|
string key = _s.ReadString();
|
||||||
|
string value = _s.ReadString();
|
||||||
|
Constants.Add(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMPath
|
||||||
|
{
|
||||||
|
public int Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Closed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Precision
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMPathPoint> Points
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMPath(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
Kind = _s.ReadInteger();
|
||||||
|
Closed = _s.ReadBoolean();
|
||||||
|
Precision = _s.ReadInteger();
|
||||||
|
Points = new List<GMPathPoint>();
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
double x = _s.ReadDouble();
|
||||||
|
double y = _s.ReadDouble();
|
||||||
|
double speed = _s.ReadDouble();
|
||||||
|
Points.Add(new GMPathPoint(x, y, speed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMPathPoint
|
||||||
|
{
|
||||||
|
public double X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Speed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMPathPoint(double _x, double _y, double _speed)
|
||||||
|
{
|
||||||
|
X = _x;
|
||||||
|
Y = _y;
|
||||||
|
Speed = _speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,235 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMRoom
|
||||||
|
{
|
||||||
|
public string Caption
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Speed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Persistent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Colour
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ShowColour
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Code
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMBack> Backgrounds
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnableViews
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ViewClearScreen
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMView> Views
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMInstance> Instances
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<GMTile> Tiles
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GMRoom(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
Caption = _stream.ReadString();
|
||||||
|
Width = _stream.ReadInteger();
|
||||||
|
Height = _stream.ReadInteger();
|
||||||
|
Speed = _stream.ReadInteger();
|
||||||
|
Persistent = _stream.ReadBoolean();
|
||||||
|
Colour = _stream.ReadInteger();
|
||||||
|
int num2 = _stream.ReadInteger();
|
||||||
|
ShowColour = ((num2 & 1) != 0);
|
||||||
|
ViewClearScreen = ((num2 & 2) == 0);
|
||||||
|
Code = _stream.ReadString();
|
||||||
|
int num3 = _stream.ReadInteger();
|
||||||
|
Backgrounds = new List<GMBack>(num3);
|
||||||
|
for (int i = 0; i < num3; i++)
|
||||||
|
{
|
||||||
|
GMBack item = new GMBack(_stream);
|
||||||
|
Backgrounds.Add(item);
|
||||||
|
}
|
||||||
|
EnableViews = _stream.ReadBoolean();
|
||||||
|
num3 = _stream.ReadInteger();
|
||||||
|
Views = new List<GMView>(num3);
|
||||||
|
for (int j = 0; j < num3; j++)
|
||||||
|
{
|
||||||
|
GMView item2 = new GMView(_stream);
|
||||||
|
Views.Add(item2);
|
||||||
|
}
|
||||||
|
num3 = _stream.ReadInteger();
|
||||||
|
Instances = new List<GMInstance>(num3);
|
||||||
|
for (int k = 0; k < num3; k++)
|
||||||
|
{
|
||||||
|
GMInstance item3 = new GMInstance(_stream, num);
|
||||||
|
Instances.Add(item3);
|
||||||
|
}
|
||||||
|
num3 = _stream.ReadInteger();
|
||||||
|
Tiles = new List<GMTile>(num3);
|
||||||
|
for (int l = 0; l < num3; l++)
|
||||||
|
{
|
||||||
|
GMTile item4 = new GMTile(_stream, num);
|
||||||
|
Tiles.Add(item4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMRoom(GMAssets _a, Stream _stream, bool _gmk)
|
||||||
|
{
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
Caption = _stream.ReadString();
|
||||||
|
Width = _stream.ReadInteger();
|
||||||
|
Height = _stream.ReadInteger();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
if (num >= 520)
|
||||||
|
{
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
Speed = _stream.ReadInteger();
|
||||||
|
Persistent = _stream.ReadBoolean();
|
||||||
|
Colour = _stream.ReadInteger();
|
||||||
|
ShowColour = _stream.ReadBoolean();
|
||||||
|
Code = _stream.ReadString();
|
||||||
|
int num2 = _stream.ReadInteger();
|
||||||
|
Backgrounds = new List<GMBack>(num2);
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
GMBack item = new GMBack(_stream);
|
||||||
|
Backgrounds.Add(item);
|
||||||
|
}
|
||||||
|
EnableViews = _stream.ReadBoolean();
|
||||||
|
num2 = _stream.ReadInteger();
|
||||||
|
Views = new List<GMView>(num2);
|
||||||
|
for (int j = 0; j < num2; j++)
|
||||||
|
{
|
||||||
|
GMView item2 = new GMView(_stream);
|
||||||
|
Views.Add(item2);
|
||||||
|
}
|
||||||
|
num2 = _stream.ReadInteger();
|
||||||
|
Instances = new List<GMInstance>(num2);
|
||||||
|
for (int k = 0; k < num2; k++)
|
||||||
|
{
|
||||||
|
GMInstance item3 = new GMInstance(_stream, true);
|
||||||
|
Instances.Add(item3);
|
||||||
|
}
|
||||||
|
num2 = _stream.ReadInteger();
|
||||||
|
Tiles = new List<GMTile>(num2);
|
||||||
|
for (int l = 0; l < num2; l++)
|
||||||
|
{
|
||||||
|
GMTile item4 = new GMTile(_stream, num);
|
||||||
|
if (num >= 520)
|
||||||
|
{
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
Tiles.Add(item4);
|
||||||
|
}
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
if (num < 520)
|
||||||
|
{
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
if (num < 520)
|
||||||
|
{
|
||||||
|
_stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
if (num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num >= 520 && num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
if (num >= 520 && num < 541)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
_stream.ReadInteger();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
_stream.ReadInteger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMScript
|
||||||
|
{
|
||||||
|
public string Script
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ParseVariableStrings(string _functionName)
|
||||||
|
{
|
||||||
|
if (!Script.Contains(_functionName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int num;
|
||||||
|
for (num = Script.IndexOf(_functionName); num >= 0; num = Script.IndexOf(_functionName, num + 1))
|
||||||
|
{
|
||||||
|
int num2 = Script.IndexOf("(", num);
|
||||||
|
int num3 = Script.IndexOf(")", num);
|
||||||
|
if (num2 > 0 && num2 > 0 && num3 > num2)
|
||||||
|
{
|
||||||
|
int num4 = Script.IndexOf("\"", num2);
|
||||||
|
while (num4 >= 0 && num4 < num3)
|
||||||
|
{
|
||||||
|
Script = Script.Remove(num4, 1);
|
||||||
|
num3--;
|
||||||
|
num4 = Script.IndexOf("\"", num4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (num >= 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMScript(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
switch (_s.ReadInteger())
|
||||||
|
{
|
||||||
|
case 400:
|
||||||
|
{
|
||||||
|
byte[] array = _s.ReadCompressedStream();
|
||||||
|
GMAssets.Decrypt(12345, array, 0L);
|
||||||
|
MemoryStream s = new MemoryStream(array);
|
||||||
|
Script = s.ReadString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 800:
|
||||||
|
Script = _s.ReadString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMScript(string _s)
|
||||||
|
{
|
||||||
|
Script = _s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMSound
|
||||||
|
{
|
||||||
|
public const string MissingSoundName = "Dummy";
|
||||||
|
|
||||||
|
public int Kind
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Extension
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string OrigName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ReadMe
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Effects
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Volume
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Pan
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Preload
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Data
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMSound(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
Kind = _s.ReadInteger();
|
||||||
|
Extension = _s.ReadString();
|
||||||
|
OrigName = _s.ReadString();
|
||||||
|
if (OrigName == "")
|
||||||
|
{
|
||||||
|
OrigName = "Dummy" + Extension;
|
||||||
|
}
|
||||||
|
bool flag = _s.ReadBoolean();
|
||||||
|
Data = null;
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
switch (num)
|
||||||
|
{
|
||||||
|
case 600:
|
||||||
|
Data = _s.ReadCompressedStream();
|
||||||
|
break;
|
||||||
|
case 800:
|
||||||
|
Data = _s.ReadStream();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Effects = _s.ReadInteger();
|
||||||
|
Volume = _s.ReadDouble();
|
||||||
|
Pan = _s.ReadDouble();
|
||||||
|
Preload = _s.ReadBoolean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,288 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMSprite
|
||||||
|
{
|
||||||
|
[Property("Width of the sprite", Category = "Extents")]
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Height of the sprite", Category = "Extents")]
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Left-most edge of the bounding box", Category = "Bounding Box")]
|
||||||
|
public int BBoxLeft
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Right-most edge of the bounding box", Category = "Bounding Box")]
|
||||||
|
public int BBoxRight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Bottom-most edge of the bounding box", Category = "Bounding Box")]
|
||||||
|
public int BBoxBottom
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Top-most edge of the bounding box", Category = "Bounding Box")]
|
||||||
|
public int BBoxTop
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Transparent or not (use alpha blending while rendering??)", Category = "General")]
|
||||||
|
public bool Transparent
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Smooth or not (use smooth scalong while rendering??)", Category = "General")]
|
||||||
|
public bool Smooth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Preload... or not...", Category = "General")]
|
||||||
|
public bool Preload
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Bounding Box Mode", Category = "General")]
|
||||||
|
public int BBoxMode
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("true if collision checks will be performed for the sprite", Category = "General")]
|
||||||
|
public bool ColCheck
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("X Origin of the sprite ", Category = "Extents")]
|
||||||
|
public int XOrig
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Y Origin of the sprite", Category = "Extents")]
|
||||||
|
public int YOrig
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("blah blah", Disabled = true)]
|
||||||
|
public IList<GMBitmap32> Images
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("Separate Masks?", Category = "GM8")]
|
||||||
|
public bool SepMasks
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Property("masks", Disabled = true)]
|
||||||
|
public IList<byte[]> Masks
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMSprite(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
switch (num)
|
||||||
|
{
|
||||||
|
case 542:
|
||||||
|
{
|
||||||
|
Width = _s.ReadInteger();
|
||||||
|
Height = _s.ReadInteger();
|
||||||
|
BBoxLeft = _s.ReadInteger();
|
||||||
|
BBoxRight = _s.ReadInteger();
|
||||||
|
BBoxBottom = _s.ReadInteger();
|
||||||
|
BBoxTop = _s.ReadInteger();
|
||||||
|
Transparent = _s.ReadBoolean();
|
||||||
|
Smooth = _s.ReadBoolean();
|
||||||
|
Preload = _s.ReadBoolean();
|
||||||
|
BBoxMode = _s.ReadInteger();
|
||||||
|
ColCheck = _s.ReadBoolean();
|
||||||
|
XOrig = _s.ReadInteger();
|
||||||
|
YOrig = _s.ReadInteger();
|
||||||
|
Images = new List<GMBitmap32>();
|
||||||
|
int num3 = _s.ReadInteger();
|
||||||
|
for (int k = 0; k < num3; k++)
|
||||||
|
{
|
||||||
|
Images.Add(new GMBitmap32(_s));
|
||||||
|
}
|
||||||
|
Masks = CreateMask();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 800:
|
||||||
|
case 810:
|
||||||
|
{
|
||||||
|
BBoxLeft = 99999999;
|
||||||
|
BBoxTop = 9999999;
|
||||||
|
BBoxRight = -9999999;
|
||||||
|
BBoxBottom = -9999999;
|
||||||
|
Transparent = true;
|
||||||
|
Preload = true;
|
||||||
|
ColCheck = true;
|
||||||
|
XOrig = _s.ReadInteger();
|
||||||
|
YOrig = _s.ReadInteger();
|
||||||
|
Images = new List<GMBitmap32>();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 0; i < num2; i++)
|
||||||
|
{
|
||||||
|
GMBitmap32 gMBitmap = new GMBitmap32(_s);
|
||||||
|
Images.Add(gMBitmap);
|
||||||
|
Width = gMBitmap.Width;
|
||||||
|
Height = gMBitmap.Height;
|
||||||
|
}
|
||||||
|
if (num == 810)
|
||||||
|
{
|
||||||
|
switch (_s.ReadInteger())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
ColCheck = true;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ColCheck = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Masks = new List<byte[]>();
|
||||||
|
SepMasks = _s.ReadBoolean();
|
||||||
|
if (num2 <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (SepMasks)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < num2; j++)
|
||||||
|
{
|
||||||
|
Masks.Add(LoadMaskFromStream(_s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Masks.Add(LoadMaskFromStream(_s));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] LoadMaskFromStream(Stream _s)
|
||||||
|
{
|
||||||
|
byte[] array = null;
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
int num3 = _s.ReadInteger();
|
||||||
|
int num4 = _s.ReadInteger();
|
||||||
|
int num5 = _s.ReadInteger();
|
||||||
|
int num6 = _s.ReadInteger();
|
||||||
|
int num7 = _s.ReadInteger();
|
||||||
|
if (BBoxLeft > num4)
|
||||||
|
{
|
||||||
|
BBoxLeft = num4;
|
||||||
|
}
|
||||||
|
if (BBoxRight < num5)
|
||||||
|
{
|
||||||
|
BBoxRight = num5;
|
||||||
|
}
|
||||||
|
if (BBoxBottom < num6)
|
||||||
|
{
|
||||||
|
BBoxBottom = num6;
|
||||||
|
}
|
||||||
|
if (BBoxTop > num7)
|
||||||
|
{
|
||||||
|
BBoxTop = num7;
|
||||||
|
}
|
||||||
|
int num8 = (Width + 7) / 8;
|
||||||
|
array = new byte[num8 * Height];
|
||||||
|
for (int i = 0; i < num3; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < num2; j++)
|
||||||
|
{
|
||||||
|
array[i * num8 + j / 8] |= (byte)((_s.ReadBoolean() ? 1 : 0) << 7 - (j & 7));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<byte[]> CreateMask()
|
||||||
|
{
|
||||||
|
List<byte[]> result = null;
|
||||||
|
if (ColCheck && Transparent && Images.Count > 0)
|
||||||
|
{
|
||||||
|
result = new List<byte[]>();
|
||||||
|
{
|
||||||
|
foreach (GMBitmap32 image in Images)
|
||||||
|
{
|
||||||
|
int num = image.Width * 4;
|
||||||
|
int num2 = (image.Width + 7) / 8;
|
||||||
|
byte[] array = new byte[num2 * image.Height];
|
||||||
|
int num3 = 0;
|
||||||
|
int num4 = 0;
|
||||||
|
int num5 = 0;
|
||||||
|
while (num5 < image.Height)
|
||||||
|
{
|
||||||
|
int num6 = num3;
|
||||||
|
int num7 = 0;
|
||||||
|
while (num7 < image.Width)
|
||||||
|
{
|
||||||
|
int num8 = num7 / 8 + num4;
|
||||||
|
if (image.Data[num6 + 3] != 0)
|
||||||
|
{
|
||||||
|
array[num8] |= (byte)(1 << 7 - (num7 & 7));
|
||||||
|
}
|
||||||
|
num7++;
|
||||||
|
num6 += 4;
|
||||||
|
}
|
||||||
|
num5++;
|
||||||
|
num3 += num;
|
||||||
|
num4 += num2;
|
||||||
|
}
|
||||||
|
result.Add(array);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMTile
|
||||||
|
{
|
||||||
|
public int X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int XO
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int YO
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int W
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int H
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Depth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double XScale
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double YScale
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Blend
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Alpha
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Visible
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMTile(Stream _stream, int _version)
|
||||||
|
{
|
||||||
|
X = _stream.ReadInteger();
|
||||||
|
Y = _stream.ReadInteger();
|
||||||
|
Index = _stream.ReadInteger();
|
||||||
|
XO = _stream.ReadInteger();
|
||||||
|
YO = _stream.ReadInteger();
|
||||||
|
W = _stream.ReadInteger();
|
||||||
|
H = _stream.ReadInteger();
|
||||||
|
Depth = _stream.ReadInteger();
|
||||||
|
Id = _stream.ReadInteger();
|
||||||
|
if (_version >= 810)
|
||||||
|
{
|
||||||
|
XScale = _stream.ReadDouble();
|
||||||
|
YScale = _stream.ReadDouble();
|
||||||
|
uint num = (uint)_stream.ReadInteger();
|
||||||
|
Blend = (int)(num & 0xFFFFFF);
|
||||||
|
Alpha = (num >> 24) / 255u;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XScale = 1.0;
|
||||||
|
YScale = 1.0;
|
||||||
|
Blend = 16777215;
|
||||||
|
Alpha = 1.0;
|
||||||
|
}
|
||||||
|
Visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMTimeLine
|
||||||
|
{
|
||||||
|
public IList<KeyValuePair<int, GMEvent>> Entries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMTimeLine(GMAssets _a, Stream _stream)
|
||||||
|
{
|
||||||
|
_stream.ReadInteger();
|
||||||
|
int num = _stream.ReadInteger();
|
||||||
|
Entries = new List<KeyValuePair<int, GMEvent>>(num);
|
||||||
|
for (int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
int key = _stream.ReadInteger();
|
||||||
|
GMEvent value = new GMEvent(_a, _stream);
|
||||||
|
Entries.Add(new KeyValuePair<int, GMEvent>(key, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMTrigger
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Condition
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConstName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Moment
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMTrigger(GMAssets _a, Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
if (num == 800)
|
||||||
|
{
|
||||||
|
Name = _s.ReadString();
|
||||||
|
Condition = _s.ReadString();
|
||||||
|
Moment = _s.ReadInteger();
|
||||||
|
ConstName = _s.ReadString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class GMView
|
||||||
|
{
|
||||||
|
public bool Visible
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int XView
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int YView
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int WView
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HView
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int XPort
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int YPort
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int WPort
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HPort
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Angle
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int HSpeed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VSpeed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Index
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GMView(Stream _stream)
|
||||||
|
{
|
||||||
|
Visible = _stream.ReadBoolean();
|
||||||
|
XView = _stream.ReadInteger();
|
||||||
|
YView = _stream.ReadInteger();
|
||||||
|
WView = _stream.ReadInteger();
|
||||||
|
HView = _stream.ReadInteger();
|
||||||
|
XPort = _stream.ReadInteger();
|
||||||
|
YPort = _stream.ReadInteger();
|
||||||
|
WPort = _stream.ReadInteger();
|
||||||
|
HPort = _stream.ReadInteger();
|
||||||
|
Angle = 0.0;
|
||||||
|
HBorder = _stream.ReadInteger();
|
||||||
|
VBorder = _stream.ReadInteger();
|
||||||
|
HSpeed = _stream.ReadInteger();
|
||||||
|
VSpeed = _stream.ReadInteger();
|
||||||
|
Index = _stream.ReadInteger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,149 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class IFF
|
||||||
|
{
|
||||||
|
public List<IIFFChunkHandler> m_chunks;
|
||||||
|
|
||||||
|
public List<IFFPatchEntry> m_patches;
|
||||||
|
|
||||||
|
public List<IFFString> Strings
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, int> StringCheck
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> ExternalFiles
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFF()
|
||||||
|
{
|
||||||
|
m_chunks = new List<IIFFChunkHandler>();
|
||||||
|
Strings = new List<IFFString>();
|
||||||
|
StringCheck = new Dictionary<string, int>();
|
||||||
|
m_patches = new List<IFFPatchEntry>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long GetOffset(object _o)
|
||||||
|
{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetOffset(Stream _s, object _o, long _offset)
|
||||||
|
{
|
||||||
|
foreach (IFFPatchEntry patch in m_patches)
|
||||||
|
{
|
||||||
|
if (object.ReferenceEquals(patch.Target, _o))
|
||||||
|
{
|
||||||
|
_s.PatchOffset(patch.Site);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddString(Stream _stream, string _s)
|
||||||
|
{
|
||||||
|
int value = -1;
|
||||||
|
IFFString iFFString = null;
|
||||||
|
if (!StringCheck.TryGetValue(_s, out value))
|
||||||
|
{
|
||||||
|
iFFString = new IFFString(_s);
|
||||||
|
value = Strings.Count;
|
||||||
|
Strings.Add(iFFString);
|
||||||
|
StringCheck.Add(_s, value);
|
||||||
|
}
|
||||||
|
iFFString = Strings[value];
|
||||||
|
m_patches.Add(new IFFPatchEntry(_stream.Position, iFFString));
|
||||||
|
_stream.WriteInteger(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddPatch(Stream _stream, object o)
|
||||||
|
{
|
||||||
|
m_patches.Add(new IFFPatchEntry(_stream.Position, o));
|
||||||
|
_stream.WriteInteger(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterChunk<T>(string _name, IFFChunkSaver<T> _delegate, T _data, IFFChunkType _type)
|
||||||
|
{
|
||||||
|
IFFChunkHandler<T> item = new IFFChunkHandler<T>(_name, _delegate, _data, _type);
|
||||||
|
m_chunks.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterChunk<T>(string _name, IFFChunkSaver<T> _delegate, T _data, IFFChunkType _type, int _align)
|
||||||
|
{
|
||||||
|
IFFChunkHandler<T> item = new IFFChunkHandler<T>(_name, _delegate, _data, _type, _align);
|
||||||
|
m_chunks.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterChunk<T>(string _name, IFFChunkSaver<T> _delegate, T _data, IFFChunkType _type, int _align, int _offset)
|
||||||
|
{
|
||||||
|
IFFChunkHandler<T> item = new IFFChunkHandler<T>(_name, _delegate, _data, _type, _align, _offset);
|
||||||
|
m_chunks.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WriteChunks(Stream _stream)
|
||||||
|
{
|
||||||
|
string tempFileName = Path.GetTempFileName();
|
||||||
|
Stream stream = _stream;
|
||||||
|
if (!_stream.CanSeek)
|
||||||
|
{
|
||||||
|
stream = new FileStream(tempFileName, FileMode.Create);
|
||||||
|
}
|
||||||
|
IOrderedEnumerable<IIFFChunkHandler> orderedEnumerable = m_chunks.OrderBy((IIFFChunkHandler c) => c.Type & (IFFChunkType.CPU | IFFChunkType.GPU | IFFChunkType.Audio));
|
||||||
|
stream.WriteChunk("FORM");
|
||||||
|
long patchSite = stream.WriteChunkSize();
|
||||||
|
long num = -1L;
|
||||||
|
foreach (IIFFChunkHandler item in orderedEnumerable)
|
||||||
|
{
|
||||||
|
if (num > 0)
|
||||||
|
{
|
||||||
|
if ((item.Type & IFFChunkType.Align) != 0)
|
||||||
|
{
|
||||||
|
int align = item.Align;
|
||||||
|
int num2 = align - 1;
|
||||||
|
while ((stream.Position & num2) != 0)
|
||||||
|
{
|
||||||
|
stream.WriteByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((item.Type & IFFChunkType.Offset) != 0)
|
||||||
|
{
|
||||||
|
int align2 = item.Align;
|
||||||
|
int num3 = align2 - 1;
|
||||||
|
while ((stream.Position & num3) != item.Offset)
|
||||||
|
{
|
||||||
|
stream.WriteByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stream.PatchChunkSize(num);
|
||||||
|
}
|
||||||
|
Application.DoEvents();
|
||||||
|
Program.Out.WriteLine("Writing Chunk... {0}", item.Name);
|
||||||
|
stream.WriteChunk(item.Name);
|
||||||
|
num = stream.WriteChunkSize();
|
||||||
|
item.Save(stream, this);
|
||||||
|
}
|
||||||
|
stream.PatchChunkSize(num);
|
||||||
|
stream.PatchChunkSize(patchSite);
|
||||||
|
if (!_stream.CanSeek)
|
||||||
|
{
|
||||||
|
stream.Close();
|
||||||
|
byte[] array = File.ReadAllBytes(tempFileName);
|
||||||
|
_stream.Write(array, 0, array.Length);
|
||||||
|
stream.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class IFFChunkHandler<T> : IIFFChunkHandler
|
||||||
|
{
|
||||||
|
private IFFChunkSaver<T> m_saver;
|
||||||
|
|
||||||
|
private T m_data;
|
||||||
|
|
||||||
|
private IFFChunkType m_type;
|
||||||
|
|
||||||
|
private int m_align;
|
||||||
|
|
||||||
|
private int m_offset;
|
||||||
|
|
||||||
|
private string m_name;
|
||||||
|
|
||||||
|
public IFFChunkType Type
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Align
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_align;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Offset
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IFFChunkHandler(string _name, IFFChunkSaver<T> _saver, T _data, IFFChunkType _type)
|
||||||
|
: this(_name, _saver, _data, _type | IFFChunkType.Align, 4, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IFFChunkHandler(string _name, IFFChunkSaver<T> _saver, T _data, IFFChunkType _type, int _align)
|
||||||
|
: this(_name, _saver, _data, _type | IFFChunkType.Align, _align, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IFFChunkHandler(string _name, IFFChunkSaver<T> _saver, T _data, IFFChunkType _type, int _align, int _offset)
|
||||||
|
{
|
||||||
|
m_saver = _saver;
|
||||||
|
m_data = _data;
|
||||||
|
m_type = (_type | IFFChunkType.Align);
|
||||||
|
m_align = _align;
|
||||||
|
m_offset = _offset;
|
||||||
|
m_name = _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save(Stream _stream, IFF _iff)
|
||||||
|
{
|
||||||
|
m_saver(m_data, _stream, _iff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public delegate void IFFChunkSaver<T>(T _data, Stream _stream, IFF _iff);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum IFFChunkType
|
||||||
|
{
|
||||||
|
CPU = 0x1,
|
||||||
|
GPU = 0x2,
|
||||||
|
Audio = 0x4,
|
||||||
|
Align = 0x8,
|
||||||
|
Offset = 0x10
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class IFFPatchEntry
|
||||||
|
{
|
||||||
|
public long Site
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Target
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFFPatchEntry(long _site, object _target)
|
||||||
|
{
|
||||||
|
Site = _site;
|
||||||
|
Target = _target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,917 @@
|
||||||
|
using GMAssetCompiler.Output;
|
||||||
|
using Ionic.Zip;
|
||||||
|
using NAudio.Wave;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class IFFSaver
|
||||||
|
{
|
||||||
|
private delegate void WriteDelegateKVP<T>(KeyValuePair<string, T> _kvp, Stream _s, IFF _iff, long _index);
|
||||||
|
|
||||||
|
private delegate void WriteDelegate<T>(T _t, Stream _s, IFF _iff, long _index);
|
||||||
|
|
||||||
|
private const int WAD_VERSION_NUMBER = 6;
|
||||||
|
|
||||||
|
private static TexturePage ms_tpageSprites;
|
||||||
|
|
||||||
|
private static List<Wave> ms_Waves;
|
||||||
|
|
||||||
|
private static List<GML2VM> ms_code;
|
||||||
|
|
||||||
|
static IFFSaver()
|
||||||
|
{
|
||||||
|
ms_Waves = new List<Wave>(20);
|
||||||
|
ms_code = new List<GML2VM>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save(GMAssets _assets, string _name)
|
||||||
|
{
|
||||||
|
ms_code.Clear();
|
||||||
|
if (Program.RemoveDND)
|
||||||
|
{
|
||||||
|
_assets.RemoveDND();
|
||||||
|
foreach (KeyValuePair<string, GMScript> script in _assets.Scripts)
|
||||||
|
{
|
||||||
|
if (script.Value != null && !string.IsNullOrEmpty(script.Value.Script))
|
||||||
|
{
|
||||||
|
GMLCode code = new GMLCode(_assets, script.Key, script.Value.Script, eGMLCodeType.eScript);
|
||||||
|
GML2VM gML2VM = new GML2VM();
|
||||||
|
gML2VM.Compile(_assets, code);
|
||||||
|
ms_code.Add(gML2VM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string, GMObject> @object in _assets.Objects)
|
||||||
|
{
|
||||||
|
if (@object.Value != null)
|
||||||
|
{
|
||||||
|
foreach (IList<KeyValuePair<int, GMEvent>> @event in @object.Value.Events)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<int, GMEvent> item in @event)
|
||||||
|
{
|
||||||
|
if (item.Value != null && item.Value.Actions != null && item.Value.Actions.Count > 0 && item.Value.Actions[0].Kind == eAction.ACT_CODE)
|
||||||
|
{
|
||||||
|
GMLCode code2 = new GMLCode(_assets, @object.Key, item.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
|
||||||
|
GML2VM gML2VM2 = new GML2VM();
|
||||||
|
gML2VM2.Compile(_assets, code2);
|
||||||
|
ms_code.Add(gML2VM2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string, GMTimeLine> timeLine in _assets.TimeLines)
|
||||||
|
{
|
||||||
|
if (timeLine.Value != null)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<int, GMEvent> entry in timeLine.Value.Entries)
|
||||||
|
{
|
||||||
|
if (entry.Value != null && entry.Value.Actions != null && entry.Value.Actions.Count > 0 && entry.Value.Actions[0].Kind == eAction.ACT_CODE)
|
||||||
|
{
|
||||||
|
GMLCode code3 = new GMLCode(_assets, timeLine.Key, entry.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
|
||||||
|
GML2VM gML2VM3 = new GML2VM();
|
||||||
|
gML2VM3.Compile(_assets, code3);
|
||||||
|
ms_code.Add(gML2VM3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (GMTrigger trigger in _assets.Triggers)
|
||||||
|
{
|
||||||
|
if (trigger != null)
|
||||||
|
{
|
||||||
|
GMLCode code4 = new GMLCode(_assets, trigger.Name, trigger.Condition, eGMLCodeType.eTrigger);
|
||||||
|
GML2VM gML2VM4 = new GML2VM();
|
||||||
|
gML2VM4.Compile(_assets, code4);
|
||||||
|
ms_code.Add(gML2VM4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<string, GMRoom> room in _assets.Rooms)
|
||||||
|
{
|
||||||
|
if (room.Value != null)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(room.Value.Code))
|
||||||
|
{
|
||||||
|
GMLCode code5 = new GMLCode(_assets, room.Key, room.Value.Code, eGMLCodeType.eRoomCreate);
|
||||||
|
GML2VM gML2VM5 = new GML2VM();
|
||||||
|
gML2VM5.Compile(_assets, code5);
|
||||||
|
ms_code.Add(gML2VM5);
|
||||||
|
}
|
||||||
|
foreach (GMInstance instance in room.Value.Instances)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(instance.Code))
|
||||||
|
{
|
||||||
|
GMLCode code6 = new GMLCode(_assets, room.Key, instance.Code, eGMLCodeType.eRoomInstanceCreate);
|
||||||
|
GML2VM gML2VM6 = new GML2VM();
|
||||||
|
gML2VM6.Compile(_assets, code6);
|
||||||
|
ms_code.Add(gML2VM6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ms_tpageSprites = new TexturePage(2, 2, 0, 0, Program.MachineType.TPageWidth, Program.MachineType.TPageHeight);
|
||||||
|
ms_Waves.Clear();
|
||||||
|
Program.Out.WriteLine("Saving IFF file... {0}", _name);
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
if (Path.GetExtension(_name) == ".zip")
|
||||||
|
{
|
||||||
|
using (FileStream stream = File.Create(_name))
|
||||||
|
{
|
||||||
|
ZipOutputStream zipOutputStream = new ZipOutputStream(stream);
|
||||||
|
zipOutputStream.PutNextEntry(string.Format("assets\\game{0}", Program.MachineType.Extension));
|
||||||
|
Save(_assets, zipOutputStream, list);
|
||||||
|
foreach (string item2 in list)
|
||||||
|
{
|
||||||
|
if (File.Exists(item2))
|
||||||
|
{
|
||||||
|
string entryName = Path.Combine("assets", Path.GetFileName(item2));
|
||||||
|
zipOutputStream.PutNextEntry(entryName);
|
||||||
|
byte[] array = File.ReadAllBytes(item2);
|
||||||
|
zipOutputStream.Write(array, 0, array.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zipOutputStream.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (FileStream stream2 = File.Create(_name))
|
||||||
|
{
|
||||||
|
Save(_assets, stream2, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Save(GMAssets _assets, Stream _stream, List<string> _extraFilenames)
|
||||||
|
{
|
||||||
|
IFF iFF = new IFF();
|
||||||
|
iFF.ExternalFiles = _extraFilenames;
|
||||||
|
string name = "GENL";
|
||||||
|
switch (_assets.Version)
|
||||||
|
{
|
||||||
|
case 700:
|
||||||
|
case 701:
|
||||||
|
name = "GEN7";
|
||||||
|
break;
|
||||||
|
case 800:
|
||||||
|
case 810:
|
||||||
|
name = "GEN8";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iFF.RegisterChunk(name, WriteHeader, _assets, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("TXTR", WriteTextures, _assets, IFFChunkType.GPU | IFFChunkType.Align, 128);
|
||||||
|
iFF.RegisterChunk("AUDO", WriteWaveforms, _assets, IFFChunkType.Audio);
|
||||||
|
iFF.RegisterChunk("HELP", WriteHelp, _assets.Help, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("OPTN", WriteOptions, _assets.Options, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("EXTN", WriteExtensions, _assets.Extensions, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("SOND", WriteSounds, _assets.Sounds, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("SPRT", WriteSprites, _assets.Sprites, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("BGND", WriteBackgrounds, _assets.Backgrounds, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("PATH", WritePaths, _assets.Paths, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("SCPT", WriteScripts, _assets.Scripts, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("FONT", WriteFonts, _assets.Fonts, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("TMLN", WriteTimelines, _assets.TimeLines, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("OBJT", WriteObjects, _assets.Objects, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("ROOM", WriteRooms, _assets.Rooms, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("DAFL", WriteDataFiles, _assets.DataFiles, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("TPAGE", WriteTexturePages, _assets, IFFChunkType.CPU);
|
||||||
|
iFF.RegisterChunk("STRG", (IFFChunkSaver<IList<IFFString>>)WriteStrings, (IList<IFFString>)iFF.Strings, IFFChunkType.CPU);
|
||||||
|
iFF.WriteChunks(_stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteDataKVP<T>(IList<KeyValuePair<string, T>> _data, Stream _s, IFF _iff, WriteDelegateKVP<T> _del)
|
||||||
|
{
|
||||||
|
List<long> list = new List<long>();
|
||||||
|
_s.WriteInteger(_data.Count);
|
||||||
|
for (int i = 0; i < _data.Count; i++)
|
||||||
|
{
|
||||||
|
list.Add(_s.Position);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
int num = 0;
|
||||||
|
foreach (KeyValuePair<string, T> _datum in _data)
|
||||||
|
{
|
||||||
|
if (_datum.Value != null)
|
||||||
|
{
|
||||||
|
_del(_datum, _s, _iff, list[num]);
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteDataList<T>(IList<T> _data, Stream _s, IFF _iff, WriteDelegate<T> _del)
|
||||||
|
{
|
||||||
|
List<long> list = new List<long>();
|
||||||
|
_s.WriteInteger(_data.Count);
|
||||||
|
for (int i = 0; i < _data.Count; i++)
|
||||||
|
{
|
||||||
|
list.Add(_s.Position);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
int num = 0;
|
||||||
|
foreach (T _datum in _data)
|
||||||
|
{
|
||||||
|
_del(_datum, _s, _iff, list[num]);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteOptions(GMOptions _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
_s.WriteBoolean(_data.FullScreen);
|
||||||
|
_s.WriteBoolean(_data.InterpolatePixels);
|
||||||
|
_s.WriteBoolean(_data.NoBorder);
|
||||||
|
_s.WriteBoolean(_data.ShowCursor);
|
||||||
|
_s.WriteInteger(_data.Scale);
|
||||||
|
_s.WriteBoolean(_data.Sizeable);
|
||||||
|
_s.WriteBoolean(_data.StayOnTop);
|
||||||
|
_s.WriteInteger(_data.WindowColour);
|
||||||
|
_s.WriteBoolean(_data.ChangeResolution);
|
||||||
|
_s.WriteInteger(_data.ColorDepth);
|
||||||
|
_s.WriteInteger(_data.Resolution);
|
||||||
|
_s.WriteInteger(_data.Frequency);
|
||||||
|
_s.WriteBoolean(_data.NoButtons);
|
||||||
|
_s.WriteInteger(_data.Sync_Vertex);
|
||||||
|
_s.WriteBoolean(_data.ScreenKey);
|
||||||
|
_s.WriteBoolean(_data.HelpKey);
|
||||||
|
_s.WriteBoolean(_data.QuitKey);
|
||||||
|
_s.WriteBoolean(_data.SaveKey);
|
||||||
|
_s.WriteBoolean(_data.ScreenShotKey);
|
||||||
|
_s.WriteBoolean(_data.CloseSec);
|
||||||
|
_s.WriteInteger(_data.Priority);
|
||||||
|
_s.WriteBoolean(_data.Freeze);
|
||||||
|
_s.WriteBoolean(_data.ShowProgress);
|
||||||
|
if (_data.BackImage != null && !Program.SplashOmit)
|
||||||
|
{
|
||||||
|
TexturePageEntry o = ms_tpageSprites.AddImage(_data.BackImage, true, false);
|
||||||
|
_iff.AddPatch(_s, o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
if (_data.FrontImage != null && !Program.SplashOmit)
|
||||||
|
{
|
||||||
|
TexturePageEntry o2 = ms_tpageSprites.AddImage(_data.FrontImage, true, false);
|
||||||
|
_iff.AddPatch(_s, o2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
if (_data.LoadImage != null && !Program.SplashOmit)
|
||||||
|
{
|
||||||
|
TexturePageEntry o3 = ms_tpageSprites.AddImage(_data.LoadImage, true, false);
|
||||||
|
_iff.AddPatch(_s, o3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
_s.WriteBoolean(_data.LoadTransparent);
|
||||||
|
_s.WriteInteger(_data.LoadAlpha);
|
||||||
|
_s.WriteBoolean(_data.ScaleProgress);
|
||||||
|
_s.WriteBoolean(_data.DisplayErrors);
|
||||||
|
_s.WriteBoolean(_data.WriteErrors);
|
||||||
|
_s.WriteBoolean(_data.AbortErrors);
|
||||||
|
_s.WriteBoolean(_data.VariableErrors);
|
||||||
|
_s.WriteBoolean(_data.CreationEventOrder);
|
||||||
|
int num = 0;
|
||||||
|
foreach (KeyValuePair<string, string> constant in _data.Constants)
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (GMLCompile.ms_ConstantCount.TryGetValue(constant.Key, out value) && value > 0)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_s.WriteInteger(num);
|
||||||
|
foreach (KeyValuePair<string, string> constant2 in _data.Constants)
|
||||||
|
{
|
||||||
|
int value2 = 0;
|
||||||
|
if (GMLCompile.ms_ConstantCount.TryGetValue(constant2.Key, out value2) && value2 > 0)
|
||||||
|
{
|
||||||
|
_iff.AddString(_s, constant2.Key);
|
||||||
|
_iff.AddString(_s, constant2.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteHelp(GMHelp _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
_s.WriteInteger(_data.BackgroundColour);
|
||||||
|
_s.WriteBoolean(_data.Mimic);
|
||||||
|
_iff.AddString(_s, _data.Caption);
|
||||||
|
_s.WriteInteger(_data.Left);
|
||||||
|
_s.WriteInteger(_data.Top);
|
||||||
|
_s.WriteInteger(_data.Width);
|
||||||
|
_s.WriteInteger(_data.Height);
|
||||||
|
_s.WriteBoolean(_data.Border);
|
||||||
|
_s.WriteBoolean(_data.Sizable);
|
||||||
|
_s.WriteBoolean(_data.OnTop);
|
||||||
|
_s.WriteBoolean(_data.Modal);
|
||||||
|
_iff.AddString(_s, _data.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteExtensions(IList<GMExtension> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteSounds(IList<KeyValuePair<string, GMSound>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMSound> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMSound value = _kvp.Value;
|
||||||
|
string[] source = value.OrigName.Split('\\', '/', ':');
|
||||||
|
string text = Path.GetFileName(source.Last());
|
||||||
|
bool flag = true;
|
||||||
|
while (flag)
|
||||||
|
{
|
||||||
|
flag = false;
|
||||||
|
foreach (Wave ms_Wave in ms_Waves)
|
||||||
|
{
|
||||||
|
if (ms_Wave.FileName == text)
|
||||||
|
{
|
||||||
|
text = string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(text), "_a", Path.GetExtension(text));
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value.Data != null)
|
||||||
|
{
|
||||||
|
ms_Waves.Add(new Wave(_iff, value.Data, text));
|
||||||
|
}
|
||||||
|
__s.WriteInteger(value.Kind);
|
||||||
|
__iff.AddString(__s, value.Extension);
|
||||||
|
__iff.AddString(__s, text);
|
||||||
|
__s.WriteInteger(value.Effects);
|
||||||
|
__s.WriteSingle((float)value.Volume);
|
||||||
|
__s.WriteSingle((float)value.Pan);
|
||||||
|
__s.WriteBoolean(value.Preload);
|
||||||
|
__s.WriteInteger(ms_Waves.Count - 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteSprites(IList<KeyValuePair<string, GMSprite>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMSprite> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.Align(4);
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMSprite value = _kvp.Value;
|
||||||
|
__s.WriteInteger(value.Width);
|
||||||
|
__s.WriteInteger(value.Height);
|
||||||
|
__s.WriteInteger(value.BBoxLeft);
|
||||||
|
__s.WriteInteger(value.BBoxRight);
|
||||||
|
__s.WriteInteger(value.BBoxBottom);
|
||||||
|
__s.WriteInteger(value.BBoxTop);
|
||||||
|
__s.WriteBoolean(value.Transparent);
|
||||||
|
__s.WriteBoolean(value.Smooth);
|
||||||
|
__s.WriteBoolean(value.Preload);
|
||||||
|
__s.WriteInteger(value.BBoxMode);
|
||||||
|
__s.WriteBoolean(value.ColCheck);
|
||||||
|
__s.WriteInteger(value.XOrig);
|
||||||
|
__s.WriteInteger(value.YOrig);
|
||||||
|
__s.WriteInteger(value.Images.Count);
|
||||||
|
ms_tpageSprites.BeginGroup(_kvp.Key);
|
||||||
|
for (int i = 0; i < value.Images.Count; i++)
|
||||||
|
{
|
||||||
|
if (value.Images[i].Width * value.Images[i].Height > 0)
|
||||||
|
{
|
||||||
|
TexturePageEntry o = ms_tpageSprites.AddImage(value.Images[i].Bitmap, true, false);
|
||||||
|
__iff.AddPatch(__s, o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ms_tpageSprites.EndGroup();
|
||||||
|
IList<byte[]> masks = value.Masks;
|
||||||
|
if (masks != null)
|
||||||
|
{
|
||||||
|
__s.WriteInteger(value.Masks.Count);
|
||||||
|
foreach (byte[] item in masks)
|
||||||
|
{
|
||||||
|
__s.Write(item, 0, item.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteBackgrounds(IList<KeyValuePair<string, GMBackground>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMBackground> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMBackground value = _kvp.Value;
|
||||||
|
__s.WriteBoolean(value.Transparent);
|
||||||
|
__s.WriteBoolean(value.Smooth);
|
||||||
|
__s.WriteBoolean(value.Preload);
|
||||||
|
if (value.Bitmap != null && value.Bitmap.Width * value.Bitmap.Height > 0)
|
||||||
|
{
|
||||||
|
ms_tpageSprites.BeginGroup(_kvp.Key);
|
||||||
|
TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap.Bitmap, true, false);
|
||||||
|
ms_tpageSprites.EndGroup();
|
||||||
|
texturePageEntry.OriginalRepeatBorder = true;
|
||||||
|
texturePageEntry.RepeatX = 2;
|
||||||
|
texturePageEntry.RepeatY = 2;
|
||||||
|
TextureOptions.SetTextureOptions(_kvp.Key, texturePageEntry);
|
||||||
|
__iff.AddPatch(__s, texturePageEntry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WritePaths(IList<KeyValuePair<string, GMPath>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMPath> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMPath value = _kvp.Value;
|
||||||
|
__s.WriteInteger(value.Kind);
|
||||||
|
__s.WriteBoolean(value.Closed);
|
||||||
|
__s.WriteInteger(value.Precision);
|
||||||
|
__s.WriteInteger(value.Points.Count);
|
||||||
|
foreach (GMPathPoint point in value.Points)
|
||||||
|
{
|
||||||
|
__s.WriteSingle((float)point.X);
|
||||||
|
__s.WriteSingle((float)point.Y);
|
||||||
|
__s.WriteSingle((float)point.Speed);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteScripts(IList<KeyValuePair<string, GMScript>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMScript> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMScript value = _kvp.Value;
|
||||||
|
__iff.AddString(__s, value.Script);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Bitmap Crop(Bitmap _bmp, int _x, int _y, int _w, int _h)
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new Bitmap(_w, _h, PixelFormat.Format32bppArgb);
|
||||||
|
using (Graphics graphics = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
graphics.DrawImage(_bmp, new Rectangle(0, 0, _w, _h), new Rectangle(_x, _y, _w, _h), GraphicsUnit.Pixel);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteFonts(IList<KeyValuePair<string, GMFont>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMFont> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMFont value = _kvp.Value;
|
||||||
|
__iff.AddString(__s, value.Name);
|
||||||
|
__s.WriteInteger(value.Size);
|
||||||
|
__s.WriteBoolean(value.Bold);
|
||||||
|
__s.WriteBoolean(value.Italic);
|
||||||
|
//__s.WriteInteger(value.First | (value.CharSet << 16) | (value.AntiAlias << 24));
|
||||||
|
//CharSet and AntiAliasing are NOT supported by PSP runner!
|
||||||
|
__s.WriteInteger(value.First);
|
||||||
|
__s.WriteInteger(value.Last);
|
||||||
|
ms_tpageSprites.BeginGroup(_kvp.Key);
|
||||||
|
TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap, false, true);
|
||||||
|
ms_tpageSprites.EndGroup();
|
||||||
|
__iff.AddPatch(__s, texturePageEntry);
|
||||||
|
double num = 1.0;
|
||||||
|
double num2 = 1.0;
|
||||||
|
if (texturePageEntry.W != value.Bitmap.Width || texturePageEntry.H != value.Bitmap.Height)
|
||||||
|
{
|
||||||
|
num = (double)texturePageEntry.W / (double)value.Bitmap.Width;
|
||||||
|
num2 = (double)texturePageEntry.H / (double)value.Bitmap.Height;
|
||||||
|
}
|
||||||
|
num = 1.0 / num;
|
||||||
|
num2 = 1.0 / num2;
|
||||||
|
__s.WriteSingle((float)num);
|
||||||
|
__s.WriteSingle((float)num2);
|
||||||
|
__s.WriteInteger(value.Glyphs.Count);
|
||||||
|
foreach (GMGlyph glyph in value.Glyphs)
|
||||||
|
{
|
||||||
|
__s.WriteInteger((int)(((double)glyph.X + num - 1.0) / num));
|
||||||
|
__s.WriteInteger((int)(((double)glyph.Y + num2 - 1.0) / num2));
|
||||||
|
__s.WriteInteger((int)(((double)glyph.W + num - 1.0) / num));
|
||||||
|
__s.WriteInteger((int)(((double)glyph.H + num2 - 1.0) / num2));
|
||||||
|
__s.WriteInteger((int)(((double)glyph.Shift + num - 1.0) / num));
|
||||||
|
__s.WriteInteger((int)(((double)glyph.Offset + num - 1.0) / num));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteGMEvent(GMEvent _event, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataList(_event.Actions, _s, _iff, delegate(GMAction _action, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__s.WriteInteger(_action.LibID);
|
||||||
|
__s.WriteInteger(_action.ID);
|
||||||
|
__s.WriteInteger((int)_action.Kind);
|
||||||
|
__s.WriteBoolean(_action.UseRelative);
|
||||||
|
__s.WriteBoolean(_action.IsQuestion);
|
||||||
|
__s.WriteBoolean(_action.UseApplyTo);
|
||||||
|
__s.WriteInteger((int)_action.ExeType);
|
||||||
|
__iff.AddString(__s, _action.Name);
|
||||||
|
__iff.AddString(__s, _action.Code);
|
||||||
|
__s.WriteInteger(_action.ArgumentCount);
|
||||||
|
__s.WriteInteger(_action.Who);
|
||||||
|
__s.WriteBoolean(_action.Relative);
|
||||||
|
__s.WriteBoolean(_action.IsNot);
|
||||||
|
if (_action.ArgTypes.Count != _action.Args.Count)
|
||||||
|
{
|
||||||
|
Console.WriteLine("We have a problem here!!");
|
||||||
|
}
|
||||||
|
__s.WriteInteger(_action.ArgTypes.Count);
|
||||||
|
for (int i = 0; i < _action.ArgTypes.Count; i++)
|
||||||
|
{
|
||||||
|
__s.WriteInteger((int)_action.ArgTypes[i]);
|
||||||
|
__iff.AddString(__s, _action.Args[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteTimelines(IList<KeyValuePair<string, GMTimeLine>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMTimeLine> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMTimeLine value = _kvp.Value;
|
||||||
|
__s.WriteInteger(value.Entries.Count);
|
||||||
|
foreach (KeyValuePair<int, GMEvent> entry in value.Entries)
|
||||||
|
{
|
||||||
|
__s.WriteInteger(entry.Key);
|
||||||
|
__iff.AddPatch(__s, entry.Value);
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<int, GMEvent> entry2 in value.Entries)
|
||||||
|
{
|
||||||
|
__iff.SetOffset(__s, entry2.Value, __s.Position);
|
||||||
|
WriteGMEvent(entry2.Value, __s, __iff);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteObjects(IList<KeyValuePair<string, GMObject>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMObject> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMObject value = _kvp.Value;
|
||||||
|
__s.WriteInteger(value.SpriteIndex);
|
||||||
|
__s.WriteBoolean(value.Visible);
|
||||||
|
__s.WriteBoolean(value.Solid);
|
||||||
|
__s.WriteInteger(value.Depth);
|
||||||
|
__s.WriteBoolean(value.Persistent);
|
||||||
|
__s.WriteInteger(value.Parent);
|
||||||
|
__s.WriteInteger(value.Mask);
|
||||||
|
|
||||||
|
Console.WriteLine("DEBUG:\nOBJECT EVENTS: " + value.Events.ToString());
|
||||||
|
WriteDataList(value.Events, __s, __iff, delegate(IList<KeyValuePair<int, GMEvent>> _list, Stream ___s, IFF ___iff, long ___index)
|
||||||
|
{
|
||||||
|
___s.PatchOffset(___index);
|
||||||
|
WriteDataList(_list, ___s, ___iff, delegate(KeyValuePair<int, GMEvent> _entry, Stream ____s, IFF ____iff, long ____index)
|
||||||
|
{
|
||||||
|
____s.PatchOffset(____index);
|
||||||
|
____s.WriteInteger(_entry.Key);
|
||||||
|
WriteGMEvent(_entry.Value, ____s, ____iff);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteRooms(IList<KeyValuePair<string, GMRoom>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair<string, GMRoom> _kvp, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.AddString(__s, _kvp.Key);
|
||||||
|
GMRoom value = _kvp.Value;
|
||||||
|
__iff.AddString(__s, value.Caption);
|
||||||
|
__s.WriteInteger(value.Width);
|
||||||
|
__s.WriteInteger(value.Height);
|
||||||
|
__s.WriteInteger(value.Speed);
|
||||||
|
__s.WriteBoolean(value.Persistent);
|
||||||
|
__s.WriteInteger(value.Colour);
|
||||||
|
__s.WriteBoolean(value.ShowColour);
|
||||||
|
__iff.AddString(__s, value.Code);
|
||||||
|
__s.WriteBoolean(value.EnableViews);
|
||||||
|
long position = __s.Position;
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
long position2 = __s.Position;
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
long position3 = __s.Position;
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
long position4 = __s.Position;
|
||||||
|
__s.WriteInteger(0);
|
||||||
|
__s.PatchOffset(position);
|
||||||
|
WriteDataList(value.Backgrounds, __s, __iff, delegate(GMBack _back, Stream ___s, IFF ___iff, long ___index)
|
||||||
|
{
|
||||||
|
___s.PatchOffset(___index);
|
||||||
|
___s.WriteBoolean(_back.Visible);
|
||||||
|
___s.WriteBoolean(_back.Foreground);
|
||||||
|
___s.WriteInteger(_back.Index);
|
||||||
|
___s.WriteInteger(_back.X);
|
||||||
|
___s.WriteInteger(_back.Y);
|
||||||
|
___s.WriteBoolean(_back.HTiled);
|
||||||
|
___s.WriteBoolean(_back.VTiled);
|
||||||
|
___s.WriteInteger(_back.HSpeed);
|
||||||
|
___s.WriteInteger(_back.VSpeed);
|
||||||
|
___s.WriteBoolean(_back.Stretch);
|
||||||
|
});
|
||||||
|
__s.PatchOffset(position2);
|
||||||
|
WriteDataList(value.Views, __s, __iff, delegate(GMView _view, Stream ___s, IFF ___iff, long ___index)
|
||||||
|
{
|
||||||
|
___s.PatchOffset(___index);
|
||||||
|
___s.WriteBoolean(_view.Visible);
|
||||||
|
___s.WriteInteger(_view.XView);
|
||||||
|
___s.WriteInteger(_view.YView);
|
||||||
|
___s.WriteInteger(_view.WView);
|
||||||
|
___s.WriteInteger(_view.HView);
|
||||||
|
___s.WriteInteger(_view.XPort);
|
||||||
|
___s.WriteInteger(_view.YPort);
|
||||||
|
___s.WriteInteger(_view.WPort);
|
||||||
|
___s.WriteInteger(_view.HPort);
|
||||||
|
___s.WriteInteger(_view.HBorder);
|
||||||
|
___s.WriteInteger(_view.VBorder);
|
||||||
|
___s.WriteInteger(_view.HSpeed);
|
||||||
|
___s.WriteInteger(_view.VSpeed);
|
||||||
|
___s.WriteInteger(_view.Index);
|
||||||
|
});
|
||||||
|
__s.PatchOffset(position3);
|
||||||
|
WriteDataList(value.Instances, __s, __iff, delegate(GMInstance _inst, Stream ___s, IFF ___iff, long ___index)
|
||||||
|
{
|
||||||
|
___s.PatchOffset(___index);
|
||||||
|
___s.WriteInteger(_inst.X);
|
||||||
|
___s.WriteInteger(_inst.Y);
|
||||||
|
___s.WriteInteger(_inst.Index);
|
||||||
|
___s.WriteInteger(_inst.Id);
|
||||||
|
___iff.AddString(___s, _inst.Code);
|
||||||
|
___s.WriteSingle((float)_inst.ScaleX);
|
||||||
|
___s.WriteSingle((float)_inst.ScaleY);
|
||||||
|
___s.WriteInteger((int)_inst.Colour);
|
||||||
|
___s.WriteSingle((float)_inst.Rotation);
|
||||||
|
});
|
||||||
|
__s.PatchOffset(position4);
|
||||||
|
WriteDataList(value.Tiles, __s, __iff, delegate(GMTile _tile, Stream ___s, IFF ___iff, long ___index)
|
||||||
|
{
|
||||||
|
___s.PatchOffset(___index);
|
||||||
|
___s.WriteInteger(_tile.X);
|
||||||
|
___s.WriteInteger(_tile.Y);
|
||||||
|
___s.WriteInteger(_tile.Index);
|
||||||
|
___s.WriteInteger(_tile.XO);
|
||||||
|
___s.WriteInteger(_tile.YO);
|
||||||
|
___s.WriteInteger(_tile.W);
|
||||||
|
___s.WriteInteger(_tile.H);
|
||||||
|
___s.WriteInteger(_tile.Depth);
|
||||||
|
___s.WriteInteger(_tile.Id);
|
||||||
|
___s.WriteSingle((float)_tile.XScale);
|
||||||
|
___s.WriteSingle((float)_tile.YScale);
|
||||||
|
___s.WriteInteger(_tile.Blend + ((int)(_tile.Alpha * 255.0) << 24));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteDataFiles(IList<KeyValuePair<string, GMDataFile>> _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, GMDataFile> _datum in _data)
|
||||||
|
{
|
||||||
|
GMDataFile value = _datum.Value;
|
||||||
|
string text = Path.Combine(Program.OutputDir, value.FileName);
|
||||||
|
File.WriteAllBytes(text, value.Data);
|
||||||
|
_iff.ExternalFiles.Add(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteHeader(GMAssets _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
_s.WriteInteger(((!_data.Debug) ? 1 : 0) | 0x201);
|
||||||
|
_iff.AddString(_s, Path.GetFileNameWithoutExtension(_data.FileName));
|
||||||
|
_s.WriteInteger(_data.RoomMaxId);
|
||||||
|
_s.WriteInteger(_data.RoomMaxTileId);
|
||||||
|
_s.WriteInteger(_data.GameID);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
_s.WriteInteger(_data.RoomOrder.Count);
|
||||||
|
foreach (int item in _data.RoomOrder)
|
||||||
|
{
|
||||||
|
_s.WriteInteger(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteTextures(GMAssets _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
List<byte[]> list = new List<byte[]>();
|
||||||
|
if (ms_tpageSprites.Textures != null)
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
foreach (Texture texture in ms_tpageSprites.Textures)
|
||||||
|
{
|
||||||
|
Program.Out.Write("{0} Compressing texture... ", num);
|
||||||
|
Image _dest = null;
|
||||||
|
Bitmap bitmap = texture.Bitmap;
|
||||||
|
byte[] array = Form1.createOutTexture(bitmap, eSquishFlags.kDxt5 | eSquishFlags.kColourMetricPerceptual | eSquishFlags.kClusterFitMaxIteration8, out _dest, Program.TextureType[texture.Group]);
|
||||||
|
string path = Path.Combine(Program.OutputDir, string.Format("texture_{0}{1}", num, Program.TextureTypeExtension(Program.TextureType[texture.Group])));
|
||||||
|
Program.Out.WriteLine("writing texture {0}... ", Path.GetFileName(path));
|
||||||
|
if (Program.WriteTextures)
|
||||||
|
{
|
||||||
|
if (string.Compare(Path.GetExtension(path), ".png", true) != 0)
|
||||||
|
{
|
||||||
|
texture.Bitmap.Save(Path.ChangeExtension(path, ".original.png"), ImageFormat.Png);
|
||||||
|
}
|
||||||
|
if (_dest != null)
|
||||||
|
{
|
||||||
|
_dest.Save(Path.ChangeExtension(path, ".png"), ImageFormat.Png);
|
||||||
|
}
|
||||||
|
File.WriteAllBytes(path, array);
|
||||||
|
}
|
||||||
|
list.Add(array);
|
||||||
|
Application.DoEvents();
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WriteDataList(list, _s, _iff, delegate(byte[] __tex, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
int num2 = 128;
|
||||||
|
int num3 = num2 - 1;
|
||||||
|
while ((__s.Position & num3) != 0)
|
||||||
|
{
|
||||||
|
__s.WriteByte(0);
|
||||||
|
}
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__s.Write(__tex, 0, __tex.Length);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteTexturePages(GMAssets _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
if (ms_tpageSprites.Entries.Count > 0)
|
||||||
|
{
|
||||||
|
ms_tpageSprites.Compile();
|
||||||
|
}
|
||||||
|
IOrderedEnumerable<TexturePageEntry> source = ms_tpageSprites.Entries.OrderBy((TexturePageEntry e) => e.Entry);
|
||||||
|
WriteDataList(source.ToList(), _s, _iff, delegate(TexturePageEntry _tpe, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__iff.SetOffset(__s, _tpe, __s.Position);
|
||||||
|
__s.WriteShort((short)_tpe.X);
|
||||||
|
__s.WriteShort((short)_tpe.Y);
|
||||||
|
__s.WriteShort((short)_tpe.W);
|
||||||
|
__s.WriteShort((short)_tpe.H);
|
||||||
|
__s.WriteShort((short)_tpe.XOffset);
|
||||||
|
__s.WriteShort((short)_tpe.YOffset);
|
||||||
|
__s.WriteShort((short)_tpe.CropWidth);
|
||||||
|
__s.WriteShort((short)_tpe.CropHeight);
|
||||||
|
__s.WriteShort((short)_tpe.OW);
|
||||||
|
__s.WriteShort((short)_tpe.OH);
|
||||||
|
__s.WriteShort((short)_tpe.TP.TP);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteWaveforms(GMAssets _data, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataList(ms_Waves, _s, _iff, delegate(Wave _wave, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
int num = 4;
|
||||||
|
int num2 = num - 1;
|
||||||
|
while ((__s.Position & num2) != 0)
|
||||||
|
{
|
||||||
|
__s.WriteByte(0);
|
||||||
|
}
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
__s.WriteInteger(_wave.RawWavFile.Length);
|
||||||
|
__s.Write(_wave.RawWavFile, 0, _wave.RawWavFile.Length);
|
||||||
|
if (Program.WriteWaves && _wave.FileName.ToLower().EndsWith("wav"))
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(Path.Combine(Program.OutputDir, Path.GetFileName(_wave.FileName)), _wave.RawWavFile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Console.WriteLine("SILICA PATCH!");
|
||||||
|
int NumSounds = _data.Sounds.Count;
|
||||||
|
for(int i = 0; i < NumSounds; i++)
|
||||||
|
{
|
||||||
|
// Console.WriteLine("Reading Sound: " + i.ToString());
|
||||||
|
if (_data.Sounds[i].ToString() == "[, ]")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
KeyValuePair<string,GMSound> SoundPair = _data.Sounds[i];
|
||||||
|
GMSound Sound = SoundPair.Value;
|
||||||
|
String OriginalName = Sound.OrigName;
|
||||||
|
Console.WriteLine("Writing: " + OriginalName);
|
||||||
|
String AudioFile = Path.Combine(Program.OutputDir, OriginalName);
|
||||||
|
|
||||||
|
Console.WriteLine("Converting " + OriginalName + " To .WAV");
|
||||||
|
|
||||||
|
|
||||||
|
if(Path.GetExtension(OriginalName).ToLower() == ".mid" || Path.GetExtension(OriginalName).ToLower() == ".midi")
|
||||||
|
{
|
||||||
|
// File.WriteAllBytes(AudioFile, Sound.Data);
|
||||||
|
MessageBox.Show("MIDI NOT SUPPORTED!\nPlease convert " + OriginalName + " to an MP3 File!","MIDI",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(Path.GetExtension(OriginalName).ToLower() == ".mp3" || Path.GetExtension(OriginalName).ToLower() == ".wav")
|
||||||
|
{
|
||||||
|
if(Path.GetExtension(OriginalName).ToLower() == ".mp3")
|
||||||
|
{
|
||||||
|
MemoryStream Mp3Stream = new MemoryStream(Sound.Data);
|
||||||
|
Mp3FileReader mp3 = new Mp3FileReader(Mp3Stream);
|
||||||
|
WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(mp3);
|
||||||
|
WaveFileWriter.CreateWaveFile(Path.ChangeExtension(AudioFile, "wav"), pcm);
|
||||||
|
|
||||||
|
pcm.Close();
|
||||||
|
mp3.Close();
|
||||||
|
pcm.Dispose();
|
||||||
|
mp3.Dispose();
|
||||||
|
|
||||||
|
|
||||||
|
//Convert to AT3
|
||||||
|
Process At3Tool = new Process();
|
||||||
|
At3Tool.StartInfo.FileName = Path.Combine(Application.StartupPath, "at3tool.exe");
|
||||||
|
At3Tool.StartInfo.CreateNoWindow = true;
|
||||||
|
At3Tool.StartInfo.UseShellExecute = false;
|
||||||
|
At3Tool.StartInfo.RedirectStandardOutput = true;
|
||||||
|
At3Tool.StartInfo.RedirectStandardError = true;
|
||||||
|
At3Tool.StartInfo.Arguments = "-e \"" + Path.ChangeExtension(AudioFile, "wav") + "\" \"" + Path.ChangeExtension(AudioFile, "at3") + "\"";
|
||||||
|
Console.WriteLine(At3Tool.StartInfo.FileName + " " + At3Tool.StartInfo.Arguments);
|
||||||
|
At3Tool.Start();
|
||||||
|
At3Tool.WaitForExit();
|
||||||
|
if (At3Tool.ExitCode != 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine(At3Tool.StandardOutput.ReadToEnd() + At3Tool.StandardError.ReadToEnd());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
At3Tool.Dispose();
|
||||||
|
File.Delete(Path.ChangeExtension(AudioFile, "wav"));
|
||||||
|
}
|
||||||
|
/*else if(Path.GetExtension(OriginalName) == ".wav")
|
||||||
|
{
|
||||||
|
MemoryStream WavStream = new MemoryStream(Sound.Data);
|
||||||
|
WaveFileReader WavReader = new WaveFileReader(WavStream);
|
||||||
|
WaveFormat WavFormat = new WaveFormat(44100, 16, 2);
|
||||||
|
WaveFormatConversionStream conversionStream = new WaveFormatConversionStream(WavFormat, WavReader);
|
||||||
|
WaveFileWriter.CreateWaveFile(AudioFile, conversionStream);
|
||||||
|
|
||||||
|
WavStream.Close();
|
||||||
|
WavStream.Dispose();
|
||||||
|
WavReader.Close();
|
||||||
|
WavReader.Dispose();
|
||||||
|
conversionStream.Close();
|
||||||
|
conversionStream.Dispose();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
Console.WriteLine("Done");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteStrings(IList<IFFString> _strings, Stream _s, IFF _iff)
|
||||||
|
{
|
||||||
|
WriteDataList(_strings, _s, _iff, delegate(IFFString _string, Stream __s, IFF __iff, long __index)
|
||||||
|
{
|
||||||
|
__s.PatchOffset(__index);
|
||||||
|
_s.WriteInteger(_string.String.Length);
|
||||||
|
__iff.SetOffset(__s, _string, __s.Position);
|
||||||
|
for (int i = 0; i < _string.String.Length; i++)
|
||||||
|
{
|
||||||
|
_s.WriteByte((byte)_string.String[i]);
|
||||||
|
}
|
||||||
|
_s.WriteByte(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class IFFString
|
||||||
|
{
|
||||||
|
public string String
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IFFString(string _s)
|
||||||
|
{
|
||||||
|
String = _s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public interface IIFFChunkHandler
|
||||||
|
{
|
||||||
|
IFFChunkType Type
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Align
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Offset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Save(Stream _stream, IFF _iff);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal interface IMachineType
|
||||||
|
{
|
||||||
|
string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Description
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Extension
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
eOutputType OutputType
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageWidth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageHeight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageBorderTop
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageBorderBottom
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageBorderLeft
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TPageBorderRight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
eTexType OpaqueTextureType
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
eTexType AlphaTextureType
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
ushort Convert4444(int _a, int _r, int _g, int _b);
|
||||||
|
|
||||||
|
uint Convert8888(int _a, int _r, int _g, int _b);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Flobbster.Windows.Forms;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public interface IPropertyGrid
|
||||||
|
{
|
||||||
|
PropertyBag Prepare();
|
||||||
|
|
||||||
|
Image PrepareImage();
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,31 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class LexTree
|
||||||
|
{
|
||||||
|
public List<LexTree> Children;
|
||||||
|
|
||||||
|
public Dictionary<string, VFNode> Used;
|
||||||
|
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
public VFNode Node;
|
||||||
|
|
||||||
|
public eLex Token;
|
||||||
|
|
||||||
|
public string Text;
|
||||||
|
|
||||||
|
public double _value;
|
||||||
|
|
||||||
|
public bool anon;
|
||||||
|
|
||||||
|
public LexTree(eLex _token, string _text)
|
||||||
|
{
|
||||||
|
Text = _text;
|
||||||
|
Token = _token;
|
||||||
|
Name = "";
|
||||||
|
anon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,481 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class Loader
|
||||||
|
{
|
||||||
|
public static byte[] g_FileBuffer;
|
||||||
|
|
||||||
|
private static uint[] ms_fastCRC = null;
|
||||||
|
|
||||||
|
public static GMAssets Load(string _name)
|
||||||
|
{
|
||||||
|
GMAssets gMAssets = null;
|
||||||
|
if (string.Compare(Path.GetExtension(_name), ".psp", true) == 0)
|
||||||
|
{
|
||||||
|
FileStream fileStream = File.Open(_name, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
gMAssets = LoadPSP(fileStream);
|
||||||
|
fileStream.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_FileBuffer = File.ReadAllBytes(_name);
|
||||||
|
MemoryStream memoryStream = new MemoryStream(g_FileBuffer, true);
|
||||||
|
gMAssets = LoadGMK(memoryStream, _name);
|
||||||
|
memoryStream.Close();
|
||||||
|
}
|
||||||
|
if (gMAssets != null)
|
||||||
|
{
|
||||||
|
gMAssets.FileName = Path.GetFullPath(_name);
|
||||||
|
}
|
||||||
|
return gMAssets;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint[] InitFastCRC()
|
||||||
|
{
|
||||||
|
if (ms_fastCRC == null)
|
||||||
|
{
|
||||||
|
uint[] array = new uint[256];
|
||||||
|
uint num = 3988292384u;
|
||||||
|
for (uint num2 = 0u; num2 < 256; num2++)
|
||||||
|
{
|
||||||
|
uint num3 = num2;
|
||||||
|
for (uint num4 = 8u; num4 != 0; num4--)
|
||||||
|
{
|
||||||
|
num3 = (((num3 & 1) == 0) ? (num3 >> 1) : ((num3 >> 1) ^ num));
|
||||||
|
}
|
||||||
|
array[num2] = num3;
|
||||||
|
}
|
||||||
|
ms_fastCRC = array;
|
||||||
|
}
|
||||||
|
return ms_fastCRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint CalcCRC(string _text)
|
||||||
|
{
|
||||||
|
uint[] array = InitFastCRC();
|
||||||
|
uint num = uint.MaxValue;
|
||||||
|
foreach (char c in _text)
|
||||||
|
{
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ (c & 0xFF)) & 0xFF]);
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ (((int)c >> 8) & 0xFF)) & 0xFF]);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int CalcCRC(byte[] _buffer)
|
||||||
|
{
|
||||||
|
uint[] array = InitFastCRC();
|
||||||
|
uint num = uint.MaxValue;
|
||||||
|
foreach (byte b in _buffer)
|
||||||
|
{
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ b) & 0xFF]);
|
||||||
|
}
|
||||||
|
return (int)num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint CalcCRC(byte[] _buffer, int offset)
|
||||||
|
{
|
||||||
|
uint[] array = InitFastCRC();
|
||||||
|
uint num = uint.MaxValue;
|
||||||
|
for (int i = offset; i < _buffer.Length; i++)
|
||||||
|
{
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ _buffer[i]) & 0xFF]);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe static uint HashBitmap(Bitmap _image)
|
||||||
|
{
|
||||||
|
uint[] array = InitFastCRC();
|
||||||
|
uint num = uint.MaxValue;
|
||||||
|
BitmapData bitmapData = _image.LockBits(new Rectangle(0, 0, _image.Width, _image.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
uint* ptr = (uint*)bitmapData.Scan0.ToPointer();
|
||||||
|
uint* ptr2 = ptr;
|
||||||
|
uint num4 = *ptr2;
|
||||||
|
for (int i = 0; i < _image.Height; i++)
|
||||||
|
{
|
||||||
|
uint* ptr3 = (uint*)((long)ptr + i * bitmapData.Stride);
|
||||||
|
int num2 = 0;
|
||||||
|
while (num2 < _image.Width)
|
||||||
|
{
|
||||||
|
uint num3 = *ptr3;
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ (num3 & 0xFF)) & 0xFF]);
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ ((num3 >> 8) & 0xFF)) & 0xFF]);
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ ((num3 >> 16) & 0xFF)) & 0xFF]);
|
||||||
|
num = (((num >> 8) & 0xFFFFFF) ^ array[(num ^ ((num3 >> 24) & 0xFF)) & 0xFF]);
|
||||||
|
num2++;
|
||||||
|
ptr3++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_image.UnlockBits(bitmapData);
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetUint(ref uint m_z, ref uint m_w)
|
||||||
|
{
|
||||||
|
m_z = 36969 * (m_z & 0xFFFF) + (m_z >> 16);
|
||||||
|
m_w = 18000 * (m_w & 0xFFFF) + (m_w >> 16);
|
||||||
|
return (m_z << 16) + (m_w & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Process_Encrypt(byte[] _filebuffer, int _offset, string _passphrase, uint _crcOriginal)
|
||||||
|
{
|
||||||
|
uint num = CalcCRC(_passphrase);
|
||||||
|
uint m_z = (uint)((_crcOriginal == uint.MaxValue) ? CalcCRC(_filebuffer) : ((int)_crcOriginal));
|
||||||
|
int num2 = _offset + 12 + (int)((num & 0xFF) + 6);
|
||||||
|
uint m_w = num;
|
||||||
|
for (int i = num2; i < _filebuffer.Length - 5; i += 4)
|
||||||
|
{
|
||||||
|
int num3 = _filebuffer[i] + (_filebuffer[i + 1] << 8) + (_filebuffer[i + 2] << 16) + (_filebuffer[i + 3] << 24);
|
||||||
|
num3 ^= (int)GetUint(ref m_z, ref m_w);
|
||||||
|
_filebuffer[i] = (byte)(num3 & 0xFF);
|
||||||
|
_filebuffer[i + 1] = (byte)((num3 >> 8) & 0xFF);
|
||||||
|
_filebuffer[i + 2] = (byte)((num3 >> 16) & 0xFF);
|
||||||
|
_filebuffer[i + 3] = (byte)((num3 >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
uint num4 = CalcCRC(_filebuffer, _offset + 12);
|
||||||
|
if (num4 != _crcOriginal)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckForOldVersions(Stream _stream)
|
||||||
|
{
|
||||||
|
_stream.Seek(1980000L, SeekOrigin.Begin);
|
||||||
|
if (_stream.ReadInteger() == 1234321)
|
||||||
|
{
|
||||||
|
_stream.Seek(1980000L, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num = 2000000;
|
||||||
|
_stream.Seek(num, SeekOrigin.Begin);
|
||||||
|
while (num < _stream.Length)
|
||||||
|
{
|
||||||
|
int num2 = _stream.ReadInteger();
|
||||||
|
if (num2 == 1234321)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
num += 10000;
|
||||||
|
_stream.Seek(num, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
_stream.Seek(num, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CheckFor8_1(Stream _stream)
|
||||||
|
{
|
||||||
|
for (int i = 3800000; i + 8 < _stream.Length; i++)
|
||||||
|
{
|
||||||
|
_stream.Seek(i, SeekOrigin.Begin);
|
||||||
|
uint num = (uint)_stream.ReadInteger();
|
||||||
|
uint num2 = (uint)_stream.ReadInteger();
|
||||||
|
uint num3 = (uint)(((int)num & -16711936) | (int)(num2 & 0xFF00FF));
|
||||||
|
uint num4 = (uint)(((int)num2 & -16711936) | (int)(num & 0xFF00FF));
|
||||||
|
if (((int)num4 & -65536) != 0)
|
||||||
|
{
|
||||||
|
num4 = (uint)(i - 1 - 3800004) / 4u;
|
||||||
|
}
|
||||||
|
if (num3 == 4145283175u)
|
||||||
|
{
|
||||||
|
uint num5 = (uint)_stream.ReadInteger();
|
||||||
|
uint crcOriginal = (uint)_stream.ReadInteger();
|
||||||
|
string passphrase = "_MJD" + num5.ToString() + "#RWK";
|
||||||
|
i--;
|
||||||
|
_stream.Seek(i + 17, SeekOrigin.Begin);
|
||||||
|
uint i2 = (uint)(_stream.ReadInteger() ^ (int)num4);
|
||||||
|
_stream.Seek(i + 17, SeekOrigin.Begin);
|
||||||
|
_stream.WriteInteger((int)i2);
|
||||||
|
_stream.Seek(i + 9, SeekOrigin.Begin);
|
||||||
|
if (!Process_Encrypt(g_FileBuffer, i + 9, passphrase, crcOriginal))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_stream.Seek(i + 17 - 4, SeekOrigin.Begin);
|
||||||
|
_stream.WriteInteger(1234321);
|
||||||
|
_stream.Seek(i + 17 - 4, SeekOrigin.Begin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TagBackgroundTilesets(GMAssets _assets)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, GMRoom> room in _assets.Rooms)
|
||||||
|
{
|
||||||
|
GMRoom value = room.Value;
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
foreach (GMTile tile in value.Tiles)
|
||||||
|
{
|
||||||
|
_assets.Backgrounds[tile.Index].Value.Tileset = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GMAssets LoadGMK(Stream _stream, string _name)
|
||||||
|
{
|
||||||
|
GMAssets gMAssets = null;
|
||||||
|
if (string.Compare(Path.GetExtension(_name), ".gmk", true) != 0)
|
||||||
|
{
|
||||||
|
if (!CheckFor8_1(_stream))
|
||||||
|
{
|
||||||
|
bool flag = CheckForOldVersions(_stream);
|
||||||
|
}
|
||||||
|
gMAssets = new GMAssets(_stream);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gMAssets = new GMAssets(_stream, true);
|
||||||
|
}
|
||||||
|
TagBackgroundTilesets(gMAssets);
|
||||||
|
return gMAssets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GMAssets LoadPSP(Stream _stream)
|
||||||
|
{
|
||||||
|
GMAssets result = null;
|
||||||
|
int num = (int)_stream.Length;
|
||||||
|
byte[] array = new byte[num];
|
||||||
|
_stream.Read(array, 0, num);
|
||||||
|
if (array[0] == 70 && array[1] == 79 && array[2] == 82 && array[3] == 77)
|
||||||
|
{
|
||||||
|
int num2 = array[4] + (array[5] << 8) + (array[6] << 16) + (array[7] << 24);
|
||||||
|
if (num2 == num - 8)
|
||||||
|
{
|
||||||
|
int num3 = 8;
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
while (num3 < num)
|
||||||
|
{
|
||||||
|
stringBuilder.Length = 0;
|
||||||
|
stringBuilder.Append((char)array[num3]);
|
||||||
|
stringBuilder.Append((char)array[num3 + 1]);
|
||||||
|
stringBuilder.Append((char)array[num3 + 2]);
|
||||||
|
stringBuilder.Append((char)array[num3 + 3]);
|
||||||
|
num2 = array[num3 + 4] + (array[num3 + 5] << 8) + (array[num3 + 6] << 16) + (array[num3 + 7] << 24);
|
||||||
|
string text = stringBuilder.ToString();
|
||||||
|
num3 += 8; //why 8?
|
||||||
|
switch (text)
|
||||||
|
{
|
||||||
|
case "GEN8":
|
||||||
|
Console.WriteLine("DEBUG: READING GEN8 CHUNK!");
|
||||||
|
LoadGeneral(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "OPTN":
|
||||||
|
Console.WriteLine("DEBUG: READING OPTN CHUNK!");
|
||||||
|
LoadOptions(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "SPRT":
|
||||||
|
Console.WriteLine("DEBUG: READING SPRT CHUNK!");
|
||||||
|
Load<GMSprite, YYSprite>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "SOND":
|
||||||
|
Console.WriteLine("DEBUG: READING SOND CHUNK!");
|
||||||
|
Load<GMSound, YYSound>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "BGND":
|
||||||
|
Console.WriteLine("DEBUG: READING BGND CHUNK!");
|
||||||
|
Load<GMBackground, YYBackground>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "PATH":
|
||||||
|
Console.WriteLine("DEBUG: READING PATH CHUNK!");
|
||||||
|
Load<GMPath, YYPath>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "SCPT":
|
||||||
|
Console.WriteLine("DEBUG: READING SCPT CHUNK!");
|
||||||
|
Load<GMScript, YYScript>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "FONT":
|
||||||
|
Console.WriteLine("DEBUG: READING FONT CHUNK!");
|
||||||
|
//Load<GMFont, YYFont>(text, num2, array, num3);
|
||||||
|
|
||||||
|
//makes GMAC crash when reading Karoshi game.psp
|
||||||
|
|
||||||
|
//due to it tries to load Bitmap data
|
||||||
|
//but app legit PSP games use "DDS" as texture format
|
||||||
|
break;
|
||||||
|
case "TMLN":
|
||||||
|
Console.WriteLine("DEBUG: READING TMLN CHUNK!");
|
||||||
|
//Load<GMTimeLine, YYTimeline>(text, num2, array, num3);
|
||||||
|
|
||||||
|
//also crashes here for no apparent reason!
|
||||||
|
break;
|
||||||
|
case "OBJT":
|
||||||
|
Console.WriteLine("DEBUG: READING OBJT CHUNK: PREPARE TO CRASH!");
|
||||||
|
Load<GMObject, YYObject>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
case "ROOM":
|
||||||
|
Console.WriteLine("DEBUG: READING ROOM CHUNK!");
|
||||||
|
Load<GMRoom, YYRoom>(text, num2, array, num3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Console.WriteLine("DEBUG: READING UNKN CHUNK!");//chunk is unknown
|
||||||
|
Console.WriteLine("unknown Chunk {0}", text);
|
||||||
|
break;
|
||||||
|
case "TXTR": break;
|
||||||
|
case "AUDO": break;
|
||||||
|
case "HELP": break;
|
||||||
|
case "EXTN": break;
|
||||||
|
case "DAFL": break;
|
||||||
|
case "TPAG": break;
|
||||||
|
case "STRG":
|
||||||
|
Console.WriteLine("DEBUG: READING STRING CHUNK!");
|
||||||
|
//åáàíûé ãåéììåéêåð øîá ãîðåëè â àäó åãî ñîçäàòåëè!!!!!
|
||||||
|
//fuck gamemaker i want its creators to be burned in hell!!!!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
num3 += num2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReadString(int _offsName, byte[] _buffer)
|
||||||
|
{
|
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, _offsName);
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
int num = 0;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
byte b = Marshal.ReadByte(ptr, num);
|
||||||
|
if (b == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
stringBuilder.Append((char)b);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string TypeToString(object _o, byte[] _buffer, int _offset)
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, _offset);
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
Type type = _o.GetType();
|
||||||
|
FieldInfo[] fields = type.GetFields();
|
||||||
|
FieldInfo[] array = fields;
|
||||||
|
foreach (FieldInfo fieldInfo in array)
|
||||||
|
{
|
||||||
|
object obj = null;
|
||||||
|
object[] customAttributes = fieldInfo.GetCustomAttributes(false);
|
||||||
|
foreach (object obj2 in customAttributes)
|
||||||
|
{
|
||||||
|
if (obj2 != null)
|
||||||
|
{
|
||||||
|
obj = obj2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendFormat("{0} : {1}", fieldInfo.Name, fieldInfo.GetValue(_o));
|
||||||
|
}
|
||||||
|
else if (obj is YYStringOffsetAttribute)
|
||||||
|
{
|
||||||
|
string arg = ReadString((int)fieldInfo.GetValue(_o), _buffer);
|
||||||
|
stringBuilder.AppendFormat("{0} : {1}", fieldInfo.Name, arg);
|
||||||
|
}
|
||||||
|
else if (obj is YYOffsetToAttribute)
|
||||||
|
{
|
||||||
|
YYOffsetToAttribute yYOffsetToAttribute = obj as YYOffsetToAttribute;
|
||||||
|
int num2 = (int)fieldInfo.GetValue(_o);
|
||||||
|
IntPtr ptr2 = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, num2);
|
||||||
|
object o = Marshal.PtrToStructure(ptr2, yYOffsetToAttribute.ArrayType);
|
||||||
|
stringBuilder.Append("{ ");
|
||||||
|
stringBuilder.Append(TypeToString(o, _buffer, num2));
|
||||||
|
stringBuilder.Append(" },");
|
||||||
|
}
|
||||||
|
else if (obj is YYArrayCountAttribute)
|
||||||
|
{
|
||||||
|
YYArrayCountAttribute yYArrayCountAttribute = obj as YYArrayCountAttribute;
|
||||||
|
stringBuilder.Append("[ ");
|
||||||
|
int num3 = (int)fieldInfo.GetValue(_o);
|
||||||
|
int num4 = Marshal.OffsetOf(type, fieldInfo.Name).ToInt32();
|
||||||
|
for (int k = 0; k < num3; k++)
|
||||||
|
{
|
||||||
|
int num5 = Marshal.ReadInt32(ptr, num + num4 + 4 + k * 4);
|
||||||
|
IntPtr ptr3 = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, num5);
|
||||||
|
object o2 = Marshal.PtrToStructure(ptr3, yYArrayCountAttribute.ArrayType);
|
||||||
|
stringBuilder.Append("{ ");
|
||||||
|
stringBuilder.Append(TypeToString(o2, _buffer, num5));
|
||||||
|
stringBuilder.Append(" },");
|
||||||
|
}
|
||||||
|
stringBuilder.Append(" ],");
|
||||||
|
}
|
||||||
|
else if (obj is YYFixedArrayCountAttribute)
|
||||||
|
{
|
||||||
|
YYFixedArrayCountAttribute yYFixedArrayCountAttribute = obj as YYFixedArrayCountAttribute;
|
||||||
|
stringBuilder.Append("[ ");
|
||||||
|
int num6 = (int)fieldInfo.GetValue(_o);
|
||||||
|
int num7 = Marshal.OffsetOf(type, fieldInfo.Name).ToInt32();
|
||||||
|
int num8 = Marshal.SizeOf(yYFixedArrayCountAttribute.ArrayType);
|
||||||
|
for (int l = 0; l < num6; l++)
|
||||||
|
{
|
||||||
|
int num9 = _offset + num + num7 + 4 + l * num8;
|
||||||
|
IntPtr ptr4 = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, num9);
|
||||||
|
object o3 = Marshal.PtrToStructure(ptr4, yYFixedArrayCountAttribute.ArrayType);
|
||||||
|
stringBuilder.Append("{ ");
|
||||||
|
stringBuilder.Append(TypeToString(o3, _buffer, num9));
|
||||||
|
stringBuilder.Append(" },");
|
||||||
|
}
|
||||||
|
stringBuilder.Append("]");
|
||||||
|
}
|
||||||
|
stringBuilder.AppendFormat(", ");
|
||||||
|
}
|
||||||
|
return stringBuilder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<KeyValuePair<string, G>> Load<G, Y>(string _chunk, int _sz, byte[] _buffer, int _offset)
|
||||||
|
{
|
||||||
|
List<KeyValuePair<string, G>> result = new List<KeyValuePair<string, G>>();
|
||||||
|
int num = _buffer[_offset] + (_buffer[_offset + 1] << 8) + (_buffer[_offset + 2] << 16) + (_buffer[_offset + 3] << 24);
|
||||||
|
_offset += 4;
|
||||||
|
while (num > 0)
|
||||||
|
{
|
||||||
|
int num2 = _buffer[_offset] + (_buffer[_offset + 1] << 8) + (_buffer[_offset + 2] << 16) + (_buffer[_offset + 3] << 24);
|
||||||
|
if (num2 != 0)
|
||||||
|
{
|
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, num2);
|
||||||
|
Y val = (Y)Marshal.PtrToStructure(ptr, typeof(Y));
|
||||||
|
Console.WriteLine("{0}", TypeToString(val, _buffer, num2));
|
||||||
|
}
|
||||||
|
num--;
|
||||||
|
_offset += 4;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GMOptions LoadOptions(string _chunk, int _sz, byte[] _buffer, int _offset)
|
||||||
|
{
|
||||||
|
GMOptions result = null;
|
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, _offset);
|
||||||
|
YYOptions yYOptions = (YYOptions)Marshal.PtrToStructure(ptr, typeof(YYOptions));
|
||||||
|
Console.WriteLine("{0}", TypeToString(yYOptions, _buffer, _offset));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LoadGeneral(string _chunk, int _sz, byte[] _buffer, int _offset)
|
||||||
|
{
|
||||||
|
IntPtr ptr = Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, _offset);
|
||||||
|
YYHeader yYHeader = (YYHeader)Marshal.PtrToStructure(ptr, typeof(YYHeader));
|
||||||
|
Console.WriteLine("{0}", TypeToString(yYHeader, _buffer, _offset));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,42 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class PropertyAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Category
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Default
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Disabled
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyAttribute(string _description)
|
||||||
|
{
|
||||||
|
Description = _description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class Squish
|
||||||
|
{
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_GetCPUCaps")]
|
||||||
|
public static extern eSquishCPU GetCPUCaps();
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_Compress")]
|
||||||
|
public static extern void Compress(IntPtr rgba, IntPtr block, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_CompressMasked")]
|
||||||
|
public static extern void CompressMasked(IntPtr rgba, int mask, IntPtr block, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_Decompress")]
|
||||||
|
public static extern void Decompress(IntPtr rgba, IntPtr block, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_GetStorageRequirements")]
|
||||||
|
public static extern int GetStorageRequirements(int width, int height, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_CompressImage")]
|
||||||
|
public static extern void CompressImage(IntPtr rgba, int width, int height, IntPtr blocks, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_DecompressImage")]
|
||||||
|
public static extern void DecompressImage(IntPtr rgba, int width, int height, IntPtr blocks, eSquishFlags flags);
|
||||||
|
|
||||||
|
[DllImport("squish.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "Squish_CompressPVRTC")]
|
||||||
|
public static extern void CompressPVRTC(IntPtr rgba, int width, int height, IntPtr pTempName, int flags);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,273 @@
|
||||||
|
using Ionic.Zlib;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public static class StreamHelper
|
||||||
|
{
|
||||||
|
public static short ReadShort(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadByte();
|
||||||
|
int num2 = _s.ReadByte();
|
||||||
|
return (short)(num | (num2 << 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ReadInteger(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadByte();
|
||||||
|
int num2 = _s.ReadByte();
|
||||||
|
int num3 = _s.ReadByte();
|
||||||
|
int num4 = _s.ReadByte();
|
||||||
|
return num | (num2 << 8) | (num3 << 16) | (num4 << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long ReadLong(this Stream _s)
|
||||||
|
{
|
||||||
|
long num = _s.ReadInteger();
|
||||||
|
long num2 = _s.ReadInteger();
|
||||||
|
return num | (num2 << 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ReadBoolean(this Stream _s)
|
||||||
|
{
|
||||||
|
return _s.ReadInteger() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadString(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
byte[] array = new byte[num];
|
||||||
|
int num2 = 0;
|
||||||
|
while (num > 0)
|
||||||
|
{
|
||||||
|
array[num2] = (byte)_s.ReadByte();
|
||||||
|
num--;
|
||||||
|
num2++;
|
||||||
|
}
|
||||||
|
return Encoding.UTF8.GetString(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image ReadBitmap(this Stream _s)
|
||||||
|
{
|
||||||
|
Image result = null;
|
||||||
|
if (_s.ReadBoolean())
|
||||||
|
{
|
||||||
|
byte[] buffer = _s.ReadCompressedStream();
|
||||||
|
MemoryStream stream = new MemoryStream(buffer);
|
||||||
|
result = Image.FromStream(stream);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Guid ReadGuid(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = Marshal.SizeOf(typeof(Guid));
|
||||||
|
byte[] array = new byte[num];
|
||||||
|
_s.Read(array, 0, num);
|
||||||
|
return new Guid(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ReadCompressedStream(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
byte[] result = null;
|
||||||
|
if (num >= 0)
|
||||||
|
{
|
||||||
|
byte[] array = new byte[num];
|
||||||
|
_s.Read(array, 0, num);
|
||||||
|
result = ZlibStream.UncompressBuffer(array);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream ReadStreamC(this Stream _s)
|
||||||
|
{
|
||||||
|
return new MemoryStream(_s.ReadCompressedStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Stream ReadStreamE(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
int num2 = _s.ReadInteger();
|
||||||
|
for (int i = 1; i <= num; i++)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
byte[] array = new byte[256];
|
||||||
|
_s.Read(array, 0, 256);
|
||||||
|
for (int j = 1; j <= num2; j++)
|
||||||
|
{
|
||||||
|
_s.ReadInteger();
|
||||||
|
}
|
||||||
|
byte[] array2 = new byte[256];
|
||||||
|
for (int k = 0; k < 256; k++)
|
||||||
|
{
|
||||||
|
array2[array[k]] = (byte)k;
|
||||||
|
}
|
||||||
|
int num3 = _s.ReadInteger();
|
||||||
|
byte[] array3 = new byte[num3];
|
||||||
|
_s.Read(array3, 0, num3);
|
||||||
|
for (int num4 = num3 - 1; num4 >= 1; num4--)
|
||||||
|
{
|
||||||
|
int num5 = (array2[array3[num4]] - array3[num4 - 1] - num4) % 256;
|
||||||
|
if (num5 < 0)
|
||||||
|
{
|
||||||
|
num5 += 256;
|
||||||
|
}
|
||||||
|
array3[num4] = (byte)num5;
|
||||||
|
}
|
||||||
|
for (int num6 = num3 - 1; num6 >= 0; num6--)
|
||||||
|
{
|
||||||
|
int num7 = Math.Max(0, num6 - array[num6 % 256]);
|
||||||
|
byte b = array3[num6];
|
||||||
|
array3[num6] = array3[num7];
|
||||||
|
array3[num7] = b;
|
||||||
|
}
|
||||||
|
return new MemoryStream(array3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ReadStream(this Stream _s)
|
||||||
|
{
|
||||||
|
int num = _s.ReadInteger();
|
||||||
|
byte[] array = null;
|
||||||
|
if (num > 0)
|
||||||
|
{
|
||||||
|
array = new byte[num];
|
||||||
|
_s.Read(array, 0, num);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float ReadSingle(this Stream _s)
|
||||||
|
{
|
||||||
|
return BitConverter.ToSingle(new byte[4]
|
||||||
|
{
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte()
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double ReadDouble(this Stream _s)
|
||||||
|
{
|
||||||
|
return BitConverter.ToDouble(new byte[8]
|
||||||
|
{
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte(),
|
||||||
|
(byte)_s.ReadByte()
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteInteger(this Stream _s, int _i)
|
||||||
|
{
|
||||||
|
_s.WriteByte((byte)(_i & 0xFF));
|
||||||
|
_s.WriteByte((byte)((_i >> 8) & 0xFF));
|
||||||
|
_s.WriteByte((byte)((_i >> 16) & 0xFF));
|
||||||
|
_s.WriteByte((byte)((_i >> 24) & 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteShort(this Stream _s, short _i)
|
||||||
|
{
|
||||||
|
_s.WriteByte((byte)(_i & 0xFF));
|
||||||
|
_s.WriteByte((byte)((_i >> 8) & 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteGUID(this Stream _s, Guid _g)
|
||||||
|
{
|
||||||
|
byte[] array = _g.ToByteArray();
|
||||||
|
byte[] array2 = array;
|
||||||
|
foreach (byte value in array2)
|
||||||
|
{
|
||||||
|
_s.WriteByte(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLong(this Stream _s, long _l)
|
||||||
|
{
|
||||||
|
_s.WriteInteger((int)(_l & uint.MaxValue));
|
||||||
|
_s.WriteInteger((int)(_l >> 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteBoolean(this Stream _s, bool _b)
|
||||||
|
{
|
||||||
|
_s.WriteInteger(_b ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteChunk(this Stream _s, string _chunkName)
|
||||||
|
{
|
||||||
|
byte value = (byte)((_chunkName.Length > 0) ? _chunkName[0] : ' ');
|
||||||
|
byte value2 = (byte)((_chunkName.Length > 1) ? _chunkName[1] : ' ');
|
||||||
|
byte value3 = (byte)((_chunkName.Length > 2) ? _chunkName[2] : ' ');
|
||||||
|
byte value4 = (byte)((_chunkName.Length > 3) ? _chunkName[3] : ' ');
|
||||||
|
_s.WriteByte(value);
|
||||||
|
_s.WriteByte(value2);
|
||||||
|
_s.WriteByte(value3);
|
||||||
|
_s.WriteByte(value4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long WriteChunkSize(this Stream _s)
|
||||||
|
{
|
||||||
|
long position = _s.Position;
|
||||||
|
_s.WriteInteger(0);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PatchChunkSize(this Stream _s, long _patchSite)
|
||||||
|
{
|
||||||
|
long position = _s.Position;
|
||||||
|
_s.Seek(_patchSite, SeekOrigin.Begin);
|
||||||
|
_s.WriteInteger((int)(position - _patchSite - 4));
|
||||||
|
_s.Seek(position, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PatchOffset(this Stream _s, long _patchSite)
|
||||||
|
{
|
||||||
|
long position = _s.Position;
|
||||||
|
_s.Seek(_patchSite, SeekOrigin.Begin);
|
||||||
|
_s.WriteInteger((int)position);
|
||||||
|
_s.Seek(position, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteString(this Stream _s, string _str)
|
||||||
|
{
|
||||||
|
byte[] bytes = Encoding.UTF8.GetBytes(_str);
|
||||||
|
_s.WriteInteger(bytes.Length);
|
||||||
|
for (int i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
_s.WriteByte(bytes[i]);
|
||||||
|
}
|
||||||
|
_s.WriteByte(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteDouble(this Stream _s, double db)
|
||||||
|
{
|
||||||
|
long l = BitConverter.DoubleToInt64Bits(db);
|
||||||
|
_s.WriteLong(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteSingle(this Stream _s, float ft)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(ft);
|
||||||
|
_s.Write(bytes, 0, bytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Align(this Stream _s, int _align)
|
||||||
|
{
|
||||||
|
int num = _align - 1;
|
||||||
|
while ((_s.Position & num) != 0)
|
||||||
|
{
|
||||||
|
_s.WriteByte(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,381 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class Texture
|
||||||
|
{
|
||||||
|
public yyRect TextureRects;
|
||||||
|
|
||||||
|
public Bitmap Bitmap
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GridSizeX
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GridSizeY
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AreaFree
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TP
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Group
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TexturePageEntry> Entries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture(int _width, int _height, int _gridX, int _gridY, int _marginX, int _marginY)
|
||||||
|
{
|
||||||
|
GridSizeX = _gridX;
|
||||||
|
GridSizeY = _gridY;
|
||||||
|
AreaFree = _width * _height;
|
||||||
|
Entries = new List<TexturePageEntry>();
|
||||||
|
Resize(_width, _height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resize(int width, int height)
|
||||||
|
{
|
||||||
|
AreaFree = width * height;
|
||||||
|
Bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||||
|
using (Graphics graphics = Graphics.FromImage(Bitmap))
|
||||||
|
{
|
||||||
|
graphics.Clear(Color.FromArgb(0));
|
||||||
|
}
|
||||||
|
TextureRects = yyRect.Create(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap ResizeImage(Bitmap _source, int _destWidth, int _destHeight)
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new Bitmap(_destWidth, _destHeight);
|
||||||
|
Graphics graphics = Graphics.FromImage(bitmap);
|
||||||
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
graphics.DrawImage(_source, 0, 0, _destWidth, _destHeight);
|
||||||
|
graphics.Dispose();
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Alloc(TexturePageEntry _entry, out int _X, out int _Y)
|
||||||
|
{
|
||||||
|
bool flag = false;
|
||||||
|
bool flag2 = false;
|
||||||
|
_X = -1;
|
||||||
|
_Y = -1;
|
||||||
|
int num = GridSizeX;
|
||||||
|
int num2 = GridSizeY;
|
||||||
|
int num3 = _entry.W;
|
||||||
|
int num4 = _entry.H;
|
||||||
|
if (_entry.OriginalRepeatBorder)
|
||||||
|
{
|
||||||
|
num += _entry.RepeatX;
|
||||||
|
num2 += _entry.RepeatY;
|
||||||
|
}
|
||||||
|
if (num3 < Bitmap.Width)
|
||||||
|
{
|
||||||
|
num3 += num;
|
||||||
|
num3 += num;
|
||||||
|
num3 = ((num3 + 3) & -4);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (num4 < Bitmap.Height)
|
||||||
|
{
|
||||||
|
num4 += num2;
|
||||||
|
num4 += num2;
|
||||||
|
num4 = ((num4 + 3) & -4);
|
||||||
|
flag2 = true;
|
||||||
|
}
|
||||||
|
_entry.RepeatBorder = _entry.OriginalRepeatBorder;
|
||||||
|
if (!flag || !flag2)
|
||||||
|
{
|
||||||
|
_entry.RepeatBorder = false;
|
||||||
|
}
|
||||||
|
yyRect yyRect = TextureRects.Test(num3, num4);
|
||||||
|
if (yyRect != null)
|
||||||
|
{
|
||||||
|
Point point = TextureRects.AddImage(yyRect, num3, num4);
|
||||||
|
_X = point.X;
|
||||||
|
_Y = point.Y;
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
_X += num;
|
||||||
|
}
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
_Y += num2;
|
||||||
|
}
|
||||||
|
AreaFree -= num3 * num4;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyEntries()
|
||||||
|
{
|
||||||
|
Rectangle rect = new Rectangle(0, 0, Bitmap.Width, Bitmap.Height);
|
||||||
|
BitmapData bitmapData = Bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
foreach (TexturePageEntry entry in Entries)
|
||||||
|
{
|
||||||
|
Rectangle rect2 = new Rectangle(0, 0, entry.W, entry.H);
|
||||||
|
BitmapData bitmapData2 = entry.Bitmap.LockBits(rect2, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
IntPtr intPtr = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
IntPtr intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + entry.Y * bitmapData.Stride + entry.X * 4);
|
||||||
|
int num = 0;
|
||||||
|
while (num < entry.Bitmap.Height)
|
||||||
|
{
|
||||||
|
IntPtr ptr = intPtr;
|
||||||
|
IntPtr ptr2 = intPtr2;
|
||||||
|
int num2 = 0;
|
||||||
|
while (num2 < entry.Bitmap.Width)
|
||||||
|
{
|
||||||
|
int val = Marshal.ReadInt32(ptr);
|
||||||
|
Marshal.WriteInt32(ptr2, val);
|
||||||
|
num2++;
|
||||||
|
ptr2 = new IntPtr(ptr2.ToInt64() + 4);
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
if (entry.RepeatBorder && !entry.IgnoreRepeatBorder)
|
||||||
|
{
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H) * bitmapData.Stride + entry.X * 4);
|
||||||
|
int num3 = 0;
|
||||||
|
while (num3 < entry.RepeatY)
|
||||||
|
{
|
||||||
|
IntPtr ptr3 = intPtr;
|
||||||
|
IntPtr ptr4 = intPtr2;
|
||||||
|
int num4 = 0;
|
||||||
|
while (num4 < entry.Bitmap.Width)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr4, Marshal.ReadInt32(ptr3));
|
||||||
|
num4++;
|
||||||
|
ptr4 = new IntPtr(ptr4.ToInt64() + 4);
|
||||||
|
ptr3 = new IntPtr(ptr3.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num3++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64() + (entry.H - entry.RepeatY) * bitmapData2.Stride);
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - entry.RepeatY) * bitmapData.Stride + entry.X * 4);
|
||||||
|
int num5 = 0;
|
||||||
|
while (num5 < entry.RepeatY)
|
||||||
|
{
|
||||||
|
IntPtr ptr5 = intPtr;
|
||||||
|
IntPtr ptr6 = intPtr2;
|
||||||
|
int num6 = 0;
|
||||||
|
while (num6 < entry.Bitmap.Width)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr6, Marshal.ReadInt32(ptr5));
|
||||||
|
num6++;
|
||||||
|
ptr6 = new IntPtr(ptr6.ToInt64() + 4);
|
||||||
|
ptr5 = new IntPtr(ptr5.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num5++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + entry.Y * bitmapData.Stride + (entry.X - entry.RepeatX) * 4);
|
||||||
|
int num7 = 0;
|
||||||
|
while (num7 < entry.Bitmap.Height)
|
||||||
|
{
|
||||||
|
IntPtr ptr7 = intPtr;
|
||||||
|
IntPtr ptr8 = intPtr2;
|
||||||
|
int num8 = 0;
|
||||||
|
while (num8 < entry.RepeatX)
|
||||||
|
{
|
||||||
|
IntPtr ptr9 = new IntPtr(ptr7.ToInt64() + (entry.W - entry.RepeatX) * 4);
|
||||||
|
IntPtr ptr10 = new IntPtr(ptr8.ToInt64() + (entry.W + entry.RepeatX) * 4);
|
||||||
|
Marshal.WriteInt32(ptr8, Marshal.ReadInt32(ptr9));
|
||||||
|
Marshal.WriteInt32(ptr10, Marshal.ReadInt32(ptr7));
|
||||||
|
num8++;
|
||||||
|
ptr8 = new IntPtr(ptr8.ToInt64() + 4);
|
||||||
|
ptr7 = new IntPtr(ptr7.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num7++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < entry.RepeatY; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < entry.RepeatX; j++)
|
||||||
|
{
|
||||||
|
IntPtr ptr11 = new IntPtr(bitmapData2.Scan0.ToInt64() + i * bitmapData2.Stride + j * 4);
|
||||||
|
IntPtr ptr12 = new IntPtr(bitmapData2.Scan0.ToInt64() + (entry.H - (i + 1)) * bitmapData2.Stride + j * 4);
|
||||||
|
IntPtr ptr13 = new IntPtr(ptr11.ToInt64() + (entry.W - (j + 1)) * 4);
|
||||||
|
IntPtr ptr14 = new IntPtr(ptr12.ToInt64() + (entry.W - (j + 1)) * 4);
|
||||||
|
IntPtr ptr15 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - (i + 1)) * bitmapData.Stride + (entry.X - (j + 1)) * 4);
|
||||||
|
IntPtr ptr16 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H + i) * bitmapData.Stride + (entry.X - (j + 1)) * 4);
|
||||||
|
IntPtr ptr17 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - (i + 1)) * bitmapData.Stride + (entry.X + entry.W + j) * 4);
|
||||||
|
IntPtr ptr18 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H + i) * bitmapData.Stride + (entry.X + entry.W + j) * 4);
|
||||||
|
Marshal.WriteInt32(ptr15, Marshal.ReadInt32(ptr14));
|
||||||
|
Marshal.WriteInt32(ptr18, Marshal.ReadInt32(ptr11));
|
||||||
|
Marshal.WriteInt32(ptr17, Marshal.ReadInt32(ptr12));
|
||||||
|
Marshal.WriteInt32(ptr16, Marshal.ReadInt32(ptr13));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (entry.Y != 0)
|
||||||
|
{
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - 1) * bitmapData.Stride + entry.X * 4);
|
||||||
|
int num9 = 0;
|
||||||
|
while (num9 < GridSizeY)
|
||||||
|
{
|
||||||
|
IntPtr ptr19 = intPtr;
|
||||||
|
IntPtr ptr20 = intPtr2;
|
||||||
|
int num10 = 0;
|
||||||
|
while (num10 < entry.Bitmap.Width)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr20, Marshal.ReadInt32(ptr19));
|
||||||
|
num10++;
|
||||||
|
ptr20 = new IntPtr(ptr20.ToInt64() + 4);
|
||||||
|
ptr19 = new IntPtr(ptr19.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num9++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() - bitmapData.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.Y + entry.H != Bitmap.Height)
|
||||||
|
{
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64() + (entry.H - 1) * bitmapData2.Stride);
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H) * bitmapData.Stride + entry.X * 4);
|
||||||
|
int num11 = 0;
|
||||||
|
while (num11 < GridSizeY)
|
||||||
|
{
|
||||||
|
IntPtr ptr21 = intPtr;
|
||||||
|
IntPtr ptr22 = intPtr2;
|
||||||
|
int num12 = 0;
|
||||||
|
while (num12 < entry.Bitmap.Width)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr22, Marshal.ReadInt32(ptr21));
|
||||||
|
num12++;
|
||||||
|
ptr22 = new IntPtr(ptr22.ToInt64() + 4);
|
||||||
|
ptr21 = new IntPtr(ptr21.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num11++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.X != 0)
|
||||||
|
{
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + entry.Y * bitmapData.Stride + (entry.X - 1) * 4);
|
||||||
|
int num13 = 0;
|
||||||
|
while (num13 < entry.Bitmap.Height)
|
||||||
|
{
|
||||||
|
IntPtr ptr23 = intPtr;
|
||||||
|
IntPtr ptr24 = intPtr2;
|
||||||
|
int num14 = 0;
|
||||||
|
while (num14 < GridSizeX)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr24, Marshal.ReadInt32(ptr23));
|
||||||
|
num14++;
|
||||||
|
ptr24 = new IntPtr(ptr24.ToInt64() - 4);
|
||||||
|
}
|
||||||
|
num13++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.X + entry.W != Bitmap.Width)
|
||||||
|
{
|
||||||
|
intPtr = new IntPtr(bitmapData2.Scan0.ToInt64() + (entry.W - 1) * 4);
|
||||||
|
intPtr2 = new IntPtr(bitmapData.Scan0.ToInt64() + entry.Y * bitmapData.Stride + (entry.X + entry.W) * 4);
|
||||||
|
int num15 = 0;
|
||||||
|
while (num15 < entry.Bitmap.Height)
|
||||||
|
{
|
||||||
|
IntPtr ptr25 = intPtr;
|
||||||
|
IntPtr ptr26 = intPtr2;
|
||||||
|
int num16 = 0;
|
||||||
|
while (num16 < GridSizeX)
|
||||||
|
{
|
||||||
|
Marshal.WriteInt32(ptr26, Marshal.ReadInt32(ptr25));
|
||||||
|
num16++;
|
||||||
|
ptr26 = new IntPtr(ptr26.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num15++;
|
||||||
|
intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData.Stride);
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + bitmapData2.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IntPtr ptr27 = new IntPtr(bitmapData2.Scan0.ToInt64());
|
||||||
|
IntPtr ptr28 = new IntPtr(bitmapData2.Scan0.ToInt64() + (entry.H - 1) * bitmapData2.Stride);
|
||||||
|
IntPtr ptr29 = new IntPtr(ptr27.ToInt64() + (entry.W - 1) * 4);
|
||||||
|
IntPtr ptr30 = new IntPtr(ptr28.ToInt64() + (entry.W - 1) * 4);
|
||||||
|
int val2 = Marshal.ReadInt32(ptr30);
|
||||||
|
int val3 = Marshal.ReadInt32(ptr29);
|
||||||
|
int val4 = Marshal.ReadInt32(ptr28);
|
||||||
|
int val5 = Marshal.ReadInt32(ptr27);
|
||||||
|
for (int k = 0; k < GridSizeY; k++)
|
||||||
|
{
|
||||||
|
for (int l = 0; l < GridSizeX; l++)
|
||||||
|
{
|
||||||
|
if (entry.Y != 0)
|
||||||
|
{
|
||||||
|
if (entry.X != 0)
|
||||||
|
{
|
||||||
|
IntPtr ptr31 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - (k + 1)) * bitmapData.Stride + (entry.X - (l + 1)) * 4);
|
||||||
|
Marshal.WriteInt32(ptr31, val5);
|
||||||
|
}
|
||||||
|
if (entry.X + entry.W != Bitmap.Width)
|
||||||
|
{
|
||||||
|
IntPtr ptr32 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y - (k + 1)) * bitmapData.Stride + (entry.X + entry.W + l) * 4);
|
||||||
|
Marshal.WriteInt32(ptr32, val3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.Y + entry.H != Bitmap.Height)
|
||||||
|
{
|
||||||
|
if (entry.X != 0)
|
||||||
|
{
|
||||||
|
IntPtr ptr33 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H + k) * bitmapData.Stride + (entry.X - (l + 1)) * 4);
|
||||||
|
Marshal.WriteInt32(ptr33, val4);
|
||||||
|
}
|
||||||
|
if (entry.X + entry.W != Bitmap.Width)
|
||||||
|
{
|
||||||
|
IntPtr ptr34 = new IntPtr(bitmapData.Scan0.ToInt64() + (entry.Y + entry.H + k) * bitmapData.Stride + (entry.X + entry.W + l) * 4);
|
||||||
|
Marshal.WriteInt32(ptr34, val2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.Bitmap.UnlockBits(bitmapData2);
|
||||||
|
}
|
||||||
|
Bitmap.UnlockBits(bitmapData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,386 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class TexturePage
|
||||||
|
{
|
||||||
|
public List<TexturePageEntry> Entries
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Texture> Textures
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
IEnumerable<Texture> enumerable = null;
|
||||||
|
foreach (KeyValuePair<string, List<Texture>> textureGroup in TextureGroups)
|
||||||
|
{
|
||||||
|
enumerable = ((enumerable != null) ? enumerable.Concat(textureGroup.Value) : textureGroup.Value);
|
||||||
|
}
|
||||||
|
return enumerable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, List<Texture>> TextureGroups
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GroupName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MarginX
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MarginY
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GapX
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GapY
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TextureSizeWidth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TextureSizeHeight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
Entries.Clear();
|
||||||
|
TextureGroups.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturePage(int _gapX, int _gapY, int _marginX, int _marginY, int _width, int _height)
|
||||||
|
{
|
||||||
|
GapX = _gapX;
|
||||||
|
GapY = _gapY;
|
||||||
|
MarginX = _marginX;
|
||||||
|
MarginY = _marginY;
|
||||||
|
TextureSizeWidth = _width;
|
||||||
|
TextureSizeHeight = _height;
|
||||||
|
GroupName = string.Empty;
|
||||||
|
Entries = new List<TexturePageEntry>();
|
||||||
|
TextureGroups = new Dictionary<string, List<Texture>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeginGroup(string _resourceName)
|
||||||
|
{
|
||||||
|
string groupName = string.Empty;
|
||||||
|
foreach (KeyValuePair<string, List<string>> textureGroup in Program.TextureGroups)
|
||||||
|
{
|
||||||
|
if (textureGroup.Value.Contains(_resourceName))
|
||||||
|
{
|
||||||
|
groupName = textureGroup.Key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GroupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EndGroup()
|
||||||
|
{
|
||||||
|
GroupName = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bitmap Scale(Bitmap Bitmap, int scaleWidth, int scaleHeight)
|
||||||
|
{
|
||||||
|
Bitmap image = new Bitmap(Bitmap.Width * 3, Bitmap.Height * 3);
|
||||||
|
using (Graphics graphics = Graphics.FromImage(image))
|
||||||
|
{
|
||||||
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
graphics.DrawImage(Bitmap, 0, 0);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width, 0);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width * 2, 0);
|
||||||
|
graphics.DrawImage(Bitmap, 0, Bitmap.Height);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width, Bitmap.Height);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width * 2, Bitmap.Height);
|
||||||
|
graphics.DrawImage(Bitmap, 0, Bitmap.Height * 2);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width, Bitmap.Height * 2);
|
||||||
|
graphics.DrawImage(Bitmap, Bitmap.Width * 2, Bitmap.Height * 2);
|
||||||
|
}
|
||||||
|
Bitmap bitmap = new Bitmap(scaleWidth, scaleHeight);
|
||||||
|
using (Graphics graphics2 = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
graphics2.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
graphics2.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
graphics2.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
graphics2.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
graphics2.DrawImage(image, new Rectangle(0, 0, scaleWidth, scaleHeight), new Rectangle(Bitmap.Width, Bitmap.Height, Bitmap.Width, Bitmap.Height), GraphicsUnit.Pixel);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe Bitmap RemoveSpace(Bitmap _image, out int _XOffset, out int _YOffset, out int _CropWidth, out int _CropHeight)
|
||||||
|
{
|
||||||
|
int width = _image.Width;
|
||||||
|
int height = _image.Height;
|
||||||
|
_XOffset = 0;
|
||||||
|
_YOffset = 0;
|
||||||
|
_CropWidth = width;
|
||||||
|
_CropHeight = height;
|
||||||
|
BitmapData bitmapData = _image.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
uint* ptr = (uint*)bitmapData.Scan0.ToPointer();
|
||||||
|
int num = width;
|
||||||
|
int num2 = height;
|
||||||
|
int num3 = 0;
|
||||||
|
int num4 = 0;
|
||||||
|
for (int i = 0; i < height; i++)
|
||||||
|
{
|
||||||
|
uint* ptr2 = (uint*)((long)ptr + i * bitmapData.Stride);
|
||||||
|
for (int j = 0; j < width; j++)
|
||||||
|
{
|
||||||
|
if (((int)(*ptr2) & -16777216) != 0)
|
||||||
|
{
|
||||||
|
if (j < num)
|
||||||
|
{
|
||||||
|
num = j;
|
||||||
|
}
|
||||||
|
if (i < num2)
|
||||||
|
{
|
||||||
|
num2 = i;
|
||||||
|
}
|
||||||
|
if (j > num3)
|
||||||
|
{
|
||||||
|
num3 = j;
|
||||||
|
}
|
||||||
|
if (i > num4)
|
||||||
|
{
|
||||||
|
num4 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_image.UnlockBits(bitmapData);
|
||||||
|
if (num == width && num2 == height)
|
||||||
|
{
|
||||||
|
_XOffset = 0;
|
||||||
|
_YOffset = 0;
|
||||||
|
_CropWidth = width;
|
||||||
|
_CropHeight = height;
|
||||||
|
return _image;
|
||||||
|
}
|
||||||
|
if (num != 0 || num2 != 0 || num3 != width - 1 || num4 != height - 1)
|
||||||
|
{
|
||||||
|
_XOffset = num;
|
||||||
|
_YOffset = num2;
|
||||||
|
_CropWidth = num3 - _XOffset + 1;
|
||||||
|
_CropHeight = num4 - _YOffset + 1;
|
||||||
|
int width2 = num3 - num + 1;
|
||||||
|
int height2 = num4 - num2 + 1;
|
||||||
|
Bitmap bitmap = new Bitmap(width2, height2);
|
||||||
|
using (Graphics graphics = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
graphics.DrawImage(_image, -num, -num2);
|
||||||
|
_image = bitmap;
|
||||||
|
return _image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturePageEntry AddImage(Bitmap _image, bool _pack, bool _ignoreTextureScale)
|
||||||
|
{
|
||||||
|
int width = _image.Width;
|
||||||
|
int height = _image.Height;
|
||||||
|
int _XOffset = 0;
|
||||||
|
int _YOffset = 0;
|
||||||
|
int _CropWidth = width;
|
||||||
|
int _CropHeight = height;
|
||||||
|
if (_pack)
|
||||||
|
{
|
||||||
|
_image = RemoveSpace(_image, out _XOffset, out _YOffset, out _CropWidth, out _CropHeight);
|
||||||
|
}
|
||||||
|
if (!_ignoreTextureScale && Program.TextureScale > 1)
|
||||||
|
{
|
||||||
|
_image = Scale(_image, Math.Max(1, _image.Width / Program.TextureScale), Math.Max(1, _image.Height / Program.TextureScale));
|
||||||
|
}
|
||||||
|
if (_image.Width > TextureSizeWidth || _image.Height > TextureSizeHeight)
|
||||||
|
{
|
||||||
|
int num = _image.Width;
|
||||||
|
int num2 = _image.Height;
|
||||||
|
while (num > TextureSizeWidth || num2 > TextureSizeHeight)
|
||||||
|
{
|
||||||
|
num >>= 1;
|
||||||
|
num2 >>= 1;
|
||||||
|
}
|
||||||
|
_image = Scale(_image, num, num2);
|
||||||
|
}
|
||||||
|
TexturePageEntry texturePageEntry = null;
|
||||||
|
uint num3 = Loader.HashBitmap(_image);
|
||||||
|
foreach (TexturePageEntry entry in Entries)
|
||||||
|
{
|
||||||
|
if (entry.W == _image.Width && entry.H == _image.Height && entry.Hash == num3 && entry.Name == GroupName && entry.XOffset == _XOffset && entry.YOffset == _YOffset)
|
||||||
|
{
|
||||||
|
texturePageEntry = entry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (texturePageEntry == null)
|
||||||
|
{
|
||||||
|
texturePageEntry = ((!string.IsNullOrEmpty(GroupName)) ? new TexturePageEntry(_image, GroupName, num3) : new TexturePageEntry(_image, num3));
|
||||||
|
texturePageEntry.XOffset = _XOffset;
|
||||||
|
texturePageEntry.YOffset = _YOffset;
|
||||||
|
texturePageEntry.CropWidth = _CropWidth;
|
||||||
|
texturePageEntry.CropHeight = _CropHeight;
|
||||||
|
texturePageEntry.OW = width;
|
||||||
|
texturePageEntry.OH = height;
|
||||||
|
texturePageEntry.DebugTag = false;
|
||||||
|
Entries.Add(texturePageEntry);
|
||||||
|
}
|
||||||
|
return texturePageEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Compile()
|
||||||
|
{
|
||||||
|
IOrderedEnumerable<TexturePageEntry> orderedEnumerable = from e in Entries
|
||||||
|
orderby e.Name, e.HasAlpha, e.W * e.H descending
|
||||||
|
select e;
|
||||||
|
Entries = orderedEnumerable.ToList();
|
||||||
|
int num = -1;
|
||||||
|
foreach (TexturePageEntry item in orderedEnumerable)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
if (Program.DisplaySortedTextures)
|
||||||
|
{
|
||||||
|
Console.WriteLine("entry :: w={0} h={1} hasAlpha={2}", item.W, item.H, item.HasAlpha);
|
||||||
|
}
|
||||||
|
List<Texture> list = null;
|
||||||
|
int num2 = 0;
|
||||||
|
foreach (KeyValuePair<string, List<Texture>> textureGroup in TextureGroups)
|
||||||
|
{
|
||||||
|
if (item.Name == textureGroup.Key)
|
||||||
|
{
|
||||||
|
list = textureGroup.Value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
num2++;
|
||||||
|
}
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
list = new List<Texture>();
|
||||||
|
TextureGroups.Add(item.Name, list);
|
||||||
|
num2++;
|
||||||
|
}
|
||||||
|
int _X = 0;
|
||||||
|
int _Y = 0;
|
||||||
|
bool flag = false;
|
||||||
|
Texture texture = null;
|
||||||
|
foreach (Texture item2 in list)
|
||||||
|
{
|
||||||
|
flag = item2.Alloc(item, out _X, out _Y);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
texture = item2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag)
|
||||||
|
{
|
||||||
|
Texture texture2 = new Texture(TextureSizeWidth, TextureSizeHeight, GapX, GapY, MarginX, MarginY);
|
||||||
|
texture2.Group = 0;
|
||||||
|
list.Add(texture2);
|
||||||
|
texture2.Alloc(item, out _X, out _Y);
|
||||||
|
texture = texture2;
|
||||||
|
}
|
||||||
|
item.X = _X;
|
||||||
|
item.Y = _Y;
|
||||||
|
item.TP = texture;
|
||||||
|
texture.Entries.Add(item);
|
||||||
|
if (item.DebugTag)
|
||||||
|
{
|
||||||
|
item.DebugTag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (Texture texture3 in Textures)
|
||||||
|
{
|
||||||
|
int num3 = texture3.Bitmap.Width;
|
||||||
|
int num4 = texture3.Bitmap.Height;
|
||||||
|
int _X2 = 0;
|
||||||
|
int _Y2 = 0;
|
||||||
|
bool flag2 = true;
|
||||||
|
while (flag2)
|
||||||
|
{
|
||||||
|
int num5 = (num3 == num4) ? num3 : (num3 / 2);
|
||||||
|
int num6 = (num3 == num4) ? (num4 / 2) : num4;
|
||||||
|
texture3.Resize(num5, num6);
|
||||||
|
foreach (TexturePageEntry entry in texture3.Entries)
|
||||||
|
{
|
||||||
|
if (!texture3.Alloc(entry, out _X2, out _Y2))
|
||||||
|
{
|
||||||
|
flag2 = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
entry.X = _X2;
|
||||||
|
entry.Y = _Y2;
|
||||||
|
}
|
||||||
|
if (flag2)
|
||||||
|
{
|
||||||
|
num3 = num5;
|
||||||
|
num4 = num6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
num = -1;
|
||||||
|
texture3.Resize(num3, num4);
|
||||||
|
foreach (TexturePageEntry entry2 in texture3.Entries)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
if (texture3.Alloc(entry2, out _X2, out _Y2))
|
||||||
|
{
|
||||||
|
entry2.X = _X2;
|
||||||
|
entry2.Y = _Y2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("This should not happen #2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int num7 = 0;
|
||||||
|
foreach (Texture texture4 in Textures)
|
||||||
|
{
|
||||||
|
texture4.TP = num7;
|
||||||
|
texture4.CopyEntries();
|
||||||
|
num7++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,186 @@
|
||||||
|
using GMAssetCompiler.Output;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class TexturePageEntry
|
||||||
|
{
|
||||||
|
public static int ms_count;
|
||||||
|
|
||||||
|
public int Entry
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Hash
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bitmap Bitmap
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int X
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Y
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture TP
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int W
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int H
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int XOffset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int YOffset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CropWidth
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CropHeight
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int OW
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int OH
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DebugTag
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RepeatBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OriginalRepeatBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[TextureOption("Ignore the repeat border flag for backgrounds that ordinarily ensures that sampling works correctly for tiled backgrounds by repeating opposing edges")]
|
||||||
|
public bool IgnoreRepeatBorder
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RepeatY
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RepeatX
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasAlpha
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe TexturePageEntry(Bitmap _bmp, uint _hash)
|
||||||
|
{
|
||||||
|
Entry = ms_count++;
|
||||||
|
Bitmap = _bmp;
|
||||||
|
W = _bmp.Width;
|
||||||
|
H = _bmp.Height;
|
||||||
|
HasAlpha = true;
|
||||||
|
Hash = _hash;
|
||||||
|
Name = string.Empty;
|
||||||
|
if (!Program.SeparateOpaqueAndAlpha)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BitmapData bitmapData = _bmp.LockBits(new Rectangle(0, 0, _bmp.Width, _bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
|
uint* ptr = (uint*)bitmapData.Scan0.ToPointer();
|
||||||
|
uint* ptr2 = ptr;
|
||||||
|
uint num = (uint)((int)(*ptr2) & -16777216);
|
||||||
|
int num2 = 0;
|
||||||
|
for (int i = 0; i < _bmp.Height; i++)
|
||||||
|
{
|
||||||
|
uint* ptr3 = (uint*)((long)ptr + i * bitmapData.Stride);
|
||||||
|
int num3 = 0;
|
||||||
|
while (num3 < _bmp.Width)
|
||||||
|
{
|
||||||
|
if (((int)(*ptr3) & -16777216) != (int)num)
|
||||||
|
{
|
||||||
|
num2++;
|
||||||
|
}
|
||||||
|
num3++;
|
||||||
|
ptr3++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_bmp.UnlockBits(bitmapData);
|
||||||
|
HasAlpha = (num2 > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TexturePageEntry(Bitmap _image, string _name, uint _hash)
|
||||||
|
: this(_image, _hash)
|
||||||
|
{
|
||||||
|
Name = _name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class Trace
|
||||||
|
{
|
||||||
|
public static FileStream _storageFileStream;
|
||||||
|
|
||||||
|
public static StreamWriter _streamWriter;
|
||||||
|
|
||||||
|
public static string Filename
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Trace()
|
||||||
|
{
|
||||||
|
string executablePath = Application.ExecutablePath;
|
||||||
|
string directoryName = Path.GetDirectoryName(executablePath);
|
||||||
|
if (!Directory.Exists(directoryName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directoryName);
|
||||||
|
}
|
||||||
|
string[] files = Directory.GetFiles(directoryName, "*.gz");
|
||||||
|
TimeSpan t = new TimeSpan(30, 0, 0, 0, 0);
|
||||||
|
string[] array = files;
|
||||||
|
foreach (string text in array)
|
||||||
|
{
|
||||||
|
FileInfo fileInfo = new FileInfo(text);
|
||||||
|
if (TimeSpan.Compare(DateTime.Now.Subtract(fileInfo.CreationTime), t) > 0)
|
||||||
|
{
|
||||||
|
File.Delete(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Filename = Path.Combine(directoryName, "TraceGMA.log");
|
||||||
|
if (File.Exists(Filename))
|
||||||
|
{
|
||||||
|
FileInfo fileInfo2 = new FileInfo(Filename);
|
||||||
|
if (fileInfo2.Length > 204800)
|
||||||
|
{
|
||||||
|
string path = string.Format("trace-{0}.gz", DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss"));
|
||||||
|
using (FileStream fileStream2 = fileInfo2.OpenRead())
|
||||||
|
{
|
||||||
|
using (FileStream fileStream = new FileStream(Path.Combine(directoryName, path), FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (GZipStream gZipStream = new GZipStream(fileStream, CompressionMode.Compress))
|
||||||
|
{
|
||||||
|
byte[] array2 = new byte[2048];
|
||||||
|
bool flag = false;
|
||||||
|
while (!flag)
|
||||||
|
{
|
||||||
|
fileStream2.Position = 0L;
|
||||||
|
fileStream.Position = 0L;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int num2;
|
||||||
|
for (long num = 0L; num < fileInfo2.Length; num += num2)
|
||||||
|
{
|
||||||
|
num2 = fileStream2.Read(array2, 0, array2.Length);
|
||||||
|
gZipStream.Write(array2, 0, num2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
gZipStream.Close();
|
||||||
|
fileStream.Close();
|
||||||
|
fileStream2.Close();
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
File.Delete(Filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~Trace()
|
||||||
|
{
|
||||||
|
_storageFileStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(string message)
|
||||||
|
{
|
||||||
|
using (_storageFileStream = new FileStream(Filename, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (_streamWriter = new StreamWriter(_storageFileStream))
|
||||||
|
{
|
||||||
|
_streamWriter.AutoFlush = true;
|
||||||
|
_streamWriter.WriteLine(message);
|
||||||
|
_streamWriter.Flush();
|
||||||
|
bool isAttached = Debugger.IsAttached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(string message, params object[] _arguments)
|
||||||
|
{
|
||||||
|
using (_storageFileStream = new FileStream(Filename, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (_streamWriter = new StreamWriter(_storageFileStream))
|
||||||
|
{
|
||||||
|
_streamWriter.AutoFlush = true;
|
||||||
|
_streamWriter.WriteLine(message, _arguments);
|
||||||
|
_streamWriter.Flush();
|
||||||
|
bool isAttached = Debugger.IsAttached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,241 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class VAG
|
||||||
|
{
|
||||||
|
public const int NUM_SAMPLES_IN_VAG_PACKET = 28;
|
||||||
|
|
||||||
|
public const int NUM_BYTES_IN_VAG_PACKET = 16;
|
||||||
|
|
||||||
|
public const uint AUDIO_SAMP_BITS_MASK = 0u;
|
||||||
|
|
||||||
|
public const int AUDIO_SAMP_BITS_SHFT = 0;
|
||||||
|
|
||||||
|
public const uint AUDIO_SAMP_FMT_MASK = 0u;
|
||||||
|
|
||||||
|
public const uint AUDIO_FMT_VAG = 0u;
|
||||||
|
|
||||||
|
public const int AUDIO_SAMP_FMT_SHFT = 0;
|
||||||
|
|
||||||
|
public const int ERR_OK = 0;
|
||||||
|
|
||||||
|
private int nNumLoops;
|
||||||
|
|
||||||
|
private double[] adbSamples = new double[28];
|
||||||
|
|
||||||
|
private ushort[] awFourBit = new ushort[28];
|
||||||
|
|
||||||
|
private int predict_nr;
|
||||||
|
|
||||||
|
private int shift_factor;
|
||||||
|
|
||||||
|
private double pack_1;
|
||||||
|
|
||||||
|
private double pack_2;
|
||||||
|
|
||||||
|
private double _s_1;
|
||||||
|
|
||||||
|
private double _s_2;
|
||||||
|
|
||||||
|
private static double[] g_f_1 = new double[5]
|
||||||
|
{
|
||||||
|
0.0,
|
||||||
|
-0.9375,
|
||||||
|
-1.796875,
|
||||||
|
-1.53125,
|
||||||
|
-1.90625
|
||||||
|
};
|
||||||
|
|
||||||
|
private static double[] g_f_2 = new double[5]
|
||||||
|
{
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.8125,
|
||||||
|
55.0 / 64.0,
|
||||||
|
0.9375
|
||||||
|
};
|
||||||
|
|
||||||
|
public unsafe void memset(void* _pSrc, byte _fill, uint _size)
|
||||||
|
{
|
||||||
|
byte* ptr = (byte*)_pSrc;
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
*(ptr++) = _fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe int WavToVag(byte[] _pInBuff, uint _nInLen, uint _nInFormat, byte[] _pOutBuff, uint _nOutSize, out uint _OutLen, out uint _OutFormat)
|
||||||
|
{
|
||||||
|
fixed (byte* ptr = &_pInBuff[0])
|
||||||
|
{
|
||||||
|
fixed (byte* ptr3 = &_pOutBuff[0])
|
||||||
|
{
|
||||||
|
uint num = 0u;
|
||||||
|
byte b = (byte)((nNumLoops <= 0) ? 6 : 2);
|
||||||
|
uint num2 = /*_nInLen * 8*/0u;
|
||||||
|
uint num3 = (num2 + 28 - 1) / 28u * 16 + 16;
|
||||||
|
if (_pOutBuff == null)
|
||||||
|
{
|
||||||
|
_OutFormat = 0u;
|
||||||
|
_OutLen = num3;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint num4 = num2 / 28u;
|
||||||
|
uint num5 = num2 % 28u;
|
||||||
|
short* ptr2 = (short*)ptr;
|
||||||
|
byte* ptr4 = ptr3;
|
||||||
|
memset(ptr4, 0, 16u);
|
||||||
|
ptr4 += 16;
|
||||||
|
while (num4 != 0)
|
||||||
|
{
|
||||||
|
find_predict(ptr2, adbSamples, out predict_nr, out shift_factor, 1u);
|
||||||
|
pack(adbSamples, awFourBit, predict_nr, shift_factor);
|
||||||
|
*ptr4 = (byte)((predict_nr << 4) | shift_factor);
|
||||||
|
if (num5 == 0 && num4 == 1 && nNumLoops == 0)
|
||||||
|
{
|
||||||
|
b = 3;
|
||||||
|
}
|
||||||
|
ptr4[1] = b;
|
||||||
|
byte* ptr5 = ptr4 + 2;
|
||||||
|
fixed (ushort* ptr6 = &awFourBit[0])
|
||||||
|
{
|
||||||
|
int num6 = 0;
|
||||||
|
int num7 = 28;
|
||||||
|
while (num7 > 0)
|
||||||
|
{
|
||||||
|
*ptr5 = (byte)(((ptr6[num6] >> 12) & 0xF) | ((ptr6[num6 + 1] >> 8) & 0xF0));
|
||||||
|
num7 -= 2;
|
||||||
|
num6 += 2;
|
||||||
|
ptr5++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b = 2;
|
||||||
|
num4--;
|
||||||
|
ptr2 += 28;
|
||||||
|
ptr4 += 16;
|
||||||
|
num += 28;
|
||||||
|
}
|
||||||
|
if (num5 != 0)
|
||||||
|
{
|
||||||
|
short[] array = new short[28];
|
||||||
|
fixed (short* ptr7 = &array[0])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < num5; i++)
|
||||||
|
{
|
||||||
|
ptr7[i] = ptr2[i];
|
||||||
|
}
|
||||||
|
find_predict(ptr7, adbSamples, out predict_nr, out shift_factor, 1u);
|
||||||
|
pack(adbSamples, awFourBit, predict_nr, shift_factor);
|
||||||
|
}
|
||||||
|
*ptr4 = (byte)((predict_nr << 4) | shift_factor);
|
||||||
|
if (nNumLoops == 0)
|
||||||
|
{
|
||||||
|
ptr4[1] = 3;
|
||||||
|
}
|
||||||
|
byte* ptr8 = ptr4 + 2;
|
||||||
|
fixed (ushort* ptr9 = &awFourBit[0])
|
||||||
|
{
|
||||||
|
int num8 = 0;
|
||||||
|
int num9 = 28;
|
||||||
|
while (num9 > 0)
|
||||||
|
{
|
||||||
|
*ptr8 = (byte)(((ptr9[num8] >> 12) & 0xF) | ((ptr9[num8 + 1] >> 8) & 0xF0));
|
||||||
|
num9 -= 2;
|
||||||
|
num8 += 2;
|
||||||
|
ptr8++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr4 += 16;
|
||||||
|
}
|
||||||
|
_OutFormat = (uint)((int)_nInFormat & -1);
|
||||||
|
_OutLen = _nOutSize;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void find_predict(short* _pSamples, double[] d_samples, out int _predict_nr, out int _shift_factor, uint dwInterleave)
|
||||||
|
{
|
||||||
|
double[] array = new double[140];
|
||||||
|
double num = 10000000000.0;
|
||||||
|
double[] array2 = new double[5];
|
||||||
|
double num2 = _s_1;
|
||||||
|
double num3 = _s_2;
|
||||||
|
_predict_nr = 0;
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
array2[i] = 0.0;
|
||||||
|
num2 = _s_1;
|
||||||
|
num3 = _s_2;
|
||||||
|
for (int j = 0; j < 28; j++)
|
||||||
|
{
|
||||||
|
double num4 = _pSamples[j * dwInterleave];
|
||||||
|
if (num4 > 30719.0)
|
||||||
|
{
|
||||||
|
num4 = 30719.0;
|
||||||
|
}
|
||||||
|
if (num4 < -30720.0)
|
||||||
|
{
|
||||||
|
num4 = -30720.0;
|
||||||
|
}
|
||||||
|
double num5 = array[j + i * 28] = num4 + num2 * g_f_1[i] + num3 * g_f_1[i];
|
||||||
|
if (num5 < 0.0)
|
||||||
|
{
|
||||||
|
num5 = 0.0 - num5;
|
||||||
|
}
|
||||||
|
if (num5 > array2[i])
|
||||||
|
{
|
||||||
|
array2[i] = num5;
|
||||||
|
}
|
||||||
|
num3 = num2;
|
||||||
|
num2 = num4;
|
||||||
|
}
|
||||||
|
if (array2[i] < num)
|
||||||
|
{
|
||||||
|
num = array2[i];
|
||||||
|
_predict_nr = i;
|
||||||
|
}
|
||||||
|
if (num <= 7.0)
|
||||||
|
{
|
||||||
|
_predict_nr = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_s_1 = num2;
|
||||||
|
_s_2 = num3;
|
||||||
|
for (int i = 0; i < 28; i++)
|
||||||
|
{
|
||||||
|
d_samples[i] = array[i + _predict_nr * 28];
|
||||||
|
}
|
||||||
|
int num6 = (int)num;
|
||||||
|
int num7 = 16384;
|
||||||
|
_shift_factor = 0;
|
||||||
|
while (_shift_factor < 12 && (num7 & (num6 + (num7 >> 3))) != 0)
|
||||||
|
{
|
||||||
|
_shift_factor++;
|
||||||
|
num7 >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pack(double[] d_samples, ushort[] _four_bit, int predict_nr, int shift_factor)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 28; i++)
|
||||||
|
{
|
||||||
|
double num = d_samples[i] + pack_1 * g_f_1[predict_nr] + pack_1 * g_f_1[predict_nr];
|
||||||
|
double num2 = num * (double)(1 << shift_factor);
|
||||||
|
int num3 = ((int)num2 + 2048) & -4096;
|
||||||
|
if (num3 > 32767)
|
||||||
|
{
|
||||||
|
num3 = 32767;
|
||||||
|
}
|
||||||
|
if (num3 < -32768)
|
||||||
|
{
|
||||||
|
num3 = -32768;
|
||||||
|
}
|
||||||
|
_four_bit[i] = (ushort)(short)num3;
|
||||||
|
num3 >>= shift_factor;
|
||||||
|
pack_2 = pack_1;
|
||||||
|
pack_1 = (double)num3 - num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class VFNode
|
||||||
|
{
|
||||||
|
public int Count;
|
||||||
|
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
public List<LexTree> pFunction;
|
||||||
|
|
||||||
|
public bool AlreadyRemoved;
|
||||||
|
|
||||||
|
public VFNode(string _name)
|
||||||
|
{
|
||||||
|
Name = _name;
|
||||||
|
AlreadyRemoved = false;
|
||||||
|
pFunction = new List<LexTree>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class VMBuffer
|
||||||
|
{
|
||||||
|
public MemoryStream Buffer
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VMBuffer()
|
||||||
|
{
|
||||||
|
Buffer = new MemoryStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetInt(int _address)
|
||||||
|
{
|
||||||
|
byte[] buffer = Buffer.GetBuffer();
|
||||||
|
return BitConverter.ToInt32(buffer, _address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetInt(int _address, int _value)
|
||||||
|
{
|
||||||
|
byte[] buffer = Buffer.GetBuffer();
|
||||||
|
buffer[_address] = (byte)(_value & 0xFF);
|
||||||
|
buffer[_address + 1] = (byte)((_value >> 8) & 0xFF);
|
||||||
|
buffer[_address + 2] = (byte)((_value >> 16) & 0xFF);
|
||||||
|
buffer[_address + 3] = (byte)((_value >> 24) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(params int[] _entry)
|
||||||
|
{
|
||||||
|
foreach (int i2 in _entry)
|
||||||
|
{
|
||||||
|
Buffer.WriteInteger(i2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int EncodeArgDouble(int _a, int _b)
|
||||||
|
{
|
||||||
|
return _a | (_b << 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int EncodeInstructionArg(int _ins, int _arg)
|
||||||
|
{
|
||||||
|
return (_ins << 24) | (_arg << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int EncodeInstructionBranch(int _instr, int _offset)
|
||||||
|
{
|
||||||
|
return (_instr << 24) | ((_offset >> 2) & 0xFFFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetInstruction(int _d)
|
||||||
|
{
|
||||||
|
return (_d >> 24) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetArg(int _d)
|
||||||
|
{
|
||||||
|
return (_d >> 16) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetBranch(int _d)
|
||||||
|
{
|
||||||
|
return _d << 8 >> 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class VMLabel
|
||||||
|
{
|
||||||
|
public VMBuffer VMB
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Label
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Address
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> Patches
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Marked
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BreakCount
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VMLabel(string _label, VMBuffer _vmb)
|
||||||
|
{
|
||||||
|
Label = _label;
|
||||||
|
Address = 0L;
|
||||||
|
Patches = new List<int>();
|
||||||
|
Marked = false;
|
||||||
|
BreakCount = 0;
|
||||||
|
VMB = _vmb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Mark(long _address)
|
||||||
|
{
|
||||||
|
Address = _address;
|
||||||
|
Marked = true;
|
||||||
|
Patch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Patch()
|
||||||
|
{
|
||||||
|
foreach (int patch in Patches)
|
||||||
|
{
|
||||||
|
long address = Address;
|
||||||
|
int @int = VMB.GetInt(patch);
|
||||||
|
int value = VMBuffer.EncodeInstructionBranch(VMBuffer.GetInstruction(@int), patch);
|
||||||
|
VMB.SetInt(patch, value);
|
||||||
|
}
|
||||||
|
Patches.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
using Flobbster.Windows.Forms;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class View<T> : IPropertyGrid
|
||||||
|
{
|
||||||
|
protected T m_this;
|
||||||
|
|
||||||
|
protected PropertyInfo[] m_props;
|
||||||
|
|
||||||
|
public View(T _entry)
|
||||||
|
{
|
||||||
|
m_this = _entry;
|
||||||
|
Type typeFromHandle = typeof(T);
|
||||||
|
m_props = typeFromHandle.GetProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyBag Prepare()
|
||||||
|
{
|
||||||
|
PropertyBag propertyBag = new PropertyBag();
|
||||||
|
propertyBag.GetValue += GetValue;
|
||||||
|
PropertyInfo[] props = m_props;
|
||||||
|
foreach (PropertyInfo propertyInfo in props)
|
||||||
|
{
|
||||||
|
string name = propertyInfo.Name;
|
||||||
|
string description = string.Empty;
|
||||||
|
string category = "default";
|
||||||
|
object defaultValue = null;
|
||||||
|
object[] customAttributes = propertyInfo.GetCustomAttributes(true);
|
||||||
|
PropertyAttribute propertyAttribute = null;
|
||||||
|
object[] array = customAttributes;
|
||||||
|
foreach (object obj in array)
|
||||||
|
{
|
||||||
|
propertyAttribute = (obj as PropertyAttribute);
|
||||||
|
if (propertyAttribute != null)
|
||||||
|
{
|
||||||
|
description = propertyAttribute.Description;
|
||||||
|
if (!string.IsNullOrEmpty(propertyAttribute.Category))
|
||||||
|
{
|
||||||
|
category = propertyAttribute.Category;
|
||||||
|
}
|
||||||
|
defaultValue = propertyAttribute.Default;
|
||||||
|
if (!string.IsNullOrEmpty(propertyAttribute.Name))
|
||||||
|
{
|
||||||
|
name = propertyAttribute.Name;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (propertyAttribute == null || !propertyAttribute.Disabled)
|
||||||
|
{
|
||||||
|
PropertySpec value = new PropertySpec(name, propertyInfo.PropertyType, category, description, defaultValue);
|
||||||
|
propertyBag.Properties.Add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return propertyBag;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetValue(object _sender, PropertySpecEventArgs _e)
|
||||||
|
{
|
||||||
|
PropertyInfo[] props = m_props;
|
||||||
|
int num = 0;
|
||||||
|
PropertyInfo propertyInfo;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (num < props.Length)
|
||||||
|
{
|
||||||
|
propertyInfo = props[num];
|
||||||
|
if (propertyInfo.Name == _e.Property.Name)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_e.Value = propertyInfo.GetGetMethod().Invoke(m_this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Image PrepareImage()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CopyBits(BitmapData _data, int _x, int _y, GMBitmap32 _bmp)
|
||||||
|
{
|
||||||
|
IntPtr intPtr = new IntPtr(_data.Scan0.ToInt64() + _y * _data.Stride + _x * 4);
|
||||||
|
int num = 0;
|
||||||
|
int num2 = 0;
|
||||||
|
while (num2 < _bmp.Height)
|
||||||
|
{
|
||||||
|
int num3 = num;
|
||||||
|
IntPtr ptr = intPtr;
|
||||||
|
int num4 = 0;
|
||||||
|
while (num4 < _bmp.Width)
|
||||||
|
{
|
||||||
|
int val = _bmp.Data[num3] + (_bmp.Data[num3 + 1] << 8) + (_bmp.Data[num3 + 2] << 16) + ((0xFF | _bmp.Data[num3 + 3]) << 24);
|
||||||
|
Marshal.WriteInt32(ptr, val);
|
||||||
|
num4++;
|
||||||
|
num3 += 4;
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num2++;
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + _data.Stride);
|
||||||
|
num += _bmp.Width * 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void CopyBits(BitmapData _data, int _x, int _y, byte[] _mask, int _width, int _height)
|
||||||
|
{
|
||||||
|
IntPtr intPtr = new IntPtr(_data.Scan0.ToInt64() + _y * _data.Stride + _x * 4);
|
||||||
|
int num = (_width + 7) / 8;
|
||||||
|
int num2 = 0;
|
||||||
|
int num3 = 0;
|
||||||
|
while (num3 < _height)
|
||||||
|
{
|
||||||
|
int num4 = num2;
|
||||||
|
IntPtr ptr = intPtr;
|
||||||
|
byte b = 128;
|
||||||
|
int num5 = 0;
|
||||||
|
while (num5 < _width)
|
||||||
|
{
|
||||||
|
if (b == 0)
|
||||||
|
{
|
||||||
|
b = 128;
|
||||||
|
num4++;
|
||||||
|
}
|
||||||
|
int val = 16777215;
|
||||||
|
if ((_mask[num4] & b) != 0)
|
||||||
|
{
|
||||||
|
val = -16777216;
|
||||||
|
}
|
||||||
|
Marshal.WriteInt32(ptr, val);
|
||||||
|
num5++;
|
||||||
|
b = (byte)(b >> 1);
|
||||||
|
ptr = new IntPtr(ptr.ToInt64() + 4);
|
||||||
|
}
|
||||||
|
num3++;
|
||||||
|
intPtr = new IntPtr(intPtr.ToInt64() + _data.Stride);
|
||||||
|
num2 += num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class ViewBackground : View<GMBackground>
|
||||||
|
{
|
||||||
|
public ViewBackground(GMBackground _entry)
|
||||||
|
: base(_entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Image PrepareImage()
|
||||||
|
{
|
||||||
|
Bitmap bitmap = new Bitmap(m_this.Width, m_this.Height, PixelFormat.Format32bppArgb);
|
||||||
|
Rectangle rect = new Rectangle(0, 0, m_this.Width, m_this.Height);
|
||||||
|
BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
CopyBits(bitmapData, 0, 0, m_this.Bitmap);
|
||||||
|
bitmap.UnlockBits(bitmapData);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal class ViewFont : View<GMFont>
|
||||||
|
{
|
||||||
|
public ViewFont(GMFont _entry)
|
||||||
|
: base(_entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Image PrepareImage()
|
||||||
|
{
|
||||||
|
return m_this.Bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class ViewSprite : View<GMSprite>
|
||||||
|
{
|
||||||
|
public ViewSprite(GMSprite _entry)
|
||||||
|
: base(_entry)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Image PrepareImage()
|
||||||
|
{
|
||||||
|
int num = 8;
|
||||||
|
int num2 = 8;
|
||||||
|
int num3 = num;
|
||||||
|
int num4 = 0;
|
||||||
|
foreach (GMBitmap32 image in m_this.Images)
|
||||||
|
{
|
||||||
|
if (num4 < image.Height)
|
||||||
|
{
|
||||||
|
num4 = image.Height;
|
||||||
|
}
|
||||||
|
num3 += image.Width;
|
||||||
|
num3 += num;
|
||||||
|
}
|
||||||
|
num4 += num * 2;
|
||||||
|
Bitmap bitmap = new Bitmap(num3, num4, PixelFormat.Format32bppArgb);
|
||||||
|
int num5 = num;
|
||||||
|
int y = num2;
|
||||||
|
Rectangle rect = new Rectangle(0, 0, num3, num4);
|
||||||
|
BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||||
|
foreach (GMBitmap32 image2 in m_this.Images)
|
||||||
|
{
|
||||||
|
CopyBits(bitmapData, num5, y, image2);
|
||||||
|
num5 += image2.Width + num;
|
||||||
|
}
|
||||||
|
bitmap.UnlockBits(bitmapData);
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,206 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
public class Wave
|
||||||
|
{
|
||||||
|
public struct SRIFF
|
||||||
|
{
|
||||||
|
public uint ChunkID;
|
||||||
|
|
||||||
|
public uint ChunkSize;
|
||||||
|
|
||||||
|
public uint Format;
|
||||||
|
|
||||||
|
public uint SubChunk1ID;
|
||||||
|
|
||||||
|
public uint SubChunk1Size;
|
||||||
|
|
||||||
|
public short AudioFormat;
|
||||||
|
|
||||||
|
public short NumChannels;
|
||||||
|
|
||||||
|
public uint SampleRate;
|
||||||
|
|
||||||
|
public uint ByteRate;
|
||||||
|
|
||||||
|
public short BlockAlign;
|
||||||
|
|
||||||
|
public short BitsPerSample;
|
||||||
|
|
||||||
|
public uint SubChunk2ID;
|
||||||
|
|
||||||
|
public uint SubChunk2Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private const int SAMPLES_PER_SECOND = 22050;
|
||||||
|
|
||||||
|
private const int MAX_CHANNELS = 1;
|
||||||
|
|
||||||
|
private const int BITS_PER_SAMPLE = 16;
|
||||||
|
|
||||||
|
public byte[] RawWavFile;
|
||||||
|
|
||||||
|
public string FileName;
|
||||||
|
|
||||||
|
private int DataIndex;
|
||||||
|
|
||||||
|
private int DataSize;
|
||||||
|
|
||||||
|
private ushort NumChannels;
|
||||||
|
|
||||||
|
private uint SampleRate;
|
||||||
|
|
||||||
|
private uint ByteRate;
|
||||||
|
|
||||||
|
private ushort BlockAlign;
|
||||||
|
|
||||||
|
private ushort BitsPerSample;
|
||||||
|
|
||||||
|
private ushort AudioFormat;
|
||||||
|
|
||||||
|
private static int fileID;
|
||||||
|
|
||||||
|
public Wave(IFF _iff, byte[] _wave, string _name)
|
||||||
|
{
|
||||||
|
RawWavFile = _wave;
|
||||||
|
FileName = _name;
|
||||||
|
if (!ReadHeader())
|
||||||
|
{
|
||||||
|
string text = Path.Combine(Program.OutputDir, _name);
|
||||||
|
Program.Out.WriteLine("writing audio file {0}...", text);
|
||||||
|
File.WriteAllBytes(text, _wave);
|
||||||
|
_iff.ExternalFiles.Add(text);
|
||||||
|
RawWavFile = new byte[128];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint Flip(uint _val)
|
||||||
|
{
|
||||||
|
return ((_val >> 24) & 0xFF) | ((_val >> 8) & 0xFF00) | ((_val & 0xFF) << 24) | ((_val & 0xFF00) << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe void GetDataChunk(byte[] _pWave, out int _ChunkSize, out int _index)
|
||||||
|
{
|
||||||
|
int num = _pWave.Length;
|
||||||
|
fixed (byte* ptr = &_pWave[0])
|
||||||
|
{
|
||||||
|
SRIFF* ptr2 = (SRIFF*)ptr;
|
||||||
|
ptr2 = (SRIFF*)(ptr + (int)ptr2->SubChunk1Size + 20);
|
||||||
|
while (ptr2->ChunkID != 1635017060 && ptr2 < ptr + num)
|
||||||
|
{
|
||||||
|
ptr2 = (SRIFF*)((byte*)ptr2 + (int)ptr2->ChunkSize + 8);
|
||||||
|
}
|
||||||
|
_ChunkSize = (int)ptr2->ChunkSize;
|
||||||
|
_index = (int)((long)ptr2 - (long)ptr) + 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ReadHeader()
|
||||||
|
{
|
||||||
|
uint val = BitConverter.ToUInt32(RawWavFile, 0);
|
||||||
|
BitConverter.ToUInt32(RawWavFile, 4);
|
||||||
|
uint val2 = BitConverter.ToUInt32(RawWavFile, 8);
|
||||||
|
val = Flip(val);
|
||||||
|
val2 = Flip(val2);
|
||||||
|
if (val != 1380533830)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (val2 != 1463899717)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uint val3 = BitConverter.ToUInt32(RawWavFile, 12);
|
||||||
|
BitConverter.ToUInt32(RawWavFile, 16);
|
||||||
|
AudioFormat = BitConverter.ToUInt16(RawWavFile, 20);
|
||||||
|
val3 = Flip(val3);
|
||||||
|
if (val3 != 1718449184 || AudioFormat != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
NumChannels = BitConverter.ToUInt16(RawWavFile, 22);
|
||||||
|
SampleRate = BitConverter.ToUInt32(RawWavFile, 24);
|
||||||
|
ByteRate = BitConverter.ToUInt32(RawWavFile, 28);
|
||||||
|
BlockAlign = BitConverter.ToUInt16(RawWavFile, 32);
|
||||||
|
BitsPerSample = BitConverter.ToUInt16(RawWavFile, 34);
|
||||||
|
GetDataChunk(RawWavFile, out DataSize, out DataIndex);
|
||||||
|
RawWavFile = Resample();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe byte[] Resample()
|
||||||
|
{
|
||||||
|
if (AudioFormat == 1 && SampleRate == 22050 && NumChannels == 1 && BitsPerSample == 16)
|
||||||
|
{
|
||||||
|
return RawWavFile;
|
||||||
|
}
|
||||||
|
fixed (byte* ptr4 = &RawWavFile[0])
|
||||||
|
{
|
||||||
|
int num = (int)BitsPerSample / 8;
|
||||||
|
float num2 = (float)(double)SampleRate / 22050f;
|
||||||
|
float num3 = 0f;
|
||||||
|
int num4 = num * NumChannels;
|
||||||
|
int num5 = DataSize / num4;
|
||||||
|
int num6 = (int)((float)num5 / num2);
|
||||||
|
int num7 = (int)(2.0 * (double)num6);
|
||||||
|
byte[] array = new byte[num7 + 44];
|
||||||
|
fixed (byte* ptr = &array[0])
|
||||||
|
{
|
||||||
|
short* ptr2 = (short*)ptr;
|
||||||
|
SRIFF* ptr3 = (SRIFF*)ptr2;
|
||||||
|
ptr2 += 22;
|
||||||
|
ptr3->ChunkID = 1179011410u;
|
||||||
|
ptr3->ChunkSize = (uint)(36 + num7);
|
||||||
|
ptr3->Format = 1163280727u;
|
||||||
|
ptr3->SubChunk1ID = 544501094u;
|
||||||
|
ptr3->SubChunk1Size = 16u;
|
||||||
|
ptr3->AudioFormat = 1;
|
||||||
|
ptr3->NumChannels = 1;
|
||||||
|
ptr3->SampleRate = 22050u;
|
||||||
|
ptr3->ByteRate = ptr3->SampleRate * 2;
|
||||||
|
ptr3->BitsPerSample = 16;
|
||||||
|
ptr3->BlockAlign = 2;
|
||||||
|
ptr3->SubChunk2ID = 1635017060u;
|
||||||
|
ptr3->SubChunk2Size = (uint)num7;
|
||||||
|
byte* ptr5 = ptr4 + DataIndex;
|
||||||
|
int num8 = 0;
|
||||||
|
int num9 = 0;
|
||||||
|
while (num6 > 0)
|
||||||
|
{
|
||||||
|
int num10 = 0;
|
||||||
|
int num11 = num8 * num4;
|
||||||
|
switch (BitsPerSample)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
num10 = ptr5[num11] - 128 << 8;
|
||||||
|
if (NumChannels == 2)
|
||||||
|
{
|
||||||
|
byte b = ptr5[num11 + 1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
num10 = ((ptr5[num11] & 0xFF) | ((ptr5[num11 + 1] & 0xFF) << 8));
|
||||||
|
if (NumChannels == 2)
|
||||||
|
{
|
||||||
|
byte b2 = ptr5[num11 + 2];
|
||||||
|
byte b3 = ptr5[num11 + 3];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ptr2[num9] = (short)num10;
|
||||||
|
num9++;
|
||||||
|
num3 += num2;
|
||||||
|
int num12 = (int)num3;
|
||||||
|
num3 -= (float)num12;
|
||||||
|
num8 += num12;
|
||||||
|
num6--;
|
||||||
|
}
|
||||||
|
fileID++;
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace GMAssetCompiler
|
||||||
|
{
|
||||||
|
internal struct YYArgEntry
|
||||||
|
{
|
||||||
|
public int type;
|
||||||
|
|
||||||
|
[YYStringOffset]
|
||||||
|
public int arg;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue