Skip to content

Commit

Permalink
playerlist fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stonedDiscord committed Aug 31, 2024
1 parent c4f8f6f commit 84db1ce
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions public/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<link rel="stylesheet" type="text/css" href="styles/default.css?v=1.0.1" id="client_theme">
<link rel="stylesheet" type="text/css" href="styles/chatbox/aa.css?v=1.0.1" id="chatbox_theme">
<link rel="stylesheet" type="text/css" href="styles/nameplates.css" id="nameplate_setting">
<link rel="stylesheet" type="text/css" href="styles/nomod.css" id="mod_ui">
<link rel="stylesheet" type="text/css" href="" id="effect_css">
<link type="text/css" rel="stylesheet" href="golden/css/goldenlayout.css" />
<link type="text/css" rel="stylesheet"
Expand Down
17 changes: 15 additions & 2 deletions webAO/dom/banPlayer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { client } from '../client'

/**
* Tries to ban a player from the playerlist
* @param {Number} id the players id
*/
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;
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;
1 change: 1 addition & 0 deletions webAO/dom/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions webAO/packets/handlers/handleAUTH.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* i am mod now
* @param {Array} args packet arguments
*/
export const handleAUTH = (args: string[]) => {
(<HTMLAnchorElement>(
document.getElementById("mod_ui")
)).href = `styles/mod.css`;
}
10 changes: 8 additions & 2 deletions webAO/packets/handlers/handlePR.ts
Original file line number Diff line number Diff line change
@@ -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 = <HTMLTableElement>document.getElementById("client_playerlist");
Expand All @@ -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 = <HTMLButtonElement>document.createElement("button");
kick.innerText = "Kick";
kick.onclick = () => { window.kickPlayer(playerID) }
kickCell.appendChild(kick);

const banCell = playerRow.insertCell(5);
const ban = <HTMLButtonElement>document.createElement("button");
ban.innerText = "Ban";
ban.onclick = () => { window.banPlayer(playerID) }
Expand Down
2 changes: 2 additions & 0 deletions webAO/packets/packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -71,6 +72,7 @@ export const packets = {
"PN": handlePN,
"SI": handleSI,
"ARUP": handleARUP,
"AUTH": handleAUTH,
"askchaa": handleaskchaa,
"CC": handleCC,
"RC": handleRC,
Expand Down
4 changes: 4 additions & 0 deletions webAO/styles/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@
color: #fff;
}

#client_playerlist {
overflow-y: scroll;
}

#client_menu {
overflow-y: auto;
height: 100%;
Expand Down
3 changes: 3 additions & 0 deletions webAO/styles/mod.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table#client_playerlist td:nth-child(5), td:nth-child(6) {
display: inherit;
}
3 changes: 3 additions & 0 deletions webAO/styles/nomod.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table#client_playerlist td:nth-child(5), td:nth-child(6) {
display: none;
}

0 comments on commit 84db1ce

Please sign in to comment.