Skip to content

Commit

Permalink
Windows position fixes, streamdeck json fix for dcsbios class organiz…
Browse files Browse the repository at this point in the history
…ation (#468)
  • Loading branch information
jdahlblom authored Feb 7, 2024
1 parent 7190115 commit 054f9db
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 67 deletions.
4 changes: 2 additions & 2 deletions src/ControlReference/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
<value>%userprofile%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json</value>
</setting>
<setting name="MainWindowHeight" serializeAs="String">
<value>-1</value>
<value>600</value>
</setting>
<setting name="MainWindowWidth" serializeAs="String">
<value>-1</value>
<value>700</value>
</setting>
<setting name="MainWindowTop" serializeAs="String">
<value>-1</value>
Expand Down
9 changes: 5 additions & 4 deletions src/ControlReference/CTRLMainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
return;
}
Top = Settings.Default.MainWindowTop.CompareTo(-1) == 0 ? Top : Settings.Default.MainWindowTop;
Left = Settings.Default.MainWindowLeft.CompareTo(-1) == 0 ? Top : Settings.Default.MainWindowLeft;
Height = Settings.Default.MainWindowHeight.CompareTo(-1) == 0 ? Top : Settings.Default.MainWindowHeight;
Width = Settings.Default.MainWindowWidth.CompareTo(-1) == 0 ? Top : Settings.Default.MainWindowWidth;

Top = Settings.Default.MainWindowTop;
Left = Settings.Default.MainWindowLeft;
Height = Settings.Default.MainWindowHeight;
Width = Settings.Default.MainWindowWidth;

var result = Common.CheckJSONDirectory(Settings.Default.DCSBiosJSONLocation);
if (result.Item1 == false && result.Item2 == false)
Expand Down
4 changes: 2 additions & 2 deletions src/ControlReference/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/ControlReference/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<Value Profile="(Default)">%userprofile%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json</Value>
</Setting>
<Setting Name="MainWindowHeight" Type="System.Double" Scope="User">
<Value Profile="(Default)">-1</Value>
<Value Profile="(Default)">600</Value>
</Setting>
<Setting Name="MainWindowWidth" Type="System.Double" Scope="User">
<Value Profile="(Default)">-1</Value>
<Value Profile="(Default)">700</Value>
</Setting>
<Setting Name="MainWindowTop" Type="System.Double" Scope="User">
<Value Profile="(Default)">-1</Value>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using ClassLibraryCommon;
using DCS_BIOS.Json;
using DCS_BIOS.Serialized;

