Skip to content

Commit

Permalink
Improve leaderboard score handling (#5481)
Browse files Browse the repository at this point in the history
* Leaderboards will now display the score of the player, if a score was just sent before displaying the leaderboard.
* If the score is being sent, the leaderboard will wait for it to be sent before showing the leaderboard.
* Important change: a player name can now be empty when a score is sent. In this case, the leaderboard will auto-generate a name.
* Leaderboard administration was improved to allow to customise the prefix used to generate automatically player names (when no name is entered by the player). You can also now choose to disallow any custom player name to prevent abuse (in this case, all non-connected player names will be auto-generated)
* Allow to use custom CSS to fully customize the leaderboard - only for business users (reach out if you need this).

Co-authored-by: AlexandreS <[email protected]>
  • Loading branch information
4ian and AlexandreSi authored Jul 18, 2023
1 parent ed74a49 commit 9e8a155
Show file tree
Hide file tree
Showing 10 changed files with 701 additions and 331 deletions.
41 changes: 25 additions & 16 deletions Extensions/Leaderboards/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ module.exports = {
false
)
.addParameter('string', _('Name to register for the player'), '', false)
.setParameterLongDescription(
_(
'Let this empty to let the leaderboard auto-generate a player name (e.g: "Player23464"). You can configure this in the leaderboard administration.'
)
)
.setHelpPath('/all-features/leaderboards')
.getCodeExtraInformation()
.setIncludeFile('Extensions/Leaderboards/sha256.js')
.addIncludeFile('Extensions/Leaderboards/leaderboardstools.js')
.setFunctionName('gdjs.evtTools.leaderboards.savePlayerScore');
.setFunctionName('gdjs.evtTools.leaderboards.savePlayerScore')
.setAsyncFunctionName('gdjs.evtTools.leaderboards.savePlayerScore');

extension
.addAction(
Expand All @@ -89,7 +95,8 @@ module.exports = {
.getCodeExtraInformation()
.setIncludeFile('Extensions/Leaderboards/sha256.js')
.addIncludeFile('Extensions/Leaderboards/leaderboardstools.js')
.setFunctionName('gdjs.evtTools.leaderboards.saveConnectedPlayerScore');
.setFunctionName('gdjs.evtTools.leaderboards.saveConnectedPlayerScore')
.setAsyncFunctionName('gdjs.evtTools.leaderboards.saveConnectedPlayerScore');

extension
.addCondition(
Expand Down Expand Up @@ -154,20 +161,22 @@ module.exports = {
.setIncludeFile('Extensions/Leaderboards/leaderboardstools.js')
.setFunctionName('gdjs.evtTools.leaderboards.isSaving');

extension
.addCondition(
'HasPlayerJustClosedLeaderboardView',
_('Closed by player'),
_('Check if the player has just closed the leaderboard view.'),
_('Player has just closed the leaderboard view'),
_('Display leaderboard'),
'JsPlatform/Extensions/leaderboard.svg',
'JsPlatform/Extensions/leaderboard.svg'
)
.setHelpPath('/all-features/leaderboards')
.getCodeExtraInformation()
.setIncludeFile('Extensions/Leaderboards/leaderboardstools.js')
.setFunctionName('gdjs.evtTools.leaderboards.hasPlayerJustClosedLeaderboardView');
extension
.addCondition(
'HasPlayerJustClosedLeaderboardView',
_('Closed by player'),
_('Check if the player has just closed the leaderboard view.'),
_('Player has just closed the leaderboard view'),
_('Display leaderboard'),
'JsPlatform/Extensions/leaderboard.svg',
'JsPlatform/Extensions/leaderboard.svg'
)
.setHelpPath('/all-features/leaderboards')
.getCodeExtraInformation()
.setIncludeFile('Extensions/Leaderboards/leaderboardstools.js')
.setFunctionName(
'gdjs.evtTools.leaderboards.hasPlayerJustClosedLeaderboardView'
);

extension
.addStrExpression(
Expand Down
Loading

0 comments on commit 9e8a155

Please sign in to comment.