mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 08:07:54 -05:00
Rework credits data structure.
This commit is contained in:
parent
1e888658f7
commit
5311b043ac
3 changed files with 47 additions and 22 deletions
|
@ -5,7 +5,7 @@ package funkin.ui.credits;
|
|||
*/
|
||||
typedef CreditsData =
|
||||
{
|
||||
var roles:Array<CreditsDataRole>;
|
||||
var entries:Array<CreditsDataRole>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,16 @@ typedef CreditsData =
|
|||
*/
|
||||
typedef CreditsDataRole =
|
||||
{
|
||||
var roleName:String;
|
||||
var members:Array<CreditsDataMember>;
|
||||
@:optional
|
||||
var header:String;
|
||||
|
||||
@:optional
|
||||
@:default([])
|
||||
var body:Array<CreditsDataMember>;
|
||||
|
||||
@:optional
|
||||
@:default(false)
|
||||
var appendBackers:Bool;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,5 +30,5 @@ typedef CreditsDataRole =
|
|||
*/
|
||||
typedef CreditsDataMember =
|
||||
{
|
||||
var fullName:String;
|
||||
var line:String;
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ class CreditsDataHandler
|
|||
return;
|
||||
}
|
||||
|
||||
var roleCount = data.roles.length;
|
||||
var memberCount = 0;
|
||||
for (role in data.roles)
|
||||
var entryCount = data.entries.length;
|
||||
var lineCount = 0;
|
||||
for (entry in data.entries)
|
||||
{
|
||||
memberCount += role.members.length;
|
||||
lineCount += entry?.body?.length ?? 0;
|
||||
}
|
||||
|
||||
trace('CreditsData($roleCount roles with $memberCount members)');
|
||||
trace('CreditsData($entryCount entries containing $lineCount lines)');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,15 +43,19 @@ class CreditsDataHandler
|
|||
public static inline function getFallback():CreditsData
|
||||
{
|
||||
return {
|
||||
roles: [
|
||||
entries: [
|
||||
{
|
||||
roleName: 'Founders',
|
||||
members: [
|
||||
{fullName: 'ninjamuffin99'},
|
||||
{fullName: 'PhantomArcade'},
|
||||
{fullName: 'KawaiSprite'},
|
||||
{fullName: 'evilsk8r'},
|
||||
header: 'Founders',
|
||||
body: [
|
||||
{line: 'ninjamuffin99'},
|
||||
{line: 'PhantomArcade'},
|
||||
{line: 'KawaiSprite'},
|
||||
{line: 'evilsk8r'},
|
||||
]
|
||||
},
|
||||
{
|
||||
header: 'Kickstarter Backers',
|
||||
appendBackers: true
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -116,17 +116,30 @@ class CreditsState extends MusicBeatState
|
|||
{
|
||||
var y = 0;
|
||||
|
||||
for (role in CreditsDataHandler.CREDITS_DATA.roles)
|
||||
for (entry in CreditsDataHandler.CREDITS_DATA.entries)
|
||||
{
|
||||
creditsGroup.add(buildCreditsLine(role.roleName, y, true, CreditsSide.Center));
|
||||
y += CREDITS_HEADER_FONT_SIZE;
|
||||
|
||||
for (member in role.members)
|
||||
if (entry.header != null)
|
||||
{
|
||||
creditsGroup.add(buildCreditsLine(member.fullName, y, false, CreditsSide.Center));
|
||||
creditsGroup.add(buildCreditsLine(entry.header, y, true, CreditsSide.Center));
|
||||
y += CREDITS_HEADER_FONT_SIZE;
|
||||
}
|
||||
|
||||
for (line in entry?.body ?? [])
|
||||
{
|
||||
creditsGroup.add(buildCreditsLine(line.line, y, false, CreditsSide.Center));
|
||||
y += CREDITS_FONT_SIZE;
|
||||
}
|
||||
|
||||
if (entry.appendBackers)
|
||||
{
|
||||
var backers = CreditsDataHandler.fetchBackerEntries();
|
||||
for (backer in backers)
|
||||
{
|
||||
creditsGroup.add(buildCreditsLine(backer, y, false, CreditsSide.Center));
|
||||
y += CREDITS_FONT_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
// Padding between each role.
|
||||
y += CREDITS_FONT_SIZE * 2;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue