fixes
@@ -9,10 +9,11 @@ import {
9
9
10
10
/**
11
11
* @param {{
12
* onChange: (settings: { viewDistance: string, lighting: string, bloom: string }) => void
12
* onChange: (settings: object) => void,
13
* onSuppressWorldClick?: () => void
13
14
* }} options
14
15
*/
15
export function initGraphicsSettings ({ onChange })
16
export function initGraphicsSettings ({ onChange, onSuppressWorldClick })
16
17
{
17
18
const toggle = document.getElementById("settings-toggle");
18
19
const panel = document.getElementById("settings-panel");
@@ -22,7 +23,8 @@ export function initGraphicsSettings ({ onChange })
22
23
return {
23
24
getSettings: () => loadGraphicsSettings(),
24
25
apply: () => {},
25
close: () => {}
26
close: () => {},
27
isBlocking: () => false
26
28
};
27
29
}
28
30
@@ -56,17 +58,43 @@ export function initGraphicsSettings ({ onChange })
56
58
panel.hidden = true;
57
59
}
58
60
59
toggle.addEventListener("click", () =>
61
function isBlocking ()
60
62
{
63
return !panel.hidden;
64
}
65
66
function suppressWorld (event)
67
{
68
event.preventDefault();
69
event.stopPropagation();
70
onSuppressWorldClick?.();
71
}
72
73
toggle.addEventListener("mousedown", suppressWorld);
74
toggle.addEventListener("click", (event) =>
75
{
76
event.preventDefault();
77
event.stopPropagation();
78
onSuppressWorldClick?.();
61
79
if (panel.hidden)
62
80
{ open(); }
63
81
else
64
82
{ close(); }
65
83
});
66
closeBtn?.addEventListener("click", close);
84
closeBtn?.addEventListener("mousedown", suppressWorld);
85
closeBtn?.addEventListener("click", (event) =>
86
{
87
event.preventDefault();
88
event.stopPropagation();
89
onSuppressWorldClick?.();
90
close();
91
});
67
92
93
panel.addEventListener("mousedown", suppressWorld);
68
94
panel.addEventListener("click", (event) =>
69
95
{
96
event.stopPropagation();
97
onSuppressWorldClick?.();
70
98
const btn = event.target.closest("[data-graphics-key]");
71
99
if (!btn || !panel.contains(btn))
72
100
{ return; }
@@ -85,7 +113,8 @@ export function initGraphicsSettings ({ onChange })
85
113
/** Re-apply current settings (e.g. after world enter). */
86
114
apply ()
87
115
{ onChange?.(settings); },
88
close
116
close,
117
isBlocking
89
118
};
90
119
}
91
120
@@ -9,10 +9,11 @@ import {9
9
10
/**10
/**11
* @param {{11
* @param {{12
* onChange: (settings: { viewDistance: string, lighting: string, bloom: string }) => void12
* onChange: (settings: object) => void,13
* onSuppressWorldClick?: () => void13
* }} options14
* }} options14
*/15
*/15
export function initGraphicsSettings ({ onChange })16
export function initGraphicsSettings ({ onChange, onSuppressWorldClick })16
{17
{17
const toggle = document.getElementById("settings-toggle");18
const toggle = document.getElementById("settings-toggle");18
const panel = document.getElementById("settings-panel");19
const panel = document.getElementById("settings-panel");@@ -22,7 +23,8 @@ export function initGraphicsSettings ({ onChange })22
return {23
return {23
getSettings: () => loadGraphicsSettings(),24
getSettings: () => loadGraphicsSettings(),24
apply: () => {},25
apply: () => {},25
close: () => {}26
close: () => {},27
isBlocking: () => false26
};28
};27
}29
}28
30
@@ -56,17 +58,43 @@ export function initGraphicsSettings ({ onChange })56
panel.hidden = true;58
panel.hidden = true;57
}59
}58
60
59
toggle.addEventListener("click", () =>61
function isBlocking ()60
{62
{63
return !panel.hidden;64
}65
66
function suppressWorld (event)67
{68
event.preventDefault();69
event.stopPropagation();70
onSuppressWorldClick?.();71
}72
73
toggle.addEventListener("mousedown", suppressWorld);74
toggle.addEventListener("click", (event) =>75
{76
event.preventDefault();77
event.stopPropagation();78
onSuppressWorldClick?.();61
if (panel.hidden)79
if (panel.hidden)62
{ open(); }80
{ open(); }63
else81
else64
{ close(); }82
{ close(); }65
});83
});66
closeBtn?.addEventListener("click", close);84
closeBtn?.addEventListener("mousedown", suppressWorld);85
closeBtn?.addEventListener("click", (event) =>86
{87
event.preventDefault();88
event.stopPropagation();89
onSuppressWorldClick?.();90
close();91
});67
92
93
panel.addEventListener("mousedown", suppressWorld);68
panel.addEventListener("click", (event) =>94
panel.addEventListener("click", (event) =>69
{95
{96
event.stopPropagation();97
onSuppressWorldClick?.();70
const btn = event.target.closest("[data-graphics-key]");98
const btn = event.target.closest("[data-graphics-key]");71
if (!btn || !panel.contains(btn))99
if (!btn || !panel.contains(btn))72
{ return; }100
{ return; }@@ -85,7 +113,8 @@ export function initGraphicsSettings ({ onChange })85
/** Re-apply current settings (e.g. after world enter). */113
/** Re-apply current settings (e.g. after world enter). */86
apply ()114
apply ()87
{ onChange?.(settings); },115
{ onChange?.(settings); },88
close116
close,117
isBlocking89
};118
};90
}119
}91
120
@@ -122,6 +122,7 @@ function uiBlocked ()
122
122
|| market?.isBlocking() || bounty?.isBlocking() || barber?.isBlocking()
123
123
|| questsUi?.isBlocking() || dialogueUi?.isBlocking()
124
124
|| contextMenu?.isOpen() || death?.isBlocking() || spells?.isBlocking()
125
|| graphicsSettingsUi?.isBlocking?.()
125
126
|| pointerOverSpellUi());
126
127
}
127
128
@@ -1003,7 +1004,8 @@ async function main ()
1003
1004
});
1004
1005
void createHairControls?.refreshPreview();
1005
1006
graphicsSettingsUi = initGraphicsSettings({
1006
onChange: applyGraphicsSettings
1007
onChange: applyGraphicsSettings,
1008
onSuppressWorldClick: consumeWorldClick
1007
1009
});
1008
1010
social = initSocial({
1009
1011
socket: { send (payload) { socket.send(payload); } },
@@ -122,6 +122,7 @@ function uiBlocked ()122
|| market?.isBlocking() || bounty?.isBlocking() || barber?.isBlocking()122
|| market?.isBlocking() || bounty?.isBlocking() || barber?.isBlocking()123
|| questsUi?.isBlocking() || dialogueUi?.isBlocking()123
|| questsUi?.isBlocking() || dialogueUi?.isBlocking()124
|| contextMenu?.isOpen() || death?.isBlocking() || spells?.isBlocking()124
|| contextMenu?.isOpen() || death?.isBlocking() || spells?.isBlocking()125
|| graphicsSettingsUi?.isBlocking?.()125
|| pointerOverSpellUi());126
|| pointerOverSpellUi());126
}127
}127
128
@@ -1003,7 +1004,8 @@ async function main ()1003
});1004
});1004
void createHairControls?.refreshPreview();1005
void createHairControls?.refreshPreview();1005
graphicsSettingsUi = initGraphicsSettings({1006
graphicsSettingsUi = initGraphicsSettings({1006
onChange: applyGraphicsSettings1007
onChange: applyGraphicsSettings,1008
onSuppressWorldClick: consumeWorldClick1007
});1009
});1008
social = initSocial({1010
social = initSocial({1009
socket: { send (payload) { socket.send(payload); } },1011
socket: { send (payload) { socket.send(payload); } },@@ -142,7 +142,7 @@ Each entry is a short note on behaviour and where the code lives. Update this fi
142
142
## Client graphics settings
143
143
144
144
**Status:** full
145
**Spec:** Gear button (top-right) opens a client settings panel persisted in `localStorage`. **Viewing distance** Long (default) keeps the 5×5 map ring; Short limits map subscriptions to the 3×3 around the player (`SET_GRAPHICS_SETTINGS`). **Lighting** Soft (default) uses corner-blended lightmaps; Simple fills each tile flat. **Bloom** On/Off toggles the bloom render layer. **Soft terrain** On/Off (default Off) edge-blends `blendable` ground tiles (grass, dirt) into differing neighbours along **cardinal** edges only: outer edge pixel 50% neighbour, next pixel 25% (softer 40%/20% when both sides are blendable); baked at chunk atlas time.
145
**Spec:** Gear button (top-right) opens a client settings panel persisted in `localStorage`. **Viewing distance** Long (default) keeps the 5×5 map ring; Short limits map subscriptions to the 3×3 around the player (`SET_GRAPHICS_SETTINGS`). **Lighting** Soft (default) uses corner-blended lightmaps; Simple fills each tile flat. **Bloom** On/Off toggles the bloom render layer. **Soft terrain** On/Off (default **On**) edge-blends `blendable` ground tiles (grass, dirt) into differing neighbours along **cardinal** edges only: outer edge pixel 50% neighbour, next pixel 25% (softer 40%/20% when both sides are blendable); baked at chunk atlas time. The settings panel blocks world clicks while open.
146
146
**Code:** `shared/graphics/settings.js`, `client/src/play/graphicsSettings.js`, `client/src/render/worldView.js` (`setGraphicsPrefs`), `client/src/render/chunkBake.js`, `shared/render/softTerrain.js`, `server/src/gateway/websocket.js`
147
147
148
148
## Night shading
@@ -142,7 +142,7 @@ Each entry is a short note on behaviour and where the code lives. Update this fi142
## Client graphics settings
142
## Client graphics settings
143
143
144
**Status:** full
144
**Status:** full
145
**Spec:** Gear button (top-right) opens a client settings panel persisted in `localStorage`. **Viewing distance** Long (default) keeps the 5×5 map ring; Short limits map subscriptions to the 3×3 around the player (`SET_GRAPHICS_SETTINGS`). **Lighting** Soft (default) uses corner-blended lightmaps; Simple fills each tile flat. **Bloom** On/Off toggles the bloom render layer. **Soft terrain** On/Off (default Off) edge-blends `blendable` ground tiles (grass, dirt) into differing neighbours along **cardinal** edges only: outer edge pixel 50% neighbour, next pixel 25% (softer 40%/20% when both sides are blendable); baked at chunk atlas time.
145
**Spec:** Gear button (top-right) opens a client settings panel persisted in `localStorage`. **Viewing distance** Long (default) keeps the 5×5 map ring; Short limits map subscriptions to the 3×3 around the player (`SET_GRAPHICS_SETTINGS`). **Lighting** Soft (default) uses corner-blended lightmaps; Simple fills each tile flat. **Bloom** On/Off toggles the bloom render layer. **Soft terrain** On/Off (default **On**) edge-blends `blendable` ground tiles (grass, dirt) into differing neighbours along **cardinal** edges only: outer edge pixel 50% neighbour, next pixel 25% (softer 40%/20% when both sides are blendable); baked at chunk atlas time. The settings panel blocks world clicks while open.
146
**Code:** `shared/graphics/settings.js`, `client/src/play/graphicsSettings.js`, `client/src/render/worldView.js` (`setGraphicsPrefs`), `client/src/render/chunkBake.js`, `shared/render/softTerrain.js`, `server/src/gateway/websocket.js`
146
**Code:** `shared/graphics/settings.js`, `client/src/play/graphicsSettings.js`, `client/src/render/worldView.js` (`setGraphicsPrefs`), `client/src/render/chunkBake.js`, `shared/render/softTerrain.js`, `server/src/gateway/websocket.js`
147
147
148
## Night shading
148
## Night shading
@@ -23,12 +23,13 @@ test("grass and dirt are blendable outdoor grounds", () =>
23
23
assert.equal(GROUND_DEFINITIONS[GroundType.water].blendable, undefined);
24
24
});
25
25
26
test("soft terrain setting defaults off and normalizes", () =>
26
test("soft terrain setting defaults on and normalizes", () =>
27
27
{
28
assert.equal(DEFAULT_GRAPHICS_SETTINGS.softTerrain, SoftTerrainMode.off);
29
assert.equal(normalizeGraphicsSettings({}).softTerrain, SoftTerrainMode.off);
28
assert.equal(DEFAULT_GRAPHICS_SETTINGS.softTerrain, SoftTerrainMode.on);
29
assert.equal(normalizeGraphicsSettings({}).softTerrain, SoftTerrainMode.on);
30
30
assert.equal(normalizeGraphicsSettings({ softTerrain: "on" }).softTerrain, SoftTerrainMode.on);
31
assert.equal(normalizeGraphicsSettings({ softTerrain: "nope" }).softTerrain, SoftTerrainMode.off);
31
assert.equal(normalizeGraphicsSettings({ softTerrain: "off" }).softTerrain, SoftTerrainMode.off);
32
assert.equal(normalizeGraphicsSettings({ softTerrain: "nope" }).softTerrain, SoftTerrainMode.on);
32
33
});
33
34
34
35
test("east edge weights: outer 50%, inner 25% (hard neighbor)", () =>
@@ -23,12 +23,13 @@ test("grass and dirt are blendable outdoor grounds", () =>23
assert.equal(GROUND_DEFINITIONS[GroundType.water].blendable, undefined);23
assert.equal(GROUND_DEFINITIONS[GroundType.water].blendable, undefined);24
});24
});25
25
26
test("soft terrain setting defaults off and normalizes", () =>26
test("soft terrain setting defaults on and normalizes", () =>27
{27
{28
assert.equal(DEFAULT_GRAPHICS_SETTINGS.softTerrain, SoftTerrainMode.off);28
assert.equal(DEFAULT_GRAPHICS_SETTINGS.softTerrain, SoftTerrainMode.on);29
assert.equal(normalizeGraphicsSettings({}).softTerrain, SoftTerrainMode.off);29
assert.equal(normalizeGraphicsSettings({}).softTerrain, SoftTerrainMode.on);30
assert.equal(normalizeGraphicsSettings({ softTerrain: "on" }).softTerrain, SoftTerrainMode.on);30
assert.equal(normalizeGraphicsSettings({ softTerrain: "on" }).softTerrain, SoftTerrainMode.on);31
assert.equal(normalizeGraphicsSettings({ softTerrain: "nope" }).softTerrain, SoftTerrainMode.off);31
assert.equal(normalizeGraphicsSettings({ softTerrain: "off" }).softTerrain, SoftTerrainMode.off);32
assert.equal(normalizeGraphicsSettings({ softTerrain: "nope" }).softTerrain, SoftTerrainMode.on);32
});33
});33
34
34
test("east edge weights: outer 50%, inner 25% (hard neighbor)", () =>35
test("east edge weights: outer 50%, inner 25% (hard neighbor)", () =>