Skip to content

Commit

Permalink
Career editor (#116)
Browse files Browse the repository at this point in the history
- Add career editor
- Add domcal mod
- Add a popup that opens if the user selects a sims.exe that cannot be patched
  • Loading branch information
FaithBeam authored Dec 14, 2024
1 parent c3fe926 commit c53760b
Show file tree
Hide file tree
Showing 75 changed files with 2,562 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: .NET

env:
PACK_ID: Sims1WidescreenPatcher
PACK_VER: 3.12.0
PACK_VER: 3.13.0

on:
push:
Expand Down
3 changes: 0 additions & 3 deletions Sims1WidescreenPatcher.Core/Events/NewProgressEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ public class NewProgressEventArgs
public string Status { get; }
public string Status2 { get; }

public NewProgressEventArgs(double progress)
: this(progress, string.Empty, string.Empty) { }

public NewProgressEventArgs(double progress, string status, string status2)
{
Progress = progress;
Expand Down
3 changes: 0 additions & 3 deletions Sims1WidescreenPatcher.Core/Events/NewUninstallEventArgs.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Sims.Far;
using Sims1WidescreenPatcher.Core.Models;
using Sims1WidescreenPatcher.Core.Services;
using Sims1WidescreenPatcher.Core.ViewModels;

namespace Sims1WidescreenPatcher.Core.Factories;

public interface ICareerEditorViewModelFactory
{
CareerEditorDialogViewModel Create();
}

public class CareerEditorViewModelFactory : ICareerEditorViewModelFactory
{
private readonly IAppState _appState;
private readonly IFar _far;
private readonly IIffService _iffService;

public CareerEditorViewModelFactory(IAppState appState, IFar far, IIffService iffService)
{
_appState = appState;
_far = far;
_iffService = iffService;
}

public CareerEditorDialogViewModel Create() =>
new CareerEditorDialogViewModel(_appState, _far, _iffService);
}
9 changes: 9 additions & 0 deletions Sims1WidescreenPatcher.Core/Models/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

namespace Sims1WidescreenPatcher.Core.Models;

public interface IAppState
{
string? SimsExePath { get; set; }
bool SimsExePathExists { get; }
Resolution? Resolution { get; set; }
string SimsBackupPath { get; }
bool SimsBackupExists { get; }
}

public class AppState : ReactiveObject, IAppState
{
private string? _simsExePath;
Expand Down
33 changes: 19 additions & 14 deletions Sims1WidescreenPatcher.Core/Models/CheckboxSelectionSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,51 @@

public class CheckboxSelectionSnapshot : IEquatable<CheckboxSelectionSnapshot>
{
private readonly bool[] _vms;

public CheckboxSelectionSnapshot(params bool[] vms)
public CheckboxSelectionSnapshot(params ValueTuple<string, bool>[] values)
{
_vms = vms;
States = new Dictionary<string, bool>();
foreach (var vt in values)
{
States.Add(vt.Item1, vt.Item2);
}
}

public readonly Dictionary<string, bool> States;

public bool Equals(CheckboxSelectionSnapshot? other)
{
if (ReferenceEquals(null, other))
if (other is null)
return false;
if (ReferenceEquals(this, other))
return true;
if (_vms.Length != other._vms.Length)
return false;

for (int i = 0; i < _vms.Length; i++)
foreach (var state in States)
{
if (_vms[i] != other._vms[i])
if (!other.States.ContainsKey(state.Key))
{
return false;
}
}

if (other.States[state.Key] != state.Value)
{
return false;
}
}
return true;
}

public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj))
if (obj is null)
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != this.GetType())
if (obj.GetType() != GetType())
return false;
return Equals((CheckboxSelectionSnapshot)obj);
}

public override int GetHashCode()
{
return _vms.GetHashCode();
return States.GetHashCode();
}
}
10 changes: 0 additions & 10 deletions Sims1WidescreenPatcher.Core/Models/IAppState.cs

This file was deleted.

Binary file not shown.
14 changes: 14 additions & 0 deletions Sims1WidescreenPatcher.Core/Services/CheatsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@

namespace Sims1WidescreenPatcher.Core.Services;

public interface ICheatsService
{
bool CheatsEnabled();

/// <summary>
/// Determine if the sims exe can be patched to enable all cheats
/// </summary>
/// <returns></returns>
bool CanEnableCheats();

void EnableCheats();
void DisableCheats();
}

public class CheatsService : ICheatsService
{
private readonly IAppState _appState;
Expand Down
16 changes: 0 additions & 16 deletions Sims1WidescreenPatcher.Core/Services/CheckDDrawCompatIniService.cs

This file was deleted.

22 changes: 19 additions & 3 deletions Sims1WidescreenPatcher.Core/Services/DDrawCompatSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ params DDrawCompatEnums[] settings
{
throw new DirectoryNotFoundException($"Directory not found: {dir}");
}
using var sw = new StreamWriter(Path.Combine(dir, "DDrawCompat.ini"));

await using var sw = new StreamWriter(Path.Combine(dir, "DDrawCompat.ini"));
foreach (var setting in settings)
{
switch (setting)
Expand All @@ -26,12 +27,27 @@ params DDrawCompatEnums[] settings
await sw.WriteLineAsync("FullscreenMode=exclusive");
await sw.WriteLineAsync("DisplayResolution=app");
break;
default:
break;
}
}
await sw.WriteLineAsync("CPUAffinity=all"); // the default was changed to 1 in 0.4.0 which was a culprit for the major issues, crashes, and lag
await sw.WriteLineAsync("DisplayRefreshRate=desktop"); // removes erroneous lock to 60fps on higher-than-60hz displays when vsync is enabled
await sw.WriteLineAsync("AltTabFix=keepvidmem"); // fixes crashes/bugs when using Alt+Tab
}

public static string DDrawCompatSettingsExist(string pathToSimsExe)
{
var dir = Path.GetDirectoryName(pathToSimsExe);
if (string.IsNullOrWhiteSpace(dir))
{
throw new ArgumentException($"Invalid directory: {pathToSimsExe}");
}

var ddrawSettingsPath = Path.Combine(dir, "DDrawCompat.ini");
return File.Exists(ddrawSettingsPath) ? ddrawSettingsPath : string.Empty;
}

public static void Remove(string pathToSettings)
{
File.Delete(pathToSettings);
}
}
Loading

0 comments on commit c53760b

Please sign in to comment.