Skip to content
Open
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
Binary file added Knossos.NET/Assets/fs2_res/fs1_coop_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/fs2_coop_banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/fs2_demo_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/fsport_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/mvps_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/str_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/fs2_res/str_coop_banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Knossos.NET/Assets/general/menu_fs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ public static void ResetBasePath()
Dispatcher.UIThread.InvokeAsync(async () =>
{
MainWindowViewModel.Instance?.ClearViews();
FreespaceViewModel.Instance?.SetLoading(true);
FreespaceViewModel.Instance?.SetFS2RootFound(false);
FreespaceViewModel.Instance?.SetInstalling(null, false);
installedMods.Clear();
engineBuilds.Clear();
retailFs2RootFound = false;
Expand Down Expand Up @@ -840,7 +843,8 @@ await Task.Run(async () => {
ModListView.Instance?.GenerateFilterButtons();
MainWindowViewModel.Instance?.NebulaModsView?.UpdateFS2InstallButton();
MainWindowViewModel.Instance?.InstalledModsView?.UpdateFS2InstallButton();

FreespaceViewModel.Instance?.SetLoading(false);
FreespaceViewModel.Instance?.SetFS2RootFound(retailFs2RootFound);
});

initIsComplete = true;
Expand Down
92 changes: 92 additions & 0 deletions Knossos.NET/ViewModels/FreespaceViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Knossos.NET.Views;
using ObservableCollections;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Knossos.NET.ViewModels
{
public partial class FreespaceViewModel : ViewModelBase
{
[ObservableProperty]
public ObservableList<FreespaceModCardViewModel> cardList = new ObservableList<FreespaceModCardViewModel>();

public static FreespaceViewModel? Instance { get; private set; }

public FreespaceViewModel()
{
CardList = new ObservableList<FreespaceModCardViewModel>() {
new FreespaceModCardViewModel("fs2_org_demo", "The original Freespace 2 Demo with no modifications", "avares://Knossos.NET/Assets/fs2_res/fs2_demo_banner.png", false),
new FreespaceModCardViewModel("FS2", "Freespace 2 Retail without any graphics upgrades", "avares://Knossos.NET/Assets/fs2_res/kn_banner.png", true),
new FreespaceModCardViewModel("MVPS", "Freespace 2 with the newerest graphics upgrades", "avares://Knossos.NET/Assets/fs2_res/mvps_banner.png", true),
new FreespaceModCardViewModel("fsport", "FSPort is a conversion of Freespace 1 story to Freespace 2. No graphics upgrades.", "avares://Knossos.NET/Assets/fs2_res/fsport_banner.png", true),
new FreespaceModCardViewModel("fsport-mediavps", "FSPort (Freespace 1 Story) with all the graphic upgrades", "avares://Knossos.NET/Assets/fs2_res/fsport_mvps_banner.png", true),
new FreespaceModCardViewModel("str", "A retell of the Freespace 1 expansion 'Silent Threat', includes all the graphic upgrades", "avares://Knossos.NET/Assets/fs2_res/str_banner.png", true),
new FreespaceModCardViewModel("fs2coopup", "This mod includes multiplayer coop missions to play the entire Freespace 2 story with friends.", "avares://Knossos.NET/Assets/fs2_res/fs2_coop_banner.jpg", true),
new FreespaceModCardViewModel("fs1coopup", "This mod includes multiplayer coop missions to play the entire Freespace 1 story with friends.", "avares://Knossos.NET/Assets/fs2_res/fs1_coop_banner.png", true),
new FreespaceModCardViewModel("strcoopup", "This mod includes multiplayer coop missions to play the entire Silent Threat Reborn story with friends.", "avares://Knossos.NET/Assets/fs2_res/str_coop_banner.jpg", true)
};

Instance = this;
}

/// <summary>
/// Sets the loading status to all mods listed in the freespace tab
/// </summary>
/// <param name="status"></param>
public void SetLoading(bool status)
{
foreach (var item in CardList)
{
item.SetLoadingOverlay(status);
}
}

/// <summary>
/// Set the status of the freespace 2 root found to all mods listed in the freespace tab
/// </summary>
/// <param name="status"></param>
public void SetFS2RootFound(bool status)
{
foreach (var item in CardList)
{
item.SetRetailOverlay(!status);
}
}

/// <summary>
/// Set the status of the installing overlay to a mod in the freespace tab
/// Allows to pass null as modID to change the status of all mods
/// </summary>
/// <param name="modID"></param>
/// <param name="status"></param>
public void SetInstalling(string? modID,bool status)
{
foreach (var item in CardList)
{
if(modID == null || modID == item.ModID)
item.SetInstallingOverlay(status);
}
}

/// <summary>
/// Set the status of the installed overlay to a mod in the freespace tab
/// </summary>
/// <param name="modID"></param>
/// <param name="status"></param>
public void SetInstalled(string modID, bool status)
{
foreach (var item in CardList)
{
if (modID == item.ModID)
{
item.SetInstalled(status);
break;
}
}
}
}
}
10 changes: 10 additions & 0 deletions Knossos.NET/ViewModels/ModListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,15 @@ internal async void InstallFS2Command()
Fs2Present = Knossos.retailFs2RootFound;
}
}

