Skip to content

Commit aacc2a1

Browse files
committed
Make the button work
Signed-off-by: Kláben Szabolcs Bence (Tudi20) <[email protected]>
1 parent 063d1e7 commit aacc2a1

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

Universal THCRAP Launcher/Form1.cs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ namespace Universal_THCRAP_Launcher
1313
public partial class Form1 : Form
1414
{
1515
private const string ConfigFile = "utl_config.js";
16+
private readonly Image _custom = new Bitmap(Resources.Custom);
17+
private readonly Image _game = new Bitmap(Resources.Game);
18+
19+
private readonly Image _gameAndCustom = new Bitmap(Resources.GameAndCustom);
1620
private readonly List<string> _gamesList = new List<string>();
1721

1822
private readonly Image _sortAscending = new Bitmap(Resources.Sort_Ascending);
@@ -154,6 +158,8 @@ private void Form1_Load(object sender, EventArgs e)
154158

155159
#endregion
156160

161+
#region Set default state for the sort/filter buttons
162+
157163
//Default sort
158164
for (var i = 0; i < 2; i++)
159165
if (Configuration1.IsDescending[i] == "false")
@@ -197,6 +203,11 @@ private void Form1_Load(object sender, EventArgs e)
197203
}
198204
}
199205

206+
//Default exe type button state
207+
filterByType_button.BackgroundImage = _gameAndCustom;
208+
209+
#endregion
210+
200211
Debug.WriteLine("Form1 Loaded");
201212
}
202213

@@ -385,7 +396,8 @@ private void Form1_Resize(object sender, EventArgs e)
385396
star_button2.Location.X + _resizeConstants[8], filterByType_button.Location.Y);
386397
}
387398

388-
private void label1_Click(object sender, EventArgs e) => Process.Start("https://github.com/Tudi20/Universal-THCRAP-Launcher");
399+
private void label1_Click(object sender, EventArgs e) =>
400+
Process.Start("https://github.com/Tudi20/Universal-THCRAP-Launcher");
389401

390402
private void sort_az_button1_Click(object sender, EventArgs e)
391403
{
@@ -461,7 +473,7 @@ private void star_button2_Click(object sender, EventArgs e)
461473
star_button2.BackgroundImage = _starHollow;
462474
for (var n = listBox2.Items.Count - 1; n >= 0; --n)
463475
{
464-
var filterItem = "★";
476+
const string filterItem = "★";
465477
if (!listBox2.Items[n].ToString().Contains(filterItem))
466478
listBox2.Items.RemoveAt(n);
467479
}
@@ -514,11 +526,37 @@ private void SelectedIndexChanged(object sender, EventArgs e)
514526
}
515527
}
516528

517-
private void checkBox1_CheckedChanged(object sender, EventArgs e) => Configuration1.ExitAfterStartup = checkBox1.Checked;
529+
private void checkBox1_CheckedChanged(object sender, EventArgs e) =>
530+
Configuration1.ExitAfterStartup = checkBox1.Checked;
518531

519532
private void filterByType_button_Click(object sender, EventArgs e)
520533
{
534+
if (filterByType_button.BackgroundImage.Equals(_gameAndCustom))
535+
{
536+
filterByType_button.BackgroundImage = _game;
537+
listBox2.Items.Clear();
538+
foreach (var item in _gamesList)
539+
if (!item.Contains("_custom"))
540+
listBox2.Items.Add(item);
541+
return;
542+
}
521543

544+
if (filterByType_button.BackgroundImage.Equals(_game))
545+
{
546+
filterByType_button.BackgroundImage = _custom;
547+
listBox2.Items.Clear();
548+
foreach (var item in _gamesList)
549+
if (item.Contains("_custom"))
550+
listBox2.Items.Add(item);
551+
return;
552+
}
553+
554+
if (!filterByType_button.BackgroundImage.Equals(_custom)) return;
555+
{
556+
filterByType_button.BackgroundImage = _gameAndCustom;
557+
listBox2.Items.Clear();
558+
foreach (var item in _gamesList) listBox2.Items.Add(item);
559+
}
522560
}
523561
}
524562

0 commit comments

Comments
 (0)