Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding checkboxes to control which palette lines get blended.
  • Loading branch information
MainMemory committed Mar 25, 2016
1 parent 76ef9f3 commit 56a3c73
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 50 deletions.
184 changes: 142 additions & 42 deletions SonLVL/AlternatePaletteDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 31 additions & 6 deletions SonLVL/AlternatePaletteDialog.cs
Expand Up @@ -25,6 +25,10 @@ private void cancelButton_Click(object sender, EventArgs e)

int palnum;
public Color BlendColor { get; set; }
public bool Line1 { get { return checkBox1.Checked; } }
public bool Line2 { get { return checkBox2.Checked; } }
public bool Line3 { get { return checkBox3.Checked; } }
public bool Line4 { get { return checkBox4.Checked; } }

private void UnderwaterPaletteDialog_Load(object sender, EventArgs e)
{
Expand Down Expand Up @@ -73,17 +77,38 @@ private void button1_Click(object sender, EventArgs e)
Bitmap bmp = new Bitmap(256, 64);
Graphics gfx = Graphics.FromImage(bmp);
for (int l = 0; l < 4; l++)
{
bool doblend = false;
switch (l)
{
case 0:
doblend = checkBox1.Checked;
break;
case 1:
doblend = checkBox2.Checked;
break;
case 2:
doblend = checkBox3.Checked;
break;
case 3:
doblend = checkBox4.Checked;
break;
}
for (int i = 0; i < 16; i++)
{
Color col = LevelData.PaletteToColor(l, i, false);
if (radioButton1.Checked)
col = col.Blend(BlendColor);
else if (radioButton2.Checked)
col = Color.FromArgb(Math.Min(col.R + BlendColor.R, 255), Math.Min(col.G + BlendColor.G, 255), Math.Min(col.B + BlendColor.B, 255));
else
col = Color.FromArgb(Math.Max(col.R - BlendColor.R, 0), Math.Max(col.G - BlendColor.G, 0), Math.Max(col.B - BlendColor.B, 0));
if (doblend)
{
if (radioButton1.Checked)
col = col.Blend(BlendColor);
else if (radioButton2.Checked)
col = Color.FromArgb(Math.Min(col.R + BlendColor.R, 255), Math.Min(col.G + BlendColor.G, 255), Math.Min(col.B + BlendColor.B, 255));
else
col = Color.FromArgb(Math.Max(col.R - BlendColor.R, 0), Math.Max(col.G - BlendColor.G, 0), Math.Max(col.B - BlendColor.B, 0));
}
gfx.FillRectangle(new SolidBrush(col), i * 16, l * 16, 16, 16);
}
}
pictureBox2.Image = bmp;
LevelData.CurPal = palnum;
}
Expand Down
21 changes: 19 additions & 2 deletions SonLVL/MainForm.cs
Expand Up @@ -867,13 +867,30 @@ private void DoRedo(int num)
private void blendAlternatePaletteToolStripMenuItem_Click(object sender, EventArgs e)
{
using (AlternatePaletteDialog dlg = new AlternatePaletteDialog())
{
if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
int underwater = LevelData.CurPal;
LevelData.CurPal = 0;
Color[,] pal = new Color[4, 16];
for (int l = 0; l < 4; l++)
{
bool doblend = false;
switch (l)
{
case 0:
doblend = dlg.Line1;
break;
case 1:
doblend = dlg.Line2;
break;
case 2:
doblend = dlg.Line3;
break;
case 3:
doblend = dlg.Line4;
break;
}
if (!doblend) continue;
for (int i = 0; i < 16; i++)
{
Color col = LevelData.PaletteToColor(l, i, false);
Expand All @@ -884,14 +901,14 @@ private void blendAlternatePaletteToolStripMenuItem_Click(object sender, EventAr
else
pal[l, i] = Color.FromArgb(Math.Max(col.R - dlg.BlendColor.R, 0), Math.Max(col.G - dlg.BlendColor.G, 0), Math.Max(col.B - dlg.BlendColor.B, 0));
}
}
LevelData.CurPal = dlg.paletteIndex.SelectedIndex + 1;
for (int l = 0; l < 4; l++)
for (int i = 0; i < 16; i++)
LevelData.ColorToPalette(l, i, pal[l, i]);
LevelData.CurPal = underwater;
LevelData.PaletteChanged();
}
}
}
#endregion

Expand Down

0 comments on commit 56a3c73

Please sign in to comment.