Skip to content

Commit

Permalink
Installer / VR / LOD Format / Profiles / MinLOD only FPS / DefaultLOD…
Browse files Browse the repository at this point in the history
… / conf. Offsets / GUI Changes / Installer FSUIPC Auto-Start
  • Loading branch information
Fragtality committed Dec 21, 2023
1 parent 5e0deec commit 3a7957a
Show file tree
Hide file tree
Showing 35 changed files with 1,970 additions and 212 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# CUSTOM
Releases/
AppPackage.zip
Build.ps1
CopyToMSFS.ps1
desktop.ini
build.lck
Expand Down
Binary file modified DynamicLOD-latest.zip
Binary file not shown.
8 changes: 7 additions & 1 deletion DynamicLOD.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicLOD", "DynamicLOD\DynamicLOD.csproj", "{8841C1AB-3A51-473C-B0F9-8705650478B2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamicLOD", "DynamicLOD\DynamicLOD.csproj", "{8841C1AB-3A51-473C-B0F9-8705650478B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Installer", "Installer\Installer.csproj", "{BF3DD08A-7547-4352-B1DD-9A343D757421}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{8841C1AB-3A51-473C-B0F9-8705650478B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8841C1AB-3A51-473C-B0F9-8705650478B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8841C1AB-3A51-473C-B0F9-8705650478B2}.Release|Any CPU.Build.0 = Release|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF3DD08A-7547-4352-B1DD-9A343D757421}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
21 changes: 0 additions & 21 deletions DynamicLOD/App.config

This file was deleted.

22 changes: 17 additions & 5 deletions DynamicLOD/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,25 @@ public partial class App : Application
private TaskbarIcon notifyIcon;

public static new App Current => Application.Current as App;
public static string ConfigFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DynamicLOD\DynamicLOD.config";
public static string AppDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\DynamicLOD\bin";

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var args = Environment.GetCommandLineArgs();
if (args.Length == 3 && args[1].ToLower() == "-path" && Directory.Exists(args[2]))
Directory.SetCurrentDirectory(args[2]);

Directory.SetCurrentDirectory(AppDir);

if (!File.Exists(ConfigFile))
{
ConfigFile = Directory.GetCurrentDirectory() + @"\DynamicLOD.config";
if (!File.Exists(ConfigFile))
{
MessageBox.Show("No Configuration File found! Closing ...", "Critical Error", MessageBoxButton.OK, MessageBoxImage.Error);
Application.Current.Shutdown();
return;
}
}

Model = new();
InitLog();
Expand Down Expand Up @@ -63,8 +75,8 @@ protected void OnTick(object sender, EventArgs e)

protected void InitLog()
{
string logFilePath = Model.GetSetting("logFilePath", "DynamicLOD.log");
string logLevel = Model.GetSetting("logLevel", "Debug");
string logFilePath = @"..\log\" + Model.GetSetting("logFilePath", "Fenix2GSX.log");
string logLevel = Model.GetSetting("logLevel", "Debug"); ;
LoggerConfiguration loggerConfiguration = new LoggerConfiguration().WriteTo.File(logFilePath, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 3,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level:u3}] {Message} {NewLine}{Exception}");
if (logLevel == "Warning")
Expand Down
70 changes: 70 additions & 0 deletions DynamicLOD/ConfigurationFile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System.Collections.Generic;
using System.IO;
using System.Xml;

namespace DynamicLOD
{
public class ConfigurationFile
{
private Dictionary<string, string> appSettings = new();
private XmlDocument xmlDoc = new();

public string this[string key]
{
get => GetSetting(key);
set => SetSetting(key, value);
}

public void LoadConfiguration()
{
xmlDoc = new();
xmlDoc.LoadXml(File.ReadAllText(App.ConfigFile));

XmlNode xmlSettings = xmlDoc.ChildNodes[1];
appSettings.Clear();
foreach(XmlNode child in xmlSettings.ChildNodes)
appSettings.Add(child.Attributes["key"].Value, child.Attributes["value"].Value);
}

public void SaveConfiguration()
{
foreach (XmlNode child in xmlDoc.ChildNodes[1])
child.Attributes["value"].Value = appSettings[child.Attributes["key"].Value];

xmlDoc.Save(App.ConfigFile);
}

public string GetSetting(string key, string defaultValue = "")
{
if (appSettings.ContainsKey(key))
return appSettings[key];
else
{
XmlNode newNode = xmlDoc.CreateElement("add");

XmlAttribute attribute = xmlDoc.CreateAttribute("key");
attribute.Value = key;
newNode.Attributes.Append(attribute);

attribute = xmlDoc.CreateAttribute("value");
attribute.Value = defaultValue;
newNode.Attributes.Append(attribute);

xmlDoc.ChildNodes[1].AppendChild(newNode);
appSettings.Add(key, defaultValue);
SaveConfiguration();

return defaultValue;
}
}

public void SetSetting(string key, string value)
{
if (appSettings.ContainsKey(key))
{
appSettings[key] = value;
SaveConfiguration();
}
}
}
}
36 changes: 36 additions & 0 deletions DynamicLOD/DynamicLOD.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="mfLvarPerFrame" value="15" />
<add key="ConfigVersion" value="1" />
<add key="logFilePath" value="DynamicLOD.log" />
<add key="logLevel" value="Debug" />
<add key="waitForConnect" value="true" />
<add key="openWindow" value="true" />
<add key="simBinary" value="FlightSimulator" />
<add key="simModule" value="WwiseLibPCx64P.dll" />
<add key="offsetModuleBase" value="0x004B2368"/>
<add key="offsetPointerMain" value="0x3D0"/>
<add key="offsetPointerTlod" value="0xC"/>
<add key="offsetPointerTlodVr" value="0x114"/>
<add key="offsetPointerOlod" value="0xC"/>
<add key="simMinLod" value="10"/>
<add key="selectedProfile" value="0"/>
<add key="tlodPairs0" value="0:100|1500:150|5000:200" />
<add key="olodPairs0" value="0:100|2500:150|7500:200" />
<add key="isVr0" value="false"/>
<add key="tlodPairs1" value="0:100|500:125|2000:150|7500:175|15000:200|20000:225" />
<add key="olodPairs1" value="0:100|500:125|2500:150|5000:175|9500:200" />
<add key="isVr1" value="false"/>
<add key="tlodPairs2" value="0:100|1500:150|5000:200" />
<add key="olodPairs2" value="0:100|2500:150|7500:200" />
<add key="isVr2" value="true"/>
<add key="defaultTlod" value="200" />
<add key="defaultOlod" value="200" />
<add key="useTargetFps" value="false" />
<add key="targetFpsIndex" value="0"/>
<add key="targetFps" value="40" />
<add key="constraintTicks" value="60" />
<add key="decreaseTlod" value="50" />
<add key="decreaseOlod" value="50" />
<add key="minLod" value="100" />
</appSettings>
5 changes: 4 additions & 1 deletion DynamicLOD/DynamicLOD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Description>Another Adapative LOD Implementation based on muumimorko
Work</Description>
<Copyright>Copyright © 2023</Copyright>
<Version>0.2.5</Version>
<Version>0.3.1</Version>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down Expand Up @@ -50,6 +50,9 @@ Work</Description>
</ItemGroup>

<ItemGroup>
<None Update="DynamicLOD.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Microsoft.FlightSimulator.SimConnect.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
1 change: 1 addition & 0 deletions DynamicLOD/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
[assembly: SuppressMessage("Interoperability", "SYSLIB1054:Verwenden Sie \\\"LibraryImportAttribute\\\" anstelle von \\\"DllImportAttribute\\\", um P/Invoke-Marshallingcode zur Kompilierzeit zu generieren.")]
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:DynamicLOD.NotifyIconViewModel.ExitApplication")]
[assembly: SuppressMessage("Style", "IDE1006:Benennungsstile")]
[assembly: SuppressMessage("Usage", "CA2211:Nicht konstante Felder dürfen nicht sichtbar sein")]
4 changes: 3 additions & 1 deletion DynamicLOD/IPCManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static bool WaitForSessionReady(ServiceModel model)
{
int waitDuration = 5000;
SimConnect.SubscribeSimVar("CAMERA STATE", "Enum");
SimConnect.SubscribeSimVar("PLANE IN PARKING STATE", "Bool");
Thread.Sleep(250);
bool isReady = IsCamReady();
while (IsSimRunning() && !isReady && !model.CancellationRequested)
Expand All @@ -101,8 +102,9 @@ public static bool WaitForSessionReady(ServiceModel model)
public static bool IsCamReady()
{
float value = SimConnect.ReadSimVar("CAMERA STATE", "Enum");
bool parkState = SimConnect.ReadSimVar("PLANE IN PARKING STATE", "Bool") == 1;

return value >= 2 && value <= 5;
return value >= 2 && value <= 5 && !parkState;
}

public static void CloseSafe()
Expand Down
Loading

0 comments on commit 3a7957a

Please sign in to comment.