2009-11-08 23:53:22 +01:00
|
|
|
|
/* This file is part of CustomizeMii
|
|
|
|
|
* Copyright (C) 2009 Leathl
|
|
|
|
|
*
|
2009-11-24 01:09:42 +01:00
|
|
|
|
* CustomizeMii is free software: you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License as published
|
|
|
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* CustomizeMii is distributed in the hope that it will be
|
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
|
|
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-11-08 23:53:22 +01:00
|
|
|
|
* GNU General Public License for more details.
|
2009-11-24 01:09:42 +01:00
|
|
|
|
*
|
2009-11-08 23:53:22 +01:00
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-11-24 01:09:42 +01:00
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-11-08 23:53:22 +01:00
|
|
|
|
*/
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2009-11-08 23:53:22 +01:00
|
|
|
|
using System;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
using System.Collections.Generic;
|
2009-11-08 23:53:22 +01:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
using libWiiSharp;
|
2009-11-08 23:53:22 +01:00
|
|
|
|
|
|
|
|
|
namespace CustomizeMii
|
|
|
|
|
{
|
|
|
|
|
public partial class CustomizeMii_Preview : Form
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
private TplImage[][] images = new TplImage[2][];
|
|
|
|
|
private U8 bannerBin;
|
|
|
|
|
private U8 iconBin;
|
|
|
|
|
private string startTPL;
|
|
|
|
|
private bool startIcon = false;
|
2010-04-20 21:54:36 +02:00
|
|
|
|
Timer tipTimer = new Timer();
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
public U8 BannerBin { get { return bannerBin; } set { bannerBin = value; } }
|
|
|
|
|
public U8 IconBin { get { return iconBin; } set { iconBin = value; } }
|
|
|
|
|
public string StartTPL { get { return startTPL; } set { startTPL = value; } }
|
|
|
|
|
public bool StartIcon { get { return startIcon; } set { startIcon = value; } }
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2009-11-08 23:53:22 +01:00
|
|
|
|
public CustomizeMii_Preview()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2009-12-31 04:34:47 +01:00
|
|
|
|
this.Icon = global::CustomizeMii.Properties.Resources.CustomizeMii;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Preview_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
2010-02-06 00:09:36 +01:00
|
|
|
|
images = null;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
cbBanner.Items.Clear();
|
|
|
|
|
cbIcon.Items.Clear();
|
2009-11-08 23:53:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-31 04:34:47 +01:00
|
|
|
|
private void Preview_Load(object sender, EventArgs e)
|
2009-11-08 23:53:22 +01:00
|
|
|
|
{
|
|
|
|
|
this.CenterToParent();
|
2010-03-28 20:29:30 +02:00
|
|
|
|
cbBanner.Items.Clear();
|
|
|
|
|
cbIcon.Items.Clear();
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
int startIndex = -1;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
List<TplImage> bannerImages = new List<TplImage>();
|
|
|
|
|
List<TplImage> iconImages = new List<TplImage>();
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
for (int i = 0; i < bannerBin.NumOfNodes; i++)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (bannerBin.StringTable[i].ToLower().EndsWith(".tpl"))
|
|
|
|
|
{
|
|
|
|
|
TplImage tmpImage = new TplImage();
|
|
|
|
|
TPL tmpTpl = TPL.Load(bannerBin.Data[i]);
|
|
|
|
|
|
|
|
|
|
if (i == 10) { }
|
|
|
|
|
|
|
|
|
|
tmpImage.fileName = bannerBin.StringTable[i];
|
|
|
|
|
tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
|
|
|
|
tmpImage.tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height);
|
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (tmpImage.tplFormat.StartsWith("CI"))
|
|
|
|
|
tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
bannerImages.Add(tmpImage);
|
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < iconBin.NumOfNodes; i++)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (iconBin.StringTable[i].ToLower().EndsWith(".tpl"))
|
|
|
|
|
{
|
|
|
|
|
TplImage tmpImage = new TplImage();
|
|
|
|
|
TPL tmpTpl = TPL.Load(iconBin.Data[i]);
|
|
|
|
|
|
|
|
|
|
tmpImage.fileName = iconBin.StringTable[i];
|
|
|
|
|
tmpImage.tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
|
|
|
|
tmpImage.tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
tmpImage.checkerBoard = createCheckerBoard(tmpImage.tplImage.Width, tmpImage.tplImage.Height);
|
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (tmpImage.tplFormat.StartsWith("CI"))
|
|
|
|
|
tmpImage.tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
iconImages.Add(tmpImage);
|
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
images[0] = bannerImages.ToArray();
|
|
|
|
|
images[1] = iconImages.ToArray();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < images[0].Length; i++)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
cbBanner.Items.Add(images[0][i].fileName);
|
|
|
|
|
if (!startIcon)
|
|
|
|
|
if (images[0][i].fileName.ToLower() == startTPL.ToLower())
|
|
|
|
|
startIndex = i;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
for (int i = 0; i < images[1].Length; i++)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
cbIcon.Items.Add(images[1][i].fileName);
|
|
|
|
|
if (startIcon)
|
|
|
|
|
if (images[1][i].fileName.ToLower() == startTPL.ToLower())
|
|
|
|
|
startIndex = i;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (startIndex != -1)
|
|
|
|
|
if (!startIcon)
|
|
|
|
|
cbBanner.SelectedIndex = startIndex;
|
|
|
|
|
else
|
|
|
|
|
cbIcon.SelectedIndex = startIndex;
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1) cbBanner.Select();
|
|
|
|
|
else if (cbIcon.SelectedIndex != -1) cbIcon.Select();
|
2010-04-20 21:54:36 +02:00
|
|
|
|
|
|
|
|
|
tipTimer.Interval = 7000;
|
|
|
|
|
tipTimer.Tag = 0;
|
|
|
|
|
tipTimer.Tick += new EventHandler(tipTimer_Tick);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tipTimer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lbTip.Visible = false;
|
|
|
|
|
tipTimer.Stop();
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbBanner_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (cbBanner.SelectedIndex != -1)
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
|
2010-01-18 21:13:32 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (cbCheckerBoard.Checked) pbPic.BackgroundImage = images[0][cbBanner.SelectedIndex].checkerBoard;
|
2010-02-24 22:41:37 +01:00
|
|
|
|
|
|
|
|
|
cbIcon.SelectedIndex = -1;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbIcon_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (cbIcon.SelectedIndex != -1)
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
|
2010-01-18 21:13:32 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (cbCheckerBoard.Checked) pbPic.BackgroundImage = images[1][cbIcon.SelectedIndex].checkerBoard;
|
2010-02-24 22:41:37 +01:00
|
|
|
|
|
|
|
|
|
cbBanner.SelectedIndex = -1;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
private Image resizeImage(Image img, int x, int y)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
Image newimage = new Bitmap(x, y);
|
|
|
|
|
|
|
|
|
|
using (Graphics gfx = Graphics.FromImage(newimage))
|
|
|
|
|
gfx.DrawImage(img, 0, 0, x, y);
|
|
|
|
|
|
|
|
|
|
return newimage;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
private Image createCheckerBoard(int w, int h)
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
Color darkColor = Color.DarkGray;
|
|
|
|
|
Color lightColor = Color.White;
|
|
|
|
|
int tileSize = 10;
|
|
|
|
|
|
|
|
|
|
Bitmap img = new Bitmap(w, h);
|
|
|
|
|
|
|
|
|
|
using (Graphics g = Graphics.FromImage(img))
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
g.Clear(lightColor);
|
|
|
|
|
|
|
|
|
|
for (int col = 0; col < w; col += tileSize)
|
|
|
|
|
{
|
|
|
|
|
for (int row = 0; row < h; row += tileSize)
|
|
|
|
|
{
|
|
|
|
|
Color curColor;
|
|
|
|
|
|
|
|
|
|
if ((col / tileSize) % 2 == 0)
|
|
|
|
|
curColor = (row / tileSize) % 2 == 0 ? darkColor : lightColor;
|
|
|
|
|
else
|
|
|
|
|
curColor = (row / tileSize) % 2 == 0 ? lightColor : darkColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (curColor == lightColor) continue;
|
|
|
|
|
|
|
|
|
|
Rectangle rect = new Rectangle(col, row, tileSize, tileSize);
|
|
|
|
|
g.FillRectangle(new SolidBrush(darkColor), rect);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
return (Image)img;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnReplace_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
cmFormat.Show(MousePosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cmFormat_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
|
|
ofd.Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TPL|*.tpl|All|*.png;*.jpg;*.gif;*.bmp;*.tpl";
|
|
|
|
|
ofd.FilterIndex = 6;
|
|
|
|
|
|
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
string tplName;
|
|
|
|
|
TPL tmpTpl = new TPL();
|
|
|
|
|
Image newImg;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (cbIcon.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
tplName = cbBanner.SelectedItem.ToString().ToLower();
|
|
|
|
|
tmpTpl.LoadFile(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tplName = cbIcon.SelectedItem.ToString().ToLower();
|
|
|
|
|
tmpTpl.LoadFile(iconBin.Data[iconBin.GetNodeIndex(tplName)]);
|
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
if (!ofd.FileName.ToLower().EndsWith(".tpl")) newImg = Image.FromFile(ofd.FileName);
|
|
|
|
|
else
|
2009-12-31 04:34:47 +01:00
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
TPL newTpl = TPL.Load(ofd.FileName);
|
|
|
|
|
newImg = newTpl.ExtractTexture();
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
Size tplSize = tmpTpl.GetTextureSize(0);
|
|
|
|
|
|
|
|
|
|
if (newImg.Width != tplSize.Width ||
|
|
|
|
|
newImg.Height != tplSize.Height)
|
|
|
|
|
newImg = resizeImage(newImg, tplSize.Width, tplSize.Height);
|
|
|
|
|
|
2009-12-31 04:34:47 +01:00
|
|
|
|
ToolStripMenuItem cmSender = sender as ToolStripMenuItem;
|
2010-04-20 21:54:36 +02:00
|
|
|
|
TPL_TextureFormat tplFormat;
|
|
|
|
|
TPL_PaletteFormat pFormat = TPL_PaletteFormat.RGB5A3;
|
|
|
|
|
|
2009-12-31 04:34:47 +01:00
|
|
|
|
switch (cmSender.Tag.ToString().ToLower())
|
|
|
|
|
{
|
2010-02-06 00:09:36 +01:00
|
|
|
|
case "i4":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.I4;
|
2010-02-06 00:09:36 +01:00
|
|
|
|
break;
|
|
|
|
|
case "i8":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.I8;
|
2010-02-06 00:09:36 +01:00
|
|
|
|
break;
|
|
|
|
|
case "ia4":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.IA4;
|
2010-02-06 00:09:36 +01:00
|
|
|
|
break;
|
|
|
|
|
case "ia8":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.IA8;
|
2010-02-06 00:09:36 +01:00
|
|
|
|
break;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
case "rgb565":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGB565;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
break;
|
|
|
|
|
case "rgb5a3":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8rgb5a3":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8rgb565":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB565;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8ia8":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.IA8;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4rgb5a3":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4rgb565":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB565;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4ia8":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.IA8;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGBA8;
|
2009-12-31 04:34:47 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
tmpTpl.RemoveTexture(0);
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tmpTpl.AddTexture(newImg, tplFormat, pFormat);
|
2010-02-06 00:09:36 +01:00
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1)
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
bannerBin.ReplaceFile(bannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
2010-02-06 00:09:36 +01:00
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (images[0][cbBanner.SelectedIndex].tplFormat.StartsWith("CI"))
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
|
2010-02-06 00:09:36 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-03-28 20:29:30 +02:00
|
|
|
|
iconBin.ReplaceFile(iconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
2010-02-06 00:09:36 +01:00
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (images[1][cbIcon.SelectedIndex].tplFormat.StartsWith("CI"))
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
|
2010-02-06 00:09:36 +01:00
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1) cbBanner.Select();
|
|
|
|
|
else if (cbIcon.SelectedIndex != -1) cbIcon.Select();
|
2010-04-20 21:54:36 +02:00
|
|
|
|
|
|
|
|
|
if (tplFormat == TPL_TextureFormat.CI4 || tplFormat == TPL_TextureFormat.CI8)
|
|
|
|
|
{
|
|
|
|
|
lbTip.Visible = true;
|
|
|
|
|
tipTimer.Start();
|
|
|
|
|
}
|
2009-12-31 04:34:47 +01:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
|
|
|
|
}
|
2009-11-08 23:53:22 +01:00
|
|
|
|
}
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
private void cmChangeFormat_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string tplName;
|
|
|
|
|
TPL tmpTpl = new TPL();
|
|
|
|
|
Image newImg;
|
|
|
|
|
|
|
|
|
|
if (cbIcon.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
tplName = cbBanner.SelectedItem.ToString().ToLower();
|
|
|
|
|
tmpTpl.LoadFile(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tplName = cbIcon.SelectedItem.ToString().ToLower();
|
|
|
|
|
tmpTpl.LoadFile(iconBin.Data[iconBin.GetNodeIndex(tplName)]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newImg = tmpTpl.ExtractTexture();
|
2010-04-20 21:54:36 +02:00
|
|
|
|
TPL_TextureFormat tplFormat;
|
|
|
|
|
TPL_PaletteFormat pFormat = TPL_PaletteFormat.RGB5A3;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
ToolStripMenuItem cmSender = sender as ToolStripMenuItem;
|
|
|
|
|
switch (cmSender.Tag.ToString().ToLower())
|
|
|
|
|
{
|
|
|
|
|
case "i4":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.I4;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case "i8":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.I8;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case "ia4":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.IA4;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case "ia8":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.IA8;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case "rgb565":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGB565;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
case "rgb5a3":
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8rgb5a3":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8rgb565":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB565;
|
|
|
|
|
break;
|
|
|
|
|
case "ci8ia8":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI8;
|
|
|
|
|
pFormat = TPL_PaletteFormat.IA8;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4rgb5a3":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB5A3;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4rgb565":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.RGB565;
|
|
|
|
|
break;
|
|
|
|
|
case "ci4ia8":
|
|
|
|
|
tplFormat = TPL_TextureFormat.CI4;
|
|
|
|
|
pFormat = TPL_PaletteFormat.IA8;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tplFormat = TPL_TextureFormat.RGBA8;
|
2010-03-28 20:29:30 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tmpTpl.GetTextureFormat(0) == tplFormat) return;
|
|
|
|
|
|
|
|
|
|
tmpTpl.RemoveTexture(0);
|
2010-04-20 21:54:36 +02:00
|
|
|
|
tmpTpl.AddTexture(newImg, tplFormat, pFormat);
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
bannerBin.ReplaceFile(bannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (images[0][cbBanner.SelectedIndex].tplFormat.StartsWith("CI"))
|
|
|
|
|
images[0][cbBanner.SelectedIndex].tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
2010-03-28 20:29:30 +02:00
|
|
|
|
|
|
|
|
|
pbPic.Image = images[0][cbBanner.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[0][cbBanner.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[0][cbBanner.SelectedIndex].tplImage.Width, images[0][cbBanner.SelectedIndex].tplImage.Height);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iconBin.ReplaceFile(iconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplImage = tmpTpl.ExtractTexture();
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplFormat = tmpTpl.GetTextureFormat(0).ToString();
|
|
|
|
|
|
2010-04-20 21:54:36 +02:00
|
|
|
|
if (images[1][cbIcon.SelectedIndex].tplFormat.StartsWith("CI"))
|
|
|
|
|
images[1][cbIcon.SelectedIndex].tplFormat += " + " + tmpTpl.GetPaletteFormat(0);
|
|
|
|
|
|
2010-03-28 20:29:30 +02:00
|
|
|
|
pbPic.Image = images[1][cbIcon.SelectedIndex].tplImage;
|
|
|
|
|
lbFormat.Text = images[1][cbIcon.SelectedIndex].tplFormat;
|
|
|
|
|
lbSize.Text = string.Format("{0} x {1}", images[1][cbIcon.SelectedIndex].tplImage.Width, images[1][cbIcon.SelectedIndex].tplImage.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1) cbBanner.Select();
|
|
|
|
|
else if (cbIcon.SelectedIndex != -1) cbIcon.Select();
|
2010-04-20 21:54:36 +02:00
|
|
|
|
|
|
|
|
|
if (tplFormat == TPL_TextureFormat.CI4 || tplFormat == TPL_TextureFormat.CI8)
|
|
|
|
|
{
|
|
|
|
|
lbTip.Visible = true;
|
|
|
|
|
tipTimer.Start();
|
|
|
|
|
}
|
2010-03-28 20:29:30 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cbCheckerBoard_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (cbCheckerBoard.Checked)
|
|
|
|
|
{
|
|
|
|
|
if (cbBanner.SelectedIndex != -1)
|
|
|
|
|
pbPic.BackgroundImage = images[0][cbBanner.SelectedIndex].checkerBoard;
|
|
|
|
|
else
|
|
|
|
|
pbPic.BackgroundImage = images[1][cbIcon.SelectedIndex].checkerBoard;
|
|
|
|
|
}
|
|
|
|
|
else pbPic.BackgroundImage = null;
|
|
|
|
|
|
|
|
|
|
if (cbBanner.SelectedIndex != -1)
|
|
|
|
|
cbBanner.Focus();
|
|
|
|
|
else
|
|
|
|
|
cbIcon.Focus();
|
|
|
|
|
}
|
2009-11-08 23:53:22 +01:00
|
|
|
|
}
|
|
|
|
|
}
|