From 4bd5e5aa493e74734717417c1d12787c72ca9164 Mon Sep 17 00:00:00 2001 From: kookroach Date: Sun, 2 May 2021 06:19:15 +0200 Subject: [PATCH] Inventory and onlinelist now pre load on login and open without delay on keybind press. --- ReallifeGamemode.Client/Gui/playerlist.ts | 29 ++-- .../assets/css/onlinelist/style.css | 8 ++ .../assets/html/inventory/inventory.html | 133 ++++++++++-------- .../assets/html/onlinelist/index.html | 79 ++++++----- .../assets/js/onlinelist/script.js | 16 ++- .../inventory/inventory.ts | 83 +++-------- ReallifeGamemode.Server/Events/Login.cs | 3 + .../Managers/InventoryManager.cs | 4 +- 8 files changed, 181 insertions(+), 174 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/playerlist.ts b/ReallifeGamemode.Client/Gui/playerlist.ts index 1d176cba..d714cf2b 100644 --- a/ReallifeGamemode.Client/Gui/playerlist.ts +++ b/ReallifeGamemode.Client/Gui/playerlist.ts @@ -5,30 +5,39 @@ */ export default function playerList(globalData: IGlobalData): void { - var playerlistBrowser: BrowserMp = null; - var pList; + var pList = []; + var loaded = false; var factionPlayersMap: Map = new Map(); const factionIds = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - mp.events.add("showPlayerlist", (playersJson) => { + mp.events.add("loadPlayerListCEF", () => { if (playerlistBrowser !== null) { playerlistBrowser.destroy(); - playerlistBrowser = null; - globalData.InMenu = false; - mp.gui.cursor.show(false, false); - mp.gui.chat.activate(true); } - else if (!globalData.InMenu) { + playerlistBrowser = mp.browsers.new('package://assets/html/onlinelist/index.html'); + }); + + mp.events.add("showPlayerlist", (playersJson) => { + if (!globalData.InMenu && !loaded) { globalData.InMenu = true; - playerlistBrowser = mp.browsers.new('package://assets/html/onlinelist/index.html'); + loaded = true; mp.gui.chat.activate(false); mp.gui.cursor.show(true, true); pList = JSON.parse(playersJson); + playerlistBrowser.execute(`showPlayerList()`); + } else if (loaded) { + globalData.InMenu = false; + loaded = false; + mp.gui.cursor.show(false, false); + mp.gui.chat.activate(true); + playerlistBrowser.execute(`closePlayerList()`); } }); mp.events.add("CEF:PlayerList_Loaded", () => { + playerlistBrowser.execute(`clear_row()`); + factionIds.forEach(f => { factionPlayersMap.set(f, 0); }); @@ -54,4 +63,4 @@ export default function playerList(globalData: IGlobalData): void { // table = table + tableRow; // }) // return document.write(table); -//} +//} \ No newline at end of file diff --git a/ReallifeGamemode.Client/assets/css/onlinelist/style.css b/ReallifeGamemode.Client/assets/css/onlinelist/style.css index 9daec4a7..f4793000 100644 --- a/ReallifeGamemode.Client/assets/css/onlinelist/style.css +++ b/ReallifeGamemode.Client/assets/css/onlinelist/style.css @@ -8,7 +8,13 @@ html { -ms-user-select: none; user-select: none; } +.show { + display: show !important; +} +.hidden { + display: none !important; +} html, body { margin: unset; } @@ -209,4 +215,6 @@ ol.inline.stats { ol.inline.stats abbr { text-decoration: none; } + + /*# sourceMappingURL=style.css.map */ diff --git a/ReallifeGamemode.Client/assets/html/inventory/inventory.html b/ReallifeGamemode.Client/assets/html/inventory/inventory.html index 5e537caf..23e0cc6f 100644 --- a/ReallifeGamemode.Client/assets/html/inventory/inventory.html +++ b/ReallifeGamemode.Client/assets/html/inventory/inventory.html @@ -10,76 +10,78 @@ -
-
+