Skip to content

Commit

Permalink
Group By Area and Hide unused icons
Browse files Browse the repository at this point in the history
Upgrade from 4.6.1 to 4.7.1 for Tuple ValueTypes
AJE now hides Characters
AC now hides everything except Characters
Add support for new sort option that groups entries by area over type
  • Loading branch information
gmjosack committed Jul 12, 2022
1 parent 87045de commit 209ca94
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>AchievementsTracker</RootNamespace>
<AssemblyName>SpelunkyRTATracker</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -76,6 +76,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Category.cs" />
<Compile Include="EntryType.cs" />
<Compile Include="ImgOrder.cs" />
<Compile Include="Achievement.cs" />
<Compile Include="GameManager.cs" />
<Compile Include="Http.cs" />
Expand Down
2 changes: 1 addition & 1 deletion AchievementsTracker/AchievementsTracker/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1"/>
</startup>
</configuration>
7 changes: 7 additions & 0 deletions AchievementsTracker/AchievementsTracker/EntryType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace AchievementsTracker
{
public enum EntryType
{
Character, Monster, Item, Trap
}
}
88 changes: 70 additions & 18 deletions AchievementsTracker/AchievementsTracker/ImgForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace AchievementsTracker
{
Expand All @@ -16,7 +17,8 @@ public partial class ImgForm : Form
int imageSize = 40;
int rows = 8;
bool inverted = false;
int[] CHAR_ORDER = { 2, 6, 7, 4, 9, 12, 11, 5, 1, 8, 14, 10, 13, 15, 3, 0 };
bool groupByArea = false;
Category category = Category.AA;

public ImgForm()
{
Expand Down Expand Up @@ -55,70 +57,120 @@ public void SetInverted(bool inv)
inverted = inv;
}

public void Reset()
public void changeCategory(Category cat)
{
ArrangeUnlockables();
category = cat;
}

public void SetGroupByArea(bool param)
{
groupByArea = param;
}

public void Reset()
{
foreach (Control c in Controls)
{
c.Show();
}
ArrangeUnlockables();

}

public void ArrangeUnlockables()
{
for (int i = 0; i < 120; i++)
Debug.WriteLine("Category: " + category.ToString());


int pos = 0;

var imgOrder = ImgOrder.DEFAULT;
if (groupByArea)
{
imgOrder = ImgOrder.BY_AREA;
}

foreach ((EntryType entryType, string name) in imgOrder)
{
// Get the right image box
Control picBox;
if (i < 16)

if (entryType == EntryType.Character)
{
picBox = Controls.Find("c" + CHAR_ORDER[i], false)[0];

picBox = Controls.Find(name, false)[0];
if (category != Category.AA && category != Category.AC)
{
picBox.Hide();
continue;
}
picBox.Show();
}
else if (i >= 16 && i < 72)
else if (entryType == EntryType.Monster)
{
picBox = Controls.Find("m" + (i - 16), false)[0];
picBox = Controls.Find(name, false)[0];
if (category != Category.AA && category != Category.AJE)
{
picBox.Hide();
continue;
}
picBox.Show();
}
else if (i >= 72 && i < 106)
else if (entryType == EntryType.Item)
{
picBox = Controls.Find("i" + (i - 72), false)[0];
picBox = Controls.Find(name, false)[0];
if (category != Category.AA && category != Category.AJE)
{
picBox.Hide();
continue;
}
picBox.Show();
}
else
{
picBox = Controls.Find("t" + (i - 106), false)[0];
picBox = Controls.Find(name, false)[0];
if (category != Category.AA && category != Category.AJE)
{
picBox.Hide();
continue;
}
picBox.Show();
}


// Position it accordingly
int xIdx;
int yIdx;
if (!inverted)
{
xIdx = (i / rows);
yIdx = (i % rows);
xIdx = (pos / rows);
yIdx = (pos % rows);
} else
{
xIdx = (i % rows);
yIdx = (i / rows);
xIdx = (pos % rows);
yIdx = (pos / rows);
}
int x = imageSize * xIdx;
int y = imageSize * yIdx;
picBox.Location = new Point(x, y);
picBox.Size = new Size(imageSize, imageSize);

pos++;
}

// Handle remainder
int remainder = 0;
if (120 % rows != 0)
if ((pos-1) % rows != 0)
{
remainder = 1;
}

if (inverted)
{
ClientSize = new Size(imageSize * rows, imageSize * (120 / rows + remainder));
ClientSize = new Size(imageSize * rows, imageSize * ((pos-1) / rows + remainder));
} else
{
ClientSize = new Size(imageSize * (120 / rows + remainder), imageSize * rows);
ClientSize = new Size(imageSize * ((pos-1) / rows + remainder), imageSize * rows);
}
}

Expand Down
Loading

0 comments on commit 209ca94

Please sign in to comment.