@@ -33,10 +33,15 @@ public mainMenuForm()
3333 private string maxrambox ;
3434 private string widthbox ;
3535 private string heightbox ;
36-
36+
3737 public string latestFabricVersion =
3838 readPhpContent ( "https://mc.projects.gg/LauncherUpdateStream/version-fabric.php" ) ;
3939
40+ public string latestModVersion =
41+ readPhpContent ( "https://mc.projects.gg/LauncherUpdateStream/version-mcmod.php" ) ;
42+
43+ string appDataDizini = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ;
44+
4045 private string maxramlabell ;
4146 private string minramlabell ;
4247 private string heightlabell ;
@@ -201,6 +206,8 @@ private void Anamenu_Load(object sender, EventArgs e)
201206 versionBox . Text = Properties . Settings . Default . SelectedVersion ;
202207 }
203208
209+ modVersionBox . Text = Properties . Settings . Default . curModVer ;
210+
204211 if ( Properties . Settings . Default . RamMax != string . Empty )
205212 {
206213 maxRamTextBox . Text = Properties . Settings . Default . RamMax ;
@@ -262,6 +269,8 @@ private async Task Launch() // Minecraft startup settings
262269 var path = new MinecraftPath ( launcherdizin ) ;
263270 var launcher = new CMLauncher ( path ) ;
264271
272+ launcher . ProgressChanged += launcher_DownloadProgressChanged ;
273+
265274 sessions = Properties . Settings . Default . NickNames ;
266275
267276 string serverIP = Properties . Settings . Default . autoConnect ? "play.projects.gg" : "" ;
@@ -304,8 +313,6 @@ private void oynabutton_Click(object sender, EventArgs e)
304313 {
305314 string surum_appDataDizini = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) +
306315 "/.projects/versions/projects-fabric-" + latestFabricVersion ; // Fabric directory
307- string appDataDizini =
308- Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) ; // AppData directory
309316
310317 int MinimumRamMb = int . Parse ( Properties . Settings . Default . RamMin ) ;
311318 int MaximumRamMb = int . Parse ( Properties . Settings . Default . RamMax ) ;
@@ -390,6 +397,19 @@ private void oynabutton_Click(object sender, EventArgs e)
390397 if ( versionBox . SelectedIndex == - 1 )
391398 {
392399 MessageBox . Show ( "Kullandığınız oyun sürümü \" " + Properties . Settings . Default . SelectedVersion + "\" yüklü değil!\n \n İlk defa yükleneceği için bu işlem\n birkaç dakika sürebilir. Lütfen başlatıcıyı\n bu süreç içerisinde kapatmayınız." ) ;
400+ downloadCompleteBar . Visible = true ;
401+
402+ }
403+ }
404+
405+ if ( ! Properties . Settings . Default . curModVer . Equals ( "Manuel" ) && ! Properties . Settings . Default . curModVer . Equals ( latestModVersion ) )
406+ {
407+ DialogResult askForModPackage = MessageBox . Show ( "Mod paketi güncel değil. Mod paketimizi kurarak mini harita, gece görüşü (H tuşu) gibi önemli özellikler elde edebilirsiniz. Reddetseniz bile daha sonra istemeniz durumunda ayarlar kısmından mod sürümü seçip mod paketi kurabilirsiniz.\n \n Yüklemek istiyor musunuz?" , "Mod Paketi" , MessageBoxButtons . YesNo ) ; //Fabric dosyasının olmadığını bildir
408+
409+ if ( askForModPackage == DialogResult . Yes )
410+ {
411+ updateModPackage ( ) ;
412+ return ;
393413 }
394414 }
395415
@@ -404,7 +424,7 @@ private void oynabutton_Click(object sender, EventArgs e)
404424 DiscordRpcClientSetup ( ) ;
405425
406426 prepareGameToLaunch . Stop ( ) ; // Stop prepareGameToLaunch
407- NotificationAboutException ( ex , "Luanch prepareGameToLaunch" ) ;
427+ NotificationAboutException ( ex , "Launch prepareGameToLaunch" ) ;
408428
409429 thisTrue ( ) ; // Open components of the launcher
410430
@@ -416,6 +436,42 @@ private void oynabutton_Click(object sender, EventArgs e)
416436 GC . WaitForPendingFinalizers ( ) ;
417437 }
418438
439+ private void updateModPackage ( )
440+ {
441+ WebClient wc2 = new WebClient ( ) ;
442+
443+ if ( Directory . Exists ( appDataDizini + "/.projects/mods" ) )
444+ {
445+ Directory . Delete ( appDataDizini + "/.projects/mods" , true ) ;
446+ }
447+
448+ wc2 . DownloadFileCompleted +=
449+ Wc2_DownloadFileCompleted ; // Call the codes when download process complete
450+
451+ wc2 . DownloadProgressChanged += Wc_DownloadProgressChanged ;
452+
453+ Uri modVersion = new Uri ( "https://mc.projects.gg/LauncherUpdateStream/projects-mcmod-" + latestModVersion + ".zip" ) ; // Mod installer address
454+
455+ Properties . Settings . Default . curModVer = latestModVersion ;
456+ Properties . Settings . Default . Save ( ) ;
457+
458+ playButtonStaticLabel . Enabled = false ;
459+ settingsStaticPictureBox . Enabled = false ;
460+ versionInfoStaticLabel . Text = "Mod paketi kuruluyor..." ;
461+ downloadCompleteLabel . Visible = true ;
462+ downloadCompleteBar . Visible = true ;
463+ playSplitStaticLabel . Visible = true ;
464+
465+ wc2 . DownloadFileAsync ( modVersion ,
466+ appDataDizini +
467+ "/.projects/projects-mcmod-" + latestModVersion + ".zip" ) ; // Download fabric to directory '.projects
468+ }
469+
470+ private void launcher_DownloadProgressChanged ( object sender , ProgressChangedEventArgs e )
471+ {
472+ downloadCompleteBar . Value = e . ProgressPercentage ;
473+ }
474+
419475 private void Wc_DownloadProgressChanged ( object sender , DownloadProgressChangedEventArgs e )
420476 {
421477 downloadCompleteLabel . Text = String . Format ( "{0:0.##}" , Convert . ToDouble ( e . BytesReceived ) / 1024 / 1024 ) +
@@ -426,6 +482,34 @@ private void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEv
426482 downloadCompleteBar . Value = e . ProgressPercentage ;
427483 }
428484
485+ private void Wc2_DownloadFileCompleted ( object sender , AsyncCompletedEventArgs e )
486+ {
487+ try
488+ {
489+ string zipPath = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) +
490+ "/.projects/projects-mcmod-" + latestModVersion + ".zip" ;
491+ string extractPath = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) +
492+ "/.projects/mods/" ;
493+
494+ System . IO . Compression . ZipFile . ExtractToDirectory ( zipPath , extractPath ) ;
495+ Thread . Sleep ( 1100 ) ;
496+ Properties . Settings . Default . curModVer = latestModVersion ;
497+ Properties . Settings . Default . Save ( ) ;
498+ playButtonStaticLabel . Enabled = true ;
499+ settingsStaticPictureBox . Enabled = true ;
500+ downloadCompleteLabel . Visible = false ;
501+ downloadCompleteBar . Visible = false ;
502+ playSplitStaticLabel . Visible = false ;
503+ versionInfoStaticLabel . Text = Properties . Settings . Default . SelectedVersion ;
504+ }
505+ catch ( Exception ex )
506+ {
507+ NotificationAboutException ( ex , "DownloadFileCompleted (mod download process)" ) ;
508+ }
509+
510+ GC . WaitForPendingFinalizers ( ) ;
511+ }
512+
429513 private void Wc_DownloadFileCompleted ( object sender , AsyncCompletedEventArgs e )
430514 {
431515 try
@@ -450,6 +534,17 @@ private void Wc_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
450534 NotificationAboutException ( ex , "DownloadFileCompleted (fabric download process)" ) ;
451535 }
452536
537+ if ( ! Properties . Settings . Default . curModVer . Equals ( "Manuel" ) ) {
538+ if ( ! Properties . Settings . Default . curModVer . Equals ( latestModVersion ) || ! Directory . Exists ( appDataDizini + "/.projects/mods" ) ) {
539+ DialogResult askForModPackage = MessageBox . Show ( "Mod paketi güncel değil. Mod paketimizi kurarak mini harita, gece görüşü (H tuşu) gibi önemli özellikler elde edebilirsiniz. Reddetseniz bile daha sonra istemeniz durumunda ayarlar kısmından mod sürümü seçip mod paketi kurabilirsiniz.\n \n Yüklemek istiyor musunuz?" , "Mod Paketi" , MessageBoxButtons . YesNo ) ; //Fabric dosyasının olmadığını bildir
540+
541+ if ( askForModPackage == DialogResult . Yes ) {
542+ updateModPackage ( ) ;
543+ return ;
544+ }
545+ }
546+ }
547+
453548 GC . WaitForPendingFinalizers ( ) ;
454549 }
455550
@@ -695,6 +790,31 @@ private void surumsec_SelectedIndexChanged(object sender, EventArgs e)
695790 versionInfoStaticLabel . Text = versionBox . Text ;
696791 }
697792
793+ private void modPickVersion_SelectedIndexChanged ( object sender , EventArgs e )
794+ {
795+ string testString = modVersionBox . Text , resultString = "" ;
796+
797+ if ( testString . IndexOf ( "" ) == - 1 )
798+ {
799+ resultString = testString ;
800+ }
801+ else
802+ {
803+ foreach ( char versionTextChars in testString )
804+ {
805+ if ( versionTextChars . Equals ( ' ' ) )
806+ {
807+ break ;
808+ }
809+
810+ resultString += versionTextChars ;
811+ }
812+ }
813+
814+ Properties . Settings . Default . curModVer = resultString ;
815+ Properties . Settings . Default . Save ( ) ;
816+ }
817+
698818 private void discord_Click ( object sender , EventArgs e )
699819 {
700820 try
@@ -749,9 +869,6 @@ private void minramlabel_Click(object sender, EventArgs e)
749869
750870 private void modsLabel_Click ( object sender , EventArgs e )
751871 {
752- string appDataDizini = Environment . GetFolderPath ( Environment . SpecialFolder . ApplicationData ) +
753- "/.projects/mods" ;
754-
755872 if ( Directory . Exists ( @appDataDizini ) )
756873 {
757874 string myPath = @appDataDizini ;
0 commit comments