Skip to content

Commit

Permalink
Merge pull request #81 from FPGSchiba/bugfix/76-fix-radio-panel-headers
Browse files Browse the repository at this point in the history
Fixed radio panel naming logic
  • Loading branch information
Dabble1SC authored Nov 26, 2023
2 parents 3d01d23 + 6b6890e commit 4c4e54b
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 72 deletions.
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

0 comments on commit 4c4e54b

Please sign in to comment.