mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 09:14:09 +00:00
Leaderboard improvements (#1424)
## Description: 1. Made leaderboard smaller 2. replaced show top 5/show all with a +/- to save space 3. show leaderboard by default on larger screens <img width="458" height="393" alt="Screenshot 2025-07-13 at 5 27 10 PM" src="https://github.com/user-attachments/assets/c18c732b-8b1e-4b71-89aa-b807ceb91e30" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -432,9 +432,7 @@
|
|||||||
"team": "Team",
|
"team": "Team",
|
||||||
"owned": "Owned",
|
"owned": "Owned",
|
||||||
"gold": "Gold",
|
"gold": "Gold",
|
||||||
"troops": "Troops",
|
"troops": "Troops"
|
||||||
"show_top_5": "Show Top 5",
|
|
||||||
"show_all": "Show All"
|
|
||||||
},
|
},
|
||||||
"player_info_overlay": {
|
"player_info_overlay": {
|
||||||
"type": "Type",
|
"type": "Type",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export class GameLeftSidebar extends LitElement implements Layer {
|
|||||||
|
|
||||||
private playerColor: Colord = new Colord("#FFFFFF");
|
private playerColor: Colord = new Colord("#FFFFFF");
|
||||||
public game: GameView;
|
public game: GameView;
|
||||||
|
private _shownOnInit = false;
|
||||||
|
|
||||||
createRenderRoot() {
|
createRenderRoot() {
|
||||||
return this;
|
return this;
|
||||||
@@ -32,6 +33,11 @@ export class GameLeftSidebar extends LitElement implements Layer {
|
|||||||
if (this.isTeamGame) {
|
if (this.isTeamGame) {
|
||||||
this.isPlayerTeamLabelVisible = true;
|
this.isPlayerTeamLabelVisible = true;
|
||||||
}
|
}
|
||||||
|
// Make it visible by default on large screens
|
||||||
|
if (window.innerWidth >= 1024) {
|
||||||
|
// lg breakpoint
|
||||||
|
this._shownOnInit = true;
|
||||||
|
}
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +55,12 @@ export class GameLeftSidebar extends LitElement implements Layer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._shownOnInit && !this.game.inSpawnPhase()) {
|
||||||
|
this._shownOnInit = false;
|
||||||
|
this.isLeaderboardShow = true;
|
||||||
|
this.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.game.inSpawnPhase()) {
|
if (!this.game.inSpawnPhase()) {
|
||||||
this.isPlayerTeamLabelVisible = false;
|
this.isPlayerTeamLabelVisible = false;
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
players: Entry[] = [];
|
players: Entry[] = [];
|
||||||
|
|
||||||
@property({ type: Boolean }) visible = false;
|
@property({ type: Boolean }) visible = false;
|
||||||
private _shownOnInit = false;
|
|
||||||
private showTopFive = true;
|
private showTopFive = true;
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
@@ -57,10 +56,6 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
if (this.game === null) throw new Error("Not initialized");
|
if (this.game === null) throw new Error("Not initialized");
|
||||||
if (!this._shownOnInit && !this.game.inSpawnPhase()) {
|
|
||||||
this._shownOnInit = true;
|
|
||||||
this.updateLeaderboard();
|
|
||||||
}
|
|
||||||
if (!this.visible) return;
|
if (!this.visible) return;
|
||||||
if (this.game.ticks() % 10 === 0) {
|
if (this.game.ticks() % 10 === 0) {
|
||||||
this.updateLeaderboard();
|
this.updateLeaderboard();
|
||||||
@@ -174,37 +169,25 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class="max-h-[35vh] overflow-y-auto text-white text-xs md:text-sm md:max-h-[50vh] ${this
|
class="max-h-[35vh] overflow-y-auto text-white text-xs md:text-xs lg:text-sm md:max-h-[50vh] ${this
|
||||||
.visible
|
.visible
|
||||||
? ""
|
? ""
|
||||||
: "hidden"}"
|
: "hidden"}"
|
||||||
@contextmenu=${(e: Event) => e.preventDefault()}
|
@contextmenu=${(e: Event) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
<button
|
|
||||||
class="mb-2 px-2 py-1 md:px-2.5 md:py-1.5 text-xs md:text-sm lg:text-base border border-white/20 hover:bg-white/10"
|
|
||||||
@click=${() => {
|
|
||||||
this.showTopFive = !this.showTopFive;
|
|
||||||
this.updateLeaderboard();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
${this.showTopFive
|
|
||||||
? translateText("leaderboard.show_all")
|
|
||||||
: translateText("leaderboard.show_top_5")}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="grid bg-gray-800/70 w-full text-xs md:text-sm lg:text-base"
|
class="grid bg-gray-800/70 w-full text-xs md:text-xs lg:text-sm"
|
||||||
style="grid-template-columns: 35px 100px 85px 65px 65px;"
|
style="grid-template-columns: 30px 100px 70px 55px 75px;"
|
||||||
>
|
>
|
||||||
<div class="contents font-bold bg-gray-700/50">
|
<div class="contents font-bold bg-gray-700/50">
|
||||||
<div class="py-1.5 md:py-2.5 text-center border-b border-slate-500">
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
#
|
#
|
||||||
</div>
|
</div>
|
||||||
<div class="py-1.5 md:py-2.5 text-center border-b border-slate-500">
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
${translateText("leaderboard.player")}
|
${translateText("leaderboard.player")}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
|
class="py-1 md:py-2 text-center border-b border-slate-500 cursor-pointer whitespace-nowrap"
|
||||||
@click=${() => this.setSort("tiles")}
|
@click=${() => this.setSort("tiles")}
|
||||||
>
|
>
|
||||||
${translateText("leaderboard.owned")}
|
${translateText("leaderboard.owned")}
|
||||||
@@ -215,7 +198,7 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
|
class="py-1 md:py-2 text-center border-b border-slate-500 cursor-pointer whitespace-nowrap"
|
||||||
@click=${() => this.setSort("gold")}
|
@click=${() => this.setSort("gold")}
|
||||||
>
|
>
|
||||||
${translateText("leaderboard.gold")}
|
${translateText("leaderboard.gold")}
|
||||||
@@ -226,7 +209,7 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 cursor-pointer"
|
class="py-1 md:py-2 text-center border-b border-slate-500 cursor-pointer whitespace-nowrap"
|
||||||
@click=${() => this.setSort("troops")}
|
@click=${() => this.setSort("troops")}
|
||||||
>
|
>
|
||||||
${translateText("leaderboard.troops")}
|
${translateText("leaderboard.troops")}
|
||||||
@@ -248,29 +231,21 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
: ""} cursor-pointer"
|
: ""} cursor-pointer"
|
||||||
@click=${() => this.handleRowClickPlayer(player.player)}
|
@click=${() => this.handleRowClickPlayer(player.player)}
|
||||||
>
|
>
|
||||||
<div
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500"
|
|
||||||
>
|
|
||||||
${player.position}
|
${player.position}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500 truncate"
|
class="py-1 md:py-2 text-center border-b border-slate-500 truncate"
|
||||||
>
|
>
|
||||||
${player.name}
|
${player.name}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500"
|
|
||||||
>
|
|
||||||
${player.score}
|
${player.score}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500"
|
|
||||||
>
|
|
||||||
${player.gold}
|
${player.gold}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="py-1 md:py-2 text-center border-b border-slate-500">
|
||||||
class="py-1.5 md:py-2.5 text-center border-b border-slate-500"
|
|
||||||
>
|
|
||||||
${player.troops}
|
${player.troops}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -278,6 +253,16 @@ export class Leaderboard extends LitElement implements Layer {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="mt-1 px-1.5 py-0.5 md:px-2 md:py-0.5 text-xs md:text-xs lg:text-sm border border-white/20 hover:bg-white/10 text-white mx-auto block"
|
||||||
|
@click=${() => {
|
||||||
|
this.showTopFive = !this.showTopFive;
|
||||||
|
this.updateLeaderboard();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
${this.showTopFive ? "+" : "-"}
|
||||||
|
</button>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user