@@ -53,6 +53,11 @@ void Form1_DragDrop(object sender, DragEventArgs e)
5353 {
5454 installBtn . Enabled = true ;
5555 }
56+ if ( gameinfo . host == "offline" )
57+ {
58+ downloadBtn . Enabled = false ;
59+ gameinfo . title = gameinfo . title + " | Offline | " ;
60+ }
5661
5762 typeGameInfo ( gameinfo ) ;
5863 }
@@ -62,13 +67,15 @@ void Form1_DragDrop(object sender, DragEventArgs e)
6267 public String ghost = null ;
6368 public String gname = null ;
6469 public String gexec = null ;
70+ public String gtype = null ;
6571
6672 public void typeGameInfo ( metadata gameinfo )
6773 {
6874 garc = gameinfo . archivename ;
6975 gname = gameinfo . title ;
7076 ghost = gameinfo . host ;
7177 gexec = gameinfo . executable ;
78+ gtype = gameinfo . setup ;
7279 gtitle . Text = gameinfo . title ;
7380 originalsize . Text = gameinfo . originalsize ;
7481 repacksize . Text = gameinfo . repacksize ;
@@ -124,11 +131,12 @@ private void Client_DownloadProgressChanged(object sender, DownloadProgressChang
124131 public async void prepareWorkDir ( )
125132 {
126133 System . IO . Directory . CreateDirectory ( appfolder ) ;
134+ System . IO . Directory . CreateDirectory ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " ) ;
127135 if ( ! System . IO . File . Exists ( appfolder + "linker.bat" ) )
128136 {
129137 string [ ] linkerCode =
130138 {
131- "set lnn=%1" , "set ldd=%2" , "set lnn=%lnn:\" =%" , "set ldd=%ldd:\" =%" , "mklink \" %userprofile%\\ Desktop\\ %lnn%\" \" %ldd%\" "
139+ "set lnn=%1" , "set ldd=%2" , "set lnn=%lnn:\" =%" , "set ldd=%ldd:\" =%" , "mklink /H \" %userprofile%\\ Desktop\\ %lnn%\" \" %ldd%\" "
132140 } ;
133141 File . WriteAllLines ( appfolder + "linker.bat" , linkerCode ) ;
134142 }
@@ -188,7 +196,7 @@ public class metadata
188196 }
189197
190198 private void downloadBtn_Click ( object sender , EventArgs e )
191- {
199+ {
192200 downloadArchive ( garc , ghost ) ;
193201 this . AllowDrop = false ;
194202 installBtn . Enabled = true ;
@@ -199,29 +207,87 @@ private void installBtn_Click(object sender, EventArgs e)
199207 this . AllowDrop = false ;
200208 gpanel . Hide ( ) ;
201209 dropMeta . Visible = true ;
202- dropMeta . Text = "Select Installation Path" ;
203-
204- DialogResult result = folderBrowserDialog1 . ShowDialog ( ) ;
205- if ( result == DialogResult . OK && ! string . IsNullOrWhiteSpace ( folderBrowserDialog1 . SelectedPath ) )
210+
211+ if ( gtype == "unpack" ) {
212+ dropMeta . Text = "Select Installation Path" ;
213+ DialogResult result = folderBrowserDialog1 . ShowDialog ( ) ;
214+ if ( result == DialogResult . OK && ! string . IsNullOrWhiteSpace ( folderBrowserDialog1 . SelectedPath ) )
215+ {
216+ dropMeta . Text = "Installing to: \n " + folderBrowserDialog1 . SelectedPath ;
217+
218+ var inst = Process . Start ( appfolder + "arc.exe" , "x -o+ " + appfolder + garc + " --yes --display --diskpath\" " + folderBrowserDialog1 . SelectedPath + "\" " ) ;
219+ inst . WaitForExit ( ) ;
220+
221+ dropMeta . Text = "Creating Desktop Shortcut..." ;
222+
223+ var link = Process . Start ( appfolder + "linker.bat" , "\" " + gname + "\" " + "\" " + folderBrowserDialog1 . SelectedPath + @"\" + gexec + "\" " ) ;
224+ Thread . Sleep ( 1 ) ;
225+ dropMeta . Text = gname + "\n Installed successfully!" ;
226+ Thread . Sleep ( 3 ) ;
227+
228+ }
229+ } else if ( gtype == "external" )
206230 {
207- dropMeta . Text = "Installing to: \n " + folderBrowserDialog1 . SelectedPath ;
231+ if ( System . IO . Directory . Exists ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " ) )
232+ {
233+ System . IO . Directory . Delete ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " , true ) ;
234+ System . IO . Directory . CreateDirectory ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " ) ;
235+ }
236+
237+ dropMeta . Text = "Decompressing external installer" ;
238+
239+ string tempcode =
240+ (
241+ appfolder + "arc.exe x -o+ " + appfolder + garc + " --yes --display --diskpath" + Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ "
242+ ) ;
243+ File . Delete ( appfolder + garc + "_decompress.bat" ) ;
244+ File . WriteAllText ( appfolder + garc + "_decompress.bat" , tempcode ) ;
245+
208246
209- var inst = Process . Start ( appfolder + "arc.exe" , "x -o+ " + appfolder + garc + " --yes --display --diskpath\" " + folderBrowserDialog1 . SelectedPath + "\" " ) ;
210- inst . WaitForExit ( ) ;
247+ Process unpack = new Process ( ) ;
248+ ProcessStartInfo info = unpack . StartInfo ;
249+ info . FileName = "powershell.exe" ;
250+ info . Arguments = appfolder + garc + "_decompress.bat" ;
251+ info . Verb = "runas" ;
252+ unpack . StartInfo = info ;
253+ unpack . Start ( ) ;
254+ unpack . WaitForExit ( ) ;
211255
212- dropMeta . Text = "Creating Desktop Shortcut... " ;
256+ dropMeta . Text = "Starting external installer " ;
213257
214- var link = Process . Start ( appfolder + "linker.bat" , "\" " + gname + "\" " + "\" " + folderBrowserDialog1 . SelectedPath + @"\" + gexec + "\" " ) ;
215- Thread . Sleep ( 1 ) ;
216- dropMeta . Text = gname + "\n Installed successfully!" ;
217- Thread . Sleep ( 3 ) ;
258+ var setupProcess = Process . Start ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " + gexec ) ;
259+ setupProcess . WaitForExit ( ) ;
260+
261+ dropMeta . Text = "Deleting external installer" ;
262+ System . IO . Directory . Delete ( Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) + "\\ dotTemp\\ " , true ) ;
218263
219264 }
265+
220266 dropMeta . Visible = false ;
221267 gpanel . Show ( ) ;
268+ this . AllowDrop = true ;
222269
223270 }
224271
272+ private void button1_Click ( object sender , EventArgs e )
273+ {
274+ DialogResult dialogResult = MessageBox . Show ( "Do you really want to delete all data and restart? \n ( this doesn't uninstall your games, only archives )" , "dotGame | Wipe Data" , MessageBoxButtons . YesNo ) ;
275+ if ( dialogResult == DialogResult . Yes )
276+ {
277+ gpanel . Hide ( ) ;
278+ dropMeta . Visible = true ;
279+ dropMeta . Text = "Clearing data...\n App will restart soon..." ;
280+ Thread . Sleep ( 1 ) ;
281+ System . IO . Directory . Delete ( appfolder , true ) ;
282+ Thread . Sleep ( 1 ) ;
283+ Application . Restart ( ) ;
284+ }
285+ else
286+ {
287+ return ;
288+ }
289+ }
225290 }
291+
226292}
227293
0 commit comments