private void ot_importImage_Click(object sender, EventArgs e) { if (ot_info_RomAddress.Text.Contains("N/A") || ot_info_RomAddress.Text.Contains("null")) { MessageBox.Show("Importing over compressed MIO0 data is not currently supported in this version. You will need to use an extended ROM file.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } string filename = LoadImage(); if (filename != null) { Bitmap newImg = new Bitmap(Image.FromFile(filename), new Size(ot_bitmap_preview.BackgroundImage.Width, ot_bitmap_preview.BackgroundImage.Height)); byte format = TextureFormats.ConvertStringToFormat(ot_info_Format.Text.Substring(ot_info_Format.Text.LastIndexOf(" ") + 1)); byte[] data = TextureFormats.encodeTexture(format, newImg); if (data != null) { uint rom_offset = uint.Parse(ot_info_RomAddress.Text.Substring(ot_info_RomAddress.Text.LastIndexOf(" ") + 1), System.Globalization.NumberStyles.HexNumber); uint seg_offset = uint.Parse(ot_info_SegAddress.Text.Substring(ot_info_SegAddress.Text.LastIndexOf(" ") + 1), System.Globalization.NumberStyles.HexNumber); ROM.Instance.writeByteArray(rom_offset, data); ROM.Instance.writeByteArrayToSegment(seg_offset, data); Bitmap newImage = TextureFormats.decodeTexture( format, data, ot_bitmap_preview.BackgroundImage.Width, ot_bitmap_preview.BackgroundImage.Height, null, false ); ot_bitmap_preview.BackgroundImage = newImage; ReplaceButtonImage(ref ot_buttons[ot_list_index], newImage); needToUpdateLevel = true; } } }
private void lt_importImage_Click(object sender, EventArgs e) { if (info_Format.Text.EndsWith("CI4") || info_Format.Text.EndsWith("CI8")) { MessageBox.Show("CI texture importing is not currently supported in this version.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (info_Address.Text.Contains("N/A") || info_Address.Text.Contains("null")) { MessageBox.Show("Importing over compressed MIO0 data is not currently supported in this version. You will need to use an extended ROM file.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } string filename = LoadImage(); if (filename != null) { Bitmap newImg = new Bitmap(Image.FromFile(filename), new Size(info_bitmapImage.BackgroundImage.Width, info_bitmapImage.BackgroundImage.Height)); byte format = TextureFormats.ConvertStringToFormat(info_Format.Text.Substring(info_Format.Text.LastIndexOf(" ") + 1)); byte[] data = TextureFormats.encodeTexture(format, newImg); if (data != null) { uint rom_offset = uint.Parse(info_Address.Text.Substring(info_Address.Text.LastIndexOf(" ") + 1), System.Globalization.NumberStyles.HexNumber); uint seg_offset = uint.Parse(info_SegmentAddress.Text.Substring(info_SegmentAddress.Text.LastIndexOf(" ") + 1), System.Globalization.NumberStyles.HexNumber); ROM.Instance.writeByteArray(rom_offset, data); ROM.Instance.writeByteArrayToSegment(seg_offset, data); Bitmap newImage = TextureFormats.decodeTexture( format, data, info_bitmapImage.BackgroundImage.Width, info_bitmapImage.BackgroundImage.Height, null, false ); info_bitmapImage.BackgroundImage = newImage; switch (lt_list_index) { case 0: if (!ReplaceButtonImage(ref lt_levelButtons, newImage)) { ReplaceButtonImage(ref lt_modelButtons, newImage); } break; case 1: ReplaceButtonImage(ref lt_levelButtons, newImage); break; case 2: ReplaceButtonImage(ref lt_modelButtons, newImage); break; case 3: ReplaceButtonImage(ref lt_objectButtons, newImage); break; } needToUpdateLevel = true; } } }