Skip to content

Commit

Permalink
Move messages to top-center position and update all interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
KSP-TaxiService committed Apr 15, 2018
1 parent 408618f commit 6074bf0
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/CommNetConstellation/CommNetLayer/CNCCommNetVessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ public bool isFreqListEditable()
return true;
}

ScreenMessage msg = new ScreenMessage(string.Format("Frequency list of Vessel '{0}' is locked.", this.vessel.GetDisplayName()), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage(string.Format("Frequency list of Vessel '{0}' is locked.", this.vessel.GetDisplayName()), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
CNCLog.Verbose("CommNet Vessel '{0}''s freq list is locked", this.Vessel.GetName());
return false;
Expand Down Expand Up @@ -645,7 +645,7 @@ public void toggleAntenna(CNCAntennaPartInfo partInfo, bool inUse)
{
if(!partInfo.canComm) // antenna is not deployed
{
ScreenMessage msg = new ScreenMessage(string.Format("Antenna '{0}' is not deployed.", partInfo.name), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage(string.Format("Antenna '{0}' is not deployed.", partInfo.name), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
CNCLog.Verbose("Cannot set the non-deployed antenna '{0}' of CommNet vessel '{1}' to {2}", partInfo.name, this.Vessel.GetName(), inUse);
return;
Expand Down
14 changes: 7 additions & 7 deletions src/CommNetConstellation/UI/AntennaSetupDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public AntennaSetupDialog(string title, Vessel vessel, Part antennaPart) : base(
0.5f, //x
0.5f, //y
250, //width
230, //height
210, //height
new DialogOptions[] { DialogOptions.HideCloseButton})
{
this.hostVessel = vessel;
Expand All @@ -50,20 +50,20 @@ protected override List<DialogGUIBase> drawContentComponents()

DialogGUILabel nameLabel = new DialogGUILabel("<b>Name</b>", 40, 12);
nameInput = new DialogGUITextInput(antennaModule.Name, false, CNCSettings.MaxLengthName, setNameInput, 145, 25);
DialogGUIButton defaultButton = new DialogGUIButton("Reset", defaultNameClick, 40, 32, false);
DialogGUIButton defaultButton = new DialogGUIButton("Reset", defaultNameClick, 45, 25, false);
DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nameLabel, nameInput, defaultButton });
listComponments.Add(nameGroup);

DialogGUILabel freqLabel = new DialogGUILabel("<b>Frequency</b>", 52, 12);
frequencyInput = new DialogGUITextInput(antennaModule.Frequency.ToString(), false, CNCSettings.MaxDigits, setConstellFreq, 45, 25);
DialogGUIButton publicButton = new DialogGUIButton("Revert to public", defaultFreqClick, false);
DialogGUIButton publicButton = new DialogGUIButton("Revert to public", defaultFreqClick, 100, 25, false);
DialogGUIHorizontalLayout freqGRoup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, publicButton });
listComponments.Add(freqGRoup);

constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, Color.white, colorTexture);
DialogGUILabel constNameLabel = new DialogGUILabel(getConstellationName, 200, 12);
DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(5, 25, 5, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { constellationColorImage, constNameLabel });
listComponments.Add(new DialogGUIScrollList(Vector2.one, false, false, constellationGroup));
listComponments.Add(new DialogGUIScrollList(new Vector2(200, 40), false, false, constellationGroup));

DialogGUIButton updateButton = new DialogGUIButton("Update", updateAction, false);
DialogGUIButton cancelButton = new DialogGUIButton("Cancel", delegate { this.dismiss(); }, false);
Expand Down Expand Up @@ -138,15 +138,15 @@ private void updateAction()
if (this.antennaModule.Frequency != inputFreq) // different frequency
{
this.antennaModule.Frequency = inputFreq;
ScreenMessage msg = new ScreenMessage(string.Format("Frequency is updated to {0}", inputFreq), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage(string.Format("Frequency is updated to {0}", inputFreq), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
changesCommitted = true;
}

if (!this.antennaModule.Name.Equals(inputName)) // different name
{
this.antennaModule.Name = inputName;
ScreenMessage msg = new ScreenMessage(string.Format("Antenna is renamed to '{0}'", this.antennaModule.Name), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage(string.Format("Antenna is renamed to '{0}'", this.antennaModule.Name), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
changesCommitted = true;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ private void updateAction()
}
catch (Exception e)
{
ScreenMessage msg = new ScreenMessage("<color=red>" + e.Message + "</color>", CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage("<color=red>" + e.Message + "</color>", CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
}
}
Expand Down
26 changes: 16 additions & 10 deletions src/CommNetConstellation/UI/ConstellationControlDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ protected override List<DialogGUIBase> drawContentComponents()

List<DialogGUIBase> listComponments = new List<DialogGUIBase>();

listComponments.Add(new DialogGUILabel("Administer multiple communication constellations of vessels with one or more frequencies. Ground, air and space vessels can be independently assigned and configured.", false, false));
DialogGUIButton constellationBtn = new DialogGUIButton("Constellations", delegate { displayContentLayout(ContentType.CONSTELLATIONS); }, false);
DialogGUIButton groundstationBtn = new DialogGUIButton("Ground Stations", delegate { displayContentLayout(ContentType.GROUNDSTATIONS); }, false);
DialogGUIButton vesselBtn = new DialogGUIButton("CommNet Vessels", delegate { displayContentLayout(ContentType.VESSELS); }, false);
listComponments.Add(new DialogGUILabel("Manage communication networks of ground, air and space vessels.", false, false));

float btnWidth = (600-50)/3;
float btnHeight = 32;
DialogGUIButton constellationBtn = new DialogGUIButton("Constellations", delegate { displayContentLayout(ContentType.CONSTELLATIONS); }, btnWidth, btnHeight, false);
DialogGUIButton groundstationBtn = new DialogGUIButton("Ground Stations", delegate { displayContentLayout(ContentType.GROUNDSTATIONS); }, btnWidth, btnHeight, false);
DialogGUIButton vesselBtn = new DialogGUIButton("CommNet Vessels", delegate { displayContentLayout(ContentType.VESSELS); }, btnWidth, btnHeight, false);
listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { constellationBtn, groundstationBtn, vesselBtn}));

contentLayout = new DialogGUIVerticalLayout(true, false, 4, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, new DialogGUIBase[] { new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true) });
contentLayout.AddChildren(getVesselContentLayout().ToArray());
this.currentContentType = ContentType.VESSELS;
listComponments.Add(new DialogGUIScrollList(Vector2.one, false, true, contentLayout));
listComponments.Add(new DialogGUIScrollList(new Vector2(550, 250), false, true, contentLayout));

sortVesselBtnLayout = new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, getVesselSortLayout());
listComponments.Add(sortVesselBtnLayout);
Expand Down Expand Up @@ -317,11 +320,14 @@ private List<DialogGUIBase> getVesselContentLayout()

private DialogGUIBase[] getVesselSortLayout()
{
DialogGUILabel sortLabel = new DialogGUILabel("Sort by");
DialogGUIButton launchSortBtn = new DialogGUIButton("Launch time", delegate { currentVesselSort = VesselListSort.LAUNCHDATE; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, false);
DialogGUIButton freqSortBtn = new DialogGUIButton("Strongest frequency", delegate { currentVesselSort = VesselListSort.RADIOFREQ; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, false);
DialogGUIButton nameSortBtn = new DialogGUIButton("Vessel name", delegate { currentVesselSort = VesselListSort.VESSELNAME; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, false);
DialogGUIButton bodySortBtn = new DialogGUIButton("Celestial body", delegate { currentVesselSort = VesselListSort.CBODY; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, false);
float btnWidth = 100;
float btnHeight = 28;

DialogGUILabel sortLabel = new DialogGUILabel("Sort by", 35, 12);
DialogGUIButton launchSortBtn = new DialogGUIButton("Launch time", delegate { currentVesselSort = VesselListSort.LAUNCHDATE; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);
DialogGUIButton freqSortBtn = new DialogGUIButton("Strongest frequency", delegate { currentVesselSort = VesselListSort.RADIOFREQ; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth+40, btnHeight, false);
DialogGUIButton nameSortBtn = new DialogGUIButton("Vessel name", delegate { currentVesselSort = VesselListSort.VESSELNAME; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);
DialogGUIButton bodySortBtn = new DialogGUIButton("Celestial body", delegate { currentVesselSort = VesselListSort.CBODY; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);

return new DialogGUIBase[] { sortLabel, launchSortBtn, freqSortBtn, nameSortBtn, bodySortBtn };
}
Expand Down
22 changes: 11 additions & 11 deletions src/CommNetConstellation/UI/ConstellationEditDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ protected override List<DialogGUIBase> drawContentComponents()

listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description+"\n\n", false, false) }));

DialogGUILabel nameLabel = new DialogGUILabel("<b>Name</b>", 52, 12);
DialogGUILabel nameLabel = new DialogGUILabel("<b>Name</b>", 60, 12);
nameInput = new DialogGUITextInput(constellName, false, CNCSettings.MaxLengthName, setConstellName, 170, 25);
DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { nameLabel, nameInput });
listComponments.Add(nameGroup);

DialogGUILabel freqLabel = new DialogGUILabel("<b>Frequency</b>", 52, 12);
frequencyInput = new DialogGUITextInput(constellFreq.ToString(), false, CNCSettings.MaxDigits, setConstellFreq, 47, 25);
constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.zero, this.constellColor, colorTexture);
DialogGUIButton colorButton = new DialogGUIButton("Color", colorEditClick, null, 50, 32, false);
DialogGUIHorizontalLayout freqColorGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(16), colorButton, constellationColorImage });
DialogGUILabel freqLabel = new DialogGUILabel("<b>Frequency</b>", 60, 12);
frequencyInput = new DialogGUITextInput(constellFreq.ToString(), false, CNCSettings.MaxDigits, setConstellFreq, 55, 25);
constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, this.constellColor, colorTexture);
DialogGUIButton colorButton = new DialogGUIButton("Color", colorEditClick, null, 50, 25, false);
DialogGUIHorizontalLayout freqColorGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(15), colorButton, constellationColorImage });
listComponments.Add(freqColorGroup);