/// <summary>
/// Find if a modcard is added to this view by mod id, and return a reference to it
/// </summary>
/// <param name="modId"></param>
/// <returns>ModcardViewModel or null</returns>
public ModCardViewModel? GetModCardByID (string modId)
{
return Mods.FirstOrDefault (m => m.ID == modId);
}
}
}
12 changes: 11 additions & 1 deletion Knossos.NET/ViewModels/NebulaModListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ internal async void InstallFS2Command()
await dialog.ShowDialog<Fs2InstallerView?>(MainWindow.instance);
Fs2Present = Knossos.retailFs2RootFound;
}
}
}

/// <summary>
/// Find if a modcard is added to this view by mod id, and return a reference to it
/// </summary>
/// <param name="modId"></param>
/// <returns>NebulaModcardViewModel or null</returns>
public NebulaModCardViewModel? GetModCardByID(string modId)
{
return Mods.FirstOrDefault(m => m.ID == modId);
}
}
}
168 changes: 168 additions & 0 deletions Knossos.NET/ViewModels/Templates/FreespaceModCardViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using CommunityToolkit.Mvvm.ComponentModel;
using Knossos.NET.Views;
using Microsoft.VisualBasic;
using System;

namespace Knossos.NET.ViewModels
{
public partial class FreespaceModCardViewModel : ViewModelBase
{
[ObservableProperty]
internal Bitmap? bannerImage;
[ObservableProperty]
internal bool installingOverlay = false;
[ObservableProperty]
internal bool loadingOverlay = false;
[ObservableProperty]
internal bool retailOverlay = false;
[ObservableProperty]
internal bool installed = false;
[ObservableProperty]
internal string tooltip = "Test";

public readonly string ModID;
public readonly bool NeedsRetail = false;

public FreespaceModCardViewModel()
{
ModID = "";
BannerImage = new Bitmap(AssetLoader.Open(new Uri("avares://Knossos.NET/Assets/fs2_res/fs2_demo_banner.png")));
}

public FreespaceModCardViewModel(string modID, string modTooltip, string assetBannerPath, bool needsFs2Retail)
{
ModID = modID;
Tooltip = modTooltip;
BannerImage = new Bitmap(AssetLoader.Open(new Uri(assetBannerPath)));
NeedsRetail = needsFs2Retail;
LoadingOverlay = true;
if(NeedsRetail)
RetailOverlay = true;
}

public void SetInstallingOverlay(bool status)
{
InstallingOverlay = status;
}

public void SetInstalled(bool status)
{
Installed = status;
}

public void SetLoadingOverlay(bool status)
{
LoadingOverlay = status;
}

public void SetRetailOverlay(bool status)
{
if(NeedsRetail)
RetailOverlay = status;
}

internal void CommandPlay()
{
var card = FindModCard();
if (card != null)
{
card.ButtonCommand("play");
}
else
{
MessageBox.Show(MainWindow.instance,"Unable to find modcard id: " + ModID + ", on the installed mod list. This should not happen, try restarting KnossosNET.", "An error has ocurred", MessageBox.MessageBoxButtons.OK);
}
}

internal void CommandSettings()
{
var card = FindModCard();
if (card != null)
{
card.ButtonCommand("settings");
}
else
{
MessageBox.Show(MainWindow.instance, "Unable to find modcard id: " + ModID + ", on the installed mod list. This should not happen, try restarting KnossosNET.", "An error has ocurred", MessageBox.MessageBoxButtons.OK);
}
}

internal void CommandModify()
{
var card = FindModCard();
if (card != null)
{
card.ButtonCommand("modify");
}
else
{
MessageBox.Show(MainWindow.instance, "Unable to find modcard id: " + ModID + ", on the installed mod list. This should not happen, try restarting KnossosNET.", "An error has ocurred", MessageBox.MessageBoxButtons.OK);
}
}

internal void CommandDetails()
{
var card = FindModCard();
if (card != null)
{
card.ButtonCommand("details");
}
else
{
MessageBox.Show(MainWindow.instance, "Unable to find modcard id: " + ModID + ", on the installed mod list. This should not happen, try restarting KnossosNET.", "An error has ocurred", MessageBox.MessageBoxButtons.OK);
}
}

internal void CommandInstall()
{
var card = FindNebulaModCard();
if (card != null)
{
card.ButtonCommand("install");
}
else
{
MessageBox.Show(MainWindow.instance, "Unable to find modcard id: " + ModID + ", on the nebula mod list. This should not happen, try restarting KnossosNET.", "An error has ocurred", MessageBox.MessageBoxButtons.OK);
}
}

internal void CommandRetail()
{
if (MainWindowViewModel.Instance != null && MainWindowViewModel.Instance.InstalledModsView != null)
{
MainWindowViewModel.Instance.InstalledModsView.InstallFS2Command();
}
}

internal void CommandGetGOG()
{
KnUtils.OpenBrowserURL("https://www.gog.com/en/game/freespace_2");
}

internal void CommandGetSteam()
{
KnUtils.OpenBrowserURL("https://store.steampowered.com/app/273620/Freespace_2/");
}

private ModCardViewModel? FindModCard()
{
if (MainWindowViewModel.Instance != null && MainWindowViewModel.Instance.InstalledModsView != null)
{
return MainWindowViewModel.Instance.InstalledModsView.GetModCardByID(ModID);
}
return null;
}

private NebulaModCardViewModel? FindNebulaModCard()
{
if (MainWindowViewModel.Instance != null && MainWindowViewModel.Instance.NebulaModsView != null)
{
return MainWindowViewModel.Instance.NebulaModsView.GetModCardByID(ModID);
}
return null;
}
}
}
2 changes: 2 additions & 0 deletions Knossos.NET/ViewModels/Templates/ModCardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public ModCardViewModel(Mod modJson)
BorderColor = KnUtils.GetResourceColor("ModCardBorderDevMode");
}
LoadImage();
FreespaceViewModel.Instance?.SetInstalled(ID, true);
}

