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
5 changes: 5 additions & 0 deletions Knossos.NET/Classes/Knossos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,11 @@ public static async void PlayMod(Mod mod, FsoExecType fsoExecType, bool standalo
var modList = new List<Mod>();
FsoBuild? fsoBuild = specifiedBuild;

if(mod.modSettings.noIngameOptions)
{
cmdline += " -no_ingame_options";
}

if(additionalCmd != null)
{
cmdline += " " + additionalCmd;
Expand Down
3 changes: 3 additions & 0 deletions Knossos.NET/Models/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class ModSettings
[JsonIgnore]
private string? filePath = null;

[JsonPropertyName("no_ingame_options")]
public bool noIngameOptions { get; set; } = false;

public ModSettings()
{
}
Expand Down
56 changes: 55 additions & 1 deletion Knossos.NET/ViewModels/Windows/ModSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.IO;
using VP.NET;
using System.Diagnostics;

namespace Knossos.NET.ViewModels
{
Expand Down Expand Up @@ -50,6 +51,10 @@ public partial class ModSettingsViewModel : ViewModelBase
internal bool ignoreGlobalCmd = false;
[ObservableProperty]
internal string buildMissingWarning = string.Empty;
[ObservableProperty]
internal bool noIngameOptions = false;
[ObservableProperty]
internal bool ingameOptionsFileExist = false;

public ModSettingsViewModel()
{
Expand Down Expand Up @@ -81,6 +86,7 @@ public ModSettingsViewModel(Mod modJson, ModCardViewModel? modCard=null)
isDevMode = modJson.devMode;
compressed = modJson.modSettings.isCompressed;
ignoreGlobalCmd = modJson.modSettings.ignoreGlobalCmd;
noIngameOptions = modJson.modSettings.noIngameOptions;
if (Knossos.globalSettings.modCompression != CompressionSettings.Disabled && !modJson.modSettings.isCompressed)
{
compressionAvailable = true;
Expand Down Expand Up @@ -130,7 +136,7 @@ public ModSettingsViewModel(Mod modJson, ModCardViewModel? modCard=null)
}
}
}

CheckIfOptionsFileExist();
//Size
Task.Factory.StartNew(() => UpdateModSize());
}
Expand Down Expand Up @@ -331,6 +337,7 @@ internal void SaveSettingsCommand()
}

modJson.modSettings.ignoreGlobalCmd = IgnoreGlobalCmd;
modJson.modSettings.noIngameOptions = NoIngameOptions;

modJson.modSettings.Save();
if(modCardViewModel != null)
Expand Down Expand Up @@ -520,5 +527,52 @@ internal async void DecompressCommand()
await Task.Factory.StartNew(() => UpdateModSize());
}
}

internal void DeleteIngameOptions()
{
try
{
if (IngameOptionsFileExist)
{
File.Delete(Path.Combine(KnUtils.GetFSODataFolderPath(), "data", modJson!.id + "_settings.ini"));
}
CheckIfOptionsFileExist();
}
catch (Exception ex)
{
Log.Add(Log.LogSeverity.Error, "ModSettingsViewModel.DeleteIngameOptions()", ex);
}
}

internal void ViewIngameOptions()
{
if (File.Exists(Path.Combine(KnUtils.GetFSODataFolderPath(), "data", modJson!.id + "_settings.ini")))
{
try
{
var cmd = new Process();
cmd.StartInfo.FileName = Path.Combine(KnUtils.GetFSODataFolderPath(), "data", modJson!.id + "_settings.ini");
cmd.StartInfo.UseShellExecute = true;
cmd.Start();
cmd.Dispose();
}
catch (Exception ex)
{
Log.Add(Log.LogSeverity.Error, "MainWindowViewModel.ViewIngameOptions", ex);
}
}
}

private void CheckIfOptionsFileExist()
{
try
{
IngameOptionsFileExist = File.Exists(Path.Combine(KnUtils.GetFSODataFolderPath(), "data", modJson!.id + "_settings.ini"));
}
catch (Exception ex)
{
Log.Add(Log.LogSeverity.Error, "ModSettingsViewModel.CheckIfOptionsFileExist()", ex);
}
}
}
}
14 changes: 12 additions & 2 deletions Knossos.NET/Views/Windows/ModSettingsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
WindowStartupLocation="CenterScreen"
Title="{Binding Title}"
SizeToContent="Width"
Height="750"
Height="650"
CanResize="True">

<Design.DataContext>
Expand All @@ -34,6 +34,17 @@
<Label Foreground="White">Available exec type options: </Label>
Comment thread
JohnAFernandez marked this conversation as resolved.
<Label Foreground="Orange">Default, Release, Debug, Fred2, Fred2Debug, QtFred, QtFredDebug</Label>
</WrapPanel>
<!--Mod Engine Settings-->
<Label Margin="0,20,0,0" FontWeight="Black" FontSize="20">ENGINE SETTINGS</Label>
<CheckBox IsChecked="{Binding NoIngameOptions}" Margin="5" ToolTip.Tip="By disabling in-game options, launcher engine settings will be used instead. Only valid if the mod uses a FSO engine build equal or higher than version 24.2.0">
Disable in-game options
</CheckBox>
<WrapPanel IsVisible="{Binding !NoIngameOptions}">
<Label VerticalAlignment="Center" Margin="5" FontWeight="Bold" IsVisible="{Binding IngameOptionsFileExist}" Foreground="Yellow" ToolTip.Tip="This file is used to save in-game FSO engine settings not managed by Knossos.NET">In-game options file detected</Label>
<Button Command="{Binding ViewIngameOptions}" IsVisible="{Binding IngameOptionsFileExist}" Margin="5" Classes="Option" ToolTip.Tip="Open the file in a text editor.">View</Button>
<Button Command="{Binding DeleteIngameOptions}" IsVisible="{Binding IngameOptionsFileExist}" Margin="5" Classes="Cancel" ToolTip.Tip="By deleting the FSO in-game options file all values will be reseted back to default the next time you launch this mod">Delete</Button>
</WrapPanel>
<!--Mod Engine Settings END-->
<!--FSO Build Settings -->
<Label Margin="0,20,0,0" FontWeight="Black" FontSize="20">FSO BUILD</Label>
<v:FsoBuildPickerView Content="{Binding FsoPicker}"/>
Expand All @@ -42,7 +53,6 @@
<v:FsoFlagsView Content="{Binding FsoFlags}"/>
<CheckBox IsChecked="{Binding IgnoreGlobalCmd}" Margin="5,5,0,0" ToolTip.Tip="This means that global settings and global Command Line is not applied to the mod.">Do not apply global settings or global Command Line on this mod</CheckBox>
<!--FSO Build END -->

<!--Dependencies Settings-->
<StackPanel>
<Label Margin="0,20,0,0" FontWeight="Black" FontSize="20">MOD DEPENDENCIES</Label>
Expand Down