Skip to content

Commit 19375f3

Browse files
committed
Slight updates to keys and main window.
1 parent 863aa63 commit 19375f3

6 files changed

Lines changed: 106 additions & 15 deletions

File tree

Images/Settings.png

6.92 KB
Loading

Pages/GenericKeys.xaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
mc:Ignorable="d"
88
Title="GenericKeys" Height="500" Width="400" WindowStyle="None"
99
AllowsTransparency="True" HorizontalAlignment="Left" VerticalAlignment="Top"
10-
Foreground="{x:Null}">
10+
Foreground="{x:Null}" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
1111
<Window.Background>
1212
<ImageBrush ImageSource="/Images/TS3_Box2.png"/>
1313
</Window.Background>
@@ -45,7 +45,7 @@
4545

4646
<!-- Read-only output field -->
4747
<TextBox x:Name="KeyField"
48-
HorizontalAlignment="Center" Margin="0,300,0,0"
48+
HorizontalAlignment="Center" Margin="0,250,0,0"
4949
VerticalAlignment="Top" Width="252" Height="24"
5050
TextWrapping="Wrap"
5151
IsReadOnly="True"
@@ -55,7 +55,7 @@
5555

5656
<!-- Generate -->
5757
<Button x:Name="GenerateButton" Content="Generate"
58-
HorizontalAlignment="Left" Margin="75,333,0,0" VerticalAlignment="Top"
58+
HorizontalAlignment="Left" Margin="75,283,0,0" VerticalAlignment="Top"
5959
Width="120" Height="34" FontFamily="Tahoma" FontWeight="Bold"
6060
Click="GenerateButton_Click">
6161
<Button.Background>
@@ -65,13 +65,18 @@
6565

6666
<!-- Copy -->
6767
<Button x:Name="CopyButton" Content="Copy"
68-
HorizontalAlignment="Left" Margin="205,333,0,0" VerticalAlignment="Top"
68+
HorizontalAlignment="Left" Margin="205,283,0,0" VerticalAlignment="Top"
6969
Width="120" Height="34" FontFamily="Tahoma" FontWeight="Bold"
7070
Click="CopyButton_Click">
7171
<Button.Background>
7272
<ImageBrush ImageSource="/Images/button_normal.png"/>
7373
</Button.Background>
7474
</Button>
75+
<TextBlock x:Name="KeysInfoText_Copy"
76+
HorizontalAlignment="Center" Margin="0,332,0,0"
77+
TextWrapping="Wrap" VerticalAlignment="Top"
78+
Width="352" Height="32"
79+
FontFamily="Tahoma" FontWeight="Bold" TextAlignment="Center" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"><Run Text="These keys will not work for online registration."/><LineBreak/><Run Text="They will only allow for installation from retail discs."/></TextBlock>
7580

7681
</Grid>
7782
</Window>

Pages/MainWindow.xaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
FontSize="16"
3131
ToolTip="Settings"
3232
Click="SettingsButton_Click" BorderBrush="{x:Null}">
33+
<Button.Foreground>
34+
<ImageBrush ImageSource="/Images/Settings.png"/>
35+
</Button.Foreground>
3336
<Button.Background>
3437
<ImageBrush ImageSource="/Images/button_yellow.png"/>
3538
</Button.Background>
@@ -51,9 +54,8 @@
5154
</Button>
5255
<Button x:Name="NewGPUButton" Content="GPU Support &gt;"
5356
HorizontalAlignment="Left" Margin="8,216,0,0" VerticalAlignment="Top"
54-
Width="162" Height="34" FontFamily="Tahoma" FontWeight="Bold"
55-
Click="NewGPUButton_Click" FontSize="11"
56-
ContextMenuOpening="NewGPUButton_Context" BorderBrush="{x:Null}">
57+
Width="162" Height="34" FontFamily="Tahoma" FontWeight="Bold" FontSize="11"
58+
ContextMenuOpening="NewGPUButton_Context" BorderBrush="{x:Null}" Click="NewGPUButton_Click">
5759
<Button.Style>
5860
<Style TargetType="Button">
5961
<Setter Property="Background">
@@ -123,12 +125,12 @@
123125
<ImageBrush ImageSource="/Images/button_normal.png"/>
124126
</Button.Background>
125127
</Button>
126-
<Button x:Name="ModToolsButton" Content="Mod Tools &gt;" HorizontalAlignment="Left" Margin="8,496,0,0" VerticalAlignment="Top" Width="159" Height="34" FontFamily="Tahoma" FontWeight="Bold" Click="ThanksButton_Click" FontSize="11" BorderBrush="{x:Null}">
128+
<Button x:Name="ModToolsButton" Content="Mod Tools &gt;" HorizontalAlignment="Left" Margin="8,496,0,0" VerticalAlignment="Top" Width="159" Height="34" FontFamily="Tahoma" FontWeight="Bold" FontSize="11" BorderBrush="{x:Null}" Click="ModToolsButton_Click">
127129
<Button.Background>
128130
<ImageBrush ImageSource="/Images/button_normal.png"/>
129131
</Button.Background>
130132
</Button>
131-
<Button x:Name="GenericKeysButton" Content="Generic Game Keys" HorizontalAlignment="Left" Margin="8,536,0,0" VerticalAlignment="Top" Width="159" Height="34" FontFamily="Tahoma" FontWeight="Bold" Click="TweakButton_Click" FontSize="11" ContextMenuOpening="TweakButton_Context" BorderBrush="{x:Null}">
133+
<Button x:Name="GenericKeysButton" Content="Generic Game Keys" HorizontalAlignment="Left" Margin="8,536,0,0" VerticalAlignment="Top" Width="159" Height="34" FontFamily="Tahoma" FontWeight="Bold" Click="GenericKeysButton_Click" FontSize="11" BorderBrush="{x:Null}">
132134
<Button.Background>
133135
<ImageBrush ImageSource="/Images/button_normal.png"/>
134136
</Button.Background>

Pages/MainWindow.xaml.cs

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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.\nPlease 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\nWould you like to create a desktop shortcut to Simitone.Windows.exe?"
403+
: "Simitone has been extracted to your Sims 1 directory.\n\nWould 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
}

SimTools_v4.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<Resource Include="Images\paypal.png" />
114114
<Resource Include="Images\plumbob.gif" />
115115
<Resource Include="Images\plumbob_shatter.gif" />
116+
<Resource Include="Images\Settings.png" />
116117
<Resource Include="Images\setup.ico" />
117118
<Resource Include="Images\SimTools_Logo.png" />
118119
<Resource Include="Images\steam.png" />
@@ -145,6 +146,7 @@
145146
<None Remove="Images\github.png" />
146147
<None Remove="Images\patreon.png" />
147148
<None Remove="Images\paypal.png" />
149+
<None Remove="Images\Settings.png" />
148150
</ItemGroup>
149151

150152
<ItemGroup>

build.counter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4024
1+
4033

0 commit comments

Comments
 (0)