From 84db1ce9a2eaf6670605104d2ede8683159b67df Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Sat, 31 Aug 2024 14:30:52 +0200 Subject: playerlist fixes --- webAO/dom/banPlayer.ts | 17 +++++++++++++++-- webAO/dom/window.ts | 1 + webAO/packets/handlers/handleAUTH.ts | 9 +++++++++ webAO/packets/handlers/handlePR.ts | 10 ++++++++-- webAO/packets/packets.ts | 2 ++ webAO/styles/client.css | 4 ++++ webAO/styles/mod.css | 3 +++ webAO/styles/nomod.css | 3 +++ 8 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 webAO/packets/handlers/handleAUTH.ts create mode 100644 webAO/styles/mod.css create mode 100644 webAO/styles/nomod.css (limited to 'webAO') diff --git a/webAO/dom/banPlayer.ts b/webAO/dom/banPlayer.ts index 5a8894a..f122a1b 100644 --- a/webAO/dom/banPlayer.ts +++ b/webAO/dom/banPlayer.ts @@ -1,4 +1,5 @@ import { client } from '../client' + /** * Tries to ban a player from the playerlist * @param {Number} id the players id @@ -6,9 +7,21 @@ import { client } from '../client' export function banPlayer(id: number) { let reason; let length; - reason = prompt("Please enter the ban reason", "Being annoying"); + reason = prompt("Please enter the reason", "Being annoying"); length = Number(prompt("Please enter the ban length in minutes", "60")); client.sender.sendMA(id, length, reason); } -window.banPlayer = banPlayer; \ No newline at end of file +window.banPlayer = banPlayer; + +/** + * Tries to kick a player from the playerlist + * @param {Number} id the players id + */ +export function kickPlayer(id: number) { + let reason; + reason = prompt("Please enter the reason", "Being annoying"); + + client.sender.sendMA(id, 0, reason); +} +window.kickPlayer = kickPlayer; \ No newline at end of file diff --git a/webAO/dom/window.ts b/webAO/dom/window.ts index f2cd86c..59ad575 100644 --- a/webAO/dom/window.ts +++ b/webAO/dom/window.ts @@ -52,6 +52,7 @@ declare global { onEnter: (event: any) => void; onReplayGo: (_event: any) => void; onOOCEnter: (_event: any) => void; + kickPlayer: (id: number) => void; banPlayer: (id: number) => void; hcallback: (_event: any) => void; } diff --git a/webAO/packets/handlers/handleAUTH.ts b/webAO/packets/handlers/handleAUTH.ts new file mode 100644 index 0000000..1408402 --- /dev/null +++ b/webAO/packets/handlers/handleAUTH.ts @@ -0,0 +1,9 @@ +/** +* i am mod now +* @param {Array} args packet arguments +*/ +export const handleAUTH = (args: string[]) => { + (( + document.getElementById("mod_ui") + )).href = `styles/mod.css`; +} diff --git a/webAO/packets/handlers/handlePR.ts b/webAO/packets/handlers/handlePR.ts index a52ad1f..0073140 100644 --- a/webAO/packets/handlers/handlePR.ts +++ b/webAO/packets/handlers/handlePR.ts @@ -1,5 +1,5 @@ import { client } from "../../client"; -import { banPlayer } from '../../dom/banPlayer' +import { kickPlayer, banPlayer } from '../../dom/banPlayer' function addPlayer(playerID: number) { const list = document.getElementById("client_playerlist"); @@ -19,7 +19,13 @@ function addPlayer(playerID: number) { const oocNameCell = playerRow.insertCell(3); oocNameCell.appendChild(name); - const banCell = playerRow.insertCell(4); + const kickCell = playerRow.insertCell(4); + const kick = document.createElement("button"); + kick.innerText = "Kick"; + kick.onclick = () => { window.kickPlayer(playerID) } + kickCell.appendChild(kick); + + const banCell = playerRow.insertCell(5); const ban = document.createElement("button"); ban.innerText = "Ban"; ban.onclick = () => { window.banPlayer(playerID) } diff --git a/webAO/packets/packets.ts b/webAO/packets/packets.ts index ab6e3b0..d215f9e 100644 --- a/webAO/packets/packets.ts +++ b/webAO/packets/packets.ts @@ -27,6 +27,7 @@ import { handleID } from './handlers/handleID' import { handlePN } from './handlers/handlePN' import { handleSI } from './handlers/handleSI' import { handleARUP } from './handlers/handleARUP' +import { handleAUTH } from './handlers/handleAUTH' import { handleaskchaa } from './handlers/handleaskchaa' import { handleCC } from './handlers/handleCC' import { handleRC } from './handlers/handleRC' @@ -71,6 +72,7 @@ export const packets = { "PN": handlePN, "SI": handleSI, "ARUP": handleARUP, + "AUTH": handleAUTH, "askchaa": handleaskchaa, "CC": handleCC, "RC": handleRC, diff --git a/webAO/styles/client.css b/webAO/styles/client.css index f95613a..1525500 100644 --- a/webAO/styles/client.css +++ b/webAO/styles/client.css @@ -563,6 +563,10 @@ color: #fff; } +#client_playerlist { + overflow-y: scroll; +} + #client_menu { overflow-y: auto; height: 100%; diff --git a/webAO/styles/mod.css b/webAO/styles/mod.css new file mode 100644 index 0000000..859996f --- /dev/null +++ b/webAO/styles/mod.css @@ -0,0 +1,3 @@ +table#client_playerlist td:nth-child(5), td:nth-child(6) { + display: inherit; +} \ No newline at end of file diff --git a/webAO/styles/nomod.css b/webAO/styles/nomod.css new file mode 100644 index 0000000..79d4d12 --- /dev/null +++ b/webAO/styles/nomod.css @@ -0,0 +1,3 @@ +table#client_playerlist td:nth-child(5), td:nth-child(6) { + display: none; +} \ No newline at end of file -- cgit