Move mission briefing to rules.
This commit is contained in:
@@ -86,7 +86,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public string Title;
|
public string Title;
|
||||||
public string Type = "Conquest";
|
public string Type = "Conquest";
|
||||||
public string Description;
|
|
||||||
public string Author;
|
public string Author;
|
||||||
public string Tileset;
|
public string Tileset;
|
||||||
public Bitmap CustomPreview;
|
public Bitmap CustomPreview;
|
||||||
@@ -201,7 +200,6 @@ namespace OpenRA
|
|||||||
var tileRef = new TerrainTile(tileset.Templates.First().Key, 0);
|
var tileRef = new TerrainTile(tileset.Templates.First().Key, 0);
|
||||||
|
|
||||||
Title = "Name your map here";
|
Title = "Name your map here";
|
||||||
Description = "Describe your map here";
|
|
||||||
Author = "Your name here";
|
Author = "Your name here";
|
||||||
|
|
||||||
MapSize = new int2(size);
|
MapSize = new int2(size);
|
||||||
@@ -429,7 +427,6 @@ namespace OpenRA
|
|||||||
"MapFormat",
|
"MapFormat",
|
||||||
"RequiresMod",
|
"RequiresMod",
|
||||||
"Title",
|
"Title",
|
||||||
"Description",
|
|
||||||
"Author",
|
"Author",
|
||||||
"Tileset",
|
"Tileset",
|
||||||
"MapSize",
|
"MapSize",
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Defines the FMVs that can be played by missions.")]
|
[Desc("Defines the FMVs that can be played by missions.")]
|
||||||
public class MissionDataInfo : TraitInfo<MissionData>
|
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.")]
|
[Desc("Played by the \"Background Info\" button in the mission browser.")]
|
||||||
public readonly string BackgroundVideo;
|
public readonly string BackgroundVideo;
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
Author = "Westwood Studios"
|
Author = "Westwood Studios"
|
||||||
};
|
};
|
||||||
|
|
||||||
Map.Description = ExtractBriefing(file);
|
|
||||||
|
|
||||||
Map.RequiresMod = modData.Manifest.Mod.Id;
|
Map.RequiresMod = modData.Manifest.Mod.Id;
|
||||||
|
|
||||||
SetBounds(Map, mapSection);
|
SetBounds(Map, mapSection);
|
||||||
@@ -77,6 +75,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
ReadTrees(file);
|
ReadTrees(file);
|
||||||
|
|
||||||
LoadVideos(file, "BASIC");
|
LoadVideos(file, "BASIC");
|
||||||
|
LoadBriefing(file);
|
||||||
|
|
||||||
ReadActors(file);
|
ReadActors(file);
|
||||||
|
|
||||||
@@ -120,17 +119,34 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
public abstract void ValidateMapFormat(int format);
|
public abstract void ValidateMapFormat(int format);
|
||||||
|
|
||||||
static string ExtractBriefing(IniFile file)
|
void LoadBriefing(IniFile file)
|
||||||
{
|
{
|
||||||
var briefingSection = file.GetSection("Briefing", true);
|
var briefingSection = file.GetSection("Briefing", true);
|
||||||
if (briefingSection == null)
|
if (briefingSection == null)
|
||||||
return string.Empty;
|
return;
|
||||||
|
|
||||||
var briefing = new StringBuilder();
|
var briefing = new StringBuilder();
|
||||||
foreach (var s in briefingSection)
|
foreach (var s in briefingSection)
|
||||||
briefing.AppendLine(s.Value);
|
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)
|
static void SetBounds(Map map, IniSection mapSection)
|
||||||
|
|||||||
@@ -52,10 +52,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var author = widget.Get<TextFieldWidget>("AUTHOR");
|
var author = widget.Get<TextFieldWidget>("AUTHOR");
|
||||||
author.Text = map.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
|
// TODO: This should use a multi-selection dropdown once they exist
|
||||||
var visibilityDropdown = widget.Get<DropDownButtonWidget>("VISIBILITY_DROPDOWN");
|
var visibilityDropdown = widget.Get<DropDownButtonWidget>("VISIBILITY_DROPDOWN");
|
||||||
{
|
{
|
||||||
@@ -160,7 +156,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
map.Title = title.Text;
|
map.Title = title.Text;
|
||||||
map.Description = description.Text;
|
|
||||||
map.Author = author.Text;
|
map.Author = author.Text;
|
||||||
map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), visibilityDropdown.Text);
|
map.Visibility = (MapVisibility)Enum.Parse(typeof(MapVisibility), visibilityDropdown.Text);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
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 mapDescriptionPanel = widget.Get<ScrollPanelWidget>("MAP_DESCRIPTION_PANEL");
|
||||||
var mapDescription = widget.Get<LabelWidget>("MAP_DESCRIPTION");
|
var mapDescription = widget.Get<LabelWidget>("MAP_DESCRIPTION");
|
||||||
var mapFont = Game.Renderer.Fonts[mapDescription.Font];
|
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);
|
var missionData = world.Map.Rules.Actors["world"].TraitInfoOrDefault<MissionDataInfo>();
|
||||||
mapDescription.Text = text;
|
if (missionData != null)
|
||||||
mapDescription.Bounds.Height = mapFont.Measure(text).Y;
|
{
|
||||||
mapDescriptionPanel.ScrollToTop();
|
var text = WidgetUtils.WrapText(missionData.Briefing.Replace("\\n", "\n"), mapDescription.Bounds.Width, mapFont);
|
||||||
mapDescriptionPanel.Layout.AdjustChildren();
|
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 infoVideoVisible = false;
|
||||||
var infoVideoDisabled = true;
|
var infoVideoDisabled = true;
|
||||||
|
|
||||||
|
var map = selectedMap;
|
||||||
new Thread(() =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
selectedMap.PreloadRules();
|
map.PreloadRules();
|
||||||
var mapOptions = selectedMap.Rules.Actors["world"].TraitInfo<MapOptionsInfo>();
|
var mapOptions = map.Rules.Actors["world"].TraitInfo<MapOptionsInfo>();
|
||||||
|
|
||||||
difficulty = mapOptions.Difficulty ?? mapOptions.Difficulties.FirstOrDefault();
|
difficulty = mapOptions.Difficulty ?? mapOptions.Difficulties.FirstOrDefault();
|
||||||
difficulties = mapOptions.Difficulties;
|
difficulties = mapOptions.Difficulties;
|
||||||
difficultyDisabled = mapOptions.DifficultyLocked || mapOptions.Difficulties.Length <= 1;
|
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)
|
if (missionData != null)
|
||||||
{
|
{
|
||||||
briefingVideo = missionData.BriefingVideo;
|
briefingVideo = missionData.BriefingVideo;
|
||||||
@@ -208,6 +209,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
infoVideo = missionData.BackgroundVideo;
|
infoVideo = missionData.BackgroundVideo;
|
||||||
infoVideoVisible = infoVideo != null;
|
infoVideoVisible = infoVideo != null;
|
||||||
infoVideoDisabled = !(infoVideoVisible && modData.DefaultFileSystem.Exists(infoVideo));
|
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();
|
}).Start();
|
||||||
|
|
||||||
@@ -219,12 +232,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
startInfoVideoButton.IsDisabled = () => infoVideoDisabled || playingVideo != PlayingVideo.None;
|
startInfoVideoButton.IsDisabled = () => infoVideoDisabled || playingVideo != PlayingVideo.None;
|
||||||
startInfoVideoButton.OnClick = () => PlayVideo(videoPlayer, infoVideo, PlayingVideo.Info, () => StopVideo(videoPlayer));
|
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.ScrollToTop();
|
||||||
descriptionPanel.Layout.AdjustChildren();
|
|
||||||
|
|
||||||
if (difficultyButton != null)
|
if (difficultyButton != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ Background@SAVE_MAP_PANEL:
|
|||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 345
|
Width: 345
|
||||||
Height: 264
|
Height: 229
|
||||||
Children:
|
Children:
|
||||||
Label@LABEL_TITLE:
|
Label@LABEL_TITLE:
|
||||||
Text: Save Map
|
Text: Save Map
|
||||||
@@ -89,7 +89,7 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Align: Center
|
Align: Center
|
||||||
Background@SAVE_MAP_BACKGROUND:
|
Background@SAVE_MAP_BACKGROUND:
|
||||||
Width: PARENT_RIGHT
|
Width: PARENT_RIGHT
|
||||||
Height: 230
|
Height: 195
|
||||||
Background: panel-black
|
Background: panel-black
|
||||||
Children:
|
Children:
|
||||||
Label@TITLE_LABEL:
|
Label@TITLE_LABEL:
|
||||||
@@ -118,60 +118,47 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Width: 220
|
Width: 220
|
||||||
MaxLength: 50
|
MaxLength: 50
|
||||||
Height: 25
|
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:
|
Label@VISIBILITY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 119
|
Y: 84
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Visibility:
|
Text: Visibility:
|
||||||
DropDownButton@VISIBILITY_DROPDOWN:
|
DropDownButton@VISIBILITY_DROPDOWN:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 120
|
Y: 85
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Label@DIRECTORY_LABEL:
|
Label@DIRECTORY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 154
|
Y: 119
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Directory:
|
Text: Directory:
|
||||||
DropDownButton@DIRECTORY_DROPDOWN:
|
DropDownButton@DIRECTORY_DROPDOWN:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 155
|
Y: 120
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Label@FILENAME_LABEL:
|
Label@FILENAME_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 189
|
Y: 154
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Filename:
|
Text: Filename:
|
||||||
TextField@FILENAME:
|
TextField@FILENAME:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 190
|
Y: 155
|
||||||
Width: 105
|
Width: 105
|
||||||
Height: 25
|
Height: 25
|
||||||
DropDownButton@TYPE_DROPDOWN:
|
DropDownButton@TYPE_DROPDOWN:
|
||||||
X: 220
|
X: 220
|
||||||
Y: 190
|
Y: 155
|
||||||
Width: 110
|
Width: 110
|
||||||
Height: 25
|
Height: 25
|
||||||
Font: Regular
|
Font: Regular
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ Background@SAVE_MAP_PANEL:
|
|||||||
X: (WINDOW_RIGHT - WIDTH)/2
|
X: (WINDOW_RIGHT - WIDTH)/2
|
||||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width: 350
|
Width: 350
|
||||||
Height: 335
|
Height: 300
|
||||||
Children:
|
Children:
|
||||||
Label@LABEL_TITLE:
|
Label@LABEL_TITLE:
|
||||||
X: (PARENT_RIGHT - WIDTH)/2
|
X: (PARENT_RIGHT - WIDTH)/2
|
||||||
@@ -111,58 +111,45 @@ Background@SAVE_MAP_PANEL:
|
|||||||
Width: 220
|
Width: 220
|
||||||
MaxLength: 50
|
MaxLength: 50
|
||||||
Height: 25
|
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:
|
Label@VISIBILITY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 164
|
Y: 129
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Visibility:
|
Text: Visibility:
|
||||||
DropDownButton@VISIBILITY_DROPDOWN:
|
DropDownButton@VISIBILITY_DROPDOWN:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 165
|
Y: 130
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@DIRECTORY_LABEL:
|
Label@DIRECTORY_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 199
|
Y: 164
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Directory:
|
Text: Directory:
|
||||||
DropDownButton@DIRECTORY_DROPDOWN:
|
DropDownButton@DIRECTORY_DROPDOWN:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 200
|
Y: 165
|
||||||
Width: 220
|
Width: 220
|
||||||
Height: 25
|
Height: 25
|
||||||
Label@FILENAME_LABEL:
|
Label@FILENAME_LABEL:
|
||||||
X: 10
|
X: 10
|
||||||
Y: 234
|
Y: 199
|
||||||
Width: 95
|
Width: 95
|
||||||
Height: 25
|
Height: 25
|
||||||
Align: Right
|
Align: Right
|
||||||
Text: Filename:
|
Text: Filename:
|
||||||
TextField@FILENAME:
|
TextField@FILENAME:
|
||||||
X: 110
|
X: 110
|
||||||
Y: 235
|
Y: 200
|
||||||
Width: 105
|
Width: 105
|
||||||
Height: 25
|
Height: 25
|
||||||
DropDownButton@TYPE_DROPDOWN:
|
DropDownButton@TYPE_DROPDOWN:
|
||||||
X: 220
|
X: 220
|
||||||
Y: 235
|
Y: 200
|
||||||
Width: 110
|
Width: 110
|
||||||
Height: 25
|
Height: 25
|
||||||
Button@SAVE_BUTTON:
|
Button@SAVE_BUTTON:
|
||||||
|
|||||||
Reference in New Issue
Block a user