Permalink
Browse files

Various cleanups

  • Loading branch information...
1 parent d2a6e59 commit 18610ae34f8f724b513d28746046007886d84b4c Sagu committed Apr 6, 2010
View
4 .gitignore
@@ -26,4 +26,6 @@ Thumbs.db
obj/
[Rr]elease*/
_ReSharper*/
-[Tt]est[Rr]esult*
+[Tt]est[Rr]esult*
+UpgradeLog.XML
+_UpgradeReport_Files/*
View
4 MapLoader.sln
@@ -1,6 +1,6 @@

-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual C# Express 2008
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapLoader", "MapLoader\MapLoader.csproj", "{B0D33570-5487-4F92-AC9F-D568215045BA}"
EndProject
Global
View
47 MapLoader/ExtensionConfiguration.cs
@@ -11,15 +11,15 @@ namespace Nibbler
class ExtensionConfiguration
{
- private Dictionary<string, Extension> dictExtConfiguration;
+ private readonly Dictionary<string, Extension> _dictExtConfiguration;
/// <summary>
/// Checks if there's an action defined for this extension
/// </summary>
/// <returns></returns>
public bool IsValidExtension(string extension)
{
- return dictExtConfiguration.ContainsKey(extension);
+ return _dictExtConfiguration.ContainsKey(extension);
}
@@ -31,34 +31,34 @@ public bool IsValidExtension(string extension)
public string GetCopyPathForExtension(string extension) {
// check if we have something for this extension in store
- if (!dictExtConfiguration.ContainsKey(extension.ToLower())) return "";
+ if (!_dictExtConfiguration.ContainsKey(extension.ToLower())) return "";
- Extension currentExtension = dictExtConfiguration[extension.ToLower()];
+ Extension currentExtension = _dictExtConfiguration[extension.ToLower()];
// Determining OS
- OperatingSystem os = System.Environment.OSVersion;
- Version osVersion = os.Version;
+ var os = Environment.OSVersion;
+ var osVersion = os.Version;
// good ol' Xp
if (osVersion.Major == 5)
{
- if (currentExtension.dictActionsPerOS.ContainsKey("xp")) return currentExtension.dictActionsPerOS["xp"];
- else return currentExtension.dictActionsPerOS["default"];
+ if (currentExtension.DictActionsPerOs.ContainsKey("xp")) return currentExtension.DictActionsPerOs["xp"];
+ else return currentExtension.DictActionsPerOs["default"];
}
// Windows Vista
else if (osVersion.Major == 6 && osVersion.Minor == 0)
{
- if (currentExtension.dictActionsPerOS.ContainsKey("vista")) return currentExtension.dictActionsPerOS["vista"];
- else return currentExtension.dictActionsPerOS["default"];
+ if (currentExtension.DictActionsPerOs.ContainsKey("vista")) return currentExtension.DictActionsPerOs["vista"];
+ else return currentExtension.DictActionsPerOs["default"];
}
// Windows 7
else if (osVersion.Major == 6 && osVersion.Minor == 1)
{
- if (currentExtension.dictActionsPerOS.ContainsKey("windows7")) return currentExtension.dictActionsPerOS["windows7"];
- else return currentExtension.dictActionsPerOS["default"];
+ if (currentExtension.DictActionsPerOs.ContainsKey("windows7")) return currentExtension.DictActionsPerOs["windows7"];
+ else return currentExtension.DictActionsPerOs["default"];
}
- return currentExtension.dictActionsPerOS["default"];
+ return currentExtension.DictActionsPerOs["default"];
}
@@ -67,19 +67,19 @@ public bool IsValidExtension(string extension)
/// </summary>
class Extension
{
- public string ExtensionName;
- public Dictionary<string, string> dictActionsPerOS;
+ public readonly string ExtensionName;
+ public readonly Dictionary<string, string> DictActionsPerOs;
public Extension(string name)
{
- this.ExtensionName = name;
- dictActionsPerOS = new Dictionary<string, string>();
+ ExtensionName = name;
+ DictActionsPerOs = new Dictionary<string, string>();
}
}
public ExtensionConfiguration()
{
- dictExtConfiguration = new Dictionary<string, Extension>();
+ _dictExtConfiguration = new Dictionary<string, Extension>();
}
/// <summary>
@@ -88,7 +88,7 @@ public ExtensionConfiguration()
public void ReadConfig()
{
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
- XmlTextReader reader = new XmlTextReader( appPath + "/extensions.xml");
+ var reader = new XmlTextReader( appPath + "/extensions.xml");
Extension currentExtension = null;
@@ -109,8 +109,13 @@ public void ReadConfig()
currentAction = reader.Value;
break;
case XmlNodeType.EndElement:
- if (reader.Name == "extension") dictExtConfiguration.Add(currentExtension.ExtensionName, currentExtension);
- else currentExtension.dictActionsPerOS.Add(reader.Name, currentAction);
+ if (currentExtension != null)
+ {
+ if (reader.Name == "extension") _dictExtConfiguration.Add(currentExtension.ExtensionName, currentExtension);
+ else currentExtension.DictActionsPerOs.Add(reader.Name, currentAction);
+ }
+ else
+ throw new XmlException("Malformed XML");
break;
}
}
View
8 MapLoader/LoaderConfig.Designer.cs
@@ -100,7 +100,7 @@ private void InitializeComponent()
this.btn_sc1dir.TabIndex = 6;
this.btn_sc1dir.Text = "Change";
this.btn_sc1dir.UseVisualStyleBackColor = true;
- this.btn_sc1dir.Click += new System.EventHandler(this.btn_sc1dir_Click);
+ this.btn_sc1dir.Click += new System.EventHandler(this.BtnSc1DirClick);
//
// btn_sc2dir
//
@@ -110,7 +110,7 @@ private void InitializeComponent()
this.btn_sc2dir.TabIndex = 7;
this.btn_sc2dir.Text = "Change";
this.btn_sc2dir.UseVisualStyleBackColor = true;
- this.btn_sc2dir.Click += new System.EventHandler(this.btn_sc2dir_Click);
+ this.btn_sc2dir.Click += new System.EventHandler(this.BtnSc2DirClick);
//
// btn_wc3dir
//
@@ -120,7 +120,7 @@ private void InitializeComponent()
this.btn_wc3dir.TabIndex = 8;
this.btn_wc3dir.Text = "Change";
this.btn_wc3dir.UseVisualStyleBackColor = true;
- this.btn_wc3dir.Click += new System.EventHandler(this.btn_wc3dir_Click);
+ this.btn_wc3dir.Click += new System.EventHandler(this.BtnWc3DirClick);
//
// btn_ok
//
@@ -130,7 +130,7 @@ private void InitializeComponent()
this.btn_ok.TabIndex = 9;
this.btn_ok.Text = "OK";
this.btn_ok.UseVisualStyleBackColor = true;
- this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
+ this.btn_ok.Click += new System.EventHandler(this.BtnOkClick);
//
// openFileDialog1
//
View
42 MapLoader/LoaderConfig.cs
@@ -12,21 +12,21 @@ namespace Nibbler
{
public partial class LoaderConfig : Form
{
- ExtensionConfiguration extConf;
- PathFinder pathFinder;
+ ExtensionConfiguration _extConf;
+ PathFinder _pathFinder;
public LoaderConfig()
{
InitializeComponent();
}
- private void btn_ok_Click(object sender, EventArgs e)
+ private void BtnOkClick(object sender, EventArgs e)
{
- ClientSettings.Default.SC1_INSTALL_PATH = tb_sc1dir.Text;
- ClientSettings.Default.SC2_INSTALL_PATH = tb_sc2dir.Text;
- ClientSettings.Default.WC3_INSTALL_PATH = tb_wc3dir.Text;
- ClientSettings.Default.Save();
- this.Close();
+ Properties.Client.Default.SC1_INSTALL_PATH = tb_sc1dir.Text;
+ Properties.Client.Default.SC2_INSTALL_PATH = tb_sc2dir.Text;
+ Properties.Client.Default.WC3_INSTALL_PATH = tb_wc3dir.Text;
+ Properties.Client.Default.Save();
+ Close();
// Application.Exit();
}
@@ -35,38 +35,38 @@ private void Formsetup_Load(object sender, EventArgs e)
// ==========================================================
// Reading XML Extension Config
// ==========================================================
- extConf = new ExtensionConfiguration();
- extConf.ReadConfig();
+ _extConf = new ExtensionConfiguration();
+ _extConf.ReadConfig();
// ==========================================================
// Find Pathes for Game Folders etc.
// ==========================================================
- pathFinder = new PathFinder();
- pathFinder.GatherPathes();
+ _pathFinder = new PathFinder();
+ _pathFinder.GatherPathes();
//Check if we know our dirs
- tb_sc1dir.Text = pathFinder.GetPath("%SC1_INSTALL_PATH%");
+ tb_sc1dir.Text = _pathFinder.GetPath("%SC1_INSTALL_PATH%");
- tb_sc2dir.Text = pathFinder.GetPath("%SC2_INSTALL_PATH%");
+ tb_sc2dir.Text = _pathFinder.GetPath("%SC2_INSTALL_PATH%");
- tb_wc3dir.Text = pathFinder.GetPath("%WC3_INSTALL_PATH%");
+ tb_wc3dir.Text = _pathFinder.GetPath("%WC3_INSTALL_PATH%");
}
- private void btn_sc1dir_Click(object sender, EventArgs e)
+ private void BtnSc1DirClick(object sender, EventArgs e)
{
- string sc1 = pathFinder.QueryUserForPath(this, "%SC1_INSTALL_PATH%");
+ string sc1 = _pathFinder.QueryUserForPath(this, "%SC1_INSTALL_PATH%");
tb_sc1dir.Text = sc1;
}
- private void btn_sc2dir_Click(object sender, EventArgs e)
+ private void BtnSc2DirClick(object sender, EventArgs e)
{
- string sc2 = pathFinder.QueryUserForPath(this, "%SC2_INSTALL_PATH%");
+ string sc2 = _pathFinder.QueryUserForPath(this, "%SC2_INSTALL_PATH%");
tb_sc2dir.Text = sc2;
}
- private void btn_wc3dir_Click(object sender, EventArgs e)
+ private void BtnWc3DirClick(object sender, EventArgs e)
{
- string wc3 = pathFinder.QueryUserForPath(this, "%WC3_INSTALL_PATH%");
+ string wc3 = _pathFinder.QueryUserForPath(this, "%WC3_INSTALL_PATH%");
tb_wc3dir.Text = wc3;
}
}
View
71 MapLoader/LoaderForm.cs
@@ -8,45 +8,43 @@
using System.Windows.Forms;
using System.Net;
using System.IO;
-using Microsoft.Win32;
using System.Threading;
namespace Nibbler
{
public partial class LoaderForm : Form
{
- ExtensionConfiguration extConf;
- PathFinder pathFinder;
- Uri fileUri;
- string fileLink;
+ ExtensionConfiguration _extConf;
+ PathFinder _pathFinder;
+ Uri _fileUri;
+ readonly string _fileLink;
public LoaderForm(string fileLink)
{
- this.fileLink = fileLink;
- InitializeComponent();
+ _fileLink = fileLink;
+ InitializeComponent();
}
private void LoaderForm_Load(object sender, EventArgs e)
{
// ==========================================================
// Reading XML Extension Config
// ==========================================================
- extConf = new ExtensionConfiguration();
- extConf.ReadConfig();
+ _extConf = new ExtensionConfiguration();
+ _extConf.ReadConfig();
// ==========================================================
// Find Pathes for Game Folders etc.
// ==========================================================
- pathFinder = new PathFinder();
- pathFinder.GatherPathes();
+ _pathFinder = new PathFinder();
+ _pathFinder.GatherPathes();
// ==========================================================
// Start Download
// ==========================================================
- WebRequest wrGETURL;
- wrGETURL = WebRequest.Create(this.fileLink);
+ WebRequest wrGeturl = WebRequest.Create(_fileLink);
- HttpWebResponse resp = (HttpWebResponse)wrGETURL.GetResponse();
+ var resp = (HttpWebResponse)wrGeturl.GetResponse();
int statusCode = (int)resp.StatusCode;
// ==========================================================
@@ -55,11 +53,11 @@ private void LoaderForm_Load(object sender, EventArgs e)
if (statusCode == 200)
{
// Construct URI
- fileUri = resp.ResponseUri;
+ _fileUri = resp.ResponseUri;
// ==========================================================
// Check Extension
// ==========================================================
- string fileName = fileUri.Segments[fileUri.Segments.Length - 1].Replace('+', ' ');
+ string fileName = _fileUri.Segments[_fileUri.Segments.Length - 1].Replace('+', ' ');
string extension = Path.GetExtension(fileName);
if (string.IsNullOrEmpty(extension))
@@ -70,12 +68,12 @@ private void LoaderForm_Load(object sender, EventArgs e)
extension = extension.ToLower().Substring(1);
- if (extConf.IsValidExtension(extension))
+ if (_extConf.IsValidExtension(extension))
{
lblFilename.Text = fileName; // Display filename
//ask user if they want to download file
- if (MessageBox.Show("Do you want to download " + fileName + "?", "Confirm download", MessageBoxButtons.YesNo) == DialogResult.Yes)
+ if (MessageBox.Show(string.Format("Do you want to download {0}?",fileName), "Confirm download", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// a 'DialogResult.Yes' value was returned from the MessageBox
bgWorker.RunWorkerAsync();
@@ -108,30 +106,30 @@ private void LoaderForm_Load(object sender, EventArgs e)
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
// the URL to download the file from
- string sUrlToReadFileFrom = fileUri.OriginalString;
+ string sUrlToReadFileFrom = _fileUri.OriginalString;
// the path to write the file to
- string fileName = fileUri.Segments[fileUri.Segments.Length - 1].Replace('+', ' ');
+ string fileName = _fileUri.Segments[_fileUri.Segments.Length - 1].Replace('+', ' ');
string sFilePathToWriteFileTo = Path.GetTempPath() + "/" + fileName;
// first, we need to get the exact size (in bytes) of the file we are downloading
- Uri url = new Uri(sUrlToReadFileFrom);
- System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
- System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
+ var url = new Uri(sUrlToReadFileFrom);
+ var request = (HttpWebRequest)WebRequest.Create(url);
+ var response = (HttpWebResponse)request.GetResponse();
response.Close();
// gets the size of the file in bytes
- Int64 iSize = response.ContentLength;
+ long iSize = response.ContentLength;
// keeps track of the total bytes downloaded so we can update the progress bar
- Int64 iRunningByteTotal = 0;
+ long iRunningByteTotal = 0;
// use the webclient object to download the file
- using (System.Net.WebClient client = new System.Net.WebClient())
+ using (var client = new WebClient())
{
// open the file at the remote URL for reading
- using (System.IO.Stream streamRemote = client.OpenRead(new Uri(sUrlToReadFileFrom)))
+ using (var streamRemote = client.OpenRead(new Uri(sUrlToReadFileFrom)))
{
// using the FileStream object, we can write the downloaded bytes to the file system
- using (Stream streamLocal = new FileStream(sFilePathToWriteFileTo, FileMode.Create, FileAccess.Write, FileShare.None))
+ using (var streamLocal = new FileStream(sFilePathToWriteFileTo, FileMode.Create, FileAccess.Write, FileShare.None))
{
// loop the stream and get the file into the byte buffer
int iByteSize = 0;
@@ -143,8 +141,8 @@ private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
iRunningByteTotal += iByteSize;
// calculate the progress out of a base "100"
- double dIndex = (double)(iRunningByteTotal);
- double dTotal = (double)byteBuffer.Length;
+ double dIndex = iRunningByteTotal;
+ double dTotal = byteBuffer.Length;
double dProgressPercentage = (dIndex / dTotal);
int iProgressPercentage = (int)(dProgressPercentage * 100);
@@ -176,11 +174,11 @@ private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
// ==========================================================
private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
- string fileName = fileUri.Segments[fileUri.Segments.Length - 1].Replace('+', ' ');
+ string fileName = _fileUri.Segments[_fileUri.Segments.Length - 1].Replace('+', ' ');
string extension = Path.GetExtension(fileName).ToLower().Substring(1);
// Move
- string moveTo = extConf.GetCopyPathForExtension(extension);
+ string moveTo = _extConf.GetCopyPathForExtension(extension);
// Construct Path
while (moveTo.IndexOf("%") != -1)
@@ -201,7 +199,7 @@ private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventA
// to the real Path
// ==============================================
// 1. Check if PathFinder know our Path
- string realPath = pathFinder.GetPath(pathIdentfier);
+ string realPath = _pathFinder.GetPath(pathIdentfier);
@@ -211,12 +209,12 @@ private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventA
if (MessageBox.Show("Missing installation path for " + fileName + ". Would you like configure Nibbler now?", "No path found!", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// open setup if user say yes
- System.Threading.Thread setup = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
+ Thread setup = new Thread(ThreadProc);
setup.SetApartmentState(ApartmentState.STA);
setup.Start();
setup.Join();
- realPath = pathFinder.GetPath(pathIdentfier);
+ realPath = _pathFinder.GetPath(pathIdentfier);
}
}
@@ -231,8 +229,7 @@ private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventA
if (string.IsNullOrEmpty(moveTo))
{
- SaveFileDialog fileDialog = new SaveFileDialog();
- fileDialog.FileName = fileName;
+ var fileDialog = new SaveFileDialog {FileName = fileName};
if (fileDialog.ShowDialog() == DialogResult.OK)
{
moveTo = fileDialog.FileName.Replace("\\" + fileName, "");
View
16 MapLoader/MapLoader.csproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -15,6 +15,10 @@
<StartupObject>
</StartupObject>
<ApplicationIcon>nibbits.ico</ApplicationIcon>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>4.0</OldToolsVersion>
+ <UpgradeBackupLocation />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -24,6 +28,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -32,6 +37,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -51,10 +57,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="ClientSettings.Designer.cs">
+ <Compile Include="Properties\Client.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
- <DependentUpon>ClientSettings.settings</DependentUpon>
+ <DependentUpon>Client.settings</DependentUpon>
</Compile>
<Compile Include="ExtensionConfiguration.cs" />
<Compile Include="LoaderForm.cs">
@@ -92,9 +98,9 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
- <None Include="ClientSettings.settings">
+ <None Include="Properties\Client.settings">
<Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>ClientSettings.Designer.cs</LastGenOutput>
+ <LastGenOutput>Client.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
View
106 MapLoader/PathFinder.cs
@@ -17,11 +17,11 @@ namespace Nibbler
class PathFinder
{
- public Dictionary<string, string> dictPathIdentifiers;
+ public Dictionary<string, string> DictPathIdentifiers;
public PathFinder()
{
- dictPathIdentifiers = new Dictionary<string, string>();
+ DictPathIdentifiers = new Dictionary<string, string>();
}
/// <summary>
@@ -40,26 +40,27 @@ public void GatherPathes()
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);
+ 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 + add modifyregistry
- if (string.IsNullOrEmpty(ClientSettings.Default.SC2_INSTALL_PATH))
+ if (string.IsNullOrEmpty(Properties.Client.Default.SC2_INSTALL_PATH))
{
- string pathToStarcraft2Folder = "";
- ModifyRegistry mysc2Registry = new ModifyRegistry();
- mysc2Registry.SubKey = "Software\\Blizzard Entertainment\\Starcraft II\\";
- mysc2Registry.ShowError = true;
+ var mysc2Registry = new ModifyRegistry
+ {
+ SubKey = "Software\\Blizzard Entertainment\\Starcraft II\\",
+ ShowError = true
+ };
// 1a. Try Registry LocalMachine
- pathToStarcraft2Folder = mysc2Registry.Read("InstallPath");
+ string pathToStarcraft2Folder = mysc2Registry.Read("InstallPath");
// 1b. Try Registry CurrentUser
if (string.IsNullOrEmpty(pathToStarcraft2Folder))
@@ -76,8 +77,8 @@ public void GatherPathes()
// 2. Try Default Path
if (string.IsNullOrEmpty(pathToStarcraft2Folder))
{
- string sc2_defaultPath = pathToProgramFiles + "/" + "StarCraft II/";
- if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = sc2_defaultPath;
+ string sc2DefaultPath = pathToProgramFiles + "/" + "StarCraft II/";
+ if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = sc2DefaultPath;
}
// 3. Try Default Path (Beta)
@@ -93,24 +94,25 @@ public void GatherPathes()
pathToStarcraft2Folder = "";
}
- ClientSettings.Default.SC2_INSTALL_PATH = pathToStarcraft2Folder;
+ Properties.Client.Default.SC2_INSTALL_PATH = pathToStarcraft2Folder;
}
- dictPathIdentifiers.Add("%SC2_INSTALL_PATH%", ClientSettings.Default.SC2_INSTALL_PATH);
+ DictPathIdentifiers.Add("%SC2_INSTALL_PATH%", Properties.Client.Default.SC2_INSTALL_PATH);
// =======================================
// STARCRAFT I
// =======================================
- if (string.IsNullOrEmpty(ClientSettings.Default.SC1_INSTALL_PATH))
+ if (string.IsNullOrEmpty(Properties.Client.Default.SC1_INSTALL_PATH))
{
- string pathToStarcraft1Folder = "";
- ModifyRegistry mysc1Registry = new ModifyRegistry();
- mysc1Registry.SubKey = "Software\\Blizzard Entertainment\\Starcraft\\";
- mysc1Registry.ShowError = true;
+ var mysc1Registry = new ModifyRegistry
+ {
+ SubKey = "Software\\Blizzard Entertainment\\Starcraft\\",
+ ShowError = true
+ };
// 1a. Try Registry LocalMachine (no idea if localmachine is used, dont think so, but i let it stay)
- pathToStarcraft1Folder = mysc1Registry.Read("InstallPath");
+ string pathToStarcraft1Folder = mysc1Registry.Read("InstallPath");
// 1b. Try Registry CurrentUser
if (string.IsNullOrEmpty(pathToStarcraft1Folder))
@@ -127,34 +129,35 @@ public void GatherPathes()
// 2. Try Default Path
if (string.IsNullOrEmpty(pathToStarcraft1Folder))
{
- string sc1_defaultPath = pathToProgramFiles + "/" + "StarCraft/";
+ string sc1DefaultPath = pathToProgramFiles + "/" + "StarCraft/";
- if (File.Exists(pathToProgramFiles + "StarCraft.exe")) pathToStarcraft1Folder = sc1_defaultPath;
+ if (File.Exists(pathToProgramFiles + "StarCraft.exe")) pathToStarcraft1Folder = sc1DefaultPath;
}
// 3. Default to empty path
if (string.IsNullOrEmpty(pathToStarcraft1Folder))
{
pathToStarcraft1Folder = "";
}
- ClientSettings.Default.SC1_INSTALL_PATH = pathToStarcraft1Folder;
+ Properties.Client.Default.SC1_INSTALL_PATH = pathToStarcraft1Folder;
}
- dictPathIdentifiers.Add("%SC1_INSTALL_PATH%", ClientSettings.Default.SC1_INSTALL_PATH);
+ DictPathIdentifiers.Add("%SC1_INSTALL_PATH%", Properties.Client.Default.SC1_INSTALL_PATH);
//=====================
//Warcraft 3
//=====================
- if (string.IsNullOrEmpty(ClientSettings.Default.WC3_INSTALL_PATH))
+ if (string.IsNullOrEmpty(Properties.Client.Default.WC3_INSTALL_PATH))
{
- string pathToWarcraft3Folder = "";
- ModifyRegistry mywc3Registry = new ModifyRegistry();
- mywc3Registry.SubKey = "Software\\Blizzard Entertainment\\Warcraft III\\";
- mywc3Registry.ShowError = true;
+ var mywc3Registry = new ModifyRegistry
+ {
+ SubKey = "Software\\Blizzard Entertainment\\Warcraft III\\",
+ ShowError = true
+ };
// 1a. Try Registry LocalMachine (no idea if localmachine is used, dont think so, but i let it stay)
- pathToWarcraft3Folder = mywc3Registry.Read("InstallPath");
+ string pathToWarcraft3Folder = mywc3Registry.Read("InstallPath");
// 1b. Try Registry CurrentUser
if (string.IsNullOrEmpty(pathToWarcraft3Folder))
@@ -168,23 +171,24 @@ public void GatherPathes()
pathToWarcraft3Folder = "";
}
- ClientSettings.Default.WC3_INSTALL_PATH = pathToWarcraft3Folder;
+ Properties.Client.Default.WC3_INSTALL_PATH = pathToWarcraft3Folder;
}
- dictPathIdentifiers.Add("%WC3_INSTALL_PATH%", ClientSettings.Default.WC3_INSTALL_PATH);
+ DictPathIdentifiers.Add("%WC3_INSTALL_PATH%", Properties.Client.Default.WC3_INSTALL_PATH);
// TODO: this isnt always nescesary
- ClientSettings.Default.Save();
+ Properties.Client.Default.Save();
}
public string GetPath(string pathIdentifier)
{
- if (dictPathIdentifiers.ContainsKey(pathIdentifier))
+ if (DictPathIdentifiers.ContainsKey(pathIdentifier))
{
- string path = dictPathIdentifiers[pathIdentifier];
+ string path = DictPathIdentifiers[pathIdentifier];
return path;
}
- else return "";
+ else
+ return "";
}
public string QueryUserForPath(LoaderConfig form, string pathIdentifier)
@@ -200,10 +204,10 @@ public string QueryUserForPath(LoaderConfig form, string pathIdentifier)
{
returnValue = form.openFileDialog1.FileName;
returnValue = returnValue.ToLower().Replace("starcraft.exe", "");
- Nibbler.ClientSettings.Default.SC1_INSTALL_PATH = returnValue;
- Nibbler.ClientSettings.Default.Save();
- dictPathIdentifiers.Remove(pathIdentifier);
- dictPathIdentifiers.Add(pathIdentifier, returnValue);
+ Properties.Client.Default.SC1_INSTALL_PATH = returnValue;
+ Properties.Client.Default.Save();
+ DictPathIdentifiers.Remove(pathIdentifier);
+ DictPathIdentifiers.Add(pathIdentifier, returnValue);
}
break;
@@ -215,10 +219,10 @@ public string QueryUserForPath(LoaderConfig form, string pathIdentifier)
{
returnValue = form.openFileDialog1.FileName;
returnValue = returnValue.ToLower().Replace("warcraft iii.exe", "");
- Nibbler.ClientSettings.Default.WC3_INSTALL_PATH = returnValue;
- Nibbler.ClientSettings.Default.Save();
- dictPathIdentifiers.Remove(pathIdentifier);
- dictPathIdentifiers.Add(pathIdentifier, returnValue);
+ Properties.Client.Default.WC3_INSTALL_PATH = returnValue;
+ Properties.Client.Default.Save();
+ DictPathIdentifiers.Remove(pathIdentifier);
+ DictPathIdentifiers.Add(pathIdentifier, returnValue);
}
break;
@@ -230,10 +234,10 @@ public string QueryUserForPath(LoaderConfig form, string pathIdentifier)
{
returnValue = form.openFileDialog1.FileName;
returnValue = returnValue.ToLower().Replace("starcraft ii.exe", "");
- Nibbler.ClientSettings.Default.SC2_INSTALL_PATH = returnValue;
- Nibbler.ClientSettings.Default.Save();
- dictPathIdentifiers.Remove(pathIdentifier);
- dictPathIdentifiers.Add(pathIdentifier, returnValue);
+ Properties.Client.Default.SC2_INSTALL_PATH = returnValue;
+ Properties.Client.Default.Save();
+ DictPathIdentifiers.Remove(pathIdentifier);
+ DictPathIdentifiers.Add(pathIdentifier, returnValue);
}
break;
}
View
9 MapLoader/Program.cs
@@ -19,16 +19,13 @@ static void Main(string[] args)
if (args.Length == 0)
{
Application.Run(new LoaderConfig());
- Application.Exit();
return;
}
string link = args[0];
- //string link = "nibbits://wc3.nibbits.com/maps/get/131603/";
- //string link = "nibbits://sc2.nibbits.com/maps/get/132027/";
- //string link = "nibbits://sc.nibbits.com/maps/get/131761/";
-
- link = link.Replace("nibbits://", "http://");
+
+ //I recommend relocating "nibbits" somewhere, and adding some logic to register the helper.
+ link = link.Replace(link.Substring(0, "nibbits".Length), "http");
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
View
12 MapLoader/ClientSettings.Designer.cs → MapLoader/Properties/Client.Designer.cs
@@ -1,23 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
+// Runtime Version:4.0.30128.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
-namespace Nibbler {
+namespace Nibbler.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
- internal sealed partial class ClientSettings : global::System.Configuration.ApplicationSettingsBase {
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Client : global::System.Configuration.ApplicationSettingsBase {
- private static ClientSettings defaultInstance = ((ClientSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new ClientSettings())));
+ private static Client defaultInstance = ((Client)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Client())));
- public static ClientSettings Default {
+ public static Client Default {
get {
return defaultInstance;
}
View
2 MapLoader/ClientSettings.settings → MapLoader/Properties/Client.settings
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nibbler" GeneratedClassName="ClientSettings">
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Nibbler" GeneratedClassName="Client">
<Profiles />
<Settings>
<Setting Name="SC1_INSTALL_PATH" Type="System.String" Scope="User">
View
4 MapLoader/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4927
+// Runtime Version:4.0.30128.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -19,7 +19,7 @@ namespace Nibbler.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
View
8 MapLoader/app.config
@@ -2,12 +2,12 @@
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
- <section name="Nibbler.ClientSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
- <section name="Nibbler.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ <section name="Nibbler.Client" type="System.Configuration.ClientSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
+ <section name="Nibbler.Properties.Settings" type="System.Configuration.ClientSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
- <Nibbler.ClientSettings>
+ <Nibbler.Client>
<setting name="SC1_INSTALL_PATH" serializeAs="String">
<value />
</setting>
@@ -17,7 +17,7 @@
<setting name="WC3_INSTALL_PATH" serializeAs="String">
<value />
</setting>
- </Nibbler.ClientSettings>
+ </Nibbler.Client>
<Nibbler.Properties.Settings>
<setting name="wc3_install_path" serializeAs="String">
<value />

0 comments on commit 18610ae

Please sign in to comment.