/// <summary>
Expand Down Expand Up @@ -348,6 +349,7 @@ internal async void ButtonCommandDelete()
MainWindowViewModel.Instance?.AddNebulaMod(modVersions[modVersions.Count - 1]);
}
Knossos.RemoveMod(modVersions[activeVersionIndex].id);
FreespaceViewModel.Instance?.SetInstalled(ID, false);
MainWindowViewModel.Instance?.RunModStatusChecks();
if (Knossos.globalSettings.hiddenModIds.Contains(modVersions[activeVersionIndex].id))
{
Expand Down
3 changes: 3 additions & 0 deletions Knossos.NET/ViewModels/Templates/NebulaModCardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ public void InstallingMod(CancellationTokenSource cancelToken)
{
IsInstalling = true;
cancellationTokenSource = cancelToken;
FreespaceViewModel.Instance?.SetInstalling(ID!, true);
}

public void CancelInstall()
{
IsInstalling = false;
cancellationTokenSource = null;
FreespaceViewModel.Instance?.SetInstalling(ID!, false);
}

public void CancelInstallCommand()
Expand All @@ -141,6 +143,7 @@ public void CancelInstallCommand()
catch { }
cancellationTokenSource = null;
TaskViewModel.Instance?.CancelAllInstallTaskWithID(ID!, ModVersion);
FreespaceViewModel.Instance?.SetInstalling(ID!,false);
}

