Make radio emit range editable (5-20)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Maintainer-controlled web client version.
|
||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||
window.CHGRID_WEB_VERSION = "2026.02.21 R119";
|
||||
window.CHGRID_WEB_VERSION = "2026.02.21 R120";
|
||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||
|
||||
@@ -48,7 +48,7 @@ const DEFAULT_CLOCK_TIME_ZONE_OPTIONS = [
|
||||
const DEFAULT_ITEM_TYPE_SEQUENCE: ItemType[] = ['clock', 'dice', 'radio_station', 'wheel'];
|
||||
|
||||
const DEFAULT_ITEM_TYPE_EDITABLE_PROPERTIES: Record<ItemType, string[]> = {
|
||||
radio_station: ['title', 'streamUrl', 'enabled', 'channel', 'volume', 'effect', 'effectValue', 'facing'],
|
||||
radio_station: ['title', 'streamUrl', 'enabled', 'channel', 'volume', 'effect', 'effectValue', 'facing', 'emitRange'],
|
||||
dice: ['title', 'sides', 'number'],
|
||||
wheel: ['title', 'spaces'],
|
||||
clock: ['title', 'timeZone', 'use24Hour'],
|
||||
@@ -131,6 +131,7 @@ export function itemTypeLabel(type: ItemType): string {
|
||||
|
||||
export function itemPropertyLabel(key: string): string {
|
||||
if (key === 'use24Hour') return 'use 24 hour format';
|
||||
if (key === 'emitRange') return 'emit range';
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +525,9 @@ function itemLabel(item: WorldItem): string {
|
||||
|
||||
function getItemSpatialConfig(item: WorldItem): { range: number; directional: boolean; facingDeg: number } {
|
||||
const global = getItemTypeGlobalProperties(item.type);
|
||||
const rawRange = Number(global.emitRange);
|
||||
const rawParamRange = Number(item.params.emitRange);
|
||||
const rawGlobalRange = Number(global.emitRange);
|
||||
const rawRange = Number.isFinite(rawParamRange) && rawParamRange > 0 ? rawParamRange : rawGlobalRange;
|
||||
const range = Number.isFinite(rawRange) && rawRange > 0 ? rawRange : 15;
|
||||
const directional = global.directional === true;
|
||||
const rawFacing = Number(item.params.facing ?? 0);
|
||||
@@ -713,6 +715,11 @@ function getItemPropertyValue(item: WorldItem, key: string): string {
|
||||
if (!Number.isFinite(parsed)) return '0';
|
||||
return String(Math.round(normalizeDegrees(parsed) * 10) / 10);
|
||||
}
|
||||
if (key === 'emitRange') {
|
||||
const parsed = Number(item.params.emitRange ?? getItemTypeGlobalProperties(item.type)?.emitRange ?? 15);
|
||||
if (!Number.isFinite(parsed)) return '15';
|
||||
return String(Math.round(parsed));
|
||||
}
|
||||
const globalValue = getItemTypeGlobalProperties(item.type)?.[key];
|
||||
if (globalValue !== undefined) return String(globalValue);
|
||||
return String(item.params[key] ?? '');
|
||||
@@ -2008,6 +2015,14 @@ function handleItemPropertyEditModeInput(code: string, key: string, ctrlKey: boo
|
||||
return;
|
||||
}
|
||||
signaling.send({ type: 'item_update', itemId, params: { facing: Math.round(parsed * 10) / 10 } });
|
||||
} else if (propertyKey === 'emitRange') {
|
||||
const parsed = Number(value);
|
||||
if (!Number.isInteger(parsed) || parsed < 5 || parsed > 20) {
|
||||
updateStatus('emit range must be an integer between 5 and 20.');
|
||||
audio.sfxUiCancel();
|
||||
return;
|
||||
}
|
||||
signaling.send({ type: 'item_update', itemId, params: { emitRange: parsed } });
|
||||
} else if (propertyKey === 'spaces') {
|
||||
const spaces = value
|
||||
.split(',')
|
||||
|
||||
Reference in New Issue
Block a user