Skip to content

Commit

Permalink
Fixed games folder detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sp0ok3r committed Jul 31, 2021
1 parent 30ab73e commit 0e3037f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
24 changes: 17 additions & 7 deletions MercuryBOT/Helpers/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private static MetroStyleManager FindManager(IContainer contr, MetroForm owner)


#region "Refresh Notification Area Icons"

public const int WM_PAINT = 15;
[DllImport("USER32.DLL")]
public static extern int SendMessage(IntPtr hwnd, int msg, int character, IntPtr lpsText);
Expand Down Expand Up @@ -386,7 +386,7 @@ public static void RefreshTrayArea()
/// Returns the location of the CS:GO installation, or null if it's unable to find it. moritzuehling
/// </summary>
/// <returns></returns>
public static string GetCSGODir()
public static string GetCSGODir(bool getcs)
{
string steamPath = (string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", "");
string pathsFile = Path.Combine(steamPath, "steamapps", "libraryfolders.vdf");
Expand All @@ -411,18 +411,28 @@ public static string GetCSGODir()
libraries.Add(match.Replace("\\\\", "\\"));
}
}

foreach (var library in libraries)
if (getcs == true)
{
string csgoPath = Path.Combine(library, "steamapps\\common\\Counter-Strike Global Offensive\\csgo");
if (Directory.Exists(csgoPath))
foreach (var library in libraries)
{
return csgoPath;
string csgoPath = Path.Combine(library, "steamapps\\common\\Counter-Strike Global Offensive\\csgo");
if (Directory.Exists(csgoPath))
{
return csgoPath;
}
}
}
else
{
// libraries.RemoveAt(0);
return String.Join(",", libraries);
}

return null;
}



#endregion

}
Expand Down
17 changes: 10 additions & 7 deletions MercuryBOT/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void RefreshAccountList()
ApiWeb = false;
}

string[] row = { a.username, (a.SteamID).ToString(), "",(LoginK).ToString(), (ApiWeb).ToString() };
string[] row = { a.username, (a.SteamID).ToString(), "", (LoginK).ToString(), (ApiWeb).ToString() };

AccountsList_Grid.Rows.Add(row);

Expand Down Expand Up @@ -1935,13 +1935,16 @@ private void btn_folderGames_Click(object sender, EventArgs e)
{

// btn_folderGames.Enabled = true;
if (AccountLogin.IsLoggedIn == true)
{
Process.Start(Extensions.SteamLocation + @"/steamapps/common/");
}
else
if (Extensions.GetCSGODir(false) != null)//go to csgo folder
{
Process.Start(Extensions.SteamLocation + @"\steamapps\common");
List<string> result = Extensions.GetCSGODir(false).Split(',').ToList();
foreach (var a in result)
{
if (Directory.Exists(a + "\\steamapps\\common\\"))
{
Process.Start(a + "\\steamapps\\common\\");
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MercuryBOT/SteamCommunity/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Utils



File.WriteAllText(Program.ExecutablePath + @"\testo.html", resp);
// File.WriteAllText(Program.ExecutablePath + @"\testo.html", resp);


var document = new HtmlParser().ParseDocument(resp);
Expand Down
20 changes: 14 additions & 6 deletions MercuryBOT/SteamGroups/GatherSteamGroups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private void txtBox_groupidsFile_Click(object sender, EventArgs e)
private void btn_csgobind_Click(object sender, EventArgs e)
{
btn_csgobind.Enabled = false;

List<string> GroupsList = new List<string>();

int count = 1;// pervent alias bind bug
Expand Down Expand Up @@ -395,9 +396,9 @@ private void btn_csgobind_Click(object sender, EventArgs e)

using (var fbd = new FolderBrowserDialog())
{
if (Extensions.GetCSGODir() + "\\cfg" != null)//go to csgo folder
if (Extensions.GetCSGODir(true) + "\\cfg" != null)//go to csgo folder
{
fbd.SelectedPath = Extensions.GetCSGODir() + "\\cfg";
fbd.SelectedPath = Extensions.GetCSGODir(true) + "\\cfg";
}

DialogResult result = fbd.ShowDialog();
Expand All @@ -413,14 +414,21 @@ private void btn_csgobind_Click(object sender, EventArgs e)
}
}
Process.Start(fbd.SelectedPath + "/clantags.cfg");
//Process.Start(Extensions.GetCSGODir() + "/cfg");

btn_csgobind.Enabled = true;
GroupsList.Clear();

InfoForm.InfoHelper.CustomMessageBox.Show("Info", "Saved clantags.cfg! Now enter in csgo, open console and write \"exec clantags.cfg\" ,after this click on the key that you selected. Default(\"F11\").");
}
else
{
btn_csgobind.Enabled = true;
GroupsList.Clear();
return;
}

}
btn_csgobind.Enabled = true;
GroupsList.Clear();

InfoForm.InfoHelper.CustomMessageBox.Show("Info", "Saved clantags.cfg! Now enter in csgo, open console and write \"exec clantags.cfg\" ,after this click on the key that you selected. Default(\"F11\").");
}
}
}

0 comments on commit 0e3037f

Please sign in to comment.