DialogGUIButton updateButton = new DialogGUIButton(this.actionButtonText, actionClick, false);
Expand Down Expand Up @@ -167,7 +167,7 @@ private void actionClick()
creationCallback(newConstellation);

string message = string.Format("New constellation '{0}' of frequency {1} is created", constellName, constellFreq);
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT));
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER));

CNCLog.Debug("New constellation: {0}, {1}", constellName, constellFreq);

Expand Down Expand Up @@ -195,7 +195,7 @@ private void actionClick()
affectedStations[i].replaceFrequency(prevFreq, this.existingConstellation.frequency);
}

ScreenMessage msg = new ScreenMessage(string.Format("Constellation has the new frequency {0}", constellFreq), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage(string.Format("Constellation has the new frequency {0}", constellFreq), CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
changesCommitted = true;
}
Expand All @@ -204,15 +204,15 @@ private void actionClick()
{
this.existingConstellation.name = constellName;
string message = string.Format("Constellation is renamed to '{0}'", constellName);
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT));
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER));
changesCommitted = true;
}

if (!this.existingConstellation.color.Equals(this.constellColor)) // new color
{
this.existingConstellation.color = this.constellColor;
string message = string.Format("Constellation color becomes '{0}'", UIUtils.colorToHex(this.constellColor));
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT));
ScreenMessages.PostScreenMessage(new ScreenMessage(message, CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER));
changesCommitted = true;
}

Expand All @@ -236,7 +236,7 @@ private void actionClick()
}
catch (Exception e)
{
ScreenMessage msg = new ScreenMessage("<color=red>" + e.Message + "</color>", CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_LEFT);
ScreenMessage msg = new ScreenMessage("<color=red>" + e.Message + "</color>", CNCSettings.ScreenMessageDuration, ScreenMessageStyle.UPPER_CENTER);
ScreenMessages.PostScreenMessage(msg);
}
}
Expand Down
Loading

0 comments on commit 6074bf0

Please sign in to comment.