Skip to content

feat(Radio): Disable beeps when ACE Radio is loaded #15

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
91 changes: 49 additions & 42 deletions addons/core/UI/layouts/Menus/SettingsMenu/AFM_Settings.layout
Original file line number Diff line number Diff line change
Expand Up @@ -23,55 +23,62 @@ HorizontalLayoutWidgetClass {
Padding -4 0 10 0
}
{
VerticalLayoutWidgetClass "{63301827145A82EF}" : "{FEEEB639F2735BA1}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsTitle.layout" {
Name "TitleGeneral"
Slot LayoutSlot "{58B30C1CBB34716F}" {
}
components {
SCR_LabelComponent "{58B30C1A8E56F0FF}" {
m_sLabel "#AFM_Core-Settings_Radio"
m_fPaddingTop 4
}
VerticalLayoutWidgetClass "{65135E8A7D369F8B}" {
Name "RadioCategory"
Slot LayoutSlot "{65135E8A7D369FA4}" {
}
{
TextWidgetClass "{58B30C1F77EC7B4E}" {
Prefab "{58B30C1F77EC7B4E}"
Slot LayoutSlot "{58B30C1F77EC7B76}" {
Padding 39 4 39 20
VerticalLayoutWidgetClass "{63301827145A82EF}" : "{FEEEB639F2735BA1}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsTitle.layout" {
Name "TitleGeneral"
Slot LayoutSlot "{58B30C1CBB34716F}" {
}
components {
SCR_LabelComponent "{58B30C1A8E56F0FF}" {
m_sLabel "#AFM_Core-Settings_Radio"
m_fPaddingTop 4
}
}
{
TextWidgetClass "{58B30C1F77EC7B4E}" {
Prefab "{58B30C1F77EC7B4E}"
Slot LayoutSlot "{58B30C1F77EC7B76}" {
Padding 39 4 39 20
}
}
}
}
}
}
ButtonWidgetClass "{63301827145A82E6}" : "{C9DF0E6590F6C388}UI/layouts/WidgetLibrary/SpinBox/WLib_SpinBox.layout" {
Name "Beep_Ch1"
Slot LayoutSlot "{54890CCD613ED416}" {
Padding 4 4 4 4
}
components {
SCR_SpinBoxComponent "{5472C6CBC0640458}" {
m_sLabel "#AFM_Core-Settings_Radio_Beep_Ch1"
m_sLabelLayout "{F003823FF141983C}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsLabel.layout"
m_aElementNames {
"#AFM_Core-Settings_Radio_Beep_Off" "#AFM_Core-Settings_Radio_Beep_1" "#AFM_Core-Settings_Radio_Beep_2"
ButtonWidgetClass "{63301827145A82E6}" : "{C9DF0E6590F6C388}UI/layouts/WidgetLibrary/SpinBox/WLib_SpinBox.layout" {
Name "Beep_Ch1"
Slot LayoutSlot "{54890CCD613ED416}" {
Padding 4 4 4 4
}
components {
SCR_SpinBoxComponent "{5472C6CBC0640458}" {
m_sLabel "#AFM_Core-Settings_Radio_Beep_Ch1"
m_sLabelLayout "{F003823FF141983C}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsLabel.layout"
m_aElementNames {
"#AFM_Core-Settings_Radio_Beep_Off" "#AFM_Core-Settings_Radio_Beep_1" "#AFM_Core-Settings_Radio_Beep_2"
}
m_bUseLightArrows 1
m_bCycleMode 1
}
}
m_bUseLightArrows 1
m_bCycleMode 1
}
}
}
ButtonWidgetClass "{6330182609023B86}" : "{C9DF0E6590F6C388}UI/layouts/WidgetLibrary/SpinBox/WLib_SpinBox.layout" {
Name "Beep_Ch2"
Slot LayoutSlot "{54890CCD613ED416}" {
Padding 4 4 4 4
}
components {
SCR_SpinBoxComponent "{5472C6CBC0640458}" {
m_sLabel "#AFM_Core-Settings_Radio_Beep_Ch2"
m_sLabelLayout "{F003823FF141983C}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsLabel.layout"
m_aElementNames {
"#AFM_Core-Settings_Radio_Beep_Off" "#AFM_Core-Settings_Radio_Beep_1" "#AFM_Core-Settings_Radio_Beep_2"
ButtonWidgetClass "{6330182609023B86}" : "{C9DF0E6590F6C388}UI/layouts/WidgetLibrary/SpinBox/WLib_SpinBox.layout" {
Name "Beep_Ch2"
Slot LayoutSlot "{54890CCD613ED416}" {
Padding 4 4 4 4
}
components {
SCR_SpinBoxComponent "{5472C6CBC0640458}" {
m_sLabel "#AFM_Core-Settings_Radio_Beep_Ch2"
m_sLabelLayout "{F003823FF141983C}UI/layouts/Menus/SettingsMenu/CustomWidgets/SettingsLabel.layout"
m_aElementNames {
"#AFM_Core-Settings_Radio_Beep_Off" "#AFM_Core-Settings_Radio_Beep_1" "#AFM_Core-Settings_Radio_Beep_2"
}
m_bCycleMode 1
}
}
m_bCycleMode 1
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,47 @@ class AFM_SettingsSubMenu : SCR_SettingsSubMenuBase
//------------------------------------------------------------------------------------------------
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
{
BaseContainer radioSettings = GetGame().GetGameUserSettings().GetModule(MODULE_RADIO);

super.OnTabCreate(menuRoot, buttonsLayout, index);

if (!radioSettings)
return;

// Radio beep Ch1
SCR_SelectionWidgetComponent checkBoxBeep1 = SCR_SelectionWidgetComponent.GetSelectionComponent("Beep_Ch1", m_wRoot);
if (checkBoxBeep1)
{
int value;
radioSettings.Get("m_BeepCh1", value);

checkBoxBeep1.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
checkBoxBeep1.m_OnChanged.Insert(SetBeepCh1);
}
else
{
Print("Radio setting 'Beep_Ch1' not found", LogLevel.WARNING);
}

// Radio beep Ch1
SCR_SelectionWidgetComponent checkBoxBeep2 = SCR_SelectionWidgetComponent.GetSelectionComponent("Beep_Ch2", m_wRoot);
if (checkBoxBeep2)

BaseContainer radioSettings = GetGame().GetGameUserSettings().GetModule(MODULE_RADIO);
if (radioSettings && AFM_VONSettings.Enabled())
{
int value;
radioSettings.Get("m_BeepCh2", value);

checkBoxBeep2.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
checkBoxBeep2.m_OnChanged.Insert(SetBeepCh2);
// Radio beep Ch1
SCR_SelectionWidgetComponent checkBoxBeep1 = SCR_SelectionWidgetComponent.GetSelectionComponent("Beep_Ch1", m_wRoot);
if (checkBoxBeep1)
{
int value;
radioSettings.Get("m_BeepCh1", value);

checkBoxBeep1.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
checkBoxBeep1.m_OnChanged.Insert(SetBeepCh1);
}
else
{
Print("Radio setting 'Beep_Ch1' not found", LogLevel.WARNING);
}

// Radio beep Ch1
Copy link
Contributor

@nielu nielu Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel 2 but tbh I don't think this comment is necessary anyway, same for others in this file

SCR_SelectionWidgetComponent checkBoxBeep2 = SCR_SelectionWidgetComponent.GetSelectionComponent("Beep_Ch2", m_wRoot);
if (checkBoxBeep2)
{
int value;
radioSettings.Get("m_BeepCh2", value);

checkBoxBeep2.SetCurrentItem(value >> 1, false, false); //--- Shift the value, because it's a flag
checkBoxBeep2.m_OnChanged.Insert(SetBeepCh2);
}
else
{
Print("Radio setting 'Beep_Ch2' not found", LogLevel.WARNING);
}
}
else
{
Print("Radio setting 'Beep_Ch2' not found", LogLevel.WARNING);
Print("Radio settings category disabled");
VerticalLayoutWidget radioSettingsContainer = VerticalLayoutWidget.Cast(menuRoot.FindAnyWidget("RadioCategory"));
radioSettingsContainer.SetVisible(false);
radioSettingsContainer.SetEnabled(false);
}
}

Expand Down
21 changes: 21 additions & 0 deletions addons/core/scripts/Game/AFM_Core/VON/AFM_VONSettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ enum AFM_EVONBeep

class AFM_VONSettings : ModuleGameSettings
{
private const string GUID_ACE_RADIO = "64475DC102F2BDA4";

private static bool m_bEnabledLoaded;
private static bool m_bEnabled;

static bool Enabled()
{
// we can't simply use GameProject.GetAddonID as ACE_Radio can be available but not loaded
if (!m_bEnabledLoaded)
{
// TODO this could be extracted into an utility class if we will use it in more places
array<string> addonGUIDs = {};
GameProject.GetLoadedAddons(addonGUIDs);

m_bEnabled = !addonGUIDs.Contains(GUID_ACE_RADIO);
m_bEnabledLoaded = true;
}

return m_bEnabled;
}

[Attribute(AFM_EVONBeep.NORMAL.ToString(), uiwidget: UIWidgets.ComboBox, desc: "Sound to play when activating VoN Ch1", enums: ParamEnumArray.FromEnum(AFM_EVONBeep))]
AFM_EVONBeep m_BeepCh1;

Expand Down
18 changes: 11 additions & 7 deletions addons/core/scripts/Game/AFM_Core/VON/SCR_VONController.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ modded class SCR_VONController: ScriptComponent
const string SOUND_START_2 = "Sounds/AFM_Core/VON/beep_lr_on.wav";
const string SOUND_END = "Sounds/AFM_Core/VON/click_off.wav";

protected AFM_EVONBeep m_eBeepTypeCh1;
protected AFM_EVONBeep m_eBeepTypeCh2;
protected AFM_EVONBeep m_eBeepTypeCh1 = AFM_EVONBeep.OFF;
protected AFM_EVONBeep m_eBeepTypeCh2 = AFM_EVONBeep.OFF;
protected bool m_bBeepEnd = false;

//------------------------------------------------------------------------------------------------
override void OnPostInit(IEntity owner)
Expand All @@ -20,11 +21,14 @@ modded class SCR_VONController: ScriptComponent
protected void AFM_LoadSettings()
{
BaseContainer settings = GetGame().GetGameUserSettings().GetModule(AFM_SettingsSubMenu.MODULE_RADIO);
if (AFM_VONSettings.Enabled())
{
settings.Get("m_BeepCh1", m_eBeepTypeCh1);
settings.Get("m_BeepCh2", m_eBeepTypeCh2);
m_bBeepEnd = true;

settings.Get("m_BeepCh1", m_eBeepTypeCh1);
settings.Get("m_BeepCh2", m_eBeepTypeCh2);

PrintFormat("SCR_VONController.AFM_LoadSettings: %1, %2", m_eBeepTypeCh1, m_eBeepTypeCh2, level: LogLevel.DEBUG);
PrintFormat("SCR_VONController.AFM_LoadSettings: %1, %2", m_eBeepTypeCh1, m_eBeepTypeCh2, level: LogLevel.DEBUG);
}
}

//------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -64,7 +68,7 @@ modded class SCR_VONController: ScriptComponent
//------------------------------------------------------------------------------------------------
override void DeactivateVON(EVONTransmitType transmitType = EVONTransmitType.NONE)
{
if (m_bIsActive)
if (m_bIsActive && m_bBeepEnd)
{
if (transmitType != EVONTransmitType.DIRECT)
{
Expand Down