Browse Source

Code blocks now behaving, just need to fix the font

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
b0e3a76ba3
1 changed files with 6 additions and 6 deletions
  1. +6
    -6
      BSIPA-ModList/UI/ViewControllers/MarkdownView.cs

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

@ -107,6 +107,7 @@ namespace BSIPA_ModList.UI.ViewControllers
{ {
_consolas.material.color = new Color(1f, 1f, 1f, 0f); _consolas.material.color = new Color(1f, 1f, 1f, 0f);
_consolas.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None; _consolas.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.None;
MaterialReferenceManager.AddFontAsset(_consolas);
} }
} }
return _consolas; return _consolas;
@ -231,7 +232,6 @@ namespace BSIPA_ModList.UI.ViewControllers
private const string LinkDefaultColor = "#0061ff"; private const string LinkDefaultColor = "#0061ff";
private const string LinkHoverColor = "#009dff"; private const string LinkHoverColor = "#009dff";
private bool resetContentPosition = false;
private IEnumerator UpdateMd() private IEnumerator UpdateMd()
{ {
mdDirty = false; mdDirty = false;
@ -492,7 +492,7 @@ namespace BSIPA_ModList.UI.ViewControllers
break; break;
case InlineTag.Code: case InlineTag.Code:
EnsureText(); EnsureText();
currentText.text += $"<link=\"$$codeBlock\"><noparse>{inl.LiteralContent}</noparse></link>";
currentText.text += $"<font=\"CONSOLAS\"><noparse>{inl.LiteralContent}</noparse></font>";
break; break;
case InlineTag.Link: case InlineTag.Link:
EnsureText(); EnsureText();
@ -515,16 +515,15 @@ namespace BSIPA_ModList.UI.ViewControllers
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)
/*if (Consolas != null)
{ {
foreach (var link in texts.Select(t => t.textInfo.linkInfo).Aggregate<IEnumerable<TMP_LinkInfo>>(Enumerable.Concat).Where(l => l.GetLinkID() == "$$codeBlock")) 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; //link.textComponent.font = Consolas;
var texinfo = link.textComponent.textInfo; var texinfo = link.textComponent.textInfo;
texinfo.characterInfo[link.linkTextfirstCharacterIndex].DebugPrintTo(Logger.md.Debug, 2);
for (int i = link.linkTextfirstCharacterIndex; i < link.linkTextfirstCharacterIndex + link.linkTextLength; i++) 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].fontAsset = Consolas;
texinfo.characterInfo[i].material = Consolas.material; texinfo.characterInfo[i].material = Consolas.material;
texinfo.characterInfo[i].isUsingAlternateTypeface = true; texinfo.characterInfo[i].isUsingAlternateTypeface = true;
@ -533,9 +532,10 @@ namespace BSIPA_ModList.UI.ViewControllers
foreach (var text in texts) foreach (var text in texts)
{ {
text.SetLayoutDirty(); text.SetLayoutDirty();
text.SetMaterialDirty();
text.SetVerticesDirty(); text.SetVerticesDirty();
} }
}
}*/
} }
private class TextLinkDecoder : MonoBehaviour, IPointerClickHandler private class TextLinkDecoder : MonoBehaviour, IPointerClickHandler


Loading…
Cancel
Save