Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
IviriusMain committed Jan 21, 2025
1 parent ad5bf7f commit 0c99664
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 48 deletions.
9 changes: 0 additions & 9 deletions Helpers/Modding/IReboundApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,10 @@ public interface IReboundRootApp
public void Uninstall();

public ReboundAppIntegrity GetIntegrity();
}

public interface IReboundPackagedApp : IReboundRootApp
{
public List<AppPackage>? AppPackages { get; set; }
}

public interface IReboundShortcutsApp : IReboundRootApp
{
public List<ReboundAppShortcut>? Shortcuts { get; set; }
}

public interface IReboundIFEOApp : IReboundRootApp
{
public List<IFEOEntry>? IFEOEntries { get; set; }
}
45 changes: 8 additions & 37 deletions Helpers/Modding/StandardReboundApp.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;

#nullable enable

namespace Rebound.Helpers.Modding;

public partial class StandardReboundApp : IReboundPackagedApp, IReboundShortcutsApp, IReboundIFEOApp
public abstract class StandardReboundApp : IReboundRootApp
{
public virtual List<AppPackage>? AppPackages { get; set; }

Expand All @@ -25,48 +25,19 @@ public void Uninstall()

public ReboundAppIntegrity GetIntegrity()
{
if (AppPackages == null || Shortcuts == null || IFEOEntries == null)
{
throw new InvalidOperationException("App packages and shortcuts must not be null.");
}

var isAppPackageIntact = true;
var isShortcutIntact = true;
var isIFEOEntryIntact = true;

foreach (var appPackage in AppPackages)
{
if (!appPackage.IsInstalled())
{
isAppPackageIntact = false;
}
}

foreach (var shortcut in Shortcuts)
{
if (!shortcut.IsShortcutIconModernized())
{
isShortcutIntact = false;
}
}

foreach (var entry in IFEOEntries)
{
if (!entry.IsIntact())
{
isIFEOEntryIntact = false;
}
}
var isAppPackageIntact = AppPackages?.All(pkg => pkg.IsInstalled());
var isShortcutIntact = Shortcuts?.All(sc => sc.IsShortcutIconModernized());
var isIFEOEntryIntact = IFEOEntries?.All(entry => entry.IsIntact());

return
// Check if everything is ok
isShortcutIntact && isAppPackageIntact && isIFEOEntryIntact ?
isShortcutIntact is true or null && isAppPackageIntact is true or null && isIFEOEntryIntact is true or null ?

// All good
ReboundAppIntegrity.Installed :

// Check if nothing is ok
!isShortcutIntact && !isAppPackageIntact && !isIFEOEntryIntact ?
isShortcutIntact is false && !isAppPackageIntact is false && !isIFEOEntryIntact is false ?

// Not installed
ReboundAppIntegrity.NotInstalled :
Expand Down
22 changes: 20 additions & 2 deletions Rebound/Apps/Defrag.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
using System.Collections.Generic;
using CommunityToolkit.WinUI.UI.Controls.TextToolbarSymbols;
using Rebound.Helpers.Modding;

#nullable enable

namespace Rebound.Apps;

public partial class Defrag : StandardReboundApp
{
public override List<ReboundAppShortcut> Shortcuts { get; set; } =
public override List<ReboundAppShortcut>? Shortcuts { get; set; } =
[
new ReboundAppShortcut()
{

}
];

public override List<AppPackage>? AppPackages { get; set; } =
[
new AppPackage()
{

}
];

public override List<IFEOEntry>? IFEOEntries { get; set; } =
[
new IFEOEntry()
{

}
];
}

0 comments on commit 0c99664

Please sign in to comment.