mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-20 23:33:12 +09:00
Sync the toolbar of players through the controller
The toolbar order, favourites, and open panels were saved into exp_legacy's PlayerData, which was never synced, and the file doing so was no longer loaded. When a player leaves, the lua side now sends Gui.toolbar.get_state as json compressed with helpers.encode_string, and the controller stores the string on the player record. When the player joins again the instance plugin sends the stored string over rcon to exp_scenario.player_settings.receive_toolbar, which decodes it and calls Gui.toolbar.set_state. exp_gui builds the toolbar in on_player_joined_game, so it exists by the time the rcon arrives. A string which does not decode, or a state naming buttons which no longer exist, is logged and ignored rather than raising in the game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ebe7504c00
commit
54941b85aa
15 files changed
+228
-45
No files matched your search
@@ -195,6 +195,27 @@ t.test("player settings", t2 => {
|
||||
t3.strictSame(sent.map(request => [request.playerName, request.message]), [["Alice", "Hi"], ["Alice", null]]);
|
||||
});
|
||||
|
||||
t2.test("a joining player's stored toolbar is sent to the lua side", async t3 => {
|
||||
const bob = new messages.PlayerRecord("Bob", undefined, undefined, "eNqrVkrLz1eyUlBKSixSqgUAGQwD8g==");
|
||||
const { start, playerEvent, setStatus, state } = await startPlugin(t3, [], [bob]);
|
||||
await start();
|
||||
setStatus("running");
|
||||
state.rcons.length = 0;
|
||||
|
||||
await playerEvent({ type: "join", name: "Bob" });
|
||||
t3.equal(state.rcons.length, 1, "only the toolbar, Bob has no join message");
|
||||
const { data, code } = decodePlayerRcon(state.rcons[0]);
|
||||
t3.strictSame(data, { toolbar: bob.toolbar, name: "Bob" });
|
||||
t3.equal(code, "exp_scenario.player_settings.receive_toolbar(d.name, d.toolbar)");
|
||||
});
|
||||
|
||||
t2.test("ipc with a toolbar is forwarded to the controller", async t3 => {
|
||||
const { ipc, state } = await startPlugin(t3);
|
||||
await ipc("exp_scenario:toolbar", { player_name: "Alice", toolbar: "abc" });
|
||||
const [event] = state.sent.filter(request => request instanceof messages.PlayerToolbarEvent);
|
||||
t3.strictSame([event.playerName, event.toolbar], ["Alice", "abc"]);
|
||||
});
|
||||
|
||||
t2.test("ipc with a locale is forwarded to the controller", async t3 => {
|
||||
const { ipc, state } = await startPlugin(t3);
|
||||
await ipc("exp_scenario:locale", { player_name: "Alice", locale: "de" });
|
||||
|
||||
Reference in new issue
Block a user