Browse Source

Fixed font materials for font

pull/11/head
Anairkoen Schno 5 years ago
parent
commit
19d18bbe4a
4 changed files with 19 additions and 37 deletions
  1. +5
    -1
      BSIPA-ModList/BSIPA-ModList.csproj
  2. +11
    -33
      BSIPA-ModList/UI/ViewControllers/MarkdownView.cs
  3. +2
    -2
      BSIPA-ModList/UI/ViewControllers/ModCells.cs
  4. +1
    -1
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs

+ 5
- 1
BSIPA-ModList/BSIPA-ModList.csproj View File

@ -119,9 +119,13 @@
<EmbeddedResource Include="Icons\library.png" /> <EmbeddedResource Include="Icons\library.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Bundles\consolas" />
<EmbeddedResource Include="README.md" /> <EmbeddedResource Include="README.md" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TMP Exporter\Assets\AssetBundles\fonts\consolas.font">
<Link>Bundles\consolas.font</Link>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild"> <Target Name="AfterBuild">
<Message Text="Packing..." Importance="normal" /> <Message Text="Packing..." Importance="normal" />


+ 11
- 33
BSIPA-ModList/UI/ViewControllers/MarkdownView.cs View File

@ -91,7 +91,7 @@ namespace BSIPA_ModList.UI.ViewControllers
get get
{ {
if (_bundle == null) 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; return _bundle;
} }
} }
@ -105,8 +105,12 @@ namespace BSIPA_ModList.UI.ViewControllers
_consolas = Bundle?.LoadAsset<TMP_FontAsset>("CONSOLAS"); _consolas = Bundle?.LoadAsset<TMP_FontAsset>("CONSOLAS");
if (_consolas != null) if (_consolas != null)
{ {
_consolas.material.color = new Color(1f, 1f, 1f, 0f);
_consolas.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None;
var originalFont = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().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); MaterialReferenceManager.AddFontAsset(_consolas);
} }
} }
@ -433,13 +437,6 @@ namespace BSIPA_ModList.UI.ViewControllers
currentText = BeatSaberUI.CreateText(layout.Peek(), "", Vector2.zero); currentText = BeatSaberUI.CreateText(layout.Peek(), "", Vector2.zero);
currentText.gameObject.AddComponent<TextLinkDecoder>(); currentText.gameObject.AddComponent<TextLinkDecoder>();
/*if (Consolas != null)
{
// Set the font to Consolas so code blocks work
currentText.font = Instantiate(Consolas);
currentText.text = $"<font={DefaultFontName}>";
}*/
switch (tt.Tag) switch (tt.Tag)
{ {
case BlockTag.List: case BlockTag.List:
@ -453,10 +450,13 @@ namespace BSIPA_ModList.UI.ViewControllers
size -= HLevelDecrease * (tt.hData.Level - 1); size -= HLevelDecrease * (tt.hData.Level - 1);
currentText.fontSize = size; currentText.fontSize = size;
currentText.enableWordWrapping = true; currentText.enableWordWrapping = true;
if (tt.hData.Level == 1)
currentText.alignment = TextAlignmentOptions.Center;
break; break;
case BlockTag.SetextHeading: case BlockTag.SetextHeading:
currentText.fontSize = H1Size; currentText.fontSize = H1Size;
currentText.enableWordWrapping = true; currentText.enableWordWrapping = true;
currentText.alignment = TextAlignmentOptions.Center;
break; break;
// TODO: add other relevant types // TODO: add other relevant types
} }
@ -492,7 +492,7 @@ namespace BSIPA_ModList.UI.ViewControllers
break; break;
case InlineTag.Code: case InlineTag.Code:
EnsureText(); EnsureText();
currentText.text += $"<font=\"CONSOLAS\"><mark=#A0A0C080><noparse>{inl.LiteralContent}</noparse></mark></font>";
currentText.text += $"<font=\"CONSOLAS\"><size=80%><mark=#A0A0C080><noparse>{inl.LiteralContent}</noparse></mark></size></font>";
break; break;
case InlineTag.SoftBreak: case InlineTag.SoftBreak:
EnsureText(); EnsureText();
@ -518,28 +518,6 @@ namespace BSIPA_ModList.UI.ViewControllers
content.gameObject.GetComponent<VerticalLayoutGroup>().enabled = false; content.gameObject.GetComponent<VerticalLayoutGroup>().enabled = false;
var childRt = content.GetChild(0) as RectTransform; var childRt = content.GetChild(0) as RectTransform;
childRt.anchoredPosition = new Vector2(0f, childRt.anchoredPosition.y); childRt.anchoredPosition = new Vector2(0f, childRt.anchoredPosition.y);
/*if (Consolas != null)
{
foreach (var link in texts.Select(t => t.textInfo.linkInfo).Aggregate<IEnumerable<TMP_LinkInfo>>(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 private class TextLinkDecoder : MonoBehaviour, IPointerClickHandler


+ 2
- 2
BSIPA-ModList/UI/ViewControllers/ModCells.cs View File

@ -175,8 +175,8 @@ namespace BSIPA_ModList.UI.ViewControllers
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>(); infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "<color=#BFBFBF><i>Unknown Author</i>", infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "<color=#BFBFBF><i>Unknown Author</i>",
"<color=#A0A0A0>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); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);


+ 1
- 1
BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs View File

@ -196,7 +196,7 @@ namespace BSIPA_ModList.UI
mdv.rectTransform.SetParent(rectTransform); mdv.rectTransform.SetParent(rectTransform);
mdv.rectTransform.anchorMin = new Vector2(.5f, .5f); mdv.rectTransform.anchorMin = new Vector2(.5f, .5f);
mdv.rectTransform.anchorMax = 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); mdv.rectTransform.sizeDelta = new Vector2(65f, 40f);
mdvgo.SetActive(true); mdvgo.SetActive(true);
mdv.Markdown = controller.Description; mdv.Markdown = controller.Description;


Loading…
Cancel
Save