From 19d18bbe4a113e03aba4ffb4a420fc3dbe7a7d36 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 11 May 2019 22:23:12 -0500 Subject: [PATCH] Fixed font materials for font --- BSIPA-ModList/BSIPA-ModList.csproj | 6 ++- .../UI/ViewControllers/MarkdownView.cs | 44 +++++-------------- BSIPA-ModList/UI/ViewControllers/ModCells.cs | 4 +- .../ViewControllers/ModInfoViewController.cs | 2 +- 4 files changed, 19 insertions(+), 37 deletions(-) diff --git a/BSIPA-ModList/BSIPA-ModList.csproj b/BSIPA-ModList/BSIPA-ModList.csproj index 589f7f96..569c6229 100644 --- a/BSIPA-ModList/BSIPA-ModList.csproj +++ b/BSIPA-ModList/BSIPA-ModList.csproj @@ -119,9 +119,13 @@ - + + + Bundles\consolas.font + + diff --git a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs index 1486cfe7..b2f7b46a 100644 --- a/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs +++ b/BSIPA-ModList/UI/ViewControllers/MarkdownView.cs @@ -91,7 +91,7 @@ namespace BSIPA_ModList.UI.ViewControllers get { if (_bundle == null) - _bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("BSIPA_ModList.Bundles.consolas")); + _bundle = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("BSIPA_ModList.Bundles.consolas.font")); return _bundle; } } @@ -105,8 +105,12 @@ namespace BSIPA_ModList.UI.ViewControllers _consolas = Bundle?.LoadAsset("CONSOLAS"); if (_consolas != null) { - _consolas.material.color = new Color(1f, 1f, 1f, 0f); - _consolas.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None; + var originalFont = Resources.FindObjectsOfTypeAll().Last(f => f.name == "Teko-Medium SDF No Glow"); + var matCopy = Instantiate(originalFont.material); + matCopy.mainTexture = _consolas.material.mainTexture; + matCopy.mainTextureOffset = _consolas.material.mainTextureOffset; + matCopy.mainTextureScale = _consolas.material.mainTextureScale; + _consolas.material = matCopy; MaterialReferenceManager.AddFontAsset(_consolas); } } @@ -433,13 +437,6 @@ namespace BSIPA_ModList.UI.ViewControllers currentText = BeatSaberUI.CreateText(layout.Peek(), "", Vector2.zero); currentText.gameObject.AddComponent(); - /*if (Consolas != null) - { - // Set the font to Consolas so code blocks work - currentText.font = Instantiate(Consolas); - currentText.text = $""; - }*/ - switch (tt.Tag) { case BlockTag.List: @@ -453,10 +450,13 @@ namespace BSIPA_ModList.UI.ViewControllers size -= HLevelDecrease * (tt.hData.Level - 1); currentText.fontSize = size; currentText.enableWordWrapping = true; + if (tt.hData.Level == 1) + currentText.alignment = TextAlignmentOptions.Center; break; case BlockTag.SetextHeading: currentText.fontSize = H1Size; currentText.enableWordWrapping = true; + currentText.alignment = TextAlignmentOptions.Center; break; // TODO: add other relevant types } @@ -492,7 +492,7 @@ namespace BSIPA_ModList.UI.ViewControllers break; case InlineTag.Code: EnsureText(); - currentText.text += $"{inl.LiteralContent}"; + currentText.text += $"{inl.LiteralContent}"; break; case InlineTag.SoftBreak: EnsureText(); @@ -518,28 +518,6 @@ namespace BSIPA_ModList.UI.ViewControllers content.gameObject.GetComponent().enabled = false; var childRt = content.GetChild(0) as RectTransform; childRt.anchoredPosition = new Vector2(0f, childRt.anchoredPosition.y); - - /*if (Consolas != null) - { - foreach (var link in texts.Select(t => t.textInfo.linkInfo).Aggregate>(Enumerable.Concat).Where(l => l.GetLinkID() == "$$codeBlock")) - { - //link.textComponent.font = Consolas; - var texinfo = link.textComponent.textInfo; - for (int i = link.linkTextfirstCharacterIndex; i < link.linkTextfirstCharacterIndex + link.linkTextLength; i++) - { - texinfo.characterInfo[i].DebugPrintTo(Logger.md.Debug, 2); - texinfo.characterInfo[i].fontAsset = Consolas; - texinfo.characterInfo[i].material = Consolas.material; - texinfo.characterInfo[i].isUsingAlternateTypeface = true; - } - } - foreach (var text in texts) - { - text.SetLayoutDirty(); - text.SetMaterialDirty(); - text.SetVerticesDirty(); - } - }*/ } private class TextLinkDecoder : MonoBehaviour, IPointerClickHandler diff --git a/BSIPA-ModList/UI/ViewControllers/ModCells.cs b/BSIPA-ModList/UI/ViewControllers/ModCells.cs index 5dbbef55..d6d7dfb7 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModCells.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModCells.cs @@ -175,8 +175,8 @@ namespace BSIPA_ModList.UI.ViewControllers infoView = BeatSaberUI.CreateViewController(); infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "Unknown Author", - "This mod was written for IPA Reloaded. No metadata is avaliable for this mod. " + - "Please contact the mod author and ask them to port it to BSIPA to provide more information.", updateInfo); + "# This mod was written for IPA Reloaded. No metadata is avaliable for this mod.\n\n" + + "# Please contact the mod author and ask them to port it to BSIPA to provide more information.", updateInfo); } list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); diff --git a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs index f6cf4b4a..0c7930f0 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs @@ -196,7 +196,7 @@ namespace BSIPA_ModList.UI mdv.rectTransform.SetParent(rectTransform); mdv.rectTransform.anchorMin = new Vector2(.5f, .5f); mdv.rectTransform.anchorMax = new Vector2(.5f, .5f); - mdv.rectTransform.anchoredPosition = new Vector2(-4f, -3.5f); + mdv.rectTransform.anchoredPosition = new Vector2(-4f, -3.6f); mdv.rectTransform.sizeDelta = new Vector2(65f, 40f); mdvgo.SetActive(true); mdv.Markdown = controller.Description;