Move mission briefing to rules.

This commit is contained in:
Paul Chote
2016-03-02 20:56:46 +00:00
parent 668e13b849
commit 01a14d9ae5
8 changed files with 68 additions and 70 deletions

View File

@@ -52,10 +52,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var author = widget.Get<TextFieldWidget>("AUTHOR");
author.Text = map.Author;
// TODO: This should use a multi-line textfield once they exist
var description = widget.Get<TextFieldWidget>("DESCRIPTION");
description.Text = map.Description;
// TODO: This should use a multi-selection dropdown once they exist
var visibilityDropdown = widget.Get<DropDownButtonWidget>("VISIBILITY_DROPDOWN");
{
@@ -160,7 +156,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return;
map.Title = title.Text;
map.Description = description.Text;
map.Author = author.Text;
map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), visibilityDropdown.Text);

View File

@@ -9,6 +9,7 @@
*/
#endregion
using OpenRA.Mods.Common.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
@@ -24,12 +25,16 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var mapDescriptionPanel = widget.Get<ScrollPanelWidget>("MAP_DESCRIPTION_PANEL");
var mapDescription = widget.Get<LabelWidget>("MAP_DESCRIPTION");
var mapFont = Game.Renderer.Fonts[mapDescription.Font];
var text = world.Map.Description != null ? world.Map.Description.Replace("\\n", "\n") : "";
text = WidgetUtils.WrapText(text, mapDescription.Bounds.Width, mapFont);
mapDescription.Text = text;
mapDescription.Bounds.Height = mapFont.Measure(text).Y;
mapDescriptionPanel.ScrollToTop();
mapDescriptionPanel.Layout.AdjustChildren();
var missionData = world.Map.Rules.Actors["world"].TraitInfoOrDefault<MissionDataInfo>();
if (missionData != null)
{
var text = WidgetUtils.WrapText(missionData.Briefing.Replace("\\n", "\n"), mapDescription.Bounds.Width, mapFont);
mapDescription.Text = text;
mapDescription.Bounds.Height = mapFont.Measure(text).Y;
mapDescriptionPanel.ScrollToTop();
mapDescriptionPanel.Layout.AdjustChildren();
}
}
}
}

View File

@@ -189,16 +189,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var infoVideoVisible = false;
var infoVideoDisabled = true;
var map = selectedMap;
new Thread(() =>
{
selectedMap.PreloadRules();
var mapOptions = selectedMap.Rules.Actors["world"].TraitInfo<MapOptionsInfo>();
map.PreloadRules();
var mapOptions = map.Rules.Actors["world"].TraitInfo<MapOptionsInfo>();
difficulty = mapOptions.Difficulty ?? mapOptions.Difficulties.FirstOrDefault();
difficulties = mapOptions.Difficulties;
difficultyDisabled = mapOptions.DifficultyLocked || mapOptions.Difficulties.Length <= 1;
var missionData = selectedMap.Rules.Actors["world"].TraitInfoOrDefault<MissionDataInfo>();
var missionData = map.Rules.Actors["world"].TraitInfoOrDefault<MissionDataInfo>();
if (missionData != null)
{
briefingVideo = missionData.BriefingVideo;
@@ -208,6 +209,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
infoVideo = missionData.BackgroundVideo;
infoVideoVisible = infoVideo != null;
infoVideoDisabled = !(infoVideoVisible && modData.DefaultFileSystem.Exists(infoVideo));
var briefing = WidgetUtils.WrapText(missionData.Briefing.Replace("\\n", "\n"), description.Bounds.Width, descriptionFont);
var height = descriptionFont.Measure(briefing).Y;
Game.RunAfterTick(() =>
{
if (map == selectedMap)
{
description.Text = briefing;
description.Bounds.Height = height;
descriptionPanel.Layout.AdjustChildren();
}
});
}
}).Start();
@@ -219,12 +232,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
startInfoVideoButton.IsDisabled = () => infoVideoDisabled || playingVideo != PlayingVideo.None;
startInfoVideoButton.OnClick = () => PlayVideo(videoPlayer, infoVideo, PlayingVideo.Info, () => StopVideo(videoPlayer));
var text = selectedMap.Description != null ? selectedMap.Description.Replace("\\n", "\n") : "";
text = WidgetUtils.WrapText(text, description.Bounds.Width, descriptionFont);
description.Text = text;
description.Bounds.Height = descriptionFont.Measure(text).Y;
descriptionPanel.ScrollToTop();
descriptionPanel.Layout.AdjustChildren();
if (difficultyButton != null)
{