Skip to content

Commit

Permalink
Update CreditsMain.hx (#370)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
NebulaStellaNova and NexIsDumb authored Aug 26, 2024
1 parent 3ce7561 commit abb8449
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion assets/data/config/credits.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<menu name="Mod Credits" desc="Modify mod credits here">
<!-- \/ You can also set the portrait shader as false as you can see below in the github one -->
<credit name="Credit Example" desc="Click me to know more about me!" icon="credit icon example" size="130" url="https://youtu.be/fugtxz1znVw"/>
<github user="NexIsDumb" customName="Nex is Dumb" desc="The bitch who made these credits menus" size="100" portrait="false"/>
<github user="NexIsDumb" customName="Nex is Dumb" desc="The bitch who made these credits menus" size="100" portrait="false" color="#808080"/>
</menu>
28 changes: 17 additions & 11 deletions source/funkin/menus/credits/CreditsMain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<OptionType> = [];

public override function create() {
bg = new FlxSprite(-80).loadGraphic(Paths.image('menus/menuBGBlue'));
Expand All @@ -18,7 +20,6 @@ class CreditsMain extends TreeMenu {
bg.antialiasing = true;
add(bg);

var selectables:Array<OptionType> = [];
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)) {
Expand All @@ -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"]);
Expand All @@ -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);
Expand All @@ -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() {
Expand All @@ -98,4 +104,4 @@ class CreditsMain extends TreeMenu {

return credsMenus;
}
}
}

0 comments on commit abb8449

Please sign in to comment.