@@ -363,11 +363,55 @@ private void SetupTweakContextMenu()
363363 var sims1Item = new MenuItem { Header = LanguageManager . Get ( "ContextMenu" , "Tweaks_Sims1" , "The Sims 1" ) } ;
364364
365365 var sims1_simitone = new MenuItem { Header = LanguageManager . Get ( "ContextMenu" , "Tweaks_Simitone" , "Simitone" ) } ;
366- sims1_simitone . Click += ( s , args ) => DownloadAndOpenExe (
367- url : "https://github.com/riperiperi/Simitone/releases/download/v0.8.12/SimitoneWindows.zip" , // ← replace
368- fileName : "SimitoneWindows.zip" ,
369- downloadDirectory : Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "install" )
370- ) ;
366+ sims1_simitone . Click += async ( _ , _ ) =>
367+ {
368+ if ( ! GamePaths . IsConfigured ( GamePaths . Sims1Game ) )
369+ {
370+ MessageBox . Show (
371+ LanguageManager . Get ( "Messages" , "Error_Sims1PathNotSet" ,
372+ "The Sims 1 game directory has not been configured.\n Please set it in Settings before using this feature." ) ,
373+ "SimTools — Path Not Set" ,
374+ MessageBoxButton . OK , MessageBoxImage . Warning ) ;
375+ return ;
376+ }
377+
378+ string gameDir = GamePaths . Sims1Game ;
379+ string tempZip = Path . Combine ( Path . GetTempPath ( ) , "SimitoneWindows.zip" ) ;
380+
381+ var ( ok , _) = await DownloadFileOnly (
382+ url : "https://github.com/riperiperi/Simitone/releases/download/v0.8.12/SimitoneWindows.zip" , // ← replace
383+ destFilePath : tempZip ) ;
384+
385+ if ( ! ok ) return ;
386+
387+ try
388+ {
389+ ZipFile . ExtractToDirectory ( tempZip , gameDir , overwriteFiles : true ) ;
390+ }
391+ catch ( Exception ex )
392+ {
393+ MessageBox . Show (
394+ $ "Failed to extract Simitone:\n { ex . Message } ",
395+ "SimTools — Extraction Error" ,
396+ MessageBoxButton . OK , MessageBoxImage . Error ) ;
397+ return ;
398+ }
399+
400+ string simitoneExe = Path . Combine ( gameDir , "Simitone.Windows.exe" ) ;
401+ string message = File . Exists ( simitoneExe )
402+ ? "Simitone has been installed to your Sims 1 directory.\n \n Would you like to create a desktop shortcut to Simitone.Windows.exe?"
403+ : "Simitone has been extracted to your Sims 1 directory.\n \n Would you like to create a desktop shortcut?" ;
404+
405+ var result = MessageBox . Show ( message ,
406+ "SimTools — Simitone Installed" ,
407+ MessageBoxButton . YesNo , MessageBoxImage . Question ) ;
408+
409+ if ( result == MessageBoxResult . Yes )
410+ CreateDesktopShortcut (
411+ targetExe : File . Exists ( simitoneExe ) ? simitoneExe : gameDir ,
412+ shortcutName : "Simitone" ,
413+ description : "Simitone — The Sims 1 for Modern Computers" ) ;
414+ } ;
371415 sims1Item . Items . Add ( sims1_simitone ) ;
372416 contextMenu . Items . Add ( sims1Item ) ;
373417
@@ -743,6 +787,18 @@ private void ThanksButton_Click(object sender, RoutedEventArgs e)
743787 new SpecialThanks { Owner = this } . ShowDialog ( ) ;
744788 }
745789
790+ private void GenericKeysButton_Click ( object sender , RoutedEventArgs e )
791+ {
792+ MessageBox . Show (
793+ "This feature provides generic product keys for legacy Maxis/EA titles.\n \n "
794+ + "It may be removed from a future version of SimTools at any time, at the behest of EA." ,
795+ "SimTools \u2014 Generic Keys" ,
796+ MessageBoxButton . OK ,
797+ MessageBoxImage . Information ) ;
798+
799+ new GenericKeys { Owner = this } . ShowDialog ( ) ;
800+ }
801+
746802 // ═══════════════════════════════════════════════════════════════════════
747803 // BUGFIX BUTTON
748804 // ═══════════════════════════════════════════════════════════════════════
@@ -1732,5 +1788,31 @@ private void DonateButton_Click(object sender, RoutedEventArgs e)
17321788 about . ShowDialog ( ) ;
17331789 }
17341790 }
1791+
1792+ // ── Desktop shortcut helper ───────────────────────────────────────────────
1793+ /// <summary>
1794+ /// Creates a .lnk shortcut on the user's Desktop using WScript.Shell COM.
1795+ /// </summary>
1796+ [ System . Runtime . Versioning . SupportedOSPlatform ( "windows" ) ]
1797+ private static void CreateDesktopShortcut ( string targetExe , string shortcutName , string description = "" )
1798+ {
1799+ string desktop = Environment . GetFolderPath ( Environment . SpecialFolder . Desktop ) ;
1800+ string shortcutPath = Path . Combine ( desktop , shortcutName + ".lnk" ) ;
1801+
1802+ Type shellType = Type . GetTypeFromProgID ( "WScript.Shell" )
1803+ ?? throw new InvalidOperationException ( "WScript.Shell is not available." ) ;
1804+ dynamic shell = Activator . CreateInstance ( shellType ) ! ;
1805+ dynamic shortcut = shell . CreateShortcut ( shortcutPath ) ;
1806+
1807+ shortcut . TargetPath = targetExe ;
1808+ shortcut . WorkingDirectory = Path . GetDirectoryName ( targetExe ) ?? string . Empty ;
1809+ shortcut . Description = description ;
1810+ shortcut . Save ( ) ;
1811+ }
1812+
1813+ private void ModToolsButton_Click ( object sender , RoutedEventArgs e )
1814+ {
1815+
1816+ }
17351817 }
17361818}
0 commit comments