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
8 changes: 8 additions & 0 deletions Knossos.NET/ViewModels/DeveloperModsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ public void UpdateVersionManager(string? modid = null)
ModEditor?.UpdateVersionManager(modid);
}

/// <summary>
/// If the mod editor is open this will refresh the listed build options in the Fso Settings tabs
/// </summary>
public void UpdateListedFsoBuildVersionsInEditor()
{
ModEditor?.UpdateFsoSettingsComboBox();
}

/// <summary>
/// Resets the mod editor
/// Reloads the currently loaded mod in editor if it matches the passed id, null for always
Expand Down
1 change: 1 addition & 0 deletions Knossos.NET/ViewModels/FsoBuildsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public void DeleteBuild(FsoBuild build, FsoBuildItemViewModel? item, bool runMod
}
}
Knossos.RemoveBuild(build);
DeveloperModsViewModel.Instance?.UpdateListedFsoBuildVersionsInEditor();
if (runModstatusChecks)
{
MainWindowViewModel.Instance?.RunModStatusChecks();
Expand Down
11 changes: 11 additions & 0 deletions Knossos.NET/ViewModels/Templates/DevModEditorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,16 @@ public void UpdateVersionManager(string? modid = null)
if(VersionsView != null && (modid == null || ActiveVersion.id == modid) )
VersionsView?.HackUpdateModList();
}

/// <summary>
/// If the mod editor is open this will refresh the listed build options in the Fso Settings tabs
/// </summary>
public void UpdateFsoSettingsComboBox()
{
if (FsoSettingsView != null)
{
FsoSettingsView.UpdateFsoPicker();
}
}
}
}
58 changes: 38 additions & 20 deletions Knossos.NET/ViewModels/Templates/DevModFsoSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,48 @@ public DevModFsoSettingsViewModel()
public DevModFsoSettingsViewModel(DevModEditorViewModel devModEditorViewModel)
{
editor = devModEditorViewModel;
if (editor.ActiveVersion.modSettings.customBuildId == null)
{
fsoPicker = new FsoBuildPickerViewModel(null);
}
else
LoadFsoPicker();
}

private void LoadFsoPicker()
{
if (editor != null)
{
if (editor.ActiveVersion.modSettings.customBuildExec != null)
if (editor.ActiveVersion.modSettings.customBuildId == null)
{
fsoPicker = new FsoBuildPickerViewModel(new FsoBuild(editor.ActiveVersion.modSettings.customBuildExec));
FsoPicker = new FsoBuildPickerViewModel(null);
}
else
{
var matchingBuilds = Knossos.GetInstalledBuildsList(editor.ActiveVersion.modSettings.customBuildId);
if (matchingBuilds.Any())
if (editor.ActiveVersion.modSettings.customBuildExec != null)
{
var theBuild = matchingBuilds.FirstOrDefault(build => build.version == editor.ActiveVersion.modSettings.customBuildVersion);
if (theBuild != null)
FsoPicker = new FsoBuildPickerViewModel(new FsoBuild(editor.ActiveVersion.modSettings.customBuildExec));
}
else
{
var matchingBuilds = Knossos.GetInstalledBuildsList(editor.ActiveVersion.modSettings.customBuildId);
if (matchingBuilds.Any())
{
fsoPicker = new FsoBuildPickerViewModel(theBuild);
var theBuild = matchingBuilds.FirstOrDefault(build => build.version == editor.ActiveVersion.modSettings.customBuildVersion);
if (theBuild != null)
{
FsoPicker = new FsoBuildPickerViewModel(theBuild);
}
else
{
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build version for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId + " and version: " + editor.ActiveVersion.modSettings.customBuildVersion);
FsoPicker = new FsoBuildPickerViewModel(null);
}
}
else
{
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build version for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId + " and version: " + editor.ActiveVersion.modSettings.customBuildVersion);
fsoPicker = new FsoBuildPickerViewModel(null);
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build id for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId);
FsoPicker = new FsoBuildPickerViewModel(null);
}
}
else
{
Log.Add(Log.LogSeverity.Warning, "DevModFsoSettingsViewModel.Constructor()", "Missing user-saved build id for mod: " + editor.ActiveVersion.tile + " - " + editor.ActiveVersion.version + " requested build id: " + editor.ActiveVersion.modSettings.customBuildId);
fsoPicker = new FsoBuildPickerViewModel(null);
}
}
CmdLine = editor.ActiveVersion.cmdline;
}
CmdLine = editor.ActiveVersion.cmdline;
}

