Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions Client/Simitone/Simitone.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,23 @@ static void Main(string[] args)

try
{
var app = new Application(Eto.Platform.Detect);
var dialog = new InstallationSelectorDialog(new System.Collections.Generic.List<InstallationInfo>());
var result = dialog.ShowModal();
// Save current directory - Eto.Forms file dialogs on Linux (GTK) can change the working directory
var savedDir = Directory.GetCurrentDirectory();

InstallationSelectionResult? result = null;
using (var app = new Application(Eto.Platform.Detect))
{
using (var dialog = new InstallationSelectorDialog(new System.Collections.Generic.List<InstallationInfo>()))
{
result = dialog.ShowModal();
dialog.Visible = false;
}
// Process pending events to ensure dialog is fully closed
app.RunIteration();
}

// Restore current directory after dialog closes
Directory.SetCurrentDirectory(savedDir);

if (result != null)
{
Expand Down Expand Up @@ -231,9 +245,23 @@ static void Main(string[] args)

try
{
var app = new Application(Eto.Platform.Detect);
var dialog = new InstallationSelectorDialog(installInfos);
var result = dialog.ShowModal();
// Save current directory - Eto.Forms file dialogs on Linux (GTK) can change the working directory
var savedDir = Directory.GetCurrentDirectory();

InstallationSelectionResult? result = null;
using (var app = new Application(Eto.Platform.Detect))
{
using (var dialog = new InstallationSelectorDialog(installInfos))
{
result = dialog.ShowModal();
dialog.Visible = false;
}
// Process pending events to ensure dialog is fully closed
app.RunIteration();
}

// Restore current directory after dialog closes
Directory.SetCurrentDirectory(savedDir);

if (result != null)
{
Expand Down
43 changes: 28 additions & 15 deletions Client/Simitone/Simitone.Shared/UI/InstallationSelectorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ public InstallationSelectorDialog(List<InstallationInfo> installations)

private void BuildContent()
{
// Header label
var headerText = installations.Count > 0
? "Multiple The Sims 1 installations were detected. Please select one:"
: "No installations found. Click Browse to locate your The Sims 1 folder:";

var headerLabel = new Label
{
Text = "Multiple The Sims 1 installations were detected. Please select one:",
Text = headerText,
Font = SystemFonts.Bold()
};

Expand Down Expand Up @@ -129,25 +132,35 @@ private void SelectCurrentInstallation()

private void BrowseForInstallation()
{
var dialog = new SelectFolderDialog
{
Title = "Select The Sims 1 Installation Folder"
};

if (dialog.ShowDialog(this) == DialogResult.Ok)
string? selectedPath = null;

using (var dialog = new SelectFolderDialog())
{
var selectedPath = dialog.Directory;
dialog.Title = "Select The Sims 1 Installation Folder";

if (dialog.ShowDialog(this) == DialogResult.Ok)
{
selectedPath = dialog.Directory;
}
}

if (selectedPath != null)
{
// Validate it's a real TS1 installation
var behaviorPath = System.IO.Path.Combine(selectedPath, "GameData", "Behavior.iff");
if (System.IO.File.Exists(behaviorPath))
{
Close(new InstallationSelectionResult
{
Path = selectedPath.Replace('\\', '/') + "/",
IsSteam = false, // Manually selected, assume not Steam
Source = "browse"
});
// Normalize the path
var normalizedPath = selectedPath.Replace('\\', '/');
if (!normalizedPath.EndsWith("/")) normalizedPath += "/";

// Add to the list and select it
var newInstall = new InstallationInfo("Custom Location", normalizedPath, GameLocator.TS1InstallationType.Portable);
installations.Add(newInstall);

// Refresh the grid and select the new item
installationGrid.DataStore = installations;
installationGrid.SelectedRow = installations.Count - 1;
}
else
{
Expand Down