Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some more config in extension.xml
- Loading branch information
Showing
5 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,95 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.IO; | |||
using Microsoft.Win32; | |||
|
|||
namespace MapLoader | |||
{ | |||
class PathFinder | |||
{ | |||
|
|||
private Dictionary<string, string> dictPathIdentifiers; | |||
|
|||
public PathFinder() | |||
{ | |||
dictPathIdentifiers = new Dictionary<string, string>(); | |||
} | |||
|
|||
/// <summary> | |||
/// Tries to find game pathes etc. in the registry or other places | |||
/// and stores them in a Dictionary. | |||
/// Must be called before pathes are accessed through GetPath. | |||
/// </summary> | |||
public void GatherPathes() | |||
{ | |||
// ======================================= | |||
// Misc | |||
// ======================================= | |||
string pathToProgramFiles = Environment.GetEnvironmentVariable("ProgramFiles"); | |||
string pathToTempFiles = Path.GetTempPath(); | |||
string pathToAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | |||
string pathToAppDataLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); | |||
string pathToDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); | |||
|
|||
dictPathIdentifiers.Add("%PROGRAM_FILES%", pathToProgramFiles); | |||
dictPathIdentifiers.Add("%TEMP%", pathToTempFiles); | |||
dictPathIdentifiers.Add("%APP_DATA%", pathToAppData); | |||
dictPathIdentifiers.Add("%APP_DATA_LOCAL%", pathToAppDataLocal); | |||
dictPathIdentifiers.Add("%DOCUMENTS%", pathToDocuments); | |||
|
|||
// ======================================= | |||
// STARCRAFT II | |||
// ======================================= | |||
// Install Path | |||
string pathToStarcraft2Folder = ""; | |||
|
|||
// 1. Try Registry | |||
pathToStarcraft2Folder = GetRegistryValueFromLocalMachine("Software\\Blizzard Entertainment\\Starcraft II", "InstallPath"); | |||
|
|||
// 2. Try Default Path | |||
if (pathToStarcraft2Folder == "") | |||
{ | |||
string defaultPath = pathToProgramFiles + "/" + "StarCraft II/"; | |||
if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = defaultPath; | |||
} | |||
|
|||
// 3. Try Default Path (Beta) | |||
if (pathToStarcraft2Folder == "") | |||
{ | |||
string defaultPath = pathToProgramFiles + "/" + "StarCraft II Beta/"; | |||
if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = defaultPath; | |||
} | |||
|
|||
dictPathIdentifiers.Add("%SC2_INSTALL_PATH%", pathToStarcraft2Folder); | |||
} | |||
|
|||
|
|||
public string GetPath(string pathIdentifier) | |||
{ | |||
if (dictPathIdentifiers.ContainsKey(pathIdentifier)) return dictPathIdentifiers[pathIdentifier]; | |||
else return ""; | |||
} | |||
|
|||
|
|||
|
|||
|
|||
private string GetRegistryValueFromLocalMachine(string key, string value) | |||
{ | |||
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(key); | |||
string retVal = ""; | |||
if (registryKey != null) | |||
{ | |||
retVal = registryKey.GetValue(value).ToString(); | |||
} | |||
else | |||
{ | |||
retVal = ""; | |||
} | |||
registryKey.Close(); | |||
return retVal; | |||
} | |||
|
|||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,4 @@ | |||
<extension type="s2ma"> | <extension type="s2replay"> | ||
<default>C:\Nibbits</default> | <default>%DOCUMENTS%\Starcraft II Beta\Replays\Multiplayer\Recent</default> | ||
<windows7>%DOCUMENTS%\Starcraft II Beta\Replays\Multiplayer\Recent</windows7> | |||
</extension> | </extension> |