private void ExportAsTiff(object sender, EventArgs e) { if (listBoxSec.SelectedIndex == -1) { return; } int i = int.Parse(listBoxSec.Items[listBoxSec.SelectedIndex].ToString()); if (!SecondTexture.IsValidTexture(i)) { return; } string path = Options.OutputPath; string fileName = Path.Combine(path, $"Texture(Sec) 0x{i:X}.tiff"); SecondTexture.GetTexture(i).Save(fileName, ImageFormat.Tiff); MessageBox.Show( $"Texture saved to {fileName}", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); }
private void CopyAddOnly_Click(object sender, EventArgs e) { for (int i = 0; i < 0x4000; i++) { if (!SecondTexture.IsValidTexture(i)) { continue; } if (Textures.TestTexture(i)) { continue; } Bitmap copy = new Bitmap(SecondTexture.GetTexture(i)); Textures.Replace(i, copy); ControlEvents.FireTextureChangeEvent(this, i); } _mCompare.Clear(); listBoxOrg.BeginUpdate(); listBoxOrg.Items.Clear(); List <object> cache = new List <object>(); for (int i = 0; i < 0x4000; i++) { cache.Add(i); } listBoxOrg.Items.AddRange(cache.ToArray()); listBoxOrg.EndUpdate(); }
private bool Compare(int index) { if (_mCompare.ContainsKey(index)) { return(_mCompare[index]); } Bitmap bitorg = Textures.GetTexture(index); Bitmap bitsec = SecondTexture.GetTexture(index); if (bitorg == null && bitsec == null) { _mCompare[index] = true; return(true); } if (bitorg == null || bitsec == null || bitorg.Size != bitsec.Size) { _mCompare[index] = false; return(false); } byte[] btImage1 = new byte[1]; btImage1 = (byte[])_ic.ConvertTo(bitorg, btImage1.GetType()); byte[] btImage2 = new byte[1]; btImage2 = (byte[])_ic.ConvertTo(bitsec, btImage2.GetType()); string hash1String = BitConverter.ToString(_shaM.ComputeHash(btImage1)); string hash2String = BitConverter.ToString(_shaM.ComputeHash(btImage2)); bool res = hash1String == hash2String; _mCompare[index] = res; return(res); }
private void DrawItemSec(object sender, DrawItemEventArgs e) { if (e.Index == -1) { return; } Brush fontBrush = Brushes.Gray; int i = int.Parse(listBoxOrg.Items[e.Index].ToString()); if (listBoxSec.SelectedIndex == e.Index) { e.Graphics.FillRectangle(Brushes.LightSteelBlue, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } if (!SecondTexture.IsValidTexture(i)) { fontBrush = Brushes.Red; } else if (!Compare(i)) { fontBrush = Brushes.Blue; } e.Graphics.DrawString($"0x{i:X}", Font, fontBrush, new PointF(5, e.Bounds.Y + ((e.Bounds.Height / 2) - (e.Graphics.MeasureString($"0x{i:X}", Font).Height / 2)))); }
private void OnIndexChangedSec(object sender, EventArgs e) { if (listBoxSec.SelectedIndex == -1 || listBoxSec.Items.Count < 1) { return; } int i = int.Parse(listBoxSec.Items[listBoxSec.SelectedIndex].ToString()); listBoxOrg.SelectedIndex = listBoxOrg.Items.IndexOf(i); pictureBoxSec.BackgroundImage = SecondTexture.IsValidTexture(i) ? SecondTexture.GetTexture(i) : null; listBoxSec.Invalidate(); }
private void OnClickCopy(object sender, EventArgs e) { if (listBoxSec.SelectedIndex == -1) { return; } int i = int.Parse(listBoxSec.Items[listBoxSec.SelectedIndex].ToString()); if (!SecondTexture.IsValidTexture(i)) { return; } Bitmap copy = new Bitmap(SecondTexture.GetTexture(i)); Textures.Replace(i, copy); Options.ChangedUltimaClass["Texture"] = true; ControlEvents.FireTextureChangeEvent(this, i); _mCompare[i] = true; listBoxOrg.BeginUpdate(); bool done = false; for (int id = 0; id < 0x4000; id++) { if (id > i) { listBoxOrg.Items.Insert(id, i); done = true; break; } if (id == i) { done = true; break; } } if (!done) { listBoxOrg.Items.Add(i); } listBoxOrg.EndUpdate(); listBoxOrg.Invalidate(); listBoxSec.Invalidate(); OnIndexChangedOrg(this, null); }
private void OnClickLoadSecond(object sender, EventArgs e) { if (textBoxSecondDir.Text == null) { return; } string path = textBoxSecondDir.Text; string file = Path.Combine(path, "texmaps.mul"); string file2 = Path.Combine(path, "texidx.mul"); if (File.Exists(file) && File.Exists(file2)) { SecondTexture.SetFileIndex(file2, file); LoadSecond(); } }