Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed radio panel naming logic #81

Merged
merged 1 commit into from
Nov 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ private void RadioRefresh(object sender, EventArgs eventArgs)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "5 Horizontal";
ControlText.Text = "5 Radio Panel";
}
else
{
ControlText.Text = "5 Horizontal";
ControlText.Text = "5 Radio Panel";
}
}
else
{
ControlText.Text = "5 Horizontal (Disconnected)";
ControlText.Text = "5 Radio Panel (Disconnected)";

}
}
else
{
ControlText.Text = "5 Horizontal (Disconnected)";
ControlText.Text = "5 Radio Panel (Disconnected)";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,22 @@ private void RadioRefresh(object sender, EventArgs eventArgs)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "5 Vertical";
ControlText.Text = "5 Radio Panel";
}
else
{
ControlText.Text = "5 Vertical";
ControlText.Text = "5 Radio Panel";
}
}
else
{
ControlText.Text = "5 Vertical (Disconnected)";
ControlText.Text = "5 Radio Panel (Disconnected)";

}
}
else
{
ControlText.Text = "5 Vertical (Disconnected)";
ControlText.Text = "5 Radio Panel (Disconnected)";
}

FocusDCS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,23 @@ private void RadioRefresh(object sender, EventArgs eventArgs)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "1 Horizontal";
ControlText.Text = "1 Radio Panel";
}
else
{
ControlText.Text = "1 Horizontal";
ControlText.Text = "1 Radio Panel";
}
}
else
{
ControlText.Text = "1 Horizontal (Disconnected)";
ControlText.Text = "1 Radio Panel (Disconnected)";

}
}
else
{
ResetHeight();
ControlText.Text = "1 Horizontal (Disconnected)";
ControlText.Text = "1 Radio Panel (Disconnected)";
}

FocusDCS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay
public partial class RadioOverlayWindowOneVertical : Window
{
private double _aspectRatio;

private readonly Logger Logger = LogManager.GetCurrentClassLogger();

private readonly Client.UI.AwacsRadioOverlayWindow.RadioControlGroup[] radioControlGroup =
Expand Down Expand Up @@ -128,23 +129,23 @@ private void RadioRefresh(object sender, EventArgs eventArgs)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "1 Vertical";
ControlText.Text = "1 Radio Panel";
}
else
{
ControlText.Text = "1 Vertical";
ControlText.Text = "1 Radio Panel";
}
}
else
{
ControlText.Text = "1 Vertical (Disconnected)";
ControlText.Text = "1 Radio Panel (Disconnected)";

}
}
else
{
ResetHeight();
ControlText.Text = "1 Vertical (Disconnected)";
ControlText.Text = "1 Radio Panel (Disconnected)";
}

FocusDCS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay
public partial class RadioOverlayWindowTenHorizontal : Window
{
private readonly double _aspectRatio;

private readonly Logger Logger = LogManager.GetCurrentClassLogger();

private long _lastUnitId;

private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[10];

private readonly DispatcherTimer _updateTimer;
Expand Down Expand Up @@ -94,6 +97,8 @@ private void Location_Changed(object sender, EventArgs e)

private void RadioRefresh(object sender, EventArgs eventArgs)
{
var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;

foreach (var radio in radioControlGroup)
{
radio.RepaintRadioStatus();
Expand All @@ -102,23 +107,45 @@ private void RadioRefresh(object sender, EventArgs eventArgs)

intercom.RepaintRadioStatus();

var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;
if (dcsPlayerRadioInfo != null)
if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent())
{
if (_clientStateSingleton.IsConnected && dcsPlayerRadioInfo.IsCurrent()
&& _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.ENABLED_INTERNAL_SRS_CONTROLS)
//reset when we switch planes
if (_lastUnitId != dcsPlayerRadioInfo.unitId)
{
_lastUnitId = dcsPlayerRadioInfo.unitId;
}

var avalilableRadios = 0;
var availableRadios = 0;

for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
avalilableRadios++;
}
availableRadios++;

}
}

