Remove unused code, separate fade and scroll credits

This commit is contained in:
Nick 2022-08-14 13:10:12 -04:00
parent dceea1d237
commit 7217946ab8

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Xml;
using UnityEngine;
using static RumbleManager.Rumble;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Handlers
@ -43,12 +44,12 @@ namespace NewHorizons.Handlers
// Fade credits look wrong right now bc it works with just one column not two
/*
var nodeFade = CreateCreditsFromList(xml, sectionName, entries, true);
var nodeFade = CreateFadeCreditsFromList(xml, sectionName, entries, true);
finalCredits.InsertAfter(nodeFade, finalCredits.ChildNodes[0]);
*/
var fastCredits = NodeWhere(finalCredits.ChildNodes, "MainScrollSection");
var nodeScroll = CreateCreditsFromList(xml, sectionName, entries, false);
var nodeScroll = CreateScrollCreditsFromList(xml, sectionName, entries);
fastCredits.InsertBefore(nodeScroll, fastCredits.ChildNodes[0]);
}
@ -65,9 +66,9 @@ namespace NewHorizons.Handlers
return null;
}
private static XmlNode CreateCreditsFromList(XmlDocument doc, string title, string[] entries, bool fade)
private static XmlNode CreateFadeCreditsFromList(XmlDocument doc, string title, string[] entries)
{
var rootSection = MakeNode(doc, "section", fade ? new Dictionary<string, string>()
var rootSection = MakeNode(doc, "section", new Dictionary<string, string>()
{
{ "platform", "All" },
{ "type", "Fade" },
@ -77,18 +78,11 @@ namespace NewHorizons.Handlers
{ "waitTime", "0.5" },
{ "padding-bottom", "-8" },
{ "spacing", "16" }
} : new Dictionary<string, string>()
{
{ "platform", "All" },
{ "type", "Scroll" },
{ "scrollDuration", "214" },
{ "spacing", "12" },
{ "width", "1590" }
});
var titleLayout = MakeNode(doc, "layout", new Dictionary<string, string>()
{
{ "type", fade ? "SingleColumnFadeCentered" : "SingleColumnScrollCentered" }
{ "type", "SingleColumnFadeCentered" }
});
var titleNode = MakeNode(doc, "title", new Dictionary<string, string>()
@ -99,20 +93,58 @@ namespace NewHorizons.Handlers
titleNode.InnerText = title;
titleLayout.AppendChild(titleNode);
var type = fade ? "SingleColumnFadeCentered" : "TwoColumnScrollAlignRightLeft";
var type = "SingleColumnFadeCentered";
var xmlText = $"<layout type=\"{type}\" spacer-base-height=\"10\">\n";
for (int i = 0; i < entries.Length; i++)
{
var entry = entries[i];
if (fade) entry = entry.Split('#')[0];
entry = entry.Split('#')[0];
xmlText += $"{entry}\n";
if (fade)
xmlText += "<spacer />\n";
}
xmlText += "<spacer height = \"295\" />\n";
xmlText += "</layout>";
rootSection.AppendChild(titleLayout);
rootSection.AppendChild(StringToNode(doc, xmlText));
return rootSection;
}
private static XmlNode CreateScrollCreditsFromList(XmlDocument doc, string title, string[] entries)
{
if (i == entries.Length - 1) xmlText += "<spacer height = \"295\" />\n";
else xmlText += "<spacer />\n";
}
var rootSection = MakeNode(doc, "section", new Dictionary<string, string>()
{
{ "platform", "All" },
{ "type", "Scroll" },
{ "scrollDuration", "214" },
{ "spacing", "12" },
{ "width", "1590" }
});
var titleLayout = MakeNode(doc, "layout", new Dictionary<string, string>()
{
{ "type", "SingleColumnScrollCentered" }
});
var titleNode = MakeNode(doc, "title", new Dictionary<string, string>()
{
{"text-align", "UpperCenter" },
{"height", "122" }
});
titleNode.InnerText = title;
titleLayout.AppendChild(titleNode);
var type = "TwoColumnScrollAlignRightLeft";
var xmlText = $"<layout type=\"{type}\" spacer-base-height=\"10\">\n";
for (int i = 0; i < entries.Length; i++)
{
var entry = entries[i];
xmlText += $"{entry}\n";
}
xmlText += "<spacer height = \"295\" />\n";
xmlText += "</layout>";
rootSection.AppendChild(titleLayout);
@ -148,17 +180,5 @@ namespace NewHorizons.Handlers
return xmlNode;
}
internal class CreditsInfo
{
string sectionName;
string[] entries;
internal CreditsInfo(string sectionName, string[] entries)
{
this.sectionName = sectionName;
this.entries = entries;
}
}
}
}