Suppress duplicate property row echo after quick adjust

This commit is contained in:
Jage9
2026-02-22 20:50:04 -05:00
parent acca054fae
commit ecef4832fc
4 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.22 R187"; window.CHGRID_WEB_VERSION = "2026.02.22 R188";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -38,6 +38,7 @@ type EditorDeps = {
effectSequenceIdsCsv: string; effectSequenceIdsCsv: string;
applyTextInputEdit: (code: string, key: string, maxLength: number, ctrlKey?: boolean, allowReplaceOnNextType?: boolean) => void; applyTextInputEdit: (code: string, key: string, maxLength: number, ctrlKey?: boolean, allowReplaceOnNextType?: boolean) => void;
setReplaceTextOnNextType: (value: boolean) => void; setReplaceTextOnNextType: (value: boolean) => void;
suppressItemPropertyEchoMs: (ms: number) => void;
updateStatus: (message: string) => void; updateStatus: (message: string) => void;
sfxUiBlip: () => void; sfxUiBlip: () => void;
sfxUiCancel: () => void; sfxUiCancel: () => void;
@@ -102,6 +103,7 @@ export function createItemPropertyEditor(deps: EditorDeps): {
const delta = code === 'ArrowRight' ? 1 : -1; const delta = code === 'ArrowRight' ? 1 : -1;
const nextIndex = (currentIndex + delta + options.length) % options.length; const nextIndex = (currentIndex + delta + options.length) % options.length;
const nextValue = options[nextIndex]; const nextValue = options[nextIndex];
deps.suppressItemPropertyEchoMs(600);
deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } }); deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } });
deps.updateStatus(nextValue); deps.updateStatus(nextValue);
deps.sfxUiBlip(); deps.sfxUiBlip();
@@ -114,6 +116,7 @@ export function createItemPropertyEditor(deps: EditorDeps): {
current = selectedKey === 'enabled' ? item.params.enabled !== false : item.params[selectedKey] === true; current = selectedKey === 'enabled' ? item.params.enabled !== false : item.params[selectedKey] === true;
} }
const nextValue = !current; const nextValue = !current;
deps.suppressItemPropertyEchoMs(600);
deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } }); deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } });
deps.updateStatus(nextValue ? 'on' : 'off'); deps.updateStatus(nextValue ? 'on' : 'off');
deps.sfxUiBlip(); deps.sfxUiBlip();
@@ -136,6 +139,7 @@ export function createItemPropertyEditor(deps: EditorDeps): {
let nextValue = attempted; let nextValue = attempted;
if (Number.isFinite(min)) nextValue = Math.max(min, nextValue); if (Number.isFinite(min)) nextValue = Math.max(min, nextValue);
if (Number.isFinite(max)) nextValue = Math.min(max, nextValue); if (Number.isFinite(max)) nextValue = Math.min(max, nextValue);
deps.suppressItemPropertyEchoMs(600);
deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } }); deps.signalingSend({ type: 'item_update', itemId, params: { [selectedKey]: nextValue } });
deps.updateStatus(formatSteppedNumber(nextValue, step)); deps.updateStatus(formatSteppedNumber(nextValue, step));
if (Math.abs(nextValue - currentValue) < 1e-9 || Math.abs(nextValue - attempted) > 1e-9) { if (Math.abs(nextValue - currentValue) < 1e-9 || Math.abs(nextValue - attempted) > 1e-9) {

View File

@@ -221,6 +221,7 @@ let lastSubscriptionRefreshTileX = Math.round(state.player.x);
let lastSubscriptionRefreshTileY = Math.round(state.player.y); let lastSubscriptionRefreshTileY = Math.round(state.player.y);
let subscriptionRefreshInFlight = false; let subscriptionRefreshInFlight = false;
let subscriptionRefreshPending = false; let subscriptionRefreshPending = false;
let suppressItemPropertyEchoUntilMs = 0;
let activeTeleportLoopStop: (() => void) | null = null; let activeTeleportLoopStop: (() => void) | null = null;
let activeTeleportLoopToken = 0; let activeTeleportLoopToken = 0;
let activeTeleport: let activeTeleport:
@@ -1491,6 +1492,7 @@ const onAppMessage = createOnMessageHandler({
itemPropertyLabel, itemPropertyLabel,
getItemPropertyValue, getItemPropertyValue,
getItemById: (itemId) => state.items.get(itemId), getItemById: (itemId) => state.items.get(itemId),
shouldAnnounceItemPropertyEcho: () => Date.now() >= suppressItemPropertyEchoUntilMs,
playLocateToneAt: (x, y) => audio.sfxLocate({ x: x - state.player.x, y: y - state.player.y }), playLocateToneAt: (x, y) => audio.sfxLocate({ x: x - state.player.x, y: y - state.player.y }),
resolveIncomingSoundUrl, resolveIncomingSoundUrl,
playIncomingItemUseSound: (url, x, y) => { playIncomingItemUseSound: (url, x, y) => {
@@ -2251,6 +2253,9 @@ const itemPropertyEditor = createItemPropertyEditor({
setReplaceTextOnNextType: (value) => { setReplaceTextOnNextType: (value) => {
replaceTextOnNextType = value; replaceTextOnNextType = value;
}, },
suppressItemPropertyEchoMs: (ms) => {
suppressItemPropertyEchoUntilMs = Math.max(suppressItemPropertyEchoUntilMs, Date.now() + Math.max(0, ms));
},
updateStatus, updateStatus,
sfxUiBlip: () => audio.sfxUiBlip(), sfxUiBlip: () => audio.sfxUiBlip(),
sfxUiCancel: () => audio.sfxUiCancel(), sfxUiCancel: () => audio.sfxUiCancel(),

View File

@@ -62,6 +62,7 @@ type MessageHandlerDeps = {
itemPropertyLabel: (key: string) => string; itemPropertyLabel: (key: string) => string;
getItemPropertyValue: (item: WorldItem, key: string) => string; getItemPropertyValue: (item: WorldItem, key: string) => string;
getItemById: (itemId: string) => WorldItem | undefined; getItemById: (itemId: string) => WorldItem | undefined;
shouldAnnounceItemPropertyEcho: () => boolean;
playLocateToneAt: (x: number, y: number) => void; playLocateToneAt: (x: number, y: number) => void;
resolveIncomingSoundUrl: (url: string) => string; resolveIncomingSoundUrl: (url: string) => string;
playIncomingItemUseSound: (url: string, x: number, y: number) => void; playIncomingItemUseSound: (url: string, x: number, y: number) => void;
@@ -204,7 +205,7 @@ export function createOnMessageHandler(deps: MessageHandlerDeps): (message: Inco
deps.state.carriedItemId = deps.getCarriedItemId(); deps.state.carriedItemId = deps.getCarriedItemId();
if (deps.state.mode === 'itemProperties' && deps.state.selectedItemId === message.item.id) { if (deps.state.mode === 'itemProperties' && deps.state.selectedItemId === message.item.id) {
const key = deps.state.itemPropertyKeys[deps.state.itemPropertyIndex]; const key = deps.state.itemPropertyKeys[deps.state.itemPropertyIndex];
if (key) { if (key && deps.shouldAnnounceItemPropertyEcho()) {
deps.updateStatus(`${deps.itemPropertyLabel(key)}: ${deps.getItemPropertyValue(message.item, key)}`); deps.updateStatus(`${deps.itemPropertyLabel(key)}: ${deps.getItemPropertyValue(message.item, key)}`);
} }
} }