Skip to content

Commit

Permalink
Enable combo boxes on Read, do cleanup, comment out broken listview s…
Browse files Browse the repository at this point in the history
…elect
  • Loading branch information
hbivnm committed Feb 20, 2023
1 parent b35e4be commit 3ed6983
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions VenomCrosshairs/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ private void btnReadConfig_Click(object sender, EventArgs e)
MessageBox.Show("No Venom Crosshairs config folder found!\n\nMake sure your custom crosshair folder is named \"" + VC_CONFIG_NAME + "\".", "Venom Crosshairs - Failed to read current config", MessageBoxButtons.OK, MessageBoxIcon.Error);
writeLineToDebugger("Failed!");
}
cbClass.Enabled = true;
cbWeapon.Enabled = true;
cbCrosshair.Enabled = true;
pictureBoxLoading.Visible = false;
}

Expand Down Expand Up @@ -440,11 +443,22 @@ private void onCheckBoxAddClassWeaponsChangeEvent(object sender, EventArgs e)
}
}

private void onCBExplosionEffectChangeEvent(object server, EventArgs e)
private void onCBExplosionEffectChangeEvent(object sender, EventArgs e)
{
File.WriteAllText(PATH_VC_RESOURCES_VC_EXPLOSION_EFFECT_CFG_FILE, Convert.ToString(cbExplosionEffect.SelectedIndex));
}

//private void onListViewChosenCrosshairSelect(object sender, EventArgs e) // TODO: Select from ListView
//{
// if (this.listViewChosenCrosshairs.SelectedItems.Count == 1)
// {
// writeLineToDebugger(this.listViewChosenCrosshairs.SelectedItems[0].SubItems[1].Text);
// cbClass.Text = "";
// cbWeapon.Text = this.listViewChosenCrosshairs.SelectedItems[0].SubItems[1].Text;
// cbCrosshair.Text = this.listViewChosenCrosshairs.SelectedItems[0].SubItems[0].Text;
// }
//}

private void onFormLoad(object sender, EventArgs e)
{
// Fetch public crosshairs, if new crosshairs are available -> prompt user
Expand Down Expand Up @@ -488,6 +502,7 @@ private void initVC()
// ListView
listViewChosenCrosshairs.Columns.Add("Crosshair", 220);
listViewChosenCrosshairs.Columns.Add("Weapon", 599);
//listViewChosenCrosshairs.SelectedIndexChanged += new EventHandler(onListViewChosenCrosshairSelect); TODO: Select from ListView

// Hide console
if (showConsole)
Expand All @@ -508,6 +523,7 @@ private void initVC()
// Read user settings
// Explosion effect
if (File.Exists(PATH_VC_RESOURCES_VC_EXPLOSION_EFFECT_CFG_FILE))
{
try
{
cbExplosionEffect.SelectedIndex = Convert.ToInt32(File.ReadAllText(PATH_VC_RESOURCES_VC_EXPLOSION_EFFECT_CFG_FILE));
Expand All @@ -517,8 +533,11 @@ private void initVC()
MessageBox.Show($"User setting file for \"Explosion effect\" could not be parsed to an Integer.\n\nExplosion effect restored to default.\n\nFor developer: Exception: {ex.Message}", "Venom Crosshairs - Could not parse user setting: Explosion effect", MessageBoxButtons.OK, MessageBoxIcon.Error);
File.Delete(PATH_VC_RESOURCES_VC_EXPLOSION_EFFECT_CFG_FILE);
}
}
else
{
cbExplosionEffect.SelectedIndex = 0;
}
cbExplosionEffect.SelectedIndexChanged += new EventHandler(onCBExplosionEffectChangeEvent);

// User TF2 path
Expand Down Expand Up @@ -897,11 +916,12 @@ private void performInstallation(bool removeOldConfig)
string fullScriptPath = $@"{textBoxTF2Path.Text}\tf\custom\{VC_CONFIG_NAME}\scripts\{weaponScriptName}";

if (File.Exists(fullScriptPath))
{
File.Delete(fullScriptPath);
}

try
{

File.WriteAllText(
$@"{textBoxTF2Path.Text}\tf\custom\{VC_CONFIG_NAME}\scripts\{weaponScriptName}",
File.ReadAllText($@"{PATH_VC_RESOURCES_SCRIPTS}\{weaponScriptName}")
Expand All @@ -922,9 +942,13 @@ private void performInstallation(bool removeOldConfig)
doVPKCheck();

if (!isUpdate)
{
writeLineToDebugger("Venom Crosshairs config successfully installed!");
}
else
{
writeLineToDebugger("Venom Crosshairs config successfully updated!");
}

Invoke(new MethodInvoker(delegate ()
{
Expand Down Expand Up @@ -1336,7 +1360,6 @@ private void setDarkModeTheme(bool darkMode)
}
}
}

File.WriteAllText(PATH_VC_RESOURCES_VC_USERTHEME_CFG_FILE, darkMode.ToString());
}

Expand Down

0 comments on commit 3ed6983

Please sign in to comment.