Reputation: 513
I've been coding a Minecraft launcher using Windows Forms. I made it download the launcher if it doesn't detect one. The variable for the EXE is called _exe
(I used a get-set for it). I made another form download the launcher async (for a progress bar, talk about aesthetics!). In Program.cs
, where all the big stuff happens (where Main()
is), I have a method called Boot()
which loads all the settings and checks for missing files (Minecraft.exe, Launch.bat (which sets the environment variable %APPDATA%
because I have no idea how to set environment variables and launch Minecraft with that). When the DownloadLauncher form initializes, it tells me that it's downloading to the folder the launcher is in (which is the default option) although in the settings it's already set to use the original %APPDATA%
folder. I know this is a case of objects being declared numerous times but I have no idea how to fix it because it's on such a large scale.
Program.cs , DownloadLauncher.cs
Problem is that the variable prog._rw.var._exe
in line 23 isn't supposed to be .minecraft\Minecraft.exe
but (%APPDATA%)\.minecraft\Minecraft.exe
Upvotes: 1
Views: 298
Reputation: 1752
public static class VariableStore
{
public static string MinecraftPath
{
get;
set;
}
}
Now to 'set' your variable, you'd call:
VariableStore.MinecraftPath = "%appdata%\\roaming\\.minecraft";
You access it the same way:
System.Diagnostics.Debug.Print(VariableStore.MinecraftPath);
Keep in mind that this is a very crude solution. Also, if you're planning to go through with your project (which sounds like a really nice learning project), I'd advice you to read up a little bit more about WinForms and how they work before you go any further, as you have multiple design flaws already. Don't give up and good luck! :)
Upvotes: 2