Skip to content

Commit 4b4d95f

Browse files
committed
Fixes for the bugs
Signed-off-by: Kláben Szabolcs Bence (Tudi20) <[email protected]>
1 parent aacc2a1 commit 4b4d95f

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

Universal THCRAP Launcher/Form1.cs

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,8 @@ private void Form1_Load(object sender, EventArgs e)
128128
checkBox1.Checked = Configuration1.ExitAfterStartup;
129129

130130
//Update Display favourites
131-
foreach (var variable in Favourites1.Patches)
132-
{
133-
var index = listBox1.FindStringExact(variable);
134-
listBox1.Items[index] += " ★";
135-
}
136-
137-
foreach (var variable in Favourites1.Games)
138-
{
139-
var index = listBox2.FindStringExact(variable);
140-
listBox2.Items[index] += " ★";
141-
}
131+
AddStars(listBox1, Favourites1.Patches);
132+
AddStars(listBox2, Favourites1.Games);
142133

143134
#endregion
144135

@@ -165,8 +156,15 @@ private void Form1_Load(object sender, EventArgs e)
165156
if (Configuration1.IsDescending[i] == "false")
166157
{
167158
if (i == 0)
159+
{
168160
SortListBoxItems(ref listBox1);
169-
else SortListBoxItems(ref listBox2);
161+
sort_az_button1.BackgroundImage = _sortDescending;
162+
}
163+
else
164+
{
165+
SortListBoxItems(ref listBox2);
166+
sort_az_button2.BackgroundImage = _sortDescending;
167+
}
170168
}
171169
else if (i == 0)
172170
{
@@ -182,6 +180,7 @@ private void Form1_Load(object sender, EventArgs e)
182180
//Default favourite button state
183181
for (var i = 0; i < 2; i++)
184182
if (Configuration1.OnlyFavourites[i] == "true")
183+
{
185184
if (i == 0)
186185
{
187186
star_button1.BackgroundImage = _starHollow;
@@ -202,6 +201,12 @@ private void Form1_Load(object sender, EventArgs e)
202201
listBox2.Items.RemoveAt(n);
203202
}
204203
}
204+
}
205+
else
206+
{
207+
if (i == 0) star_button1.BackgroundImage = _star;
208+
else star_button2.BackgroundImage = _star;
209+
}
205210

206211
//Default exe type button state
207212
filterByType_button.BackgroundImage = _gameAndCustom;
@@ -329,7 +334,7 @@ private void StartThcrap()
329334
/// <summary>
330335
/// Handles starting thcrap with enter and favouring when pressing f
331336
/// </summary>
332-
private new void KeyPress(object sender, KeyPressEventArgs e)
337+
private void KeyPress(object sender, KeyPressEventArgs e)
333338
{
334339
switch (e.KeyChar)
335340
{
@@ -435,14 +440,23 @@ private void sort_az_button2_Click(object sender, EventArgs e)
435440
ReadConfig();
436441
}
437442

443+
private static void AddStars(ListBox listBox, IEnumerable<string> list)
444+
{
445+
foreach (var variable in list)
446+
{
447+
var index = listBox.FindStringExact(variable);
448+
if (index != -1) listBox.Items[index] += " ★";
449+
}
450+
}
451+
438452
private void star_button1_Click(object sender, EventArgs e)
439453
{
440454
if (!star_button1.BackgroundImage.Equals(_starHollow))
441455
{
442456
star_button1.BackgroundImage = _starHollow;
443457
for (var n = listBox1.Items.Count - 1; n >= 0; --n)
444458
{
445-
var filterItem = "★";
459+
const char filterItem = '★';
446460
if (!listBox1.Items[n].ToString().Contains(filterItem))
447461
listBox1.Items.RemoveAt(n);
448462
}
@@ -455,11 +469,7 @@ private void star_button1_Click(object sender, EventArgs e)
455469
listBox1.Items.Clear();
456470
foreach (var s in _jsFiles) listBox1.Items.Add(s);
457471

458-
foreach (var variable in Favourites1.Patches)
459-
{
460-
var index = listBox1.FindStringExact(variable);
461-
listBox1.Items[index] += " ★";
462-
}
472+
AddStars(listBox1, Favourites1.Patches);
463473

464474
Configuration1.OnlyFavourites[0] = "false";
465475
ReadConfig();
@@ -486,11 +496,7 @@ private void star_button2_Click(object sender, EventArgs e)
486496
listBox2.Items.Clear();
487497
foreach (var s in _gamesList) listBox2.Items.Add(s);
488498

489-
foreach (var variable in Favourites1.Games)
490-
{
491-
var index = listBox2.FindStringExact(variable);
492-
listBox2.Items[index] += " ★";
493-
}
499+
AddStars(listBox2, Favourites1.Games);
494500

495501
Configuration1.OnlyFavourites[1] = "false";
496502
ReadConfig();
@@ -538,6 +544,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
538544
foreach (var item in _gamesList)
539545
if (!item.Contains("_custom"))
540546
listBox2.Items.Add(item);
547+
AddStars(listBox2, Favourites1.Games);
541548
return;
542549
}
543550

@@ -548,6 +555,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
548555
foreach (var item in _gamesList)
549556
if (item.Contains("_custom"))
550557
listBox2.Items.Add(item);
558+
AddStars(listBox2, Favourites1.Games);
551559
return;
552560
}
553561

@@ -556,6 +564,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
556564
filterByType_button.BackgroundImage = _gameAndCustom;
557565
listBox2.Items.Clear();
558566
foreach (var item in _gamesList) listBox2.Items.Add(item);
567+
AddStars(listBox2, Favourites1.Games);
559568
}
560569
}
561570
}

0 commit comments

Comments
 (0)