Skip to content

Commit

Permalink
Remove 1 extra-public-freq function in master frequency update
Browse files Browse the repository at this point in the history
  • Loading branch information
KSP-TaxiService committed Dec 12, 2020
1 parent 88777c5 commit 710a954
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/CommNetConstellation/UI/VesselMgtTools/VanillaFreqTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class VanillaFreqTool : AbstractMgtTool
private static readonly Texture2D colorTexture = UIUtils.loadImage("colorDisplay");
private DialogGUITextInput frequencyInput;
private DialogGUIImage constellationColorImage;
private bool membershipOption;

public VanillaFreqTool(CommNetVessel thisVessel, Callback updateFreqRowsCallback) : base(thisVessel, "vanilla", Localizer.Format("#CNC_ToolsNames_MasterFrequency"), new List<Callback>() { updateFreqRowsCallback })//"Master frequency"
{
Expand All @@ -27,17 +26,14 @@ public override List<DialogGUIBase> getContentComponents()
DialogGUILabel msgLbl = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_msgLabel4"), 100, 32);//"Set up the master frequency in one go. All antennas will be assigned to this frequency, and Comm powers of those deployed antennas will be combined."
layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl }));

DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_FrequencyLabel") + "</b>", 52, 12);//Frequency
DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_FrequencyLabel") + "</b>", 60, 12);//Frequency
frequencyInput = new DialogGUITextInput(CNCSettings.Instance.PublicRadioFrequency+"", false, CNCSettings.MaxDigits, setConstellFreq, 45, 25);
DialogGUIToggle membershipToggle = new DialogGUIToggle(false, "", membershipFlagToggle);
DialogGUILabel membershipLabel = new DialogGUILabel("<b>"+Localizer.Format("#CNC_getContentCompon_membershipLabel") +"</b>", 200, 12);//Talk to constellation members only

DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(20), membershipToggle, membershipLabel });
layout.Add(constellationGroup);

constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, Color.white, colorTexture);
DialogGUILabel constNameLabel = new DialogGUILabel(getConstellationName, 200, 12);
layout.Add(new DialogGUIHorizontalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { constNameLabel, constellationColorImage }));

DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUISpace(45), freqLabel, frequencyInput, new DialogGUISpace(45), constNameLabel, constellationColorImage, new DialogGUISpace(45) });
layout.Add(constellationGroup);

DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateClick, false);//"Update"
DialogGUIButton publicButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_PublicButton"), defaultClick, false);//"Revert to public"
Expand All @@ -47,11 +43,6 @@ public override List<DialogGUIBase> getContentComponents()
return layout;
}

private void membershipFlagToggle(bool state)
{
this.membershipOption = state;
}

private string setConstellFreq(string freqInput)
{
//do nothing
Expand Down Expand Up @@ -79,6 +70,7 @@ private string getConstellationName()
private void defaultClick()
{
frequencyInput.uiItem.GetComponent<TMP_InputField>().text = CNCSettings.Instance.PublicRadioFrequency.ToString();
updateClick();
}

private void updateClick()
Expand Down Expand Up @@ -114,13 +106,6 @@ private void updateClick()
this.cncVessel.updateFrequency(thisAntenna, userFreq);
}
this.cncVessel.rebuildFreqList();

//if membership option is not enabled, add public freq of same comm power
if (!membershipOption && userFreq != CNCSettings.Instance.PublicRadioFrequency)
{
double commPower = this.cncVessel.getMaxComPower(userFreq);
this.cncVessel.addToFreqList(CNCSettings.Instance.PublicRadioFrequency, commPower);
}

actionCallbacks[0]();
}
Expand Down

0 comments on commit 710a954

Please sign in to comment.