Hello Stack Overflow community,
I have been working on making a custom installer/launcher for the game I am making, it is currently in working in a non-portable context, however if I want to put it inside of a game for distribution, it must work inside of a portable context (i.e. it should not access the drive for any of it's own needs, only the other software's needs)/
At the current moment it loads a song from the drive to play, and as well loads the prerequisites for the game if the launcher has never been opened before or did not finish successfully. The files are all set to "EmbeddedResource" inside of SharpDevelop, and they are part of the final compiled script.
However, in the code's current context, the script still has to access the drive to do all of those functions, even when they are embedded into the final program.
The current code I have so far is below, "programpath" refers to the directory of which the file is being executed from, "MainText" is the main output window, which is better seen in this Stack Overflow question, and label1 is a debug line, that is only used to show the path of the current running command (will be removed when all the things are embedded).
public MainForm()
{
//Open Window
InitializeComponent();
CenterToScreen();
//Start song
System.Media.SoundPlayer player = new System.Media.SoundPlayer(programpath+"\\Resonance.wav");
player.PlayLooping();
this.Shown+=(s,e)=>{
if(File.Exists(programpath+"\\FirstLaunch.lic")&&File.ReadAllText(programpath+"\\FirstLaunch.lic").IndexOf("Installation Successful")>=0){
BackColor=System.Drawing.Color.OrangeRed;
MainText.BackColor=System.Drawing.Color.OrangeRed;
MainText.ForeColor=System.Drawing.Color.Aquamarine;
MainText.Text="Starting game..";
Process game = new Process();
//placeholder executable, will be finished game executable
game.StartInfo.FileName="D:\\UT2004\\System\\UT2004.exe";
game.StartInfo.ErrorDialog=true;
game.Start();
//stop playing music,
player.Stop();
//when game stops, close the launcher
game.WaitForExit();
Application.Exit();
}else{
//Start prerequisite installation
newLaunch();
}
};
}
//if the launcher has not been open before OR the last installation was not successful
void newLaunch(){
//Creates and makes a stream to the file
StreamWriter writer = new StreamWriter(programpath+"\\FirstLaunch.lic");
//Changing color scheme
BackColor=System.Drawing.Color.Chartreuse;
MainText.BackColor=System.Drawing.Color.Chartreuse;
MainText.ForeColor=System.Drawing.Color.Black;
MainText.Text="Configuring Prerequisites....\nInstalling DirectX";
//write to file about stage
writer.Write("Installing DirectX");
//start DirectX installer
Process prerequisite = new Process();
prerequisite.StartInfo.FileName=programpath+"\\dxwebsetup.exe";
prerequisite.StartInfo.ErrorDialog=true;
prerequisite.Start();
//debug line
label1.Text=programpath+"\\dxwebsetup.exe";
//wait for installer to finish and close
prerequisite.WaitForExit();
//remove refernce to DirectX installer
prerequisite.Close();
//write to file about stage
writer.WriteLine("...true");
//Changing color scheme
BackColor=System.Drawing.Color.DarkMagenta;
MainText.BackColor=System.Drawing.Color.DarkMagenta;
MainText.ForeColor=System.Drawing.Color.Yellow;
MainText.Text="Configuring Prerequisites....\nInstalling Microsoft VC++2015 Update RC3";
//write to file about stage
writer.Write("Installing VCRedist");
//start VC Redistributable installer
prerequisite.StartInfo.FileName=programpath+"\\vc_redist.x86.exe";
prerequisite.StartInfo.ErrorDialog=true;
prerequisite.Start();
//debug line
label1.Text=programpath+"\\vc_redist.x86.exe";
//wait for installer to finish and close
prerequisite.WaitForExit();
//remove reference to VC Redistributable installer
prerequisite.Close();
//write to file about stage
writer.WriteLine("...true");
writer.WriteLine("Installation Successful");
writer.Close();
//re-open launcher from open context
label1.Text=programpath+"\\ColorLoop.exe";
Process.Start(programpath+"\\ColorLoop.exe");
Application.Exit();
}
}
}
How do I get the program to play the music, and load the pre-requisites from itself and not from separate drive files inside the code. It is all already embedded, just not being used.