Move mission briefing to rules.
This commit is contained in:
@@ -86,7 +86,6 @@ namespace OpenRA
|
||||
|
||||
public string Title;
|
||||
public string Type = "Conquest";
|
||||
public string Description;
|
||||
public string Author;
|
||||
public string Tileset;
|
||||
public Bitmap CustomPreview;
|
||||
@@ -201,7 +200,6 @@ namespace OpenRA
|
||||
var tileRef = new TerrainTile(tileset.Templates.First().Key, 0);
|
||||
|
||||
Title = "Name your map here";
|
||||
Description = "Describe your map here";
|
||||
Author = "Your name here";
|
||||
|
||||
MapSize = new int2(size);
|
||||
@@ -429,7 +427,6 @@ namespace OpenRA
|
||||
"MapFormat",
|
||||
"RequiresMod",
|
||||
"Title",
|
||||
"Description",
|
||||
"Author",
|
||||
"Tileset",
|
||||
"MapSize",
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Defines the FMVs that can be played by missions.")]
|
||||
public class MissionDataInfo : TraitInfo<MissionData>
|
||||
{
|
||||
[Desc("Briefing text displayed in the mission browser.")]
|
||||
public readonly string Briefing;
|
||||
|
||||
[Desc("Played by the \"Background Info\" button in the mission browser.")]
|
||||
public readonly string BackgroundVideo;
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
Author = "Westwood Studios"
|
||||
};
|
||||
|
||||
Map.Description = ExtractBriefing(file);
|
||||
|
||||
Map.RequiresMod = modData.Manifest.Mod.Id;
|
||||
|
||||
SetBounds(Map, mapSection);
|
||||
@@ -77,6 +75,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
ReadTrees(file);
|
||||
|
||||
LoadVideos(file, "BASIC");
|
||||
LoadBriefing(file);
|
||||
|
||||
ReadActors(file);
|
||||
|
||||
@@ -120,17 +119,34 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
|
||||
public abstract void ValidateMapFormat(int format);
|
||||
|
||||
static string ExtractBriefing(IniFile file)
|
||||
void LoadBriefing(IniFile file)
|
||||
{
|
||||
var briefingSection = file.GetSection("Briefing", true);
|
||||
if (briefingSection == null)
|
||||
return string.Empty;
|
||||
return;
|
||||
|
||||
var briefing = new StringBuilder();
|
||||
foreach (var s in briefingSection)
|
||||
briefing.AppendLine(s.Value);
|
||||
|
||||
return briefing.Replace("\n", " ").ToString();
|
||||
if (briefing.Length == 0)
|
||||
return;
|
||||
|
||||
var worldNode = Rules.Nodes.FirstOrDefault(n => n.Key == "World");
|
||||
if (worldNode == null)
|
||||
{
|
||||
worldNode = new MiniYamlNode("World", new MiniYaml("", new List<MiniYamlNode>()));
|
||||
Rules.Nodes.Add(worldNode);
|
||||
}
|
||||
|
||||
var missionData = worldNode.Value.Nodes.FirstOrDefault(n => n.Key == "MissionData");
|
||||
if (missionData == null)
|
||||
{
|
||||
missionData = new MiniYamlNode("MissionData", new MiniYaml("", new List<MiniYamlNode>()));
|
||||
worldNode.Value.Nodes.Add(missionData);
|
||||
}
|
||||
|
||||
missionData.Value.Nodes.Add(new MiniYamlNode("Briefing", briefing.Replace("\n", " ").ToString()));
|
||||
}
|
||||
|
||||
static void SetBounds(Map map, IniSection mapSection)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ Background@SAVE_MAP_PANEL:
|
||||
X: (WINDOW_RIGHT - WIDTH)/2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width: 345
|
||||
Height: 264
|
||||
Height: 229
|
||||
Children:
|
||||
Label@LABEL_TITLE:
|
||||
Text: Save Map
|
||||
@@ -89,7 +89,7 @@ Background@SAVE_MAP_PANEL:
|
||||
Align: Center
|
||||
Background@SAVE_MAP_BACKGROUND:
|
||||
Width: PARENT_RIGHT
|
||||
Height: 230
|
||||
Height: 195
|
||||
Background: panel-black
|
||||
Children:
|
||||
Label@TITLE_LABEL:
|
||||
@@ -118,60 +118,47 @@ Background@SAVE_MAP_PANEL:
|
||||
Width: 220
|
||||
MaxLength: 50
|
||||
Height: 25
|
||||
Label@DESCRIPTION_LABEL:
|
||||
X: 10
|
||||
Y: 84
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Description:
|
||||
TextField@DESCRIPTION:
|
||||
X: 110
|
||||
Y: 85
|
||||
Width: 220
|
||||
MaxLength: 50
|
||||
Height: 25
|
||||
Label@VISIBILITY_LABEL:
|
||||
X: 10
|
||||
Y: 119
|
||||
Y: 84
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Visibility:
|
||||
DropDownButton@VISIBILITY_DROPDOWN:
|
||||
X: 110
|
||||
Y: 120
|
||||
Y: 85
|
||||
Width: 220
|
||||
Height: 25
|
||||
Font: Regular
|
||||
Label@DIRECTORY_LABEL:
|
||||
X: 10
|
||||
Y: 154
|
||||
Y: 119
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Directory:
|
||||
DropDownButton@DIRECTORY_DROPDOWN:
|
||||
X: 110
|
||||
Y: 155
|
||||
Y: 120
|
||||
Width: 220
|
||||
Height: 25
|
||||
Font: Regular
|
||||
Label@FILENAME_LABEL:
|
||||
X: 10
|
||||
Y: 189
|
||||
Y: 154
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Filename:
|
||||
TextField@FILENAME:
|
||||
X: 110
|
||||
Y: 190
|
||||
Y: 155
|
||||
Width: 105
|
||||
Height: 25
|
||||
DropDownButton@TYPE_DROPDOWN:
|
||||
X: 220
|
||||
Y: 190
|
||||
Y: 155
|
||||
Width: 110
|
||||
Height: 25
|
||||
Font: Regular
|
||||
|
||||
@@ -75,7 +75,7 @@ Background@SAVE_MAP_PANEL:
|
||||
X: (WINDOW_RIGHT - WIDTH)/2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width: 350
|
||||
Height: 335
|
||||
Height: 300
|
||||
Children:
|
||||
Label@LABEL_TITLE:
|
||||
X: (PARENT_RIGHT - WIDTH)/2
|
||||
@@ -111,58 +111,45 @@ Background@SAVE_MAP_PANEL:
|
||||
Width: 220
|
||||
MaxLength: 50
|
||||
Height: 25
|
||||
Label@DESCRIPTION_LABEL:
|
||||
X: 10
|
||||
Y: 129
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Description:
|
||||
TextField@DESCRIPTION:
|
||||
X: 110
|
||||
Y: 130
|
||||
Width: 220
|
||||
MaxLength: 50
|
||||
Height: 25
|
||||
Label@VISIBILITY_LABEL:
|
||||
X: 10
|
||||
Y: 164
|
||||
Y: 129
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Visibility:
|
||||
DropDownButton@VISIBILITY_DROPDOWN:
|
||||
X: 110
|
||||
Y: 165
|
||||
Y: 130
|
||||
Width: 220
|
||||
Height: 25
|
||||
Label@DIRECTORY_LABEL:
|
||||
X: 10
|
||||
Y: 199
|
||||
Y: 164
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Directory:
|
||||
DropDownButton@DIRECTORY_DROPDOWN:
|
||||
X: 110
|
||||
Y: 200
|
||||
Y: 165
|
||||
Width: 220
|
||||
Height: 25
|
||||
Label@FILENAME_LABEL:
|
||||
X: 10
|
||||
Y: 234
|
||||
Y: 199
|
||||
Width: 95
|
||||
Height: 25
|
||||
Align: Right
|
||||
Text: Filename:
|
||||
TextField@FILENAME:
|
||||
X: 110
|
||||
Y: 235
|
||||
Y: 200
|
||||
Width: 105
|
||||
Height: 25
|
||||
DropDownButton@TYPE_DROPDOWN:
|
||||
X: 220
|
||||
Y: 235
|
||||
Y: 200
|
||||
Width: 110
|
||||
Height: 25
|
||||
Button@SAVE_BUTTON:
|
||||
|
||||
Reference in New Issue
Block a user