Move wet-sand band to world graphics settings with an editor slider.
Remove the client Settings buttons; wetSandBand (0–1, default 0.6) is authored in the world editor and rebakes shorelines when live settings change.
@@ -54,15 +54,6 @@
54
54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>
55
55
</div>
56
56
</section>
57
<section class="settings-group">
58
<h3>Wet sand</h3>
59
<div class="settings-options">
60
<button type="button" data-graphics-key="wetSand" data-graphics-value="0">Off</button>
61
<button type="button" data-graphics-key="wetSand" data-graphics-value="30">30%</button>
62
<button type="button" data-graphics-key="wetSand" data-graphics-value="60">60%</button>
63
<button type="button" data-graphics-key="wetSand" data-graphics-value="100">100%</button>
64
</div>
65
</section>
66
57
<section class="settings-group">
67
58
<h3>Autorun</h3>
68
59
<div class="settings-options">
@@ -54,15 +54,6 @@54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>55
</div>55
</div>56
</section>56
</section>57
<section class="settings-group">58
<h3>Wet sand</h3>59
<div class="settings-options">60
<button type="button" data-graphics-key="wetSand" data-graphics-value="0">Off</button>61
<button type="button" data-graphics-key="wetSand" data-graphics-value="30">30%</button>62
<button type="button" data-graphics-key="wetSand" data-graphics-value="60">60%</button>63
<button type="button" data-graphics-key="wetSand" data-graphics-value="100">100%</button>64
</div>65
</section>66
<section class="settings-group">57
<section class="settings-group">67
<h3>Autorun</h3>58
<h3>Autorun</h3>68
<div class="settings-options">59
<div class="settings-options">@@ -3,7 +3,6 @@ import {
3
3
LightingMode,
4
4
BloomMode,
5
5
AutorunMode,
6
WetSandBand,
7
6
loadGraphicsSettings,
8
7
saveGraphicsSettings,
9
8
normalizeGraphicsSettings
@@ -120,4 +119,4 @@ export function initGraphicsSettings ({ onChange, onSuppressWorldClick })
120
119
};
121
120
}
122
121
123
export { ViewDistance, LightingMode, BloomMode, AutorunMode, WetSandBand };
122
export { ViewDistance, LightingMode, BloomMode, AutorunMode };
@@ -3,7 +3,6 @@ import {3
LightingMode,3
LightingMode,4
BloomMode,4
BloomMode,5
AutorunMode,5
AutorunMode,6
WetSandBand,7
loadGraphicsSettings,6
loadGraphicsSettings,8
saveGraphicsSettings,7
saveGraphicsSettings,9
normalizeGraphicsSettings8
normalizeGraphicsSettings@@ -120,4 +119,4 @@ export function initGraphicsSettings ({ onChange, onSuppressWorldClick })120
};119
};121
}120
}122
121
123
export { ViewDistance, LightingMode, BloomMode, AutorunMode, WetSandBand };122
export { ViewDistance, LightingMode, BloomMode, AutorunMode };@@ -501,8 +501,6 @@ export class WorldView
501
501
this.bloomEnabled = true;
502
502
/** Soft edge blend for blendable grounds (grass, dirt, …). */
503
503
this.softTerrain = false;
504
/** Wet sand shoreline width as a 0–1 tile fraction (graphics setting). */
505
this.wetSandBandFraction = 0.6;
506
504
this.settings = { ...DEFAULT_WORLD_SETTINGS };
507
505
this.worldHour = 12;
508
506
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */
@@ -529,13 +527,18 @@ export class WorldView
529
527
530
528
setSettings (settings)
531
529
{
530
const previous = this.settings;
532
531
this.settings = { ...DEFAULT_WORLD_SETTINGS, ...settings };
533
532
this.#syncBloomLayer();
533
const prevBand = Number(previous?.wetSandBand);
534
const nextBand = Number(this.settings.wetSandBand);
535
if (Number.isFinite(nextBand) && prevBand !== nextBand)
536
{ this.#rebakeAllChunks(); }
534
537
}
535
538
536
539
/**
537
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain, wet sand).
538
* @param {{ lighting?: string, bloom?: string, softTerrain?: string, wetSand?: string }} prefs
540
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain).
541
* @param {{ lighting?: string, bloom?: string, softTerrain?: string }} prefs
539
542
*/
540
543
setGraphicsPrefs (prefs)
541
544
{
@@ -552,30 +555,15 @@ export class WorldView
552
555
else
553
556
{ this.bloomEnabled = enabled; }
554
557
}
555
let rebake = false;
556
558
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")
557
559
{
558
560
const enabled = prefs.softTerrain === "on";
559
561
if (enabled !== this.softTerrain)
560
562
{
561
563
this.softTerrain = enabled;
562
rebake = true;
563
}
564
}
565
if (prefs?.wetSand != null)
566
{
567
const pct = Number(prefs.wetSand);
568
const next = !Number.isFinite(pct) || pct <= 0
569
? 0
570
: Math.min(1, pct / 100);
571
if (next !== this.wetSandBandFraction)
572
{
573
this.wetSandBandFraction = next;
574
rebake = true;
564
this.#rebakeAllChunks();
575
565
}
576
566
}
577
if (rebake)
578
{ this.#rebakeAllChunks(); }
579
567
}
580
568
581
569
/** Apply server (or local) calendar season; rebakes chunks when it changes. */
@@ -3738,7 +3726,7 @@ export class WorldView
3738
3726
preview: this.preview,
3739
3727
season: this.worldSeason,
3740
3728
softTerrain: this.softTerrain,
3741
wetSandBandFraction: this.wetSandBandFraction,
3729
wetSandBandFraction: Math.max(0, Math.min(1, Number(this.settings?.wetSandBand) || 0)),
3742
3730
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),
3743
3731
cache: this.#atlasCache
3744
3732
});
@@ -501,8 +501,6 @@ export class WorldView501
this.bloomEnabled = true;501
this.bloomEnabled = true;502
/** Soft edge blend for blendable grounds (grass, dirt, …). */502
/** Soft edge blend for blendable grounds (grass, dirt, …). */503
this.softTerrain = false;503
this.softTerrain = false;504
/** Wet sand shoreline width as a 0–1 tile fraction (graphics setting). */505
this.wetSandBandFraction = 0.6;506
this.settings = { ...DEFAULT_WORLD_SETTINGS };504
this.settings = { ...DEFAULT_WORLD_SETTINGS };507
this.worldHour = 12;505
this.worldHour = 12;508
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */506
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */@@ -529,13 +527,18 @@ export class WorldView529
527
530
setSettings (settings)528
setSettings (settings)531
{529
{530
const previous = this.settings;532
this.settings = { ...DEFAULT_WORLD_SETTINGS, ...settings };531
this.settings = { ...DEFAULT_WORLD_SETTINGS, ...settings };533
this.#syncBloomLayer();532
this.#syncBloomLayer();533
const prevBand = Number(previous?.wetSandBand);534
const nextBand = Number(this.settings.wetSandBand);535
if (Number.isFinite(nextBand) && prevBand !== nextBand)536
{ this.#rebakeAllChunks(); }534
}537
}535
538
536
/**539
/**537
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain, wet sand).540
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain).538
* @param {{ lighting?: string, bloom?: string, softTerrain?: string, wetSand?: string }} prefs541
* @param {{ lighting?: string, bloom?: string, softTerrain?: string }} prefs539
*/542
*/540
setGraphicsPrefs (prefs)543
setGraphicsPrefs (prefs)541
{544
{@@ -552,30 +555,15 @@ export class WorldView552
else555
else553
{ this.bloomEnabled = enabled; }556
{ this.bloomEnabled = enabled; }554
}557
}555
let rebake = false;556
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")558
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")557
{559
{558
const enabled = prefs.softTerrain === "on";560
const enabled = prefs.softTerrain === "on";559
if (enabled !== this.softTerrain)561
if (enabled !== this.softTerrain)560
{562
{561
this.softTerrain = enabled;563
this.softTerrain = enabled;562
rebake = true;564
this.#rebakeAllChunks();563
}564
}565
if (prefs?.wetSand != null)566
{567
const pct = Number(prefs.wetSand);568
const next = !Number.isFinite(pct) || pct <= 0569
? 0570
: Math.min(1, pct / 100);571
if (next !== this.wetSandBandFraction)572
{573
this.wetSandBandFraction = next;574
rebake = true;575
}565
}576
}566
}577
if (rebake)578
{ this.#rebakeAllChunks(); }579
}567
}580
568
581
/** Apply server (or local) calendar season; rebakes chunks when it changes. */569
/** Apply server (or local) calendar season; rebakes chunks when it changes. */@@ -3738,7 +3726,7 @@ export class WorldView3738
preview: this.preview,3726
preview: this.preview,3739
season: this.worldSeason,3727
season: this.worldSeason,3740
softTerrain: this.softTerrain,3728
softTerrain: this.softTerrain,3741
wetSandBandFraction: this.wetSandBandFraction,3729
wetSandBandFraction: Math.max(0, Math.min(1, Number(this.settings?.wetSandBand) || 0)),3742
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),3730
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),3743
cache: this.#atlasCache3731
cache: this.#atlasCache3744
});3732
});@@ -33,6 +33,11 @@ test("live settings save writes only changed fields and appends a log", () =>
33
33
const noop = editor.saveSettings({ nightDarkness: 0.4 }, "admin-2");
34
34
assert.deepEqual(noop.changed, {});
35
35
assert.equal(noop.changelog.length, 1);
36
37
const wet = editor.saveSettings({ wetSandBand: 0.35 }, "admin-1");
38
assert.equal(wet.settings.wetSandBand, 0.35);
39
assert.deepEqual(wet.changed, { wetSandBand: 0.35 });
40
assert.match(wet.changelog.at(-1).diffEntries[0], /Wet sand band/);
36
41
}
37
42
finally
38
43
{ worldDb.close(); }
@@ -33,6 +33,11 @@ test("live settings save writes only changed fields and appends a log", () =>33
const noop = editor.saveSettings({ nightDarkness: 0.4 }, "admin-2");33
const noop = editor.saveSettings({ nightDarkness: 0.4 }, "admin-2");34
assert.deepEqual(noop.changed, {});34
assert.deepEqual(noop.changed, {});35
assert.equal(noop.changelog.length, 1);35
assert.equal(noop.changelog.length, 1);36
37
const wet = editor.saveSettings({ wetSandBand: 0.35 }, "admin-1");38
assert.equal(wet.settings.wetSandBand, 0.35);39
assert.deepEqual(wet.changed, { wetSandBand: 0.35 });40
assert.match(wet.changelog.at(-1).diffEntries[0], /Wet sand band/);36
}41
}37
finally42
finally38
{ worldDb.close(); }43
{ worldDb.close(); }@@ -14,12 +14,8 @@ import {
14
14
isLiquidWaterGround
15
15
} from "../../shared/definitions/tiles.js";
16
16
import { SeasonId } from "../../shared/world/season.js";
17
import {
18
DEFAULT_GRAPHICS_SETTINGS,
19
WetSandBand,
20
wetSandBandFraction,
21
normalizeGraphicsSettings
22
} from "../../shared/graphics/settings.js";
17
import { DEFAULT_WORLD_SETTINGS } from "../../shared/protocol/constants.js";
18
import { WORLD_SETTING_CATEGORIES } from "../../shared/definitions/worldSettings.js";
23
19
24
20
test("sand is blendable wet-shore ground with year-round sprites", () =>
25
21
{
@@ -33,18 +29,17 @@ test("sand is blendable wet-shore ground with year-round sprites", () =>
33
29
assert.equal(sand.water, false);
34
30
});
35
31
36
test("wet sand band defaults to 60% and is a graphics setting", () =>
32
test("wet sand band defaults to 60% as a world graphics setting", () =>
37
33
{
38
34
assert.equal(WET_SAND_BAND_FRACTION, 0.6);
35
assert.equal(DEFAULT_WORLD_SETTINGS.wetSandBand, 0.6);
39
36
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);
40
assert.equal(DEFAULT_GRAPHICS_SETTINGS.wetSand, WetSandBand.medium);
41
assert.equal(wetSandBandFraction(WetSandBand.medium), 0.6);
42
assert.equal(wetSandBandFraction(WetSandBand.off), 0);
43
assert.equal(wetSandBandFraction(WetSandBand.narrow), 0.3);
44
assert.equal(wetSandBandFraction(WetSandBand.wide), 1);
45
assert.equal(normalizeGraphicsSettings({}).wetSand, "60");
46
assert.equal(normalizeGraphicsSettings({ wetSand: "30" }).wetSand, "30");
47
assert.equal(normalizeGraphicsSettings({ wetSand: "nope" }).wetSand, "60");
37
const graphics = WORLD_SETTING_CATEGORIES.find((category) => category.id === "graphics");
38
const field = graphics?.fields.find((entry) => entry.key === "wetSandBand");
39
assert.ok(field);
40
assert.equal(field.type, "range");
41
assert.equal(field.min, 0);
42
assert.equal(field.max, 1);
48
43
});
49
44
50
45
test("east water: edge fully wet, beyond band dry", () =>
@@ -14,12 +14,8 @@ import {14
isLiquidWaterGround14
isLiquidWaterGround15
} from "../../shared/definitions/tiles.js";15
} from "../../shared/definitions/tiles.js";16
import { SeasonId } from "../../shared/world/season.js";16
import { SeasonId } from "../../shared/world/season.js";17
import {17
import { DEFAULT_WORLD_SETTINGS } from "../../shared/protocol/constants.js";18
DEFAULT_GRAPHICS_SETTINGS,18
import { WORLD_SETTING_CATEGORIES } from "../../shared/definitions/worldSettings.js";19
WetSandBand,20
wetSandBandFraction,21
normalizeGraphicsSettings22
} from "../../shared/graphics/settings.js";23
19
24
test("sand is blendable wet-shore ground with year-round sprites", () =>20
test("sand is blendable wet-shore ground with year-round sprites", () =>25
{21
{@@ -33,18 +29,17 @@ test("sand is blendable wet-shore ground with year-round sprites", () =>33
assert.equal(sand.water, false);29
assert.equal(sand.water, false);34
});30
});35
31
36
test("wet sand band defaults to 60% and is a graphics setting", () =>32
test("wet sand band defaults to 60% as a world graphics setting", () =>37
{33
{38
assert.equal(WET_SAND_BAND_FRACTION, 0.6);34
assert.equal(WET_SAND_BAND_FRACTION, 0.6);35
assert.equal(DEFAULT_WORLD_SETTINGS.wetSandBand, 0.6);39
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);36
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);40
assert.equal(DEFAULT_GRAPHICS_SETTINGS.wetSand, WetSandBand.medium);37
const graphics = WORLD_SETTING_CATEGORIES.find((category) => category.id === "graphics");41
assert.equal(wetSandBandFraction(WetSandBand.medium), 0.6);38
const field = graphics?.fields.find((entry) => entry.key === "wetSandBand");42
assert.equal(wetSandBandFraction(WetSandBand.off), 0);39
assert.ok(field);43
assert.equal(wetSandBandFraction(WetSandBand.narrow), 0.3);40
assert.equal(field.type, "range");44
assert.equal(wetSandBandFraction(WetSandBand.wide), 1);41
assert.equal(field.min, 0);45
assert.equal(normalizeGraphicsSettings({}).wetSand, "60");42
assert.equal(field.max, 1);46
assert.equal(normalizeGraphicsSettings({ wetSand: "30" }).wetSand, "30");47
assert.equal(normalizeGraphicsSettings({ wetSand: "nope" }).wetSand, "60");48
});43
});49
44
50
test("east water: edge fully wet, beyond band dry", () =>45
test("east water: edge fully wet, beyond band dry", () =>