From abb8449ca2782e748ae2a5fb4cfc6a7e3aeb5457 Mon Sep 17 00:00:00 2001
From: "Nebula S. Nova" <78160470+jasontheone111@users.noreply.github.com>
Date: Mon, 26 Aug 2024 19:05:46 -0400
Subject: [PATCH] Update CreditsMain.hx (#370)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Update CreditsMain.hx
Made it easier to edit via script, also added color node support.
* edited
items name idea from @NeeEoo
* sweet
---------
Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
---
assets/data/config/credits.xml | 2 +-
source/funkin/menus/credits/CreditsMain.hx | 28 +++++++++++++---------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/assets/data/config/credits.xml b/assets/data/config/credits.xml
index 56a5cafd..4f300fcb 100644
--- a/assets/data/config/credits.xml
+++ b/assets/data/config/credits.xml
@@ -3,5 +3,5 @@
diff --git a/source/funkin/menus/credits/CreditsMain.hx b/source/funkin/menus/credits/CreditsMain.hx
index 56507274..847d2b64 100644
--- a/source/funkin/menus/credits/CreditsMain.hx
+++ b/source/funkin/menus/credits/CreditsMain.hx
@@ -4,9 +4,11 @@ import funkin.options.OptionsScreen;
import funkin.options.type.*;
import funkin.options.TreeMenu;
import haxe.xml.Access;
+import flixel.util.FlxColor;
class CreditsMain extends TreeMenu {
var bg:FlxSprite;
+ var items:Array = [];
public override function create() {
bg = new FlxSprite(-80).loadGraphic(Paths.image('menus/menuBGBlue'));
@@ -18,7 +20,6 @@ class CreditsMain extends TreeMenu {
bg.antialiasing = true;
add(bg);
- var selectables:Array = [];
var xmlPath = Paths.xml('config/credits');
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
@@ -31,17 +32,17 @@ class CreditsMain extends TreeMenu {
if (access != null)
for(c in parseCreditsFromXML(access, source))
- selectables.push(c);
+ items.push(c);
}
}
- selectables.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
+ items.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
optionsTree.add(Type.createInstance(CreditsCodename, []));
}));
- selectables.push(new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
+ items.push(new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
CoolUtil.openURL("https://ninja-muffin24.itch.io/funkin");
}));
- main = new OptionsScreen('Credits', 'The people who made this possible!', selectables);
+ main = new OptionsScreen('Credits', 'The people who made this possible!', items);
super.create();
DiscordUtil.call("onMenuLoaded", ["Credits Menu"]);
@@ -68,11 +69,13 @@ class CreditsMain extends TreeMenu {
html_url: 'https://github.com/$username',
avatar_url: 'https://github.com/$username.png'
};
-
- credsMenus.push(new GithubIconOption(user, desc, null,
+ var opt:GithubIconOption = new GithubIconOption(user, desc, null,
node.has.customName ? node.att.customName : null, node.has.size ? Std.parseInt(node.att.size) : 96,
node.has.portrait ? node.att.portrait.toLowerCase() == "false" ? false : true : true
- ));
+ );
+ if (node.has.color)
+ @:privateAccess opt.__text.color = FlxColor.fromString(node.att.color);
+ credsMenus.push(opt);
} else {
if (!node.has.name) {
Logs.trace("A credit node requires a name attribute.", WARNING);
@@ -82,11 +85,14 @@ class CreditsMain extends TreeMenu {
switch(node.name) {
case "credit":
- credsMenus.push(new PortraitOption(name, desc, function() if(node.has.url) CoolUtil.openURL(node.att.url),
+ var opt:PortraitOption = new PortraitOption(name, desc, function() if(node.has.url) CoolUtil.openURL(node.att.url),
node.has.icon && Paths.assetsTree.existsSpecific(Paths.image('credits/${node.att.icon}'), "IMAGE", source) ?
FlxG.bitmap.add(Paths.image('credits/${node.att.icon}')) : null, node.has.size ? Std.parseInt(node.att.size) : 96,
node.has.portrait ? node.att.portrait.toLowerCase() == "false" ? false : true : true
- ));
+ );
+ if (node.has.color)
+ @:privateAccess opt.__text.color = FlxColor.fromString(node.att.color);
+ credsMenus.push(opt);
case "menu":
credsMenus.push(new TextOption(name + " >", desc, function() {
@@ -98,4 +104,4 @@ class CreditsMain extends TreeMenu {
return credsMenus;
}
-}
\ No newline at end of file
+}