namespace DCS_BIOS.misc
namespace DCS_BIOS.Serialized
{

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/DCSFlightpanels/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Loaded="WindowLoaded"
Closing="MainWindowClosing"
Closed="MainWindow_OnClosed"
LocationChanged="MainWindowLocationChanged"
KeyDown="MainWindow_OnKeyDown"
SizeChanged="MainWindowSizeChanged"
WindowStartupLocation="CenterScreen"
Expand Down
55 changes: 11 additions & 44 deletions src/DCSFlightpanels/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public MainWindow()
AppEventHandler.AttachSettingsModified(this);
AppEventHandler.AttachPanelEventListener(this);
AppEventHandler.AttachForwardPanelEventListener(this);
BIOSEventHandler.AttachConnectionListener(this);
BIOSEventHandler.AttachConnectionListener(this);
BIOSEventHandler.AttachStringListener(this);
/*
* Correct JSON folder path, move away from $USERDIRECTORY$.
Expand Down Expand Up @@ -184,7 +184,7 @@ private void WindowLoaded(object sender, RoutedEventArgs e)
Common.ShowErrorMessageBox(ex);
}
}

private void FindDCSBIOSControls()
{
if (!DCSAircraft.HasDCSBIOSModules || DCSAircraft.IsKeyEmulator(ProfileHandler.ActiveDCSAircraft) || DCSAircraft.IsKeyEmulatorSRS(ProfileHandler.ActiveDCSAircraft))
Expand Down Expand Up @@ -361,51 +361,14 @@ private void LoadSettings()
{
LoadProcessPriority();

if (Settings.Default.MainWindowHeight > 0)
{
Height = Settings.Default.MainWindowHeight;
}

if (Settings.Default.MainWindowWidth > 0)
{
Width = Settings.Default.MainWindowWidth;
}

if (Settings.Default.MainWindowTop > 0)
{
Top = Settings.Default.MainWindowTop;
}

if (Settings.Default.MainWindowLeft > 0)
{
Left = Settings.Default.MainWindowLeft;
}
Height = Settings.Default.MainWindowHeight;
Width = Settings.Default.MainWindowWidth;
Top = Settings.Default.MainWindowTop;
Left = Settings.Default.MainWindowLeft;

Common.APIModeUsed = Settings.Default.APIMode == 0 ? APIModeEnum.KeybdEvent : APIModeEnum.SendInput;
}

private void MainWindowLocationChanged(object sender, EventArgs e)
{
try
{
if (!_isLoaded)
{
return;
}

if (Top > 0 && Left > 0)
{
Settings.Default.MainWindowTop = Top;
Settings.Default.MainWindowLeft = Left;
Settings.Default.Save();
}
}
catch (Exception ex)
{
Common.ShowErrorMessageBox(ex);
}
}

public void SwitchesChanged(object sender, SwitchesChangedEventArgs e)
{
try
Expand Down Expand Up @@ -576,6 +539,10 @@ private void MainWindowClosing(object sender, System.ComponentModel.CancelEventA
{
e.Cancel = true;
}

Settings.Default.MainWindowTop = Top;
Settings.Default.MainWindowLeft = Left;
Settings.Default.Save();
}
catch (Exception ex)
{
Expand Down Expand Up @@ -1380,7 +1347,7 @@ private void MenuItemCTRLRef_OnClick(object sender, RoutedEventArgs e)
FileName = AppDomain.CurrentDomain.BaseDirectory + "ctrlref.exe",
UseShellExecute = true
});

}
catch (Exception ex)
{
Expand Down
6 changes: 3 additions & 3 deletions src/DCSFlightpanels/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/DCSFlightpanels/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<Value Profile="(Default)" />
</Setting>
<Setting Name="MainWindowHeight" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
<Value Profile="(Default)">800</Value>
</Setting>
<Setting Name="MainWindowWidth" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
<Value Profile="(Default)">1300</Value>
</Setting>
<Setting Name="MainWindowTop" Type="System.Double" Scope="User">
<Value Profile="(Default)">0</Value>
Expand Down
4 changes: 2 additions & 2 deletions src/DCSFlightpanels/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<value />
</setting>
<setting name="MainWindowHeight" serializeAs="String">
<value>0</value>
<value>800</value>
</setting>
<setting name="MainWindowWidth" serializeAs="String">
<value>0</value>
<value>1300</value>
</setting>
<setting name="MainWindowTop" serializeAs="String">
<value>0</value>
Expand Down
11 changes: 11 additions & 0 deletions src/NonVisuals/Panels/StreamDeck/JSONFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public static string Fix(string json)
*/
json = json.Replace("NonVisuals.KeyPress, NonVisuals", "NonVisuals.KeyEmulation.KeyPress, NonVisuals");
json = json.Replace("NonVisuals.KeyPressInfo, NonVisuals", "NonVisuals.KeyEmulation.KeyPressInfo, NonVisuals");

/*
* 07.02.2024, organized DCS-BIOS classes
*/
json = json.Replace("DCS_BIOS.DCSBIOSInput, DCS-BIOS", "DCS_BIOS.Serialized.DCSBIOSInput, DCS-BIOS");
json = json.Replace("DCS_BIOS.DCSBIOSOutput, DCS-BIOS", "DCS_BIOS.Serialized.DCSBIOSOutput, DCS-BIOS");
json = json.Replace("DCS_BIOS.DCSBIOSOutputFormula, DCS-BIOS", "DCS_BIOS.Serialized.DCSBIOSOutputFormula, DCS-BIOS");
json = json.Replace("DCS_BIOS.DCSBIOSInputInterface, DCS-BIOS", "DCS_BIOS.Serialized.DCSBIOSInputInterface, DCS-BIOS");



return json;
}

Expand Down
1 change: 0 additions & 1 deletion src/Tests/DcsBios/DCSBIOSInputInterfaceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using DCS_BIOS.Json;
using DCS_BIOS.misc;
using DCS_BIOS.Serialized;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DCS_BIOS.misc;
using DCS_BIOS.Serialized;
using DCS_BIOS.Serialized;
using DCSFPTests.Serialization.Common;
using Newtonsoft.Json;
using Xunit;
Expand Down

0 comments on commit 054f9db

Please sign in to comment.