diff --git a/ChovyUI.Designer.cs b/ChovyUI.Designer.cs new file mode 100644 index 0000000..225b8eb --- /dev/null +++ b/ChovyUI.Designer.cs @@ -0,0 +1,624 @@ +namespace ChovyUI +{ + partial class ChovyUI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.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; + } +} \ No newline at end of file diff --git a/ChovyUI.cs b/ChovyUI.cs new file mode 100644 index 0000000..5abf6ad --- /dev/null +++ b/ChovyUI.cs @@ -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); + } + } + } +} diff --git a/ChovyUI.resx b/ChovyUI.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ChovyUI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Flobbster.Windows.Forms/PropertyBag.cs b/Flobbster.Windows.Forms/PropertyBag.cs new file mode 100644 index 0000000..4599cff --- /dev/null +++ b/Flobbster.Windows.Forms/PropertyBag.cs @@ -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; + } + } +} diff --git a/Flobbster.Windows.Forms/PropertySpec.cs b/Flobbster.Windows.Forms/PropertySpec.cs new file mode 100644 index 0000000..25fda8e --- /dev/null +++ b/Flobbster.Windows.Forms/PropertySpec.cs @@ -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) + { + } + } +} diff --git a/Flobbster.Windows.Forms/PropertySpecEventArgs.cs b/Flobbster.Windows.Forms/PropertySpecEventArgs.cs new file mode 100644 index 0000000..17388a3 --- /dev/null +++ b/Flobbster.Windows.Forms/PropertySpecEventArgs.cs @@ -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; + } + } +} diff --git a/Flobbster.Windows.Forms/PropertySpecEventHandler.cs b/Flobbster.Windows.Forms/PropertySpecEventHandler.cs new file mode 100644 index 0000000..05cf432 --- /dev/null +++ b/Flobbster.Windows.Forms/PropertySpecEventHandler.cs @@ -0,0 +1,4 @@ +namespace Flobbster.Windows.Forms +{ + public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e); +} diff --git a/Flobbster.Windows.Forms/PropertyTable.cs b/Flobbster.Windows.Forms/PropertyTable.cs new file mode 100644 index 0000000..becfa19 --- /dev/null +++ b/Flobbster.Windows.Forms/PropertyTable.cs @@ -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); + } + } +} diff --git a/GMAC1098/.vs/GMAssetCompiler/v15/.suo b/GMAC1098/.vs/GMAssetCompiler/v15/.suo new file mode 100644 index 0000000..9016c57 Binary files /dev/null and b/GMAC1098/.vs/GMAssetCompiler/v15/.suo differ diff --git a/GMAC1098/Flobbster.Windows.Forms/PropertyBag.cs b/GMAC1098/Flobbster.Windows.Forms/PropertyBag.cs new file mode 100644 index 0000000..4599cff --- /dev/null +++ b/GMAC1098/Flobbster.Windows.Forms/PropertyBag.cs @@ -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; + } + } +} diff --git a/GMAC1098/Flobbster.Windows.Forms/PropertySpec.cs b/GMAC1098/Flobbster.Windows.Forms/PropertySpec.cs new file mode 100644 index 0000000..25fda8e --- /dev/null +++ b/GMAC1098/Flobbster.Windows.Forms/PropertySpec.cs @@ -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) + { + } + } +} diff --git a/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventArgs.cs b/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventArgs.cs new file mode 100644 index 0000000..17388a3 --- /dev/null +++ b/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventArgs.cs @@ -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; + } + } +} diff --git a/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventHandler.cs b/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventHandler.cs new file mode 100644 index 0000000..05cf432 --- /dev/null +++ b/GMAC1098/Flobbster.Windows.Forms/PropertySpecEventHandler.cs @@ -0,0 +1,4 @@ +namespace Flobbster.Windows.Forms +{ + public delegate void PropertySpecEventHandler(object sender, PropertySpecEventArgs e); +} diff --git a/GMAC1098/Flobbster.Windows.Forms/PropertyTable.cs b/GMAC1098/Flobbster.Windows.Forms/PropertyTable.cs new file mode 100644 index 0000000..becfa19 --- /dev/null +++ b/GMAC1098/Flobbster.Windows.Forms/PropertyTable.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/Android.cs b/GMAC1098/GMAssetCompiler.Machines/Android.cs new file mode 100644 index 0000000..0a3ee26 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/Android.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/HTML5.cs b/GMAC1098/GMAssetCompiler.Machines/HTML5.cs new file mode 100644 index 0000000..86dec65 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/HTML5.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/IOS.cs b/GMAC1098/GMAssetCompiler.Machines/IOS.cs new file mode 100644 index 0000000..77a2bac --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/IOS.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/PSP.cs b/GMAC1098/GMAssetCompiler.Machines/PSP.cs new file mode 100644 index 0000000..24d249c --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/PSP.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/Symbian.cs b/GMAC1098/GMAssetCompiler.Machines/Symbian.cs new file mode 100644 index 0000000..c4c2592 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/Symbian.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Machines/Windows.cs b/GMAC1098/GMAssetCompiler.Machines/Windows.cs new file mode 100644 index 0000000..7058e91 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Machines/Windows.cs @@ -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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Output/TextureOptionAttribute.cs b/GMAC1098/GMAssetCompiler.Output/TextureOptionAttribute.cs new file mode 100644 index 0000000..3d1ec39 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Output/TextureOptionAttribute.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Output/TextureOptions.cs b/GMAC1098/GMAssetCompiler.Output/TextureOptions.cs new file mode 100644 index 0000000..2fe8769 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Output/TextureOptions.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace GMAssetCompiler.Output +{ + internal class TextureOptions + { + private static Dictionary> 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>(); + 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()); + } + } + } + + public static void AddResourceOptions(string _optionName, List _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> textureResourcesOption in TextureResourcesOptions) + { + if (textureResourcesOption.Value.Contains(_GMResourceName)) + { + type.GetProperty(textureResourcesOption.Key).SetValue(_tpageEntry, true, null); + } + } + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Properties/Resources.cs b/GMAC1098/GMAssetCompiler.Properties/Resources.cs new file mode 100644 index 0000000..8db3597 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Properties/Resources.cs @@ -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() + { + } + } +} diff --git a/GMAC1098/GMAssetCompiler.Properties/Settings.cs b/GMAC1098/GMAssetCompiler.Properties/Settings.cs new file mode 100644 index 0000000..bd38780 --- /dev/null +++ b/GMAC1098/GMAssetCompiler.Properties/Settings.cs @@ -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; + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler.csproj b/GMAC1098/GMAssetCompiler.csproj new file mode 100644 index 0000000..1a1d51a --- /dev/null +++ b/GMAC1098/GMAssetCompiler.csproj @@ -0,0 +1,217 @@ + + + + {9448EC1D-1983-4043-ACE5-94049A822CD7} + Debug + x86 + Exe + 5 + SilicaAssetCompiler + v4.5 + 4 + True + + + + x86 + + + bin\Debug\ + true + full + false + + + bin\Release\ + true + pdbonly + true + + + false + + + false + + + + packages\NAudio.1.9.0\lib\net35\NAudio.dll + + + C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll + + + C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll + + + C:\Windows\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll + + + C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll + + + C:\Users\Nik\AppData\Roaming\GameMaker-Studio\Ionic.Zip.Reduced.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GMAC1098/GMAssetCompiler.sln b/GMAC1098/GMAssetCompiler.sln new file mode 100644 index 0000000..ef6a85a --- /dev/null +++ b/GMAC1098/GMAssetCompiler.sln @@ -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 diff --git a/GMAC1098/GMAssetCompiler.v12.suo b/GMAC1098/GMAssetCompiler.v12.suo new file mode 100644 index 0000000..1e25d76 Binary files /dev/null and b/GMAC1098/GMAssetCompiler.v12.suo differ diff --git a/GMAC1098/GMAssetCompiler/DDS.cs b/GMAC1098/GMAssetCompiler/DDS.cs new file mode 100644 index 0000000..730d462 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/DDS.cs @@ -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; + } +} diff --git a/GMAC1098/GMAssetCompiler/DummyStream.cs b/GMAC1098/GMAssetCompiler/DummyStream.cs new file mode 100644 index 0000000..be02903 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/DummyStream.cs @@ -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) + { + } + } +} diff --git a/GMAC1098/GMAssetCompiler/ExtensionKind.cs b/GMAC1098/GMAssetCompiler/ExtensionKind.cs new file mode 100644 index 0000000..88d1f73 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/ExtensionKind.cs @@ -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 + } +} diff --git a/GMAC1098/GMAssetCompiler/Form1.cs b/GMAC1098/GMAssetCompiler/Form1.cs new file mode 100644 index 0000000..589542a --- /dev/null +++ b/GMAC1098/GMAssetCompiler/Form1.cs @@ -0,0 +1,1081 @@ +using Flobbster.Windows.Forms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Runtime.InteropServices; +using System.Windows.Forms; + +namespace GMAssetCompiler +{ + public class Form1 : Form + { + public delegate PropertyBag Prepare(object _o); + + private GMAssets m_assets; + + private ToolStripMenuItem m_currentMachineSelected; + + private ToolStripMenuItem[] m_currentTextureSelected; + + private IContainer components; + + private SplitContainer splitContainer1; + + private TreeView treeView1; + + private SplitContainer splitContainer2; + + private PropertyGrid propertyGrid1; + + private PictureBox pictureBox1; + + private ToolStrip toolStrip1; + + private ToolStripButton compileButton; + + private ToolStripDropDownButton targetDDButton; + + private ToolStripMenuItem pSPToolStripMenuItem; + + private ToolStripMenuItem windowsToolStripMenuItem; + + private ToolStripMenuItem iOSToolStripMenuItem; + + private ToolStripButton toolStripButton1; + + private ToolStripTextBox SearchBox; + + private ToolStripDropDownButton toolStripOpaqueTextureButton; + + private ToolStripMenuItem bitToolStripMenuItem; + + private ToolStripMenuItem r8G8B8A8ToolStripMenuItem; + + private ToolStripMenuItem dXTC5ToolStripMenuItem; + + private ToolStripMenuItem pVRTCToolStripMenuItem; + + private ToolStripDropDownButton toolStripAlphaTextureButton; + + private ToolStripMenuItem toolStripMenuItem1; + + private ToolStripMenuItem toolStripMenuItem2; + + private ToolStripMenuItem toolStripMenuItem3; + + private ToolStripMenuItem toolStripMenuItem4; + + private ToolStripMenuItem pNGToolStripMenuItem; + + private ToolStripMenuItem pNGToolStripMenuItem1; + + private ToolStripMenuItem androidToolStripMenuItem; + + private ToolStripMenuItem symbianToolStripMenuItem; + + private ToolStripMenuItem hTML5ToolStripMenuItem; + + private ToolStripDropDownButton toolStripDropDownButton1; + + private ToolStripMenuItem writeTexturesToolStripMenuItem; + + private ToolStripMenuItem writeWavsToolStripMenuItem; + + private ToolStripMenuItem separateAlphaOpaqueTexturesToolStripMenuItem; + + private ToolStripMenuItem noCacheStripMenuItem; + + private ToolStripMenuItem verboseToolStripMenuItem; + + private ToolStripMenuItem obfuscateToolStripMenuItem; + + private ToolStripMenuItem prettyPrintingToolStripMenuItem; + + private ToolStripMenuItem RemoveUnusedFunctionsToolStripMenuItem; + + private ToolStripMenuItem encodeStringsToolStripMenuItem; + + private ToolStripMenuItem obfuscateToolStripMenuItem1; + + public Form1(GMAssets _assets) + { + m_assets = _assets; + InitializeComponent(); + Text = string.Format("GMAssetCompiler : {0} : {1}", Program.MachineType.Name, _assets.FileName); + m_currentTextureSelected = new ToolStripMenuItem[2]; + foreach (ToolStripMenuItem dropDownItem in targetDDButton.DropDownItems) + { + if (string.Compare(dropDownItem.Text, Program.MachineType.Name, true) == 0) + { + m_currentMachineSelected = dropDownItem; + dropDownItem.Checked = true; + break; + } + } + foreach (ToolStripMenuItem dropDownItem2 in toolStripOpaqueTextureButton.DropDownItems) + { + dropDownItem2.Tag = (eTexType)Enum.Parse(typeof(eTexType), dropDownItem2.Tag as string); + dropDownItem2.Checked = (Program.TextureType[0] == (eTexType)dropDownItem2.Tag); + if (dropDownItem2.Checked) + { + m_currentTextureSelected[0] = dropDownItem2; + } + } + foreach (ToolStripMenuItem dropDownItem3 in toolStripAlphaTextureButton.DropDownItems) + { + dropDownItem3.Tag = (eTexType)Enum.Parse(typeof(eTexType), dropDownItem3.Tag as string); + dropDownItem3.Checked = (Program.TextureType[1] == (eTexType)dropDownItem3.Tag); + if (dropDownItem3.Checked) + { + m_currentTextureSelected[1] = dropDownItem3; + } + } + writeTexturesToolStripMenuItem.Checked = Program.WriteTextures; + writeWavsToolStripMenuItem.Checked = Program.WriteWaves; + separateAlphaOpaqueTexturesToolStripMenuItem.Checked = Program.SeparateOpaqueAndAlpha; + noCacheStripMenuItem.Checked = Program.NoCache; + verboseToolStripMenuItem.Checked = Program.Verbose; + obfuscateToolStripMenuItem.Checked = Program.DoObfuscate; + prettyPrintingToolStripMenuItem.Checked = Program.ObfuscatePrettyPrint; + RemoveUnusedFunctionsToolStripMenuItem.Checked = Program.ObfuscateRemoveUnused; + encodeStringsToolStripMenuItem.Checked = Program.ObfuscateEncodeStrings; + obfuscateToolStripMenuItem1.Checked = Program.ObfuscateObfuscate; + AddExtensions(); + AddSounds(); + AddSprites(); + AddBackgrounds(); + AddPaths(); + AddScripts(); + AddFonts(); + AddTimeLines(); + AddObjects(); + AddRooms(); + AddDataFiles(); + AddLibraries(); + AddRoomOrder(); + AddOptions(); + } + + private void AddEntry(IList> _collection, string _name, Type _tag) + { + List list = new List(); + int num = 0; + foreach (KeyValuePair item in _collection) + { + if (!string.IsNullOrEmpty(item.Key)) + { + TreeNode treeNode = new TreeNode(item.Key + string.Format("({0})", num)); + treeNode.Tag = ((_tag != null) ? Activator.CreateInstance(_tag, item.Value) : null); + list.Add(treeNode); + } + num++; + } + TreeNode node = new TreeNode(_name, list.ToArray()); + treeView1.Nodes.Add(node); + } + + public void AddSprites() + { + AddEntry(m_assets.Sprites, "sprites", typeof(ViewSprite)); + } + + public void AddExtensions() + { + List list = new List(); + foreach (GMExtension extension in m_assets.Extensions) + { + list.Add(new TreeNode(extension.Name)); + } + TreeNode node = new TreeNode("extensions", list.ToArray()); + treeView1.Nodes.Add(node); + } + + public void AddSounds() + { + AddEntry(m_assets.Sounds, "sounds", typeof(View)); + } + + public void AddBackgrounds() + { + AddEntry(m_assets.Backgrounds, "backgrounds", typeof(ViewBackground)); + } + + public void AddPaths() + { + AddEntry(m_assets.Paths, "paths", typeof(View)); + } + + public void AddScripts() + { + AddEntry(m_assets.Scripts, "scripts", typeof(View)); + } + + public void AddFonts() + { + AddEntry(m_assets.Fonts, "fonts", typeof(ViewFont)); + } + + public void AddTimeLines() + { + AddEntry(m_assets.TimeLines, "timelines", typeof(View)); + } + + public void AddObjects() + { + AddEntry(m_assets.Objects, "objects", typeof(View)); + } + + public void AddRooms() + { + AddEntry(m_assets.Rooms, "rooms", typeof(View)); + } + + public void AddDataFiles() + { + AddEntry(m_assets.DataFiles, "datafiles", typeof(View)); + } + + public void AddLibraries() + { + List list = new List(); + foreach (string library in m_assets.Libraries) + { + list.Add(new TreeNode(library)); + } + TreeNode node = new TreeNode("libraries", list.ToArray()); + treeView1.Nodes.Add(node); + } + + public void AddRoomOrder() + { + List list = new List(); + foreach (int item in m_assets.RoomOrder) + { + list.Add(new TreeNode(m_assets.Rooms[item].Key)); + } + TreeNode node = new TreeNode("roomOrder", list.ToArray()); + treeView1.Nodes.Add(node); + } + + public void AddOptions() + { + } + + private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) + { + propertyGrid1.SelectedObject = null; + if (e.Node.Tag != null) + { + IPropertyGrid propertyGrid = (IPropertyGrid)e.Node.Tag; + PropertyBag selectedObject = propertyGrid.Prepare(); + propertyGrid1.SelectedObject = selectedObject; + Image image = propertyGrid.PrepareImage(); + pictureBox1.Image = image; + } + } + + public static byte[] createOutTexture(Image image, eSquishFlags _flags, out Image _dest, eTexType _type) + { + _dest = null; + switch (_type) + { + case eTexType.e4444: + return CompressImageRaw4444(image, out _dest); + case eTexType.eRaw: + return CompressImageRaw(image); + case eTexType.ePVR: + return CompressImagePVR(image); + case eTexType.ePNG: + { + MemoryStream memoryStream = new MemoryStream(); + image.Save(memoryStream, ImageFormat.Png); + return memoryStream.ToArray(); + } + default: + return CompressImageDXT(image, _flags); + } + } + + private unsafe static byte[] CompressImageRaw(Image image) + { + int num = 0; + Bitmap bitmap = new Bitmap(image); + Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); + BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + IMachineType machineType = Program.MachineType; + byte[] array = new byte[image.Width * image.Height * 4 + 16]; + fixed (byte* ptr2 = &array[0]) + { + IntPtr scan = bitmapData.Scan0; + IntPtr intPtr = scan; + int num2 = 0; + while (num2 < image.Height) + { + IntPtr ptr = intPtr; + int num3 = 0; + while (num3 < image.Width) + { + int num4 = Marshal.ReadInt32(ptr); + *(uint*)(ptr2 + (long)(4 + num) * 4L) = machineType.Convert8888((num4 >> 24) & 0xFF, num4 & 0xFF, (num4 & 0xFF00) >> 8, (num4 >> 16) & 0xFF); + num++; + num3++; + ptr = new IntPtr(ptr.ToInt64() + 4); + } + num2++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + } + *(int*)ptr2 = 542589266; + *(int*)(ptr2 + 4) = image.Width; + *(int*)(ptr2 + 8) = image.Height; + *(int*)(ptr2 + 12) = 0; + } + bitmap.UnlockBits(bitmapData); + return array; + } + + private unsafe static byte[] CompressImageRaw4444(Image image, out Image _destImage) + { + Bitmap bitmap = (Bitmap)(_destImage = new Bitmap(image)); + int num = 0; + Bitmap bitmap2 = new Bitmap(image); + Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); + BitmapData bitmapData = bitmap2.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); + BitmapData bitmapData2 = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); + byte[] array = new byte[image.Width * image.Height * 2 + 16]; + fixed (byte* ptr3 = &array[0]) + { + IntPtr scan = bitmapData.Scan0; + IntPtr scan2 = bitmapData2.Scan0; + IntPtr intPtr = scan; + IntPtr intPtr2 = scan2; + IMachineType machineType = Program.MachineType; + int num2 = 0; + while (num2 < image.Height) + { + IntPtr ptr = intPtr; + IntPtr ptr2 = intPtr2; + float num3 = 0.4375f; + float num4 = 0.1875f; + float num5 = 0.3125f; + float num6 = 0.0625f; + int num7 = 0; + while (num7 < image.Width) + { + int num8 = Marshal.ReadInt32(ptr); + int num9 = num8 & 0xFF; + int num10 = (num8 >> 8) & 0xFF; + int num11 = (num8 >> 16) & 0xFF; + int num12 = (num8 >> 24) & 0xFF; + *(ushort*)(ptr3 + (long)(8 + num) * 2L) = machineType.Convert4444(num12, num9, num10, num11); + int num13 = num12 & 0xF0; + if (num13 != 0) + { + num13 |= 0xF; + } + Marshal.WriteInt32(ptr2, (num13 << 24) | ((num11 & 0xF0) << 16) | ((num10 & 0xF0) << 8) | (num9 & 0xF0)); + int num14 = num9 & 0xF; + int num15 = num10 & 0xF; + int num16 = num11 & 0xF; + if (num7 < image.Width - 1) + { + num8 = Marshal.ReadInt32(ptr, 4); + num9 = (int)((float)(num8 & 0xFF) + num3 * (float)num14); + num10 = (int)((float)((num8 >> 8) & 0xFF) + num3 * (float)num15); + num11 = (int)((float)((num8 >> 16) & 0xFF) + num3 * (float)num16); + num12 = ((num8 >> 24) & 0xFF); + num9 = ((num9 >= 0) ? ((num9 > 255) ? 255 : num9) : 0); + num10 = ((num10 >= 0) ? ((num10 > 255) ? 255 : num10) : 0); + num11 = ((num11 >= 0) ? ((num11 > 255) ? 255 : num11) : 0); + num8 = ((num12 << 24) | (num11 << 16) | (num10 << 8) | num9); + Marshal.WriteInt32(ptr, 4, num8); + } + if (num7 > 0 && num2 < image.Height - 1) + { + num8 = Marshal.ReadInt32(ptr, -4 + bitmapData.Stride); + num9 = (int)((float)(num8 & 0xFF) + num4 * (float)num14); + num10 = (int)((float)((num8 >> 8) & 0xFF) + num4 * (float)num15); + num11 = (int)((float)((num8 >> 16) & 0xFF) + num4 * (float)num16); + num12 = ((num8 >> 24) & 0xFF); + num9 = ((num9 >= 0) ? ((num9 > 255) ? 255 : num9) : 0); + num10 = ((num10 >= 0) ? ((num10 > 255) ? 255 : num10) : 0); + num11 = ((num11 >= 0) ? ((num11 > 255) ? 255 : num11) : 0); + num8 = ((num12 << 24) | (num11 << 16) | (num10 << 8) | num9); + Marshal.WriteInt32(ptr, -4 + bitmapData.Stride, num8); + } + if (num2 < image.Height - 1) + { + num8 = Marshal.ReadInt32(ptr, bitmapData.Stride); + num9 = (int)((float)(num8 & 0xFF) + num5 * (float)num14); + num10 = (int)((float)((num8 >> 8) & 0xFF) + num5 * (float)num15); + num11 = (int)((float)((num8 >> 16) & 0xFF) + num5 * (float)num16); + num12 = ((num8 >> 24) & 0xFF); + num9 = ((num9 >= 0) ? ((num9 > 255) ? 255 : num9) : 0); + num10 = ((num10 >= 0) ? ((num10 > 255) ? 255 : num10) : 0); + num11 = ((num11 >= 0) ? ((num11 > 255) ? 255 : num11) : 0); + num8 = ((num12 << 24) | (num11 << 16) | (num10 << 8) | num9); + Marshal.WriteInt32(ptr, bitmapData.Stride, num8); + } + if (num7 < image.Width - 1 && num2 < image.Height - 1) + { + num8 = Marshal.ReadInt32(ptr, 4 + bitmapData.Stride); + num9 = (int)((float)(num8 & 0xFF) + num6 * (float)num14); + num10 = (int)((float)((num8 >> 8) & 0xFF) + num6 * (float)num15); + num11 = (int)((float)((num8 >> 16) & 0xFF) + num6 * (float)num16); + num12 = ((num8 >> 24) & 0xFF); + num9 = ((num9 >= 0) ? ((num9 > 255) ? 255 : num9) : 0); + num10 = ((num10 >= 0) ? ((num10 > 255) ? 255 : num10) : 0); + num11 = ((num11 >= 0) ? ((num11 > 255) ? 255 : num11) : 0); + num8 = ((num12 << 24) | (num11 << 16) | (num10 << 8) | num9); + Marshal.WriteInt32(ptr, 4 + bitmapData.Stride, num8); + } + num++; + num7++; + ptr = new IntPtr(ptr.ToInt64() + 4); + ptr2 = new IntPtr(ptr2.ToInt64() + 4); + } + num2++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + intPtr2 = new IntPtr(intPtr2.ToInt64() + bitmapData2.Stride); + } + *(int*)ptr3 = 542589266; + *(int*)(ptr3 + 4) = image.Width; + *(int*)(ptr3 + 8) = image.Height; + *(int*)(ptr3 + 12) = 1; + } + bitmap2.UnlockBits(bitmapData); + return array; + } + + private static byte[] CompressImagePVR(Image image) + { + Bitmap bitmap = new Bitmap(image); + Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); + BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + IntPtr scan = bitmapData.Scan0; + IntPtr intPtr = scan; + int num = 0; + while (num < image.Height) + { + IntPtr ptr = intPtr; + int num2 = 0; + while (num2 < image.Width) + { + int num3 = Marshal.ReadInt32(ptr); + int val = (num3 & -16711936) | ((num3 & 0xFF) << 16) | ((num3 & 0xFF0000) >> 16); + Marshal.WriteInt32(ptr, val); + num2++; + ptr = new IntPtr(ptr.ToInt64() + 4); + } + num++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + } + string text = Path.ChangeExtension(Path.GetTempFileName(), ".pvr"); + IntPtr intPtr2 = Marshal.StringToHGlobalAnsi(text); + Squish.CompressPVRTC(bitmapData.Scan0, image.Width, image.Height, intPtr2, 0); + Marshal.FreeHGlobal(intPtr2); + scan = bitmapData.Scan0; + intPtr = scan; + int num4 = 0; + while (num4 < image.Height) + { + IntPtr ptr2 = intPtr; + int num5 = 0; + while (num5 < image.Width) + { + int num6 = Marshal.ReadInt32(ptr2); + int val2 = (num6 & -16711936) | ((num6 & 0xFF) << 16) | ((num6 & 0xFF0000) >> 16); + Marshal.WriteInt32(ptr2, val2); + num5++; + ptr2 = new IntPtr(ptr2.ToInt64() + 4); + } + num4++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + } + byte[] result = File.ReadAllBytes(text); + bitmap.UnlockBits(bitmapData); + return result; + } + + private unsafe static byte[] CompressImageDXT(Image image, eSquishFlags _flags) + { + Bitmap bitmap = new Bitmap(image); + Rectangle rect = new Rectangle(0, 0, image.Width, image.Height); + BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); + int storageRequirements = Squish.GetStorageRequirements(image.Width, image.Height, _flags); + int num = Marshal.SizeOf(typeof(DDS.SDDSHeader)); + storageRequirements += num; + byte[] array = new byte[storageRequirements + 15]; + fixed (byte* value = &array[num]) + { + IntPtr scan = bitmapData.Scan0; + IntPtr intPtr = scan; + int num2 = 0; + while (num2 < image.Height) + { + IntPtr ptr = intPtr; + int num3 = 0; + while (num3 < image.Width) + { + int num4 = Marshal.ReadInt32(ptr); + int val = (num4 & -16711936) | ((num4 & 0xFF) << 16) | ((num4 & 0xFF0000) >> 16); + Marshal.WriteInt32(ptr, val); + num3++; + ptr = new IntPtr(ptr.ToInt64() + 4); + } + num2++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + } + Squish.CompressImage(bitmapData.Scan0, image.Width, image.Height, new IntPtr(value), _flags); + intPtr = scan; + int num5 = 0; + while (num5 < image.Height) + { + IntPtr ptr2 = intPtr; + int num6 = 0; + while (num6 < image.Width) + { + int num7 = Marshal.ReadInt32(ptr2); + int val2 = (num7 & -16711936) | ((num7 & 0xFF) << 16) | ((num7 & 0xFF0000) >> 16); + Marshal.WriteInt32(ptr2, val2); + num6++; + ptr2 = new IntPtr(ptr2.ToInt64() + 4); + } + num5++; + intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); + } + } + bitmap.UnlockBits(bitmapData); + fixed (byte* ptr3 = &array[0]) + { + DDS.SDDSHeader* ptr4 = (DDS.SDDSHeader*)ptr3; + ptr4->Magic = 542327876u; + ptr4->dwSize = (uint)Marshal.SizeOf(typeof(DDS.SDDSHeader)); + ptr4->dwFlags = 659463u; + ptr4->dwMipMapCount = 0u; + ptr4->dwWidth = (uint)image.Width; + ptr4->dwHeight = (uint)image.Height; + ptr4->ddpfPixelFormat.dwSize = (uint)Marshal.SizeOf(typeof(DDS.SDDPIXELFORMAT)); + if ((_flags & eSquishFlags.kDxt1) != 0) + { + ptr4->ddpfPixelFormat.dwFourCC = 827611204u; + } + else if ((_flags & eSquishFlags.kDxt3) != 0) + { + ptr4->ddpfPixelFormat.dwFourCC = 861165636u; + } + else if ((_flags & eSquishFlags.kDxt5) != 0) + { + ptr4->ddpfPixelFormat.dwFourCC = 894720068u; + } + ptr4->ddpfPixelFormat.dwFlags = 4u; + ptr4->ddsCaps.dwCaps1 = 4096u; + } + return array; + } + + private void compileButton_Click(object sender, EventArgs e) + { + string extension = Program.MachineType.Extension; + if (Program.Studio) + { + extension = ".zip"; + } + string name = Path.Combine(Program.OutputDir, Path.ChangeExtension(Path.GetFileName(m_assets.FileName), extension)); + switch (Program.MachineType.OutputType) + { + case eOutputType.eWAD: + IFFSaver.Save(m_assets, name); + break; + case eOutputType.eHTML5: + HTML5Saver.Save(m_assets, name); + break; + } + } + + private void ToolStripMenuItem_MachineSelect_Click(object sender, EventArgs e) + { + m_currentMachineSelected.Checked = false; + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.SetMachineType(toolStripMenuItem.Text); + toolStripMenuItem.Checked = true; + m_currentMachineSelected = toolStripMenuItem; + Text = string.Format("GMAssetCompiler : {0} : {1}", Program.MachineType.Name, m_assets.FileName); + foreach (ToolStripMenuItem dropDownItem in toolStripOpaqueTextureButton.DropDownItems) + { + dropDownItem.Checked = (Program.TextureType[0] == (eTexType)dropDownItem.Tag); + if (dropDownItem.Checked) + { + m_currentTextureSelected[0] = dropDownItem; + } + } + foreach (ToolStripMenuItem dropDownItem2 in toolStripAlphaTextureButton.DropDownItems) + { + dropDownItem2.Checked = (Program.TextureType[1] == (eTexType)dropDownItem2.Tag); + if (dropDownItem2.Checked) + { + m_currentTextureSelected[1] = dropDownItem2; + } + } + } + + private void toolStripButton1_Click(object sender, EventArgs e) + { + string text = SearchBox.Text; + Console.WriteLine("------------- Finding '{0}' ----------------------", text); + foreach (KeyValuePair script in m_assets.Scripts) + { + GMScript value = script.Value; + if (value != null && !string.IsNullOrEmpty(value.Script) && value.Script.Contains(text)) + { + Console.WriteLine("Found in script - {0}", script.Key); + } + } + foreach (KeyValuePair @object in m_assets.Objects) + { + GMObject value2 = @object.Value; + if (value2 != null) + { + foreach (IList> @event in value2.Events) + { + foreach (KeyValuePair item in @event) + { + GMEvent value3 = item.Value; + foreach (GMAction action in value3.Actions) + { + foreach (string arg in action.Args) + { + if (!string.IsNullOrEmpty(arg) && arg.Contains(text)) + { + Console.WriteLine("Found in object {0} in event {1} action {2}", @object.Key, item.Key, action.Name); + } + } + if (!string.IsNullOrEmpty(action.Code) && action.Code.Contains(text)) + { + Console.WriteLine("Found in object {0} in event {1} action {2}", @object.Key, item.Key, action.Name); + } + } + } + } + } + } + } + + private void ToolStripMenuItem_OpaqueTextureSelect_Click(object sender, EventArgs e) + { + ToolStripMenuItem_TextureSelect_Click(sender, e, 0); + } + + private void ToolStripMenuItem_AlphaTextureSelect_Click(object sender, EventArgs e) + { + ToolStripMenuItem_TextureSelect_Click(sender, e, 1); + } + + private void ToolStripMenuItem_TextureSelect_Click(object sender, EventArgs e, int n) + { + m_currentTextureSelected[n].Checked = false; + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.TextureType[n] = (eTexType)toolStripMenuItem.Tag; + toolStripMenuItem.Checked = true; + m_currentTextureSelected[n] = toolStripMenuItem; + } + + private void writeTexturesToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.WriteTextures = !Program.WriteTextures; + toolStripMenuItem.Checked = Program.WriteTextures; + } + + private void writeWavsToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.WriteWaves = !Program.WriteWaves; + toolStripMenuItem.Checked = Program.WriteWaves; + } + + private void separateAlphaOpaqueTexturesToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.SeparateOpaqueAndAlpha = !Program.SeparateOpaqueAndAlpha; + toolStripMenuItem.Checked = Program.SeparateOpaqueAndAlpha; + } + + private void noCacheStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.NoCache = !Program.NoCache; + toolStripMenuItem.Checked = Program.NoCache; + } + + private void verboseToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.Verbose = !Program.Verbose; + toolStripMenuItem.Checked = Program.Verbose; + } + + private void obfuscateToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.DoObfuscate = !Program.DoObfuscate; + toolStripMenuItem.Checked = Program.DoObfuscate; + } + + private void prettyPrintingToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.ObfuscatePrettyPrint = !Program.ObfuscatePrettyPrint; + toolStripMenuItem.Checked = Program.ObfuscatePrettyPrint; + } + + private void reToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.ObfuscateRemoveUnused = !Program.ObfuscateRemoveUnused; + toolStripMenuItem.Checked = Program.ObfuscateRemoveUnused; + } + + private void encodeStringsToolStripMenuItem_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.ObfuscateEncodeStrings = !Program.ObfuscateEncodeStrings; + toolStripMenuItem.Checked = Program.ObfuscateEncodeStrings; + } + + private void obfuscateToolStripMenuItem1_Click(object sender, EventArgs e) + { + ToolStripMenuItem toolStripMenuItem = sender as ToolStripMenuItem; + Program.ObfuscateObfuscate = !Program.ObfuscateObfuscate; + toolStripMenuItem.Checked = Program.ObfuscateObfuscate; + } + + protected override void Dispose(bool disposing) + { + if (disposing && components != null) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GMAssetCompiler.Form1)); + splitContainer1 = new System.Windows.Forms.SplitContainer(); + treeView1 = new System.Windows.Forms.TreeView(); + splitContainer2 = new System.Windows.Forms.SplitContainer(); + propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + pictureBox1 = new System.Windows.Forms.PictureBox(); + toolStrip1 = new System.Windows.Forms.ToolStrip(); + compileButton = new System.Windows.Forms.ToolStripButton(); + targetDDButton = new System.Windows.Forms.ToolStripDropDownButton(); + pSPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + windowsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + iOSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + androidToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + symbianToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + hTML5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + toolStripOpaqueTextureButton = new System.Windows.Forms.ToolStripDropDownButton(); + bitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + r8G8B8A8ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + dXTC5ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + pVRTCToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + pNGToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + toolStripAlphaTextureButton = new System.Windows.Forms.ToolStripDropDownButton(); + toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem(); + pNGToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton(); + writeTexturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + writeWavsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + separateAlphaOpaqueTexturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + noCacheStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + verboseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + obfuscateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + prettyPrintingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + RemoveUnusedFunctionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + encodeStringsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + SearchBox = new System.Windows.Forms.ToolStripTextBox(); + toolStripButton1 = new System.Windows.Forms.ToolStripButton(); + obfuscateToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + splitContainer1.Panel1.SuspendLayout(); + splitContainer1.Panel2.SuspendLayout(); + splitContainer1.SuspendLayout(); + splitContainer2.Panel1.SuspendLayout(); + splitContainer2.Panel2.SuspendLayout(); + splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + toolStrip1.SuspendLayout(); + SuspendLayout(); + splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + splitContainer1.Location = new System.Drawing.Point(0, 25); + splitContainer1.Name = "splitContainer1"; + splitContainer1.Panel1.Controls.Add(treeView1); + splitContainer1.Panel2.Controls.Add(splitContainer2); + splitContainer1.Size = new System.Drawing.Size(921, 633); + splitContainer1.SplitterDistance = 173; + splitContainer1.TabIndex = 0; + treeView1.Dock = System.Windows.Forms.DockStyle.Fill; + treeView1.Location = new System.Drawing.Point(0, 0); + treeView1.Name = "treeView1"; + treeView1.Size = new System.Drawing.Size(173, 633); + treeView1.TabIndex = 0; + treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeView1_AfterSelect); + splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + splitContainer2.Location = new System.Drawing.Point(0, 0); + splitContainer2.Name = "splitContainer2"; + splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; + splitContainer2.Panel1.Controls.Add(propertyGrid1); + splitContainer2.Panel2.Controls.Add(pictureBox1); + splitContainer2.Size = new System.Drawing.Size(744, 633); + splitContainer2.SplitterDistance = 371; + splitContainer2.TabIndex = 0; + propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + propertyGrid1.Location = new System.Drawing.Point(0, 0); + propertyGrid1.Name = "propertyGrid1"; + propertyGrid1.Size = new System.Drawing.Size(744, 371); + propertyGrid1.TabIndex = 0; + pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; + pictureBox1.Location = new System.Drawing.Point(0, 0); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new System.Drawing.Size(744, 258); + pictureBox1.TabIndex = 0; + pictureBox1.TabStop = false; + toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[7] + { + compileButton, + targetDDButton, + toolStripOpaqueTextureButton, + toolStripAlphaTextureButton, + toolStripDropDownButton1, + SearchBox, + toolStripButton1 + }); + toolStrip1.Location = new System.Drawing.Point(0, 0); + toolStrip1.Name = "toolStrip1"; + toolStrip1.Size = new System.Drawing.Size(921, 25); + toolStrip1.TabIndex = 1; + toolStrip1.Text = "toolStrip1"; + compileButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + compileButton.Image = (System.Drawing.Image)resources.GetObject("compileButton.Image"); + compileButton.ImageTransparentColor = System.Drawing.Color.Magenta; + compileButton.Name = "compileButton"; + compileButton.Size = new System.Drawing.Size(56, 22); + compileButton.Text = "Compile"; + compileButton.Click += new System.EventHandler(compileButton_Click); + targetDDButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + targetDDButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[6] + { + pSPToolStripMenuItem, + windowsToolStripMenuItem, + iOSToolStripMenuItem, + androidToolStripMenuItem, + symbianToolStripMenuItem, + hTML5ToolStripMenuItem + }); + targetDDButton.Image = (System.Drawing.Image)resources.GetObject("targetDDButton.Image"); + targetDDButton.ImageTransparentColor = System.Drawing.Color.Magenta; + targetDDButton.Name = "targetDDButton"; + targetDDButton.Size = new System.Drawing.Size(54, 22); + targetDDButton.Text = "Target"; + pSPToolStripMenuItem.Name = "pSPToolStripMenuItem"; + pSPToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + pSPToolStripMenuItem.Tag = ""; + pSPToolStripMenuItem.Text = "PSP"; + pSPToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + windowsToolStripMenuItem.Name = "windowsToolStripMenuItem"; + windowsToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + windowsToolStripMenuItem.Text = "Windows"; + windowsToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + iOSToolStripMenuItem.Name = "iOSToolStripMenuItem"; + iOSToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + iOSToolStripMenuItem.Tag = ""; + iOSToolStripMenuItem.Text = "iOS"; + iOSToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + androidToolStripMenuItem.Name = "androidToolStripMenuItem"; + androidToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + androidToolStripMenuItem.Text = "Android"; + androidToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + symbianToolStripMenuItem.Name = "symbianToolStripMenuItem"; + symbianToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + symbianToolStripMenuItem.Text = "Symbian"; + symbianToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + hTML5ToolStripMenuItem.Name = "hTML5ToolStripMenuItem"; + hTML5ToolStripMenuItem.Size = new System.Drawing.Size(123, 22); + hTML5ToolStripMenuItem.Text = "HTML5"; + hTML5ToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_MachineSelect_Click); + toolStripOpaqueTextureButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + toolStripOpaqueTextureButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[5] + { + bitToolStripMenuItem, + r8G8B8A8ToolStripMenuItem, + dXTC5ToolStripMenuItem, + pVRTCToolStripMenuItem, + pNGToolStripMenuItem + }); + toolStripOpaqueTextureButton.Image = (System.Drawing.Image)resources.GetObject("toolStripOpaqueTextureButton.Image"); + toolStripOpaqueTextureButton.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripOpaqueTextureButton.Name = "toolStripOpaqueTextureButton"; + toolStripOpaqueTextureButton.Size = new System.Drawing.Size(133, 22); + toolStripOpaqueTextureButton.Text = "Opaque Texture Type"; + bitToolStripMenuItem.Name = "bitToolStripMenuItem"; + bitToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + bitToolStripMenuItem.Tag = "e4444"; + bitToolStripMenuItem.Text = "16bit - R4G4B4A4"; + bitToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_OpaqueTextureSelect_Click); + r8G8B8A8ToolStripMenuItem.Name = "r8G8B8A8ToolStripMenuItem"; + r8G8B8A8ToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + r8G8B8A8ToolStripMenuItem.Tag = "eRaw"; + r8G8B8A8ToolStripMenuItem.Text = "32bit - R8G8B8A8"; + r8G8B8A8ToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_OpaqueTextureSelect_Click); + dXTC5ToolStripMenuItem.Name = "dXTC5ToolStripMenuItem"; + dXTC5ToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + dXTC5ToolStripMenuItem.Tag = "eDXT"; + dXTC5ToolStripMenuItem.Text = "DXTC5"; + dXTC5ToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_OpaqueTextureSelect_Click); + pVRTCToolStripMenuItem.Name = "pVRTCToolStripMenuItem"; + pVRTCToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + pVRTCToolStripMenuItem.Tag = "ePVR"; + pVRTCToolStripMenuItem.Text = "PVRTC"; + pVRTCToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_OpaqueTextureSelect_Click); + pNGToolStripMenuItem.Name = "pNGToolStripMenuItem"; + pNGToolStripMenuItem.Size = new System.Drawing.Size(165, 22); + pNGToolStripMenuItem.Tag = "ePNG"; + pNGToolStripMenuItem.Text = "PNG"; + pNGToolStripMenuItem.Click += new System.EventHandler(ToolStripMenuItem_OpaqueTextureSelect_Click); + toolStripAlphaTextureButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + toolStripAlphaTextureButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[5] + { + toolStripMenuItem1, + toolStripMenuItem2, + toolStripMenuItem3, + toolStripMenuItem4, + pNGToolStripMenuItem1 + }); + toolStripAlphaTextureButton.Image = (System.Drawing.Image)resources.GetObject("toolStripAlphaTextureButton.Image"); + toolStripAlphaTextureButton.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripAlphaTextureButton.Name = "toolStripAlphaTextureButton"; + toolStripAlphaTextureButton.Size = new System.Drawing.Size(122, 22); + toolStripAlphaTextureButton.Text = "Alpha Texture Type"; + toolStripMenuItem1.Name = "toolStripMenuItem1"; + toolStripMenuItem1.Size = new System.Drawing.Size(165, 22); + toolStripMenuItem1.Tag = "e4444"; + toolStripMenuItem1.Text = "16bit - R4G4B4A4"; + toolStripMenuItem1.Click += new System.EventHandler(ToolStripMenuItem_AlphaTextureSelect_Click); + toolStripMenuItem2.Name = "toolStripMenuItem2"; + toolStripMenuItem2.Size = new System.Drawing.Size(165, 22); + toolStripMenuItem2.Tag = "eRaw"; + toolStripMenuItem2.Text = "32bit - R8G8B8A8"; + toolStripMenuItem2.Click += new System.EventHandler(ToolStripMenuItem_AlphaTextureSelect_Click); + toolStripMenuItem3.Name = "toolStripMenuItem3"; + toolStripMenuItem3.Size = new System.Drawing.Size(165, 22); + toolStripMenuItem3.Tag = "eDXT"; + toolStripMenuItem3.Text = "DXTC5"; + toolStripMenuItem3.Click += new System.EventHandler(ToolStripMenuItem_AlphaTextureSelect_Click); + toolStripMenuItem4.Name = "toolStripMenuItem4"; + toolStripMenuItem4.Size = new System.Drawing.Size(165, 22); + toolStripMenuItem4.Tag = "ePVR"; + toolStripMenuItem4.Text = "PVRTC"; + toolStripMenuItem4.Click += new System.EventHandler(ToolStripMenuItem_AlphaTextureSelect_Click); + pNGToolStripMenuItem1.Name = "pNGToolStripMenuItem1"; + pNGToolStripMenuItem1.Size = new System.Drawing.Size(165, 22); + pNGToolStripMenuItem1.Tag = "ePNG"; + pNGToolStripMenuItem1.Text = "PNG"; + pNGToolStripMenuItem1.Click += new System.EventHandler(ToolStripMenuItem_AlphaTextureSelect_Click); + toolStripDropDownButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + toolStripDropDownButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[6] + { + writeTexturesToolStripMenuItem, + writeWavsToolStripMenuItem, + separateAlphaOpaqueTexturesToolStripMenuItem, + noCacheStripMenuItem, + verboseToolStripMenuItem, + obfuscateToolStripMenuItem + }); + toolStripDropDownButton1.Image = (System.Drawing.Image)resources.GetObject("toolStripDropDownButton1.Image"); + toolStripDropDownButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripDropDownButton1.Name = "toolStripDropDownButton1"; + toolStripDropDownButton1.Size = new System.Drawing.Size(62, 22); + toolStripDropDownButton1.Text = "Options"; + writeTexturesToolStripMenuItem.Name = "writeTexturesToolStripMenuItem"; + writeTexturesToolStripMenuItem.Size = new System.Drawing.Size(268, 22); + writeTexturesToolStripMenuItem.Text = "Write Textures"; + writeTexturesToolStripMenuItem.Click += new System.EventHandler(writeTexturesToolStripMenuItem_Click); + writeWavsToolStripMenuItem.Name = "writeWavsToolStripMenuItem"; + writeWavsToolStripMenuItem.Size = new System.Drawing.Size(268, 22); + writeWavsToolStripMenuItem.Text = "Write Wavs"; + writeWavsToolStripMenuItem.Click += new System.EventHandler(writeWavsToolStripMenuItem_Click); + separateAlphaOpaqueTexturesToolStripMenuItem.Name = "separateAlphaOpaqueTexturesToolStripMenuItem"; + separateAlphaOpaqueTexturesToolStripMenuItem.Size = new System.Drawing.Size(268, 22); + separateAlphaOpaqueTexturesToolStripMenuItem.Text = "Separate Alpha and Opaque Textures"; + separateAlphaOpaqueTexturesToolStripMenuItem.Click += new System.EventHandler(separateAlphaOpaqueTexturesToolStripMenuItem_Click); + noCacheStripMenuItem.Name = "noCacheStripMenuItem"; + noCacheStripMenuItem.Size = new System.Drawing.Size(268, 22); + noCacheStripMenuItem.Text = "No-cache (html5)"; + noCacheStripMenuItem.Click += new System.EventHandler(noCacheStripMenuItem_Click); + verboseToolStripMenuItem.Name = "verboseToolStripMenuItem"; + verboseToolStripMenuItem.Size = new System.Drawing.Size(268, 22); + verboseToolStripMenuItem.Text = "Verbose"; + verboseToolStripMenuItem.Click += new System.EventHandler(verboseToolStripMenuItem_Click); + obfuscateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[4] + { + prettyPrintingToolStripMenuItem, + RemoveUnusedFunctionsToolStripMenuItem, + encodeStringsToolStripMenuItem, + obfuscateToolStripMenuItem1 + }); + obfuscateToolStripMenuItem.Name = "obfuscateToolStripMenuItem"; + obfuscateToolStripMenuItem.Size = new System.Drawing.Size(268, 22); + obfuscateToolStripMenuItem.Text = "Obfuscate"; + obfuscateToolStripMenuItem.Click += new System.EventHandler(obfuscateToolStripMenuItem_Click); + prettyPrintingToolStripMenuItem.Name = "prettyPrintingToolStripMenuItem"; + prettyPrintingToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + prettyPrintingToolStripMenuItem.Text = "Pretty Printing"; + prettyPrintingToolStripMenuItem.Click += new System.EventHandler(prettyPrintingToolStripMenuItem_Click); + RemoveUnusedFunctionsToolStripMenuItem.Name = "RemoveUnusedFunctionsToolStripMenuItem"; + RemoveUnusedFunctionsToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + RemoveUnusedFunctionsToolStripMenuItem.Text = "Remove Unused Functions"; + RemoveUnusedFunctionsToolStripMenuItem.Click += new System.EventHandler(reToolStripMenuItem_Click); + encodeStringsToolStripMenuItem.Name = "encodeStringsToolStripMenuItem"; + encodeStringsToolStripMenuItem.Size = new System.Drawing.Size(215, 22); + encodeStringsToolStripMenuItem.Text = "Encode Strings"; + encodeStringsToolStripMenuItem.Click += new System.EventHandler(encodeStringsToolStripMenuItem_Click); + SearchBox.Name = "SearchBox"; + SearchBox.Size = new System.Drawing.Size(150, 25); + toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + toolStripButton1.Image = (System.Drawing.Image)resources.GetObject("toolStripButton1.Image"); + toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; + toolStripButton1.Name = "toolStripButton1"; + toolStripButton1.Size = new System.Drawing.Size(46, 22); + toolStripButton1.Text = "Search"; + toolStripButton1.Click += new System.EventHandler(toolStripButton1_Click); + obfuscateToolStripMenuItem1.Name = "obfuscateToolStripMenuItem1"; + obfuscateToolStripMenuItem1.Size = new System.Drawing.Size(215, 22); + obfuscateToolStripMenuItem1.Text = "Obfuscate"; + obfuscateToolStripMenuItem1.Click += new System.EventHandler(obfuscateToolStripMenuItem1_Click); + base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + base.ClientSize = new System.Drawing.Size(921, 658); + base.Controls.Add(splitContainer1); + base.Controls.Add(toolStrip1); + base.Name = "Form1"; + Text = "GMAssetCompiler"; + splitContainer1.Panel1.ResumeLayout(false); + splitContainer1.Panel2.ResumeLayout(false); + splitContainer1.ResumeLayout(false); + splitContainer2.Panel1.ResumeLayout(false); + splitContainer2.Panel2.ResumeLayout(false); + splitContainer2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + toolStrip1.ResumeLayout(false); + toolStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/Form1.resx b/GMAC1098/GMAssetCompiler/Form1.resx new file mode 100644 index 0000000..946e56f --- /dev/null +++ b/GMAC1098/GMAssetCompiler/Form1.resx @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +text/microsoft-resx1.3System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089AAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIILAAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIILAAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIILAAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIILAAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIILAAEAAAD/////AQAAAAAAAAAMAgAAAFFTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0yLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAcwIAAAKJUE5HDQoaCgAAAA1JSERSAAAAEAAAABAIBgAAAB/z/2EAAAABc1JHQgCuzhzpAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAghJREFUOE+lk/tLU3EYxs8/EppdVSQwSrwikpQKhj+EaAjKaqQNhhdwKMNk4A1RFKMI0YVBROyXgZdUzEqTrZhTh9dCloiXKAdDEFEfz/PC/JogBh74cuCc83ye570cDee8NOrrehb+ObXdc7C89MHcNgVjkwf5td9w3zKB9NIxJJd8RKJxAPEGp1gfAfb2D3Da2dndRyC4i82tHfjXt7G4EkTk3Wf/B/AuBcQ5zfwFzrE1Edv7/Liebj0bQGeK3bN/0fpuSWIT+Mq5jGt3qhWANZ+MH4pNZ4ozKsYRV+jAhO8P2t7/0AFVCsCGHQccr5mx6Uwxo3+a/C0Nv5pWqQDsdgjAiPfKx+W49Oismc/oTPGgewPWzllcSS1TAI6KgHl/UIQ9H37BMbqK6Kx6tOjx2TCeDsdP9H5dQ8XzGVxOMSsA50xxbo1bxJOLAbzu96PyhQ838+wS/e3wCjRNk/dPW7y4lGRSAC5Jge073ugvGZd3m30ejxo9Mr4bOe2o1+subZ8WiKHBg4jEYgXgqOgYEvNjU6sX2To44XGfAMLjDEgxfUbSkyGBXIw3KgDXc8C1Ls6smTU+sLr0tR1BbG4XojJsetctEjsmu1l2gMCjVeZuMzIP62NJfEZxdGadiDm20P1C7EOE3S5SAM6Zu81Ok84loYCjYrfpzJoZm84Uh90qVIDz/NGH0AEgNQb7UmkAAAAASUVORK5CYIIL \ No newline at end of file diff --git a/GMAC1098/GMAssetCompiler/GMAction.cs b/GMAC1098/GMAssetCompiler/GMAction.cs new file mode 100644 index 0000000..d15bcde --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMAction.cs @@ -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 ArgTypes + { + get; + private set; + } + + public int Who + { + get; + private set; + } + + public bool Relative + { + get; + private set; + } + + public IList 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(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(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(1); + ArgTypes.Add(eArgTypes.ARG_STRING); + Who = -1; + Relative = false; + Args = new List(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 _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 item = new KeyValuePair(Name, value); + _assets.Scripts.Add(item); + countScript++; + ExeType = eExecuteTypes.EXE_FUNCTION; + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMAssets.cs b/GMAC1098/GMAssetCompiler/GMAssets.cs new file mode 100644 index 0000000..bffc041 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMAssets.cs @@ -0,0 +1,779 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace GMAssetCompiler +{ + public class GMAssets + { + private delegate T Factory(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 Extensions + { + get; + private set; + } + + public IList Triggers + { + get; + private set; + } + + public IList> Sounds + { + get; + private set; + } + + public IList> Sprites + { + get; + private set; + } + + public IList> Backgrounds + { + get; + private set; + } + + public IList> Paths + { + get; + private set; + } + + public IList> Scripts + { + get; + private set; + } + + public IList> Fonts + { + get; + private set; + } + + public IList> TimeLines + { + get; + private set; + } + + public IList> Objects + { + get; + private set; + } + + public IList> Rooms + { + get; + private set; + } + + public IList> DataFiles + { + get; + private set; + } + + public IList Libraries + { + get; + private set; + } + + public IList 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(); + Triggers = new List(); + Sounds = new List>(); + Sprites = new List>(); + Backgrounds = new List>(); + Paths = new List>(); + Scripts = new List>(); + Fonts = new List>(); + TimeLines = new List>(); + Objects = new List>(); + Rooms = new List>(); + DataFiles = new List>(); + Libraries = new List(); + RoomOrder = new List(); + 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(IList> _list, Stream _s, Factory _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(key, value)); + } + } + } + + private void LoadGMK_GMDataFile(IList> _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(key, value)); + } + } + + private void LoadGMK_GMExtension(IList _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(); + Triggers = new List(); + Sounds = new List>(); + Sprites = new List>(); + Backgrounds = new List>(); + Paths = new List>(); + Scripts = new List>(); + Fonts = new List>(); + TimeLines = new List>(); + Objects = new List>(); + Rooms = new List>(); + DataFiles = new List>(); + Libraries = new List(); + RoomOrder = new List(); + 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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMSound value = new GMSound(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMSprite value = new GMSprite(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMBackground value = new GMBackground(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMPath value = new GMPath(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMScript value = new GMScript(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = s.ReadString(); + GMFont value = new GMFont(this, s); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = stream.ReadString(); + GMTimeLine value = new GMTimeLine(this, stream); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = stream.ReadString(); + GMObject value = new GMObject(this, stream); + item = new KeyValuePair(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 item = default(KeyValuePair); + if (flag) + { + string key = stream.ReadString(); + GMRoom value = new GMRoom(this, stream); + item = new KeyValuePair(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 keyValuePair = default(KeyValuePair); + GMDataFile value = new GMDataFile(this, stream); + keyValuePair = new KeyValuePair("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(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 @object in Objects) + { + GMObject value = @object.Value; + if (value != null) + { + foreach (IList> @event in value.Events) + { + using (IEnumerator> enumerator3 = @event.GetEnumerator()) + { + while (enumerator3.MoveNext()) + { + RemoveEventDND(_ev: enumerator3.Current.Value, _name: @object.Key); + } + } + } + } + } + foreach (KeyValuePair timeLine in TimeLines) + { + GMTimeLine value3 = timeLine.Value; + if (value3 != null) + { + using (IEnumerator> 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); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMBack.cs b/GMAC1098/GMAssetCompiler/GMBack.cs new file mode 100644 index 0000000..5646221 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMBack.cs @@ -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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMBackground.cs b/GMAC1098/GMAssetCompiler/GMBackground.cs new file mode 100644 index 0000000..b12df27 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMBackground.cs @@ -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; + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMBitmap32.cs b/GMAC1098/GMAssetCompiler/GMBitmap32.cs new file mode 100644 index 0000000..3a9feb1 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMBitmap32.cs @@ -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); + } + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMDataFile.cs b/GMAC1098/GMAssetCompiler/GMDataFile.cs new file mode 100644 index 0000000..b27b9b0 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMDataFile.cs @@ -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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMEvent.cs b/GMAC1098/GMAssetCompiler/GMEvent.cs new file mode 100644 index 0000000..f6bcff4 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMEvent.cs @@ -0,0 +1,380 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace GMAssetCompiler +{ + public class GMEvent + { + private static Stack RelativeStack = new Stack(); + + private static bool conditionVar = false; + + public List Actions + { + get; + set; + } + + public GMEvent(GMAssets _a, Stream _stream) + { + _stream.ReadInteger(); + int num = _stream.ReadInteger(); + Actions = new List(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> _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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMExtension.cs b/GMAC1098/GMAssetCompiler/GMExtension.cs new file mode 100644 index 0000000..c41399f --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMExtension.cs @@ -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 Includes + { + get; + private set; + } + + public IList ExtensionDLL + { + get; + private set; + } + + public GMExtension(GMAssets _a, Stream _s) + { + _s.ReadInteger(); + Name = _s.ReadString(); + Folder = _s.ReadString(); + Includes = new List(); + 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(); + for (int j = 0; j < Includes.Count; j++) + { + if (Includes[j].Kind != 3) + { + ExtensionDLL.Add(memoryStream.ReadCompressedStream()); + } + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMExtensionConstant.cs b/GMAC1098/GMAssetCompiler/GMExtensionConstant.cs new file mode 100644 index 0000000..e96731c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMExtensionConstant.cs @@ -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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMExtensionFunction.cs b/GMAC1098/GMAssetCompiler/GMExtensionFunction.cs new file mode 100644 index 0000000..1c49e6a --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMExtensionFunction.cs @@ -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 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 num = _s.ReadInteger(); + for (int i = 0; i <= 16; i++) + { + int item = _s.ReadInteger(); + if (i < num) + { + Args.Add(item); + } + } + ReturnType = _s.ReadInteger(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMExtensionInclude.cs b/GMAC1098/GMAssetCompiler/GMExtensionInclude.cs new file mode 100644 index 0000000..4736d81 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMExtensionInclude.cs @@ -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 Functions + { + get; + private set; + } + + public IList 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(); + int num = _s.ReadInteger(); + for (int i = 0; i < num; i++) + { + Functions.Add(new GMExtensionFunction(_s)); + } + Constants = new List(); + 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; + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMFont.cs b/GMAC1098/GMAssetCompiler/GMFont.cs new file mode 100644 index 0000000..ad193c7 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMFont.cs @@ -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 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(); + 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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMGlyph.cs b/GMAC1098/GMAssetCompiler/GMGlyph.cs new file mode 100644 index 0000000..f3a0ba2 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMGlyph.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMHelp.cs b/GMAC1098/GMAssetCompiler/GMHelp.cs new file mode 100644 index 0000000..25c944f --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMHelp.cs @@ -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(); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMInstance.cs b/GMAC1098/GMAssetCompiler/GMInstance.cs new file mode 100644 index 0000000..72cc54d --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMInstance.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GML2JavaScript.cs b/GMAC1098/GMAssetCompiler/GML2JavaScript.cs new file mode 100644 index 0000000..47d4ee2 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GML2JavaScript.cs @@ -0,0 +1,1138 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; + +namespace GMAssetCompiler +{ + internal class GML2JavaScript + { + private static GMLCode ms_code; + + private static GMAssets ms_assets; + + private static int ms_numErrors; + + private static bool ms_error; + + public static string ms_varPrefix = "gml"; + + public static Dictionary ms_globals = new Dictionary(); + + private static Dictionary ms_locals = new Dictionary(); + + private static Dictionary ms_arguments = new Dictionary(); + + private static Stack ms_thisName = new Stack(); + + private static Stack ms_otherName = new Stack(); + + private static Stack ms_breakContext = new Stack(); + + private static int ms_unique = 0; + + private static int ms_statements = 0; + + private static Dictionary ms_arrays = new Dictionary(); + + private static StringBuilder ms_sbVariableName = new StringBuilder(); + + private static string GetUniqueName() + { + return string.Format("__yy__v{0}", ms_unique++); + } + + public static void Error(string _errorMessage, GMLToken _token) + { + if (!Program.InhibitErrorOutput) + { + int num = 1; + for (int i = 0; i < _token.Index; i++) + { + if (ms_code.Code[i] == '\n') + { + num++; + } + } + Console.WriteLine("Error : {0}({1}) : {2}", ms_code.Name, num, _errorMessage); + } + ms_numErrors++; + ms_error = true; + Program.ExitCode = 1; + } + + private static eType CompileUnary(GMLToken _tok, TextWriter _sw) + { + eType result = eType.eGMLT_Unknown; + switch (_tok.Id) + { + case 203: + _sw.Write("!("); + if (CompileExpression(_tok.Children[0], _sw) != 0) + { + _sw.Write(" > 0.5)"); + } + else + { + _sw.Write(")"); + } + result = eType.eGMLT_Bool; + break; + case 210: + case 211: + case 220: + _sw.Write(_tok.Text); + result = CompileExpression(_tok.Children[0], _sw); + break; + } + return result; + } + + private static eType CompileBinary(GMLToken _tok, TextWriter _sw) + { + eType result = 0; + bool flag = false; + switch (_tok.Children[1].Token) + { + case eToken.eDiv: + _sw.Write("(~~"); + break; + case eToken.eAnd: + case eToken.eOr: + flag = true; + break; + } + _sw.Write("("); + if (flag) + { + _sw.Write("("); + } + eType eType = CompileExpression(_tok.Children[0], _sw); + if (flag && eType != 0) + { + _sw.Write(" > 0.5"); + } + if (flag) + { + _sw.Write(")"); + } + for (int i = 1; i < _tok.Children.Count; i += 2) + { + switch (_tok.Children[i].Token) + { + case eToken.eNot: + _sw.Write("!"); + break; + case eToken.eBitXor: + _sw.Write("^"); + break; + case eToken.eDiv: + _sw.Write("/"); + break; + case eToken.eMod: + _sw.Write("%"); + break; + case eToken.eAnd: + _sw.Write("&&"); + break; + case eToken.eOr: + _sw.Write("||"); + break; + case eToken.eNotEqual: + _sw.Write("!="); + break; + case eToken.eAssign: + case eToken.eEqual: + _sw.Write("=="); + break; + default: + _sw.Write(_tok.Children[i].Text); + break; + } + if (flag) + { + _sw.Write("("); + } + eType eType2 = CompileExpression(_tok.Children[i + 1], _sw); + if (flag && eType2 != 0) + { + _sw.Write(" > 0.5"); + } + if (flag) + { + _sw.Write(")"); + } + switch (_tok.Children[i].Token) + { + case eToken.eAssign: + case eToken.eAnd: + case eToken.eOr: + case eToken.eLess: + case eToken.eLessEqual: + case eToken.eEqual: + case eToken.eNotEqual: + case eToken.eGreaterEqual: + case eToken.eGreater: + result = eType.eGMLT_Bool; + break; + } + eType = eType2; + } + _sw.Write(")"); + eToken token = _tok.Children[1].Token; + if (token == eToken.eDiv) + { + _sw.Write(")"); + } + return result; + } + + private static eType CompileConstant(GMLToken _tok, TextWriter _sw) + { + bool _setFunc = false; + eType result = eType.eGMLT_Var; + switch (_tok.Text) + { + case "global": + case "other": + case "self": + CompileVariable(_tok, _sw, false, out _setFunc); + break; + default: + switch (_tok.Value.Kind) + { + case eKind.eConstant: + _sw.Write("g_gmlConst.{0}", _tok.Value.ValueS); + break; + case eKind.eNone: + _sw.Write("null"); + break; + case eKind.eNumber: + if (_tok.Value.ValueI < 0.0) + { + _sw.Write("("); + } + _sw.Write("{0}", Convert.ToString(_tok.Value.ValueI, CultureInfo.InvariantCulture.NumberFormat)); + if (_tok.Value.ValueI < 0.0) + { + _sw.Write(")"); + } + result = ((!(_tok.Text == "true") && !(_tok.Text == "false")) ? eType.eGMLT_Real : eType.eGMLT_Bool); + break; + case eKind.eString: + { + string text = _tok.Value.ValueS.Replace("\\", "\\\\"); + text = text.Replace("\"", "\\\""); + text = text.Replace(Environment.NewLine, "#"); + text = text.Replace(new string('\n', 1), "#"); + _sw.Write("\"{0}\"", text); + result = eType.eGMLT_String; + break; + } + } + break; + } + return result; + } + + private static eType CompileExpression(GMLToken _tok, TextWriter _sw) + { + eType result = eType.eGMLT_Unknown; + bool _setFunc = false; + switch (_tok.Token) + { + case eToken.eConstant: + result = CompileConstant(_tok, _sw); + break; + case eToken.eBinary: + result = CompileBinary(_tok, _sw); + break; + case eToken.eUnary: + result = CompileUnary(_tok, _sw); + break; + case eToken.eFunction: + result = CompileFunction(_tok, _sw); + break; + case eToken.eVariable: + case eToken.eDot: + result = CompileVariable(_tok, _sw, false, out _setFunc); + break; + } + return result; + } + + private static void CompileSimpleVariable(GMLToken _tok, StringWriter _sw, bool _lvalue, out bool _setFunc, bool _inhibitExpansion) + { + string text = null; + string text2 = _tok.Text; + GMLVariable value = null; + if (!GMLCompile.ms_builtins.TryGetValue(text2, out value)) + { + GMLCompile.ms_builtinsLocal.TryGetValue(text2, out value); + } + _setFunc = false; + if (value != null) + { + if (_lvalue && value.setFunction != null) + { + text2 = string.Format("{0}( ", value.setFunction); + _setFunc = true; + } + else if (!_lvalue && value.getFunction != null) + { + text2 = string.Format("{0}()", value.getFunction); + } + } + else + { + text2 = ms_varPrefix + text2; + } + text = text2; + if (!_inhibitExpansion && _tok.Id < 100000 && GMLCompile.ms_builtins.TryGetValue(_tok.Text, out value) && !ms_arguments.TryGetValue(_tok.Text, out text)) + { + string empty = string.Empty; + empty = ((!(text2 == "argument_count")) ? string.Format("g_pBuiltIn.{0}", text2) : string.Format("({0}.arguments.length-2)", ms_code.Name)); + _sw.Write(empty); + } + else if (!_inhibitExpansion && ms_globals.TryGetValue(_tok.Text, out text)) + { + string value2 = string.Format("global.{0}", text2); + _sw.Write(value2); + } + else if (_inhibitExpansion || ms_locals.TryGetValue(text2, out text) || ms_arguments.TryGetValue(_tok.Text, out text) || string.IsNullOrEmpty(ms_thisName.Peek())) + { + _sw.Write(text); + } + else if (!_inhibitExpansion && GMLCompile.Find(ms_assets.Objects, _tok.Text) >= 0) + { + _sw.Write(GMLCompile.Find(ms_assets.Objects, _tok.Text).ToString()); + } + else + { + string value3 = string.Format("{0}.{1}", ms_thisName.Peek(), text2); + _sw.Write(value3); + } + bool flag = false; + string value4 = "]"; + string text3 = string.Empty; + if (_tok.Children.Count > 0) + { + string text4 = _sw.GetStringBuilder().ToString(); + if (text4 == "g_pBuiltIn.instance_id") + { + _sw.GetStringBuilder().Length = 0; + _sw.Write("g_pBuiltIn.get_instance_id("); + value4 = ")"; + flag = true; + } + else if (text4 == "g_pBuiltIn.argument") + { + _sw.GetStringBuilder().Length = 0; + _sw.Write("{0}.arguments[", ms_code.Name); + text3 = "2+"; + flag = true; + } + else + { + int num = text4.LastIndexOf('.'); + string arg = (num < 0) ? "_inst" : text4.Substring(0, num); + string arg2 = (num < 0) ? text4 : text4.Substring(num + 1, text4.Length - (num + 1)); + _sw.GetStringBuilder().Length = 0; + _setFunc = _lvalue; + if (_lvalue) + { + string value5 = string.Format("array_set_{0}D( {1}, \"__{2}__\" ", _tok.Children.Count, arg, arg2); + _sw.Write(value5); + } + else + { + string value6 = string.Format("array_get_{0}D( {1}, \"__{2}__\" ", _tok.Children.Count, arg, arg2); + _sw.Write(value6); + } + } + } + ms_thisName.Pop(); + if (_tok.Token != eToken.eVariable) + { + return; + } + int num2 = 0; + foreach (GMLToken child in _tok.Children) + { + if (!flag || num2 > 0) + { + _sw.Write(", "); + } + if (!string.IsNullOrEmpty(text3)) + { + _sw.Write("{0} (", text3); + } + CompileExpression(child, _sw); + if (!string.IsNullOrEmpty(text3)) + { + _sw.Write(")"); + } + num2++; + } + if (_tok.Children.Count > 0) + { + if (flag) + { + _sw.Write(value4); + } + else if (_lvalue) + { + _sw.Write(", "); + } + else + { + _sw.Write(" ) "); + } + } + } + + private static eType CompileVariable(GMLToken _tok, TextWriter _sw, bool _lvalue, out bool _setFunc) + { + eType result = eType.eGMLT_Var; + _setFunc = false; + int count = ms_thisName.Count; + ms_sbVariableName.Length = 0; + bool flag = false; + StringBuilder stringBuilder = new StringBuilder(); + StringWriter stringWriter = new StringWriter(stringBuilder); + switch (_tok.Token) + { + case eToken.eDot: + switch (_tok.Children.Count) + { + case 0: + case 1: + Error("Expecting expression after the '.' ", _tok); + break; + default: + { + string text = null; + switch (_tok.Children[0].Text) + { + case "global": + text = _tok.Children[0].Text; + stringWriter.Write(text); + flag = true; + break; + case "self": + stringWriter.Write(ms_thisName.Peek()); + flag = true; + break; + case "other": + stringWriter.Write(ms_otherName.Peek()); + flag = true; + break; + default: + switch (_tok.Children[0].Token) + { + case eToken.eConstant: + CompileConstant(_tok.Children[0], stringWriter); + break; + case eToken.eVariable: + ms_thisName.Push(ms_thisName.Peek()); + CompileSimpleVariable(_tok.Children[0], stringWriter, false, out _setFunc, false); + break; + case eToken.eFunction: + CompileFunction(_tok.Children[0], stringWriter); + break; + case eToken.eDot: + CompileVariable(_tok.Children[0], stringWriter, _lvalue, out _setFunc); + break; + default: + Console.WriteLine("This is a problem now!"); + break; + } + break; + } + for (int i = 1; i < _tok.Children.Count; i++) + { + if (!flag) + { + string arg = stringBuilder.ToString(); + stringBuilder.Length = 0; + stringWriter.Write("yyInst({0})", arg); + } + flag = false; + stringWriter.Write("."); + ms_thisName.Push(""); + CompileSimpleVariable(_tok.Children[i], stringWriter, i == _tok.Children.Count - 1 && _lvalue, out _setFunc, true); + } + break; + } + } + break; + case eToken.eVariable: + ms_thisName.Push(ms_thisName.Peek()); + CompileSimpleVariable(_tok, stringWriter, _lvalue, out _setFunc, false); + break; + case eToken.eConstant: + switch (_tok.Text) + { + default: + Error("constant is invalid here", _tok); + break; + case "self": + stringWriter.Write("{0}.id", ms_thisName.Peek()); + break; + case "other": + stringWriter.Write("{0}.id", ms_otherName.Peek()); + break; + } + break; + } + stringWriter.Close(); + _sw.Write(stringBuilder.ToString()); + if (count != ms_thisName.Count) + { + Error("Houston we have a problem!", _tok); + } + return result; + } + + private static void CompileVar(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count > 0) + { + _sw.Write("var "); + int num = 0; + foreach (GMLToken child in _tok.Children) + { + if (num != 0) + { + _sw.Write(","); + } + string text = ms_varPrefix + child.Text; + _sw.Write("{0}", text); + string value; + if (!ms_locals.TryGetValue(text, out value)) + { + ms_locals.Add(text, text); + } + num++; + } + } + } + + private static void CompileGlobalVar(GMLToken _tok, TextWriter _sw) + { + foreach (GMLToken child in _tok.Children) + { + ms_globals[child.Text] = child.Text; + } + } + + private static void CompileRepeat(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 2) + { + Error("malformed repeat statement", _tok); + } + string uniqueName = GetUniqueName(); + string uniqueName2 = GetUniqueName(); + _sw.Write("for( var {0}=0, {1}=", uniqueName, uniqueName2); + CompileExpression(_tok.Children[0], _sw); + _sw.Write("; {0}<{1}; {0}++) ", uniqueName, uniqueName2); + if (_tok.Children[1].Token == eToken.eBegin) + { + ms_statements++; + } + ms_breakContext.Push("CompileRepeat"); + CompileStatement(_tok.Children[1], _sw); + ms_breakContext.Pop(); + } + + private static void CompileIf(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count < 2) + { + Error("malformed if statement", _tok); + } + _sw.Write("if ("); + if (CompileExpression(_tok.Children[0], _sw) != 0) + { + _sw.Write(" > 0.5"); + } + _sw.Write(") {"); + if (_tok.Children.Count > 1) + { + if (_tok.Children[1].Token == eToken.eBegin) + { + ms_statements++; + } + CompileStatement(_tok.Children[1], _sw); + _sw.WriteLine(";}"); + if (_tok.Children.Count > 2) + { + _sw.Write(" else {"); + if (_tok.Children[2].Token == eToken.eBegin) + { + ms_statements++; + } + CompileStatement(_tok.Children[2], _sw); + _sw.Write(";}"); + } + } + else + { + Error("if requires a then statement", _tok); + } + } + + private static void CompileWhile(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 2) + { + Error("malformed while statement", _tok); + } + _sw.Write("while ("); + CompileExpression(_tok.Children[0], _sw); + _sw.Write(") "); + ms_breakContext.Push("CompileWhile"); + if (_tok.Children[1].Token == eToken.eBegin) + { + ms_statements++; + } + CompileStatement(_tok.Children[1], _sw); + ms_breakContext.Pop(); + } + + private static void CompileDo(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 2) + { + Error("malformed do statement", _tok); + } + _sw.WriteLine("do {"); + ms_breakContext.Push("CompileDo"); + CompileStatement(_tok.Children[0], _sw); + ms_breakContext.Pop(); + _sw.Write("} while( !("); + CompileExpression(_tok.Children[1], _sw); + _sw.WriteLine("))"); + } + + private static void CompileFor(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 4) + { + Error("malformed for statement", _tok); + } + _sw.Write("for ("); + CompileStatement(_tok.Children[0], _sw); + _sw.Write(" ; "); + CompileExpression(_tok.Children[1], _sw); + _sw.Write(" ; "); + CompileStatement(_tok.Children[2], _sw); + _sw.Write(") "); + if (_tok.Children[3].Token == eToken.eBegin) + { + ms_statements++; + } + ms_breakContext.Push("CompileFor"); + CompileStatement(_tok.Children[3], _sw); + ms_breakContext.Pop(); + } + + private static void CompileWith(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 2) + { + Error("malformed with statement", _tok); + } + if (_tok.Children[0].Token == eToken.eConstant && (_tok.Children[0].Text == "other" || _tok.Children[0].Text == "self")) + { + string item = string.Empty; + switch (_tok.Children[0].Text) + { + case "other": + item = ms_otherName.Peek(); + break; + case "self": + item = ms_thisName.Peek(); + break; + } + ms_otherName.Push(ms_thisName.Peek()); + ms_thisName.Push(item); + CompileStatement(_tok.Children[1], _sw); + if (_tok.Children[1].Token != eToken.eBegin) + { + _sw.Write(";"); + } + ms_thisName.Pop(); + ms_otherName.Pop(); + return; + } + _sw.WriteLine("{"); + string uniqueName = GetUniqueName(); + string uniqueName2 = GetUniqueName(); + string uniqueName3 = GetUniqueName(); + _sw.Write("var {0} = GetWithArray(", uniqueName); + CompileExpression(_tok.Children[0], _sw); + _sw.WriteLine(" );"); + _sw.WriteLine("for( var {0} in {1} ) {{", uniqueName2, uniqueName); + _sw.WriteLine(" var {0} = {1}[{2}];", uniqueName3, uniqueName, uniqueName2); + ms_otherName.Push(ms_thisName.Peek()); + ms_thisName.Push(uniqueName3); + ms_statements++; + ms_breakContext.Push("CompileWith"); + CompileStatement(_tok.Children[1], _sw); + ms_breakContext.Pop(); + if (_tok.Children[1].Token != eToken.eBegin) + { + _sw.Write(";"); + } + _sw.WriteLine("}"); + ms_thisName.Pop(); + ms_otherName.Pop(); + _sw.WriteLine("}"); + } + + private static void CompileSwitch(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count == 0) + { + Error("malformed switch statement", _tok); + } + _sw.Write("switch("); + CompileExpression(_tok.Children[0], _sw); + _sw.WriteLine(") {"); + ms_breakContext.Push("CompileSwitch"); + bool flag = false; + for (int i = 1; i < _tok.Children.Count; i++) + { + switch (_tok.Children[i].Token) + { + case eToken.eCase: + _sw.Write("case "); + CompileExpression(_tok.Children[i].Children[0], _sw); + _sw.WriteLine(":"); + flag = true; + break; + case eToken.eDefault: + _sw.WriteLine("default:"); + flag = true; + break; + case eToken.eBreak: + if (!flag) + { + Error("statement in a switch MUST appear after case or default", _tok.Children[i]); + break; + } + CompileStatement(_tok.Children[i], _sw); + _sw.WriteLine(";"); + flag = false; + break; + default: + if (!flag) + { + Error("statement in a switch MUST appear after case or default", _tok.Children[i]); + break; + } + CompileStatement(_tok.Children[i], _sw); + _sw.WriteLine(";"); + break; + } + } + _sw.Write("}"); + ms_breakContext.Pop(); + } + + private static eType CompileFunction(GMLToken _tok, TextWriter _sw) + { + eType result = eType.eGMLT_Var; + string text = _tok.Text; + int num = 0; + bool flag = false; + bool flag2 = false; + bool flag3 = false; + if (_tok.Id < 100000) + { + if (_tok.Text == "script_execute") + { + _sw.Write("JSON_game.Scripts[ "); + CompileExpression(_tok.Children[0], _sw); + _sw.Write("]( "); + flag = true; + flag2 = true; + flag3 = true; + } + else + { + int num2 = _tok.Id - GMLCompile.ms_id; + int index = (num2 >> 8) & 0xF; + int index2 = num2 >> 12; + if (_tok.Id > GMLCompile.ms_id && ms_assets.Extensions[index].Includes[index2].Kind == 2) + { + _sw.Write("gml_Script_{0}( ", _tok.Text); + flag = true; + flag2 = true; + } + else + { + GMLFunction value = null; + GMLCompile.ms_funcs.TryGetValue(text, out value); + _sw.Write("{0}( ", text); + flag = (value != null && value.InstanceFirstParam); + flag2 = (value != null && value.OtherSecondParam); + } + } + } + else + { + _sw.Write("gml_Script_{0}( ", _tok.Text); + flag = true; + flag2 = true; + } + if (flag) + { + if (!string.IsNullOrEmpty(ms_thisName.Peek())) + { + _sw.Write("{0} ", ms_thisName.Peek()); + num++; + } + else + { + Error("calling a function that needs an instance and no instance is available", _tok); + } + if (flag2) + { + if (!string.IsNullOrEmpty(ms_otherName.Peek())) + { + _sw.Write(", {0} ", ms_otherName.Peek()); + num++; + } + else + { + Error("calling a function that needs an \"other\" and no \"other\" is available", _tok); + } + } + } + foreach (GMLToken child in _tok.Children) + { + if ((flag3 && num < 2) || !flag3) + { + if (num != 0) + { + _sw.Write(", "); + } + CompileExpression(child, _sw); + } + num++; + flag3 = false; + } + _sw.Write(" )"); + return result; + } + + private static void CompileAssign(GMLToken _tok, TextWriter _sw) + { + if (_tok.Children.Count != 3) + { + Error("malformed assignment statement", _tok); + } + bool _setFunc = false; + CompileVariable(_tok.Children[0], _sw, true, out _setFunc); + if (!_setFunc) + { + switch (_tok.Children[1].Token) + { + case eToken.eAssignPlus: + case eToken.eAssignMinus: + case eToken.eAssignTimes: + case eToken.eAssignDivide: + case eToken.eAssignOr: + case eToken.eAssignAnd: + case eToken.eAssignXor: + _sw.Write(_tok.Children[1].Text); + CompileExpression(_tok.Children[2], _sw); + break; + case eToken.eAssign: + _sw.Write("="); + CompileExpression(_tok.Children[2], _sw); + break; + } + return; + } + switch (_tok.Children[1].Token) + { + case eToken.eAssignPlus: + case eToken.eAssignMinus: + case eToken.eAssignTimes: + case eToken.eAssignDivide: + case eToken.eAssignOr: + case eToken.eAssignAnd: + case eToken.eAssignXor: + CompileVariable(_tok.Children[0], _sw, false, out _setFunc); + _sw.Write(" {0} ", _tok.Children[1].Text[0]); + CompileExpression(_tok.Children[2], _sw); + break; + case eToken.eAssign: + CompileExpression(_tok.Children[2], _sw); + break; + } + _sw.Write(" )"); + } + + private static void CompileReturn(GMLToken _tok, TextWriter _sw) + { + _sw.Write("return "); + if (_tok.Children.Count > 0) + { + CompileExpression(_tok.Children[0], _sw); + } + } + + private static void CompileBreak(GMLToken _tok, TextWriter _sw) + { + if (ms_breakContext.Count > 0) + { + _sw.Write("break"); + } + else + { + _sw.Write("return"); + } + } + + private static void CompileExit(GMLToken _tok, TextWriter _sw) + { + _sw.Write("return"); + } + + private static void CompileContinue(GMLToken _tok, TextWriter _sw) + { + if (ms_breakContext.Count > 0) + { + _sw.Write("continue"); + } + else + { + _sw.Write("return"); + } + } + + private static void CompileStatement(GMLToken _tok, TextWriter _sw) + { + switch (_tok.Token) + { + case eToken.eVar: + CompileVar(_tok, _sw); + break; + case eToken.eGlobalVar: + CompileGlobalVar(_tok, _sw); + break; + case eToken.eBegin: + case eToken.eBlock: + CompileBlock(_tok, _sw); + break; + case eToken.eRepeat: + CompileRepeat(_tok, _sw); + break; + case eToken.eIf: + CompileIf(_tok, _sw); + break; + case eToken.eWhile: + CompileWhile(_tok, _sw); + break; + case eToken.eDo: + CompileDo(_tok, _sw); + break; + case eToken.eFor: + CompileFor(_tok, _sw); + break; + case eToken.eWith: + CompileWith(_tok, _sw); + break; + case eToken.eSwitch: + CompileSwitch(_tok, _sw); + break; + case eToken.eFunction: + CompileFunction(_tok, _sw); + break; + case eToken.eAssign: + CompileAssign(_tok, _sw); + break; + case eToken.eReturn: + CompileReturn(_tok, _sw); + break; + case eToken.eBreak: + CompileBreak(_tok, _sw); + break; + case eToken.eExit: + CompileExit(_tok, _sw); + break; + case eToken.eContinue: + CompileContinue(_tok, _sw); + break; + } + } + + private static void CheckEmitArrayCheck(TextWriter _sw) + { + IEnumerable> enumerable = ms_arrays.Where((KeyValuePair a) => a.Value == ms_statements); + foreach (KeyValuePair item in enumerable) + { + _sw.WriteLine("if (!{0}) {0} = [];", item.Key); + } + } + + private static void CompileStatement2(GMLToken _tok, TextWriter _sw) + { + CheckEmitArrayCheck(_sw); + CompileStatement(_tok, _sw); + ms_statements++; + } + + private static void CompileBlock(GMLToken _tok, TextWriter _sw) + { + _sw.WriteLine("{"); + foreach (GMLToken child in _tok.Children) + { + CompileStatement2(child, _sw); + _sw.WriteLine(";"); + } + _sw.WriteLine("}"); + } + + private static void CompileProgram(GMLToken _tok, TextWriter _sw) + { + switch (_tok.Token) + { + case eToken.eEOF: + break; + case eToken.eBlock: + CompileBlock(_tok, _sw); + break; + default: + Error("No program to compile", _tok); + break; + } + } + + private static void GatherArgs(GMLToken _tok) + { + eToken token = _tok.Token; + if (token == eToken.eVariable) + { + switch (_tok.Text) + { + case "argument0": + case "argument1": + case "argument2": + case "argument3": + case "argument4": + case "argument5": + case "argument6": + case "argument7": + case "argument8": + case "argument9": + case "argument10": + case "argument11": + case "argument12": + case "argument13": + case "argument14": + case "argument15": + { + string value; + if (!ms_arguments.TryGetValue(_tok.Text, out value)) + { + ms_arguments.Add(_tok.Text, _tok.Text); + } + break; + } + } + } + foreach (GMLToken child in _tok.Children) + { + GatherArgs(child); + } + } + + public static void Compile(GMAssets _assets, GMLCode _code, TextWriter _sw) + { + ms_assets = _assets; + ms_code = _code; + ms_numErrors = 0; + ms_error = false; + Console.WriteLine("Compiling - {0}", _code.Name); + _sw.WriteLine("\n// #####################################################################################################"); + string[] array = _code.Code.Split('\n'); + string[] array2 = array; + foreach (string text in array2) + { + string text2 = text.Replace('\r', ' '); + text2 = text2.Replace('\n', ' '); + _sw.WriteLine("// {0}", text2); + } + ms_arguments.Clear(); + switch (_code.Type) + { + case eGMLCodeType.eRoomCreate: + _sw.WriteLine("function {0}(_inst)", _code.Name); + ms_thisName.Push("_inst"); + ms_otherName.Push("_inst"); + break; + case eGMLCodeType.eScript: + { + GatherArgs(_code.Token); + _sw.Write("function {0}( _inst, _other ", _code.Name); + for (int j = 0; j < ms_arguments.Count; j++) + { + string text3 = string.Format("argument{0}", j); + string value = string.Empty; + if (!ms_arguments.TryGetValue(text3, out value)) + { + Error(string.Format("argument naming error, {0} arguments but no reference found to {1}", ms_arguments.Count, text3), _code.Token); + } + _sw.Write(", {0}", text3); + } + _sw.Write(")"); + ms_thisName.Push("_inst"); + ms_otherName.Push("_other"); + break; + } + case eGMLCodeType.eRoomInstanceCreate: + _sw.WriteLine("function {0}( _inst )", _code.Name); + ms_thisName.Push("_inst"); + ms_otherName.Push("_inst"); + break; + case eGMLCodeType.eEvent: + case eGMLCodeType.eTrigger: + _sw.WriteLine("function {0}( _inst, _other )", _code.Name); + ms_thisName.Push("_inst"); + ms_otherName.Push("_other"); + break; + case eGMLCodeType.eConstant: + _sw.WriteLine("function {0}()", _code.Name); + ms_thisName.Push(""); + ms_otherName.Push(""); + break; + } + DummyStream stream = new DummyStream(); + StreamWriter sw = new StreamWriter(stream); + int num = ms_unique; + ms_locals.Clear(); + ms_arrays.Clear(); + ms_breakContext.Clear(); + ms_statements = 0; + CompileProgram(_code.Token, sw); + if (!ms_error) + { + ms_unique = num; + ms_locals.Clear(); + ms_breakContext.Clear(); + ms_statements = 0; + CompileProgram(_code.Token, _sw); + } + ms_thisName.Pop(); + ms_otherName.Pop(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GML2VM.cs b/GMAC1098/GMAssetCompiler/GML2VM.cs new file mode 100644 index 0000000..301414a --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GML2VM.cs @@ -0,0 +1,1281 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace GMAssetCompiler +{ + internal class GML2VM + { + private const int VARIABLE_ARRAY_MAX_DIMENSION = 32000; + + public static int ms_numErrors; + + public VMBuffer VMB + { + get; + set; + } + + public GMLCode Code + { + get; + set; + } + + public bool ErrorFlag + { + get; + set; + } + + public Stack TypeStack + { + get; + set; + } + + public Stack LoopEnv + { + get; + set; + } + + public Stack LoopEndEnv + { + get; + set; + } + + public static List Strings + { + get; + set; + } + + public static List StringPatches + { + get; + set; + } + + public static List VarStringEntry + { + get; + set; + } + + public static List VarPatches + { + get; + set; + } + + public static List ObjectStringEntry + { + get; + set; + } + + public static List ObjectPatches + { + get; + set; + } + + static GML2VM() + { + Strings = new List(); + StringPatches = new List(); + VarStringEntry = new List(); + VarPatches = new List(); + ObjectStringEntry = new List(); + ObjectPatches = new List(); + } + + public GML2VM() + { + VMB = new VMBuffer(); + TypeStack = new Stack(); + LoopEnv = new Stack(); + LoopEndEnv = new Stack(); + } + + private int AddString(string _string) + { + int num = Strings.IndexOf(_string); + if (num == -1) + { + num = Strings.Count; + Strings.Add(_string); + } + return num; + } + + private int AddStringAndPatch(string _string) + { + int result = AddString(_string); + StringPatches.Add(VMB.Buffer.Position); + return result; + } + + private int AddVar(string _string) + { + int item = AddString(_string); + int num = VarStringEntry.IndexOf(item); + if (num == -1) + { + num = VarStringEntry.Count; + VarStringEntry.Add(item); + } + return num; + } + + private int AddVarAndPatch(string _string) + { + int result = AddVar(_string); + VarPatches.Add(VMB.Buffer.Position); + return result; + } + + private int AddObjectAndPatch(string _string) + { + int item = AddString(_string); + int num = ObjectStringEntry.IndexOf(item); + if (num == -1) + { + num = ObjectStringEntry.Count; + ObjectStringEntry.Add(item); + } + ObjectPatches.Add(VMB.Buffer.Position); + return num; + } + + private void EmitBreak(ushort _v) + { + VMB.Add(VMBuffer.EncodeInstructionArg(255, 15) | _v); + } + + private void Emit(eVM_Instruction _inst, eVM_Type _type1) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, (int)_type1)); + } + + private void Emit(eVM_Instruction _inst, eVM_Type _type1, eVM_Type _type2) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, VMBuffer.EncodeArgDouble((int)_type1, (int)_type2))); + } + + private void EmitI(eVM_Instruction _inst, double _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 0)); + VMB.Buffer.WriteDouble(_val); + } + + private void EmitI(eVM_Instruction _inst, float _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 1)); + VMB.Buffer.WriteSingle(_val); + } + + private void EmitI(eVM_Instruction _inst, long _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 3)); + VMB.Buffer.WriteLong(_val); + } + + private void EmitI(eVM_Instruction _inst, int _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 2)); + VMB.Buffer.WriteInteger(_val); + } + + private void EmitI(eVM_Instruction _inst, bool _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 4)); + VMB.Buffer.WriteBoolean(_val); + } + + private void EmitI(eVM_Instruction _inst, string _val) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 6)); + int count = Strings.Count; + Strings.Add(_val); + StringPatches.Add(VMB.Buffer.Position); + VMB.Buffer.WriteInteger(count); + } + + private void EmitIVar(eVM_Instruction _inst, int _var) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, 5)); + VMB.Buffer.WriteInteger(_var); + } + + private void EmitIVar(eVM_Instruction _inst, int _var, eVM_Type _target) + { + VMB.Add(VMBuffer.EncodeInstructionArg((int)_inst, VMBuffer.EncodeArgDouble(5, (int)_target))); + VMB.Buffer.WriteInteger(_var); + } + + private void Emit(eVM_Instruction _inst, VMLabel _label) + { + if (!_label.Marked) + { + _label.Patches.Add((int)VMB.Buffer.Position); + VMB.Add(VMBuffer.EncodeInstructionBranch((int)_inst, 0)); + } + else + { + long num = _label.Address - VMB.Buffer.Position; + VMB.Add(VMBuffer.EncodeInstructionBranch((int)_inst, (int)num)); + } + } + + private void EmitDebugInfo(GMLToken _tok) + { + } + + public void Error(string _errorMessage, GMLToken _token) + { + if (!Program.InhibitErrorOutput) + { + int num = 1; + for (int i = 0; i < _token.Index; i++) + { + if (Code.Code[i] == '\n') + { + num++; + } + } + Console.WriteLine("Error : {0}({1}) : {2}", Code.Name, num, _errorMessage); + } + ms_numErrors++; + ErrorFlag = true; + Program.ExitCode = 1; + } + + private void CompileConstant(GMLToken _tok) + { + switch (_tok.Value.Kind) + { + case eKind.eConstant: + Error("constant token", _tok); + break; + case eKind.eNone: + Error("None constant token", _tok); + break; + case eKind.eNumber: + { + double num = (long)_tok.Value.ValueI; + if (num == _tok.Value.ValueI) + { + long num2 = (long)_tok.Value.ValueI; + if (num2 > int.MaxValue || num2 < int.MinValue) + { + EmitI(eVM_Instruction.eVMI_PUSH, num2); + TypeStack.Push(eVM_Type.eVMT_Long); + } + else if (num2 > 32767 || num2 < -32768) + { + EmitI(eVM_Instruction.eVMI_PUSH, (int)num2); + TypeStack.Push(eVM_Type.eVMT_Int); + } + else + { + VMB.Add(VMBuffer.EncodeInstructionArg(192, 15) | (int)(num2 & 0xFFFF)); + TypeStack.Push(eVM_Type.eVMT_Int); + } + } + else + { + EmitI(eVM_Instruction.eVMI_PUSH, _tok.Value.ValueI); + TypeStack.Push(eVM_Type.eVMT_Double); + } + break; + } + case eKind.eString: + EmitI(eVM_Instruction.eVMI_PUSH, _tok.Value.ValueS); + TypeStack.Push(eVM_Type.eVMT_String); + break; + } + } + + private void BinaryTypeCoercion(GMLToken _tok, int _parmNum) + { + eVM_Type eVM_Type = TypeStack.Peek(); + switch (_tok.Children[1].Token) + { + case eToken.eNot: + case eToken.eLess: + case eToken.eLessEqual: + case eToken.eEqual: + case eToken.eNotEqual: + case eToken.eGreaterEqual: + case eToken.eGreater: + case eToken.eBitNegate: + break; + case eToken.ePlus: + case eToken.eMinus: + case eToken.eTime: + case eToken.eDivide: + case eToken.eDiv: + case eToken.eMod: + if (eVM_Type == eVM_Type.eVMT_Bool) + { + TypeStack.Pop(); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + break; + case eToken.eAnd: + case eToken.eOr: + case eToken.eXor: + if (eVM_Type != eVM_Type.eVMT_Bool) + { + TypeStack.Pop(); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Bool); + TypeStack.Push(eVM_Type.eVMT_Bool); + } + break; + case eToken.eBitOr: + case eToken.eBitAnd: + case eToken.eBitXor: + case eToken.eBitShiftLeft: + case eToken.eBitShiftRight: + if (eVM_Type == eVM_Type.eVMT_Int) + { + TypeStack.Pop(); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + break; + } + } + + private int TypeSize(eVM_Type _t) + { + int result = 0; + switch (_t) + { + case eVM_Type.eVMT_Double: + result = 8; + break; + case eVM_Type.eVMT_Long: + result = 8; + break; + case eVM_Type.eVMT_String: + result = 4; + break; + case eVM_Type.eVMT_Variable: + result = 12; + break; + case eVM_Type.eVMT_Float: + result = 4; + break; + case eVM_Type.eVMT_Bool: + result = 4; + break; + case eVM_Type.eVMT_Int: + result = 4; + break; + } + return result; + } + + private void CompileBinary(GMLToken _tok) + { + CompileExpression(_tok.Children[0]); + BinaryTypeCoercion(_tok, 1); + CompileExpression(_tok.Children[2]); + BinaryTypeCoercion(_tok, 2); + eVM_Type eVM_Type = TypeStack.Pop(); + eVM_Type eVM_Type2 = TypeStack.Pop(); + int num = TypeSize(eVM_Type); + int num2 = TypeSize(eVM_Type2); + eVM_Type item = (num > num2) ? eVM_Type : eVM_Type2; + switch (_tok.Children[1].Token) + { + case eToken.eTime: + Emit(eVM_Instruction.eVMI_MUL, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eDivide: + Emit(eVM_Instruction.eVMI_DIV, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eDiv: + Emit(eVM_Instruction.eVMI_REM, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eMod: + Emit(eVM_Instruction.eVMI_MOD, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.ePlus: + Emit(eVM_Instruction.eVMI_ADD, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eMinus: + Emit(eVM_Instruction.eVMI_SUB, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eLess: + Emit(eVM_Instruction.eVMI_SET_LT, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eLessEqual: + Emit(eVM_Instruction.eVMI_SET_LE, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eAssign: + case eToken.eEqual: + Emit(eVM_Instruction.eVMI_SET_EQ, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eNotEqual: + Emit(eVM_Instruction.eVMI_SET_NE, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eGreaterEqual: + Emit(eVM_Instruction.eVMI_SET_GE, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eGreater: + Emit(eVM_Instruction.eVMI_SET_GT, eVM_Type, eVM_Type2); + TypeStack.Push(eVM_Type.eVMT_Bool); + break; + case eToken.eAnd: + case eToken.eBitAnd: + Emit(eVM_Instruction.eVMI_AND, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eOr: + case eToken.eBitOr: + Emit(eVM_Instruction.eVMI_OR, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eXor: + case eToken.eBitXor: + Emit(eVM_Instruction.eVMI_XOR, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eBitShiftLeft: + Emit(eVM_Instruction.eVMI_SHL, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + case eToken.eBitShiftRight: + Emit(eVM_Instruction.eVMI_SHR, eVM_Type, eVM_Type2); + TypeStack.Push(item); + break; + } + } + + private void CompileUnary(GMLToken _tok) + { + CompileExpression(_tok.Children[0]); + eVM_Type eVM_Type = TypeStack.Peek(); + switch (_tok.Id) + { + case 203: + switch (eVM_Type) + { + case eVM_Type.eVMT_String: + case eVM_Type.eVMT_Error: + Error("Unable to Not a string", _tok); + break; + case eVM_Type.eVMT_Double: + case eVM_Type.eVMT_Float: + case eVM_Type.eVMT_Int: + case eVM_Type.eVMT_Long: + case eVM_Type.eVMT_Variable: + TypeStack.Pop(); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Bool); + TypeStack.Push(eVM_Type.eVMT_Bool); + eVM_Type = eVM_Type.eVMT_Bool; + break; + } + Emit(eVM_Instruction.eVMI_NOT, eVM_Type); + break; + case 211: + Emit(eVM_Instruction.eVMI_NEG, eVM_Type); + break; + case 220: + switch (eVM_Type) + { + case eVM_Type.eVMT_String: + case eVM_Type.eVMT_Error: + Error("Unable to Negate a string", _tok); + break; + case eVM_Type.eVMT_Double: + case eVM_Type.eVMT_Float: + case eVM_Type.eVMT_Variable: + TypeStack.Pop(); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + eVM_Type = eVM_Type.eVMT_Int; + break; + } + Emit(eVM_Instruction.eVMI_NOT, eVM_Type); + break; + } + } + + private void CompileVariable(GMLToken _tok) + { + switch (_tok.Token) + { + case eToken.eVariable: + case eToken.eDot: + if (_tok.Children.Count >= 2) + { + int num = 0; + CompileExpression(_tok.Children[0]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + if (_tok.Children[1].Children.Count > 0) + { + CompileExpression(_tok.Children[1].Children[0]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + if (_tok.Children[1].Children.Count > 1) + { + EmitI(eVM_Instruction.eVMI_PUSH, 32000); + Emit(eVM_Instruction.eVMI_MUL, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + CompileExpression(_tok.Children[1].Children[1]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + Emit(eVM_Instruction.eVMI_ADD, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + TypeStack.Pop(); + } + TypeStack.Pop(); + } + else + { + num |= int.MinValue; + } + TypeStack.Pop(); + EmitIVar(eVM_Instruction.eVMI_PUSH, _tok.Children[1].Id | num); + TypeStack.Push(eVM_Type.eVMT_Variable); + } + else + { + Error("Malformed variable reference", _tok); + } + break; + case eToken.eConstant: + Error("Unsure where these come from", _tok); + break; + } + } + + private void CompileExpression(GMLToken _tok) + { + EmitDebugInfo(_tok); + switch (_tok.Token) + { + case eToken.eConstant: + CompileConstant(_tok); + break; + case eToken.eBinary: + CompileBinary(_tok); + break; + case eToken.eUnary: + CompileUnary(_tok); + break; + case eToken.eFunction: + CompileFunction(_tok); + break; + case eToken.eVariable: + case eToken.eDot: + CompileVariable(_tok); + break; + } + } + + private void CompileGlobalVar(GMLToken _tok) + { + } + + private void CompileRepeat(GMLToken _tok) + { + VMLabel vMLabel = new VMLabel("End", VMB); + VMLabel vMLabel2 = new VMLabel("Repeat", VMB); + CompileExpression(_tok.Children[0]); + eVM_Type eVM_Type = TypeStack.Pop(); + if (eVM_Type != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Int); + } + Emit(eVM_Instruction.eVMI_DUP, eVM_Type.eVMT_Int); + EmitI(eVM_Instruction.eVMI_PUSH, 0); + Emit(eVM_Instruction.eVMI_SET_LE, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + Emit(eVM_Instruction.eVMI_BTRUE, vMLabel); + LoopEnv.Push(vMLabel2); + LoopEndEnv.Push(vMLabel); + vMLabel2.Mark(VMB.Buffer.Position); + CompileStatement(_tok.Children[1]); + EmitI(eVM_Instruction.eVMI_PUSH, 1); + Emit(eVM_Instruction.eVMI_SUB, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + Emit(eVM_Instruction.eVMI_DUP, eVM_Type.eVMT_Int); + Emit(eVM_Instruction.eVMI_CONV, eVM_Type.eVMT_Int, eVM_Type.eVMT_Bool); + Emit(eVM_Instruction.eVMI_BTRUE, vMLabel2); + vMLabel.Mark(VMB.Buffer.Position); + Emit(eVM_Instruction.eVMI_POPNULL, eVM_Type.eVMT_Int); + LoopEnv.Pop(); + LoopEndEnv.Pop(); + } + + private void CompileIf(GMLToken _tok) + { + } + + private void CompileWhile(GMLToken _tok) + { + } + + private void CompileDo(GMLToken _tok) + { + } + + private void CompileFor(GMLToken _tok) + { + } + + private void CompileWith(GMLToken _tok) + { + } + + private void CompileSwitch(GMLToken _tok) + { + } + + private void CompileFunction(GMLToken _tok) + { + foreach (GMLToken child in _tok.Children) + { + CompileExpression(child); + eVM_Type eVM_Type = TypeStack.Pop(); + if (eVM_Type != eVM_Type.eVMT_Variable) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Variable); + } + } + EmitI(eVM_Instruction.eVMI_CALL, _tok.Id); + TypeStack.Push(GMAssetCompiler.eVM_Type.eVMT_Variable); + } + + private void CompilePop(GMLToken _tok, eVM_Type _type) + { + switch (_tok.Token) + { + case eToken.eVariable: + case eToken.eDot: + if (_tok.Children.Count >= 2) + { + int num = 0; + CompileExpression(_tok.Children[0]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + if (_tok.Children[1].Children.Count > 0) + { + CompileExpression(_tok.Children[1].Children[0]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + if (_tok.Children[1].Children.Count > 1) + { + EmitI(eVM_Instruction.eVMI_PUSH, 32000); + Emit(eVM_Instruction.eVMI_MUL, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + CompileExpression(_tok.Children[1].Children[1]); + if (TypeStack.Peek() != eVM_Type.eVMT_Int) + { + Emit(eVM_Instruction.eVMI_CONV, TypeStack.Pop(), eVM_Type.eVMT_Int); + TypeStack.Push(eVM_Type.eVMT_Int); + } + Emit(eVM_Instruction.eVMI_ADD, eVM_Type.eVMT_Int, eVM_Type.eVMT_Int); + TypeStack.Pop(); + } + TypeStack.Pop(); + } + else + { + num |= int.MinValue; + } + TypeStack.Pop(); + EmitIVar(eVM_Instruction.eVMI_POP, _tok.Children[1].Id | num, _type); + TypeStack.Push(eVM_Type.eVMT_Variable); + } + else + { + Error("Malformed variable reference", _tok); + } + break; + case eToken.eConstant: + Error("Unsure where these come from", _tok); + break; + } + } + + private void CompileAssign(GMLToken _tok) + { + switch (_tok.Children[1].Token) + { + case eToken.eAssign: + CompileExpression(_tok.Children[2]); + CompilePop(_tok.Children[0], TypeStack.Pop()); + break; + case eToken.eAssignPlus: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type3 = TypeStack.Pop(); + if (eVM_Type3 == eVM_Type.eVMT_Bool) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type3, eVM_Type.eVMT_Int); + eVM_Type3 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_ADD, eVM_Type3, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignMinus: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type7 = TypeStack.Pop(); + if (eVM_Type7 == eVM_Type.eVMT_Bool) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type7, eVM_Type.eVMT_Int); + eVM_Type7 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_SUB, eVM_Type7, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignTimes: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type2 = TypeStack.Pop(); + if (eVM_Type2 == eVM_Type.eVMT_Bool) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type2, eVM_Type.eVMT_Int); + eVM_Type2 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_MUL, eVM_Type2, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignDivide: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type6 = TypeStack.Pop(); + if (eVM_Type6 == eVM_Type.eVMT_Bool) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type6, eVM_Type.eVMT_Int); + eVM_Type6 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_DIV, eVM_Type6, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignOr: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type4 = TypeStack.Pop(); + if (eVM_Type4 != eVM_Type.eVMT_Int && eVM_Type4 != eVM_Type.eVMT_Long) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type4, eVM_Type.eVMT_Int); + eVM_Type4 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_OR, eVM_Type4, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignAnd: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type5 = TypeStack.Pop(); + if (eVM_Type5 != eVM_Type.eVMT_Int && eVM_Type5 != eVM_Type.eVMT_Long) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type5, eVM_Type.eVMT_Int); + eVM_Type5 = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_AND, eVM_Type5, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + case eToken.eAssignXor: + { + CompileVariable(_tok.Children[0]); + TypeStack.Pop(); + CompileExpression(_tok.Children[2]); + eVM_Type eVM_Type = TypeStack.Pop(); + if (eVM_Type != eVM_Type.eVMT_Int && eVM_Type != eVM_Type.eVMT_Long) + { + Emit(eVM_Instruction.eVMI_CONV, eVM_Type, eVM_Type.eVMT_Int); + eVM_Type = eVM_Type.eVMT_Int; + } + Emit(eVM_Instruction.eVMI_XOR, eVM_Type, eVM_Type.eVMT_Variable); + CompilePop(_tok.Children[0], eVM_Type.eVMT_Variable); + break; + } + } + } + + private void CompileReturn(GMLToken _tok) + { + } + + private void CompileBreak(GMLToken _tok) + { + } + + private void CompileExit(GMLToken _tok) + { + } + + private void CompileContinue(GMLToken _tok) + { + } + + private void CompileStatement(GMLToken _tok) + { + EmitDebugInfo(_tok); + switch (_tok.Token) + { + case eToken.eVar: + break; + case eToken.eGlobalVar: + CompileGlobalVar(_tok); + break; + case eToken.eBegin: + case eToken.eBlock: + CompileBlock(_tok); + break; + case eToken.eRepeat: + CompileRepeat(_tok); + break; + case eToken.eIf: + CompileIf(_tok); + break; + case eToken.eWhile: + CompileWhile(_tok); + break; + case eToken.eDo: + CompileDo(_tok); + break; + case eToken.eFor: + CompileFor(_tok); + break; + case eToken.eWith: + CompileWith(_tok); + break; + case eToken.eSwitch: + CompileSwitch(_tok); + break; + case eToken.eFunction: + CompileFunction(_tok); + break; + case eToken.eAssign: + CompileAssign(_tok); + break; + case eToken.eReturn: + CompileReturn(_tok); + break; + case eToken.eBreak: + CompileBreak(_tok); + break; + case eToken.eExit: + CompileExit(_tok); + break; + case eToken.eContinue: + CompileContinue(_tok); + break; + default: + Error("Token is undefined at CompileStatement", _tok); + break; + } + } + + private void CompileBlock(GMLToken _tok) + { + foreach (GMLToken child in _tok.Children) + { + CompileStatement(child); + } + } + + private void CompileProgram(GMLToken _tok) + { + switch (_tok.Token) + { + case eToken.eEOF: + break; + case eToken.eBlock: + CompileBlock(_tok); + break; + default: + Error("No program to compile", _tok); + break; + } + } + + private GMLToken RewriteVariable(GMLToken _tok) + { + GMLToken gMLToken = new GMLToken(_tok); + gMLToken.Token = eToken.eDot; + gMLToken.Children = new List(2); + gMLToken.Children.Add(new GMLToken(eToken.eConstant, _tok, -6, new GMLValue(-6.0))); + gMLToken.Children.Add(_tok); + return gMLToken; + } + + private GMLToken RewriteDot(GMLToken _tok) + { + GMLToken gMLToken = null; + if (_tok.Children.Count > 2) + { + gMLToken = new GMLToken(_tok); + GMLToken gMLToken2 = gMLToken; + gMLToken2.Children = new List(2); + gMLToken2.Children.Add(null); + gMLToken2.Children.Add(null); + gMLToken2.Children[1] = _tok.Children[_tok.Children.Count - 1]; + for (int num = _tok.Children.Count - 2; num > 2; num--) + { + gMLToken2.Children[0] = new GMLToken(_tok); + gMLToken2.Children[0].Children = new List(2); + gMLToken2.Children[0].Children.Add(null); + gMLToken2.Children[0].Children.Add(null); + gMLToken2.Children[0].Children[1] = _tok.Children[num]; + gMLToken2 = gMLToken2.Children[0]; + } + gMLToken2.Children[0] = new GMLToken(_tok); + gMLToken2.Children[0].Children = new List(2); + gMLToken2.Children[0].Children.Add(null); + gMLToken2.Children[0].Children.Add(null); + gMLToken2.Children[0].Children[1] = _tok.Children[1]; + gMLToken2.Children[0].Children[0] = _tok.Children[0]; + } + return gMLToken; + } + + private GMLToken RewriteTree(GMLToken _tok) + { + GMLToken result = null; + bool flag = true; + switch (_tok.Token) + { + case eToken.eDot: + result = RewriteDot(_tok); + flag = false; + break; + case eToken.eVariable: + result = RewriteVariable(_tok); + flag = false; + break; + } + if (flag) + { + for (int i = 0; i < _tok.Children.Count; i++) + { + GMLToken gMLToken = RewriteTree(_tok.Children[i]); + if (gMLToken != null) + { + _tok.Children[i] = gMLToken; + } + } + } + return result; + } + + private int ParamSize(int _arg) + { + int result = 0; + switch (_arg & 0xF) + { + case 0: + result = 8; + break; + case 3: + result = 8; + break; + case 1: + case 2: + case 4: + case 5: + case 6: + result = 4; + break; + } + return result; + } + + private string Instruction2String(int _ins) + { + string result = "unknown"; + switch (_ins) + { + case 192: + result = "push"; + break; + case 65: + result = "pop"; + break; + case 130: + result = "dup"; + break; + case 4: + result = "mul"; + break; + case 5: + result = "div"; + break; + case 6: + result = "rem"; + break; + case 7: + result = "mod"; + break; + case 8: + result = "add"; + break; + case 9: + result = "sub"; + break; + case 3: + result = "conv"; + break; + case 10: + result = "and"; + break; + case 11: + result = "or"; + break; + case 12: + result = "xor"; + break; + case 13: + result = "neg"; + break; + case 14: + result = "not"; + break; + case 15: + result = "shl"; + break; + case 16: + result = "shr"; + break; + case 17: + result = "slt"; + break; + case 18: + result = "sle"; + break; + case 19: + result = "seq"; + break; + case 20: + result = "sne"; + break; + case 21: + result = "sge"; + break; + case 22: + result = "sgt"; + break; + case 183: + result = "b"; + break; + case 184: + result = "bt"; + break; + case 185: + result = "bf"; + break; + case 218: + result = "call"; + break; + case 187: + result = "pushenv"; + break; + case 188: + result = "popenv"; + break; + case 157: + result = "ret"; + break; + case 158: + result = "exit"; + break; + case 159: + result = "popz"; + break; + case 255: + result = "break"; + break; + } + return result; + } + + private string Arg2String(int _arg) + { + string result = ""; + switch (_arg & 0xF) + { + case 3: + result = ".l"; + break; + case 0: + result = ".d"; + break; + case 2: + result = ".i"; + break; + case 5: + result = ".v"; + break; + case 6: + result = ".s"; + break; + case 1: + result = ".f"; + break; + case 4: + result = ".b"; + break; + case 15: + result = ".e"; + break; + } + return result; + } + + public int DisasmOne(VMBuffer _vmb, int _offs, TextWriter _sw) + { + int num = _offs; + int @int = _vmb.GetInt(_offs); + _offs += 4; + int instruction = VMBuffer.GetInstruction(@int); + int arg = VMBuffer.GetArg(@int); + int num2 = _offs; + if ((instruction & 0x40) != 0) + { + _offs += ParamSize(arg); + } + int i = 11; + _sw.Write("{0:x8} : ", num); + int num3 = num; + while (num3 < _offs) + { + _sw.Write("{0:x2}", _vmb.Buffer.GetBuffer()[num3]); + num3++; + i += 2; + } + for (; i < 36; i++) + { + _sw.Write(" "); + } + string text = Instruction2String(instruction); + _sw.Write(text); + i += text.Length; + if ((instruction & 0xA0) == 128) + { + _sw.Write(Arg2String(arg)); + i += 2; + } + else if ((instruction & 0xA0) == 0) + { + _sw.Write(Arg2String(arg & 0xF)); + _sw.Write(Arg2String(arg >> 4)); + i += 4; + } + for (; i < 46; i++) + { + _sw.Write(" "); + } + if ((instruction & 0x40) != 0) + { + long position = _vmb.Buffer.Position; + _vmb.Buffer.Position = num2; + switch (arg & 0xF) + { + case 3: + _sw.Write("{0}", _vmb.Buffer.ReadLong()); + break; + case 0: + _sw.Write("{0}", _vmb.Buffer.ReadDouble()); + break; + case 2: + _sw.Write("{0}", _vmb.Buffer.ReadInteger()); + break; + case 5: + _sw.Write("{0}", _vmb.Buffer.ReadInteger() & 0x1FFFFFFF); + break; + case 6: + _sw.Write("{0}", Strings[_vmb.Buffer.ReadInteger()]); + break; + case 1: + _sw.Write("{0}", _vmb.Buffer.ReadSingle()); + break; + case 4: + _sw.Write("{0}", _vmb.Buffer.ReadInteger() != 0); + break; + case 15: + _sw.Write("{0}", @int << 16 >> 16); + break; + } + _vmb.Buffer.Position = position; + } + else if ((instruction & 0x20) != 0) + { + int num4 = num + VMBuffer.GetBranch(@int); + _sw.WriteLine("0x{0:x8}", num4); + } + _sw.WriteLine(""); + return _offs; + } + + public void Disasm(TextWriter _sw) + { + for (int num = 0; num < VMB.Buffer.Position; num = DisasmOne(VMB, num, _sw)) + { + } + } + + public void Compile(GMAssets _assets, GMLCode _code) + { + Code = _code; + if (Program.CompileVerbose) + { + RewriteTree(_code.Token); + CompileProgram(_code.Token); + Disasm(Program.Out); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLCode.cs b/GMAC1098/GMAssetCompiler/GMLCode.cs new file mode 100644 index 0000000..b1ff1a1 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLCode.cs @@ -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 Errors + { + get; + set; + } + + public GMLCode(GMAssets _assets, string _name, string _code, eGMLCodeType _type) + { + Name = _name.Replace(' ', '_').Replace('\t', '_'); + Code = _code; + Type = _type; + List _errors = null; + Token = GMLCompile.Compile(_assets, Name, Code, out _errors); + Errors = _errors; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLCompile.cs b/GMAC1098/GMAssetCompiler/GMLCompile.cs new file mode 100644 index 0000000..cc825ca --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLCompile.cs @@ -0,0 +1,3559 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows.Forms; + +namespace GMAssetCompiler +{ + internal class GMLCompile + { + public const int OBJECT_SELF = -1; + + public const int OBJECT_OTHER = -2; + + public const int OBJECT_ALL = -3; + + public const int OBJECT_NOONE = -4; + + public const int OBJECT_GLOBAL = -5; + + public const int OBJECT_LOCAL = -7; + + public const int OBJECT_NOTSPECIFIED = -6; + + private const int clBlack = 0; + + private const int clMaroon = 128; + + private const int clGreen = 32768; + + private const int clOlive = 32896; + + private const int clNavy = 8388608; + + private const int clPurple = 8388736; + + private const int clTeal = 8421376; + + private const int clGray = 8421504; + + private const int clSilver = 12632256; + + private const int clRed = 255; + + private const int clLime = 65280; + + private const int clYellow = 65535; + + private const int clBlue = 16711680; + + private const int clFuchsia = 16711935; + + private const int clAqua = 16776960; + + private const int clLtGray = 12632256; + + private const int clDkGray = 8421504; + + private const int clWhite = 16777215; + + private const int clMoneyGreen = 12639424; + + private const int clSkyBlue = 15780518; + + private const int clCream = 15793151; + + private const int clMedGray = 10789024; + + private const int EVENT_CREATE = 0; + + private const int EVENT_DESTROY = 1; + + private const int EVENT_ALARM = 2; + + private const int EVENT_STEP = 3; + + private const int EVENT_COLLISION = 4; + + private const int EVENT_KEYBOARD = 5; + + private const int EVENT_MOUSE = 6; + + private const int EVENT_OTHER = 7; + + private const int EVENT_DRAW = 8; + + private const int EVENT_KEYPRESS = 9; + + private const int EVENT_KEYRELEASE = 10; + + private const int EVENT_TRIGGER = 11; + + private const int VK_RETURN = 13; + + private const int VK_SHIFT = 16; + + private const int VK_CONTROL = 17; + + private const int VK_MENU = 18; + + private const int VK_ESCAPE = 27; + + private const int VK_SPACE = 32; + + private const int VK_BACK = 8; + + private const int VK_TAB = 9; + + private const int VK_PAUSE = 19; + + private const int VK_SNAPSHOT = 44; + + private const int VK_LEFT = 37; + + private const int VK_RIGHT = 39; + + private const int VK_UP = 38; + + private const int VK_DOWN = 40; + + private const int VK_HOME = 36; + + private const int VK_END = 35; + + private const int VK_DELETE = 46; + + private const int VK_INSERT = 45; + + private const int VK_PRIOR = 33; + + private const int VK_NEXT = 34; + + private const int VK_F1 = 112; + + private const int VK_F2 = 113; + + private const int VK_F3 = 114; + + private const int VK_F4 = 115; + + private const int VK_F5 = 116; + + private const int VK_F6 = 117; + + private const int VK_F7 = 118; + + private const int VK_F8 = 119; + + private const int VK_F9 = 120; + + private const int VK_F10 = 121; + + private const int VK_F11 = 128; + + private const int VK_F12 = 129; + + private const int VK_NUMPAD0 = 96; + + private const int VK_NUMPAD1 = 97; + + private const int VK_NUMPAD2 = 98; + + private const int VK_NUMPAD3 = 99; + + private const int VK_NUMPAD4 = 100; + + private const int VK_NUMPAD5 = 101; + + private const int VK_NUMPAD6 = 102; + + private const int VK_NUMPAD7 = 103; + + private const int VK_NUMPAD8 = 104; + + private const int VK_NUMPAD9 = 105; + + private const int VK_DIVIDE = 111; + + private const int VK_MULTIPLY = 106; + + private const int VK_SUBTRACT = 109; + + private const int VK_ADD = 107; + + private const int VK_DECIMAL = 110; + + private const int VK_LSHIFT = 160; + + private const int VK_LCONTROL = 162; + + private const int VK_LMENU = 164; + + private const int VK_RSHIFT = 161; + + private const int VK_RCONTROL = 163; + + private const int VK_RMENU = 165; + + public static Dictionary ms_constants = new Dictionary(); + + public static Dictionary ms_ConstantCount = new Dictionary(); + + public static Dictionary ms_funcs = new Dictionary(); + + public static Dictionary ms_builtins = new Dictionary(); + + public static Dictionary ms_builtinsArray = new Dictionary(); + + public static Dictionary ms_builtinsLocal = new Dictionary(); + + public static Dictionary ms_builtinsLocalArray = new Dictionary(); + + private static Dictionary ms_vars = new Dictionary(); + + public static int ms_id = 0; + + private static GMAssets ms_assets = null; + + private static string ms_script = string.Empty; + + private static List ms_errors = null; + + private static bool ms_error = false; + + private static int ms_numErrors = 0; + + private static string ms_scriptName = ""; + + private static void SkipWhitespace(string _script, ref int _index) + { + bool flag = false; + while (!flag) + { + while (_index < _script.Length && char.IsWhiteSpace(_script[_index])) + { + _index++; + } + if (_index < _script.Length && _script[_index] == '/') + { + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '*': + _index += 2; + while (_index < _script.Length && (_script[_index] != '*' || _script[_index + 1] != '/')) + { + _index++; + } + if (_index >= _script.Length) + { + ms_errors.Add(new GMLError(eErrorKind.Warning_Unclosed_Comment, "unclosed comment (/*) at tend of script", null, _index)); + } + else + { + _index += 2; + } + break; + case '/': + _index += 2; + while (_index < _script.Length && _script[_index] != '\n' && _script[_index] != '\r') + { + _index++; + } + _index++; + break; + default: + flag = true; + break; + } + } + else + { + flag = true; + } + } + else + { + flag = true; + } + } + } + + private static GMLToken NextName(string _script, ref int _index) + { + StringBuilder stringBuilder = new StringBuilder(); + int index = _index; + stringBuilder.Append(_script[_index]); + _index++; + while (_index < _script.Length && (char.IsLetterOrDigit(_script[_index]) || _script[_index] == '_')) + { + stringBuilder.Append(_script[_index]); + _index++; + } + string text = stringBuilder.ToString(); + switch (text) + { + case "var": + return new GMLToken(eToken.eVar, index, text); + case "if": + return new GMLToken(eToken.eIf, index, text); + case "end": + return new GMLToken(eToken.eEnd, index, text); + case "else": + return new GMLToken(eToken.eElse, index, text); + case "while": + return new GMLToken(eToken.eWhile, index, text); + case "do": + return new GMLToken(eToken.eDo, index, text); + case "for": + return new GMLToken(eToken.eFor, index, text); + case "begin": + return new GMLToken(eToken.eBegin, index, text); + case "then": + return new GMLToken(eToken.eThen, index, text); + case "with": + return new GMLToken(eToken.eWith, index, text); + case "until": + return new GMLToken(eToken.eUntil, index, text); + case "repeat": + return new GMLToken(eToken.eRepeat, index, text); + case "exit": + return new GMLToken(eToken.eExit, index, text); + case "return": + return new GMLToken(eToken.eReturn, index, text); + case "break": + return new GMLToken(eToken.eBreak, index, text); + case "continue": + return new GMLToken(eToken.eContinue, index, text); + case "switch": + return new GMLToken(eToken.eSwitch, index, text); + case "case": + return new GMLToken(eToken.eCase, index, text); + case "default": + return new GMLToken(eToken.eDefault, index, text); + case "and": + return new GMLToken(eToken.eAnd, index, text); + case "or": + return new GMLToken(eToken.eOr, index, text); + case "not": + return new GMLToken(eToken.eNot, index, text); + case "div": + return new GMLToken(eToken.eDiv, index, text); + case "mod": + return new GMLToken(eToken.eMod, index, text); + case "xor": + return new GMLToken(eToken.eBitXor, index, text); + case "globalvar": + return new GMLToken(eToken.eGlobalVar, index, text); + default: + return new GMLToken(eToken.eName, index, text); + } + } + + private static GMLToken NextValue(string _script, ref int _index) + { + StringBuilder stringBuilder = new StringBuilder(); + int index = _index; + stringBuilder.Append(_script[_index]); + _index++; + while (_index < _script.Length && (char.IsDigit(_script[_index]) || _script[_index] == '.')) + { + stringBuilder.Append(_script[_index]); + _index++; + } + return new GMLToken(eToken.eNumber, index, stringBuilder.ToString()); + } + + private static GMLToken NextHex(string _script, ref int _index) + { + StringBuilder stringBuilder = new StringBuilder(); + int index = _index; + stringBuilder.Append(_script[_index]); + _index++; + while (_index < _script.Length && (char.IsDigit(_script[_index]) || (char.ToLower(_script[_index]) >= 'a' && char.ToLower(_script[_index]) <= 'f'))) + { + stringBuilder.Append(_script[_index]); + _index++; + } + return new GMLToken(eToken.eNumber, index, stringBuilder.ToString()); + } + + private static GMLToken NextString(string _script, ref int _index) + { + StringBuilder stringBuilder = new StringBuilder(); + int index = _index; + char c = _script[_index]; + _index++; + while (_index < _script.Length && c != _script[_index]) + { + stringBuilder.Append(_script[_index]); + _index++; + } + if (_index < _script.Length) + { + _index++; + } + return new GMLToken(eToken.eString, index, stringBuilder.ToString()); + } + + private static GMLToken NextToken(string _script, ref int _index) + { + SkipWhitespace(_script, ref _index); + if (_index >= _script.Length) + { + return new GMLToken(eToken.eEOF, _index, string.Empty); + } + char c = _script[_index]; + if (char.IsLetter(c) || c == '_') + { + return NextName(_script, ref _index); + } + if (char.IsDigit(c)) + { + return NextValue(_script, ref _index); + } + switch (c) + { + case '$': + return NextHex(_script, ref _index); + case '"': + case '\'': + return NextString(_script, ref _index); + default: + if (_index + 1 < _script.Length && _script[_index] == '.' && char.IsDigit(_script[_index + 1])) + { + return NextValue(_script, ref _index); + } + switch (c) + { + case '{': + return new GMLToken(eToken.eBegin, _index++, "{"); + case '}': + return new GMLToken(eToken.eEnd, _index++, "}"); + case '(': + return new GMLToken(eToken.eOpen, _index++, "("); + case ')': + return new GMLToken(eToken.eClose, _index++, ")"); + case '[': + return new GMLToken(eToken.eArrayOpen, _index++, "["); + case ']': + return new GMLToken(eToken.eArrayClose, _index++, "]"); + case ';': + return new GMLToken(eToken.eSepStatement, _index++, ";"); + case ',': + return new GMLToken(eToken.eSepArgument, _index++, ","); + case '.': + return new GMLToken(eToken.eDot, _index++, "."); + case '~': + return new GMLToken(eToken.eBitNegate, _index++, "~"); + case '!': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eNot, _index - 1, "!"); + } + return new GMLToken(eToken.eNotEqual, _index++ - 2, "!="); + case '=': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eAssign, _index - 1, "="); + } + return new GMLToken(eToken.eEqual, _index++ - 2, "=="); + case ':': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eLabel, _index - 1, ":"); + } + return new GMLToken(eToken.eAssign, _index++ - 2, ":="); + case '+': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.ePlus, _index - 1, "+"); + } + return new GMLToken(eToken.eAssignPlus, _index++ - 2, "+="); + case '-': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eMinus, _index - 1, "-"); + } + return new GMLToken(eToken.eAssignMinus, _index++ - 2, "-="); + case '*': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eTime, _index - 1, "*"); + } + return new GMLToken(eToken.eAssignTimes, _index++ - 2, "*="); + case '/': + _index++; + if (_index >= _script.Length || _script[_index] != '=') + { + return new GMLToken(eToken.eDivide, _index - 1, "/"); + } + return new GMLToken(eToken.eAssignDivide, _index++ - 2, "/="); + case '<': + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '>': + _index += 2; + return new GMLToken(eToken.eNotEqual, _index, "<>"); + case '<': + _index += 2; + return new GMLToken(eToken.eBitShiftLeft, _index, "<<"); + case '=': + _index += 2; + return new GMLToken(eToken.eLessEqual, _index, "<="); + default: + return new GMLToken(eToken.eLess, _index++, "<"); + } + } + return new GMLToken(eToken.eLess, _index++, "<"); + case '>': + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '>': + _index += 2; + return new GMLToken(eToken.eBitShiftRight, _index, ">>"); + case '=': + _index += 2; + return new GMLToken(eToken.eGreaterEqual, _index, ">="); + default: + return new GMLToken(eToken.eGreater, _index++, ">"); + } + } + return new GMLToken(eToken.eGreater, _index++, ">"); + case '|': + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '|': + _index += 2; + return new GMLToken(eToken.eOr, _index, "||"); + case '=': + _index += 2; + return new GMLToken(eToken.eAssignOr, _index, "|="); + default: + return new GMLToken(eToken.eBitOr, _index++, "|"); + } + } + return new GMLToken(eToken.eBitOr, _index++, "|"); + case '&': + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '&': + _index += 2; + return new GMLToken(eToken.eAnd, _index, "&&"); + case '=': + _index += 2; + return new GMLToken(eToken.eAssignAnd, _index, "&="); + default: + return new GMLToken(eToken.eBitAnd, _index++, "&"); + } + } + return new GMLToken(eToken.eBitAnd, _index++, "&"); + case '^': + if (_index + 1 < _script.Length) + { + switch (_script[_index + 1]) + { + case '^': + _index += 2; + return new GMLToken(eToken.eXor, _index, "^^"); + case '=': + _index += 2; + return new GMLToken(eToken.eAssignXor, _index, "^="); + default: + return new GMLToken(eToken.eBitXor, _index++, "^"); + } + } + return new GMLToken(eToken.eBitXor, _index++, "^"); + default: + return new GMLToken(eToken.eError, _index, string.Empty); + } + } + } + + public static void Check(string _check, eToken _token) + { + int _index = 0; + GMLToken gMLToken = NextToken(_check, ref _index); + if (gMLToken.Token != _token && _index == _check.Length) + { + Console.WriteLine("Failed Token Check : got {0:G} should be {1:G} for {2}", gMLToken.Token, _token, _check); + } + } + + public static void Test() + { + Check("012345", eToken.eNumber); + Check("var", eToken.eVar); + Check("if", eToken.eIf); + Check("end", eToken.eEnd); + Check("else", eToken.eElse); + Check("while", eToken.eWhile); + Check("do", eToken.eDo); + Check("for", eToken.eFor); + Check("begin", eToken.eBegin); + Check("then", eToken.eThen); + Check("with", eToken.eWith); + Check("until", eToken.eUntil); + Check("repeat", eToken.eRepeat); + Check("exit", eToken.eExit); + Check("return", eToken.eReturn); + Check("break", eToken.eBreak); + Check("continue", eToken.eContinue); + Check("switch", eToken.eSwitch); + Check("case", eToken.eCase); + Check("default", eToken.eDefault); + Check("and", eToken.eAnd); + Check("or", eToken.eOr); + Check("div", eToken.eDiv); + Check("mod", eToken.eMod); + Check("xor", eToken.eBitXor); + Check("globalvar", eToken.eGlobalVar); + Check("$0123456", eToken.eNumber); + Check(".0123456", eToken.eNumber); + Check("0123.456", eToken.eNumber); + Check("\"0123.456\"", eToken.eString); + Check("'0123.456'", eToken.eString); + Check("blahblah", eToken.eName); + Check("{", eToken.eBegin); + Check("}", eToken.eEnd); + Check("(", eToken.eOpen); + Check(")", eToken.eClose); + Check("[", eToken.eArrayOpen); + Check("]", eToken.eArrayClose); + Check(";", eToken.eSepStatement); + Check(",", eToken.eSepArgument); + Check(".", eToken.eDot); + Check("~", eToken.eBitNegate); + Check("!=", eToken.eNotEqual); + Check("!", eToken.eNot); + Check("==", eToken.eEqual); + Check("=", eToken.eAssign); + Check(":=", eToken.eAssign); + Check(":", eToken.eLabel); + Check("+=", eToken.eAssignPlus); + Check("+", eToken.ePlus); + Check("-=", eToken.eAssignMinus); + Check("-", eToken.eMinus); + Check("*=", eToken.eAssignTimes); + Check("*", eToken.eTime); + Check("/=", eToken.eAssignDivide); + Check("/", eToken.eDivide); + Check("<<", eToken.eBitShiftLeft); + Check("<=", eToken.eLessEqual); + Check("<", eToken.eLess); + Check(">>", eToken.eBitShiftRight); + Check(">=", eToken.eGreaterEqual); + Check(">", eToken.eGreater); + Check("||", eToken.eOr); + Check("|=", eToken.eAssignOr); + Check("&&", eToken.eAnd); + Check("&=", eToken.eAssignAnd); + Check("&", eToken.eBitAnd); + Check("^^", eToken.eXor); + Check("^=", eToken.eAssignXor); + Check("^", eToken.eBitXor); + } + + public static void Error(string _errorMessage, string _script, GMLToken _token) + { + if (!Program.InhibitErrorOutput) + { + int num = 1; + for (int i = 0; i < _token.Index; i++) + { + if (_script[i] == '\n') + { + num++; + } + } + Console.WriteLine("Error : {0}({1}) : {2}", ms_scriptName, num, _errorMessage); + } + ms_numErrors++; + ms_error = true; + Program.ExitCode = 1; + } + + private static void Function_Add(string _string, int _numArgs7, int _numArgs8, bool _Pro) + { + GMLFunction gMLFunction = new GMLFunction(); + gMLFunction.Name = _string; + gMLFunction.Id = ms_id++; + gMLFunction.NumArgs7 = _numArgs7; + gMLFunction.NumArgs8 = _numArgs8; + gMLFunction.Pro = _Pro; + gMLFunction.InstanceFirstParam = false; + gMLFunction.OtherSecondParam = false; + try + { + ms_funcs.Add(_string, gMLFunction); + } + catch (Exception) + { + MessageBox.Show(_string); + } + } + + private static void Function_Add(string _string, int _numArgs7, int _numArgs8, bool _Pro, bool _InstanceFirstParam) + { + GMLFunction gMLFunction = new GMLFunction(); + gMLFunction.Name = _string; + gMLFunction.Id = ms_id++; + gMLFunction.NumArgs7 = _numArgs7; + gMLFunction.NumArgs8 = _numArgs8; + gMLFunction.Pro = _Pro; + gMLFunction.InstanceFirstParam = _InstanceFirstParam; + gMLFunction.OtherSecondParam = false; + ms_funcs.Add(_string, gMLFunction); + } + + private static void Function_Add(string _string, int _numArgs7, int _numArgs8, bool _Pro, bool _InstanceFirstParam, bool _OtherSecondParam) + { + GMLFunction gMLFunction = new GMLFunction(); + gMLFunction.Name = _string; + gMLFunction.Id = ms_id++; + gMLFunction.NumArgs7 = _numArgs7; + gMLFunction.NumArgs8 = _numArgs8; + gMLFunction.Pro = _Pro; + gMLFunction.InstanceFirstParam = _InstanceFirstParam; + gMLFunction.OtherSecondParam = _OtherSecondParam; + ms_funcs.Add(_string, gMLFunction); + } + + private static void AddRealConstant(string _name, double _value) + { + ms_constants.Add(_name, _value); + } + + private static void Variable_BuiltIn_Add(string _name, bool _get, bool _set, bool _pro, string _setFunc, string _getFunc) + { + GMLVariable gMLVariable = new GMLVariable(); + gMLVariable.Name = _name; + gMLVariable.Id = ms_id++; + gMLVariable.Get = _get; + gMLVariable.Set = _set; + gMLVariable.Pro = _pro; + gMLVariable.setFunction = _setFunc; + gMLVariable.getFunction = _getFunc; + ms_builtins.Add(_name, gMLVariable); + } + + private static void Variable_BuiltIn_Array_Add(string _name, bool _get, bool _set, bool _pro) + { + GMLVariable gMLVariable = new GMLVariable(); + gMLVariable.Name = _name; + gMLVariable.Id = ms_id++; + gMLVariable.Get = _get; + gMLVariable.Set = _set; + gMLVariable.Pro = _pro; + gMLVariable.setFunction = null; + gMLVariable.getFunction = null; + ms_builtins.Add(_name, gMLVariable); + ms_builtinsArray.Add(_name, gMLVariable); + } + + private static void Variable_BuiltIn_Local_Add(string _name, bool _get, bool _set, bool _pro, string _setFunc, string _getFunc) + { + GMLVariable gMLVariable = new GMLVariable(); + gMLVariable.Name = _name; + gMLVariable.Id = ms_id++; + gMLVariable.Get = _get; + gMLVariable.Set = _set; + gMLVariable.Pro = _pro; + gMLVariable.setFunction = _setFunc; + gMLVariable.getFunction = _getFunc; + ms_builtinsLocal.Add(_name, gMLVariable); + } + + private static void Variable_BuiltIn_Local_Array_Add(string _name, bool _get, bool _set, bool _pro) + { + GMLVariable gMLVariable = new GMLVariable(); + gMLVariable.Name = _name; + gMLVariable.Id = ms_id++; + gMLVariable.Get = _get; + gMLVariable.Set = _set; + gMLVariable.Pro = _pro; + gMLVariable.setFunction = null; + gMLVariable.getFunction = null; + ms_builtinsLocal.Add(_name, gMLVariable); + ms_builtinsLocalArray.Add(_name, gMLVariable); + } + + public static void Code_Init() + { + Function_Add("d3d_start", 0, 0, true); + Function_Add("d3d_end", 0, 0, true); + Function_Add("d3d_set_perspective", 1, 1, true); + Function_Add("d3d_set_hidden", 1, 1, true); + Function_Add("d3d_set_depth", 1, 1, true); + Function_Add("d3d_set_lighting", 1, 1, true); + Function_Add("d3d_set_shading", 1, 1, true); + Function_Add("d3d_set_fog", 4, 4, true); + Function_Add("d3d_set_culling", 1, 1, true); + Function_Add("d3d_primitive_begin", 1, 1, true); + Function_Add("d3d_primitive_begin_texture", 2, 2, true); + Function_Add("d3d_primitive_end", 0, 0, true); + Function_Add("d3d_vertex", 3, 3, true); + Function_Add("d3d_vertex_color", 5, 5, true); + Function_Add("d3d_vertex_texture", 5, 5, true); + Function_Add("d3d_vertex_texture_color", 7, 7, true); + Function_Add("d3d_vertex_normal", 6, 6, true); + Function_Add("d3d_vertex_normal_color", 8, 8, true); + Function_Add("d3d_vertex_normal_texture", 8, 8, true); + Function_Add("d3d_vertex_normal_texture_color", 10, 10, true); + Function_Add("d3d_draw_block", 9, 9, true); + Function_Add("d3d_draw_cylinder", 11, 11, true); + Function_Add("d3d_draw_cone", 11, 11, true); + Function_Add("d3d_draw_ellipsoid", 10, 10, true); + Function_Add("d3d_draw_wall", 9, 9, true); + Function_Add("d3d_draw_floor", 9, 9, true); + Function_Add("d3d_set_projection", 9, 9, true); + Function_Add("d3d_set_projection_ext", 13, 13, true); + Function_Add("d3d_set_projection_ortho", 5, 5, true); + Function_Add("d3d_set_projection_perspective", 5, 5, true); + Function_Add("d3d_transform_set_identity", 0, 0, true); + Function_Add("d3d_transform_set_translation", 3, 3, true); + Function_Add("d3d_transform_set_scaling", 3, 3, true); + Function_Add("d3d_transform_set_rotation_x", 1, 1, true); + Function_Add("d3d_transform_set_rotation_y", 1, 1, true); + Function_Add("d3d_transform_set_rotation_z", 1, 1, true); + Function_Add("d3d_transform_set_rotation_axis", 4, 4, true); + Function_Add("d3d_transform_add_translation", 3, 3, true); + Function_Add("d3d_transform_add_scaling", 3, 3, true); + Function_Add("d3d_transform_add_rotation_x", 1, 1, true); + Function_Add("d3d_transform_add_rotation_y", 1, 1, true); + Function_Add("d3d_transform_add_rotation_z", 1, 1, true); + Function_Add("d3d_transform_add_rotation_axis", 4, 4, true); + Function_Add("d3d_transform_stack_clear", 0, 0, true); + Function_Add("d3d_transform_stack_empty", 0, 0, true); + Function_Add("d3d_transform_stack_push", 0, 0, true); + Function_Add("d3d_transform_stack_pop", 0, 0, true); + Function_Add("d3d_transform_stack_top", 0, 0, true); + Function_Add("d3d_transform_stack_discard", 0, 0, true); + Function_Add("d3d_light_define_direction", 5, 5, true); + Function_Add("d3d_light_define_point", 6, 6, true); + Function_Add("d3d_light_enable", 2, 2, true); + Function_Add("d3d_model_create", 0, 0, true); + Function_Add("d3d_model_destroy", 1, 1, true); + Function_Add("d3d_model_clear", 1, 1, true); + Function_Add("d3d_model_load", 2, 2, true); + Function_Add("d3d_model_save", 2, 2, true); + Function_Add("d3d_model_draw", 5, 5, true); + Function_Add("d3d_model_primitive_begin", 2, 2, true); + Function_Add("d3d_model_primitive_end", 1, 1, true); + Function_Add("d3d_model_vertex", 4, 4, true); + Function_Add("d3d_model_vertex_color", 6, 6, true); + Function_Add("d3d_model_vertex_texture", 6, 6, true); + Function_Add("d3d_model_vertex_texture_color", 8, 8, true); + Function_Add("d3d_model_vertex_normal", 7, 7, true); + Function_Add("d3d_model_vertex_normal_color", 9, 9, true); + Function_Add("d3d_model_vertex_normal_texture", 9, 9, true); + Function_Add("d3d_model_vertex_normal_texture_color", 11, 11, true); + Function_Add("d3d_model_block", 9, 9, true); + Function_Add("d3d_model_cylinder", 11, 11, true); + Function_Add("d3d_model_cone", 11, 11, true); + Function_Add("d3d_model_ellipsoid", 10, 10, true); + Function_Add("d3d_model_wall", 9, 9, true); + Function_Add("d3d_model_floor", 9, 9, true); + Function_Add("action_path_old", 3, 3, false); + Function_Add("action_set_sprite", 2, 2, false, true); + Function_Add("action_draw_font", 1, 1, false); + Function_Add("action_draw_font_old", 6, 6, false); + Function_Add("action_fill_color", 1, 1, false); + Function_Add("action_line_color", 1, 1, false); + Function_Add("action_highscore", 0, 0, false); + Function_Add("action_set_relative", 1, 1, false); + Function_Add("action_move", 2, 2, false, true); + Function_Add("action_set_motion", 2, 2, false, true); + Function_Add("action_set_hspeed", 1, 1, false, true); + Function_Add("action_set_vspeed", 1, 1, false, true); + Function_Add("action_set_gravity", 2, 2, false, true); + Function_Add("action_set_friction", 1, 1, false, true); + Function_Add("action_move_point", 3, 3, false, true); + Function_Add("action_move_to", 2, 2, false, true); + Function_Add("action_move_start", 0, 0, false, true); + Function_Add("action_move_random", 2, 2, false, true); + Function_Add("action_snap", 2, 2, false, true); + Function_Add("action_wrap", 1, 1, false, true); + Function_Add("action_reverse_xdir", 0, 0, false, true); + Function_Add("action_reverse_ydir", 0, 0, false, true); + Function_Add("action_move_contact", 3, 3, false, true); + Function_Add("action_bounce", 2, 2, false, true); + Function_Add("action_path", 4, 4, false, true); + Function_Add("action_path_end", 0, 0, false, true); + Function_Add("action_path_position", 1, 1, false, true); + Function_Add("action_path_speed", 1, 1, false, true); + Function_Add("action_linear_step", 4, 4, false, true); + Function_Add("action_potential_step", 4, 4, false, true); + Function_Add("action_kill_object", 0, 0, false, true); + Function_Add("action_create_object", 3, 3, false, true); + Function_Add("action_create_object_motion", 5, 5, false, true); + Function_Add("action_create_object_random", 6, 6, false, true); + Function_Add("action_change_object", 2, 2, false, true); + Function_Add("action_kill_position", 2, 2, false, true); + Function_Add("action_sprite_set", 3, 3, false, true); + Function_Add("action_sprite_transform", 4, 4, true, true); + Function_Add("action_sprite_color", 2, 2, true, true); + Function_Add("action_sound", 2, 2, false); + Function_Add("action_end_sound", 1, 1, false); + Function_Add("action_if_sound", 1, 1, false); + Function_Add("action_another_room", 2, 2, false); + Function_Add("action_current_room", 1, 1, false); + Function_Add("action_previous_room", 1, 1, false); + Function_Add("action_next_room", 1, 1, false); + Function_Add("action_if_previous_room", 0, 0, false); + Function_Add("action_if_next_room", 0, 0, false); + Function_Add("action_set_alarm", 2, 2, false, true); + Function_Add("action_sleep", 2, 2, false); + Function_Add("action_set_timeline", 2, 2, false, true); + Function_Add("action_timeline_set", 2, 2, false, true); + Function_Add("action_timeline_start", 0, 0, false, true); + Function_Add("action_timeline_stop", 0, 0, false, true); + Function_Add("action_timeline_pause", 0, 0, false, true); + Function_Add("action_set_timeline_position", 1, 1, false, true); + Function_Add("action_set_timeline_speed", 1, 1, false, true); + Function_Add("action_message", 1, 1, false); + Function_Add("action_show_info", 0, 0, false); + Function_Add("action_show_video", 3, 3, true); + Function_Add("action_end_game", 0, 0, false); + Function_Add("action_restart_game", 0, 0, false); + Function_Add("action_save_game", 1, 1, false); + Function_Add("action_load_game", 1, 1, false); + Function_Add("action_replace_sprite", 3, 3, true); + Function_Add("action_replace_sound", 2, 2, true); + Function_Add("action_replace_background", 2, 2, true); + Function_Add("action_if_empty", 3, 3, false, true); + Function_Add("action_if_collision", 3, 3, false, true); + Function_Add("action_if", 1, 1, false); + Function_Add("action_if_number", 3, 3, false); + Function_Add("action_if_object", 3, 3, false, true); + Function_Add("action_if_question", 1, 1, false); + Function_Add("action_if_dice", 1, 1, false); + Function_Add("action_if_mouse", 1, 1, false); + Function_Add("action_if_aligned", 2, 2, false, true); + Function_Add("action_execute_script", 6, 6, false, true); + Function_Add("action_inherited", 0, 0, false, true, true); + Function_Add("action_if_variable", 3, 3, false); + Function_Add("action_draw_variable", 3, 3, false, true); + Function_Add("action_set_score", 1, 1, false); + Function_Add("action_if_score", 2, 2, false); + Function_Add("action_draw_score", 3, 3, false, true); + Function_Add("action_highscore_show", 5, 5, false); + Function_Add("action_highscore_clear", 0, 0, false); + Function_Add("action_set_life", 1, 1, false); + Function_Add("action_if_life", 2, 2, false); + Function_Add("action_draw_life", 3, 3, false, true); + Function_Add("action_draw_life_images", 3, 3, false, true); + Function_Add("action_set_health", 1, 1, false, true); + Function_Add("action_if_health", 2, 2, false, true); + Function_Add("action_draw_health", 6, 6, false, true); + Function_Add("action_set_caption", 6, 6, false); + Function_Add("action_partsyst_create", 1, 1, true); + Function_Add("action_partsyst_destroy", 0, 0, true); + Function_Add("action_partsyst_clear", 0, 0, true); + Function_Add("action_parttype_create_old", 6, 6, true); + Function_Add("action_parttype_create", 6, 6, true); + Function_Add("action_parttype_color", 6, 6, true); + Function_Add("action_parttype_life", 3, 3, true); + Function_Add("action_parttype_speed", 6, 6, true); + Function_Add("action_parttype_gravity", 3, 3, true); + Function_Add("action_parttype_secondary", 5, 5, true); + Function_Add("action_partemit_create", 6, 6, true); + Function_Add("action_partemit_destroy", 1, 1, true); + Function_Add("action_partemit_burst", 3, 3, true); + Function_Add("action_partemit_stream", 3, 3, true); + Function_Add("action_cd_play", 2, 2, true); + Function_Add("action_cd_stop", 0, 0, true); + Function_Add("action_cd_pause", 0, 0, true); + Function_Add("action_cd_resume", 0, 0, true); + Function_Add("action_cd_present", 0, 0, true); + Function_Add("action_cd_playing", 0, 0, true); + Function_Add("action_set_cursor", 2, 2, true); + Function_Add("action_webpage", 1, 1, true); + Function_Add("action_splash_web", 1, 1, true); + Function_Add("action_draw_sprite", 4, 4, false, true); + Function_Add("action_draw_background", 4, 4, false, true); + Function_Add("action_draw_text", 3, 3, false, true); + Function_Add("action_draw_text_transformed", 6, 6, true, true); + Function_Add("action_draw_rectangle", 5, 5, false, true); + Function_Add("action_draw_gradient_hor", 6, 6, true, true); + Function_Add("action_draw_gradient_vert", 6, 6, true, true); + Function_Add("action_draw_ellipse", 5, 5, false, true); + Function_Add("action_draw_ellipse_gradient", 6, 6, true, true); + Function_Add("action_draw_line", 4, 4, false, true); + Function_Add("action_draw_arrow", 5, 5, false, true); + Function_Add("action_color", 1, 1, false); + Function_Add("action_font", 2, 2, false); + Function_Add("action_fullscreen", 1, 1, false); + Function_Add("action_snapshot", 1, 1, true); + Function_Add("action_effect", 6, 6, true, true); + Function_Add("ds_set_precision", 1, 1, true); + Function_Add("ds_stack_create", 0, 0, true); + Function_Add("ds_stack_destroy", 1, 1, true); + Function_Add("ds_stack_clear", 1, 1, true); + Function_Add("ds_stack_copy", 2, 2, true); + Function_Add("ds_stack_size", 1, 1, true); + Function_Add("ds_stack_empty", 1, 1, true); + Function_Add("ds_stack_push", 2, 2, true); + Function_Add("ds_stack_pop", 1, 1, true); + Function_Add("ds_stack_top", 1, 1, true); + Function_Add("ds_stack_write", 1, 1, true); + Function_Add("ds_stack_read", 2, 2, true); + Function_Add("ds_queue_create", 0, 0, true); + Function_Add("ds_queue_destroy", 1, 1, true); + Function_Add("ds_queue_clear", 1, 1, true); + Function_Add("ds_queue_copy", 2, 2, true); + Function_Add("ds_queue_size", 1, 1, true); + Function_Add("ds_queue_empty", 1, 1, true); + Function_Add("ds_queue_enqueue", 2, 2, true); + Function_Add("ds_queue_dequeue", 1, 1, true); + Function_Add("ds_queue_head", 1, 1, true); + Function_Add("ds_queue_tail", 1, 1, true); + Function_Add("ds_queue_write", 1, 1, true); + Function_Add("ds_queue_read", 2, 2, true); + Function_Add("ds_list_create", 0, 0, true); + Function_Add("ds_list_destroy", 1, 1, true); + Function_Add("ds_list_clear", 1, 1, true); + Function_Add("ds_list_copy", 2, 2, true); + Function_Add("ds_list_size", 1, 1, true); + Function_Add("ds_list_empty", 1, 1, true); + Function_Add("ds_list_add", 2, 2, true); + Function_Add("ds_list_insert", 3, 3, true); + Function_Add("ds_list_replace", 3, 3, true); + Function_Add("ds_list_delete", 2, 2, true); + Function_Add("ds_list_find_index", 2, 2, true); + Function_Add("ds_list_find_value", 2, 2, true); + Function_Add("ds_list_sort", 2, 2, true); + Function_Add("ds_list_shuffle", 1, 1, true); + Function_Add("ds_list_write", 1, 1, true); + Function_Add("ds_list_read", 2, 2, true); + Function_Add("ds_map_create", 0, 0, true); + Function_Add("ds_map_destroy", 1, 1, true); + Function_Add("ds_map_clear", 1, 1, true); + Function_Add("ds_map_copy", 2, 2, true); + Function_Add("ds_map_size", 1, 1, true); + Function_Add("ds_map_empty", 1, 1, true); + Function_Add("ds_map_add", 3, 3, true); + Function_Add("ds_map_replace", 3, 3, true); + Function_Add("ds_map_delete", 2, 2, true); + Function_Add("ds_map_exists", 2, 2, true); + Function_Add("ds_map_find_value", 2, 2, true); + Function_Add("ds_map_find_previous", 2, 2, true); + Function_Add("ds_map_find_next", 2, 2, true); + Function_Add("ds_map_find_first", 1, 1, true); + Function_Add("ds_map_find_last", 1, 1, true); + Function_Add("ds_map_write", 1, 1, true); + Function_Add("ds_map_read", 1, 2, true); + Function_Add("ds_priority_create", 0, 0, true); + Function_Add("ds_priority_destroy", 1, 1, true); + Function_Add("ds_priority_clear", 1, 1, true); + Function_Add("ds_priority_copy", 1, 2, true); + Function_Add("ds_priority_size", 1, 1, true); + Function_Add("ds_priority_empty", 1, 1, true); + Function_Add("ds_priority_add", 3, 3, true); + Function_Add("ds_priority_change_priority", 3, 3, true); + Function_Add("ds_priority_find_priority", 2, 2, true); + Function_Add("ds_priority_delete_value", 2, 2, true); + Function_Add("ds_priority_delete_min", 1, 1, true); + Function_Add("ds_priority_find_min", 1, 1, true); + Function_Add("ds_priority_delete_max", 1, 1, true); + Function_Add("ds_priority_find_max", 1, 1, true); + Function_Add("ds_priority_write", 1, 1, true); + Function_Add("ds_priority_read", 2, 2, true); + Function_Add("ds_grid_create", 2, 2, true); + Function_Add("ds_grid_destroy", 1, 1, true); + Function_Add("ds_grid_copy", 2, 2, true); + Function_Add("ds_grid_resize", 3, 3, true); + Function_Add("ds_grid_width", 1, 1, true); + Function_Add("ds_grid_height", 1, 1, true); + Function_Add("ds_grid_clear", 2, 2, true); + Function_Add("ds_grid_set", 4, 4, true); + Function_Add("ds_grid_add", 4, 4, true); + Function_Add("ds_grid_multiply", 4, 4, true); + Function_Add("ds_grid_set_region", 6, 6, true); + Function_Add("ds_grid_add_region", 6, 6, true); + Function_Add("ds_grid_multiply_region", 6, 6, true); + Function_Add("ds_grid_set_disk", 5, 5, true); + Function_Add("ds_grid_add_disk", 5, 5, true); + Function_Add("ds_grid_multiply_disk", 5, 5, true); + Function_Add("ds_grid_set_grid_region", 8, 8, true); + Function_Add("ds_grid_add_grid_region", 8, 8, true); + Function_Add("ds_grid_multiply_grid_region", 8, 8, true); + Function_Add("ds_grid_get", 3, 3, true); + Function_Add("ds_grid_get_sum", 5, 5, true); + Function_Add("ds_grid_get_max", 5, 5, true); + Function_Add("ds_grid_get_min", 5, 5, true); + Function_Add("ds_grid_get_mean", 5, 5, true); + Function_Add("ds_grid_get_disk_sum", 4, 4, true); + Function_Add("ds_grid_get_disk_max", 4, 4, true); + Function_Add("ds_grid_get_disk_min", 4, 4, true); + Function_Add("ds_grid_get_disk_mean", 4, 4, true); + Function_Add("ds_grid_value_exists", 6, 6, true); + Function_Add("ds_grid_value_x", 6, 6, true); + Function_Add("ds_grid_value_y", 6, 6, true); + Function_Add("ds_grid_value_disk_exists", 5, 5, true); + Function_Add("ds_grid_value_disk_x", 5, 5, true); + Function_Add("ds_grid_value_disk_y", 5, 5, true); + Function_Add("ds_grid_shuffle", 1, 1, true); + Function_Add("ds_grid_write", 1, 1, true); + Function_Add("ds_grid_read", 2, 2, true); + Function_Add("mplay_init_ipx", 0, 0, true); + Function_Add("mplay_init_tcpip", 1, 1, true); + Function_Add("mplay_init_modem", 2, 2, true); + Function_Add("mplay_init_serial", 5, 5, true); + Function_Add("mplay_connect_status", 0, 0, true); + Function_Add("mplay_end", 0, 0, true); + Function_Add("mplay_session_mode", 1, 1, true); + Function_Add("mplay_session_create", 3, 3, true); + Function_Add("mplay_session_find", 0, 0, true); + Function_Add("mplay_session_name", 1, 1, true); + Function_Add("mplay_session_join", 2, 2, true); + Function_Add("mplay_session_status", 0, 0, true); + Function_Add("mplay_session_end", 0, 0, true); + Function_Add("mplay_player_find", 0, 0, true); + Function_Add("mplay_player_name", 1, 1, true); + Function_Add("mplay_player_id", 1, 1, true); + Function_Add("mplay_data_write", 2, 2, true); + Function_Add("mplay_data_read", 1, 1, true); + Function_Add("mplay_data_mode", 1, 1, true); + Function_Add("mplay_message_send", 3, 3, true); + Function_Add("mplay_message_send_guaranteed", 3, 3, true); + Function_Add("mplay_message_receive", 1, 1, true); + Function_Add("mplay_message_id", 0, 0, true); + Function_Add("mplay_message_value", 0, 0, true); + Function_Add("mplay_message_player", 0, 0, true); + Function_Add("mplay_message_name", 0, 0, true); + Function_Add("mplay_message_count", 1, 1, true); + Function_Add("mplay_message_clear", 1, 1, true); + Function_Add("mplay_ipaddress", 0, 0, true); + Function_Add("file_bin_open", 2, 2, false); + Function_Add("file_bin_rewrite", 1, 1, false); + Function_Add("file_bin_close", 1, 1, false); + Function_Add("file_bin_position", 1, 1, false); + Function_Add("file_bin_size", 1, 1, false); + Function_Add("file_bin_seek", 2, 2, false); + Function_Add("file_bin_read_byte", 1, 1, false); + Function_Add("file_bin_write_byte", 2, 2, false); + Function_Add("file_text_open_read", 1, 1, false); + Function_Add("file_text_open_write", 1, 1, false); + Function_Add("file_text_open_append", 1, 1, false); + Function_Add("file_text_close", 1, 1, false); + Function_Add("file_text_read_string", 1, 1, false); + Function_Add("file_text_read_real", 1, 1, false); + Function_Add("file_text_readln", 1, 1, false); + Function_Add("file_text_eof", 1, 1, false); + Function_Add("file_text_write_string", 2, 2, false); + Function_Add("file_text_write_real", 2, 2, false); + Function_Add("file_text_writeln", 1, 1, false); + Function_Add("file_open_read", 1, 1, false); + Function_Add("file_open_write", 1, 1, false); + Function_Add("file_open_append", 1, 1, false); + Function_Add("file_close", 0, 0, false); + Function_Add("file_read_string", 0, 0, false); + Function_Add("file_read_real", 0, 0, false); + Function_Add("file_readln", 0, 0, false); + Function_Add("file_eof", 0, 0, false); + Function_Add("file_write_string", 1, 1, false); + Function_Add("file_write_real", 1, 1, false); + Function_Add("file_writeln", 0, 0, false); + Function_Add("file_exists", 1, 1, false); + Function_Add("file_delete", 1, 1, false); + Function_Add("file_rename", 2, 2, false); + Function_Add("file_copy", 2, 2, false); + Function_Add("directory_exists", 1, 1, false); + Function_Add("directory_create", 1, 1, false); + Function_Add("file_find_first", 2, 2, false); + Function_Add("file_find_next", 0, 0, false); + Function_Add("file_find_close", 0, 0, false); + Function_Add("file_attributes", 2, 2, false); + Function_Add("filename_name", 1, 1, false); + Function_Add("filename_path", 1, 1, false); + Function_Add("filename_dir", 1, 1, false); + Function_Add("filename_drive", 1, 1, false); + Function_Add("filename_ext", 1, 1, false); + Function_Add("filename_change_ext", 2, 2, false); + Function_Add("export_include_file", 1, 1, false); + Function_Add("export_include_file_location", 2, 2, false); + Function_Add("discard_include_file", 1, 1, false); + Function_Add("execute_program", 3, 3, false); + Function_Add("execute_shell", 2, 2, false); + Function_Add("parameter_count", 0, 0, false); + Function_Add("parameter_string", 1, 1, false); + Function_Add("environment_get_variable", 1, 1, false); + Function_Add("registry_write_string", 2, 2, false); + Function_Add("registry_write_real", 2, 2, false); + Function_Add("registry_read_string", 1, 1, false); + Function_Add("registry_read_real", 1, 1, false); + Function_Add("registry_exists", 1, 1, false); + Function_Add("registry_write_string_ext", 3, 3, false); + Function_Add("registry_write_real_ext", 3, 3, false); + Function_Add("registry_read_string_ext", 2, 2, false); + Function_Add("registry_read_real_ext", 2, 2, false); + Function_Add("registry_exists_ext", 2, 2, false); + Function_Add("registry_set_root", 1, 1, false); + Function_Add("ini_open", 1, 1, false); + Function_Add("ini_close", 0, 0, false); + Function_Add("ini_read_string", 3, 3, false); + Function_Add("ini_read_real", 3, 3, false); + Function_Add("ini_write_string", 3, 3, false); + Function_Add("ini_write_real", 3, 3, false); + Function_Add("ini_key_exists", 2, 2, false); + Function_Add("ini_section_exists", 1, 1, false); + Function_Add("ini_key_delete", 2, 2, false); + Function_Add("ini_section_delete", 1, 1, false); + Function_Add("http_post_string", 2, 2, false); + Function_Add("http_get", 1, 1, false); + Function_Add("move_random", 2, 2, false, true); + Function_Add("place_free", 2, 2, false, true); + Function_Add("place_empty", 2, 2, false, true); + Function_Add("place_meeting", 3, 3, false, true); + Function_Add("place_snapped", 2, 2, false, true); + Function_Add("move_snap", 2, 2, false, true); + Function_Add("move_towards_point", 3, 3, false, true); + Function_Add("move_contact", 1, 1, false, true); + Function_Add("move_contact_solid", 2, 2, false, true); + Function_Add("move_contact_all", 2, 2, false, true); + Function_Add("move_outside_solid", 2, 2, false, true); + Function_Add("move_outside_all", 2, 2, false, true); + Function_Add("move_bounce", 1, 1, false, true); + Function_Add("move_bounce_solid", 1, 1, false, true); + Function_Add("move_bounce_all", 1, 1, false, true); + Function_Add("move_wrap", 3, 3, false, true); + Function_Add("motion_set", 2, 2, false, true); + Function_Add("motion_add", 2, 2, false, true); + Function_Add("distance_to_point", 2, 2, false, true); + Function_Add("distance_to_object", 1, 1, false, true); + Function_Add("path_start", 4, 4, false, true); + Function_Add("path_end", 0, 0, false, true); + Function_Add("mp_linear_step", 4, 4, false, true); + Function_Add("mp_linear_path", 5, 5, true, true); + Function_Add("mp_linear_step_object", 4, 4, false, true); + Function_Add("mp_linear_path_object", 5, 5, true, true); + Function_Add("mp_potential_settings", 4, 4, false, true); + Function_Add("mp_potential_step", 4, 4, false, true); + Function_Add("mp_potential_path", 6, 6, true, true); + Function_Add("mp_potential_step_object", 4, 4, false, true); + Function_Add("mp_potential_path_object", 6, 6, true, true); + Function_Add("mp_grid_create", 6, 6, true); + Function_Add("mp_grid_destroy", 1, 1, true); + Function_Add("mp_grid_clear_all", 1, 1, true); + Function_Add("mp_grid_clear_cell", 3, 3, true); + Function_Add("mp_grid_clear_rectangle", 5, 5, true); + Function_Add("mp_grid_add_cell", 3, 3, true); + Function_Add("mp_grid_add_rectangle", 5, 5, true); + Function_Add("mp_grid_add_instances", 3, 3, true, true); + Function_Add("mp_grid_path", 7, 7, true, true); + Function_Add("mp_grid_draw", 1, 1, true); + Function_Add("collision_point", 5, 5, false, true); + Function_Add("collision_rectangle", 7, 7, false, true); + Function_Add("collision_circle", 6, 6, false, true); + Function_Add("collision_ellipse", 7, 7, false, true); + Function_Add("collision_line", 7, 7, false, true); + Function_Add("instance_find", 2, 2, false); + Function_Add("instance_exists", 1, 1, false); + Function_Add("instance_number", 1, 1, false); + Function_Add("instance_position", 3, 3, false); + Function_Add("instance_nearest", 3, 3, false, true); + Function_Add("instance_furthest", 3, 3, false, true); + Function_Add("instance_place", 3, 3, false, true); + Function_Add("instance_create", 3, 3, false); + Function_Add("instance_copy", 1, 1, false, true); + Function_Add("instance_change", 2, 2, false, true); + Function_Add("instance_destroy", 0, 0, false, true); + Function_Add("instance_sprite", 1, 1, false, true); + Function_Add("position_empty", 2, 2, false, true); + Function_Add("position_meeting", 3, 3, false, true); + Function_Add("position_destroy", 2, 2, false, true); + Function_Add("position_change", 4, 4, false, true); + Function_Add("instance_deactivate_all", 1, 1, false, true); + Function_Add("instance_deactivate_object", 1, 1, false, true); + Function_Add("instance_deactivate_region", 6, 6, false, true); + Function_Add("instance_activate_all", 0, 0, false, true); + Function_Add("instance_activate_object", 1, 1, false, true); + Function_Add("instance_activate_region", 5, 5, false, true); + Function_Add("room_goto", 1, 1, false); + Function_Add("room_goto_previous", 0, 0, false); + Function_Add("room_goto_next", 0, 0, false); + Function_Add("room_previous", 1, 1, false); + Function_Add("room_next", 1, 1, false); + Function_Add("room_restart", 0, 0, false); + Function_Add("game_end", 0, 0, false); + Function_Add("game_restart", 0, 0, false); + Function_Add("game_load", 1, 1, false); + Function_Add("game_save", 1, 1, false); + Function_Add("transition_define", 2, 2, true); + Function_Add("transition_exists", 1, 1, true); + Function_Add("sleep", 1, 1, false); + Function_Add("display_get_width", 0, 0, false); + Function_Add("display_get_height", 0, 0, false); + Function_Add("display_get_colordepth", 0, 0, false); + Function_Add("display_get_frequency", 0, 0, false); + Function_Add("display_get_orientation", 0, 0, false); + Function_Add("display_set_size", 2, 2, true); + Function_Add("display_set_colordepth", 1, 1, true); + Function_Add("display_set_frequency", 1, 1, true); + Function_Add("display_set_all", 4, 4, true); + Function_Add("display_test_all", 4, 4, true); + Function_Add("display_reset", 0, 0, true); + Function_Add("display_mouse_get_x", 0, 0, false); + Function_Add("display_mouse_get_y", 0, 0, false); + Function_Add("display_mouse_set", 2, 2, false); + Function_Add("window_set_visible", 1, 1, false); + Function_Add("window_get_visible", 0, 0, false); + Function_Add("window_set_fullscreen", 1, 1, false); + Function_Add("window_get_fullscreen", 0, 0, false); + Function_Add("window_set_showborder", 1, 1, false); + Function_Add("window_get_showborder", 0, 0, false); + Function_Add("window_set_showicons", 1, 1, false); + Function_Add("window_get_showicons", 0, 0, false); + Function_Add("window_set_stayontop", 1, 1, false); + Function_Add("window_get_stayontop", 0, 0, false); + Function_Add("window_set_sizeable", 1, 1, false); + Function_Add("window_get_sizeable", 0, 0, false); + Function_Add("window_set_caption", 1, 1, false); + Function_Add("window_get_caption", 0, 0, false); + Function_Add("window_set_cursor", 1, 1, false); + Function_Add("window_get_cursor", 0, 0, false); + Function_Add("window_set_color", 1, 1, false); + Function_Add("window_get_color", 0, 0, false); + Function_Add("window_set_position", 2, 2, false); + Function_Add("window_set_size", 2, 2, false); + Function_Add("window_set_rectangle", 4, 4, false); + Function_Add("window_center", 0, 0, false); + Function_Add("window_default", 0, 0, false); + Function_Add("window_get_x", 0, 0, false); + Function_Add("window_get_y", 0, 0, false); + Function_Add("window_get_width", 0, 0, false); + Function_Add("window_get_height", 0, 0, false); + Function_Add("window_set_region_size", 3, 3, false); + Function_Add("window_get_region_width", 0, 0, false); + Function_Add("window_get_region_height", 0, 0, false); + Function_Add("window_set_region_scale", 2, 2, false); + Function_Add("window_get_region_scale", 0, 0, false); + Function_Add("window_mouse_get_x", 0, 0, false); + Function_Add("window_mouse_get_y", 0, 0, false); + Function_Add("window_mouse_set", 2, 2, false); + Function_Add("window_view_mouse_get_x", 1, 1, false); + Function_Add("window_view_mouse_get_y", 1, 1, false); + Function_Add("window_view_mouse_set", 3, 3, false); + Function_Add("window_views_mouse_get_x", 0, 0, false); + Function_Add("window_views_mouse_get_y", 0, 0, false); + Function_Add("window_views_mouse_set", 2, 2, false); + Function_Add("set_synchronization", 1, 1, false); + Function_Add("set_automatic_draw", 1, 1, false); + Function_Add("screen_redraw", 0, 0, false); + Function_Add("screen_refresh", 0, 0, false); + Function_Add("screen_wait_vsync", 0, 0, false); + Function_Add("screen_save", 1, 1, false); + Function_Add("screen_save_part", 5, 5, false); + Function_Add("draw_getpixel", 2, 2, false); + Function_Add("draw_set_color", 1, 1, false); + Function_Add("draw_set_alpha", 1, 1, false); + Function_Add("draw_get_color", 0, 0, false); + Function_Add("draw_get_alpha", 0, 0, false); + Function_Add("make_color", 3, 3, false); + Function_Add("make_color_rgb", 3, 3, false); + Function_Add("make_color_hsv", 3, 3, false); + Function_Add("color_get_red", 1, 1, false); + Function_Add("color_get_green", 1, 1, false); + Function_Add("color_get_blue", 1, 1, false); + Function_Add("color_get_hue", 1, 1, false); + Function_Add("color_get_saturation", 1, 1, false); + Function_Add("color_get_value", 1, 1, false); + Function_Add("merge_color", 3, 3, false); + Function_Add("draw_set_blend_mode", 1, 1, true); + Function_Add("draw_set_blend_mode_ext", 2, 2, true); + Function_Add("draw_clear", 1, 1, false); + Function_Add("draw_clear_alpha", 2, 2, false); + Function_Add("draw_point", 2, 2, false); + Function_Add("draw_line", 4, 4, false); + Function_Add("draw_line_width", 5, 5, false); + Function_Add("draw_rectangle", 5, 5, false); + Function_Add("draw_roundrect", 5, 5, false); + Function_Add("draw_triangle", 7, 7, false); + Function_Add("draw_circle", 4, 4, false); + Function_Add("draw_ellipse", 5, 5, false); + Function_Add("draw_arrow", 5, 5, false); + Function_Add("draw_button", 5, 5, false); + Function_Add("draw_healthbar", 11, 11, false); + Function_Add("draw_path", 4, 4, false); + Function_Add("draw_point_color", 3, 3, true); + Function_Add("draw_line_color", 6, 6, true); + Function_Add("draw_line_width_color", 7, 7, true); + Function_Add("draw_rectangle_color", 9, 9, true); + Function_Add("draw_roundrect_color", 7, 7, true); + Function_Add("draw_triangle_color", 10, 10, true); + Function_Add("draw_circle_color", 6, 6, true); + Function_Add("draw_ellipse_color", 7, 7, true); + Function_Add("draw_set_circle_precision", 1, 1, true); + Function_Add("draw_primitive_begin", 1, 1, true); + Function_Add("draw_primitive_begin_texture", 2, 2, true); + Function_Add("draw_primitive_end", 0, 0, true); + Function_Add("draw_vertex", 2, 2, true); + Function_Add("draw_vertex_color", 4, 4, true); + Function_Add("draw_vertex_texture", 4, 4, true); + Function_Add("draw_vertex_texture_color", 6, 6, true); + Function_Add("sprite_get_texture", 2, 2, true); + Function_Add("background_get_texture", 1, 1, true); + Function_Add("texture_exists", 1, 1, true); + Function_Add("texture_set_interpolation", 1, 1, true); + Function_Add("texture_set_blending", 1, 1, true); + Function_Add("texture_set_repeat", 1, 1, true); + Function_Add("texture_get_width", 1, 1, true); + Function_Add("texture_get_height", 1, 1, true); + Function_Add("texture_preload", 1, 1, true); + Function_Add("texture_set_priority", 2, 2, true); + Function_Add("draw_set_font", 1, 1, false); + Function_Add("draw_set_halign", 1, 1, false); + Function_Add("draw_set_valign", 1, 1, false); + Function_Add("string_width", 1, 1, false); + Function_Add("string_height", 1, 1, false); + Function_Add("string_width_ext", 3, 3, false); + Function_Add("string_height_ext", 3, 3, false); + Function_Add("draw_text", 3, 3, false); + Function_Add("draw_text_ext", 5, 5, false); + Function_Add("draw_text_transformed", 6, 6, true); + Function_Add("draw_text_ext_transformed", 8, 8, true); + Function_Add("draw_text_color", 8, 8, true); + Function_Add("draw_text_transformed_color", 11, 11, true); + Function_Add("draw_text_ext_color", 10, 10, true); + Function_Add("draw_text_ext_transformed_color", 13, 13, true); + Function_Add("draw_self", 0, 0, false, true); + Function_Add("draw_sprite", 4, 4, false, true); + Function_Add("draw_sprite_pos", 11, 11, false, true); + Function_Add("draw_sprite_ext", 9, 9, true, true); + Function_Add("draw_sprite_stretched", 6, 6, false, true); + Function_Add("draw_sprite_stretched_ext", 8, 8, true, true); + Function_Add("draw_sprite_part", 8, 8, false, true); + Function_Add("draw_sprite_part_ext", 12, 12, true, true); + Function_Add("draw_sprite_general", 16, 16, true, true); + Function_Add("draw_sprite_tiled", 4, 4, false, true); + Function_Add("draw_sprite_tiled_ext", 8, 8, true, true); + Function_Add("draw_background", 3, 3, false); + Function_Add("draw_background_ext", 8, 8, true); + Function_Add("draw_background_stretched", 5, 5, false); + Function_Add("draw_background_stretched_ext", 7, 7, true); + Function_Add("draw_background_part", 7, 7, false); + Function_Add("draw_background_part_ext", 11, 11, true); + Function_Add("draw_background_general", 15, 15, true); + Function_Add("draw_background_tiled", 3, 3, false); + Function_Add("draw_background_tiled_ext", 7, 7, true); + Function_Add("tile_get_x", 1, 1, false); + Function_Add("tile_get_y", 1, 1, false); + Function_Add("tile_get_left", 1, 1, false); + Function_Add("tile_get_top", 1, 1, false); + Function_Add("tile_get_width", 1, 1, false); + Function_Add("tile_get_height", 1, 1, false); + Function_Add("tile_get_depth", 1, 1, false); + Function_Add("tile_get_visible", 1, 1, false); + Function_Add("tile_get_xscale", 1, 1, false); + Function_Add("tile_get_yscale", 1, 1, false); + Function_Add("tile_get_blend", 1, 1, false); + Function_Add("tile_get_alpha", 1, 1, false); + Function_Add("tile_get_background", 1, 1, false); + Function_Add("tile_set_visible", 2, 2, false); + Function_Add("tile_set_background", 2, 2, false); + Function_Add("tile_set_region", 5, 5, false); + Function_Add("tile_set_position", 3, 3, false); + Function_Add("tile_set_depth", 2, 2, false); + Function_Add("tile_set_scale", 3, 3, false); + Function_Add("tile_set_blend", 2, 2, true); + Function_Add("tile_set_alpha", 2, 2, false); + Function_Add("tile_add", 8, 8, false); + Function_Add("tile_find", 3, 3, false); + Function_Add("tile_exists", 1, 1, false); + Function_Add("tile_delete", 1, 1, false); + Function_Add("tile_delete_at", 3, 3, false); + Function_Add("tile_layer_hide", 1, 1, false); + Function_Add("tile_layer_show", 1, 1, false); + Function_Add("tile_layer_delete", 1, 1, false); + Function_Add("tile_layer_shift", 3, 3, false); + Function_Add("tile_layer_find", 3, 3, false); + Function_Add("tile_layer_delete_at", 3, 3, false); + Function_Add("tile_layer_depth", 2, 2, false); + Function_Add("surface_create", 2, 2, true); + Function_Add("surface_create_ext", 3, 3, true); + Function_Add("surface_free", 1, 1, true); + Function_Add("surface_exists", 1, 1, true); + Function_Add("surface_get_width", 1, 1, true); + Function_Add("surface_get_height", 1, 1, true); + Function_Add("surface_get_texture", 1, 1, true); + Function_Add("surface_set_target", 1, 1, true); + Function_Add("surface_reset_target", 0, 0, true); + Function_Add("draw_surface", 3, 3, true); + Function_Add("draw_surface_ext", 8, 8, true); + Function_Add("draw_surface_stretched", 5, 5, true); + Function_Add("draw_surface_stretched_ext", 7, 7, true); + Function_Add("draw_surface_part", 7, 7, true); + Function_Add("draw_surface_part_ext", 11, 11, true); + Function_Add("draw_surface_general", 15, 15, true); + Function_Add("draw_surface_tiled", 3, 3, true); + Function_Add("draw_surface_tiled_ext", 7, 7, true); + Function_Add("surface_save", 2, 2, true); + Function_Add("surface_save_part", 6, 6, true); + Function_Add("surface_getpixel", 3, 3, true); + Function_Add("surface_copy", 4, 4, true); + Function_Add("surface_copy_part", 8, 8, true); + Function_Add("splash_show_video", 2, 2, true); + Function_Add("splash_show_text", 2, 2, true); + Function_Add("splash_show_image", 2, 2, true); + Function_Add("splash_show_web", 2, 2, true); + Function_Add("splash_set_caption", 1, 1, true); + Function_Add("splash_set_fullscreen", 1, 1, true); + Function_Add("splash_set_border", 1, 1, true); + Function_Add("splash_set_size", 2, 2, true); + Function_Add("splash_set_adapt", 1, 1, true); + Function_Add("splash_set_top", 1, 1, true); + Function_Add("splash_set_color", 1, 1, true); + Function_Add("splash_set_main", 1, 1, true); + Function_Add("splash_set_scale", 1, 1, true); + Function_Add("splash_set_cursor", 1, 1, true); + Function_Add("splash_set_interrupt", 1, 1, true); + Function_Add("splash_set_stop_key", 1, 1, true); + Function_Add("splash_set_stop_mouse", 1, 1, true); + Function_Add("splash_set_close_button", 1, 1, true); + Function_Add("splash_set_position", 1, 1, true); + Function_Add("show_image", 3, 3, true); + Function_Add("show_video", 3, 3, true); + Function_Add("show_text", 4, 4, true); + Function_Add("show_message", 1, 1, false); + Function_Add("show_question", 1, 1, false); + Function_Add("show_error", 2, 2, false); + Function_Add("show_info", 0, 0, false); + Function_Add("load_info", 1, 1, false); + Function_Add("highscore_show", 1, 1, false); + Function_Add("highscore_set_background", 1, 1, false); + Function_Add("highscore_set_border", 1, 1, false); + Function_Add("highscore_set_font", 3, 3, false); + Function_Add("highscore_set_strings", 3, 3, false); + Function_Add("highscore_set_colors", 3, 3, false); + Function_Add("highscore_show_ext", 7, 7, false); + Function_Add("highscore_clear", 0, 0, false); + Function_Add("highscore_add", 2, 2, false); + Function_Add("highscore_add_current", 0, 0, false); + Function_Add("highscore_value", 1, 1, false); + Function_Add("highscore_name", 1, 1, false); + Function_Add("draw_highscore", 4, 4, false); + Function_Add("show_message_ext", 4, 4, false); + Function_Add("message_background", 1, 1, false); + Function_Add("message_button", 1, 1, false); + Function_Add("message_alpha", 1, 1, false); + Function_Add("message_text_font", 4, 4, false); + Function_Add("message_button_font", 4, 4, false); + Function_Add("message_input_font", 4, 4, false); + Function_Add("message_mouse_color", 1, 1, false); + Function_Add("message_input_color", 1, 1, false); + Function_Add("message_position", 2, 2, false); + Function_Add("message_size", 2, 2, false); + Function_Add("message_caption", 2, 2, false); + Function_Add("show_menu", 2, 2, false); + Function_Add("show_menu_pos", 4, 4, false); + Function_Add("get_integer", 2, 2, false); + Function_Add("get_string", 2, 2, false); + Function_Add("get_color", 1, 1, false); + Function_Add("get_open_filename", 2, 2, false); + Function_Add("get_save_filename", 2, 2, false); + Function_Add("get_directory", 1, 1, false); + Function_Add("get_directory_alt", 2, 2, false); + Function_Add("keyboard_get_numlock", 0, 0, false); + Function_Add("keyboard_set_numlock", 1, 1, false); + Function_Add("keyboard_key_press", 1, 1, false); + Function_Add("keyboard_key_release", 1, 1, false); + Function_Add("keyboard_set_map", 2, 2, false); + Function_Add("keyboard_get_map", 1, 1, false); + Function_Add("keyboard_unset_map", 0, 0, false); + Function_Add("keyboard_check", 1, 1, false); + Function_Add("keyboard_check_pressed", 1, 1, false); + Function_Add("keyboard_check_released", 1, 1, false); + Function_Add("keyboard_check_direct", 1, 1, false); + Function_Add("mouse_check_button", 1, 1, false); + Function_Add("mouse_check_button_pressed", 1, 1, false); + Function_Add("mouse_check_button_released", 1, 1, false); + Function_Add("joystick_exists", 1, 1, false); + Function_Add("joystick_direction", 1, 1, false); + Function_Add("joystick_name", 1, 1, false); + Function_Add("joystick_axes", 1, 1, false); + Function_Add("joystick_buttons", 1, 1, false); + Function_Add("joystick_has_pov", 1, 1, false); + Function_Add("joystick_check_button", 2, 2, false); + Function_Add("joystick_xpos", 1, 1, false); + Function_Add("joystick_ypos", 1, 1, false); + Function_Add("joystick_zpos", 1, 1, false); + Function_Add("joystick_rpos", 1, 1, false); + Function_Add("joystick_upos", 1, 1, false); + Function_Add("joystick_vpos", 1, 1, false); + Function_Add("joystick_pov", 1, 1, false); + Function_Add("keyboard_clear", 1, 1, false); + Function_Add("mouse_clear", 1, 1, false); + Function_Add("io_clear", 0, 0, false); + Function_Add("io_handle", 0, 0, false); + Function_Add("keyboard_wait", 0, 0, false); + Function_Add("mouse_wait", 0, 0, false); + Function_Add("is_real", 1, 1, false); + Function_Add("is_string", 1, 1, false); + Function_Add("random", 1, 1, false); + Function_Add("random_range", 2, 2, false); + Function_Add("irandom", 1, 1, false); + Function_Add("irandom_range", 2, 2, false); + Function_Add("random_set_seed", 1, 1, false); + Function_Add("random_get_seed", 0, 0, false); + Function_Add("randomize", 0, 0, false); + Function_Add("abs", 1, 1, false); + Function_Add("round", 1, 1, false); + Function_Add("floor", 1, 1, false); + Function_Add("ceil", 1, 1, false); + Function_Add("sign", 1, 1, false); + Function_Add("frac", 1, 1, false); + Function_Add("sqrt", 1, 1, false); + Function_Add("sqr", 1, 1, false); + Function_Add("exp", 1, 1, false); + Function_Add("ln", 1, 1, false); + Function_Add("log2", 1, 1, false); + Function_Add("log10", 1, 1, false); + Function_Add("sin", 1, 1, false); + Function_Add("cos", 1, 1, false); + Function_Add("tan", 1, 1, false); + Function_Add("arcsin", 1, 1, false); + Function_Add("arccos", 1, 1, false); + Function_Add("arctan", 1, 1, false); + Function_Add("arctan2", 2, 2, false); + Function_Add("degtorad", 1, 1, false); + Function_Add("radtodeg", 1, 1, false); + Function_Add("power", 2, 2, false); + Function_Add("logn", 2, 2, false); + Function_Add("min", -1, -1, false); + Function_Add("max", -1, -1, false); + Function_Add("min3", 3, 3, false); + Function_Add("max3", 3, 3, false); + Function_Add("mean", -1, -1, false); + Function_Add("median", -1, -1, false); + Function_Add("choose", -1, -1, false); + Function_Add("clamp", 3, 3, true); + Function_Add("lerp", 3, 3, true); + Function_Add("real", 1, 1, false); + Function_Add("string", 1, 1, false); + Function_Add("string_format", 3, 3, false); + Function_Add("chr", 1, 1, false); + Function_Add("ord", 1, 1, false); + Function_Add("string_length", 1, 1, false); + Function_Add("string_pos", 2, 2, false); + Function_Add("string_copy", 3, 3, false); + Function_Add("string_char_at", 2, 2, false); + Function_Add("string_delete", 3, 3, false); + Function_Add("string_insert", 3, 3, false); + Function_Add("string_lower", 1, 1, false); + Function_Add("string_upper", 1, 1, false); + Function_Add("string_repeat", 2, 2, false); + Function_Add("string_letters", 1, 1, false); + Function_Add("string_digits", 1, 1, false); + Function_Add("string_lettersdigits", 1, 1, false); + Function_Add("string_replace", 3, 3, false); + Function_Add("string_replace_all", 3, 3, false); + Function_Add("string_count", 2, 2, false); + Function_Add("point_distance", 4, 4, false); + Function_Add("point_direction", 4, 4, false); + Function_Add("lengthdir_x", 2, 2, false); + Function_Add("lengthdir_y", 2, 2, false); + Function_Add("event_inherited", 0, 0, false, true, true); + Function_Add("event_perform", 2, 2, false, true, true); + Function_Add("event_user", 1, 1, false, true, true); + Function_Add("event_perform_object", 3, 3, false, true, true); + Function_Add("external_define", -1, -1, true); + Function_Add("external_call", -1, -1, true); + Function_Add("external_free", 1, 1, true); + Function_Add("external_define0", 3, 3, true); + Function_Add("external_call0", 1, 1, true); + Function_Add("external_define1", 4, 4, true); + Function_Add("external_call1", 2, 2, true); + Function_Add("external_define2", 5, 5, true); + Function_Add("external_call2", 3, 3, true); + Function_Add("external_define3", 6, 6, true); + Function_Add("external_call3", 4, 4, true); + Function_Add("external_define4", 7, 7, true); + Function_Add("external_call4", 5, 5, true); + Function_Add("external_define5", 3, 3, true); + Function_Add("external_call5", 6, 6, true); + Function_Add("external_define6", 3, 3, true); + Function_Add("external_call6", 7, 7, true); + Function_Add("external_define7", 3, 3, true); + Function_Add("external_call7", 8, 8, true); + Function_Add("external_define8", 3, 3, true); + Function_Add("external_call8", 9, 9, true); + Function_Add("execute_string", -1, -1, false); + Function_Add("execute_file", -1, -1, false); + Function_Add("window_handle", 0, 0, false); + Function_Add("show_debug_message", 1, 1, false); + Function_Add("set_program_priority", 1, 1, false); + Function_Add("set_application_title", 1, 1, false); + Function_Add("variable_global_exists", 1, 1, false); + Function_Add("variable_global_get", 1, 1, false); + Function_Add("variable_global_array_get", 2, 2, false); + Function_Add("variable_global_array2_get", 3, 3, false); + Function_Add("variable_global_set", 2, 2, false); + Function_Add("variable_global_array_set", 3, 3, false); + Function_Add("variable_global_array2_set", 4, 4, false); + Function_Add("variable_local_exists", 1, 1, false, true); + Function_Add("variable_local_get", 1, 1, false, true); + Function_Add("variable_local_array_get", 2, 2, false, true); + Function_Add("variable_local_array2_get", 3, 3, false, true); + Function_Add("variable_local_set", 2, 2, false, true); + Function_Add("variable_local_array_set", 3, 3, false, true); + Function_Add("variable_local_array2_set", 4, 4, false, true); + Function_Add("clipboard_has_text", 0, 0, false); + Function_Add("clipboard_set_text", 1, 1, false); + Function_Add("clipboard_get_text", 0, 0, false); + Function_Add("date_current_datetime", 0, 0, false); + Function_Add("date_current_date", 0, 0, false); + Function_Add("date_current_time", 0, 0, false); + Function_Add("date_create_datetime", 6, 6, false); + Function_Add("date_create_date", 3, 3, false); + Function_Add("date_create_time", 3, 3, false); + Function_Add("date_valid_datetime", 6, 6, false); + Function_Add("date_valid_date", 3, 3, false); + Function_Add("date_valid_time", 3, 3, false); + Function_Add("date_inc_year", 2, 2, false); + Function_Add("date_inc_month", 2, 2, false); + Function_Add("date_inc_week", 2, 2, false); + Function_Add("date_inc_day", 2, 2, false); + Function_Add("date_inc_hour", 2, 2, false); + Function_Add("date_inc_minute", 2, 2, false); + Function_Add("date_inc_second", 2, 2, false); + Function_Add("date_get_year", 1, 1, false); + Function_Add("date_get_month", 1, 1, false); + Function_Add("date_get_week", 1, 1, false); + Function_Add("date_get_day", 1, 1, false); + Function_Add("date_get_hour", 1, 1, false); + Function_Add("date_get_minute", 1, 1, false); + Function_Add("date_get_second", 1, 1, false); + Function_Add("date_get_weekday", 1, 1, false); + Function_Add("date_get_day_of_year", 1, 1, false); + Function_Add("date_get_hour_of_year", 1, 1, false); + Function_Add("date_get_minute_of_year", 1, 1, false); + Function_Add("date_get_second_of_year", 1, 1, false); + Function_Add("date_year_span", 2, 2, false); + Function_Add("date_month_span", 2, 2, false); + Function_Add("date_week_span", 2, 2, false); + Function_Add("date_day_span", 2, 2, false); + Function_Add("date_hour_span", 2, 2, false); + Function_Add("date_minute_span", 2, 2, false); + Function_Add("date_second_span", 2, 2, false); + Function_Add("date_compare_datetime", 2, 2, false); + Function_Add("date_compare_date", 2, 2, false); + Function_Add("date_compare_time", 2, 2, false); + Function_Add("date_date_of", 1, 1, false); + Function_Add("date_time_of", 1, 1, false); + Function_Add("date_datetime_string", 1, 1, false); + Function_Add("date_date_string", 1, 1, false); + Function_Add("date_time_string", 1, 1, false); + Function_Add("date_days_in_month", 1, 1, false); + Function_Add("date_days_in_year", 1, 1, false); + Function_Add("date_leap_year", 1, 1, false); + Function_Add("date_is_today", 1, 1, false); + Function_Add("part_type_create", 0, 0, true); + Function_Add("part_type_destroy", 1, 1, true); + Function_Add("part_type_exists", 1, 1, true); + Function_Add("part_type_clear", 1, 1, true); + Function_Add("part_type_shape", 2, 2, true); + Function_Add("part_type_sprite", 5, 5, true); + Function_Add("part_type_size", 5, 5, true); + Function_Add("part_type_scale", 3, 3, true); + Function_Add("part_type_life", 3, 3, true); + Function_Add("part_type_step", 3, 3, true); + Function_Add("part_type_death", 3, 3, true); + Function_Add("part_type_speed", 5, 5, true); + Function_Add("part_type_direction", 5, 5, true); + Function_Add("part_type_orientation", 6, 6, true); + Function_Add("part_type_gravity", 3, 3, true); + Function_Add("part_type_color_mix", 3, 3, true); + Function_Add("part_type_color_rgb", 7, 7, true); + Function_Add("part_type_color_hsv", 7, 7, true); + Function_Add("part_type_color1", 2, 2, true); + Function_Add("part_type_color2", 3, 3, true); + Function_Add("part_type_color3", 4, 4, true); + Function_Add("part_type_color", 4, 4, true); + Function_Add("part_type_alpha1", 2, 2, true); + Function_Add("part_type_alpha2", 3, 3, true); + Function_Add("part_type_alpha3", 4, 4, true); + Function_Add("part_type_alpha", 4, 4, true); + Function_Add("part_type_blend", 2, 2, true); + Function_Add("part_system_create", 0, 0, true); + Function_Add("part_system_destroy", 1, 1, true); + Function_Add("part_system_exists", 1, 1, true); + Function_Add("part_system_clear", 1, 1, true); + Function_Add("part_system_draw_order", 2, 2, true); + Function_Add("part_system_depth", 2, 2, true); + Function_Add("part_system_position", 3, 3, true); + Function_Add("part_system_automatic_update", 2, 2, true); + Function_Add("part_system_automatic_draw", 2, 2, true); + Function_Add("part_system_update", 1, 1, true); + Function_Add("part_system_drawit", 1, 1, true); + Function_Add("part_particles_create", 5, 5, true); + Function_Add("part_particles_create_color", 6, 6, true); + Function_Add("part_particles_clear", 1, 1, true); + Function_Add("part_particles_count", 1, 1, true); + Function_Add("part_emitter_create", 1, 1, true); + Function_Add("part_emitter_destroy", 2, 2, true); + Function_Add("part_emitter_destroy_all", 1, 1, true); + Function_Add("part_emitter_exists", 2, 2, true); + Function_Add("part_emitter_clear", 2, 2, true); + Function_Add("part_emitter_region", 8, 8, true); + Function_Add("part_emitter_burst", 4, 4, true); + Function_Add("part_emitter_stream", 4, 4, true); + Function_Add("part_attractor_create", 1, 1, true); + Function_Add("part_attractor_destroy", 2, 2, true); + Function_Add("part_attractor_destroy_all", 1, 1, true); + Function_Add("part_attractor_exists", 2, 2, true); + Function_Add("part_attractor_clear", 2, 2, true); + Function_Add("part_attractor_position", 4, 4, true); + Function_Add("part_attractor_force", 6, 6, true); + Function_Add("part_destroyer_create", 1, 1, true); + Function_Add("part_destroyer_destroy", 2, 2, true); + Function_Add("part_destroyer_destroy_all", 1, 1, true); + Function_Add("part_destroyer_exists", 2, 2, true); + Function_Add("part_destroyer_clear", 2, 2, true); + Function_Add("part_destroyer_region", 7, 7, true); + Function_Add("part_deflector_create", 1, 1, true); + Function_Add("part_deflector_destroy", 2, 2, true); + Function_Add("part_deflector_destroy_all", 1, 1, true); + Function_Add("part_deflector_exists", 2, 2, true); + Function_Add("part_deflector_clear", 2, 2, true); + Function_Add("part_deflector_region", 6, 6, true); + Function_Add("part_deflector_kind", 3, 3, true); + Function_Add("part_deflector_friction", 3, 3, true); + Function_Add("part_changer_create", 1, 1, true); + Function_Add("part_changer_destroy", 2, 2, true); + Function_Add("part_changer_destroy_all", 1, 1, true); + Function_Add("part_changer_exists", 2, 2, true); + Function_Add("part_changer_clear", 2, 2, true); + Function_Add("part_changer_region", 7, 7, true); + Function_Add("part_changer_kind", 3, 3, true); + Function_Add("part_changer_types", 4, 4, true); + Function_Add("effect_create_below", 5, 5, true); + Function_Add("effect_create_above", 5, 5, true); + Function_Add("effect_clear", 0, 0, true); + Function_Add("sprite_name", 1, 1, false); + Function_Add("sprite_exists", 1, 1, false); + Function_Add("sprite_get_name", 1, 1, false); + Function_Add("sprite_get_number", 1, 1, false); + Function_Add("sprite_get_width", 1, 1, false); + Function_Add("sprite_get_height", 1, 1, false); + Function_Add("sprite_get_transparent", 1, 1, false); + Function_Add("sprite_get_smooth", 1, 1, false); + Function_Add("sprite_get_preload", 1, 1, false); + Function_Add("sprite_get_xoffset", 1, 1, false); + Function_Add("sprite_get_yoffset", 1, 1, false); + Function_Add("sprite_get_bbox_mode", 1, 1, false); + Function_Add("sprite_get_bbox_left", 1, 1, false); + Function_Add("sprite_get_bbox_right", 1, 1, false); + Function_Add("sprite_get_bbox_top", 1, 1, false); + Function_Add("sprite_get_bbox_bottom", 1, 1, false); + Function_Add("sprite_get_precise", 1, 1, false); + Function_Add("sprite_collision_mask", 9, 9, false); + Function_Add("sprite_set_offset", 3, 3, true); + Function_Add("sprite_set_bbox_mode", 2, 2, true); + Function_Add("sprite_set_bbox", 5, 5, true); + Function_Add("sprite_set_precise", 2, 2, true); + Function_Add("sprite_set_alpha_from_sprite", 2, 2, true); + Function_Add("sprite_create_from_screen", 10, 10, true); + Function_Add("sprite_add_from_screen", 5, 5, true); + Function_Add("sprite_create_from_surface", 11, 11, true); + Function_Add("sprite_add_from_surface", 6, 6, true); + Function_Add("sprite_add", 8, 8, true); + Function_Add("sprite_replace", 9, 9, true); + Function_Add("sprite_add_alpha", 6, 6, true); + Function_Add("sprite_replace_alpha", 7, 7, true); + Function_Add("sprite_delete", 1, 1, true); + Function_Add("sprite_duplicate", 1, 1, true); + Function_Add("sprite_assign", 2, 2, true); + Function_Add("sprite_merge", 2, 2, true); + Function_Add("sprite_save", 3, 3, true); + Function_Add("sprite_set_cache_size", 2, 2, true); + Function_Add("sprite_set_cache_size_ext", 3, 3, true); + Function_Add("background_name", 1, 1, false); + Function_Add("background_exists", 1, 1, false); + Function_Add("background_get_name", 1, 1, false); + Function_Add("background_get_width", 1, 1, false); + Function_Add("background_get_height", 1, 1, false); + Function_Add("background_get_transparent", 1, 1, false); + Function_Add("background_get_smooth", 1, 1, false); + Function_Add("background_get_preload", 1, 1, false); + Function_Add("background_set_alpha_from_background", 2, 2, true); + Function_Add("background_create_from_screen", 7, 7, true); + Function_Add("background_create_from_surface", 8, 8, true); + Function_Add("background_create_color", 4, 3, true); + Function_Add("background_create_gradient", 6, 6, true); + Function_Add("background_add", 4, 4, true); + Function_Add("background_replace", 5, 5, true); + Function_Add("background_add_alpha", 2, 2, true); + Function_Add("background_replace_alpha", 3, 3, true); + Function_Add("background_delete", 1, 1, true); + Function_Add("background_duplicate", 1, 1, true); + Function_Add("background_assign", 2, 2, true); + Function_Add("background_save", 2, 2, true); + Function_Add("sound_name", 1, 1, false); + Function_Add("sound_exists", 1, 1, false); + Function_Add("sound_get_name", 1, 1, false); + Function_Add("sound_get_kind", 1, 1, false); + Function_Add("sound_get_preload", 1, 1, false); + Function_Add("sound_discard", 1, 1, false); + Function_Add("sound_restore", 1, 1, false); + Function_Add("sound_add", 3, 3, true); + Function_Add("sound_replace", 4, 4, true); + Function_Add("sound_delete", 1, 1, true); + Function_Add("font_name", 1, 1, false); + Function_Add("font_exists", 1, 1, false); + Function_Add("font_get_name", 1, 1, false); + Function_Add("font_get_fontname", 1, 1, false); + Function_Add("font_get_size", 1, 1, false); + Function_Add("font_get_bold", 1, 1, false); + Function_Add("font_get_italic", 1, 1, false); + Function_Add("font_get_first", 1, 1, false); + Function_Add("font_get_last", 1, 1, false); + Function_Add("font_add", 6, 6, true); + Function_Add("font_replace", 7, 7, true); + Function_Add("font_add_sprite", 4, 4, true); + Function_Add("font_replace_sprite", 5, 5, true); + Function_Add("font_delete", 1, 1, true); + Function_Add("script_name", 1, 1, false); + Function_Add("script_exists", 1, 1, false); + Function_Add("script_get_name", 1, 1, false); + Function_Add("script_get_text", 1, 1, false); + Function_Add("script_execute", -1, -1, false); + Function_Add("path_name", 1, 1, false); + Function_Add("path_exists", 1, 1, false); + Function_Add("path_get_name", 1, 1, false); + Function_Add("path_get_length", 1, 1, false); + Function_Add("path_get_kind", 1, 1, false); + Function_Add("path_get_closed", 1, 1, false); + Function_Add("path_get_precision", 1, 1, false); + Function_Add("path_get_number", 1, 1, false); + Function_Add("path_get_point_x", 2, 2, false); + Function_Add("path_get_point_y", 2, 2, false); + Function_Add("path_get_point_speed", 2, 2, false); + Function_Add("path_get_x", 2, 2, false); + Function_Add("path_get_y", 2, 2, false); + Function_Add("path_get_speed", 2, 2, false); + Function_Add("path_set_kind", 2, 2, true); + Function_Add("path_set_closed", 2, 2, true); + Function_Add("path_set_precision", 2, 2, true); + Function_Add("path_add", 0, 0, true); + Function_Add("path_duplicate", 1, 1, true); + Function_Add("path_assign", 2, 2, true); + Function_Add("path_append", 2, 2, true); + Function_Add("path_delete", 1, 1, true); + Function_Add("path_add_point", 4, 4, true); + Function_Add("path_insert_point", 5, 5, true); + Function_Add("path_change_point", 5, 5, true); + Function_Add("path_delete_point", 2, 2, true); + Function_Add("path_clear_points", 1, 1, true); + Function_Add("path_reverse", 1, 1, true); + Function_Add("path_mirror", 1, 1, true); + Function_Add("path_flip", 1, 1, true); + Function_Add("path_rotate", 2, 2, true); + Function_Add("path_scale", 3, 3, true); + Function_Add("path_shift", 3, 3, true); + Function_Add("timeline_name", 1, 1, false); + Function_Add("timeline_exists", 1, 1, false); + Function_Add("timeline_get_name", 1, 1, false); + Function_Add("timeline_add", 0, 0, true); + Function_Add("timeline_delete", 1, 1, true); + Function_Add("timeline_moment_clear", 2, 2, true); + Function_Add("timeline_moment_add", 3, 3, true); + Function_Add("object_name", 1, 1, false); + Function_Add("object_exists", 1, 1, false); + Function_Add("object_get_name", 1, 1, false); + Function_Add("object_get_sprite", 1, 1, false); + Function_Add("object_get_solid", 1, 1, false); + Function_Add("object_get_visible", 1, 1, false); + Function_Add("object_get_depth", 1, 1, false); + Function_Add("object_get_persistent", 1, 1, false); + Function_Add("object_get_mask", 1, 1, false); + Function_Add("object_get_parent", 1, 1, false); + Function_Add("object_is_ancestor", 2, 2, false); + Function_Add("object_set_sprite", 2, 2, true); + Function_Add("object_set_solid", 2, 2, true); + Function_Add("object_set_visible", 2, 2, true); + Function_Add("object_set_depth", 2, 2, true); + Function_Add("object_set_persistent", 2, 2, true); + Function_Add("object_set_mask", 2, 2, true); + Function_Add("object_set_parent", 2, 2, true); + Function_Add("object_add", 0, 0, true); + Function_Add("object_delete", 1, 1, true); + Function_Add("object_event_clear", 3, 3, true); + Function_Add("object_event_add", 4, 4, true); + Function_Add("room_name", 1, 1, false); + Function_Add("room_exists", 1, 1, false); + Function_Add("room_get_name", 1, 1, false); + Function_Add("room_set_width", 2, 2, true); + Function_Add("room_set_height", 2, 2, true); + Function_Add("room_set_caption", 2, 2, true); + Function_Add("room_set_persistent", 2, 2, true); + Function_Add("room_set_code", 2, 2, true); + Function_Add("room_set_background_color", 3, 3, true); + Function_Add("room_set_background", 12, 12, true); + Function_Add("room_set_view", 16, 16, true); + Function_Add("room_set_view_enabled", 2, 2, true); + Function_Add("room_add", 0, 0, true); + Function_Add("room_duplicate", 1, 1, true); + Function_Add("room_assign", 2, 2, true); + Function_Add("room_instance_add", 4, 4, true); + Function_Add("room_instance_clear", 1, 1, true); + Function_Add("room_tile_add", 9, 9, true); + Function_Add("room_tile_add_ext", 12, 12, true); + Function_Add("room_tile_clear", 1, 1, true); + Function_Add("sound_play", 1, 1, false); + Function_Add("sound_loop", 1, 1, false); + Function_Add("sound_stop", 1, 1, false); + Function_Add("sound_stop_all", 0, 0, false); + Function_Add("sound_isplaying", 1, 1, false); + Function_Add("sound_volume", 2, 2, false); + Function_Add("sound_fade", 3, 3, false); + Function_Add("sound_pan", 2, 2, false); + Function_Add("sound_background_tempo", 1, 1, false); + Function_Add("sound_global_volume", 1, 1, false); + Function_Add("sound_set_search_directory", 1, 1, false); + Function_Add("sound_effect_set", 2, 2, true); + Function_Add("sound_effect_chorus", 8, 8, true); + Function_Add("sound_effect_compressor", 7, 7, true); + Function_Add("sound_effect_echo", 6, 6, true); + Function_Add("sound_effect_flanger", 8, 8, true); + Function_Add("sound_effect_gargle", 3, 3, true); + Function_Add("sound_effect_equalizer", 4, 4, true); + Function_Add("sound_effect_reverb", 5, 5, true); + Function_Add("sound_3d_set_sound_position", 4, 4, true); + Function_Add("sound_3d_set_sound_velocity", 4, 4, true); + Function_Add("sound_3d_set_sound_distance", 3, 3, true); + Function_Add("sound_3d_set_sound_cone", 7, 7, true); + Function_Add("cd_init", 0, 0, true); + Function_Add("cd_present", 0, 0, true); + Function_Add("cd_number", 0, 0, true); + Function_Add("cd_playing", 0, 0, true); + Function_Add("cd_paused", 0, 0, true); + Function_Add("cd_track", 0, 0, true); + Function_Add("cd_length", 0, 0, true); + Function_Add("cd_track_length", 1, 1, true); + Function_Add("cd_position", 0, 0, true); + Function_Add("cd_track_position", 0, 0, true); + Function_Add("cd_play", 2, 2, true); + Function_Add("cd_stop", 0, 0, true); + Function_Add("cd_pause", 0, 0, true); + Function_Add("cd_resume", 0, 0, true); + Function_Add("cd_set_position", 1, 1, true); + Function_Add("cd_set_track_position", 1, 1, true); + Function_Add("cd_open_door", 0, 0, true); + Function_Add("cd_close_door", 0, 0, true); + Function_Add("MCI_command", 1, 1, true); + Function_Add("YoYo_AddVirtualKey", 5, 5, false); + Function_Add("YoYo_DeleteVirtualKey", 1, 1, false); + Function_Add("YoYo_ShowVirtualKey", 1, 1, false); + Function_Add("YoYo_HideVirtualKey", 1, 1, false); + Function_Add("YoYo_LoginAchievements", 0, 0, false); + Function_Add("YoYo_LogoutAchievements", 0, 0, false); + Function_Add("YoYo_PostAchievement", 2, 2, false); + Function_Add("YoYo_PostScore", 2, 2, false); + Function_Add("YoYo_AchievementsAvailable", 0, 0, false); + Function_Add("YoYo_GetDomain", 0, 0, false); + Function_Add("YoYo_OpenURL", 1, 1, false); + Function_Add("YoYo_OpenURL_ext", 2, 2, false); + Function_Add("YoYo_OpenURL_full", 3, 3, false); + Function_Add("YoYo_EnableAds", 5, 5, false); + Function_Add("YoYo_DisableAds", 0, 0, false); + Function_Add("YoYo_LeaveRating", 4, 4, false); + Function_Add("YoYo_GetTimer", 0, 0, false); + Function_Add("YoYo_EnableAlphaBlend", 1, 1, false); + Function_Add("YoYo_GetPlatform", 0, 0, false); + Function_Add("YoYo_GetDevice", 0, 0, false); + Function_Add("YoYo_GetConfig", 0, 0, false); + Function_Add("YoYo_GetTiltX", 0, 0, false); + Function_Add("YoYo_GetTiltY", 0, 0, false); + Function_Add("YoYo_GetTiltZ", 0, 0, false); + Function_Add("YoYo_SelectPicture", 0, 0, false); + Function_Add("YoYo_GetPictureSprite", 0, 0, false); + Function_Add("YoYo_IsKeypadOpen", 0, 0, false); + Function_Add("YoYo_OF_StartDashboard", 0, 0, false); + Function_Add("YoYo_OF_AddAchievement", 2, 2, false); + Function_Add("YoYo_OF_AddLeaderboard", 3, 3, false); + Function_Add("YoYo_OF_SendChallenge", 3, 3, false); + Function_Add("YoYo_OF_SendInvite", 1, 1, false); + Function_Add("YoYo_OF_SendSocial", 3, 3, false); + Function_Add("YoYo_OF_SetURL", 1, 1, false); + Function_Add("YoYo_OF_AcceptChallenge", 0, 0, false); + Function_Add("YoYo_OF_IsOnline", 0, 0, false); + Function_Add("YoYo_OF_SendChallengeResult", 2, 2, false); + Function_Add("YoYo_MouseCheckButton", 2, 2, false); + Function_Add("YoYo_MouseCheckButtonPressed", 2, 2, false); + Function_Add("YoYo_MouseCheckButtonReleased", 2, 2, false); + Function_Add("YoYo_MouseX", 1, 1, false); + Function_Add("YoYo_MouseY", 1, 1, false); + Function_Add("YoYo_EnableInAppPurchases", 0, 0, false); + Function_Add("YoYo_RestoreInAppPurchases", 0, 0, false); + Function_Add("YoYo_RetrieveInAppPurchases", 0, 0, false); + Function_Add("YoYo_AcquireInAppPurchase", 1, 1, false); + Function_Add("YoYo_GetPurchasedDetails", 0, 0, false); + Function_Add("YoYo_ProductPurchased", 1, 1, false); + Function_Add("YoYo_FacebookInit", 1, 1, false); + Function_Add("YoYo_FacebookLogin", 1, 1, false); + Function_Add("YoYo_FacebookLoginStatus", 0, 0, false); + Function_Add("YoYo_FacebookGraphRequest", 4, 4, false); + Function_Add("YoYo_FacebookDialog", 3, 3, false); + Function_Add("YoYo_FacebookLogout", 0, 0, false); + Function_Add("YoYo_OSPauseEvent", 0, 0, false); + AddRealConstant("self", -1.0); + AddRealConstant("other", -2.0); + AddRealConstant("all", -3.0); + AddRealConstant("noone", -4.0); + AddRealConstant("global", -5.0); + AddRealConstant("local", -7.0); + AddRealConstant("true", 1.0); + AddRealConstant("false", 0.0); + AddRealConstant("pi", Math.PI); + AddRealConstant("pr_pointlist", 1.0); + AddRealConstant("pr_linelist", 2.0); + AddRealConstant("pr_linestrip", 3.0); + AddRealConstant("pr_trianglelist", 4.0); + AddRealConstant("pr_trianglestrip", 5.0); + AddRealConstant("pr_trianglefan", 6.0); + AddRealConstant("c_aqua", 16776960.0); + AddRealConstant("c_black", 0.0); + AddRealConstant("c_blue", 16711680.0); + AddRealConstant("c_dkgray", 4210752.0); + AddRealConstant("c_fuchsia", 16711935.0); + AddRealConstant("c_gray", 8421504.0); + AddRealConstant("c_green", 32768.0); + AddRealConstant("c_lime", 65280.0); + AddRealConstant("c_ltgray", 12632256.0); + AddRealConstant("c_maroon", 128.0); + AddRealConstant("c_navy", 8388608.0); + AddRealConstant("c_olive", 32896.0); + AddRealConstant("c_purple", 8388736.0); + AddRealConstant("c_red", 255.0); + AddRealConstant("c_silver", 12632256.0); + AddRealConstant("c_teal", 8421376.0); + AddRealConstant("c_white", 16777215.0); + AddRealConstant("c_yellow", 65535.0); + AddRealConstant("c_orange", 4235519.0); + AddRealConstant("bm_normal", 0.0); + AddRealConstant("bm_add", 1.0); + AddRealConstant("bm_max", 2.0); + AddRealConstant("bm_subtract", 3.0); + AddRealConstant("bm_zero", 1.0); + AddRealConstant("bm_one", 2.0); + AddRealConstant("bm_src_color", 3.0); + AddRealConstant("bm_inv_src_color", 4.0); + AddRealConstant("bm_src_alpha", 5.0); + AddRealConstant("bm_inv_src_alpha", 6.0); + AddRealConstant("bm_dest_alpha", 7.0); + AddRealConstant("bm_inv_dest_alpha", 8.0); + AddRealConstant("bm_dest_color", 9.0); + AddRealConstant("bm_inv_dest_color", 10.0); + AddRealConstant("bm_src_alpha_sat", 11.0); + AddRealConstant("se_none", 0.0); + AddRealConstant("se_chorus", 1.0); + AddRealConstant("se_echo", 2.0); + AddRealConstant("se_flanger", 4.0); + AddRealConstant("se_gargle", 8.0); + AddRealConstant("se_reverb", 16.0); + AddRealConstant("se_compressor", 32.0); + AddRealConstant("se_equalizer", 64.0); + AddRealConstant("fa_left", 0.0); + AddRealConstant("fa_center", 1.0); + AddRealConstant("fa_right", 2.0); + AddRealConstant("fa_top", 0.0); + AddRealConstant("fa_middle", 1.0); + AddRealConstant("fa_bottom", 2.0); + AddRealConstant("mb_any", -1.0); + AddRealConstant("mb_none", 0.0); + AddRealConstant("mb_left", 1.0); + AddRealConstant("mb_right", 2.0); + AddRealConstant("mb_middle", 3.0); + AddRealConstant("vk_nokey", 0.0); + AddRealConstant("vk_anykey", 1.0); + AddRealConstant("vk_enter", 13.0); + AddRealConstant("vk_return", 13.0); + AddRealConstant("vk_shift", 16.0); + AddRealConstant("vk_control", 17.0); + AddRealConstant("vk_alt", 18.0); + AddRealConstant("vk_escape", 27.0); + AddRealConstant("vk_space", 32.0); + AddRealConstant("vk_backspace", 8.0); + AddRealConstant("vk_tab", 9.0); + AddRealConstant("vk_pause", 19.0); + AddRealConstant("vk_printscreen", 44.0); + AddRealConstant("vk_left", 37.0); + AddRealConstant("vk_right", 39.0); + AddRealConstant("vk_up", 38.0); + AddRealConstant("vk_down", 40.0); + AddRealConstant("vk_home", 36.0); + AddRealConstant("vk_end", 35.0); + AddRealConstant("vk_delete", 46.0); + AddRealConstant("vk_insert", 45.0); + AddRealConstant("vk_pageup", 33.0); + AddRealConstant("vk_pagedown", 34.0); + AddRealConstant("vk_f1", 112.0); + AddRealConstant("vk_f2", 113.0); + AddRealConstant("vk_f3", 114.0); + AddRealConstant("vk_f4", 115.0); + AddRealConstant("vk_f5", 116.0); + AddRealConstant("vk_f6", 117.0); + AddRealConstant("vk_f7", 118.0); + AddRealConstant("vk_f8", 119.0); + AddRealConstant("vk_f9", 120.0); + AddRealConstant("vk_f10", 121.0); + AddRealConstant("vk_f11", 128.0); + AddRealConstant("vk_f12", 129.0); + AddRealConstant("vk_numpad0", 96.0); + AddRealConstant("vk_numpad1", 97.0); + AddRealConstant("vk_numpad2", 98.0); + AddRealConstant("vk_numpad3", 99.0); + AddRealConstant("vk_numpad4", 100.0); + AddRealConstant("vk_numpad5", 101.0); + AddRealConstant("vk_numpad6", 102.0); + AddRealConstant("vk_numpad7", 103.0); + AddRealConstant("vk_numpad8", 104.0); + AddRealConstant("vk_numpad9", 105.0); + AddRealConstant("vk_divide", 111.0); + AddRealConstant("vk_multiply", 106.0); + AddRealConstant("vk_subtract", 109.0); + AddRealConstant("vk_add", 107.0); + AddRealConstant("vk_decimal", 110.0); + AddRealConstant("vk_lshift", 160.0); + AddRealConstant("vk_lcontrol", 162.0); + AddRealConstant("vk_lalt", 164.0); + AddRealConstant("vk_rshift", 161.0); + AddRealConstant("vk_rcontrol", 163.0); + AddRealConstant("vk_ralt", 165.0); + AddRealConstant("ev_create", 0.0); + AddRealConstant("ev_destroy", 1.0); + AddRealConstant("ev_step", 3.0); + AddRealConstant("ev_alarm", 2.0); + AddRealConstant("ev_keyboard", 5.0); + AddRealConstant("ev_mouse", 6.0); + AddRealConstant("ev_collision", 4.0); + AddRealConstant("ev_other", 7.0); + AddRealConstant("ev_draw", 8.0); + AddRealConstant("ev_keypress", 9.0); + AddRealConstant("ev_keyrelease", 10.0); + AddRealConstant("ev_trigger", 11.0); + AddRealConstant("ev_left_button", 0.0); + AddRealConstant("ev_right_button", 1.0); + AddRealConstant("ev_middle_button", 2.0); + AddRealConstant("ev_no_button", 3.0); + AddRealConstant("ev_left_press", 4.0); + AddRealConstant("ev_right_press", 5.0); + AddRealConstant("ev_middle_press", 6.0); + AddRealConstant("ev_left_release", 7.0); + AddRealConstant("ev_right_release", 8.0); + AddRealConstant("ev_middle_release", 9.0); + AddRealConstant("ev_mouse_enter", 10.0); + AddRealConstant("ev_mouse_leave", 11.0); + AddRealConstant("ev_global_press", 12.0); + AddRealConstant("ev_global_release", 13.0); + AddRealConstant("ev_joystick1_left", 16.0); + AddRealConstant("ev_joystick1_right", 17.0); + AddRealConstant("ev_joystick1_up", 18.0); + AddRealConstant("ev_joystick1_down", 19.0); + AddRealConstant("ev_joystick1_button1", 21.0); + AddRealConstant("ev_joystick1_button2", 22.0); + AddRealConstant("ev_joystick1_button3", 23.0); + AddRealConstant("ev_joystick1_button4", 24.0); + AddRealConstant("ev_joystick1_button5", 25.0); + AddRealConstant("ev_joystick1_button6", 26.0); + AddRealConstant("ev_joystick1_button7", 27.0); + AddRealConstant("ev_joystick1_button8", 28.0); + AddRealConstant("ev_joystick2_left", 31.0); + AddRealConstant("ev_joystick2_right", 32.0); + AddRealConstant("ev_joystick2_up", 33.0); + AddRealConstant("ev_joystick2_down", 34.0); + AddRealConstant("ev_joystick2_button1", 36.0); + AddRealConstant("ev_joystick2_button2", 37.0); + AddRealConstant("ev_joystick2_button3", 38.0); + AddRealConstant("ev_joystick2_button4", 39.0); + AddRealConstant("ev_joystick2_button5", 40.0); + AddRealConstant("ev_joystick2_button6", 41.0); + AddRealConstant("ev_joystick2_button7", 42.0); + AddRealConstant("ev_joystick2_button8", 43.0); + AddRealConstant("ev_global_left_button", 50.0); + AddRealConstant("ev_global_right_button", 51.0); + AddRealConstant("ev_global_middle_button", 52.0); + AddRealConstant("ev_global_left_press", 53.0); + AddRealConstant("ev_global_right_press", 54.0); + AddRealConstant("ev_global_middle_press", 55.0); + AddRealConstant("ev_global_left_release", 56.0); + AddRealConstant("ev_global_right_release", 57.0); + AddRealConstant("ev_global_middle_release", 58.0); + AddRealConstant("ev_mouse_wheel_up", 60.0); + AddRealConstant("ev_mouse_wheel_down", 61.0); + AddRealConstant("ev_outside", 0.0); + AddRealConstant("ev_boundary", 1.0); + AddRealConstant("ev_game_start", 2.0); + AddRealConstant("ev_game_end", 3.0); + AddRealConstant("ev_room_start", 4.0); + AddRealConstant("ev_room_end", 5.0); + AddRealConstant("ev_no_more_lives", 6.0); + AddRealConstant("ev_animation_end", 7.0); + AddRealConstant("ev_end_of_path", 8.0); + AddRealConstant("ev_no_more_health", 9.0); + AddRealConstant("ev_user0", 10.0); + AddRealConstant("ev_user1", 11.0); + AddRealConstant("ev_user2", 12.0); + AddRealConstant("ev_user3", 13.0); + AddRealConstant("ev_user4", 14.0); + AddRealConstant("ev_user5", 15.0); + AddRealConstant("ev_user6", 16.0); + AddRealConstant("ev_user7", 17.0); + AddRealConstant("ev_user8", 18.0); + AddRealConstant("ev_user9", 19.0); + AddRealConstant("ev_user10", 20.0); + AddRealConstant("ev_user11", 21.0); + AddRealConstant("ev_user12", 22.0); + AddRealConstant("ev_user13", 23.0); + AddRealConstant("ev_user14", 24.0); + AddRealConstant("ev_user15", 25.0); + AddRealConstant("ev_close_button", 30.0); + AddRealConstant("ev_step_normal", 0.0); + AddRealConstant("ev_step_begin", 1.0); + AddRealConstant("ev_step_end", 2.0); + AddRealConstant("ty_real", 0.0); + AddRealConstant("ty_string", 1.0); + AddRealConstant("dll_cdecl", 0.0); + AddRealConstant("dll_stdcall", 1.0); + AddRealConstant("fa_readonly", 1.0); + AddRealConstant("fa_hidden", 2.0); + AddRealConstant("fa_sysfile", 4.0); + AddRealConstant("fa_volumeid", 8.0); + AddRealConstant("fa_directory", 16.0); + AddRealConstant("fa_archive", 32.0); + AddRealConstant("cr_default", 0.0); + AddRealConstant("cr_none", -1.0); + AddRealConstant("cr_arrow", -2.0); + AddRealConstant("cr_arrrow", -3.0); + AddRealConstant("cr_cross", -4.0); + AddRealConstant("cr_beam", -5.0); + AddRealConstant("cr_size_nesw", -6.0); + AddRealConstant("cr_size_ns", -7.0); + AddRealConstant("cr_size_nwse", -8.0); + AddRealConstant("cr_size_we", -9.0); + AddRealConstant("cr_uparrow", -10.0); + AddRealConstant("cr_hourglass", -11.0); + AddRealConstant("cr_drag", -12.0); + AddRealConstant("cr_nodrop", -13.0); + AddRealConstant("cr_hsplit", -14.0); + AddRealConstant("cr_vsplit", -15.0); + AddRealConstant("cr_multidrag", -16.0); + AddRealConstant("cr_sqlwait", -17.0); + AddRealConstant("cr_no", -18.0); + AddRealConstant("cr_appstart", -19.0); + AddRealConstant("cr_help", -20.0); + AddRealConstant("cr_handpoint", -21.0); + AddRealConstant("cr_size_all", -22.0); + AddRealConstant("pt_shape_pixel", 0.0); + AddRealConstant("pt_shape_disk", 1.0); + AddRealConstant("pt_shape_square", 2.0); + AddRealConstant("pt_shape_line", 3.0); + AddRealConstant("pt_shape_star", 4.0); + AddRealConstant("pt_shape_circle", 5.0); + AddRealConstant("pt_shape_ring", 6.0); + AddRealConstant("pt_shape_sphere", 7.0); + AddRealConstant("pt_shape_flare", 8.0); + AddRealConstant("pt_shape_spark", 9.0); + AddRealConstant("pt_shape_explosion", 10.0); + AddRealConstant("pt_shape_cloud", 11.0); + AddRealConstant("pt_shape_smoke", 12.0); + AddRealConstant("pt_shape_snow", 13.0); + AddRealConstant("ps_distr_linear", 0.0); + AddRealConstant("ps_distr_gaussian", 1.0); + AddRealConstant("ps_distr_invgaussian", 2.0); + AddRealConstant("ps_shape_rectangle", 0.0); + AddRealConstant("ps_shape_ellipse", 1.0); + AddRealConstant("ps_shape_diamond", 2.0); + AddRealConstant("ps_shape_line", 3.0); + AddRealConstant("ps_force_constant", 0.0); + AddRealConstant("ps_force_linear", 1.0); + AddRealConstant("ps_force_quadratic", 2.0); + AddRealConstant("ps_deflect_vertical", 0.0); + AddRealConstant("ps_deflect_horizontal", 1.0); + AddRealConstant("ps_change_all", 0.0); + AddRealConstant("ps_change_shape", 1.0); + AddRealConstant("ps_change_motion", 2.0); + AddRealConstant("ef_explosion", 0.0); + AddRealConstant("ef_ring", 1.0); + AddRealConstant("ef_ellipse", 2.0); + AddRealConstant("ef_firework", 3.0); + AddRealConstant("ef_smoke", 4.0); + AddRealConstant("ef_smokeup", 5.0); + AddRealConstant("ef_star", 6.0); + AddRealConstant("ef_spark", 7.0); + AddRealConstant("ef_flare", 8.0); + AddRealConstant("ef_cloud", 9.0); + AddRealConstant("ef_rain", 10.0); + AddRealConstant("ef_snow", 11.0); + AddRealConstant("display_landscape", 0.0); + AddRealConstant("display_portrait", 1.0); + AddRealConstant("os_win32", 0.0); + AddRealConstant("os_windows", 0.0); + AddRealConstant("os_maxos", 1.0); + AddRealConstant("os_psp", 2.0); + AddRealConstant("os_ios", 3.0); + AddRealConstant("os_android", 4.0); + AddRealConstant("os_symbian", 5.0); + AddRealConstant("os_linux", 6.0); + AddRealConstant("browser_not_a_browser", -1.0); + AddRealConstant("browser_unknown", 0.0); + AddRealConstant("browser_ie", 1.0); + AddRealConstant("browser_firefox", 2.0); + AddRealConstant("browser_chrome", 3.0); + AddRealConstant("browser_safari", 4.0); + AddRealConstant("browser_safari_mobile", 5.0); + AddRealConstant("browser_opera", 6.0); + AddRealConstant("device_ios_unknown", -1.0); + AddRealConstant("device_ios_ipad", 0.0); + AddRealConstant("device_ios_iphone", 1.0); + AddRealConstant("device_ios_iphone_retina", 2.0); + AddRealConstant("of_challenge_win", 0.0); + AddRealConstant("of_challenge_lose", 1.0); + AddRealConstant("of_challenge_tie", 2.0); + AddRealConstant("leaderboard_type_number", 0.0); + AddRealConstant("leaderboard_type_time_mins_secs", 1.0); + AddRealConstant("phy_joint_anchor_1_x", 0.0); + AddRealConstant("phy_joint_anchor_1_y", 1.0); + AddRealConstant("phy_joint_anchor_2_x", 2.0); + AddRealConstant("phy_joint_anchor_2_y", 3.0); + AddRealConstant("phy_joint_reaction_force_x", 4.0); + AddRealConstant("phy_joint_reaction_force_y", 5.0); + AddRealConstant("phy_joint_reaction_torque", 6.0); + AddRealConstant("phy_joint_motor_speed", 7.0); + AddRealConstant("phy_joint_angle", 8.0); + AddRealConstant("phy_joint_motor_torque", 9.0); + AddRealConstant("phy_joint_max_motor_torque", 10.0); + AddRealConstant("phy_joint_translation", 11.0); + AddRealConstant("phy_joint_speed", 12.0); + AddRealConstant("phy_joint_motor_force", 13.0); + AddRealConstant("phy_joint_max_motor_force", 14.0); + AddRealConstant("phy_joint_length_1", 15.0); + AddRealConstant("phy_joint_length_2", 16.0); + AddRealConstant("phy_debug_render_shapes", 1.0); + AddRealConstant("phy_debug_render_joints", 2.0); + AddRealConstant("phy_debug_render_coms", 4.0); + AddRealConstant("phy_debug_render_aabb", 8.0); + AddRealConstant("phy_debug_render_obb", 16.0); + AddRealConstant("phy_debug_render_core_shapes", 32.0); + AddRealConstant("phy_debug_render_collision_pairs", 64.0); + Variable_BuiltIn_Add("argument_relative", true, false, false, null, null); + Variable_BuiltIn_Add("argument_count", true, false, false, null, null); + Variable_BuiltIn_Add("argument", true, true, true, null, null); + Variable_BuiltIn_Add("argument0", true, true, true, null, null); + Variable_BuiltIn_Add("argument1", true, true, true, null, null); + Variable_BuiltIn_Add("argument2", true, true, true, null, null); + Variable_BuiltIn_Add("argument3", true, true, true, null, null); + Variable_BuiltIn_Add("argument4", true, true, true, null, null); + Variable_BuiltIn_Add("argument5", true, true, true, null, null); + Variable_BuiltIn_Add("argument6", true, true, true, null, null); + Variable_BuiltIn_Add("argument7", true, true, true, null, null); + Variable_BuiltIn_Add("argument8", true, true, true, null, null); + Variable_BuiltIn_Add("argument9", true, true, true, null, null); + Variable_BuiltIn_Add("argument10", true, true, true, null, null); + Variable_BuiltIn_Add("argument11", true, true, true, null, null); + Variable_BuiltIn_Add("argument12", true, true, true, null, null); + Variable_BuiltIn_Add("argument13", true, true, true, null, null); + Variable_BuiltIn_Add("argument14", true, true, true, null, null); + Variable_BuiltIn_Add("argument15", true, true, true, null, null); + Variable_BuiltIn_Add("debug_mode", true, true, true, null, null); + Variable_BuiltIn_Add("room", true, true, true, "set_current_room", "get_current_room"); + Variable_BuiltIn_Add("room_first", true, false, false, null, null); + Variable_BuiltIn_Add("room_last", true, false, false, null, null); + Variable_BuiltIn_Add("transition_kind", true, true, true, null, null); + Variable_BuiltIn_Add("transition_steps", true, true, true, null, null); + Variable_BuiltIn_Add("score", true, true, true, null, null); + Variable_BuiltIn_Add("lives", true, true, true, "set_lives_function", null); + Variable_BuiltIn_Add("health", true, true, true, "set_health_function", null); + Variable_BuiltIn_Add("game_id", true, false, false, null, null); + Variable_BuiltIn_Add("working_directory", true, false, false, null, null); + Variable_BuiltIn_Add("temp_directory", true, false, false, null, null); + Variable_BuiltIn_Add("program_directory", true, false, false, null, null); + Variable_BuiltIn_Add("instance_count", true, false, false, null, "get_instance_count"); + Variable_BuiltIn_Add("instance_id", true, false, false, null, null); + Variable_BuiltIn_Add("room_width", true, false, false, "set_room_width", null); + Variable_BuiltIn_Add("room_height", true, false, false, "set_room_height", null); + Variable_BuiltIn_Add("room_caption", true, true, true, "set_room_caption", null); + Variable_BuiltIn_Add("room_speed", true, true, true, "set_room_speed", null); + Variable_BuiltIn_Add("room_persistent", true, true, true, "room_persistent", null); + Variable_BuiltIn_Add("background_color", true, true, true, "setbackground_color", "getbackground_color"); + Variable_BuiltIn_Add("background_showcolor", true, true, true, "setbackground_showcolor", "getbackground_showcolor"); + Variable_BuiltIn_Array_Add("background_visible", true, true, true); + Variable_BuiltIn_Array_Add("background_foreground", true, true, true); + Variable_BuiltIn_Array_Add("background_index", true, true, true); + Variable_BuiltIn_Array_Add("background_x", true, true, true); + Variable_BuiltIn_Array_Add("background_y", true, true, true); + Variable_BuiltIn_Array_Add("background_width", true, false, false); + Variable_BuiltIn_Array_Add("background_height", true, false, false); + Variable_BuiltIn_Array_Add("background_htiled", true, true, true); + Variable_BuiltIn_Array_Add("background_vtiled", true, true, true); + Variable_BuiltIn_Array_Add("background_xscale", true, true, true); + Variable_BuiltIn_Array_Add("background_yscale", true, true, true); + Variable_BuiltIn_Array_Add("background_hspeed", true, true, true); + Variable_BuiltIn_Array_Add("background_vspeed", true, true, true); + Variable_BuiltIn_Array_Add("background_blend", true, true, true); + Variable_BuiltIn_Array_Add("background_alpha", true, true, true); + Variable_BuiltIn_Add("view_enabled", true, true, true, "set_view_enable", "get_view_enable"); + Variable_BuiltIn_Add("view_current", true, false, false, null, null); + Variable_BuiltIn_Add("view_visible", true, true, true, null, null); + Variable_BuiltIn_Array_Add("view_xview", true, true, true); + Variable_BuiltIn_Array_Add("view_yview", true, true, true); + Variable_BuiltIn_Array_Add("view_wview", true, true, true); + Variable_BuiltIn_Array_Add("view_hview", true, true, true); + Variable_BuiltIn_Array_Add("view_xport", true, true, true); + Variable_BuiltIn_Array_Add("view_yport", true, true, true); + Variable_BuiltIn_Array_Add("view_wport", true, true, true); + Variable_BuiltIn_Array_Add("view_hport", true, true, true); + Variable_BuiltIn_Array_Add("view_angle", true, true, true); + Variable_BuiltIn_Array_Add("view_hborder", true, true, true); + Variable_BuiltIn_Array_Add("view_vborder", true, true, true); + Variable_BuiltIn_Array_Add("view_hspeed", true, true, true); + Variable_BuiltIn_Array_Add("view_vspeed", true, true, true); + Variable_BuiltIn_Array_Add("view_object", true, true, true); + Variable_BuiltIn_Array_Add("view_surface_id", true, true, true); + Variable_BuiltIn_Add("mouse_x", true, false, false, null, null); + Variable_BuiltIn_Add("mouse_y", true, false, false, null, null); + Variable_BuiltIn_Add("mouse_button", true, true, true, null, null); + Variable_BuiltIn_Add("mouse_lastbutton", true, true, true, null, null); + Variable_BuiltIn_Add("keyboard_key", true, true, true, null, null); + Variable_BuiltIn_Add("keyboard_lastkey", true, true, true, null, null); + Variable_BuiltIn_Add("keyboard_lastchar", true, true, true, null, null); + Variable_BuiltIn_Add("keyboard_string", true, true, true, null, null); + Variable_BuiltIn_Add("cursor_sprite", true, true, true, null, null); + Variable_BuiltIn_Add("show_score", true, true, true, null, null); + Variable_BuiltIn_Add("show_lives", true, true, true, null, null); + Variable_BuiltIn_Add("show_health", true, true, true, null, null); + Variable_BuiltIn_Add("caption_score", true, true, true, null, null); + Variable_BuiltIn_Add("caption_lives", true, true, true, null, null); + Variable_BuiltIn_Add("caption_health", true, true, true, null, null); + Variable_BuiltIn_Add("fps", true, false, false, null, null); + Variable_BuiltIn_Add("current_time", true, false, false, null, null); + Variable_BuiltIn_Add("current_year", true, false, false, null, null); + Variable_BuiltIn_Add("current_month", true, false, false, null, null); + Variable_BuiltIn_Add("current_day", true, false, false, null, null); + Variable_BuiltIn_Add("current_weekday", true, false, false, null, null); + Variable_BuiltIn_Add("current_hour", true, false, false, null, null); + Variable_BuiltIn_Add("current_minute", true, false, false, null, null); + Variable_BuiltIn_Add("current_second", true, false, false, null, null); + Variable_BuiltIn_Add("event_type", true, false, false, null, null); + Variable_BuiltIn_Add("event_number", true, false, false, null, null); + Variable_BuiltIn_Add("event_object", true, false, false, null, null); + Variable_BuiltIn_Add("event_action", true, false, false, null, null); + Variable_BuiltIn_Add("secure_mode", true, false, false, null, null); + Variable_BuiltIn_Add("error_occurred", true, true, true, null, null); + Variable_BuiltIn_Add("error_last", true, true, true, null, null); + Variable_BuiltIn_Add("gamemaker_registered", true, false, false, null, null); + Variable_BuiltIn_Add("gamemaker_pro", true, false, false, null, null); + Variable_BuiltIn_Add("os_type", true, false, false, null, "get_os_type"); + Variable_BuiltIn_Add("os_device", true, false, false, null, "get_os_device"); + Variable_BuiltIn_Add("os_browser", true, false, false, null, "get_os_browser"); + Variable_BuiltIn_Add("os_version", true, false, false, null, "get_os_version"); + Variable_BuiltIn_Add("browser_width", true, false, false, null, "get_browser_width"); + Variable_BuiltIn_Add("browser_height", true, false, false, null, "get_browser_height"); + Variable_BuiltIn_Add("async_load", true, false, false, null, "get_async_load"); + Variable_BuiltIn_Local_Add("x", true, true, true, "setx", null); + Variable_BuiltIn_Local_Add("y", true, true, true, "sety", null); + Variable_BuiltIn_Local_Add("xprevious", true, true, true, null, null); + Variable_BuiltIn_Local_Add("yprevious", true, true, true, null, null); + Variable_BuiltIn_Local_Add("xstart", true, true, true, null, null); + Variable_BuiltIn_Local_Add("ystart", true, true, true, null, null); + Variable_BuiltIn_Local_Add("hspeed", true, true, true, "sethspeed", null); + Variable_BuiltIn_Local_Add("vspeed", true, true, true, "setvspeed", null); + Variable_BuiltIn_Local_Add("direction", true, true, true, "setdirection", null); + Variable_BuiltIn_Local_Add("speed", true, true, true, "setspeed", null); + Variable_BuiltIn_Local_Add("friction", true, true, true, null, null); + Variable_BuiltIn_Local_Add("gravity", true, true, true, null, null); + Variable_BuiltIn_Local_Add("gravity_direction", true, true, true, null, null); + Variable_BuiltIn_Local_Add("object_index", true, false, false, null, null); + Variable_BuiltIn_Local_Add("id", true, false, false, null, null); + Variable_BuiltIn_Local_Add("alarm", true, true, true, null, null); + Variable_BuiltIn_Local_Add("solid", true, true, true, null, null); + Variable_BuiltIn_Local_Add("visible", true, true, true, null, null); + Variable_BuiltIn_Local_Add("persistent", true, true, true, null, null); + Variable_BuiltIn_Local_Add("depth", true, true, true, "setdepth", "getdepth"); + Variable_BuiltIn_Local_Add("bbox_left", true, false, false, null, "get_bbox_left"); + Variable_BuiltIn_Local_Add("bbox_right", true, false, false, null, "get_bbox_right"); + Variable_BuiltIn_Local_Add("bbox_top", true, false, false, null, "get_bbox_top"); + Variable_BuiltIn_Local_Add("bbox_bottom", true, false, false, null, "get_bbox_bottom"); + Variable_BuiltIn_Local_Add("sprite_index", true, true, true, null, null); + Variable_BuiltIn_Local_Add("image_index", true, true, true, "set_image_index", null); + Variable_BuiltIn_Local_Add("image_single", true, true, true, "set_image_single", "get_image_single"); + Variable_BuiltIn_Local_Add("image_number", true, false, false, null, "get_image_number"); + Variable_BuiltIn_Local_Add("sprite_width", true, false, false, null, "get_sprite_width"); + Variable_BuiltIn_Local_Add("sprite_height", true, false, false, null, "get_sprite_height"); + Variable_BuiltIn_Local_Add("sprite_xoffset", true, false, false, null, "get_sprite_xoffset"); + Variable_BuiltIn_Local_Add("sprite_yoffset", true, false, false, null, "get_sprite_yoffset"); + Variable_BuiltIn_Local_Add("image_xscale", true, true, true, "setxscale", null); + Variable_BuiltIn_Local_Add("image_yscale", true, true, true, "setyscale", null); + Variable_BuiltIn_Local_Add("image_angle", true, true, true, "setangle", null); + Variable_BuiltIn_Local_Add("image_alpha", true, true, true, null, null); + Variable_BuiltIn_Local_Add("image_blend", true, true, true, "set_imageblend", "get_imageblend"); + Variable_BuiltIn_Local_Add("image_speed", true, true, true, null, null); + Variable_BuiltIn_Local_Add("mask_index", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_index", true, false, false, null, null); + Variable_BuiltIn_Local_Add("path_position", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_positionprevious", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_speed", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_scale", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_orientation", true, true, true, null, null); + Variable_BuiltIn_Local_Add("path_endaction", true, true, true, null, null); + Variable_BuiltIn_Local_Add("timeline_index", true, true, true, null, null); + Variable_BuiltIn_Local_Add("timeline_position", true, true, true, null, null); + Variable_BuiltIn_Local_Add("timeline_speed", true, true, true, null, null); + Variable_BuiltIn_Local_Add("timeline_running", true, true, true, "set_timeline_running", "get_timeline_running"); + Variable_BuiltIn_Local_Add("timeline_loop", true, true, true, "set_timeline_loop", "get_timeline_loop"); + Variable_BuiltIn_Local_Add("phy_mass", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_inertia", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_com_x", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_com_y", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_dynamic", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_frozen", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_sleeping", true, false, true, null, null); + Variable_BuiltIn_Local_Add("phy_collision_points", true, false, true, null, null); + Variable_BuiltIn_Local_Array_Add("phy_collision_x", true, false, true); + Variable_BuiltIn_Local_Array_Add("phy_collision_y", true, false, true); + Variable_BuiltIn_Local_Array_Add("phy_col_normal_x", true, false, true); + Variable_BuiltIn_Local_Array_Add("phy_col_normal_y", true, false, true); + } + + public static int Find(IList> _list, string _name) + { + int i; + for (i = 0; i < _list.Count && !(_list[i].Key == _name); i++) + { + } + if (i >= _list.Count) + { + return -1; + } + return i; + } + + public static int FindTriggerConstName(IList _list, string _name) + { + int result = -1; + for (int i = 0; i < _list.Count; i++) + { + if (_list[i].ConstName == _name) + { + result = i + 1; + break; + } + } + return result; + } + + private static int Code_Function_Find(string _name) + { + if (ms_assets != null) + { + int num = 0; + foreach (GMExtension extension in ms_assets.Extensions) + { + int num2 = 0; + foreach (GMExtensionInclude include in extension.Includes) + { + int num3 = 0; + foreach (GMExtensionFunction function in include.Functions) + { + if (function.Name == _name) + { + return ms_id + num * 256 + num2 * 4096 + num3; + } + num3++; + } + num2++; + } + num++; + } + int num4 = Find(ms_assets.Scripts, _name); + if (num4 >= 0) + { + return num4 + 100000; + } + } + GMLFunction value = null; + if (!ms_funcs.TryGetValue(_name, out value)) + { + return -1; + } + return value.Id; + } + + private static int FindResourceIndexFromName(string _name) + { + int result = -1; + if (ms_assets != null) + { + int num = Find(ms_assets.Objects, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Sprites, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Sounds, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Backgrounds, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Paths, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Fonts, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.TimeLines, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Scripts, _name); + if (num >= 0) + { + return num; + } + num = Find(ms_assets.Rooms, _name); + if (num >= 0) + { + return num; + } + num = FindTriggerConstName(ms_assets.Triggers, _name); + if (num >= 0) + { + return num; + } + } + return result; + } + + private static bool Code_Constant_Find(string _name, out GMLValue _val) + { + _val = new GMLValue(); + _val.Kind = eKind.eNumber; + int value = 0; + ms_ConstantCount.TryGetValue(_name, out value); + ms_ConstantCount[_name] = value + 1; + int num = FindResourceIndexFromName(_name); + if (num >= 0) + { + _val.ValueI = num; + return true; + } + string value2; + if (ms_assets.Options.Constants.TryGetValue(_name, out value2)) + { + double result = 0.0; + if (double.TryParse(value2, out result)) + { + _val.ValueI = result; + return true; + } + num = FindResourceIndexFromName(value2); + if (num >= 0) + { + _val.ValueI = num; + return true; + } + _val.Kind = eKind.eConstant; + _val.ValueS = _name; + return true; + } + double value3 = 0.0; + if (!ms_constants.TryGetValue(_name, out value3)) + { + return false; + } + _val.ValueI = value3; + return true; + } + + private static int Code_Variable_Find(string _name) + { + GMLVariable value = null; + if (!ms_builtins.TryGetValue(_name, out value) && !ms_builtinsLocal.TryGetValue(_name, out value) && !ms_vars.TryGetValue(_name, out value)) + { + value = new GMLVariable(); + value.Name = _name; + value.Id = 100000 + ms_vars.Count; + ms_vars.Add(_name, value); + } + return value.Id; + } + + private static void CreateFunctionsToken(string _script, List _pass1, List _pass2, int _index) + { + int num = Code_Function_Find(_pass1[_index].Text); + if (num < 0) + { + Error(string.Format("unknown function or script {0}", _pass1[_index].Text), _script, _pass1[_index]); + } + _pass2.Add(new GMLToken(eToken.eFunction, _pass1[_index], num)); + } + + private static void CreateNameToken(string _script, List _pass1, List _pass2, int _index) + { + GMLValue _val = null; + if (!Code_Constant_Find(_pass1[_index].Text, out _val)) + { + int id = Code_Variable_Find(_pass1[_index].Text); + _pass2.Add(new GMLToken(eToken.eVariable, _pass1[_index], id)); + } + else + { + _pass2.Add(new GMLToken(eToken.eConstant, _pass1[_index], 0, _val)); + } + } + + private static void CreateValueToken(string _script, List _pass1, List _pass2, int _index) + { + string text = _pass1[_index].Text; + GMLValue gMLValue = null; + if (text[0] == '$') + { + long num = Convert.ToInt64(text.Substring(1), 16); + gMLValue = new GMLValue(num); + } + else + { + double result = 0.0; + if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out result)) + { + Error(string.Format("Number {0} in incorrect format", text), _script, _pass1[_index]); + } + gMLValue = new GMLValue(result); + } + _pass2.Add(new GMLToken(eToken.eConstant, _pass1[_index], 0, gMLValue)); + } + + private static void CreateStringToken(string _script, List _pass1, List _pass2, int _index) + { + _pass2.Add(new GMLToken(eToken.eConstant, _pass1[_index], 0, new GMLValue(_pass1[_index].Text))); + } + + private static void CreateNormalToken(string _script, List _pass1, List _pass2, int _index) + { + _pass2.Add(new GMLToken(_pass1[_index].Token, _pass1[_index], 0)); + } + + private static int ParseStatement(List _pass3, List _pass2, int _index) + { + int i = _index; + switch (_pass2[i].Token) + { + case eToken.eEOF: + Error("unexpected EOF encountered", ms_script, _pass2[i]); + break; + case eToken.eVar: + i = ParseVar(_pass3, _pass2, _index); + break; + case eToken.eGlobalVar: + i = ParseGlobalVar(_pass3, _pass2, _index); + break; + case eToken.eBegin: + i = ParseBlock(_pass3, _pass2, _index); + break; + case eToken.eRepeat: + i = ParseRepeat(_pass3, _pass2, _index); + break; + case eToken.eIf: + i = ParseIf(_pass3, _pass2, _index); + break; + case eToken.eWhile: + i = ParseWhile(_pass3, _pass2, _index); + break; + case eToken.eFor: + i = ParseFor(_pass3, _pass2, _index); + break; + case eToken.eDo: + i = ParseDo(_pass3, _pass2, _index); + break; + case eToken.eWith: + i = ParseWith(_pass3, _pass2, _index); + break; + case eToken.eSwitch: + i = ParseSwitch(_pass3, _pass2, _index); + break; + case eToken.eCase: + i = ParseCase(_pass3, _pass2, _index); + break; + case eToken.eDefault: + i = ParseDefault(_pass3, _pass2, _index); + break; + case eToken.eReturn: + i = ParseReturn(_pass3, _pass2, _index); + break; + case eToken.eFunction: + i = ParseFunction(_pass3, _pass2, _index); + break; + case eToken.eExit: + case eToken.eBreak: + case eToken.eContinue: + _pass3.Add(new GMLToken(_pass2[_index].Token, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value)); + i++; + break; + default: + i = ParseAssignment(_pass3, _pass2, _index); + break; + case eToken.eSepStatement: + break; + } + for (; _pass2[i].Token == eToken.eSepStatement; i++) + { + } + return i; + } + + private static int ParseVar(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eVar, _pass2[_index], 0); + int num = _index + 1; + while (_pass2[num].Token == eToken.eVariable) + { + if (_pass2[num].Id < 100000) + { + Error("cannot redeclare a builtin varable", ms_script, _pass2[num]); + } + GMLToken gMLToken2 = new GMLToken(_pass2[num]); + gMLToken2.Token = eToken.eConstant; + gMLToken.Children.Add(gMLToken2); + num++; + if (_pass2[num].Token == eToken.eSepArgument) + { + num++; + } + } + _pass3.Add(gMLToken); + return num; + } + + private static int ParseGlobalVar(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eGlobalVar, _pass2[_index], 0); + int num = _index + 1; + while (_pass2[num].Token == eToken.eVariable) + { + if (_pass2[num].Id < 100000) + { + Error("cannot redeclare a builtin varable", ms_script, _pass2[num]); + } + GMLToken gMLToken2 = new GMLToken(_pass2[num]); + gMLToken2.Token = eToken.eConstant; + gMLToken.Children.Add(gMLToken2); + num++; + GML2JavaScript.ms_globals[gMLToken2.Text] = gMLToken2.Text; + if (_pass2[num].Token == eToken.eSepArgument) + { + num++; + } + } + _pass3.Add(gMLToken); + return num; + } + + private static int ParseBlock(List _pass3, List _pass2, int _index) + { + int num = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + while (!ms_error && _pass2[num].Token != eToken.eEOF && _pass2[num].Token != eToken.eEnd) + { + num = ParseStatement(gMLToken.Children, _pass2, num); + } + if (_pass2[num].Token != eToken.eEnd) + { + Error("symbol } expected", ms_script, _pass2[num]); + } + else + { + num++; + } + return num; + } + + private static int ParseRepeat(List _pass3, List _pass2, int _index) + { + int index = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + index = ParseExpression1(gMLToken.Children, _pass2, index); + return ParseStatement(gMLToken.Children, _pass2, index); + } + + private static int ParseIf(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + int num = ParseExpression1(gMLToken.Children, _pass2, _index + 1); + if (_pass2[num].Token == eToken.eThen) + { + num++; + } + num = ParseStatement(gMLToken.Children, _pass2, num); + if (_pass2[num].Token == eToken.eElse) + { + num = ParseStatement(gMLToken.Children, _pass2, num + 1); + } + return num; + } + + private static int ParseWhile(List _pass3, List _pass2, int _index) + { + int index = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + index = ParseExpression1(gMLToken.Children, _pass2, index); + if (_pass2[index].Token == eToken.eDo) + { + index++; + } + return ParseStatement(gMLToken.Children, _pass2, index); + } + + private static int ParseFor(List _pass3, List _pass2, int _index) + { + int num = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + if (_pass2[num].Token != eToken.eOpen) + { + Error("symbol ( expected", ms_script, _pass2[num]); + } + num++; + num = ParseStatement(gMLToken.Children, _pass2, num); + if (_pass2[num].Token == eToken.eSepStatement) + { + num++; + } + num = ParseExpression1(gMLToken.Children, _pass2, num); + if (_pass2[num].Token == eToken.eSepStatement) + { + num++; + } + num = ParseStatement(gMLToken.Children, _pass2, num); + if (_pass2[num].Token != eToken.eClose) + { + Error("Symbol ) expected", ms_script, _pass2[num]); + } + num++; + return ParseStatement(gMLToken.Children, _pass2, num); + } + + private static int ParseDo(List _pass3, List _pass2, int _index) + { + int index = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + index = ParseStatement(gMLToken.Children, _pass2, index); + if (_pass2[index].Token != eToken.eUntil) + { + Error("keyword Until expected", ms_script, _pass2[index]); + } + return ParseExpression1(gMLToken.Children, _pass2, index + 1); + } + + private static int ParseWith(List _pass3, List _pass2, int _index) + { + int index = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + index = ParseExpression1(gMLToken.Children, _pass2, index); + if (_pass2[index].Token == eToken.eDo) + { + index++; + } + return ParseStatement(gMLToken.Children, _pass2, index); + } + + private static int ParseSwitch(List _pass3, List _pass2, int _index) + { + int index = _index + 1; + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + index = ParseExpression1(gMLToken.Children, _pass2, index); + if (_pass2[index].Token != eToken.eBegin) + { + Error("Symbol { expected", ms_script, _pass2[index]); + } + index++; + while (_pass2[index].Token != eToken.eEnd && _pass2[index].Token != eToken.eEOF) + { + index = ParseStatement(gMLToken.Children, _pass2, index); + } + if (_pass2[index].Token != eToken.eEnd) + { + Error("Symbol } expected", ms_script, _pass2[index]); + } + return index + 1; + } + + private static int ParseCase(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(_pass2[_index]); + int num = ParseExpression1(gMLToken.Children, _pass2, _index + 1); + if (_pass2[num].Token != eToken.eLabel) + { + Error("Symbol : expected", ms_script, _pass2[num]); + } + _pass3.Add(gMLToken); + return num + 1; + } + + private static int ParseDefault(List _pass3, List _pass2, int _index) + { + int num = _index + 1; + GMLToken item = new GMLToken(_pass2[_index]); + if (_pass2[num].Token != eToken.eLabel) + { + Error("Symbol : expected", ms_script, _pass2[num]); + } + _pass3.Add(item); + return num + 1; + } + + private static int ParseReturn(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eReturn, _pass2[_index], 0); + int index = _index + 1; + index = ParseExpression1(gMLToken.Children, _pass2, index); + _pass3.Add(gMLToken); + return index; + } + + private static int ParseFunction(List _pass3, List _pass2, int _index) + { + if (_pass2[_index].Token != eToken.eFunction) + { + Error("Function name expected", ms_script, _pass2[_index]); + } + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + int num = _index + 1; + if (_pass2[num].Token != eToken.eOpen) + { + Error("Symbol ( expected", ms_script, _pass2[num]); + } + num++; + while (!ms_error && _pass2[num].Token != eToken.eEOF && _pass2[num].Token != eToken.eClose) + { + num = ParseExpression1(gMLToken.Children, _pass2, num); + if (_pass2[num].Token == eToken.eSepArgument) + { + num++; + } + else if (_pass2[num].Token != eToken.eClose) + { + Error("Symbol , or ) expected", ms_script, _pass2[num]); + } + } + if (_pass2[num].Token != eToken.eClose) + { + Error("Symbol ) expected", ms_script, _pass2[num]); + } + else + { + num++; + } + return num; + } + + private static int ParseAssignment(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eAssign, _pass2[_index], 0); + _pass3.Add(gMLToken); + int num = ParseVariable2(gMLToken.Children, _pass2, _index); + switch (_pass2[num].Token) + { + case eToken.eAssign: + case eToken.eAssignPlus: + case eToken.eAssignMinus: + case eToken.eAssignTimes: + case eToken.eAssignDivide: + case eToken.eAssignOr: + case eToken.eAssignAnd: + case eToken.eAssignXor: + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression1(gMLToken.Children, _pass2, num + 1); + break; + default: + Error("Assignment operator expected", ms_script, _pass2[num]); + break; + } + return num; + } + + private static int ParseExpression1(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseExpression2(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.eAnd || _pass2[num].Token == eToken.eOr || _pass2[num].Token == eToken.eXor) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression2(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseExpression2(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseExpression3(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.eLess || _pass2[num].Token == eToken.eLessEqual || _pass2[num].Token == eToken.eEqual || _pass2[num].Token == eToken.eNotEqual || _pass2[num].Token == eToken.eAssign || _pass2[num].Token == eToken.eGreater || _pass2[num].Token == eToken.eGreaterEqual) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression3(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseExpression3(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseExpression4(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.eBitOr || _pass2[num].Token == eToken.eBitAnd || _pass2[num].Token == eToken.eBitXor) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression4(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseExpression4(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseExpression5(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.eBitShiftLeft || _pass2[num].Token == eToken.eBitShiftRight) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression5(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseExpression5(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseExpression6(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.ePlus || _pass2[num].Token == eToken.eMinus) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseExpression6(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseExpression6(List _pass3, List _pass2, int _index) + { + GMLToken gMLToken = new GMLToken(eToken.eBinary, _pass2[_index], _pass2[_index].Id, _pass2[_index].Value); + int num = ParseVariable2(gMLToken.Children, _pass2, _index); + if (!ms_error) + { + bool flag = true; + while (_pass2[num].Token == eToken.eTime || _pass2[num].Token == eToken.eDivide || _pass2[num].Token == eToken.eDiv || _pass2[num].Token == eToken.eMod) + { + flag = false; + gMLToken.Children.Add(_pass2[num]); + num = ParseVariable2(gMLToken.Children, _pass2, num + 1); + } + if (flag) + { + _pass3.AddRange(gMLToken.Children); + } + else + { + _pass3.Add(gMLToken); + } + } + return num; + } + + private static int ParseVariable2(List _pass3, List _pass2, int _index) + { + List list = new List(); + int num = ParseTerm(list, _pass2, _index); + if (!ms_error) + { + if (_pass2[num].Token == eToken.eDot) + { + GMLToken gMLToken = new GMLToken(eToken.eDot, _pass2[num], 0); + gMLToken.Children.AddRange(list); + _pass3.Add(gMLToken); + while (_pass2[num].Token == eToken.eDot) + { + num = ParseVariable(gMLToken.Children, _pass2, num + 1); + } + } + else + { + _pass3.AddRange(list); + } + } + return num; + } + + private static int ParseTerm(List _pass3, List _pass2, int _index) + { + int num = _index; + switch (_pass2[num].Token) + { + case eToken.eFunction: + num = ParseFunction(_pass3, _pass2, num); + break; + case eToken.eConstant: + _pass3.Add(_pass2[num]); + num++; + break; + case eToken.eOpen: + num = ParseExpression1(_pass3, _pass2, num + 1); + if (_pass2[num].Token != eToken.eClose) + { + Error("Symbol ) expected", ms_script, _pass2[num]); + } + num++; + break; + case eToken.eVariable: + num = ParseVariable(_pass3, _pass2, num); + break; + case eToken.eNot: + case eToken.ePlus: + case eToken.eMinus: + case eToken.eBitNegate: + { + GMLToken gMLToken = new GMLToken(eToken.eUnary, _pass2[num], (int)_pass2[num].Token); + num = ParseVariable2(gMLToken.Children, _pass2, num + 1); + _pass3.Add(gMLToken); + break; + } + default: + Error("unexpected symbol in expression", ms_script, _pass2[num]); + break; + } + return num; + } + + private static int ParseVariable(List _pass3, List _pass2, int _index) + { + if (_pass2[_index].Token != eToken.eVariable) + { + Error("variable name expected", ms_script, _pass2[_index]); + } + GMLToken gMLToken = new GMLToken(_pass2[_index]); + _pass3.Add(gMLToken); + int num = _index + 1; + GMLVariable value; + if (_pass2[num].Token == eToken.eArrayOpen) + { + num++; + while (_pass2[num].Token != eToken.eArrayClose && _pass2[num].Token != eToken.eEOF) + { + num = ParseExpression1(gMLToken.Children, _pass2, num); + if (_pass2[num].Token == eToken.eSepArgument) + { + num++; + } + else if (_pass2[num].Token != eToken.eArrayClose) + { + Error("symbol , or ] expected", ms_script, _pass2[num]); + } + } + if (_pass2[num].Token == eToken.eEOF) + { + Error("symbol ] expected", ms_script, _pass2[num]); + } + num++; + if (gMLToken.Children.Count >= 3) + { + Error("only 1 or 2 dimensional arrays are supported", ms_script, _pass2[num]); + } + } + else if (ms_builtinsArray.TryGetValue(gMLToken.Text, out value) || ms_builtinsLocalArray.TryGetValue(gMLToken.Text, out value)) + { + GMLToken gMLToken2 = new GMLToken(eToken.eConstant, -1, "0"); + gMLToken2.Value = new GMLValue(0.0); + gMLToken.Children.Add(gMLToken2); + } + return num; + } + + public static GMLToken Compile(GMAssets _assets, string _name, string _script, out List _errors) + { + _errors = new List(); + ms_error = false; + ms_numErrors = 0; + ms_errors = _errors; + ms_assets = _assets; + ms_script = _script; + ms_scriptName = _name; + if (Program.CompileVerbose) + { + Console.WriteLine("Original GML script - \"{0}\"", _name); + Console.WriteLine(_script); + } + List list = new List(); + int _index = 0; + bool flag = false; + while (!flag) + { + GMLToken gMLToken = NextToken(_script, ref _index); + list.Add(gMLToken); + flag = (gMLToken.Token == eToken.eEOF); + } + if (Program.CompileVerbose) + { + Console.WriteLine("-----\nPass 1\n-----"); + foreach (GMLToken item in list) + { + Console.WriteLine(item); + } + } + List list2 = new List(); + if (!ms_error) + { + for (int i = 0; i < list.Count; i++) + { + if (list[i].Token == eToken.eName && list[i + 1].Token == eToken.eOpen) + { + CreateFunctionsToken(_script, list, list2, i); + } + else if (list[i].Token == eToken.eName) + { + CreateNameToken(_script, list, list2, i); + } + else if (list[i].Token == eToken.eNumber) + { + CreateValueToken(_script, list, list2, i); + } + else if (list[i].Token == eToken.eString) + { + CreateStringToken(_script, list, list2, i); + } + else + { + CreateNormalToken(_script, list, list2, i); + } + } + if (Program.CompileVerbose) + { + Console.WriteLine("-----\nPass 2\n-----"); + foreach (GMLToken item2 in list2) + { + Console.WriteLine(item2); + } + } + } + List list3 = new List(); + if (!ms_error) + { + int index = 0; + while (!ms_error && list2[index].Token != eToken.eEOF) + { + index = ParseStatement(list3, list2, index); + } + if (Program.CompileVerbose) + { + Console.WriteLine("-----\nPass 3\n-----"); + foreach (GMLToken item3 in list3) + { + Console.WriteLine(item3); + } + } + } + GMLToken gMLToken2 = new GMLToken(eToken.eBlock, 0, ""); + gMLToken2.Children = list3; + return gMLToken2; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLError.cs b/GMAC1098/GMAssetCompiler/GMLError.cs new file mode 100644 index 0000000..a1e92f6 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLError.cs @@ -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 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(_others); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLFunction.cs b/GMAC1098/GMAssetCompiler/GMLFunction.cs new file mode 100644 index 0000000..0bc9e92 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLFunction.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLToken.cs b/GMAC1098/GMAssetCompiler/GMLToken.cs new file mode 100644 index 0000000..143306e --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLToken.cs @@ -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 Children + { + get; + set; + } + + public GMLToken(eToken _tok, int _index, string _text) + { + Token = _tok; + Index = _index; + Text = _text; + Children = new List(); + } + + public GMLToken(eToken _tok, GMLToken _pass1, int _id) + { + Token = _tok; + Index = _pass1.Index; + Text = _pass1.Text; + Id = _id; + Value = new GMLValue(); + Children = new List(); + } + + 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(); + } + + public GMLToken(GMLToken _tok) + { + Token = _tok.Token; + Index = _tok.Index; + Text = _tok.Text; + Id = _tok.Id; + Value = new GMLValue(_tok.Value); + Children = new List(_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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLValue.cs b/GMAC1098/GMAssetCompiler/GMLValue.cs new file mode 100644 index 0000000..a27d276 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLValue.cs @@ -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())); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMLVariable.cs b/GMAC1098/GMAssetCompiler/GMLVariable.cs new file mode 100644 index 0000000..cee2ffc --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMLVariable.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMObject.cs b/GMAC1098/GMAssetCompiler/GMObject.cs new file mode 100644 index 0000000..09bca24 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMObject.cs @@ -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>> 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>>(num2); + for (int i = 0; i <= num2; i++) + { + List> list = new List>(); + int num3; + do + { + num3 = _stream.ReadInteger(); + if (num3 >= 0) + { + GMEvent value = new GMEvent(_a, _stream); + KeyValuePair item = new KeyValuePair(num3, value); + list.Add(item); + } + } + while (num3 >= 0); + Events.Add(list); + } + Console.WriteLine("DEBUG: num var: " + num.ToString() + " !"); + + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMOptions.cs b/GMAC1098/GMAssetCompiler/GMOptions.cs new file mode 100644 index 0000000..2766f6a --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMOptions.cs @@ -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 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(); + 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(); + if (num != 800) + { + for (int num2 = _s.ReadInteger(); num2 > 0; num2--) + { + string key = _s.ReadString(); + string value = _s.ReadString(); + Constants.Add(key, value); + } + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMPath.cs b/GMAC1098/GMAssetCompiler/GMPath.cs new file mode 100644 index 0000000..879d2f2 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMPath.cs @@ -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 Points + { + get; + private set; + } + + public GMPath(GMAssets _a, Stream _s) + { + _s.ReadInteger(); + Kind = _s.ReadInteger(); + Closed = _s.ReadBoolean(); + Precision = _s.ReadInteger(); + Points = new List(); + 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)); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMPathPoint.cs b/GMAC1098/GMAssetCompiler/GMPathPoint.cs new file mode 100644 index 0000000..5455925 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMPathPoint.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMRoom.cs b/GMAC1098/GMAssetCompiler/GMRoom.cs new file mode 100644 index 0000000..fc3415c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMRoom.cs @@ -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 Backgrounds + { + get; + private set; + } + + public bool EnableViews + { + get; + private set; + } + + public bool ViewClearScreen + { + get; + private set; + } + + public IList Views + { + get; + private set; + } + + public IList Instances + { + get; + private set; + } + + public IList 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(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(num3); + for (int j = 0; j < num3; j++) + { + GMView item2 = new GMView(_stream); + Views.Add(item2); + } + num3 = _stream.ReadInteger(); + Instances = new List(num3); + for (int k = 0; k < num3; k++) + { + GMInstance item3 = new GMInstance(_stream, num); + Instances.Add(item3); + } + num3 = _stream.ReadInteger(); + Tiles = new List(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(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(num2); + for (int j = 0; j < num2; j++) + { + GMView item2 = new GMView(_stream); + Views.Add(item2); + } + num2 = _stream.ReadInteger(); + Instances = new List(num2); + for (int k = 0; k < num2; k++) + { + GMInstance item3 = new GMInstance(_stream, true); + Instances.Add(item3); + } + num2 = _stream.ReadInteger(); + Tiles = new List(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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMScript.cs b/GMAC1098/GMAssetCompiler/GMScript.cs new file mode 100644 index 0000000..72e9a9f --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMScript.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMSound.cs b/GMAC1098/GMAssetCompiler/GMSound.cs new file mode 100644 index 0000000..152d4d2 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMSound.cs @@ -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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMSprite.cs b/GMAC1098/GMAssetCompiler/GMSprite.cs new file mode 100644 index 0000000..596aba0 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMSprite.cs @@ -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 Images + { + get; + private set; + } + + [Property("Separate Masks?", Category = "GM8")] + public bool SepMasks + { + get; + private set; + } + + [Property("masks", Disabled = true)] + public IList 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(); + 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(); + 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(); + 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 CreateMask() + { + List result = null; + if (ColCheck && Transparent && Images.Count > 0) + { + result = new List(); + { + 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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMTile.cs b/GMAC1098/GMAssetCompiler/GMTile.cs new file mode 100644 index 0000000..e45cffd --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMTile.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMTimeLine.cs b/GMAC1098/GMAssetCompiler/GMTimeLine.cs new file mode 100644 index 0000000..3b10331 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMTimeLine.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using System.IO; + +namespace GMAssetCompiler +{ + public class GMTimeLine + { + public IList> Entries + { + get; + private set; + } + + public GMTimeLine(GMAssets _a, Stream _stream) + { + _stream.ReadInteger(); + int num = _stream.ReadInteger(); + Entries = new List>(num); + for (int i = 0; i < num; i++) + { + int key = _stream.ReadInteger(); + GMEvent value = new GMEvent(_a, _stream); + Entries.Add(new KeyValuePair(key, value)); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMTrigger.cs b/GMAC1098/GMAssetCompiler/GMTrigger.cs new file mode 100644 index 0000000..ab4ab1c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMTrigger.cs @@ -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(); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/GMView.cs b/GMAC1098/GMAssetCompiler/GMView.cs new file mode 100644 index 0000000..6a0ed86 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/GMView.cs @@ -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(); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/HTML5Saver.cs b/GMAC1098/GMAssetCompiler/HTML5Saver.cs new file mode 100644 index 0000000..255828e --- /dev/null +++ b/GMAC1098/GMAssetCompiler/HTML5Saver.cs @@ -0,0 +1,2680 @@ +using GMAssetCompiler.Output; +using Ionic.Zip; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; + +namespace GMAssetCompiler +{ + internal class HTML5Saver + { + private delegate void WriteDelegateKVP(KeyValuePair _kvp, TextWriter _s, int _n); + + private delegate void WriteDelegate(T _t, TextWriter _s, int _n); + + private enum Codepage + { + ANSI_CHARSET = 0, + DEFAULT_CHARSET = 1, + EASTEUROPE_CHARSET = 238, + RUSSIAN_CHARSET = 204, + SYMBOL_CHARSET = 2, + SHIFTJIS_CHARSET = 0x80, + HANGEUL_CHARSET = 129, + GB2312_CHARSET = 134, + CHINESEBIG5_CHARSET = 136, + JOHAB_CHARSET = 130, + HEBREW_CHARSET = 177, + ARABIC_CHARSET = 178, + GREEK_CHARSET = 161, + TURKISH_CHARSET = 162, + VIETNAMESE_CHARSET = 163, + THAI_CHARSET = 222, + MAC_CHARSET = 77, + BALTIC_CHARSET = 186, + OEM_CHARSET = 0xFF + } + + private const int EVENT_CREATE = 0; + + private const int EVENT_DESTROY = 1; + + private const int EVENT_ALARM = 2; + + private const int EVENT_STEP = 3; + + private const int EVENT_COLLISION = 4; + + private const int EVENT_KEYBOARD = 5; + + private const int EVENT_MOUSE = 6; + + private const int EVENT_OTHER = 7; + + private const int EVENT_DRAW = 8; + + private const int EVENT_KEYPRESS = 9; + + private const int EVENT_KEYRELEASE = 10; + + private const int EVENT_TRIGGER = 11; + + private const int EVENT_STEP_NORMAL = 0; + + private const int EVENT_STEP_BEGIN = 1; + + private const int EVENT_STEP_END = 2; + + private const int EVENT_OTHER_OUTSIDE = 0; + + private const int EVENT_OTHER_BOUNDARY = 1; + + private const int EVENT_OTHER_STARTGAME = 2; + + private const int EVENT_OTHER_ENDGAME = 3; + + private const int EVENT_OTHER_STARTROOM = 4; + + private const int EVENT_OTHER_ENDROOM = 5; + + private const int EVENT_OTHER_NOLIVES = 6; + + private const int EVENT_OTHER_ANIMATIONEND = 7; + + private const int EVENT_OTHER_ENDOFPATH = 8; + + private const int EVENT_OTHER_NOHEALTH = 9; + + private const int EVENT_OTHER_CLOSEBUTTON = 30; + + private const int EVENT_OTHER_OUTSIDE_VIEW0 = 40; + + private const int EVENT_OTHER_BOUNDARY_VIEW0 = 50; + + private const int EVENT_OTHER_USER0 = 10; + + private const int EVENT_OTHER_USER1 = 11; + + private const int EVENT_OTHER_USER2 = 12; + + private const int EVENT_OTHER_USER3 = 13; + + private const int EVENT_OTHER_USER4 = 14; + + private const int EVENT_OTHER_USER5 = 15; + + private const int EVENT_OTHER_USER6 = 16; + + private const int EVENT_OTHER_USER7 = 17; + + private const int EVENT_OTHER_USER8 = 18; + + private const int EVENT_OTHER_USER9 = 19; + + private const int EVENT_OTHER_USER10 = 20; + + private const int EVENT_OTHER_USER11 = 21; + + private const int EVENT_OTHER_USER12 = 22; + + private const int EVENT_OTHER_USER13 = 23; + + private const int EVENT_OTHER_USER14 = 24; + + private const int EVENT_OTHER_USER15 = 25; + + private const int EVENT_OTHER_WEB_IMAGE_LOADED = 60; + + private const int EVENT_OTHER_WEB_SOUND_LOADED = 61; + + private const int EVENT_OTHER_WEB_ASYNC = 62; + + private const int MOUSE_LeftButton = 0; + + private const int MOUSE_RightButton = 1; + + private const int MOUSE_MiddleButton = 2; + + private const int MOUSE_NoButton = 3; + + private const int MOUSE_LeftPressed = 4; + + private const int MOUSE_RightPressed = 5; + + private const int MOUSE_MiddlePressed = 6; + + private const int MOUSE_LeftReleased = 7; + + private const int MOUSE_RightReleased = 8; + + private const int MOUSE_MiddleReleased = 9; + + private const int MOUSE_MouseEnter = 10; + + private const int MOUSE_MouseLeave = 11; + + private const int MOUSE_Joystick1Left = 16; + + private const int MOUSE_Joystick1Right = 17; + + private const int MOUSE_Joystick1Up = 18; + + private const int MOUSE_Joystick1Down = 19; + + private const int MOUSE_Joystick1Button1 = 21; + + private const int MOUSE_Joystick1Button2 = 22; + + private const int MOUSE_Joystick1Button3 = 23; + + private const int MOUSE_Joystick1Button4 = 24; + + private const int MOUSE_Joystick1Button5 = 25; + + private const int MOUSE_Joystick1Button6 = 26; + + private const int MOUSE_Joystick1Button7 = 27; + + private const int MOUSE_Joystick1Button8 = 28; + + private const int MOUSE_Joystick2Left = 31; + + private const int MOUSE_Joystick2Right = 32; + + private const int MOUSE_Joystick2Up = 33; + + private const int MOUSE_Joystick2Down = 34; + + private const int MOUSE_Joystick2Button1 = 36; + + private const int MOUSE_Joystick2Button2 = 37; + + private const int MOUSE_Joystick2Button3 = 38; + + private const int MOUSE_Joystick2Button4 = 39; + + private const int MOUSE_Joystick2Button5 = 40; + + private const int MOUSE_Joystick2Button6 = 41; + + private const int MOUSE_Joystick2Button7 = 42; + + private const int MOUSE_Joystick2Button8 = 43; + + private const int MOUSE_GlobLeftButton = 50; + + private const int MOUSE_GlobRightButton = 51; + + private const int MOUSE_GlobMiddleButton = 52; + + private const int MOUSE_GlobLeftPressed = 53; + + private const int MOUSE_GlobRightPressed = 54; + + private const int MOUSE_GlobMiddlePressed = 55; + + private const int MOUSE_GlobLeftReleased = 56; + + private const int MOUSE_GlobRightReleased = 57; + + private const int MOUSE_GlobMiddleReleased = 58; + + private const int MOUSE_MouseWheelUp = 60; + + private const int MOUSE_MouseWheelDown = 61; + + private static TexturePage ms_tpageSprites; + + private static List ms_Waves = new List(); + + private static List ms_SoundFilenames = new List(); + + private static bool ms_fWriteNulls = true; + + private static Dictionary ms_codeToCompile = new Dictionary(); + + private static string[] event2Name = new string[12] + { + "Create", + "Destroy", + "Alarm", + "Step", + "Collision", + "Keyboard", + "Mouse", + "Other", + "Draw", + "KeyPress", + "KeyRelease", + "Trigger" + }; + + private static string baseDir = string.Empty; + + private static string baseGameName = string.Empty; + + private static List ms_obfuscateKeywords = new List(); + + private static GMAssets ms_assets; + + private static Dictionary ms_simpleConstants = new Dictionary(); + + public static GMAssets Assets + { + get; + private set; + } + + private static string EnsureValidId(string _name) + { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < _name.Length; i++) + { + char c = _name[i]; + if (!char.IsLetterOrDigit(c) && c != '_') + { + c = '_'; + } + stringBuilder.Append(c); + } + return stringBuilder.ToString(); + } + + public static void Save(GMAssets _assets, string _name) + { + if (Program.RemoveDND) + { + Assets = _assets; + _assets.RemoveDND(); + } + string fileName = Path.GetFileName(_name); + string text = Path.Combine(Program.OutputDir, "html5game"); + string text2 = Path.Combine(Program.OutputDir, "scripts"); + if (!Directory.Exists(text)) + { + Directory.CreateDirectory(text); + } + if (!Directory.Exists(text2)) + { + Directory.CreateDirectory(text2); + } + fileName = Path.Combine(text, fileName); + Program.Out.WriteLine("Saving HTML5 file... {0}", fileName); + ms_tpageSprites = new TexturePage(2, 2, 0, 0, Program.MachineType.TPageWidth, Program.MachineType.TPageHeight); + ms_Waves.Clear(); + ms_SoundFilenames.Clear(); + ms_codeToCompile.Clear(); + ms_obfuscateKeywords.Clear(); + TexturePageEntry.ms_count = 0; + List list = new List(); + StringBuilder stringBuilder = new StringBuilder(); + StringWriter s = new StringWriter(stringBuilder); + baseDir = text; + baseGameName = Path.GetFileNameWithoutExtension(fileName); + Save(_assets, s); + if (!Program.DoObfuscate) + { + File.WriteAllText(fileName, stringBuilder.ToString()); + } + else + { + list.Add(stringBuilder.ToString()); + } + if (!Program.NoIndexHTML) + { + GMRoom value = _assets.Rooms[_assets.RoomOrder[0]].Value; + int num = value.Width; + int num2 = value.Height; + if (value.EnableViews) + { + num = value.Views[0].WPort; + num2 = value.Views[0].HPort; + } + StreamWriter streamWriter = File.CreateText(Path.Combine(Program.OutputDir, "index.html")); + streamWriter.WriteLine(""); + streamWriter.WriteLine(""); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + if (Program.NoCache) + { + streamWriter.WriteLine(" "); + } + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(""); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" Game Maker HTML 5"); + streamWriter.WriteLine(""); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" "); + streamWriter.WriteLine(""); + streamWriter.WriteLine(" "); + streamWriter.WriteLine("
"); + bool centerHTML5Game = Program.CenterHTML5Game; + if (_assets.Options.LoadImage != null && Program.CustomLoadingScreen) + { + streamWriter.WriteLine(" \"GameMaker:HTML5"); + } + streamWriter.WriteLine(" "); + streamWriter.WriteLine(" ", num, num2); + streamWriter.WriteLine("

Your browser doesn't support HTML5 canvas.

"); + streamWriter.WriteLine("
"); + bool centerHTML5Game2 = Program.CenterHTML5Game; + streamWriter.WriteLine("
"); + streamWriter.WriteLine(""); + streamWriter.WriteLine(" "); + Random random = new Random(); + random.Next(); + streamWriter.WriteLine(" ", Path.GetFileName(_name), NewName(874871 + random.Next(61521)), random.Next(int.MaxValue)); + if (!Program.DoObfuscate) + { + streamWriter.WriteLine(" "); + } + streamWriter.WriteLine(" "); + streamWriter.WriteLine(""); + streamWriter.Close(); + } + if (!string.IsNullOrEmpty(Program.HTMLRunner)) + { + if (!Program.DoObfuscate) + { + if (File.Exists(Program.HTMLRunner)) + { + UnzipFromDir(text2, Program.HTMLRunner, new string[1] + { + ".svn" + }); + } + else + { + CopyDirFromDir(text2, Program.HTMLRunner, new string[1] + { + ".svn" + }); + } + } + else if (File.Exists(Program.HTMLRunner)) + { + GetFilesFromZip(Program.HTMLRunner, new string[3] + { + ".svn", + "runner.js", + "particles" + }, list); + } + else + { + GetFiles(Program.HTMLRunner, new string[3] + { + ".svn", + "runner.js", + "particles" + }, list); + } + } + if (_assets.Debug && list.Count == 2) + { + Program.Out.WriteLine("Debug version skipping obfuscation..."); + stringBuilder.Length = 0; + stringBuilder.Append(list[0]); + stringBuilder.AppendLine(""); + stringBuilder.Append(list[1]); + File.WriteAllText(fileName, stringBuilder.ToString()); + } + else if (Program.DoObfuscate) + { + Program.Out.WriteLine("Obfuscating..."); + YYObfuscate yYObfuscate = new YYObfuscate(); + yYObfuscate.Obfuscate = Program.ObfuscateObfuscate; + yYObfuscate.Verbose = Program.Verbose; + yYObfuscate.PrettyPrint = Program.ObfuscatePrettyPrint; + yYObfuscate.RemovedUnused = Program.ObfuscateRemoveUnused; + yYObfuscate.EncodeStrings = Program.ObfuscateEncodeStrings; + yYObfuscate.DoObfuscate(list, fileName, ms_obfuscateKeywords); + } + if (File.Exists(Program.HTMLRunner)) + { + CopyDirFromZip(Path.Combine(text, "particles"), Program.HTMLRunner, "particles", new string[1] + { + ".svn" + }); + } + else + { + CopyDirFromDir(Path.Combine(text, "particles"), Path.Combine(Program.HTMLRunner, "particles"), new string[1] + { + ".svn" + }); + } + Program.Out.WriteLine("Done! "); + } + + private static string NewName(int _count) + { + string text = ""; + for (int num = _count; num > 0; num /= 26) + { + text += (char)(num % 26 + 65); + } + _count++; + return text; + } + + private static string DecodeString(string _inp) + { + string text = ""; + for (int i = 0; i < _inp.Length; i++) + { + text += (char)(_inp[i] ^ 0x1A); + } + return text; + } + + public static void GetFiles(string _sourceDir, string[] _excludes, List _files) + { + string[] directories = Directory.GetDirectories(_sourceDir); + string[] array = directories; + foreach (string path in array) + { + if (!_excludes.Contains(Path.GetFileName(path))) + { + string sourceDir = Path.Combine(_sourceDir, Path.GetFileName(path)); + GetFiles(sourceDir, _excludes, _files); + } + } + string[] files = Directory.GetFiles(_sourceDir); + string[] array2 = files; + foreach (string path2 in array2) + { + if (!_excludes.Contains(Path.GetFileName(path2))) + { + _files.Add(File.ReadAllText(path2)); + } + } + } + + private static void GetFilesFromZip(string _sourceZip, string[] _excludes, List _files) + { + try + { + using (ZipInputStream zipInputStream = new ZipInputStream(_sourceZip)) + { + zipInputStream.Password = DecodeString("+\"(9EZjZu)m>s>hE[^^7E>9"); + ZipEntry nextEntry; + while ((nextEntry = zipInputStream.GetNextEntry()) != null) + { + string[] array = nextEntry.FileName.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); + bool flag = false; + string[] array2 = array; + foreach (string value in array2) + { + flag = (flag || _excludes.Contains(value)); + } + if (!nextEntry.IsDirectory && !flag) + { + byte[] buffer = new byte[nextEntry.UncompressedSize]; + zipInputStream.Read(buffer, 0, (int)nextEntry.UncompressedSize); + MemoryStream stream = new MemoryStream(buffer); + StreamReader streamReader = new StreamReader(stream); + _files.Add(streamReader.ReadToEnd()); + } + } + } + } + catch + { + } + } + + private static void CopyDirFromDir(string _destDir, string _sourceDir, string[] _excludes) + { + if (!Directory.Exists(_destDir)) + { + Directory.CreateDirectory(_destDir); + } + try + { + string[] directories = Directory.GetDirectories(_sourceDir); + string[] array = directories; + foreach (string path in array) + { + if (!_excludes.Contains(Path.GetFileName(path))) + { + string destDir = Path.Combine(_destDir, Path.GetFileName(path)); + string sourceDir = Path.Combine(_sourceDir, Path.GetFileName(path)); + CopyDirFromDir(destDir, sourceDir, _excludes); + } + } + string[] files = Directory.GetFiles(_sourceDir); + string[] array2 = files; + foreach (string text in array2) + { + string dest = Path.Combine(_destDir, Path.GetFileName(text)); + CopyFile(text, dest); + } + } + catch (IOException ex) + { + Console.WriteLine("CopyDirFromDir File {0}->{1} :: Caught IOException : {0}", _destDir, _sourceDir, ex.ToString()); + } + } + + private static void UnzipFromDir(string _destDir, string _sourceZip, string[] _excludes) + { + if (!Directory.Exists(_destDir)) + { + Directory.CreateDirectory(_destDir); + } + byte[] array = new byte[2048]; + using (ZipInputStream zipInputStream = new ZipInputStream(_sourceZip)) + { + zipInputStream.Password = DecodeString("+\"(9EZjZu)m>s>hE[^^7E>9"); + ZipEntry nextEntry; + while ((nextEntry = zipInputStream.GetNextEntry()) != null) + { + string text = Path.Combine(_destDir, nextEntry.FileName); + if (nextEntry.IsDirectory) + { + if (!Directory.Exists(text) && !_excludes.Contains(Path.GetFileName(text))) + { + Directory.CreateDirectory(text); + } + } + else if (!_excludes.Contains(Path.GetFileName(text))) + { + using (FileStream fileStream = File.Open(text, FileMode.Create, FileAccess.ReadWrite)) + { + long position = zipInputStream.Position; + long position2 = fileStream.Position; + bool flag = false; + while (!flag) + { + zipInputStream.Position = position; + fileStream.Position = position2; + try + { + int count; + while ((count = zipInputStream.Read(array, 0, array.Length)) > 0) + { + fileStream.Write(array, 0, count); + } + flag = true; + } + catch (IOException ex) + { + Console.WriteLine("IOException while unzipping file {0} : {1}", text, ex.ToString()); + } + } + } + } + } + } + } + + private static void CopyDirFromZip(string _destDir, string _sourceZip, string _sourceDir, string[] _excludes) + { + if (!Directory.Exists(_destDir)) + { + Directory.CreateDirectory(_destDir); + } + byte[] array = new byte[2048]; + using (ZipInputStream zipInputStream = new ZipInputStream(_sourceZip)) + { + zipInputStream.Password = DecodeString("+\"(9EZjZu)m>s>hE[^^7E>9"); + ZipEntry nextEntry; + while ((nextEntry = zipInputStream.GetNextEntry()) != null) + { + if (nextEntry.FileName.StartsWith(_sourceDir)) + { + string text = Path.Combine(_destDir, nextEntry.FileName.Remove(0, _sourceDir.Length + 1)); + if (nextEntry.IsDirectory) + { + if (!Directory.Exists(text) && !_excludes.Contains(Path.GetFileName(text))) + { + Directory.CreateDirectory(text); + } + } + else if (!_excludes.Contains(Path.GetFileName(text))) + { + using (FileStream fileStream = File.Open(text, FileMode.Create, FileAccess.ReadWrite)) + { + long position = zipInputStream.Position; + long position2 = fileStream.Position; + bool flag = false; + while (!flag) + { + zipInputStream.Position = position; + fileStream.Position = position2; + try + { + int count; + while ((count = zipInputStream.Read(array, 0, array.Length)) > 0) + { + fileStream.Write(array, 0, count); + } + flag = true; + } + catch (IOException ex) + { + Console.WriteLine("IOException while unzipping file {0} : {1}", text, ex.ToString()); + } + } + } + } + } + } + } + } + + private static void CopyFile(string f, string dest) + { + bool flag = false; + while (!flag) + { + try + { + File.Copy(f, dest, true); + flag = true; + } + catch (IOException ex) + { + Console.WriteLine("Copy File {0}->{1} :: Caught IOException : {0}", f, dest, ex.ToString()); + } + } + } + + private static void WriteDataKVP(IList> _data, TextWriter _s, WriteDelegateKVP _del) + { + int num = 0; + foreach (KeyValuePair _datum in _data) + { + if (_datum.Value != null) + { + _del(_datum, _s, num); + } + else if (ms_fWriteNulls) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\tnull"); + } + num++; + } + } + + private static void WriteDataList(IList _data, TextWriter _s, WriteDelegate _del) + { + int num = 0; + foreach (T _datum in _data) + { + _del(_datum, _s, num); + num++; + } + } + + private static void WriteHeader(GMAssets _assets, TextWriter _s) + { + } + + private static bool IsSimpleConstant(GMLCode _code, out string _ret) + { + bool result = false; + _ret = ""; + if (_code.Token != null && _code.Token.Token == eToken.eBlock && _code.Token.Children.Count == 1 && _code.Token.Children[0].Token == eToken.eReturn && _code.Token.Children[0].Children.Count == 1 && _code.Token.Children[0].Children[0].Token == eToken.eConstant) + { + result = true; + switch (_code.Token.Children[0].Children[0].Value.Kind) + { + case eKind.eNumber: + _ret = Convert.ToString(_code.Token.Children[0].Children[0].Value.ValueI, CultureInfo.InvariantCulture.NumberFormat); + break; + case eKind.eString: + _ret = _code.Token.Children[0].Children[0].Value.ValueS; + if (_ret[0] != '"') + { + _ret = '"' + _ret + '"'; + } + break; + } + } + return result; + } + + private static void WriteOptions(GMAssets _assets, TextWriter _s) + { + _s.Write("\tOptions: {"); + _s.WriteLine("\t\tdebugMode: {0},", _assets.Debug.ToString().ToLower()); + _s.WriteLine("\t\tgameId: {0},", _assets.GameID.ToString().ToLower()); + _s.WriteLine("\t\tgameGuid: \"{0}\",", _assets.GameGUID.ToString().ToLower()); + _s.WriteLine("\t\tfullScreen: {0},", _assets.Options.FullScreen.ToString().ToLower()); + _s.WriteLine("\t\tinterpolatePixels: {0},", _assets.Options.InterpolatePixels.ToString().ToLower()); + _s.WriteLine("\t\tshowCursor: {0},", _assets.Options.ShowCursor.ToString().ToLower()); + _s.WriteLine("\t\tscale: {0},", _assets.Options.Scale); + _s.WriteLine("\t\tallowFullScreenKey: {0},", _assets.Options.ScreenKey.ToString().ToLower()); + _s.WriteLine("\t\tfreezeOnLostFocus: {0},", _assets.Options.Freeze.ToString().ToLower()); + _s.WriteLine("\t\tshowLoadingBar: {0},", _assets.Options.ShowProgress.ToString().ToLower()); + _s.WriteLine("\t\tdisplayErrors: {0},", _assets.Options.DisplayErrors.ToString().ToLower()); + _s.WriteLine("\t\twriteErrors: {0},", _assets.Options.WriteErrors.ToString().ToLower()); + _s.WriteLine("\t\tabortErrors: {0},", _assets.Options.AbortErrors.ToString().ToLower()); + _s.WriteLine("\t\tvariableErrors: {0},", _assets.Options.VariableErrors.ToString().ToLower()); + _s.WriteLine("\t\tWebGL: {0},", _assets.Options.WebGL.ToString().ToLower()); + _s.WriteLine("\t\tCreateEventOrder: {0}", _assets.Options.CreationEventOrder.ToString().ToLower()); + if (Program.LoadingBarName != null) + { + _s.WriteLine(",\t\tloadingBarCallback: \"{0}\"", Program.LoadingBarName); + } + _s.WriteLine("}"); + if (_assets.Options.LoadImage != null && Program.CustomLoadingScreen) + { + _assets.Options.LoadImage.Save(baseDir + "\\loadingscreen.png"); + } + ms_simpleConstants.Clear(); + foreach (KeyValuePair constant in _assets.Options.Constants) + { + int value = 0; + if (GMLCompile.ms_ConstantCount.TryGetValue(constant.Key, out value) && value > 0) + { + GMLCode gMLCode = new GMLCode(ms_assets, "const_" + constant.Key, "return " + constant.Value, eGMLCodeType.eConstant); + string _ret; + if (!IsSimpleConstant(gMLCode, out _ret)) + { + ms_codeToCompile.Add(gMLCode.Name, gMLCode); + } + else + { + ms_simpleConstants.Add(constant.Key, _ret); + } + } + } + } + + private static void WriteTextures(GMAssets _assets, TextWriter _s) + { + _s.Write("\tTextures: ["); + int num = 0; + if (ms_tpageSprites.Textures != null) + { + foreach (Texture texture in ms_tpageSprites.Textures) + { + Program.Out.Write("{0} Compressing texture... ", num); + Image _dest = null; + byte[] bytes = Form1.createOutTexture(texture.Bitmap, eSquishFlags.kDxt5 | eSquishFlags.kColourMetricPerceptual | eSquishFlags.kClusterFitMaxIteration8, out _dest, Program.TextureType[texture.Group]); + string path = Path.Combine(baseDir, string.Format("{2}_texture_{0}{1}", num, Program.TextureTypeExtension(Program.TextureType[texture.Group]), baseGameName)); + Program.Out.WriteLine("writing texture {0}... ", Path.GetFileName(path)); + if (num > 0) + { + _s.Write(", "); + } + _s.Write("\"{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, bytes); + } + Application.DoEvents(); + num++; + } + } + _s.WriteLine("],"); + } + + private static void WriteWaveforms(GMAssets _assets, TextWriter _s) + { + } + + private static void WriteHelp(GMAssets _assets, TextWriter _s) + { + } + + private static void WriteTriggers(IList _triggers, TextWriter _s) + { + _s.Write("\tTriggers: [{ },"); + int num = 0; + foreach (GMTrigger _trigger in _triggers) + { + if (num > 0) + { + _s.Write(","); + } + _s.Write("{"); + _s.Write("pName:\"{0}\",", _trigger.Name); + _s.Write("moment: {0},", _trigger.Moment); + _s.Write("constant: \"{0}\",", _trigger.ConstName); + string text = "gml_Trigger_" + EnsureValidId(_trigger.Name); + _s.Write("pFunc:{0}", text); + GMLCode gMLCode = new GMLCode(ms_assets, text, _trigger.Condition, eGMLCodeType.eTrigger); + ms_codeToCompile.Add(gMLCode.Name, gMLCode); + _s.WriteLine("}"); + num++; + } + _s.WriteLine("],"); + } + + private static void WriteExtensions(IList _extensions, TextWriter _s) + { + _s.Write("\tExtensions: ["); + List list = new List(); + List list2 = new List(); + List list3 = new List(); + List list4 = new List(); + int num = 0; + foreach (GMExtension _extension in _extensions) + { + int num2 = 0; + list.Clear(); + list2.Clear(); + foreach (GMExtensionInclude include in _extension.Includes) + { + if (!include.Filename.EndsWith(".dll") && !include.Filename.EndsWith(".gml") && _extension.ExtensionDLL[num2] != null) + { + File.WriteAllBytes(Path.Combine(baseDir, include.Filename), _extension.ExtensionDLL[num2]); + } + if (include.Filename.EndsWith(".js")) + { + list.Add(include.Filename); + } + if (include.Filename.EndsWith(".gml")) + { + list2.Add(_extension.ExtensionDLL[num2]); + list3.Add(_extension.Includes[num2].Init); + list4.Add(_extension.Includes[num2].Final); + foreach (GMExtensionConstant constant in include.Constants) + { + ms_assets.Options.Constants[constant.Name] = constant.Value; + } + } + num2++; + } + if (list.Count > 0) + { + string text = ""; + string text2 = ""; + foreach (GMExtensionInclude include2 in _extension.Includes) + { + foreach (GMExtensionFunction function in include2.Functions) + { + ms_obfuscateKeywords.Add(function.Name); + } + foreach (GMExtensionConstant constant2 in include2.Constants) + { + ms_obfuscateKeywords.Add(constant2.Name); + } + if (!string.IsNullOrEmpty(include2.Init)) + { + text = include2.Init; + } + if (!string.IsNullOrEmpty(include2.Final)) + { + text2 = include2.Final; + } + } + if (num > 0) + { + _s.Write(","); + } + _s.WriteLine("\t{"); + _s.Write("\t\tjsFiles:["); + num2 = 0; + foreach (string item in list) + { + if (num2 > 0) + { + _s.Write(", "); + } + _s.Write("\"{0}\"", item); + num2++; + } + _s.WriteLine("]"); + if (!string.IsNullOrEmpty(text)) + { + _s.WriteLine(",\t\t init:\"{0}\"", text); + } + if (!string.IsNullOrEmpty(text2)) + { + _s.WriteLine(",\t\tfinal:\"{0}\"", text2); + } + _s.WriteLine("}"); + num++; + } + if (list2.Count > 0) + { + for (num2 = 0; num2 < list2.Count; num2++) + { + byte[] bytes = list2[num2]; + string @string = Encoding.ASCII.GetString(bytes); + string[] array = Regex.Split(@string, "\r\n"); + StringBuilder stringBuilder = new StringBuilder(); + string text3 = ""; + string[] array2 = array; + foreach (string text4 in array2) + { + string text5 = text4.Trim(); + if (text5.StartsWith("#define")) + { + if (!string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(stringBuilder.ToString())) + { + GMLCode gMLCode = new GMLCode(ms_assets, "gml_Script_" + text3, stringBuilder.ToString(), eGMLCodeType.eScript); + ms_codeToCompile.Add(gMLCode.Name, gMLCode); + } + string[] array3 = text5.Split(' ', '\t'); + text3 = ((array3.Length <= 1) ? string.Empty : array3[1]); + stringBuilder.Length = 0; + } + else + { + stringBuilder.AppendLine(text4); + } + } + if (!string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(stringBuilder.ToString())) + { + GMLCode gMLCode2 = new GMLCode(ms_assets, "gml_Script_" + text3, stringBuilder.ToString(), eGMLCodeType.eScript); + ms_codeToCompile.Add(gMLCode2.Name, gMLCode2); + } + if (num > 0) + { + _s.Write(","); + } + _s.Write("\t{"); + if (!string.IsNullOrEmpty(list3[num2])) + { + _s.Write(" init:\"gml_Script_{0}\"", list3[num2]); + ms_obfuscateKeywords.Add(string.Format("gml_Script_{0}", list3[num2])); + if (!string.IsNullOrEmpty(list4[num2])) + { + _s.Write(","); + } + } + if (!string.IsNullOrEmpty(list4[num2])) + { + _s.Write(" final:\"gml_Script_{0}\"", list4[num2]); + ms_obfuscateKeywords.Add(string.Format("gml_Script_{0}", list4[num2])); + } + _s.WriteLine("}"); + num++; + } + } + } + _s.WriteLine("],"); + } + + private static void ConvertToMP3(string _exe, string _origName, GMSound _snd) + { + string text = Path.Combine(baseDir, string.Format("{0}{1}", Path.GetFileNameWithoutExtension(_origName), ".mp3")); + if (Path.GetExtension(_origName) != ".mp3") + { + if (!File.Exists(text) || File.GetLastWriteTimeUtc(ms_assets.FileName) > File.GetLastWriteTimeUtc(text)) + { + string tempFileName = Path.GetTempFileName(); + File.WriteAllBytes(tempFileName, _snd.Data); + ProcessStartInfo processStartInfo = new ProcessStartInfo(_exe, string.Format("-y -i \"{0}\" -acodec libmp3lame -ab 128k \"{1}\"", tempFileName, text)); + processStartInfo.UseShellExecute = false; + processStartInfo.RedirectStandardOutput = true; + processStartInfo.RedirectStandardError = true; + Process process = new Process(); + process.StartInfo = processStartInfo; + process.OutputDataReceived += delegate(object sender, DataReceivedEventArgs args) + { + if (Program.Verbose) + { + Program.Out.WriteLine(args.Data); + } + }; + process.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs args) + { + if (Program.Verbose) + { + Program.Out.WriteLine(args.Data); + } + }; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + process.WaitForExit(); + File.Delete(tempFileName); + } + } + else + { + File.WriteAllBytes(text, _snd.Data); + } + } + + private static void ConvertToOgg(string _exe, string _origName, GMSound _snd) + { + string text = Path.Combine(baseDir, string.Format("{0}{1}", Path.GetFileNameWithoutExtension(_origName), ".ogg")); + if (Path.GetExtension(_origName) != ".ogg") + { + if (!File.Exists(text) || File.GetLastWriteTimeUtc(ms_assets.FileName) > File.GetLastWriteTimeUtc(text)) + { + string tempFileName = Path.GetTempFileName(); + File.WriteAllBytes(tempFileName, _snd.Data); + ProcessStartInfo processStartInfo = new ProcessStartInfo(_exe, string.Format("-y -i \"{0}\" -acodec libvorbis -aq 60 \"{1}\"", tempFileName, text)); + processStartInfo.UseShellExecute = false; + processStartInfo.RedirectStandardOutput = true; + processStartInfo.RedirectStandardError = true; + Process process = new Process(); + process.StartInfo = processStartInfo; + process.OutputDataReceived += delegate(object sender, DataReceivedEventArgs args) + { + if (Program.Verbose) + { + Program.Out.WriteLine(args.Data); + } + }; + process.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs args) + { + if (Program.Verbose) + { + Program.Out.WriteLine(args.Data); + } + }; + process.Start(); + process.BeginOutputReadLine(); + process.BeginErrorReadLine(); + process.WaitForExit(); + File.Delete(tempFileName); + } + } + else + { + File.WriteAllBytes(text, _snd.Data); + } + } + + private static void WriteSounds(IList> _sounds, TextWriter _s) + { + _s.WriteLine("\tSounds: ["); + WriteDataKVP(_sounds, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + GMSound value = _kvp.Value; + string text = Path.GetFileName(value.OrigName); + bool flag = true; + while (flag) + { + flag = false; + foreach (string ms_SoundFilename in ms_SoundFilenames) + { + if (ms_SoundFilename == text) + { + text = string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(text), "_a", Path.GetExtension(text)); + flag = true; + } + } + } + if (value.Data != null) + { + string text2 = Path.Combine(baseDir, text); + string text3 = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ffmpeg.exe"); + if (File.Exists(text3)) + { + string text4 = Path.ChangeExtension(value.OrigName, ".mp3"); + string text5 = Path.ChangeExtension(value.OrigName, ".ogg"); + if (File.Exists(text4)) + { + CopyFile(text4, Path.ChangeExtension(text2, ".mp3")); + } + if (File.Exists(text5)) + { + CopyFile(text5, Path.ChangeExtension(text2, ".ogg")); + } + if (!File.Exists(text4) || !File.Exists(text5)) + { + Program.Out.Write("Converting {0} to MP3...", text); + ConvertToMP3(text3, text2, value); + Program.Out.Write("OGG..."); + ConvertToOgg(text3, text2, value); + Program.Out.WriteLine("Finished!"); + } + text = Path.GetFileNameWithoutExtension(text); + } + else + { + File.WriteAllBytes(text2, value.Data); + } + } + ms_SoundFilenames.Add(text); + if (__n > 0) + { + _s.WriteLine(","); + } + _s.WriteLine("\t {"); + _s.WriteLine("\t\tpName: \"{0}\",", _kvp.Key); + _s.WriteLine("\t\tkind: {0},", value.Kind); + _s.WriteLine("\t\textension: \"{0}\",", value.Extension); + _s.WriteLine("\t\torigName: \"{0}\",", text); + _s.WriteLine("\t\teffects: {0},", value.Effects); + _s.WriteLine("\t\tvolume: {0},", value.Volume.ToString(CultureInfo.InvariantCulture.NumberFormat)); + _s.WriteLine("\t\tpan: {0},", value.Pan); + _s.WriteLine("\t\tpreload: {0}", value.Preload.ToString().ToLower()); + _s.Write("\t }"); + }); + _s.WriteLine("\t],"); + } + + private static byte[] RLEEncode(byte[] _source) + { + List list = new List(); + int num = 0; + while (num < _source.Length) + { + if (num + 2 < _source.Length && _source[num] == _source[num + 1] && _source[num + 1] == _source[num + 2]) + { + int i; + for (i = 1; i < 127 && num + i + 1 < _source.Length && _source[num + i] == _source[num + i + 1]; i++) + { + } + i++; + list.Add((byte)(((i - 1) & 0x7F) | 0x80)); + list.Add(_source[num]); + num += i; + continue; + } + int j; + for (j = 1; j < 127 && num + j + 1 < _source.Length && (num + j + 2 >= _source.Length || _source[num + j] != _source[num + j + 1] || _source[num + j] != _source[num + j + 2]); j++) + { + } + list.Add((byte)((j - 1) & 0x7F)); + for (int k = num; k < num + j; k++) + { + list.Add(_source[k]); + } + num += j; + } + return list.ToArray(); + } + + private static void WriteSprites(IList> _sprites, TextWriter _s) + { + _s.WriteLine("\tSprites: ["); + WriteDataKVP(_sprites, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + GMSprite value = _kvp.Value; + if (__n > 0) + { + _s.WriteLine(","); + } + _s.WriteLine("\t {"); + _s.WriteLine("\t\tpName: \"{0}\",", _kvp.Key); + if (value.Width != 16) + { + _s.Write("\t\twidth: {0},", value.Width); + } + if (value.Height != 16) + { + _s.WriteLine(" height: {0},", value.Height); + } + if (value.BBoxMode != 0) + { + _s.WriteLine(" bboxMode: {0},", value.BBoxMode); + } + if (!value.Transparent) + { + _s.WriteLine("\t\ttransparent: {0},", value.Transparent.ToString().ToLower()); + } + if (!value.Smooth) + { + _s.WriteLine("\t\tsmooth: {0},", value.Smooth.ToString().ToLower()); + } + if (!value.Preload) + { + _s.WriteLine("\t\tpreload: {0},", value.Preload.ToString().ToLower()); + } + if (value.ColCheck) + { + _s.WriteLine("\t\tcolCheck: {0},", value.ColCheck.ToString().ToLower()); + } + if (value.XOrig != 0) + { + _s.Write("\t\txOrigin: {0},", value.XOrig); + } + if (value.YOrig != 0) + { + _s.WriteLine("yOrigin: {0},", value.YOrig); + } + if (value.BBoxLeft != 0) + { + _s.Write("\t\tbboxLeft: {0},", value.BBoxLeft); + } + if (value.BBoxRight != 0) + { + _s.Write(" bboxRight: {0},", value.BBoxRight); + } + if (value.BBoxTop != 0) + { + _s.Write(" bboxTop: {0},", value.BBoxTop); + } + if (value.BBoxBottom != 0) + { + _s.Write(" bboxBottom: {0},", value.BBoxBottom); + } + _s.Write("\t\tTPEntryIndex: [ "); + for (int i = 0; i < value.Images.Count; i++) + { + TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Images[i].Bitmap, true, false); + if (i > 0) + { + _s.Write(", "); + } + _s.Write("{0}", texturePageEntry.Entry); + } + if (!value.ColCheck) + { + _s.WriteLine("]"); + } + else + { + _s.WriteLine("],"); + IList masks = value.Masks; + _s.Write("\t\tMasks: [ "); + if (masks != null) + { + _s.WriteLine(); + int num = 0; + foreach (byte[] item in masks) + { + byte[] array = RLEEncode(item); + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("[\t"); + int num2 = 0; + int num3 = 0; + byte[] array2 = array; + foreach (byte b in array2) + { + if (num2 > 0) + { + _s.Write(","); + } + if (num3 >= 32) + { + num3 = 0; + _s.WriteLine(); + _s.Write("\t"); + } + _s.Write(string.Format("0x{0:X2}", b)); + num2++; + num3++; + } + _s.Write("]"); + num++; + } + if (num > 0) + { + _s.WriteLine(); + } + } + _s.WriteLine("]"); + } + _s.Write("\t }"); + }); + _s.WriteLine("\t],"); + } + + private static void WriteBackgrounds(IList> _backgrounds, TextWriter _s) + { + _s.WriteLine("\tBackgrounds: ["); + WriteDataKVP(_backgrounds, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + GMBackground value = _kvp.Value; + _s.Write("\t\t{"); + _s.Write(" pName: \"{0}\",", _kvp.Key); + _s.Write(" transparent: {0},", value.Transparent.ToString().ToLower()); + _s.Write(" smooth: {0},", value.Smooth.ToString().ToLower()); + _s.Write(" preload: {0},", value.Smooth.ToString().ToLower()); + if (value.Bitmap != null && value.Bitmap.Data != null && value.Bitmap.Width * value.Bitmap.Height > 0) + { + TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap.Bitmap, !value.Tileset, false); + texturePageEntry.OriginalRepeatBorder = true; + texturePageEntry.RepeatX = 2; + texturePageEntry.RepeatY = 2; + TextureOptions.SetTextureOptions(_kvp.Key, texturePageEntry); + _s.Write(" TPEntryIndex: {0}", texturePageEntry.Entry); + } + else + { + _s.Write(" TPEntryIndex: -1"); + } + _s.Write(" }"); + }); + _s.WriteLine("\t],"); + } + + private static void WritePaths(IList> _paths, TextWriter _s) + { + _s.WriteLine("\tPaths: ["); + ms_fWriteNulls = true; + WriteDataKVP(_paths, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + GMPath value = _kvp.Value; + _s.Write("\t\t{"); + _s.Write(" pName: \"{0}\",", _kvp.Key); + _s.Write(" kind: {0},", value.Kind.ToString().ToLower()); + _s.Write(" closed: {0},", value.Closed.ToString().ToLower()); + _s.Write(" precision: {0},", value.Precision); + _s.WriteLine(" points : ["); + int num = 0; + foreach (GMPathPoint point in value.Points) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("{{ x:{0}, y:{1}, speed:{2} }}", point.X, point.Y, point.Speed); + num++; + } + _s.Write(" ]}"); + }); + ms_fWriteNulls = true; + _s.WriteLine("\t],"); + } + + private static void WriteScripts(IList> _scripts, TextWriter _s) + { + ms_fWriteNulls = true; + _s.WriteLine("\tScripts: ["); + WriteDataKVP(_scripts, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + GMScript value = _kvp.Value; + if (value != null) + { + GMLCode gMLCode = new GMLCode(ms_assets, "gml_Script_" + _kvp.Key, value.Script, eGMLCodeType.eScript); + ms_codeToCompile.Add(gMLCode.Name, gMLCode); + _s.WriteLine("{0}", gMLCode.Name); + } + }); + ms_fWriteNulls = true; + _s.WriteLine("\t],"); + } + + private static Encoding GetEncoding(int _codepage) + { + int codepage = 1252; + switch (_codepage) + { + case 0: + codepage = 1252; + break; + case 1: + codepage = 1252; + break; + case 238: + codepage = 1250; + break; + case 204: + codepage = 1251; + break; + case 2: + codepage = 1252; + break; + case 128: + codepage = 932; + break; + case 129: + codepage = 949; + break; + case 134: + codepage = 936; + break; + case 136: + codepage = 950; + break; + case 130: + codepage = 1361; + break; + case 177: + codepage = 1255; + break; + case 178: + codepage = 1256; + break; + case 161: + codepage = 1253; + break; + case 162: + codepage = 1254; + break; + case 163: + codepage = 1258; + break; + case 222: + codepage = 874; + break; + case 77: + codepage = 1252; + break; + case 186: + codepage = 1257; + break; + case 255: + codepage = 1252; + break; + } + return Encoding.GetEncoding(codepage); + } + + private static void WriteFonts(IList> _fonts, TextWriter _s) + { + _s.WriteLine("\tFonts: ["); + WriteDataKVP(_fonts, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + GMFont value = _kvp.Value; + __s.Write("\t\t{"); + __s.Write(" pName: \"{0}\",", _kvp.Key); + __s.Write(" size: {0},", value.Size); + __s.Write(" bold: {0},", value.Bold.ToString().ToLower()); + __s.Write(" italic: {0},", value.Italic.ToString().ToLower()); + __s.Write(" first: {0},", value.First); + __s.Write(" last: {0},", value.Last); + __s.Write(" charset: {0},", value.CharSet); + __s.Write(" antialias: {0},", value.AntiAlias); + __s.Write(" fontname: \"{0}\",", value.Name); + TexturePageEntry texturePageEntry = ms_tpageSprites.AddImage(value.Bitmap, false, true); + __s.Write(" TPageEntry: {0},", texturePageEntry.Entry); + 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.Write(" scaleX: {0},", (float)num); + __s.Write(" scaleY: {0},", (float)num2); + __s.WriteLine(" glyphs: ["); + int num3 = 0; + Encoding encoding = GetEncoding(value.CharSet); + byte[] array = new byte[1]; + foreach (GMGlyph glyph in value.Glyphs) + { + if (glyph.W * glyph.H != 0) + { + __s.Write("\t\t\t{"); + __s.Write(" i: {0},", num3); + array[0] = (byte)num3; + char[] chars = encoding.GetChars(array); + char c = chars[0]; + switch (char.GetUnicodeCategory(c)) + { + default: + if (c == '\\' || c == '"') + { + __s.Write(" c: \"\\{0}\",", c); + } + else + { + __s.Write(" c: \"{0}\",", c); + } + break; + case UnicodeCategory.Control: + case UnicodeCategory.Format: + break; + } + __s.Write(" x: {0},", (int)(((double)glyph.X + num - 1.0) / num)); + __s.Write(" y: {0},", (int)(((double)glyph.Y + num2 - 1.0) / num2)); + __s.Write(" w: {0},", (int)(((double)glyph.W + num - 1.0) / num)); + __s.Write(" h: {0},", (int)(((double)glyph.H + num2 - 1.0) / num2)); + __s.Write(" shift: {0},", (int)(((double)glyph.Shift + num - 1.0) / num)); + __s.Write(" offset: {0} ", (int)(((double)glyph.Offset + num - 1.0) / num)); + __s.WriteLine(" },"); + } + num3++; + } + __s.WriteLine("\t\t\t],"); + __s.Write("\t\t}"); + }); + _s.WriteLine("\t],"); + } + + private static void WriteGMEvent(GMEvent _event, TextWriter _s, string _basename) + { + WriteDataList(_event.Actions, _s, delegate(GMAction _action, TextWriter __s, int __n) + { + string text = _basename; + for (int i = 0; i < _action.ArgumentCount; i++) + { + if (!string.IsNullOrEmpty(_action.Args[i])) + { + GMLCode value = new GMLCode(ms_assets, text, _action.Args[i], eGMLCodeType.eEvent); + ms_codeToCompile[text] = value; + } + } + }); + } + + private static void WriteTimelines(IList> _timelines, TextWriter _s) + { + _s.WriteLine("\tTimelines: ["); + WriteDataKVP(_timelines, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + int num = 0; + GMTimeLine value = _kvp.Value; + _s.WriteLine("\t {"); + _s.WriteLine("\t\t\tpName: \"{0}\",", _kvp.Key); + _s.WriteLine("\t\t\tEvents: ["); + foreach (KeyValuePair entry in value.Entries) + { + if (entry.Value.Actions.Count > 0) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.WriteLine("\t\t\t\t{Time: " + entry.Key + ", Event: Timeline_" + EnsureValidId(_kvp.Key) + "_" + num + "}"); + num++; + } + } + _s.WriteLine("\t\t\t],"); + _s.Write("\t }"); + num = 0; + foreach (KeyValuePair entry2 in value.Entries) + { + if (entry2.Value.Actions.Count > 0) + { + WriteGMEvent(entry2.Value, __s, "Timeline_" + EnsureValidId(_kvp.Key) + "_" + num); + num++; + } + } + }); + _s.WriteLine("\t],"); + ms_fWriteNulls = true; + } + + private static string GetEventName(int _nEvent, int _nSubEvent) + { + return event2Name[_nEvent] + "_" + _nSubEvent; + } + + private static void WriteObjects(IList> _objects, TextWriter _s) + { + _s.WriteLine("\tGMObjects: ["); + WriteDataKVP(_objects, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + GMObject value = _kvp.Value; + __s.Write("\t\t{"); + __s.Write("\t\t\tpName: \"{0}\", ", _kvp.Key); + if (value.SpriteIndex != 0) + { + __s.Write(" spriteIndex: {0}, ", value.SpriteIndex); + } + if (value.Visible) + { + __s.Write(" visible: {0}, ", value.Visible.ToString().ToLower()); + } + if (value.Solid) + { + __s.Write(" solid: {0}, ", value.Solid.ToString().ToLower()); + } + if (value.Persistent) + { + __s.Write(" persistent: {0}, ", value.Persistent.ToString().ToLower()); + } + if (value.Depth != 0) + { + __s.Write(" depth: {0}, ", value.Depth); + } + if (value.Parent != 0) + { + __s.Write(" parent: {0}, ", value.Parent); + } + if (value.Mask != -1) + { + __s.Write(" spritemask: {0}, ", value.Mask); + } + string basename = "gml_Object_" + _kvp.Key.Replace(' ', '_'); + int count = 0; + WriteDataList(value.Events, __s, delegate(IList> _list, TextWriter ___s, int _nEvent) + { + WriteDataList(_list, ___s, delegate(KeyValuePair _entry, TextWriter ____s, int _nSubEvent) + { + string jSEventName = GetJSEventName(_nEvent, 0); + if (jSEventName != "CollisionEvent" && jSEventName != "Trigger") + { + jSEventName = GetJSEventName(_nEvent, _entry.Key); + string text3 = basename + "_" + GetEventName(_nEvent, _entry.Key); + WriteGMEvent(_entry.Value, ____s, text3); + if (count > 0) + { + __s.WriteLine(","); + } + __s.Write(" {0}: {1}", jSEventName, text3); + count++; + } + }); + }); + if (count > 0) + { + __s.WriteLine(","); + } + count = 0; + __s.Write(" TriggerEvents: [ ", value.Mask); + WriteDataList(value.Events, __s, delegate(IList> _list, TextWriter ___s, int _nEvent) + { + WriteDataList(_list, ___s, delegate(KeyValuePair _entry, TextWriter ____s, int _nSubEvent) + { + if (GetJSEventName(_nEvent, 0) == "Trigger") + { + string text2 = basename + "_" + GetEventName(_nEvent, _entry.Key); + WriteGMEvent(_entry.Value, ____s, text2); + if (count > 0) + { + __s.Write(","); + } + __s.Write(" {0},{1}", _entry.Key, text2); + count++; + } + }); + }); + __s.WriteLine(" ],", value.Mask); + count = 0; + __s.Write(" CollisionEvents: [ ", value.Mask); + WriteDataList(value.Events, __s, delegate(IList> _list, TextWriter ___s, int _nEvent) + { + WriteDataList(_list, ___s, delegate(KeyValuePair _entry, TextWriter ____s, int _nSubEvent) + { + if (GetJSEventName(_nEvent, 0) == "CollisionEvent") + { + string arg = _entry.Key.ToString(); + string text = basename + "_" + GetEventName(_nEvent, _entry.Key); + WriteGMEvent(_entry.Value, ____s, text); + if (count > 0) + { + __s.Write(","); + } + __s.Write(" {0}, {1}", arg, text); + count++; + } + }); + }); + __s.WriteLine(" ]", value.Mask); + __s.Write(" }"); + }); + _s.WriteLine("\t],"); + } + + private static string EncodeString(string _str) + { + _str = _str.Replace("\\", "\\"); + _str = _str.Replace("\"", "\\\""); + return _str; + } + + private static void WriteRooms(IList> _rooms, TextWriter _s) + { + _s.WriteLine("\tGMRooms: ["); + WriteDataKVP(_rooms, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + GMRoom value = _kvp.Value; + if (__n > 0) + { + _s.WriteLine(","); + } + _s.WriteLine("\t\t{\t"); + _s.WriteLine("\t\t\tpName:\"{0}\",", _kvp.Key); + if (!string.IsNullOrEmpty(value.Caption)) + { + _s.WriteLine("\t\t\tpCaption:\"{0}\",", EncodeString(value.Caption)); + } + if (value.Width != 1024) + { + _s.WriteLine("\t\t\twidth:{0},", value.Width); + } + if (value.Height != 768) + { + _s.WriteLine("\t\t\theight:{0},", value.Height); + } + if (value.Speed != 30) + { + _s.WriteLine("\t\t\tspeed:{0},", value.Speed); + } + if (value.Persistent) + { + _s.WriteLine("\t\t\tpersistent:{0},", value.Persistent.ToString().ToLower()); + } + if (value.Colour != 12632256) + { + _s.WriteLine("\t\t\tcolour:{0},", value.Colour); + } + if (!value.ShowColour) + { + _s.WriteLine("\t\t\tshowColour:{0},", value.ShowColour.ToString().ToLower()); + } + if (value.EnableViews) + { + _s.WriteLine("\t\t\tenableViews:{0},", value.EnableViews.ToString().ToLower()); + } + if (!value.ViewClearScreen) + { + _s.WriteLine("\t\t\tviewClearScreen:{0},", value.ViewClearScreen.ToString().ToLower()); + } + if (!string.IsNullOrEmpty(value.Code)) + { + string text = string.Format("gml_Room_{0}_Create", _kvp.Key); + GMLCode value2 = new GMLCode(ms_assets, text, value.Code, eGMLCodeType.eRoomCreate); + ms_codeToCompile.Add(text, value2); + _s.WriteLine("\t\t\tpCode: {0},", text); + } + _s.WriteLine("\t\t\tbackgrounds:["); + int num = 0; + foreach (GMBack background in value.Backgrounds) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\t\t\t{"); + if (background.Visible) + { + _s.Write(" visible:{0}, ", background.Visible.ToString().ToLower()); + } + if (background.Foreground) + { + _s.Write(" foreground:{0}, ", background.Foreground.ToString().ToLower()); + } + if (background.Index != -1) + { + _s.Write(" index:{0}, ", background.Index); + } + if (background.X != 0) + { + _s.Write(" x:{0}, ", background.X); + } + if (background.Y != 0) + { + _s.Write(" y:{0}, ", background.Y); + } + if (!background.HTiled) + { + _s.Write(" htiled:{0}, ", background.HTiled.ToString().ToLower()); + } + if (!background.VTiled) + { + _s.Write(" vtiled:{0}, ", background.VTiled.ToString().ToLower()); + } + if (background.HSpeed != 0) + { + _s.Write(" hspeed:{0}, ", background.HSpeed); + } + if (background.VSpeed != 0) + { + _s.Write(" vspeed:{0}, ", background.VSpeed); + } + if (background.Stretch) + { + _s.Write(" stretch:{0} ", background.Stretch.ToString().ToLower()); + } + _s.Write(" }"); + num++; + } + _s.WriteLine("\t\t\t],"); + _s.WriteLine("\t\t\tviews:["); + num = 0; + foreach (GMView view in value.Views) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\t\t\t{"); + if (view.Visible) + { + _s.Write(" visible:{0}, ", view.Visible.ToString().ToLower()); + } + if (view.XView != 0) + { + _s.Write(" xview:{0}, ", view.XView); + } + if (view.YView != 0) + { + _s.Write(" yview:{0}, ", view.YView); + } + if (view.WView != 640) + { + _s.Write(" wview:{0}, ", view.WView); + } + if (view.HView != 480) + { + _s.Write(" hview:{0}, ", view.HView); + } + if (view.XPort != 0) + { + _s.Write(" xport:{0}, ", view.XPort); + } + if (view.YPort != 0) + { + _s.Write(" yport:{0}, ", view.YPort); + } + if (view.WPort != 640) + { + _s.Write(" wport:{0}, ", view.WPort); + } + if (view.HPort != 480) + { + _s.Write(" hport:{0}, ", view.HPort); + } + if (view.HBorder != 32) + { + _s.Write(" hborder:{0}, ", view.HBorder); + } + if (view.VBorder != 32) + { + _s.Write(" vborder:{0}, ", view.VBorder); + } + if (view.HSpeed != -1) + { + _s.Write(" hspeed:{0}, ", view.HSpeed); + } + if (view.VSpeed != -1) + { + _s.Write(" vspeed:{0}, ", view.VSpeed); + } + if (view.Index != -1) + { + _s.Write(" index:{0} ", view.Index); + } + _s.Write(" }"); + num++; + } + _s.WriteLine("\t\t\t],"); + _s.WriteLine("\t\t\tpInstances:["); + int num2 = 0; + foreach (GMInstance instance in value.Instances) + { + if (num2 > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\t\t\t{"); + _s.Write(" x:{0}, ", instance.X); + _s.Write(" y:{0}, ", instance.Y); + _s.Write(" index:{0}, ", instance.Index); + _s.Write(" id:{0}, ", instance.Id); + if (!string.IsNullOrEmpty(instance.Code)) + { + string text2 = string.Format("gml_RoomCC_{0}_{1}_Create", _kvp.Key, num2); + GMLCode value3 = new GMLCode(ms_assets, text2, instance.Code, eGMLCodeType.eRoomInstanceCreate); + ms_codeToCompile.Add(text2, value3); + _s.Write(" pCode: {0}, ", text2); + } + _s.Write(" scaleX:{0}, ", instance.ScaleX); + _s.Write(" scaleY:{0}, ", instance.ScaleY); + _s.Write(" colour:{0} ", instance.Colour); + _s.Write(" }"); + num2++; + } + _s.WriteLine("\t\t\t],"); + _s.WriteLine("\t\t\ttiles:["); + num = 0; + foreach (GMTile tile in value.Tiles) + { + if (num > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\t\t\t{"); + int num3 = 0; + if (tile.X != 0) + { + _s.Write(" x:{0} ", tile.X); + num3++; + } + if (tile.Y != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" y:{0} ", tile.Y); + num3++; + } + if (tile.Index != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" index:{0} ", tile.Index); + num3++; + } + if (tile.XO != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" xo:{0} ", tile.XO); + num3++; + } + if (tile.YO != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" yo:{0} ", tile.YO); + num3++; + } + if (tile.W != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" w:{0} ", tile.W); + num3++; + } + if (tile.H != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" h:{0} ", tile.H); + num3++; + } + if (tile.Depth != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" depth:{0} ", tile.Depth); + num3++; + } + if (tile.Id != 0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" id:{0} ", tile.Id); + num3++; + } + if (tile.XScale != 1.0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" scaleX:{0} ", tile.XScale); + num3++; + } + if (tile.YScale != 1.0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" scaleY:{0} ", tile.YScale); + num3++; + } + if (tile.Blend != 1048575 || tile.Alpha != 1.0) + { + if (num3 > 0) + { + _s.Write(","); + } + _s.Write(" colour:{0} ", ((int)(tile.Alpha * 255.0) << 24) | tile.Blend); + num3++; + } + _s.Write(" }"); + num++; + } + _s.WriteLine("\t\t\t]\t"); + _s.Write("\t\t}\t"); + }); + _s.WriteLine("\t],"); + } + + private static void WriteRoomOrder(IList _roomOrder, TextWriter _sw) + { + _sw.Write("\tRoomOrder: ["); + int num = 0; + foreach (int item in _roomOrder) + { + if (num > 0) + { + _sw.Write(","); + } + _sw.Write("{0}", item); + num++; + } + _sw.WriteLine("\t],"); + } + + private static void WriteDataFiles(IList> _datafiles, TextWriter _s) + { + ms_fWriteNulls = false; + WriteDataKVP(_datafiles, _s, delegate(KeyValuePair _kvp, TextWriter __s, int __n) + { + GMDataFile value = _kvp.Value; + string text = Path.Combine(baseDir, Path.GetFileName(value.FileName)); + Program.Out.WriteLine("Writing datafile {0} to {1}", value.FileName, text); + if (value.Data != null && value.Data.Length > 0) + { + File.WriteAllBytes(text, value.Data); + } + else + { + FileStream fileStream = File.Create(text); + fileStream.Close(); + fileStream.Dispose(); + } + }); + ms_fWriteNulls = true; + } + + private static void WriteTexturePages(GMAssets _assets, TextWriter _s) + { + if (ms_tpageSprites.Entries.Count > 0) + { + ms_tpageSprites.Compile(); + } + IOrderedEnumerable source = ms_tpageSprites.Entries.OrderBy((TexturePageEntry e) => e.Entry); + _s.WriteLine("\tTPageEntries: ["); + WriteDataList(source.ToList(), _s, delegate(TexturePageEntry _tpe, TextWriter __s, int __n) + { + if (__n > 0) + { + _s.WriteLine(","); + } + _s.Write("\t\t{"); + _s.Write(" x:{0},", _tpe.X); + _s.Write(" y:{0},", _tpe.Y); + _s.Write(" w:{0},", _tpe.W); + _s.Write(" h:{0},", _tpe.H); + _s.Write(" XOffset:{0},", _tpe.XOffset); + _s.Write(" YOffset:{0},", _tpe.YOffset); + _s.Write(" CropWidth:{0},", _tpe.CropWidth); + _s.Write(" CropHeight:{0},", _tpe.CropHeight); + _s.Write(" ow:{0},", _tpe.OW); + _s.Write(" oh:{0},", _tpe.OH); + _s.Write(" tp:{0}", _tpe.TP.TP); + _s.Write("}"); + }); + _s.WriteLine("\t],"); + } + + public static void Save(GMAssets _assets, TextWriter _s) + { + ms_assets = _assets; + _s.WriteLine("var JSON_game = {"); + WriteHeader(_assets, _s); + WriteExtensions(_assets.Extensions, _s); + WriteHelp(_assets, _s); + WriteSounds(_assets.Sounds, _s); + WriteSprites(_assets.Sprites, _s); + WriteBackgrounds(_assets.Backgrounds, _s); + WritePaths(_assets.Paths, _s); + WriteScripts(_assets.Scripts, _s); + WriteFonts(_assets.Fonts, _s); + WriteTimelines(_assets.TimeLines, _s); + WriteTriggers(_assets.Triggers, _s); + WriteObjects(_assets.Objects, _s); + WriteRooms(_assets.Rooms, _s); + WriteRoomOrder(_assets.RoomOrder, _s); + WriteDataFiles(_assets.DataFiles, _s); + WriteTexturePages(_assets, _s); + WriteTextures(_assets, _s); + WriteWaveforms(_assets, _s); + WriteOptions(_assets, _s); + _s.WriteLine("};\n"); + _s.WriteLine("function gmlConst() {"); + foreach (KeyValuePair constant in _assets.Options.Constants) + { + int value = 0; + if (GMLCompile.ms_ConstantCount.TryGetValue(constant.Key, out value) && value > 0) + { + string value2; + if (!ms_simpleConstants.TryGetValue(constant.Key, out value2)) + { + _s.WriteLine("this.{0} = const_{0}();", constant.Key); + } + else + { + _s.WriteLine("this.{0} = {1};", constant.Key, value2); + } + } + } + _s.WriteLine("}"); + _s.WriteLine("function gmlInitGlobal() {"); + foreach (KeyValuePair ms_global in GML2JavaScript.ms_globals) + { + _s.WriteLine("global.{1}{0} = 0;", ms_global.Value, GML2JavaScript.ms_varPrefix); + } + _s.WriteLine("}"); + foreach (KeyValuePair item in ms_codeToCompile) + { + GMLCode value3 = item.Value; + GML2JavaScript.Compile(ms_assets, value3, _s); + _s.Flush(); + } + _s.Close(); + } + + public static string GetKeyBoardEvent(int _SubEvent) + { + switch (_SubEvent) + { + case 0: + return "NOKEY"; + case 1: + return "ANYKEY"; + case 8: + return "BACKSPACE"; + case 9: + return "TAB"; + case 13: + return "ENTER"; + case 16: + return "SHIFT"; + case 17: + return "CTRL"; + case 18: + return "ALT"; + case 19: + return "PAUSE"; + case 27: + return "ESCAPE"; + case 32: + return "SPACE"; + case 33: + return "PAGEUP"; + case 34: + return "PAGEDOWN"; + case 35: + return "END"; + case 36: + return "HOME"; + case 37: + return "LEFT"; + case 38: + return "UP"; + case 39: + return "RIGHT"; + case 40: + return "DOWN"; + case 45: + return "INSERT"; + case 46: + return "DELETE"; + case 48: + return "0"; + case 49: + return "1"; + case 50: + return "2"; + case 51: + return "3"; + case 52: + return "4"; + case 53: + return "5"; + case 54: + return "6"; + case 55: + return "7"; + case 56: + return "8"; + case 57: + return "9"; + case 65: + return "A"; + case 66: + return "B"; + case 67: + return "C"; + case 68: + return "D"; + case 69: + return "E"; + case 70: + return "F"; + case 71: + return "G"; + case 72: + return "H"; + case 73: + return "I"; + case 74: + return "J"; + case 75: + return "K"; + case 76: + return "L"; + case 77: + return "M"; + case 78: + return "N"; + case 79: + return "O"; + case 80: + return "P"; + case 81: + return "Q"; + case 82: + return "R"; + case 83: + return "S"; + case 84: + return "T"; + case 85: + return "U"; + case 86: + return "V"; + case 87: + return "W"; + case 88: + return "X"; + case 89: + return "Y"; + case 90: + return "Z"; + case 112: + return "F1"; + case 113: + return "F2"; + case 114: + return "F3"; + case 115: + return "F4"; + case 116: + return "F5"; + case 117: + return "F6"; + case 118: + return "F7"; + case 119: + return "F8"; + case 120: + return "F9"; + case 121: + return "F10"; + case 122: + return "F11"; + case 123: + return "F12"; + case 145: + return "SCROLL_LOCK"; + case 186: + return "SEMICOLON"; + case 187: + return "PLUS"; + case 188: + return "COMMA"; + case 189: + return "MINUS"; + case 190: + return "FULLSTOP"; + case 191: + return "FWSLASH"; + case 192: + return "AT"; + case 219: + return "RIGHTSQBR"; + case 220: + return "BKSLASH"; + case 221: + return "LEFTSQBR"; + case 222: + return "HASH"; + case 223: + return "TILD"; + case 144: + return "NUM_LOCK"; + case 96: + return "NUM_0"; + case 97: + return "NUM_1"; + case 98: + return "NUM_2"; + case 99: + return "NUM_3"; + case 100: + return "NUM_4"; + case 101: + return "NUM_5"; + case 102: + return "NUM_6"; + case 103: + return "NUM_7"; + case 104: + return "NUM_8"; + case 105: + return "NUM_9"; + case 106: + return "NUM_STAR"; + case 107: + return "NUM_PLUS"; + case 109: + return "NUM_MINUS"; + case 110: + return "NUM_DOT"; + case 111: + return "NUM_DIV"; + default: + return "unknown"; + } + } + + public static string GetJSEventName(int _nEvent, int _nSubEvent) + { + switch (_nEvent) + { + case 0: + return "CreateEvent"; + case 1: + return "DestroyEvent"; + case 2: + switch (_nSubEvent) + { + case 0: + return "ObjAlarm0"; + case 1: + return "ObjAlarm1"; + case 2: + return "ObjAlarm2"; + case 3: + return "ObjAlarm3"; + case 4: + return "ObjAlarm4"; + case 5: + return "ObjAlarm5"; + case 6: + return "ObjAlarm6"; + case 7: + return "ObjAlarm7"; + case 8: + return "ObjAlarm8"; + case 9: + return "ObjAlarm9"; + case 10: + return "ObjAlarm10"; + case 11: + return "ObjAlarm11"; + default: + return "unknown"; + } + case 3: + switch (_nSubEvent) + { + case 1: + return "StepBeginEvent"; + case 0: + return "StepNormalEvent"; + case 2: + return "StepEndEvent"; + default: + return "unknown"; + } + case 4: + return "CollisionEvent"; + case 5: + return "Key_" + GetKeyBoardEvent(_nSubEvent); + case 6: + switch (_nSubEvent) + { + case 0: + return "LeftButtonDown"; + case 1: + return "RightButtonDown"; + case 2: + return "MiddleButtonDown"; + case 3: + return "NoButtonPressed"; + case 4: + return "LeftButtonPressed"; + case 5: + return "RightButtonPressed"; + case 6: + return "MiddleButtonPressed"; + case 7: + return "LeftButtonReleased"; + case 8: + return "RightButtonReleased"; + case 9: + return "MiddleButtonReleased"; + case 10: + return "MouseEnter"; + case 11: + return "MouseLeave"; + case 16: + return "Joystick1Left"; + case 17: + return "Joystick1Right"; + case 18: + return "Joystick1Up"; + case 19: + return "Joystick1Down"; + case 21: + return "Joystick1Button1"; + case 22: + return "Joystick1Button2"; + case 23: + return "Joystick1Button3"; + case 24: + return "Joystick1Button4"; + case 25: + return "Joystick1Button5"; + case 26: + return "Joystick1Button6"; + case 27: + return "Joystick1Button7"; + case 28: + return "Joystick1Button8"; + case 31: + return "Joystick2Left"; + case 32: + return "Joystick2Right"; + case 33: + return "Joystick2Up"; + case 34: + return "Joystick2Down"; + case 36: + return "Joystick2Button1"; + case 37: + return "Joystick2Button2"; + case 38: + return "Joystick2Button3"; + case 39: + return "Joystick2Button4"; + case 40: + return "Joystick2Button5"; + case 41: + return "Joystick2Button6"; + case 42: + return "Joystick2Button7"; + case 43: + return "Joystick2Button8"; + case 50: + return "GlobalLeftButtonDown"; + case 51: + return "GlobalRightButtonDown"; + case 52: + return "GlobalMiddleButtonDown"; + case 53: + return "GlobalLeftButtonPressed"; + case 54: + return "GlobalRightButtonPressed"; + case 55: + return "GlobalMiddleButtonPressed"; + case 56: + return "GlobalLeftButtonReleased"; + case 57: + return "GlobalRightButtonReleased"; + case 58: + return "GlobalMiddleButtonReleased"; + case 60: + return "MouseWheelUp"; + case 61: + return "MouseWheelDown"; + default: + return "unknown"; + } + case 7: + switch (_nSubEvent) + { + case 0: + return "OutsideEvent"; + case 1: + return "BoundaryEvent"; + case 2: + return "StartGameEvent"; + case 3: + return "EndGameEvent"; + case 4: + return "StartRoomEvent"; + case 5: + return "EndRoomEvent"; + case 6: + return "NoLivesEvent"; + case 7: + return "AnimationEndEvent"; + case 8: + return "EndOfPathEvent"; + case 9: + return "NoHealthEvent"; + case 30: + return "CloseButtonEvent"; + case 40: + return "OutsideView0Event"; + case 50: + return "BoundaryView0Event"; + case 60: + return "WebImageLoadedEvent"; + case 61: + return "WebSoundLoadedEvent"; + case 62: + return "WebAsyncEvent"; + case 10: + return "UserEvent0"; + case 11: + return "UserEvent1"; + case 12: + return "UserEvent2"; + case 13: + return "UserEvent3"; + case 14: + return "UserEvent4"; + case 15: + return "UserEvent5"; + case 16: + return "UserEvent6"; + case 17: + return "UserEvent7"; + case 18: + return "UserEvent8"; + case 19: + return "UserEvent9"; + case 20: + return "UserEvent10"; + case 21: + return "UserEvent11"; + case 22: + return "UserEvent12"; + case 23: + return "UserEvent13"; + case 24: + return "UserEvent14"; + case 25: + return "UserEvent15"; + default: + return "unknown"; + } + case 8: + return "DrawEvent"; + case 9: + return "KeyPressed_" + GetKeyBoardEvent(_nSubEvent); + case 10: + return "KeyReleased_" + GetKeyBoardEvent(_nSubEvent); + case 11: + return "Trigger"; + default: + return "unknown"; + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IFF.cs b/GMAC1098/GMAssetCompiler/IFF.cs new file mode 100644 index 0000000..8b24db8 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFF.cs @@ -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 m_chunks; + + public List m_patches; + + public List Strings + { + get; + private set; + } + + public Dictionary StringCheck + { + get; + private set; + } + + public List ExternalFiles + { + get; + set; + } + + public IFF() + { + m_chunks = new List(); + Strings = new List(); + StringCheck = new Dictionary(); + m_patches = new List(); + } + + 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(string _name, IFFChunkSaver _delegate, T _data, IFFChunkType _type) + { + IFFChunkHandler item = new IFFChunkHandler(_name, _delegate, _data, _type); + m_chunks.Add(item); + } + + public void RegisterChunk(string _name, IFFChunkSaver _delegate, T _data, IFFChunkType _type, int _align) + { + IFFChunkHandler item = new IFFChunkHandler(_name, _delegate, _data, _type, _align); + m_chunks.Add(item); + } + + public void RegisterChunk(string _name, IFFChunkSaver _delegate, T _data, IFFChunkType _type, int _align, int _offset) + { + IFFChunkHandler item = new IFFChunkHandler(_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 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(); + } + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IFFChunkHandler.cs b/GMAC1098/GMAssetCompiler/IFFChunkHandler.cs new file mode 100644 index 0000000..8919281 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFChunkHandler.cs @@ -0,0 +1,76 @@ +using System.IO; + +namespace GMAssetCompiler +{ + public class IFFChunkHandler : IIFFChunkHandler + { + private IFFChunkSaver 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 _saver, T _data, IFFChunkType _type) + : this(_name, _saver, _data, _type | IFFChunkType.Align, 4, 0) + { + } + + internal IFFChunkHandler(string _name, IFFChunkSaver _saver, T _data, IFFChunkType _type, int _align) + : this(_name, _saver, _data, _type | IFFChunkType.Align, _align, 0) + { + } + + internal IFFChunkHandler(string _name, IFFChunkSaver _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); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IFFChunkSaver.cs b/GMAC1098/GMAssetCompiler/IFFChunkSaver.cs new file mode 100644 index 0000000..f116411 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFChunkSaver.cs @@ -0,0 +1,6 @@ +using System.IO; + +namespace GMAssetCompiler +{ + public delegate void IFFChunkSaver(T _data, Stream _stream, IFF _iff); +} diff --git a/GMAC1098/GMAssetCompiler/IFFChunkType.cs b/GMAC1098/GMAssetCompiler/IFFChunkType.cs new file mode 100644 index 0000000..3c55d4c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFChunkType.cs @@ -0,0 +1,14 @@ +using System; + +namespace GMAssetCompiler +{ + [Flags] + public enum IFFChunkType + { + CPU = 0x1, + GPU = 0x2, + Audio = 0x4, + Align = 0x8, + Offset = 0x10 + } +} diff --git a/GMAC1098/GMAssetCompiler/IFFPatchEntry.cs b/GMAC1098/GMAssetCompiler/IFFPatchEntry.cs new file mode 100644 index 0000000..2655470 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFPatchEntry.cs @@ -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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IFFSaver.cs b/GMAC1098/GMAssetCompiler/IFFSaver.cs new file mode 100644 index 0000000..2f5459c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFSaver.cs @@ -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(KeyValuePair _kvp, Stream _s, IFF _iff, long _index); + + private delegate void WriteDelegate(T _t, Stream _s, IFF _iff, long _index); + + private const int WAD_VERSION_NUMBER = 6; + + private static TexturePage ms_tpageSprites; + + private static List ms_Waves; + + private static List ms_code; + + static IFFSaver() + { + ms_Waves = new List(20); + ms_code = new List(); + } + + public static void Save(GMAssets _assets, string _name) + { + ms_code.Clear(); + if (Program.RemoveDND) + { + _assets.RemoveDND(); + foreach (KeyValuePair 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 @object in _assets.Objects) + { + if (@object.Value != null) + { + foreach (IList> @event in @object.Value.Events) + { + foreach (KeyValuePair 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 timeLine in _assets.TimeLines) + { + if (timeLine.Value != null) + { + foreach (KeyValuePair 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 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 list = new List(); + 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 _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>)WriteStrings, (IList)iFF.Strings, IFFChunkType.CPU); + iFF.WriteChunks(_stream); + } + + private static void WriteDataKVP(IList> _data, Stream _s, IFF _iff, WriteDelegateKVP _del) + { + List list = new List(); + _s.WriteInteger(_data.Count); + for (int i = 0; i < _data.Count; i++) + { + list.Add(_s.Position); + _s.WriteInteger(0); + } + int num = 0; + foreach (KeyValuePair _datum in _data) + { + if (_datum.Value != null) + { + _del(_datum, _s, _iff, list[num]); + } + num++; + } + } + + private static void WriteDataList(IList _data, Stream _s, IFF _iff, WriteDelegate _del) + { + List list = new List(); + _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 constant in _data.Constants) + { + int value = 0; + if (GMLCompile.ms_ConstantCount.TryGetValue(constant.Key, out value) && value > 0) + { + num++; + } + } + _s.WriteInteger(num); + foreach (KeyValuePair 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 _data, Stream _s, IFF _iff) + { + } + + private static void WriteSounds(IList> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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 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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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 entry in value.Entries) + { + __s.WriteInteger(entry.Key); + __iff.AddPatch(__s, entry.Value); + } + foreach (KeyValuePair entry2 in value.Entries) + { + __iff.SetOffset(__s, entry2.Value, __s.Position); + WriteGMEvent(entry2.Value, __s, __iff); + } + }); + } + + private static void WriteObjects(IList> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _list, Stream ___s, IFF ___iff, long ___index) + { + ___s.PatchOffset(___index); + WriteDataList(_list, ___s, ___iff, delegate(KeyValuePair _entry, Stream ____s, IFF ____iff, long ____index) + { + ____s.PatchOffset(____index); + ____s.WriteInteger(_entry.Key); + WriteGMEvent(_entry.Value, ____s, ____iff); + }); + }); + }); + } + + private static void WriteRooms(IList> _data, Stream _s, IFF _iff) + { + WriteDataKVP(_data, _s, _iff, delegate(KeyValuePair _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> _data, Stream _s, IFF _iff) + { + foreach (KeyValuePair _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 list = new List(); + 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 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 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 _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); + }); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IFFString.cs b/GMAC1098/GMAssetCompiler/IFFString.cs new file mode 100644 index 0000000..8308fed --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IFFString.cs @@ -0,0 +1,16 @@ +namespace GMAssetCompiler +{ + public class IFFString + { + public string String + { + get; + private set; + } + + public IFFString(string _s) + { + String = _s; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/IIFFChunkHandler.cs b/GMAC1098/GMAssetCompiler/IIFFChunkHandler.cs new file mode 100644 index 0000000..7aa8d7e --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IIFFChunkHandler.cs @@ -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); + } +} diff --git a/GMAC1098/GMAssetCompiler/IMachineType.cs b/GMAC1098/GMAssetCompiler/IMachineType.cs new file mode 100644 index 0000000..b347948 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IMachineType.cs @@ -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); + } +} diff --git a/GMAC1098/GMAssetCompiler/IPropertyGrid.cs b/GMAC1098/GMAssetCompiler/IPropertyGrid.cs new file mode 100644 index 0000000..40339ac --- /dev/null +++ b/GMAC1098/GMAssetCompiler/IPropertyGrid.cs @@ -0,0 +1,12 @@ +using Flobbster.Windows.Forms; +using System.Drawing; + +namespace GMAssetCompiler +{ + public interface IPropertyGrid + { + PropertyBag Prepare(); + + Image PrepareImage(); + } +} diff --git a/GMAC1098/GMAssetCompiler/Lex.cs b/GMAC1098/GMAssetCompiler/Lex.cs new file mode 100644 index 0000000..c56853c --- /dev/null +++ b/GMAC1098/GMAssetCompiler/Lex.cs @@ -0,0 +1,1164 @@ +using System; +using System.Collections.Generic; + +namespace GMAssetCompiler +{ + public class Lex + { + private const int MAX_QUEUE = 100; + + private bool m_CaseSensitive; + + private string m_Text; + + private int m_Index; + + private eLex[] m_TokenLookup = new eLex[256]; + + private eLex[] m_IDLookup = new eLex[256]; + + private int[] m_HexLookup = new int[256]; + + private int[] m_BinLookup = new int[256]; + + private int[] m_DecLookup = new int[256]; + + private eLex[] m_SymbolLookup1 = new eLex[256]; + + private eLex[] m_SymbolLookup2 = new eLex[256]; + + private eLex[] m_LexToken = new eLex[100]; + + private string[] m_LexText = new string[100]; + + private double[] m_LexValue = new double[100]; + + private int m_Head; + + private int m_Tail; + + private YYObfuscate m_pObfuscate; + + private Dictionary m_CommandLookup; + + public string yyText + { + get + { + return m_LexText[m_Tail]; + } + } + + public double yyValue + { + get + { + return m_LexValue[m_Tail]; + } + } + + public eLex yyToken + { + get + { + return m_LexToken[m_Tail]; + } + } + + public string Text + { + get + { + return m_Text; + } + set + { + m_Text = value; + m_Index = 0; + m_Tail = 0; + m_Head = 0; + if (!CaseSensitive) + { + m_Text = m_Text.ToLower(); + } + } + } + + public bool CaseSensitive + { + get + { + return m_CaseSensitive; + } + set + { + m_CaseSensitive = value; + } + } + + public void AddSymbol(string _s, eLex _token) + { + m_SymbolLookup1[_s[0]] = m_TokenLookup[_s[0]]; + m_SymbolLookup2[_s[1]] = _token; + } + + public void AddCommand(string _cmd, eLex _token) + { + eLex value; + if (!m_CommandLookup.TryGetValue(_cmd, out value)) + { + m_CommandLookup.Add(_cmd, _token); + } + } + + public Lex(YYObfuscate _pObfuscate) + { + m_pObfuscate = _pObfuscate; + CaseSensitive = false; + m_TokenLookup[124] = eLex.Bar; + m_TokenLookup[63] = eLex.QuestionMark; + m_TokenLookup[33] = eLex.Exclamation; + m_TokenLookup[34] = eLex.Quotes; + m_TokenLookup[39] = eLex.SingleQuotes; + m_TokenLookup[36] = eLex.Dollar; + m_TokenLookup[37] = eLex.Percent; + m_TokenLookup[94] = eLex.Carrot; + m_TokenLookup[38] = eLex.Ampersand; + m_TokenLookup[42] = eLex.Star; + m_TokenLookup[40] = eLex.LeftBracket; + m_TokenLookup[41] = eLex.RightBracket; + m_TokenLookup[91] = eLex.LeftSquareBracket; + m_TokenLookup[93] = eLex.RightSquareBracket; + m_TokenLookup[45] = eLex.Minus; + m_TokenLookup[43] = eLex.Plus; + m_TokenLookup[61] = eLex.Equals; + m_TokenLookup[47] = eLex.Divide; + m_TokenLookup[44] = eLex.Comma; + m_TokenLookup[58] = eLex.Colon; + m_TokenLookup[59] = eLex.SemiColon; + m_TokenLookup[123] = eLex.LCB; + m_TokenLookup[125] = eLex.RCB; + m_TokenLookup[60] = eLex.LessThan; + m_TokenLookup[62] = eLex.GreaterThan; + m_TokenLookup[46] = eLex.Dot; + m_TokenLookup[126] = eLex.Not; + m_TokenLookup[49] = eLex.Decimal; + m_TokenLookup[50] = eLex.Decimal; + m_TokenLookup[51] = eLex.Decimal; + m_TokenLookup[52] = eLex.Decimal; + m_TokenLookup[53] = eLex.Decimal; + m_TokenLookup[54] = eLex.Decimal; + m_TokenLookup[55] = eLex.Decimal; + m_TokenLookup[56] = eLex.Decimal; + m_TokenLookup[57] = eLex.Decimal; + m_TokenLookup[48] = eLex.Decimal; + m_TokenLookup[10] = eLex.NewLine; + m_TokenLookup[13] = eLex.NewLine; + m_TokenLookup[9] = eLex.WhiteSpace; + m_TokenLookup[32] = eLex.WhiteSpace; + AddSymbol("==", eLex.EqualEqual); + AddSymbol("!=", eLex.NotEqual); + AddSymbol("&=", eLex.AndEqual); + AddSymbol("~=", eLex.EorEqual); + AddSymbol("-=", eLex.MinusEqual); + AddSymbol("+=", eLex.PlusEqual); + AddSymbol("^=", eLex.XorEqual); + AddSymbol("&&", eLex.AndAnd); + AddSymbol("||", eLex.OrOr); + AddSymbol("<<", eLex.ShiftLeft); + AddSymbol(">>", eLex.ShiftRight); + for (int i = 65; i <= 90; i++) + { + m_IDLookup[i] = eLex.ID; + } + for (int j = 97; j <= 122; j++) + { + m_IDLookup[j] = eLex.ID; + } + m_IDLookup[48] = eLex.ID; + m_IDLookup[49] = eLex.ID; + m_IDLookup[50] = eLex.ID; + m_IDLookup[51] = eLex.ID; + m_IDLookup[52] = eLex.ID; + m_IDLookup[53] = eLex.ID; + m_IDLookup[54] = eLex.ID; + m_IDLookup[55] = eLex.ID; + m_IDLookup[56] = eLex.ID; + m_IDLookup[57] = eLex.ID; + m_IDLookup[95] = eLex.ID; + m_IDLookup[64] = eLex.ID; + for (int num = m_HexLookup.Length - 1; num >= 0; num--) + { + m_HexLookup[num] = -1; + } + m_HexLookup[48] = 0; + m_HexLookup[49] = 1; + m_HexLookup[50] = 2; + m_HexLookup[51] = 3; + m_HexLookup[52] = 4; + m_HexLookup[53] = 5; + m_HexLookup[54] = 6; + m_HexLookup[55] = 7; + m_HexLookup[56] = 8; + m_HexLookup[57] = 9; + m_HexLookup[65] = 10; + m_HexLookup[66] = 11; + m_HexLookup[67] = 12; + m_HexLookup[68] = 13; + m_HexLookup[69] = 14; + m_HexLookup[70] = 15; + m_HexLookup[97] = 10; + m_HexLookup[98] = 11; + m_HexLookup[99] = 12; + m_HexLookup[100] = 13; + m_HexLookup[101] = 14; + m_HexLookup[102] = 15; + for (int num2 = m_BinLookup.Length - 1; num2 >= 0; num2--) + { + m_BinLookup[num2] = -1; + } + m_BinLookup[48] = 0; + m_BinLookup[49] = 1; + for (int num3 = m_DecLookup.Length - 1; num3 >= 0; num3--) + { + m_DecLookup[num3] = -1; + } + m_DecLookup[48] = 0; + m_DecLookup[49] = 1; + m_DecLookup[50] = 2; + m_DecLookup[51] = 3; + m_DecLookup[52] = 4; + m_DecLookup[53] = 5; + m_DecLookup[54] = 6; + m_DecLookup[55] = 7; + m_DecLookup[56] = 8; + m_DecLookup[57] = 9; + m_CommandLookup = new Dictionary(); + AddCommand("Object", eLex.reserved); + AddCommand("Function", eLex.reserved); + AddCommand("defineProperty", eLex.reserved); + AddCommand("apply", eLex.reserved); + AddCommand("call", eLex.reserved); + AddCommand("__defineGetter__", eLex.reserved); + AddCommand("__defineSetter__", eLex.reserved); + AddCommand("__implements", eLex.reserved); + AddCommand("__super", eLex.reserved); + AddCommand("function", eLex.reserved2); + AddCommand("return", eLex.reserved2); + AddCommand("typeof", eLex.reserved2); + AddCommand("instanceof", eLex.reserved3); + AddCommand("continue", eLex.reserved); + AddCommand("for", eLex.reserved); + AddCommand("this", eLex.reserved); + AddCommand("var", eLex.reserved2); + AddCommand("true", eLex.reserved); + AddCommand("false", eLex.reserved); + AddCommand("null", eLex.reserved); + AddCommand("new", eLex.reserved2); + AddCommand("delete", eLex.reserved2); + AddCommand("with", eLex.reserved); + AddCommand("if", eLex.reserved2); + AddCommand("else", eLex.reserved2); + AddCommand("switch", eLex.reserved2); + AddCommand("case", eLex.reserved2); + AddCommand("default", eLex.reserved2); + AddCommand("break", eLex.reserved); + AddCommand("try", eLex.reserved); + AddCommand("catch", eLex.reserved); + AddCommand("throw", eLex.reserved2); + AddCommand("toString", eLex.reserved); + AddCommand("valueOf", eLex.reserved); + AddCommand("prototype", eLex.reserved); + AddCommand("constructor", eLex.reserved); + AddCommand("undefined", eLex.reserved); + AddCommand("in", eLex.reserved3); + AddCommand("do", eLex.reserved2); + AddCommand("while", eLex.reserved2); + AddCommand("arguments", eLex.reserved); + AddCommand("length", eLex.reserved); + AddCommand("versionSearch", eLex.reserved); + AddCommand("identity", eLex.reserved); + AddCommand("prop", eLex.reserved); + AddCommand("versionSearchString", eLex.reserved); + AddCommand("appVersion", eLex.reserved); + AddCommand("userAgent", eLex.reserved); + AddCommand("vendor", eLex.reserved); + AddCommand("platform", eLex.reserved); + AddCommand("substring", eLex.reserved); + AddCommand("searchString", eLex.reserved); + AddCommand("localStorage", eLex.reserved); + AddCommand("hasOwnProperty", eLex.reserved); + AddCommand("g_GameMakerHTML5Dir", eLex.reserved); + AddCommand("facebookUI", eLex.reserved); + AddCommand("g_fbAppHomeUrl", eLex.reserved); + AddCommand("g_fbAppId", eLex.reserved); + AddCommand("g_fbAppUrl", eLex.reserved); + AddCommand("g_fbOAuthToken", eLex.reserved); + AddCommand("navigator", eLex.reserved); + AddCommand("browser", eLex.reserved); + AddCommand("dataBrowser", eLex.reserved); + AddCommand("version", eLex.reserved); + AddCommand("searchVersion", eLex.reserved); + AddCommand("dataOS", eLex.reserved); + AddCommand("protocol", eLex.reserved); + AddCommand("host", eLex.reserved); + AddCommand("pathname", eLex.reserved); + AddCommand("location", eLex.reserved); + AddCommand("send", eLex.reserved); + AddCommand("status", eLex.reserved); + AddCommand("shiftKey", eLex.reserved); + AddCommand("char", eLex.reserved); + AddCommand("repeat", eLex.reserved); + AddCommand("elementFromPoint", eLex.reserved); + AddCommand("opera", eLex.reserved); + AddCommand("write", eLex.reserved); + AddCommand("open", eLex.reserved); + AddCommand("XMLHttpRequest", eLex.reserved); + AddCommand("ActiveXObject", eLex.reserved); + AddCommand("setRequestHeader", eLex.reserved); + AddCommand("responseText", eLex.reserved); + AddCommand("XDomainRequest", eLex.reserved); + AddCommand("status", eLex.reserved); + AddCommand("ontimeout", eLex.reserved); + AddCommand("onload", eLex.reserved); + AddCommand("send", eLex.reserved); + AddCommand("onreadystatechange", eLex.reserved); + AddCommand("onerror", eLex.reserved); + AddCommand("Math", eLex.reserved); + AddCommand("Array", eLex.reserved); + AddCommand("Date", eLex.reserved); + AddCommand("window", eLex.reserved); + AddCommand("document", eLex.reserved); + AddCommand("Boolean", eLex.reserved); + AddCommand("Number", eLex.reserved); + AddCommand("domain", eLex.reserved); + AddCommand("MAX_VALUE", eLex.reserved); + AddCommand("MIN_VALUE", eLex.reserved); + AddCommand("POSITIVE_INFINITY", eLex.reserved); + AddCommand("NEGATIVE_INFINITY", eLex.reserved); + AddCommand("toExponential", eLex.reserved); + AddCommand("toPrecision", eLex.reserved); + AddCommand("toFixed", eLex.reserved); + AddCommand("charAt", eLex.reserved); + AddCommand("charCodeAt", eLex.reserved); + AddCommand("fromCharCode", eLex.reserved); + AddCommand("indexOf", eLex.reserved); + AddCommand("lastIndexOf", eLex.reserved); + AddCommand("match", eLex.reserved); + AddCommand("replace", eLex.reserved); + AddCommand("search", eLex.reserved); + AddCommand("split", eLex.reserved); + AddCommand("substr", eLex.reserved); + AddCommand("substring", eLex.reserved); + AddCommand("toLowerCase", eLex.reserved); + AddCommand("toUpperCase", eLex.reserved); + AddCommand("anchor", eLex.reserved); + AddCommand("big", eLex.reserved); + AddCommand("blink", eLex.reserved); + AddCommand("bold", eLex.reserved); + AddCommand("fixed", eLex.reserved); + AddCommand("fontcolor", eLex.reserved); + AddCommand("fontsize", eLex.reserved); + AddCommand("italics", eLex.reserved); + AddCommand("link", eLex.reserved); + AddCommand("small", eLex.reserved); + AddCommand("strike", eLex.reserved); + AddCommand("sub", eLex.reserved); + AddCommand("sup", eLex.reserved); + AddCommand("Infinity", eLex.reserved); + AddCommand("NaN", eLex.reserved); + AddCommand("decodeURI", eLex.reserved); + AddCommand("decodeURIComponent", eLex.reserved); + AddCommand("encodeURI", eLex.reserved); + AddCommand("encodeURIComponent", eLex.reserved); + AddCommand("escape", eLex.reserved); + AddCommand("eval", eLex.reserved); + AddCommand("sFinite", eLex.reserved); + AddCommand("isNaN", eLex.reserved); + AddCommand("prompt", eLex.reserved); + AddCommand("parseFloat", eLex.reserved); + AddCommand("parseInt", eLex.reserved); + AddCommand("String", eLex.reserved); + AddCommand("unescape", eLex.reserved); + AddCommand("setInterval", eLex.reserved); + AddCommand("JSON", eLex.reserved); + AddCommand("stringify", eLex.reserved); + AddCommand("global", eLex.reserved); + AddCommand("ignoreCase", eLex.reserved); + AddCommand("lastIndex", eLex.reserved); + AddCommand("multiline", eLex.reserved); + AddCommand("source", eLex.reserved); + AddCommand("compile", eLex.reserved); + AddCommand("exec", eLex.reserved); + AddCommand("test", eLex.reserved); + AddCommand("href ", eLex.reserved); + AddCommand("button", eLex.reserved); + AddCommand("pageX", eLex.reserved); + AddCommand("pageY", eLex.reserved); + AddCommand("splice", eLex.reserved); + AddCommand("sort", eLex.reserved); + AddCommand("concat", eLex.reserved); + AddCommand("join", eLex.reserved); + AddCommand("pop", eLex.reserved); + AddCommand("push", eLex.reserved); + AddCommand("reverse", eLex.reserved); + AddCommand("shift", eLex.reserved); + AddCommand("slice", eLex.reserved); + AddCommand("nshift", eLex.reserved); + AddCommand("random", eLex.reserved); + AddCommand("round", eLex.reserved); + AddCommand("LN2", eLex.reserved); + AddCommand("LN10", eLex.reserved); + AddCommand("LOG2E", eLex.reserved); + AddCommand("PI", eLex.reserved); + AddCommand("SQRT1_2", eLex.reserved); + AddCommand("SQRT2", eLex.reserved); + AddCommand("abs", eLex.reserved); + AddCommand("acos", eLex.reserved); + AddCommand("asin", eLex.reserved); + AddCommand("atan", eLex.reserved); + AddCommand("atan2", eLex.reserved); + AddCommand("ceil", eLex.reserved); + AddCommand("cos", eLex.reserved); + AddCommand("exp", eLex.reserved); + AddCommand("floor", eLex.reserved); + AddCommand("log", eLex.reserved); + AddCommand("max", eLex.reserved); + AddCommand("min", eLex.reserved); + AddCommand("pow", eLex.reserved); + AddCommand("sin", eLex.reserved); + AddCommand("sqrt", eLex.reserved); + AddCommand("tan", eLex.reserved); + AddCommand("getDate", eLex.reserved); + AddCommand("getDay", eLex.reserved); + AddCommand("getFullYear", eLex.reserved); + AddCommand("getHours", eLex.reserved); + AddCommand("getMilliseconds", eLex.reserved); + AddCommand("getMinutes", eLex.reserved); + AddCommand("getMonth", eLex.reserved); + AddCommand("getSeconds", eLex.reserved); + AddCommand("getTime", eLex.reserved); + AddCommand("getTimezoneOffset", eLex.reserved); + AddCommand("getUTCDate", eLex.reserved); + AddCommand("getUTCDay", eLex.reserved); + AddCommand("getUTCFullYear", eLex.reserved); + AddCommand("getUTCHours", eLex.reserved); + AddCommand("getUTCMilliseconds", eLex.reserved); + AddCommand("getUTCMinutes", eLex.reserved); + AddCommand("getUTCMonth", eLex.reserved); + AddCommand("getUTCSeconds", eLex.reserved); + AddCommand("parse", eLex.reserved); + AddCommand("setDate", eLex.reserved); + AddCommand("setFullYear", eLex.reserved); + AddCommand("setHours", eLex.reserved); + AddCommand("setMilliseconds", eLex.reserved); + AddCommand("setMinutes", eLex.reserved); + AddCommand("setMonth", eLex.reserved); + AddCommand("setSeconds", eLex.reserved); + AddCommand("setTime", eLex.reserved); + AddCommand("setUTCDate", eLex.reserved); + AddCommand("setUTCFullYear", eLex.reserved); + AddCommand("setUTCHours", eLex.reserved); + AddCommand("setUTCMilliseconds", eLex.reserved); + AddCommand("setUTCMinutes", eLex.reserved); + AddCommand("setUTCMonth", eLex.reserved); + AddCommand("setUTCSeconds", eLex.reserved); + AddCommand("toDateString", eLex.reserved); + AddCommand("toLocaleDateString", eLex.reserved); + AddCommand("toLocaleTimeString", eLex.reserved); + AddCommand("toLocaleString", eLex.reserved); + AddCommand("toTimeString", eLex.reserved); + AddCommand("toUTCString", eLex.reserved); + AddCommand("UTC", eLex.reserved); + AddCommand("toDataURL", eLex.reserved); + AddCommand("ontouchstart", eLex.reserved); + AddCommand("ontouchmove", eLex.reserved); + AddCommand("ontouchend", eLex.reserved); + AddCommand("ontouchcancel", eLex.reserved); + AddCommand("requestAnimationFrame", eLex.reserved); + AddCommand("webkitRequestAnimationFrame", eLex.reserved); + AddCommand("mozRequestAnimationFrame", eLex.reserved); + AddCommand("oRequestAnimationFrame", eLex.reserved); + AddCommand("msRequestAnimationFrame", eLex.reserved); + AddCommand("setTimeout", eLex.reserved); + AddCommand("onload", eLex.reserved); + AddCommand("onerror", eLex.reserved); + AddCommand("requestAnimFrame", eLex.reserved); + AddCommand("innerWidth", eLex.reserved); + AddCommand("innerHeight", eLex.reserved); + AddCommand("console", eLex.reserved); + AddCommand("which", eLex.reserved); + AddCommand("Image", eLex.reserved); + AddCommand("naturalWidth", eLex.reserved); + AddCommand("naturalHeight", eLex.reserved); + AddCommand("complete", eLex.reserved); + AddCommand("crossOrigin", eLex.reserved); + AddCommand("isMap", eLex.reserved); + AddCommand("alt", eLex.reserved); + AddCommand("src", eLex.reserved); + AddCommand("img", eLex.reserved); + AddCommand("ismap", eLex.reserved); + AddCommand("usemap", eLex.reserved); + AddCommand("title", eLex.reserved); + AddCommand("figure", eLex.reserved); + AddCommand("meta", eLex.reserved); + AddCommand("name", eLex.reserved); + AddCommand("generator", eLex.reserved); + AddCommand("data", eLex.reserved); + AddCommand("mageData", eLex.reserved); + AddCommand("context", eLex.reserved); + AddCommand("putImageData", eLex.reserved); + AddCommand("srcElement", eLex.reserved); + AddCommand("currentTarget", eLex.reserved); + AddCommand("cursor", eLex.reserved); + AddCommand("getElementById", eLex.reserved); + AddCommand("appendChild", eLex.reserved); + AddCommand("body", eLex.reserved); + AddCommand("documentElement", eLex.reserved); + AddCommand("clientWidth", eLex.reserved); + AddCommand("clientHeight", eLex.reserved); + AddCommand("getElementsByTagName", eLex.reserved); + AddCommand("getAttribute", eLex.reserved); + AddCommand("target", eLex.reserved); + AddCommand("createEvent", eLex.reserved); + AddCommand("initMouseEvent", eLex.reserved); + AddCommand("dispatchEvent", eLex.reserved); + AddCommand("event", eLex.reserved); + AddCommand("preventDefault", eLex.reserved); + AddCommand("type", eLex.reserved); + AddCommand("changedTouches", eLex.reserved); + AddCommand("screenX", eLex.reserved); + AddCommand("screenY", eLex.reserved); + AddCommand("clientX", eLex.reserved); + AddCommand("clientY", eLex.reserved); + AddCommand("addEventListener", eLex.reserved); + AddCommand("removeEventListener", eLex.reserved); + AddCommand("createElement", eLex.reserved); + AddCommand("onmousemove", eLex.reserved); + AddCommand("onmousedown", eLex.reserved); + AddCommand("onmouseup", eLex.reserved); + AddCommand("onkeydown", eLex.reserved); + AddCommand("onkeyup", eLex.reserved); + AddCommand("onfocusin", eLex.reserved); + AddCommand("onfocusout", eLex.reserved); + AddCommand("style", eLex.reserved); + AddCommand("display", eLex.reserved); + AddCommand("insertBefore", eLex.reserved); + AddCommand("parent", eLex.reserved); + AddCommand("parentNode", eLex.reserved); + AddCommand("removeChild", eLex.reserved); + AddCommand("frames", eLex.reserved); + AddCommand("focus", eLex.reserved); + AddCommand("oncontextmenu", eLex.reserved); + AddCommand("now", eLex.reserved); + AddCommand("visibility", eLex.reserved); + AddCommand("textLength", eLex.reserved); + AddCommand("setSelectionRange", eLex.reserved); + AddCommand("alert", eLex.reserved); + AddCommand("value", eLex.reserved); + AddCommand("confirm", eLex.reserved); + AddCommand("nextSibling", eLex.reserved); + AddCommand("contentWindow", eLex.reserved); + AddCommand("mozImageSmoothingEnabled", eLex.reserved); + AddCommand("globalAlpha", eLex.reserved); + AddCommand("strokeStyle", eLex.reserved); + AddCommand("fillStyle", eLex.reserved); + AddCommand("lineStyle", eLex.reserved); + AddCommand("fillRect", eLex.reserved); + AddCommand("strokeRect", eLex.reserved); + AddCommand("getContext", eLex.reserved); + AddCommand("width", eLex.reserved); + AddCommand("height", eLex.reserved); + AddCommand("offsetLeft", eLex.reserved); + AddCommand("offsetTop", eLex.reserved); + AddCommand("offsetParent", eLex.reserved); + AddCommand("drawImage", eLex.reserved); + AddCommand("left", eLex.reserved); + AddCommand("position", eLex.reserved); + AddCommand("beginPath", eLex.reserved); + AddCommand("arc", eLex.reserved); + AddCommand("fill", eLex.reserved); + AddCommand("lineWidth", eLex.reserved); + AddCommand("moveTo", eLex.reserved); + AddCommand("lineTo", eLex.reserved); + AddCommand("stroke", eLex.reserved); + AddCommand("closePath", eLex.reserved); + AddCommand("setTransform", eLex.reserved); + AddCommand("save", eLex.reserved); + AddCommand("restore", eLex.reserved); + AddCommand("rect", eLex.reserved); + AddCommand("transform", eLex.reserved); + AddCommand("clip", eLex.reserved); + AddCommand("top", eLex.reserved); + AddCommand("hanging", eLex.reserved); + AddCommand("middle", eLex.reserved); + AddCommand("alphabetic", eLex.reserved); + AddCommand("ideographic", eLex.reserved); + AddCommand("bottom", eLex.reserved); + AddCommand("fillText", eLex.reserved); + AddCommand("strokeText", eLex.reserved); + AddCommand("font", eLex.reserved); + AddCommand("textAlign", eLex.reserved); + AddCommand("textBaseline", eLex.reserved); + AddCommand("measureText", eLex.reserved); + AddCommand("HTMLVideoElement", eLex.reserved); + AddCommand("HTMLCanvasElement", eLex.reserved); + AddCommand("HTMLImageElement", eLex.reserved); + AddCommand("video", eLex.reserved); + AddCommand("readyState", eLex.reserved); + AddCommand("onreadystatechange", eLex.reserved); + AddCommand("CanvasPixelArray", eLex.reserved); + AddCommand("shadowColor", eLex.reserved); + AddCommand("shadowOffsetX", eLex.reserved); + AddCommand("shadowOffsetY", eLex.reserved); + AddCommand("shadowBlur", eLex.reserved); + AddCommand("quadraticCurveTo", eLex.reserved); + AddCommand("bezierCurveTo", eLex.reserved); + AddCommand("arcTo", eLex.reserved); + AddCommand("drawSystemFocusRing", eLex.reserved); + AddCommand("drawCustomFocusRing", eLex.reserved); + AddCommand("scrollPathIntoView", eLex.reserved); + AddCommand("isPointInPath", eLex.reserved); + AddCommand("lineCap", eLex.reserved); + AddCommand("lineJoin", eLex.reserved); + AddCommand("miterLimit", eLex.reserved); + AddCommand("globalCompositeOperation", eLex.reserved); + AddCommand("CanvasGradient", eLex.reserved); + AddCommand("CanvasPattern", eLex.reserved); + AddCommand("TextMetrics", eLex.reserved); + AddCommand("addColorStop", eLex.reserved); + AddCommand("createLinearGradient", eLex.reserved); + AddCommand("createRadialGradient", eLex.reserved); + AddCommand("createPattern", eLex.reserved); + AddCommand("toBlob", eLex.reserved); + AddCommand("setAttribute", eLex.reserved); + AddCommand("scale", eLex.reserved); + AddCommand("rotate", eLex.reserved); + AddCommand("translate", eLex.reserved); + AddCommand("clearRect", eLex.reserved); + AddCommand("getImageData", eLex.reserved); + AddCommand("createImageData", eLex.reserved); + AddCommand("getter", eLex.reserved); + AddCommand("setter", eLex.reserved); + AddCommand("Audio", eLex.reserved); + AddCommand("controls", eLex.reserved); + AddCommand("src", eLex.reserved); + AddCommand("load", eLex.reserved); + AddCommand("autobuffer", eLex.reserved); + AddCommand("loop", eLex.reserved); + AddCommand("preload", eLex.reserved); + AddCommand("play", eLex.reserved); + AddCommand("pause", eLex.reserved); + AddCommand("currentTime", eLex.reserved); + AddCommand("volume", eLex.reserved); + AddCommand("cloneNode", eLex.reserved); + AddCommand("canplaythrough", eLex.reserved); + AddCommand("error", eLex.reserved); + AddCommand("onloaddata", eLex.reserved); + AddCommand("canplay", eLex.reserved); + AddCommand("canPlayType", eLex.reserved); + AddCommand("viewportWidth", eLex.reserved); + AddCommand("viewportHeight", eLex.reserved); + AddCommand("createShader", eLex.reserved); + AddCommand("getError", eLex.reserved); + AddCommand("compileShader", eLex.reserved); + AddCommand("shaderSource", eLex.reserved); + AddCommand("getShaderParameter", eLex.reserved); + AddCommand("attachShader", eLex.reserved); + AddCommand("VERTEX_SHADER", eLex.reserved); + AddCommand("FRAGMENT_SHADER", eLex.reserved); + AddCommand("getShaderInfoLog", eLex.reserved); + AddCommand("COMPILE_STATUS", eLex.reserved); + AddCommand("createProgram", eLex.reserved); + AddCommand("getProgramParameter", eLex.reserved); + AddCommand("LINK_STATUS", eLex.reserved); + AddCommand("useProgram", eLex.reserved); + AddCommand("getUniformLocation", eLex.reserved); + AddCommand("getAttribLocation", eLex.reserved); + AddCommand("disable", eLex.reserved); + AddCommand("CULL_FACE", eLex.reserved); + AddCommand("createTexture", eLex.reserved); + AddCommand("bindTexture", eLex.reserved); + AddCommand("pixelStorei", eLex.reserved); + AddCommand("TEXTURE_2D", eLex.reserved); + AddCommand("UNPACK_WEBGL", eLex.reserved); + AddCommand("RGBA", eLex.reserved); + AddCommand("UNSIGNED_BYTE", eLex.reserved); + AddCommand("TEXTURE_MAG_FILTER", eLex.reserved); + AddCommand("TEXTURE_MIN_FILTER", eLex.reserved); + AddCommand("NEAREST", eLex.reserved); + AddCommand("LINEAR", eLex.reserved); + AddCommand("TEXTURE_WRAP_S", eLex.reserved); + AddCommand("TEXTURE_WRAP_T", eLex.reserved); + AddCommand("CLAMP_TO_EDGE", eLex.reserved); + AddCommand("COLOR_BUFFER_BIT", eLex.reserved); + AddCommand("DEPTH_BUFFER_BIT", eLex.reserved); + AddCommand("vertexAttribPointer", eLex.reserved); + AddCommand("enableVertexAttribArray", eLex.reserved); + AddCommand("bindBuffer", eLex.reserved); + AddCommand("ARRAY_BUFFER", eLex.reserved); + AddCommand("SHORT", eLex.reserved); + AddCommand("BYTE", eLex.reserved); + AddCommand("UNSIGNED_BYTE", eLex.reserved); + AddCommand("FIXED", eLex.reserved); + AddCommand("FLOAT", eLex.reserved); + AddCommand("UNSIGNED_SHORT", eLex.reserved); + AddCommand("uniform2f", eLex.reserved); + AddCommand("uniform1i", eLex.reserved); + AddCommand("activeTexture", eLex.reserved); + AddCommand("clear", eLex.reserved); + AddCommand("clearColor", eLex.reserved); + AddCommand("uniformMatrix4fv", eLex.reserved); + AddCommand("linkProgram", eLex.reserved); + AddCommand("Int16Array", eLex.reserved); + AddCommand("Int32Array", eLex.reserved); + AddCommand("DYNAMIC_DRAW", eLex.reserved); + AddCommand("Float32Array", eLex.reserved); + AddCommand("texImage2D", eLex.reserved); + AddCommand("createBuffer", eLex.reserved); + AddCommand("texParameteri", eLex.reserved); + AddCommand("bufferData", eLex.reserved); + AddCommand("bufferSubData", eLex.reserved); + AddCommand("enable", eLex.reserved); + AddCommand("drawArrays", eLex.reserved); + AddCommand("blendFunc", eLex.reserved); + AddCommand("SRC_ALPHA", eLex.reserved); + AddCommand("ONE_MINUS_SRC_ALPHA", eLex.reserved); + AddCommand("BLEND", eLex.reserved); + AddCommand("blendFuncSeparate", eLex.reserved); + AddCommand("ONE", eLex.reserved); + AddCommand("ZERO", eLex.reserved); + AddCommand("TEXTURE0", eLex.reserved); + AddCommand("TEXTURE1", eLex.reserved); + AddCommand("viewport", eLex.reserved); + AddCommand("bindFramebuffer", eLex.reserved); + AddCommand("createFramebuffer", eLex.reserved); + AddCommand("createRenderbuffer", eLex.reserved); + AddCommand("bindRenderbuffer", eLex.reserved); + AddCommand("renderbufferStorage", eLex.reserved); + AddCommand("framebufferRenderbuffer", eLex.reserved); + AddCommand("bindFramebuffer", eLex.reserved); + AddCommand("framebufferTexture2D", eLex.reserved); + AddCommand("deleteFramebuffer", eLex.reserved); + AddCommand("deleteRenderbuffer", eLex.reserved); + AddCommand("deleteTexture", eLex.reserved); + AddCommand("readPixels", eLex.reserved); + AddCommand("Uint8Array", eLex.reserved); + AddCommand("FRAMEBUFFER", eLex.reserved); + AddCommand("RENDERBUFFER", eLex.reserved); + AddCommand("DEPTH_COMPONENT16", eLex.reserved); + AddCommand("COLOR_ATTACHMENT0", eLex.reserved); + AddCommand("colorMask", eLex.reserved); + AddCommand("TRIANGLES", eLex.reserved); + AddCommand("POINTS", eLex.reserved); + AddCommand("LINE_STRIP", eLex.reserved); + AddCommand("LINE_LOOP", eLex.reserved); + AddCommand("TRIANGLE_STRIP", eLex.reserved); + AddCommand("TRIANGLE_FAN", eLex.reserved); + AddCommand("LINES", eLex.reserved); + AddCommand("POINT", eLex.reserved); + AddCommand("aa_1241_kz", eLex.reserved); + } + + public eLex CheckToken(string _text) + { + eLex value; + if (m_CommandLookup.TryGetValue(_text, out value)) + { + return value; + } + return eLex.None; + } + + public void Push() + { + m_Tail--; + if (m_Tail < 0) + { + m_Tail = 99; + } + } + + public void EnqueueLex(eLex _token, string _text, double _value) + { + m_Head++; + if (m_Head == 100) + { + m_Head = 0; + } + m_Tail++; + if (m_Tail == 100) + { + m_Tail = 0; + } + m_LexToken[m_Head] = _token; + m_LexText[m_Head] = _text; + m_LexValue[m_Head] = _value; + } + + public char NextChar() + { + if (m_Index >= m_Text.Length) + { + return ' '; + } + return m_Text[m_Index++]; + } + + private eLex ReadID() + { + int num = m_Index - 1; + while (m_Index < m_Text.Length) + { + char c = NextChar(); + if (m_IDLookup[c] != eLex.ID) + { + m_Index--; + break; + } + } + int index = m_Index; + string text = m_Text.Substring(num, index - num); + eLex value; + if (m_CommandLookup.TryGetValue(text, out value)) + { + EnqueueLex(value, text, 0.0); + return value; + } + EnqueueLex(eLex.ID, text, 0.0); + return eLex.ID; + } + + private eLex ReadHEX() + { + int index = m_Index; + m_Index += 2; + long num = 0L; + while (m_Index < m_Text.Length) + { + char c = NextChar(); + int num2 = m_HexLookup[c]; + if (num2 == -1) + { + m_Index--; + break; + } + num = (num << 4) + num2; + } + int index2 = m_Index; + string text = m_Text.Substring(index, index2 - index); + EnqueueLex(eLex.Decimal, text, num); + return eLex.Decimal; + } + + private eLex ReadBIN() + { + int num = m_Index - 1; + long num2 = 0L; + while (m_Index < m_Text.Length) + { + char c = NextChar(); + int num3 = m_BinLookup[c]; + if (num3 == -1) + { + m_Index--; + break; + } + num2 = (num2 << 1) + num3; + } + int index = m_Index; + string text = m_Text.Substring(num, index - num); + EnqueueLex(eLex.Decimal, text, num2); + return eLex.Decimal; + } + + private eLex ReadString1() + { + if (!m_pObfuscate.EncodeStrings) + { + int num = m_Index - 1; + long num2 = 0L; + while (m_Index < m_Text.Length) + { + switch (NextChar()) + { + case '\\': + { + char c = NextChar(); + continue; + } + default: + continue; + case '"': + break; + } + break; + } + int index = m_Index; + string text = m_Text.Substring(num, index - num); + EnqueueLex(eLex.String, text, num2); + return eLex.String; + } + long num3 = 0L; + char c2; + string text2; + for (text2 = "\""; m_Index < m_Text.Length; text2 += c2) + { + c2 = NextChar(); + switch (c2) + { + case '\\': + c2 = NextChar(); + continue; + default: + continue; + case '"': + break; + } + break; + } + text2 += "\""; + EnqueueLex(eLex.String, text2, num3); + return eLex.String; + } + + private eLex ReadString2() + { + if (!m_pObfuscate.EncodeStrings) + { + int num = m_Index - 1; + long num2 = 0L; + while (m_Index < m_Text.Length) + { + switch (NextChar()) + { + case '\\': + { + char c = NextChar(); + continue; + } + default: + continue; + case '\'': + break; + } + break; + } + int index = m_Index; + string text = m_Text.Substring(num, index - num); + EnqueueLex(eLex.String, text, num2); + return eLex.String; + } + long num3 = 0L; + char c2; + string text2; + for (text2 = "\""; m_Index < m_Text.Length; text2 += c2) + { + c2 = NextChar(); + switch (c2) + { + case '\\': + c2 = NextChar(); + continue; + default: + continue; + case '\'': + break; + } + break; + } + text2 += "\""; + EnqueueLex(eLex.String, text2, num3); + return eLex.String; + } + + private eLex ReadDec() + { + m_Index--; + if (m_Index + 3 < m_Text.Length && m_Text[m_Index] == '0' && (m_Text[m_Index + 1] == 'x' || m_Text[m_Index + 2] == 'X')) + { + return ReadHEX(); + } + if (m_Index + 2 < m_Text.Length && m_Text[m_Index] == '1' && (m_Text[m_Index + 1] == 'e' || m_Text[m_Index + 1] == 'E') && (m_Text[m_Index + 2] == '+' || m_Text[m_Index + 2] == '-')) + { + string text = string.Format("{0}{1}{2}", m_Text[m_Index], m_Text[m_Index + 1], m_Text[m_Index + 2]); + m_Index += 3; + while (m_Index < m_Text.Length) + { + char c = NextChar(); + int num = m_DecLookup[c]; + if (num == -1) + { + m_Index--; + break; + } + text += c; + } + text = text.ToLower(); + double value = Convert.ToDouble(text); + EnqueueLex(eLex.Decimal, text, value); + return eLex.Decimal; + } + int index = m_Index; + long num2 = 0L; + while (m_Index < m_Text.Length) + { + char c2 = NextChar(); + int num3 = m_DecLookup[c2]; + if (num3 == -1) + { + m_Index--; + break; + } + num2 = num2 * 10 + num3; + } + int index2 = m_Index; + string text2 = m_Text.Substring(index, index2 - index); + EnqueueLex(eLex.Decimal, text2, num2); + return eLex.Decimal; + } + + private eLex CheckForComments() + { + m_Index--; + if (m_Index < m_Text.Length) + { + char c = NextChar(); + char c2 = NextChar(); + eLex eLex = m_TokenLookup[c]; + eLex eLex2 = m_TokenLookup[c2]; + if (eLex == eLex.Divide && eLex2 == eLex.Divide) + { + while (m_Index < m_Text.Length) + { + c = NextChar(); + eLex = eLex.ID; + if (c >= '\0' && c <= 'ÿ') + { + eLex = m_TokenLookup[c]; + } + if (eLex == eLex.EOF || eLex == eLex.NewLine) + { + c = NextChar(); + if (eLex != eLex.EOF && eLex != eLex.NewLine) + { + m_Index--; + } + break; + } + } + return eLex.Comment; + } + if (eLex == eLex.Divide && eLex2 == eLex.Star) + { + int num = 1; + while (m_Index < m_Text.Length) + { + c = NextChar(); + c2 = NextChar(); + eLex = eLex.ID; + eLex2 = eLex.ID; + if (c >= '\0' && c <= 'ÿ') + { + eLex = m_TokenLookup[c]; + } + if (c2 >= '\0' && c2 <= 'ÿ') + { + eLex2 = m_TokenLookup[c2]; + } + if (eLex == eLex.Divide && eLex2 == eLex.Star) + { + num++; + } + if (eLex == eLex.Star && eLex2 == eLex.Divide) + { + num--; + if (num == 0) + { + break; + } + } + m_Index--; + } + return eLex.Comment; + } + m_Index--; + EnqueueLex(eLex.Divide, "/", 0.0); + return eLex.Divide; + } + return GMAssetCompiler.eLex.Divide; + } + + public eLex MultiReadToken(char _c, eLex _token) + { + if (m_Index < m_Text.Length) + { + char c = NextChar(); + eLex eLex = m_SymbolLookup2[c]; + if (eLex != 0) + { + EnqueueLex(eLex, new string(new char[2] + { + _c, + c + }), 0.0); + return eLex; + } + m_Index--; + } + EnqueueLex(_token, new string(new char[1] + { + _c + }), 0.0); + return _token; + } + + public eLex yylex() + { + if (m_Tail != m_Head) + { + m_Tail++; + if (m_Tail == 100) + { + m_Tail = 0; + } + return m_LexToken[m_Tail]; + } + while (m_Index < m_Text.Length) + { + char c = NextChar(); + eLex eLex = eLex.ID; + if (c >= '\0' && c <= 'ÿ') + { + eLex = m_TokenLookup[c]; + } + switch (eLex) + { + case eLex.WhiteSpace: + continue; + case eLex.Divide: + return CheckForComments(); + case eLex.None: + return ReadID(); + case eLex.Quotes: + return ReadString1(); + case eLex.SingleQuotes: + return ReadString2(); + case eLex.Decimal: + return ReadDec(); + } + if (m_SymbolLookup1[c] != 0) + { + return MultiReadToken(c, eLex); + } + EnqueueLex(eLex, new string(new char[1] + { + c + }), 0.0); + return eLex; + } + EnqueueLex(GMAssetCompiler.eLex.EOF, null, 0.0); + return GMAssetCompiler.eLex.EOF; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/LexTree.cs b/GMAC1098/GMAssetCompiler/LexTree.cs new file mode 100644 index 0000000..2ba4a41 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/LexTree.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; + +namespace GMAssetCompiler +{ + public class LexTree + { + public List Children; + + public Dictionary 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; + } + } +} diff --git a/GMAC1098/GMAssetCompiler/Loader.cs b/GMAC1098/GMAssetCompiler/Loader.cs new file mode 100644 index 0000000..a09abb8 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/Loader.cs @@ -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 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(text, num2, array, num3); + break; + case "SOND": + Console.WriteLine("DEBUG: READING SOND CHUNK!"); + Load(text, num2, array, num3); + break; + case "BGND": + Console.WriteLine("DEBUG: READING BGND CHUNK!"); + Load(text, num2, array, num3); + break; + case "PATH": + Console.WriteLine("DEBUG: READING PATH CHUNK!"); + Load(text, num2, array, num3); + break; + case "SCPT": + Console.WriteLine("DEBUG: READING SCPT CHUNK!"); + Load(text, num2, array, num3); + break; + case "FONT": + Console.WriteLine("DEBUG: READING FONT CHUNK!"); + //Load(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(text, num2, array, num3); + + //also crashes here for no apparent reason! + break; + case "OBJT": + Console.WriteLine("DEBUG: READING OBJT CHUNK: PREPARE TO CRASH!"); + Load(text, num2, array, num3); + break; + case "ROOM": + Console.WriteLine("DEBUG: READING ROOM CHUNK!"); + Load(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> Load(string _chunk, int _sz, byte[] _buffer, int _offset) + { + List> result = new List>(); + 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)); + } + } +} diff --git a/GMAC1098/GMAssetCompiler/Program.cs b/GMAC1098/GMAssetCompiler/Program.cs new file mode 100644 index 0000000..31f6c35 --- /dev/null +++ b/GMAC1098/GMAssetCompiler/Program.cs @@ -0,0 +1,1164 @@ +using GMAssetCompiler.Machines; +using GMAssetCompiler.Output; +using NDesk.Options; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Net.Mail; +using System.Reflection; +using System.Text; +using System.Windows.Forms; + +namespace GMAssetCompiler +{ + internal static class Program + { + private static OptionSet m_options; + + //public static bool IsPSPFileLoaded = false; + + public static eTexType[] TextureType; + + public static IMachineType MachineType + { + get; + set; + } + + public static string OutputDir + { + get; + set; + } + + public static bool WriteTextures + { + get; + set; + } + + public static bool WriteWaves + { + get; + set; + } + + public static bool CompileOnly + { + get; + set; + } + + public static bool SplashOmit + { + get; + set; + } + + public static bool SeparateOpaqueAndAlpha + { + get; + set; + } + + public static bool DisplaySortedTextures + { + get; + set; + } + + public static int TexturePageWidth + { + get; + set; + } + + public static int TexturePageHeight + { + get; + set; + } + + public static int TextureScale + { + get; + set; + } + + public static bool Verbose + { + get; + set; + } + + public static bool CompileVerbose + { + get; + set; + } + + public static bool RemoveDND + { + get; + set; + } + + public static bool CenterHTML5Game + { + get; + set; + } + + public static bool NoCache + { + get; + set; + } + + public static bool NoIndexHTML + { + get; + set; + } + + public static string HTMLRunner + { + get; + set; + } + + public static bool DoObfuscate + { + get; + set; + } + + public static bool ObfuscateObfuscate + { + get; + set; + } + + public static bool ObfuscatePrettyPrint + { + get; + set; + } + + public static bool ObfuscateRemoveUnused + { + get; + set; + } + + public static bool ObfuscateEncodeStrings + { + get; + set; + } + + public static string LoadingBarName + { + get; + set; + } + + public static bool CustomLoadingScreen + { + get; + set; + } + + public static int ExitCode + { + get; + set; + } + + public static bool InhibitErrorOutput + { + get; + set; + } + + public static GMAssets Assets + { + get; + set; + } + + public static bool Studio + { + get; + set; + } + + public static Dictionary> TextureGroups + { + get; + set; + } + + public static TextWriter Out + { + get; + set; + } + + public static string TextureTypeExtension(eTexType _textureType) + { + switch (_textureType) + { + case eTexType.eDXT: + return ".dds"; + case eTexType.ePVR: + return ".pvr"; + case eTexType.eRaw: + case eTexType.e4444: + return ".raw"; + case eTexType.ePNG: + return ".png"; + default: + return ".dds"; + } + } + + private static void ShowHelp() + { + Console.WriteLine("Usage is:"); + Console.WriteLine("\tSillicaAssetCompiler []+"); + m_options.WriteOptionDescriptions(Console.Out); + Environment.Exit(0); + } + + public static void SetMachineType(string _m) + { + _m = "psp"; // Allways PSP + switch (_m.ToLower()) + { + case "nokia": + case "symbian": + case "qt": + MachineType = new Symbian(); + break; + case "droid": + case "android": + MachineType = new Android(); + break; + case "ipad": + case "iphone": + case "ipod": + case "ios": + MachineType = new IOS(); + break; + case "psp": + MachineType = new PSP(); + break; + case "windows": + case "win": + MachineType = new Windows(); + break; + case "html5": + MachineType = new HTML5(); + break; + } + if (MachineType != null) + { + TextureType[0] = MachineType.OpaqueTextureType; + TextureType[1] = MachineType.AlphaTextureType; + TexturePageWidth = MachineType.TPageWidth; + TexturePageHeight = MachineType.TPageHeight; + } + } + + private static eTexType SetTextureType(string _t) + { + eTexType result = eTexType.eRaw; + switch (_t.ToLower()) + { + case "png": + result = eTexType.ePNG; + break; + case "raw": + result = eTexType.eRaw; + break; + case "dxt": + result = eTexType.eDXT; + break; + case "pvr": + result = eTexType.ePVR; + break; + case "16b": + case "16bit": + case "4444": + result = eTexType.e4444; + break; + } + return result; + } + + private static void DoPreObfuscateLib(string _sourceDir, string _outputDir) + { + List files = new List(); + HTML5Saver.GetFiles(_sourceDir, new string[3] + { + ".svn", + "runner.js", + "particles" + }, files); + List list = new List(); + foreach (KeyValuePair ms_func in GMLCompile.ms_funcs) + { + list.Add(ms_func.Key); + } + foreach (KeyValuePair ms_builtin in GMLCompile.ms_builtins) + { + list.Add(ms_builtin.Key); + if (!string.IsNullOrEmpty(ms_builtin.Value.setFunction)) + { + list.Add(ms_builtin.Value.setFunction); + } + if (!string.IsNullOrEmpty(ms_builtin.Value.getFunction)) + { + list.Add(ms_builtin.Value.getFunction); + } + } + foreach (KeyValuePair item2 in GMLCompile.ms_builtinsArray) + { + list.Add(item2.Key); + if (!string.IsNullOrEmpty(item2.Value.setFunction)) + { + list.Add(item2.Value.setFunction); + } + if (!string.IsNullOrEmpty(item2.Value.getFunction)) + { + list.Add(item2.Value.getFunction); + } + } + foreach (KeyValuePair item3 in GMLCompile.ms_builtinsLocal) + { + list.Add(item3.Key); + if (!string.IsNullOrEmpty(item3.Value.setFunction)) + { + list.Add(item3.Value.setFunction); + } + if (!string.IsNullOrEmpty(item3.Value.getFunction)) + { + list.Add(item3.Value.getFunction); + } + } + foreach (KeyValuePair item4 in GMLCompile.ms_builtinsLocalArray) + { + list.Add(item4.Key); + if (!string.IsNullOrEmpty(item4.Value.setFunction)) + { + list.Add(item4.Value.setFunction); + } + if (!string.IsNullOrEmpty(item4.Value.getFunction)) + { + list.Add(item4.Value.getFunction); + } + } + foreach (KeyValuePair ms_constant in GMLCompile.ms_constants) + { + list.Add(ms_constant.Key); + } + string[] array = new string[] + { + "antialias", + "charset", + "i", + "c", + "JSON_game", + "Options", + "debugMode", + "loadingBarCallback", + "gameId", + "gameGuid", + "fullScreen", + "interpolatePixels", + "showCursor", + "scale", + "allowFullScreenKey", + "freezeOnLostFocus", + "showLoadingBar", + "displayErrors", + "writeErrors", + "abortErrors", + "variableErrors", + "Textures", + "Triggers", + "pName", + "moment", + "pFunc", + "Extensions", + "TriggerEvents", + "jsFiles", + "init", + "final", + "Sounds", + "pName", + "kind", + "extension", + "origName", + "effects", + "volume", + "pan", + "preload", + "Sprites", + "width", + "height", + "bboxMode", + "transparent", + "smooth", + "preload", + "colCheck", + "xOrigin", + "yOrigin", + "bboxLeft", + "bboxRight", + "bboxTop", + "bboxBottom", + "TPEntryIndex", + "Masks", + "Backgrounds", + "Paths", + "kind", + "closed", + "precision", + "points", + "speed", + "Fonts", + "size", + "bold", + "italic", + "first", + "last", + "TPageEntry", + "scaleX", + "scaleY", + "glyphs", + "w", + "h", + "shift", + "offset", + "Timelines", + "Events", + "Time", + "Event", + "GMObjects", + "spriteIndex", + "visible", + "solid", + "persistent", + "depth", + "parent", + "spritemask", + "CollisionEvents", + "CreateEvent", + "DestroyEvent", + "StepBeginEvent", + "StepNormalEvent", + "StepEndEvent", + "DrawEvent", + "NoButtonPressed", + "LeftButtonDown", + "RightButtonDown", + "MiddleButtonDown", + "LeftButtonPressed", + "RightButtonPressed", + "MiddleButtonPressed", + "LeftButtonReleased", + "RightButtonReleased", + "MiddleButtonReleased", + "GlobalLeftButtonDown", + "GlobalRightButtonDown", + "GlobalMiddleButtonDown", + "GlobalLeftButtonPressed", + "GlobalRightButtonPressed", + "GlobalMiddleButtonPressed", + "GlobalLeftButtonReleased", + "GlobalRightButtonReleased", + "GlobalMiddleButtonReleased", + "MouseEnter", + "MouseLeave", + "OutsideEvent", + "BoundaryEvent", + "StartGameEvent", + "EndGameEvent", + "StartRoomEvent", + "EndRoomEvent", + "NoLivesEvent", + "AnimationEndEvent", + "EndOfPathEvent", + "NoHealthEvent", + "CloseButtonEvent", + "OutsideView0Event", + "BoundaryView0Event", + "UserEvent0", + "UserEvent1", + "UserEvent2", + "UserEvent3", + "UserEvent4", + "UserEvent5", + "UserEvent6", + "UserEvent7", + "UserEvent8", + "UserEvent9", + "UserEvent10", + "UserEvent11", + "UserEvent12", + "UserEvent13", + "UserEvent14", + "UserEvent15", + "WebImageLoadedEvent", + "WebSoundLoadedEvent", + "WebAsyncEvent", + "ObjAlarm0", + "ObjAlarm1", + "ObjAlarm2", + "ObjAlarm3", + "ObjAlarm4", + "ObjAlarm5", + "ObjAlarm6", + "ObjAlarm7", + "ObjAlarm8", + "ObjAlarm9", + "ObjAlarm10", + "ObjAlarm11", + "KeyPressed_", + "KeyPressed_NOKEY", + "KeyPressed_ANYKEY", + "KeyPressed_BACKSPACE", + "KeyPressed_TAB", + "KeyPressed_ENTER", + "KeyPressed_SHIFT", + "KeyPressed_CTRL", + "KeyPressed_ALT", + "KeyPressed_PAUSE", + "KeyPressed_ESCAPE", + "KeyPressed_SPACE", + "KeyPressed_PAGEUP", + "KeyPressed_PAGEDOWN", + "KeyPressed_END", + "KeyPressed_HOME", + "KeyPressed_LEFT", + "KeyPressed_UP", + "KeyPressed_RIGHT", + "KeyPressed_DOWN", + "KeyPressed_INSERT", + "KeyPressed_DELETE", + "KeyPressed_0", + "KeyPressed_1", + "KeyPressed_2", + "KeyPressed_3", + "KeyPressed_4", + "KeyPressed_5", + "KeyPressed_6", + "KeyPressed_7", + "KeyPressed_8", + "KeyPressed_9", + "KeyPressed_A", + "KeyPressed_B", + "KeyPressed_C", + "KeyPressed_D", + "KeyPressed_E", + "KeyPressed_F", + "KeyPressed_G", + "KeyPressed_H", + "KeyPressed_I", + "KeyPressed_J", + "KeyPressed_K", + "KeyPressed_L", + "KeyPressed_M", + "KeyPressed_N", + "KeyPressed_O", + "KeyPressed_P", + "KeyPressed_Q", + "KeyPressed_R", + "KeyPressed_S", + "KeyPressed_T", + "KeyPressed_U", + "KeyPressed_V", + "KeyPressed_W", + "KeyPressed_X", + "KeyPressed_Y", + "KeyPressed_Z", + "KeyPressed_F1", + "KeyPressed_F2", + "KeyPressed_F3", + "KeyPressed_F4", + "KeyPressed_F5", + "KeyPressed_F6", + "KeyPressed_F7", + "KeyPressed_F8", + "KeyPressed_F9", + "KeyPressed_F10", + "KeyPressed_F11", + "KeyPressed_F12", + "KeyPressed_NUM_LOCK", + "KeyPressed_NUM_0", + "KeyPressed_NUM_1", + "KeyPressed_NUM_2", + "KeyPressed_NUM_3", + "KeyPressed_NUM_4", + "KeyPressed_NUM_5", + "KeyPressed_NUM_6", + "KeyPressed_NUM_7", + "KeyPressed_NUM_8", + "KeyPressed_NUM_9", + "KeyPressed_NUM_STAR", + "KeyPressed_NUM_PLUS", + "KeyPressed_NUM_MINUS", + "KeyPressed_NUM_DOT", + "KeyPressed_NUM_DIV", + "Key_NOKEY", + "Key_ANYKEY", + "Key_BACKSPACE", + "Key_TAB", + "Key_ENTER", + "Key_SHIFT", + "Key_CTRL", + "Key_ALT", + "Key_PAUSE", + "Key_ESCAPE", + "Key_SPACE", + "Key_PAGEUP", + "Key_PAGEDOWN", + "Key_END", + "Key_HOME", + "Key_LEFT", + "Key_UP", + "Key_RIGHT", + "Key_DOWN", + "Key_INSERT", + "Key_DELETE", + "Key_0", + "Key_1", + "Key_2", + "Key_3", + "Key_4", + "Key_5", + "Key_6", + "Key_7", + "Key_8", + "Key_9", + "Key_A", + "Key_B", + "Key_C", + "Key_D", + "Key_E", + "Key_F", + "Key_G", + "Key_H", + "Key_I", + "Key_J", + "Key_K", + "Key_L", + "Key_M", + "Key_N", + "Key_O", + "Key_P", + "Key_Q", + "Key_R", + "Key_S", + "Key_T", + "Key_U", + "Key_V", + "Key_W", + "Key_X", + "Key_Y", + "Key_Z", + "Key_F1", + "Key_F2", + "Key_F3", + "Key_F4", + "Key_F5", + "Key_F6", + "Key_F7", + "Key_F8", + "Key_F9", + "Key_F10", + "Key_F11", + "Key_F12", + "Key_NUM_LOCK", + "Key_NUM_0", + "Key_NUM_1", + "Key_NUM_2", + "Key_NUM_3", + "Key_NUM_4", + "Key_NUM_5", + "Key_NUM_6", + "Key_NUM_7", + "Key_NUM_8", + "Key_NUM_9", + "Key_NUM_STAR", + "Key_NUM_PLUS", + "Key_NUM_MINUS", + "Key_NUM_DOT", + "Key_NUM_DIV", + "KeyReleased_NOKEY", + "KeyReleased_ANYKEY", + "KeyReleased_BACKSPACE", + "KeyReleased_TAB", + "KeyReleased_ENTER", + "KeyReleased_SHIFT", + "KeyReleased_CTRL", + "KeyReleased_ALT", + "KeyReleased_PAUSE", + "KeyReleased_ESCAPE", + "KeyReleased_SPACE", + "KeyReleased_PAGEUP", + "KeyReleased_PAGEDOWN", + "KeyReleased_END", + "KeyReleased_HOME", + "KeyReleased_LEFT", + "KeyReleased_UP", + "KeyReleased_RIGHT", + "KeyReleased_DOWN", + "KeyReleased_INSERT", + "KeyReleased_DELETE", + "KeyReleased_0", + "KeyReleased_1", + "KeyReleased_2", + "KeyReleased_3", + "KeyReleased_4", + "KeyReleased_5", + "KeyReleased_6", + "KeyReleased_7", + "KeyReleased_8", + "KeyReleased_9", + "KeyReleased_A", + "KeyReleased_B", + "KeyReleased_C", + "KeyReleased_D", + "KeyReleased_E", + "KeyReleased_F", + "KeyReleased_G", + "KeyReleased_H", + "KeyReleased_I", + "KeyReleased_J", + "KeyReleased_K", + "KeyReleased_L", + "KeyReleased_M", + "KeyReleased_N", + "KeyReleased_O", + "KeyReleased_P", + "KeyReleased_Q", + "KeyReleased_R", + "KeyReleased_S", + "KeyReleased_T", + "KeyReleased_U", + "KeyReleased_V", + "KeyReleased_W", + "KeyReleased_X", + "KeyReleased_Y", + "KeyReleased_Z", + "KeyReleased_F1", + "KeyReleased_F2", + "KeyReleased_F3", + "KeyReleased_F4", + "KeyReleased_F5", + "KeyReleased_F6", + "KeyReleased_F7", + "KeyReleased_F8", + "KeyReleased_F9", + "KeyReleased_F10", + "KeyReleased_F11", + "KeyReleased_F12", + "KeyReleased_NUM_LOCK", + "KeyReleased_NUM_0", + "KeyReleased_NUM_1", + "KeyReleased_NUM_2", + "KeyReleased_NUM_3", + "KeyReleased_NUM_4", + "KeyReleased_NUM_5", + "KeyReleased_NUM_6", + "KeyReleased_NUM_7", + "KeyReleased_NUM_8", + "KeyReleased_NUM_9", + "KeyReleased_NUM_STAR", + "KeyReleased_NUM_PLUS", + "KeyReleased_NUM_MINUS", + "KeyReleased_NUM_DOT", + "KeyReleased_NUM_DIV", + "GMRooms", + "pCaption", + "width", + "height", + "speed", + "persistent", + "colour", + "showColour", + "enableViews", + "viewClearScreen", + "pCode", + "visible", + "foreground", + "index", + "htiled", + "vtiled", + "hspeed", + "vspeed", + "stretch", + "backgrounds", + "views", + "visible", + "xview", + "yview", + "wview", + "hview", + "xport", + "yport", + "wport", + "hport", + "hborder", + "vborder", + "hspeed", + "vspeed", + "index", + "pInstances", + "id", + "tiles", + "xo", + "yo", + "depth", + "RoomOrder", + "TPageEntries", + "XOffset", + "YOffset", + "CropWidth", + "CropHeight", + "ow", + "oh", + "tp", + "fontname", + "array_set_2D", + "array_set_1D", + "array_get_2D", + "array_get_1D", + "g_pBuiltIn", + "GetWithArray", + "yyInst", + "Scripts", + "WebGL", + "CreateEventOrder" + }; + string[] array2 = array; + foreach (string item in array2) + { + list.Add(item); + } + string outputfilename = Path.Combine(_outputDir, "gmRunner.js"); + Out.WriteLine("Obfuscating..."); + YYObfuscate yYObfuscate = new YYObfuscate(); + yYObfuscate.Obfuscate = ObfuscateObfuscate; + yYObfuscate.Verbose = Verbose; + yYObfuscate.PrettyPrint = ObfuscatePrettyPrint; + yYObfuscate.RemovedUnused = ObfuscateRemoveUnused; + yYObfuscate.EncodeStrings = ObfuscateEncodeStrings; + yYObfuscate.DoObfuscate(files, outputfilename, list); + } + + [STAThread] + private static int Main(string[] _args) + { + Trace.Write("------------ {1} {0} --------------", Assembly.GetExecutingAssembly().GetName().Version.ToString(), Assembly.GetExecutingAssembly().GetName().Name); + /*if (!Debugger.IsAttached) + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + }*/ + //Unlike yoyogames. i see NO issue with running a debugger here :D + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + GMLCompile.Test(); + GMLCompile.Code_Init(); + HTMLRunner = "C:\\source\\GameMaker\\Runner\\HTML5\\scripts"; + Verbose = false; + CompileVerbose = false; + Out = Console.Out; + SplashOmit = true; + TextureType = new eTexType[2]; + SeparateOpaqueAndAlpha = false; + DisplaySortedTextures = false; + RemoveDND = true; + CenterHTML5Game = false; + NoCache = false; + HTMLRunner = string.Empty; + NoIndexHTML = false; + TextureGroups = new Dictionary>(); + DoObfuscate = false; + ObfuscateObfuscate = true; + ObfuscatePrettyPrint = false; + ObfuscateRemoveUnused = true; + ObfuscateEncodeStrings = true; + LoadingBarName = null; + CustomLoadingScreen = false; + ExitCode = 0; + InhibitErrorOutput = false; + string PreObfuscateLib = string.Empty; + TextureScale = 1; + Studio = false; + m_options = new OptionSet().Add("?|help", "display help usage", (Action)delegate + { + ShowHelp(); + }).Add("m=|machine=", "set machine type (ios, psp, win, droid)", delegate(string m) + { + SetMachineType(m); + }).Add("t=|tex=", "override opaque texture type (dxt,raw,pvr,png)", delegate(string s) + { + TextureType[0] = SetTextureType(s); + }) + .Add("at=|alphatex=", "override alpha texture type (dxt,raw,pvr,png)", delegate(string s) + { + TextureType[1] = SetTextureType(s); + }) + .Add("o=|outputDir=", "set output directory", delegate(string d) + { + OutputDir = d; + }) + .Add("w=|tpageWidth=", "set texture page width", delegate(int w) + { + TexturePageWidth = w; + }) + .Add("h=|tpageHeight=", "set texture page height", delegate(int h) + { + TexturePageHeight = h; + }) + .Add("wt|writeTextures", "optionally write textures generated to output directory", (Action)delegate + { + WriteTextures = true; + }) + .Add("ww|writeWaves", "optionally write audio waves generated to output directory", (Action)delegate + { + WriteTextures = true; + }) + .Add("so|splashOmit", "optionally disable writing of the Spash screen to output file", (Action)delegate + { + SplashOmit = true; + }) + .Add("dst|DisplaySortedTextures", "optionally display sorted texture information", (Action)delegate + { + DisplaySortedTextures = true; + }) + .Add("c|compile", "do not display gui compile only", (Action)delegate + { + CompileOnly = true; + }) + .Add("s|separate", "separate the alpha and opaque textures (false by default)", (Action)delegate + { + SeparateOpaqueAndAlpha = true; + }) + .Add("v|verbose", "output verbose debug info", (Action)delegate + { + Verbose = true; + }) + .Add("nohtml", "do not output index.html", (Action)delegate + { + NoIndexHTML = true; + }) + .Add("HTMLRunner=", "directory with HTML Runner (will be copied as scripts)", delegate(string d) + { + HTMLRunner = d; + }) + .Add("tg=|TextureGroup=", "Group resources onto texture pages comma param is a filename, file has format : , use # for comment (NOTE: entries MUST all be on the same line", delegate(string f) + { + string[] array4 = File.ReadAllLines(f); + string[] array5 = array4; + foreach (string text3 in array5) + { + string text4 = text3.Trim().Replace(" ", "").Replace("\t", ""); + if (!string.IsNullOrEmpty(text4) && !text4.StartsWith("#")) + { + string[] array6 = text4.Split(':'); + if (array6.Length == 2) + { + string[] collection2 = array6[1].Split(','); + string key = array6[0]; + List value = new List(collection2); + TextureGroups.Add(key, value); + } + } + } + }) + .Add("to=|TextureOption=", "Set an option for a set of textures via