diff --git a/T2Tools/MainForm.Designer.cs b/T2Tools/MainForm.Designer.cs index d602eaa..36cb377 100644 --- a/T2Tools/MainForm.Designer.cs +++ b/T2Tools/MainForm.Designer.cs @@ -86,6 +86,7 @@ private void InitializeComponent() this.exportButton = new System.Windows.Forms.Button(); this.exportDialog = new System.Windows.Forms.FolderBrowserDialog(); this.saveImageDialog = new System.Windows.Forms.SaveFileDialog(); + this.openButton = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -205,9 +206,9 @@ private void InitializeComponent() this.sectionsPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.sectionsPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.sectionsPanel.Location = new System.Drawing.Point(6, 6); + this.sectionsPanel.Location = new System.Drawing.Point(78, 6); this.sectionsPanel.Name = "sectionsPanel"; - this.sectionsPanel.Size = new System.Drawing.Size(824, 23); + this.sectionsPanel.Size = new System.Drawing.Size(752, 23); this.sectionsPanel.TabIndex = 3; this.sectionsPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.sectionsPanel_Paint); this.sectionsPanel.Resize += new System.EventHandler(this.sectionsPanel_Resize); @@ -705,11 +706,22 @@ private void InitializeComponent() this.saveImageDialog.RestoreDirectory = true; this.saveImageDialog.Title = "Save PNG"; // + // openButton + // + this.openButton.Location = new System.Drawing.Point(6, 6); + this.openButton.Name = "openButton"; + this.openButton.Size = new System.Drawing.Size(66, 23); + this.openButton.TabIndex = 6; + this.openButton.Text = "OPEN"; + this.openButton.UseVisualStyleBackColor = true; + this.openButton.Click += new System.EventHandler(this.openButton_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(970, 561); + this.Controls.Add(this.openButton); this.Controls.Add(this.exportButton); this.Controls.Add(this.writeExeButton); this.Controls.Add(this.splitContainer1); @@ -814,6 +826,7 @@ private void InitializeComponent() private System.Windows.Forms.Label mapDetailsLabel; private System.Windows.Forms.CheckBox entitiesCheckbox; private System.Windows.Forms.CheckBox mapGridCheckbox; + private System.Windows.Forms.Button openButton; } } diff --git a/T2Tools/MainForm.cs b/T2Tools/MainForm.cs index 7485b30..26c535b 100644 --- a/T2Tools/MainForm.cs +++ b/T2Tools/MainForm.cs @@ -32,13 +32,28 @@ public MainForm() sectionsPanel.DoubleBuffered(true); imgPage.DoubleBuffered(true); - createHexEditor(); + createHexEditor(); + this.AllowDrop = true; + this.DragEnter += new DragEventHandler(MainForm_DragEnter); + this.DragDrop += new DragEventHandler(MainForm_DragDrop); + } + void MainForm_DragEnter(object sender, DragEventArgs e) { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; + } + + void MainForm_DragDrop(object sender, DragEventArgs e) { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + this.initForm(files[0]); // open first file } private void MainForm_Load(object sender, EventArgs e) + { + this.initForm("../../../game/T2.exe"); + } + private void initForm(string filename) { #if DEBUG - game = new Game("../../../game/T2.exe"); + game = new Game(filename); #else game = new Game("T2.exe"); #endif @@ -49,9 +64,12 @@ private void MainForm_Load(object sender, EventArgs e) return; } + this.Text = "Turrican II Tools - " + filename; + tilemapMaker = new TilemapMaker(game.Assets); // fill TOC list + fileList.Items.Clear(); foreach (var entry in game.Assets.Entries.Values) { fileList.Items.Add(new TOCListItem(entry)); @@ -122,7 +140,6 @@ private void fileSelected(TOCListItem item) bitmapControlsPanel.Visible = false; updateImagePreview(); break; - case TOCEntryType.AnimatedSprite: BOBFile bobFile = new BOBFile(item.Entry.Data); BOBDecoder decoder = new BOBDecoder(); @@ -201,9 +218,9 @@ private void fileSelected(TOCListItem item) case TOCEntryType.PixelFont: case TOCEntryType.Sound: + case TOCEntryType.DIR: + case TOCEntryType.DAT: case TOCEntryType.Executable: - case TOCEntryType.DAT: - case TOCEntryType.DIR: case TOCEntryType.Unknown: default: break; @@ -544,8 +561,32 @@ private void saveTilesetButton_Click(object sender, EventArgs e) tilesPictureBox.Image.Save(saveImageDialog.FileName); } + #endregion - + private void openButton_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog1 = new OpenFileDialog + { + //InitialDirectory = @"D:\", + Title = "Browse Turrican EXE files", + + CheckFileExists = true, + CheckPathExists = true, + + DefaultExt = "exe", + Filter = "Executables (*.exe)|*.exe", + FilterIndex = 2, + RestoreDirectory = true, + + ReadOnlyChecked = true, + ShowReadOnly = true + }; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + { + this.initForm(openFileDialog1.FileName) ; + } + } } }