some more markdown stuff

This commit is contained in:
Yoshman29
2022-12-17 23:47:20 +01:00
parent afec963867
commit 0a9ef58129
5 changed files with 76 additions and 36 deletions
@@ -1,5 +1,6 @@
package funkin.updating;
import funkin.system.MarkdownUtil;
import funkin.menus.MainMenuState;
import flixel.math.FlxPoint;
import flixel.math.FlxMath;
@@ -63,17 +64,9 @@ class UpdateAvailableScreen extends MusicBeatState {
versionCheckBG.updateHitbox();
versionCheckBG.scrollFactor.set();
changeLogText = new FunkinText(0, versionCheckBG.y + versionCheckBG.height + 10, FlxG.width, "", 20, false);
changeLogText.textField.htmlText = Markdown.markdownToHtml(check.updates.last().body.replace("\t", " "));
changeLogText.applyMarkup(
UpdateUtil.parseWarnings(changeLogText.textField.text),
[
new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFFFF00, false, true), "<o>"),
new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFFF0000, false, true), "<r>"),
new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF00FF08, false, true), "<g>"),
new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF7D7D7D, false, true), "<gray>"),
]
);
changeLogText = new FunkinText(0, versionCheckBG.y + versionCheckBG.height + 10, FlxG.width, "", 20, true);
changeLogText.borderColor = 0xFF000000;
MarkdownUtil.applyMarkdownText(changeLogText, check.updates.last().body);
installButton = new FunkinText(0, FlxG.height - 25, Std.int(FlxG.width / 2), "> INSTALL <", 32);
skipButton = new FunkinText(Std.int(FlxG.width / 2), FlxG.height - 25, Std.int(FlxG.width / 2), "SKIP", 32);
-23
View File
@@ -60,29 +60,6 @@ class UpdateUtil {
return newArray.length <= 0 ? newArray : newArray.splice(__curVersionPos+1, newArray.length-(__curVersionPos+1));
}
/**
* Replaces all `⚠ TEXT` into `<o>/!\ TEXT</o>`
* @param text
*/
public static function parseWarnings(text:String) {
text = parseEmote(text, "⚠", "<o>(!)", "<o>");
text = parseEmote(text, "❌", "<r>(X)", "<r>");
text = parseEmote(text, "✔", "<g>(+)", "<g>");
text = parseEmote(text, "\n> ", "\n<gray>| ", "<gray>");
return text;
}
public static function parseEmote(text:String, emote:String, beginning:String, end:String) {
var index:Int;
while((index = text.indexOf(emote)) >= 0) {
var nextIndex = text.indexOf("\n", index + emote.length);
if (nextIndex < 0)
nextIndex = text.length;
text = text.substr(0, index) + beginning + text.substring(index + emote.length, nextIndex) + end + text.substring(nextIndex);
}
return text;
}
}
typedef UpdateCheckCallback = {