Page MenuHomeFeedback Tracker

On screen radio controlls dont check if they can be used
Assigned, NormalPublic

Description

In SCR_VONEntryRadio there are methods that presumably determine whether or not radio frequency and power can be set wia 'on screen controls' - [G]+[Scroll]/[R] - but despite modding it to return false it only grayed out controls but player is still able to use them to turn radio on/off and change radio frequency

Here are methods that probably should dictate if on screen controls can be used:
CanBeAdjusted()
CanBeToggled()

Here are affected methods:
AdjustEntry
AdjustEntryModif*
ToggleEntry

Here is a video with controls being grayed out but player still being able to use them despite usage of the code provided in section "Steps To Reproduce"

*AdjustEntryModif this one is not used wia 'on screen actions' but as far as i understand it if CanBeAdjusted() returns false then this also shouldnt be able to adjust radio frequency

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10
Category
General
Steps To Reproduce

modded class SCR_VONEntryRadio : SCR_VONEntry
{
override bool CanBeAdjusted()
{

		return false;

}

override bool CanBeToggled()
{

		return false;

}
}

Additional Information

This is how i fixed it temporarily:

	override void AdjustEntry(int modifier)
	{
		if (!m_bIsEnabled)
			return;

		// Get & adjust frequency
		m_iFrequency = m_RadioComp.GetFrequency();

		if(CanBeAdjusted())//<------this way it wont change the frequency but it will update text (frequency) that is shown when radio is turned on
		{
			int minFreq = m_RadioComp.GetMinFrequency();
			int maxFreq = m_RadioComp.GetMaxFrequency();

			// TODO sound temp here until moved to radio level
			if ( (modifier > 0  && m_iFrequency == maxFreq) || (modifier < 0 && m_iFrequency == minFreq) )
				SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_RADIO_CHANGEFREQUENCY_ERROR);
			else if (modifier != 0)
				SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_RADIO_CHANGEFREQUENCY);

			m_iFrequency = m_iFrequency + (modifier * m_RadioComp.GetFrequencyResolution());
			m_iFrequency = Math.ClampInt(m_iFrequency, minFreq, maxFreq);

			m_RadioComp.SetFrequency(m_iFrequency); // Set new frequency
		}

		float fFrequency = Math.Round(m_iFrequency / 10); // Format the frequency text
		fFrequency = fFrequency / 100;
		m_sText = fFrequency.ToString(3, 1) + " " + LABEL_FREQUENCY_UNITS;
	}

	//------------------------------------------------------------------------------------------------
	override void AdjustEntryModif(int modifier)
	{
		if(!CanBeAdjusted())//<------if im not supposed to change frequency then there's no need to do anything more including updating frequency on screen
		return;

		SCR_GroupsManagerComponent groupManager = SCR_GroupsManagerComponent.Cast(GetGame().GetGameMode().FindComponent(SCR_GroupsManagerComponent));
		SCR_MilitaryFaction playerFaction = SCR_MilitaryFaction.Cast(SCR_RespawnSystemComponent.GetInstance().GetPlayerFaction(GetGame().GetPlayerController().GetPlayerId()));

		if (!groupManager || !playerFaction)
			return;

		int factionFreq = playerFaction.GetFactionRadioFrequency();
		int currentFreq = m_RadioComp.GetFrequency();

		array<SCR_AIGroup> groups = groupManager.GetPlayableGroupsByFaction(playerFaction);

		int newFreq;

		if (currentFreq == factionFreq)		// if platoon frequency
		{
			if (modifier == -1)
				newFreq = groups[0].GetGroupFrequency();	// go to first squad freq
			else
				newFreq = groups[groups.Count() - 1].GetGroupFrequency();	// go to last squad freq
		}
		else
		{
			int count = groups.Count();
			if (modifier == 1 && currentFreq == groups[0].GetGroupFrequency())
				newFreq = factionFreq;
			else if (modifier == -1 && currentFreq == groups[groups.Count() - 1].GetGroupFrequency())
				newFreq = factionFreq;
			else
			{
				bool isMatched;

				for (int i = 0; i < count; i++)
				{
					if (currentFreq == groups[i].GetGroupFrequency())
					{
						if (modifier == 1)
							newFreq = groups[i-1].GetGroupFrequency();
						else
							newFreq = groups[i+1].GetGroupFrequency();

						isMatched = true;
						break;
					}
				}

				if (!isMatched)
					newFreq = groups[0].GetGroupFrequency();
			}
		}

		m_iFrequency = newFreq;
		m_RadioComp.SetFrequency(m_iFrequency);

		float fFrequency = Math.Round(m_iFrequency / 10); // Format the frequency text
		fFrequency = fFrequency / 100;
		m_sText = fFrequency.ToString(3, 1) + " " + LABEL_FREQUENCY_UNITS;
	}

	//------------------------------------------------------------------------------------------------
	override void ToggleEntry()
	{
		if(CanBeToggled()) //<------as that way ui elements will be updated when player turns on the raido with radio interaction (for eg wia knob)
		{
			m_bIsEnabled = !m_RadioComp.IsPowered();

			m_RadioComp.TogglePower(m_bIsEnabled);
		}

		if (!m_bIsEnabled)
			m_sText = LABEL_DEACTIVATED;
		else
			AdjustEntry(0);
	}

Event Timeline

Geez changed the task status from New to Assigned.Mar 17 2023, 10:06 AM