Skip to content

Commit

Permalink
Refactored some things, added a new mode for solid color uncollected …
Browse files Browse the repository at this point in the history
…items, fixed some bugs. Testing still needed.
  • Loading branch information
thezerothcat committed May 11, 2018
1 parent 561d2f6 commit f9e7649
Show file tree
Hide file tree
Showing 90 changed files with 4,628 additions and 2,737 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<setting name="DeathCount" serializeAs="String">
<value>0</value>
</setting>
<setting name="ItemColor" serializeAs="String">
<value>Black</value>
</setting>
</LMRItemTracker.Properties.Settings>
<LMRItemTracker.Settings1>
<setting name="panel1Contents" serializeAs="String">
Expand Down
88 changes: 88 additions & 0 deletions ItemTextPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
namespace LMRItemTracker
{
class ItemTextPanel : System.Windows.Forms.Panel
{
private static System.Drawing.Size NO_AMMO_HEIGHT = new System.Drawing.Size(40, 40);
private static System.Drawing.Size AMMO_HEIGHT = new System.Drawing.Size(40, 56);

public TrackerBox Item { get; set; }
public TrackerLabel Label { get; set; }
public bool TreatAsAmmo { get; set; }

public ItemTextPanel()
{
Item = null;
Label = null;
TreatAsAmmo = false;
}

public void UpdateCount(bool isAdd)
{
Label.UpdateCount(Label.Count + (isAdd ? 1 : -1));
Redraw();
}

public void UpdateCount(int newCount)
{
Label.UpdateCount(newCount);
Redraw();
}

public void ToggleState(bool isAdd)
{
Item.ToggleState(isAdd);
Redraw();
}

public void Redraw()
{
if (InvokeRequired)
{
Invoke(new System.Action(() =>
{
UpdatePanel();
Item.Redraw();
Refresh();
}));
}
else
{
UpdatePanel();
Item.Redraw();
Refresh();
}

}

private void UpdatePanel()
{
if (TreatAsAmmo && !Properties.Settings.Default.ShowAmmoCount)
{
Size = NO_AMMO_HEIGHT;
}
else if (Item.Collected)
{
Size = AMMO_HEIGHT;
Label.Visible = true;
}
else if (!"hide".Equals(Properties.Settings.Default.BackgroundMode))
{
Size = AMMO_HEIGHT;
Label.Visible = !TreatAsAmmo;
}
else
{
Size = NO_AMMO_HEIGHT;
}

if (!Item.Collected && "hide".Equals(Properties.Settings.Default.BackgroundMode))
{
Visible = false;
}
else
{
Visible = true;
}
}
}
}
112 changes: 112 additions & 0 deletions KeyFairyTrackerBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using System;

namespace LMRItemTracker
{
class KeyFairyTrackerBox : System.Windows.Forms.PictureBox
{
private bool miracleCollected;
private bool mekuriCollected;

public KeyFairyTrackerBox()
{
miracleCollected = false;
mekuriCollected = false;

Paint += new System.Windows.Forms.PaintEventHandler(HandlePaint);
}

public void ToggleState(bool isCollected, bool isMiracle)
{
if(isMiracle)
{
miracleCollected = isCollected;
}
else
{
mekuriCollected = isCollected;
}
Redraw();
}

protected virtual void DetermineImage()
{
if (miracleCollected && mekuriCollected)
{
BackgroundImage = Properties.Resources.Icon_keyfairy;
}
else
{
string mode = Properties.Settings.Default.BackgroundMode;
if ("shaded".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keyfairy_blank;
}
else if ("solid".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keyfairy_solid;
}
else
{
BackgroundImage = null;
}
}

Visible = !"hide".Equals(Properties.Settings.Default.BackgroundMode) || (miracleCollected && mekuriCollected);
}

public void Redraw()
{
if (InvokeRequired)
{
Invoke(new System.Action(() =>
{
DetermineImage();
Refresh();
}));
}
else
{
DetermineImage();
Refresh();
}
}

private void HandlePaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
UpdateImage(e);
}));
}
else
{
UpdateImage(e);
}
}

private void UpdateImage(System.Windows.Forms.PaintEventArgs e)
{
if (!miracleCollected && !mekuriCollected && "solid".Equals(Properties.Settings.Default.BackgroundMode))
{
e.Graphics.Clear(Properties.Settings.Default.BackgroundColor);
System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
new float[][]{
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {Properties.Settings.Default.ItemColor.R / 255.0f,
Properties.Settings.Default.ItemColor.G / 255.0f,
Properties.Settings.Default.ItemColor.B / 255.0f,
0, 1}
});

imageAttributes.SetColorMatrix(colorMatrix);
e.Graphics.DrawImage(Properties.Resources.Icon_keysword_solid, new System.Drawing.Rectangle(0, 0, 40, 40), 0, 0, 40, 40, System.Drawing.GraphicsUnit.Pixel, imageAttributes);
}
}
}
}
116 changes: 116 additions & 0 deletions KeySwordTrackerBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;

namespace LMRItemTracker
{
class KeySwordTrackerBox : System.Windows.Forms.PictureBox
{
private bool keySwordCollected;
private bool mantrasRecited;

public KeySwordTrackerBox()
{
keySwordCollected = false;
mantrasRecited = false;

Paint += new System.Windows.Forms.PaintEventHandler(HandlePaint);
}

public void ToggleState(bool isCollected, bool isKeySword)
{
if(isKeySword)
{
keySwordCollected = isCollected;
}
else
{
mantrasRecited = isCollected;
}
Redraw();
}

public void Redraw()
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
DetermineImage();
Refresh();
}));
}
else
{
DetermineImage();
Refresh();
}
}

private void DetermineImage()
{
if (keySwordCollected && mantrasRecited)
{
BackgroundImage = Properties.Resources.Icon_keysword_awakened;
}
else if (keySwordCollected)
{
BackgroundImage = Properties.Resources.Icon_keysword;
}
else
{
string mode = Properties.Settings.Default.BackgroundMode;
if ("shaded".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keysword_blank;
}
else if ("solid".Equals(mode))
{
BackgroundImage = Properties.Resources.Icon_keysword_solid;
}
else
{
BackgroundImage = null;
}
}

Visible = !"hide".Equals(Properties.Settings.Default.BackgroundMode) || keySwordCollected;
}

private void HandlePaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
UpdateImage(e);
}));
}
else
{
UpdateImage(e);
}
}

private void UpdateImage(System.Windows.Forms.PaintEventArgs e)
{
if (!keySwordCollected && "solid".Equals(Properties.Settings.Default.BackgroundMode))
{
e.Graphics.Clear(Properties.Settings.Default.BackgroundColor);
System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
new float[][]{
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {Properties.Settings.Default.ItemColor.R / 255.0f,
Properties.Settings.Default.ItemColor.G / 255.0f,
Properties.Settings.Default.ItemColor.B / 255.0f,
0, 1}
});

imageAttributes.SetColorMatrix(colorMatrix);
e.Graphics.DrawImage(Properties.Resources.Icon_keysword_solid, new System.Drawing.Rectangle(0, 0, 40, 40), 0, 0, 40, 40, System.Drawing.GraphicsUnit.Pixel, imageAttributes);
}
}
}
}
Loading

0 comments on commit f9e7649

Please sign in to comment.