if (availableRadios > 1)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "10 Radio Panel";
}
else
{
ControlText.Text = "10 Radio Panel";
}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";

}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay
public partial class RadioOverlayWindowTenHorizontalWide : Window
{
private readonly double _aspectRatio;

private readonly Logger Logger = LogManager.GetCurrentClassLogger();

private long _lastUnitId;

private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[10];

private readonly DispatcherTimer _updateTimer;
Expand Down Expand Up @@ -90,6 +93,8 @@ private void Location_Changed(object sender, EventArgs e)

private void RadioRefresh(object sender, EventArgs eventArgs)
{
var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;

foreach (var radio in radioControlGroup)
{
radio.RepaintRadioStatus();
Expand All @@ -98,23 +103,45 @@ private void RadioRefresh(object sender, EventArgs eventArgs)

intercom.RepaintRadioStatus();

var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;
if (dcsPlayerRadioInfo != null)
if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent())
{
if (_clientStateSingleton.IsConnected && dcsPlayerRadioInfo.IsCurrent()
&& _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.ENABLED_INTERNAL_SRS_CONTROLS)
//reset when we switch planes
if (_lastUnitId != dcsPlayerRadioInfo.unitId)
{
_lastUnitId = dcsPlayerRadioInfo.unitId;
}

var avalilableRadios = 0;
var availableRadios = 0;

for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
avalilableRadios++;
}
availableRadios++;

}
}

if (availableRadios > 1)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "10 Radio Panel";
}
else
{
ControlText.Text = "10 Radio Panel";
}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";

}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";
}
}

Expand Down
47 changes: 37 additions & 10 deletions DCS-SR-Client/UI/RadioOverlayWindow/RadioOverlayTenVertical.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ namespace Ciribob.DCS.SimpleRadio.Standalone.Overlay
public partial class RadioOverlayWindowTenVertical : Window
{
private readonly double _aspectRatio;

private readonly Logger Logger = LogManager.GetCurrentClassLogger();

private long _lastUnitId;

private readonly RadioControlGroup[] radioControlGroup = new RadioControlGroup[10];

private readonly DispatcherTimer _updateTimer;
Expand Down Expand Up @@ -86,6 +89,8 @@ public RadioOverlayWindowTenVertical(Action<bool, int> ToggleOverlay)

private void RadioRefresh(object sender, EventArgs eventArgs)
{
var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;

foreach (var radio in radioControlGroup)
{
radio.RepaintRadioStatus();
Expand All @@ -94,23 +99,45 @@ private void RadioRefresh(object sender, EventArgs eventArgs)

intercom.RepaintRadioStatus();

var dcsPlayerRadioInfo = _clientStateSingleton.DcsPlayerRadioInfo;
if (dcsPlayerRadioInfo != null)
if ((dcsPlayerRadioInfo != null) && dcsPlayerRadioInfo.IsCurrent())
{
if (_clientStateSingleton.IsConnected && dcsPlayerRadioInfo.IsCurrent()
&& _clientStateSingleton.DcsPlayerRadioInfo.simultaneousTransmissionControl == DCSPlayerRadioInfo.SimultaneousTransmissionControl.ENABLED_INTERNAL_SRS_CONTROLS)
//reset when we switch planes
if (_lastUnitId != dcsPlayerRadioInfo.unitId)
{
_lastUnitId = dcsPlayerRadioInfo.unitId;
}

var avalilableRadios = 0;
var availableRadios = 0;

for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
for (var i = 0; i < dcsPlayerRadioInfo.radios.Length; i++)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
if (dcsPlayerRadioInfo.radios[i].modulation != RadioInformation.Modulation.DISABLED)
{
avalilableRadios++;
}
availableRadios++;

}
}

if (availableRadios > 1)
{
if (dcsPlayerRadioInfo.control == DCSPlayerRadioInfo.RadioSwitchControls.HOTAS)
{
ControlText.Text = "10 Radio Panel";
}
else
{
ControlText.Text = "10 Radio Panel";
}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";

}
}
else
{
ControlText.Text = "10 Radio Panel (Disconnected)";
}
}

Expand Down
Loading
Loading