(10d1ebded) WIP credits sequence

This commit is contained in:
Joonas Rikkonen
2019-05-07 13:20:33 +03:00
parent dd120a8153
commit f2f39e87e2
4 changed files with 115 additions and 1 deletions

View File

@@ -188,6 +188,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\CampaignSetupUI.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\CampaignUI.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\CharacterEditorScreen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\CreditsPlayer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\GameScreen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\LevelEditorScreen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\LobbyScreen.cs" />

View File

@@ -0,0 +1,107 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class CreditsPlayer : GUIComponent
{
private GUIListBox listBox;
private float scrollSpeed;
public CreditsPlayer(RectTransform rectT, string configFile) : base(null, rectT)
{
var doc = XMLExtensions.TryLoadXml(configFile);
scrollSpeed = doc.Root.GetAttributeFloat("scrollspeed", 100.0f);
int spacing = doc.Root.GetAttributeInt("spacing", 0);
listBox = new GUIListBox(new RectTransform(Vector2.One, rectT), style: null)
{
Spacing = spacing
};
foreach (XElement subElement in doc.Root.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "text":
AddTextElement(subElement, listBox.Content.RectTransform);
break;
case "spacing":
AddSpacingElement(subElement, listBox.Content.RectTransform);
break;
case "image":
break;
}
}
listBox.UpdateScrollBarSize();
}
private void AddTextElement(XElement element, RectTransform parent)
{
var text = element.ElementInnerText().Replace(@"\n", "\n");
Color color = element.GetAttributeColor("color", Color.White);
ScalableFont font = GUI.Font;
switch (element.GetAttributeString("font", "Font").ToLowerInvariant())
{
case "font":
font = GUI.Font;
break;
case "smallfont":
font = GUI.SmallFont;
break;
case "largefont":
font = GUI.LargeFont;
break;
case "videotitlefont":
font = GUI.VideoTitleFont;
break;
case "objectivetitlefont":
font = GUI.ObjectiveTitleFont;
break;
case "objectivenamefont":
font = GUI.ObjectiveNameFont;
break;
}
var textHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), parent), style: null);
var textBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.0f), textHolder.RectTransform, Anchor.Center),
text,
color,
font,
Alignment.Center,
wrap: true);
textBlock.RectTransform.IsFixedSize = textHolder.RectTransform.IsFixedSize = true;
textBlock.RectTransform.NonScaledSize = new Point(textBlock.Rect.Width, textBlock.Rect.Height);
textHolder.RectTransform.NonScaledSize = new Point(textHolder.Rect.Width, textBlock.Rect.Height);
}
private void AddSpacingElement(XElement element, RectTransform parent)
{
if (element.Attribute("absoluteheight") != null)
{
int absoluteHeight = element.GetAttributeInt("absoluteheight", 10);
var textHolder = new GUIFrame(new RectTransform(new Point(parent.NonScaledSize.X, absoluteHeight), parent), style: null);
}
else
{
float relativeHeight = element.GetAttributeFloat("relativeheight", 0.0f);
var textHolder = new GUIFrame(new RectTransform(new Vector2(1.0f, relativeHeight), parent), style: null);
}
}
protected override void Update(float deltaTime)
{
listBox.BarScroll += scrollSpeed / listBox.TotalSize * deltaTime;
if (listBox.BarScroll >= 1.0f)
{
listBox.BarScroll = 0.0f;
}
}
}
}

View File

@@ -109,7 +109,7 @@ namespace Barotrauma
List<string> words = new List<string>();
string currWord = "";
for (int i = 0; i<text.Length; i++)
for (int i = 0; i < text.Length; i++)
{
if (isCJK.IsMatch(text[i].ToString()))
{

View File

@@ -502,6 +502,9 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Texts\ChineseVanillaTest.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Texts\Credits.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Texts\RussianVanillaTest.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -556,6 +559,9 @@
<Content Include="$(MSBuildThisFileDirectory)Content\UI\tutorialAtlas.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="$(MSBuildThisFileDirectory)Concentus_LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Fonts\BebasNeue-Regular.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>