Skip to content
LeaderboardModule

UI / LeaderboardModule

LeaderboardModule Class

Instance

Editor built-in leaderboard

Table of contents

Methods

addField(fieldId: number, fieldName: string, valueStyle?: string): typeof LeaderboardModule other
Add a field
addPlayer(player: number Player, data?: any): void other
Add a player to the leaderboard
clear(): void other
Clear the leaderboard
hidePanel(): void other
Hide UI
removePlayer(player: number Player): void other
Remove a player from the leaderboard
setPlayerValue(player: number Player, fieldId: number, value: string number): void other
Set a field value for a player
setSortFields(...fieldIds: number[]): typeof LeaderboardModule other
Set sorting fields
setSortMethod(fn: (dataList: LeaderboardPlayerData[]) => LeaderboardPlayerData[]): typeof LeaderboardModule other
Method for setting sorting
setStyle(title: string, fieldsAutoLayout: boolean, showPlayerNum: number, itemSpacing: number): typeof LeaderboardModule other
Set Style
showPanel(hideCallback?: () => void): void other
Display UI
showRankField(fieldName: string, valueStyle?: string, notListed?: string): typeof LeaderboardModule other
Display ranking

Methods

addField

Static addField(fieldId, fieldName, valueStyle?): typeof LeaderboardModule other

Add a field

Parameters

fieldId numberField ID range: determined by ID length type:
fieldName stringField name range: Unrestricted
valueStyle? stringDisplay content style (example: {0} points) default: null range: unlimited

Returns

typeof LeaderboardModuleReturn to yourself, which can be used for chained call

addPlayer

Static addPlayer(player, data?): void other

Add a player to the leaderboard

Parameters

player number PlayerPlayer object Player id
range: depending on ID length
data? anyPlayer data default: {}

clear

Static clear(): void other

Clear the leaderboard


hidePanel

Static hidePanel(): void other

Hide UI


removePlayer

Static removePlayer(player): void other

Remove a player from the leaderboard

Parameters

player number PlayerPlayer object Player id
range: depending on ID length

setPlayerValue

Static setPlayerValue(player, fieldId, value): void other

Set a field value for a player

Parameters

player number PlayerPlayer Object Player ID
range: determined by ID length
fieldId numberField ID
range: determined by ID length type: integer
value string numberField value
range: unlimited, one Player, one data type: integer

setSortFields

Static setSortFields(...fieldIds): typeof LeaderboardModule other

Set sorting fields

Parameters

...fieldIds number[]Sort field
range: No length limit

Returns

typeof LeaderboardModuleReturn to yourself, which can be used for chained call

Multiple field sorting can be set, only supporting sorting from large to small.


setSortMethod

Static setSortMethod(fn): typeof LeaderboardModule other

Method for setting sorting

Parameters

fn (dataList: LeaderboardPlayerData[]) => LeaderboardPlayerData[]method

Returns

typeof LeaderboardModuleReturn to yourself, which can be used for chained call

setStyle

Static setStyle(title, fieldsAutoLayout, showPlayerNum, itemSpacing): typeof LeaderboardModule other

Set Style

Parameters

title stringInterface title range: UI title information
fieldsAutoLayout booleanAre the fields automatically laid out and evenly distributed
showPlayerNum numberThe maximum number of Player displayed range: reasonable, type: integer
itemSpacing numberThe spacing between each piece of data should be reasonable. Type: integer

Returns

typeof LeaderboardModuleReturn to yourself, which can be used for chained call

showPanel

Static showPanel(hideCallback?): void other

Display UI

Parameters

hideCallback? () => voidPanel closure callback default: null

showRankField

Static showRankField(fieldName, valueStyle?, notListed?): typeof LeaderboardModule other

Display ranking

Parameters

fieldName stringField name range: determined by ID length type:
valueStyle? stringField value style default: null range: no restriction
notListed? stringNot on the list (if the ranking is displayed even if it is not on the list, please fill in null) default: null range: no restrictions

Returns

typeof LeaderboardModuleReturn to yourself, which can be used for chained call