internal async void ButtonCommandDetails()
Expand Down
1 change: 1 addition & 0 deletions Knossos.NET/ViewModels/Templates/Tasks/InstallMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>
if (installed == null)
{
MainWindowViewModel.Instance?.NebulaModsView?.RemoveMod(mod.id);
FreespaceViewModel.Instance?.SetInstalling(mod.id, false);
Knossos.AddMod(mod);
await Dispatcher.UIThread.InvokeAsync(() => MainWindowViewModel.Instance?.AddInstalledMod(mod), DispatcherPriority.Background);
//We cant determine if the version we are installing is the newer one at this point, but this will determine if it is newer than anything was was installed previously, what is good enoght
Expand Down
4 changes: 4 additions & 0 deletions Knossos.NET/ViewModels/Windows/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public partial class MainWindowViewModel : ViewModelBase
[ObservableProperty]
internal int minWindowHeight = 500;
[ObservableProperty]
internal FreespaceViewModel? freespaceView;
[ObservableProperty]
internal ModListViewModel? installedModsView;
[ObservableProperty]
internal NebulaModListViewModel? nebulaModsView;
Expand Down Expand Up @@ -106,6 +108,7 @@ public MainWindowViewModel()
if (!CustomLauncher.IsCustomMode)
{
placeholderTileImage = new Bitmap(AssetLoader.Open(new Uri("avares://Knossos.NET/Assets/general/NebulaDefault.png")));
FreespaceView = new FreespaceViewModel();
InstalledModsView = new ModListViewModel();
NebulaModsView = new NebulaModListViewModel();
FsoBuildsView = new FsoBuildsViewModel();
Expand Down Expand Up @@ -245,6 +248,7 @@ private void FillMenuItemsNormalMode(int defaultSelectedIndex)
MenuItems = new ObservableCollection<MainViewMenuItem>{
new MainViewMenuItem(TaskView, null, "Tasks", "Overview of current running tasks"),
new MainViewMenuItem(InstalledModsView!, "avares://Knossos.NET/Assets/general/menu_play.png", "Play", "View and run installed Freepsace Open games and modifications"),
new MainViewMenuItem(FreespaceView!, "avares://Knossos.NET/Assets/general/menu_fs.png", "Freespace", "Quick and simple access to Freespace 2 content and improved graphics mods. Also list story relevant and Freespace multiplayer mods."),
new MainViewMenuItem(NebulaModsView!, "avares://Knossos.NET/Assets/general/menu_explore.png", "Explore", "Search and install Freespace Open games and modifications"),
new MainViewMenuItem(FsoBuildsView!, "avares://Knossos.NET/Assets/general/menu_engine.png", "Engine", "Download new Freespace Open engine builds"),
new MainViewMenuItem(DeveloperModView!, "avares://Knossos.NET/Assets/general/menu_develop.png", "Develop", "Develop new games and modifications for the Freespace Open Engine"),
Expand Down
2 changes: 1 addition & 1 deletion Knossos.NET/ViewModels/Windows/ModDetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ internal async void ButtonCommandDelete()
Knossos.globalSettings.hiddenModIds.Remove(modVersions[0].id);
Knossos.globalSettings.Save();
}

FreespaceViewModel.Instance?.SetInstalled(modVersions[0].id, false);
MainWindowViewModel.Instance?.RunModStatusChecks();
if (dialog != null)
{
Expand Down
Loading