feat(chat): custom chat bubbles

Players choose how their chat bubble looks, and everyone sees it.

- style: a gradient of 2 to 5 colour stops (linear at any 45° step,
  radial, or solid), its strength, text and border colours, outline
  thickness 0-4, opacity 25-100%, and an animation (still, pulse, shimmer,
  flow, rainbow) at 40-300% speed. lib/chatstyles.js keeps the one
  canonical form: forgiving for saved accounts, strict for requests.
- in the game: Settings > Chat Bubble > Customize opens an editor with
  presets (Ocean, Sunset, Forest, Midnight, Candy, Rainbow), a palette,
  Swap, Random, Reset and Save, and a live preview. "Custom bubbles: Off"
  draws everyone's bubbles normally on this computer only.
- on the web: the account page has a Chat bubble section with the same
  choices.
- wire: xcs with no fields asks for the saved style, with twelve (or an
  older client's 7, 10 or 11) saves it; the reply is the canonical twelve.
  A typed line ("uc") carries its sender's style after the stock extra
  field, only when it is not the default, so message and type stay where
  the game reads them and unpatched clients are unaffected.

ajclient.swf is built with this and the six client commits before it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SnipzilandClaude Opus 5.5 committed 2026-10-21 22:42:11 -04:00
1 parent c1a85f9b5d
commit 83c2fc3b0b
14 files changed
+1697 -12

No files matched your search

+31 -1
View File
@@ -21,6 +21,7 @@ const devices = require("./devices.js");
const chatlog = require("./chatlog.js");
const chatFilter = require("./chatfilter.js");
const chatSpam = require("./chatspam.js");
const chatStyles = require("./chatstyles.js");
const buddyModule = require("./buddies.js");
const dens = require("./dens.js");
const disguises = require("./disguises.js");
@@ -627,6 +628,10 @@ const sendFilter = session => {
session.sendXt("xfl", -1, filter.chosen ? 1 : 0, filter.level, filter.mode, filter.words);
};
// The in-game editor asks for this on demand too. It receives only canonical
// values, so the Flash client never has to guess at a missing account field.
const sendChatStyle = session => session.sendXt("xcs", -1, ...chatStyles.fields(session.account.chatStyle));
// the player called `username` as the senders above take one: their session
// when they are playing, else just their account. A player's card can be
// opened for anybody (the buddy list, the player search), and it asks for
@@ -653,6 +658,25 @@ const handlers = {
sendFilter(session);
},
// The Settings > Chat Bubble popup. An empty request just reloads the
// saved setting; a complete twelve-field request replaces it. Older custom
// clients remain accepted and receive a two-stop gradient automatically.
xcs(session, roomId, params) {
if (params.length === 0) {
sendChatStyle(session);
return;
}
if (![7, 10, 11, 12].includes(params.length)) return;
const [background, accent, text, border, opacity, animation, speed, gradient = "linear", angle = 45, strength = 100, outline = 1,
stops = `${background}:0;${accent}:100`] = params;
const style = {background, accent, text, border, opacity: Number(opacity), animation, speed: Number(speed),
gradient, angle: Number(angle), strength: Number(strength), outline: Number(outline), stops};
if (!chatStyles.valid(style)) return;
session.account.chatStyle = style;
accounts.save(session.account);
sendChatStyle(session);
},
// the patched client's hex colour picker (gui.ColorTable): [rgb1, rgb2,
// rgb3, rgb4], the four colours of one layer. everyone online is told the
// entry's id, the asker included, who then uses it as that layer's colour.
@@ -1918,12 +1942,18 @@ module.exports = {
// nobody hears a player they have blocked, and with chat switched
// off nobody's typed lines arrive at all.
// an invisible staff member's emotes and the like reach staff only.
// Typed chat always gets a third (stock "extra") field, followed by
// its style. Keeping message and type at their original indexes is
// what clears the local "..." bubble; carrying the style on the
// same packet prevents it being lost or applied to a later line.
const style = echo ? chatStyles.packet(session.account.chatStyle) : "";
for (const recipient of (echo || attachmentEcho) ? session.room.sessions : others(session)) {
if (session.invisible && recipient !== session && !roles.isActiveStaff(recipient.account)) {
continue;
}
if (recipient === session || (!blocks.has(recipient.account, session.account) && (!echo || accounts.featureOn(recipient.account, "chat")))) {
recipient.sendXt("uc", session.room.id, session.id, ...fields);
recipient.sendXt("uc", session.room.id, session.id,
...(echo && style ? [fields[0], fields[1], fields[2] || "", style] : fields));
}
}
}