Skip to content

Commit

Permalink
Fixes for the bugs
Browse files Browse the repository at this point in the history
Signed-off-by: Kláben Szabolcs Bence (Tudi20) <[email protected]>
  • Loading branch information
lilyremigia committed Jan 13, 2019
1 parent aacc2a1 commit 4b4d95f
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions Universal THCRAP Launcher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,8 @@ private void Form1_Load(object sender, EventArgs e)
checkBox1.Checked = Configuration1.ExitAfterStartup;

//Update Display favourites
foreach (var variable in Favourites1.Patches)
{
var index = listBox1.FindStringExact(variable);
listBox1.Items[index] += " ★";
}

foreach (var variable in Favourites1.Games)
{
var index = listBox2.FindStringExact(variable);
listBox2.Items[index] += " ★";
}
AddStars(listBox1, Favourites1.Patches);
AddStars(listBox2, Favourites1.Games);

#endregion

Expand All @@ -165,8 +156,15 @@ private void Form1_Load(object sender, EventArgs e)
if (Configuration1.IsDescending[i] == "false")
{
if (i == 0)
{
SortListBoxItems(ref listBox1);
else SortListBoxItems(ref listBox2);
sort_az_button1.BackgroundImage = _sortDescending;
}
else
{
SortListBoxItems(ref listBox2);
sort_az_button2.BackgroundImage = _sortDescending;
}
}
else if (i == 0)
{
Expand All @@ -182,6 +180,7 @@ private void Form1_Load(object sender, EventArgs e)
//Default favourite button state
for (var i = 0; i < 2; i++)
if (Configuration1.OnlyFavourites[i] == "true")
{
if (i == 0)
{
star_button1.BackgroundImage = _starHollow;
Expand All @@ -202,6 +201,12 @@ private void Form1_Load(object sender, EventArgs e)
listBox2.Items.RemoveAt(n);
}
}
}
else
{
if (i == 0) star_button1.BackgroundImage = _star;
else star_button2.BackgroundImage = _star;
}

//Default exe type button state
filterByType_button.BackgroundImage = _gameAndCustom;
Expand Down Expand Up @@ -329,7 +334,7 @@ private void StartThcrap()
/// <summary>
/// Handles starting thcrap with enter and favouring when pressing f
/// </summary>
private new void KeyPress(object sender, KeyPressEventArgs e)
private void KeyPress(object sender, KeyPressEventArgs e)
{
switch (e.KeyChar)
{
Expand Down Expand Up @@ -435,14 +440,23 @@ private void sort_az_button2_Click(object sender, EventArgs e)
ReadConfig();
}

private static void AddStars(ListBox listBox, IEnumerable<string> list)
{
foreach (var variable in list)
{
var index = listBox.FindStringExact(variable);
if (index != -1) listBox.Items[index] += " ★";
}
}

private void star_button1_Click(object sender, EventArgs e)
{
if (!star_button1.BackgroundImage.Equals(_starHollow))
{
star_button1.BackgroundImage = _starHollow;
for (var n = listBox1.Items.Count - 1; n >= 0; --n)
{
var filterItem = "★";
const char filterItem = '★';
if (!listBox1.Items[n].ToString().Contains(filterItem))
listBox1.Items.RemoveAt(n);
}
Expand All @@ -455,11 +469,7 @@ private void star_button1_Click(object sender, EventArgs e)
listBox1.Items.Clear();
foreach (var s in _jsFiles) listBox1.Items.Add(s);

foreach (var variable in Favourites1.Patches)
{
var index = listBox1.FindStringExact(variable);
listBox1.Items[index] += " ★";
}
AddStars(listBox1, Favourites1.Patches);

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

foreach (var variable in Favourites1.Games)
{
var index = listBox2.FindStringExact(variable);
listBox2.Items[index] += " ★";
}
AddStars(listBox2, Favourites1.Games);

Configuration1.OnlyFavourites[1] = "false";
ReadConfig();
Expand Down Expand Up @@ -538,6 +544,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
foreach (var item in _gamesList)
if (!item.Contains("_custom"))
listBox2.Items.Add(item);
AddStars(listBox2, Favourites1.Games);
return;
}

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

Expand All @@ -556,6 +564,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
filterByType_button.BackgroundImage = _gameAndCustom;
listBox2.Items.Clear();
foreach (var item in _gamesList) listBox2.Items.Add(item);
AddStars(listBox2, Favourites1.Games);
}
}
}
Expand Down

0 comments on commit 4b4d95f

Please sign in to comment.