Add dynamic heights for things in the objectives panel.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Missions;
|
using OpenRA.Mods.RA.Missions;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
@@ -56,31 +57,47 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
public void UpdateObjectives(bool notify)
|
public void UpdateObjectives(bool notify)
|
||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
|
||||||
objectivesButton.Highlighted = true;
|
objectivesButton.Highlighted = true;
|
||||||
}
|
|
||||||
primaryPanel.RemoveChildren();
|
primaryPanel.RemoveChildren();
|
||||||
secondaryPanel.RemoveChildren();
|
secondaryPanel.RemoveChildren();
|
||||||
|
|
||||||
foreach (var o in objectives.Objectives.Where(o => o.Status != ObjectiveStatus.Inactive))
|
foreach (var o in objectives.Objectives.Where(o => o.Status != ObjectiveStatus.Inactive))
|
||||||
{
|
{
|
||||||
var objective = o;
|
var objective = o;
|
||||||
if (objective.Type == ObjectiveType.Secondary)
|
|
||||||
|
Widget widget;
|
||||||
|
LabelWidget objectiveText;
|
||||||
|
LabelWidget objectiveStatus;
|
||||||
|
|
||||||
|
if (objective.Type == ObjectiveType.Primary)
|
||||||
{
|
{
|
||||||
var template = secondaryTemplate.Clone();
|
widget = primaryTemplate.Clone();
|
||||||
template.Get<LabelWidget>("SECONDARY_OBJECTIVE").GetText = () => objective.Text;
|
objectiveText = widget.Get<LabelWidget>("PRIMARY_OBJECTIVE");
|
||||||
template.Get<LabelWidget>("SECONDARY_STATUS").GetText = () => GetObjectiveStatusText(objective.Status);
|
objectiveStatus = widget.Get<LabelWidget>("PRIMARY_STATUS");
|
||||||
secondaryPanel.AddChild(template);
|
SetupWidget(widget, objectiveText, objectiveStatus, objective);
|
||||||
|
primaryPanel.AddChild(widget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var template = primaryTemplate.Clone();
|
widget = secondaryTemplate.Clone();
|
||||||
template.Get<LabelWidget>("PRIMARY_OBJECTIVE").GetText = () => objective.Text;
|
objectiveText = widget.Get<LabelWidget>("SECONDARY_OBJECTIVE");
|
||||||
template.Get<LabelWidget>("PRIMARY_STATUS").GetText = () => GetObjectiveStatusText(objective.Status);
|
objectiveStatus = widget.Get<LabelWidget>("SECONDARY_STATUS");
|
||||||
primaryPanel.AddChild(template);
|
SetupWidget(widget, objectiveText, objectiveStatus, objective);
|
||||||
|
secondaryPanel.AddChild(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupWidget(Widget widget, LabelWidget objectiveText, LabelWidget objectiveStatus, Objective objective)
|
||||||
|
{
|
||||||
|
var font = Game.Renderer.Fonts[objectiveText.Font];
|
||||||
|
var text = WidgetUtils.WrapText(objective.Text, objectiveText.Bounds.Width, font);
|
||||||
|
widget.Bounds.Height = objectiveText.Bounds.Height = objectiveStatus.Bounds.Height = font.Measure(text).Y;
|
||||||
|
objectiveText.GetText = () => text;
|
||||||
|
objectiveStatus.GetText = () => GetObjectiveStatusText(objective.Status);
|
||||||
|
}
|
||||||
|
|
||||||
static string GetObjectiveStatusText(ObjectiveStatus status)
|
static string GetObjectiveStatusText(ObjectiveStatus status)
|
||||||
{
|
{
|
||||||
switch (status)
|
switch (status)
|
||||||
|
|||||||
@@ -34,13 +34,12 @@ Background@MISSION_OBJECTIVES:
|
|||||||
Y:70
|
Y:70
|
||||||
Width:PARENT_RIGHT-50
|
Width:PARENT_RIGHT-50
|
||||||
Height:200
|
Height:200
|
||||||
ItemSpacing:5
|
ItemSpacing:20
|
||||||
Children:
|
Children:
|
||||||
Container@PRIMARY_OBJECTIVE_TEMPLATE:
|
Container@PRIMARY_OBJECTIVE_TEMPLATE:
|
||||||
X:15
|
X:15
|
||||||
Y:0-15
|
Y:0
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:60
|
|
||||||
Children:
|
Children:
|
||||||
Label@PRIMARY_OBJECTIVE:
|
Label@PRIMARY_OBJECTIVE:
|
||||||
X:0
|
X:0
|
||||||
@@ -75,13 +74,12 @@ Background@MISSION_OBJECTIVES:
|
|||||||
Y:305
|
Y:305
|
||||||
Width:PARENT_RIGHT-50
|
Width:PARENT_RIGHT-50
|
||||||
Height:200
|
Height:200
|
||||||
ItemSpacing:5
|
ItemSpacing:20
|
||||||
Children:
|
Children:
|
||||||
Container@SECONDARY_OBJECTIVE_TEMPLATE:
|
Container@SECONDARY_OBJECTIVE_TEMPLATE:
|
||||||
X:15
|
X:15
|
||||||
Y:0-15
|
Y:0
|
||||||
Width:PARENT_RIGHT
|
Width:PARENT_RIGHT
|
||||||
Height:60
|
|
||||||
Children:
|
Children:
|
||||||
Label@SECONDARY_OBJECTIVE:
|
Label@SECONDARY_OBJECTIVE:
|
||||||
X:0
|
X:0
|
||||||
|
|||||||
Reference in New Issue
Block a user