internal void ConfigureBuild()
Expand Down Expand Up @@ -148,5 +156,15 @@ internal void SaveSettingsCommand()
editor.ActiveVersion.SaveJson();
}
}

/// <summary>
/// Updates the FSO picker combobox to display changes to installed fso builds
/// Note: it actually destroys the current fso picker and it replaces it with a new one.
/// </summary>
public void UpdateFsoPicker()
{
//Run from UI thread
Dispatcher.UIThread.Invoke(()=> { LoadFsoPicker(); });
}
}
}
28 changes: 28 additions & 0 deletions Knossos.NET/ViewModels/Templates/DevModPkgMgrViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ internal void DeleteDependency()
EditorPackageItem.DeleteDependency(this);
}

internal void ReloadDependency()
{
EditorPackageItem.ReloadDependency(this);
}

public ModDependency? GetDependency()
{
try
Expand Down Expand Up @@ -441,6 +446,29 @@ public void DeleteDependency(EditorDependencyItem dependency)
}
}

public void ReloadDependency(EditorDependencyItem dependency)
{
int oldIndex = DependencyItems.IndexOf(dependency);
if (oldIndex != -1)
{
DeleteDependency(dependency);
try
{
if (PkgMgr.editor != null && oldIndex <= DependencyItems.Count())
DependencyItems.Insert(oldIndex, new EditorDependencyItem(dependency.Dependency, this, PkgMgr.editor.ActiveVersion.id, PkgMgr.editor.ActiveVersion.parent));
}
catch (Exception ex)
{
Log.Add(Log.LogSeverity.Error, "EditorModPackageItem.ReloadDependency()", ex);
}
}
else
{
Log.Add(Log.LogSeverity.Error, "EditorModPackageItem.ReloadDependency()", "Got -1 on DeprendencyItems.IndexOf(dependency) for some reason.");
}

}

internal void DeleteModPkg()
{
try
Expand Down
2 changes: 2 additions & 0 deletions Knossos.NET/ViewModels/Templates/TaskItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4401,7 +4401,9 @@ await Dispatcher.UIThread.InvokeAsync(async () =>
FsoBuild newBuild = new FsoBuild(modJson);
if (modifyPkgs == null)
{
//New Build
Knossos.AddBuild(newBuild);
DeveloperModsViewModel.Instance?.UpdateListedFsoBuildVersionsInEditor();
}
if (modJson.devMode)
{
Expand Down
7 changes: 5 additions & 2 deletions Knossos.NET/Views/Templates/DevModPkgMgrView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--Pkg Dependency Item-->
<Grid ColumnDefinitions="Auto,*,Auto,Auto,Auto,Auto">
<Grid ColumnDefinitions="Auto,*,Auto,Auto,Auto,Auto,Auto">
<Label Margin="30,0,0,0" Grid.Column="0" FontSize="18" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">&#x21B3;</Label>
<ComboBox SelectedIndex="{Binding ModSelectedIndex}" ItemsSource="{Binding ModItems}" Grid.Column="1" HorizontalAlignment="Stretch" Margin="5,2,2,2" FontWeight="Bold" FontSize="14" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="White" Foreground="Black"></ComboBox>
<ComboBox SelectedIndex="{Binding VersionTypeIndex}" Grid.Column="2" MinWidth="60" Margin="2" FontWeight="Bold" FontSize="16" VerticalContentAlignment="Top" HorizontalContentAlignment="Center" Background="White" Foreground="Black">
Expand All @@ -97,7 +97,10 @@
</Button.Flyout>
</Button>
<!--End Packages-->
<Button Command="{Binding DeleteDependency}" Grid.Column="5" Margin="10,0,0,0" Classes="Cancel" ToolTip.Tip="Remove this dependency">
<Button Command="{Binding ReloadDependency}" Grid.Column="5" Margin="10,0,0,0" Classes="Secondary" ToolTip.Tip="Reload Dependency versions. If you just downloaded a new version and it is not listed, use this to refresh the version list">
<Image Height="14" Width="14" Source="/Assets/general/refresh.png"></Image>
</Button>
<Button Command="{Binding DeleteDependency}" Grid.Column="6" Margin="10,0,0,0" Classes="Cancel" ToolTip.Tip="Remove this dependency">
<Image Height="14" Width="14" Source="/Assets/general/x.png"></Image>
</Button>
</Grid>
Expand Down