Skip to content

Commit 1f586c1

Browse files
author
DavidQ
committed
Flatten game skin objects and update skin loader/editor to use first-class object keys (e.g., brick1, ringSaturn) with strict hex colors and no nested object groups.
1 parent b0dd0b8 commit 1f586c1

18 files changed

Lines changed: 2173 additions & 398 deletions

File tree

games/SolarSystem/assets/presets/game-solarsystem-skin-editor.json

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,107 @@
1010
"skinPath": "/games/SolarSystem/assets/skins/default.json",
1111
"skin": {
1212
"documentKind": "game-skin",
13-
"schema": "games.solar-system.skin/1",
1413
"version": 1,
14+
"schema": "games.solar-system.skin/1",
1515
"gameId": "SolarSystem",
1616
"name": "Solar System Classic Skin",
17-
"colors": {
18-
"background": "#030712",
19-
"frame": "#dbeafe",
20-
"orbit": "#334155",
21-
"text": "#dbeafe",
22-
"muted": "#94a3b8",
23-
"panel": "#07101d"
24-
},
25-
"entities": {
17+
"objects": {
18+
"background": {
19+
"color": "#030712"
20+
},
21+
"frame": {
22+
"color": "#dbeafe"
23+
},
24+
"orbit": {
25+
"color": "#334155"
26+
},
2627
"sun": {
2728
"color": "#fbbf24",
2829
"radius": 30
2930
},
30-
"planets": {
31-
"mercury": { "color": "#9ca3af" },
32-
"venus": { "color": "#fde68a" },
33-
"earth": { "color": "#38bdf8" },
34-
"mars": { "color": "#fb7185" },
35-
"jupiter": { "color": "#f59e0b" },
36-
"saturn": { "color": "#eab308" },
37-
"uranus": { "color": "#67e8f9" },
38-
"neptune": { "color": "#60a5fa" }
39-
},
40-
"moons": {
41-
"moon": { "color": "#e5e7eb" },
42-
"io": { "color": "#fde68a" },
43-
"europa": { "color": "#dbeafe" },
44-
"ganymede": { "color": "#cbd5e1" },
45-
"titan": { "color": "#fef3c7" }
46-
},
47-
"rings": {
48-
"jupiter": "rgba(245, 158, 11, 0.22)",
49-
"saturn": "rgba(253, 230, 138, 0.55)",
50-
"uranus": "rgba(103, 232, 249, 0.28)",
51-
"neptune": "rgba(96, 165, 250, 0.24)"
31+
"hudText": {
32+
"color": "#dbeafe"
33+
},
34+
"hudMuted": {
35+
"color": "#94a3b8"
36+
},
37+
"hudPanel": {
38+
"color": "#07101d"
39+
},
40+
"mercury": {
41+
"color": "#9ca3af",
42+
"radius": 4
43+
},
44+
"venus": {
45+
"color": "#fde68a",
46+
"radius": 6
47+
},
48+
"earth": {
49+
"color": "#38bdf8",
50+
"radius": 6
51+
},
52+
"mars": {
53+
"color": "#fb7185",
54+
"radius": 5
55+
},
56+
"jupiter": {
57+
"color": "#f59e0b",
58+
"radius": 14
59+
},
60+
"saturn": {
61+
"color": "#eab308",
62+
"radius": 12
63+
},
64+
"uranus": {
65+
"color": "#67e8f9",
66+
"radius": 10
67+
},
68+
"neptune": {
69+
"color": "#60a5fa",
70+
"radius": 10
71+
},
72+
"moon": {
73+
"color": "#e5e7eb",
74+
"radius": 2
75+
},
76+
"io": {
77+
"color": "#fde68a",
78+
"radius": 2
79+
},
80+
"europa": {
81+
"color": "#dbeafe",
82+
"radius": 2
83+
},
84+
"ganymede": {
85+
"color": "#cbd5e1",
86+
"radius": 3
87+
},
88+
"titan": {
89+
"color": "#fef3c7",
90+
"radius": 3
91+
},
92+
"ringJupiter": {
93+
"color": "#f59e0b",
94+
"innerRadius": 18,
95+
"outerRadius": 22
96+
},
97+
"ringSaturn": {
98+
"color": "#fde68a",
99+
"innerRadius": 18,
100+
"outerRadius": 30
101+
},
102+
"ringUranus": {
103+
"color": "#67e8f9",
104+
"innerRadius": 15,
105+
"outerRadius": 20
106+
},
107+
"ringNeptune": {
108+
"color": "#60a5fa",
109+
"innerRadius": 15,
110+
"outerRadius": 19
52111
}
53-
}
112+
},
113+
"entities": {}
54114
}
55115
}
56116
}
Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,104 @@
11
{
22
"documentKind": "game-skin",
3-
"schema": "games.solar-system.skin/1",
43
"version": 1,
4+
"schema": "games.solar-system.skin/1",
55
"gameId": "SolarSystem",
66
"name": "Solar System Classic Skin",
7-
"colors": {
8-
"background": "#030712",
9-
"frame": "#dbeafe",
10-
"orbit": "#334155",
11-
"text": "#dbeafe",
12-
"muted": "#94a3b8",
13-
"panel": "#07101d"
14-
},
15-
"entities": {
7+
"objects": {
8+
"background": {
9+
"color": "#030712"
10+
},
11+
"frame": {
12+
"color": "#dbeafe"
13+
},
14+
"orbit": {
15+
"color": "#334155"
16+
},
1617
"sun": {
1718
"color": "#fbbf24",
1819
"radius": 30
1920
},
20-
"planets": {
21-
"mercury": { "color": "#9ca3af" },
22-
"venus": { "color": "#fde68a" },
23-
"earth": { "color": "#38bdf8" },
24-
"mars": { "color": "#fb7185" },
25-
"jupiter": { "color": "#f59e0b" },
26-
"saturn": { "color": "#eab308" },
27-
"uranus": { "color": "#67e8f9" },
28-
"neptune": { "color": "#60a5fa" }
29-
},
30-
"moons": {
31-
"moon": { "color": "#e5e7eb" },
32-
"io": { "color": "#fde68a" },
33-
"europa": { "color": "#dbeafe" },
34-
"ganymede": { "color": "#cbd5e1" },
35-
"titan": { "color": "#fef3c7" }
36-
},
37-
"rings": {
38-
"jupiter": "rgba(245, 158, 11, 0.22)",
39-
"saturn": "rgba(253, 230, 138, 0.55)",
40-
"uranus": "rgba(103, 232, 249, 0.28)",
41-
"neptune": "rgba(96, 165, 250, 0.24)"
21+
"hudText": {
22+
"color": "#dbeafe"
23+
},
24+
"hudMuted": {
25+
"color": "#94a3b8"
26+
},
27+
"hudPanel": {
28+
"color": "#07101d"
29+
},
30+
"mercury": {
31+
"color": "#9ca3af",
32+
"radius": 4
33+
},
34+
"venus": {
35+
"color": "#fde68a",
36+
"radius": 6
37+
},
38+
"earth": {
39+
"color": "#38bdf8",
40+
"radius": 6
41+
},
42+
"mars": {
43+
"color": "#fb7185",
44+
"radius": 5
45+
},
46+
"jupiter": {
47+
"color": "#f59e0b",
48+
"radius": 14
49+
},
50+
"saturn": {
51+
"color": "#eab308",
52+
"radius": 12
53+
},
54+
"uranus": {
55+
"color": "#67e8f9",
56+
"radius": 10
57+
},
58+
"neptune": {
59+
"color": "#60a5fa",
60+
"radius": 10
61+
},
62+
"moon": {
63+
"color": "#e5e7eb",
64+
"radius": 2
65+
},
66+
"io": {
67+
"color": "#fde68a",
68+
"radius": 2
69+
},
70+
"europa": {
71+
"color": "#dbeafe",
72+
"radius": 2
73+
},
74+
"ganymede": {
75+
"color": "#cbd5e1",
76+
"radius": 3
77+
},
78+
"titan": {
79+
"color": "#fef3c7",
80+
"radius": 3
81+
},
82+
"ringJupiter": {
83+
"color": "#f59e0b",
84+
"innerRadius": 18,
85+
"outerRadius": 22
86+
},
87+
"ringSaturn": {
88+
"color": "#fde68a",
89+
"innerRadius": 18,
90+
"outerRadius": 30
91+
},
92+
"ringUranus": {
93+
"color": "#67e8f9",
94+
"innerRadius": 15,
95+
"outerRadius": 20
96+
},
97+
"ringNeptune": {
98+
"color": "#60a5fa",
99+
"innerRadius": 15,
100+
"outerRadius": 19
42101
}
43-
}
102+
},
103+
"entities": {}
44104
}

games/SolarSystem/game/SolarSystemWorld.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ function sanitizeSolarWorldSkin(skin) {
109109
};
110110
}
111111

112+
function toOptionalPositiveNumber(value) {
113+
const numeric = Number(value);
114+
if (!Number.isFinite(numeric)) {
115+
return null;
116+
}
117+
return numeric > 0 ? numeric : null;
118+
}
119+
112120
function bodyPosition(centerX, centerY, orbitRadius, angleRadians, orbitScaleY = 0.72) {
113121
return {
114122
x: centerX + Math.cos(angleRadians) * orbitRadius,
@@ -159,11 +167,27 @@ export default class SolarSystemWorld {
159167
if (typeof skinPlanet.color === 'string' && skinPlanet.color.trim()) {
160168
planet.color = skinPlanet.color.trim();
161169
}
162-
const ringColor = this.skin.entities.rings[planet.id];
170+
const skinPlanetRadius = toOptionalPositiveNumber(skinPlanet.radius);
171+
if (skinPlanetRadius !== null) {
172+
planet.radius = skinPlanetRadius;
173+
}
174+
const ringEntry = this.skin.entities.rings[planet.id];
175+
const ringColor = typeof ringEntry === 'string'
176+
? ringEntry
177+
: toObject(ringEntry).color;
163178
if (planet.ring) {
164179
if (typeof ringColor === 'string' && ringColor.trim()) {
165180
planet.ring.color = ringColor.trim();
166181
}
182+
const ringDetails = toObject(ringEntry);
183+
const nextInner = toOptionalPositiveNumber(ringDetails.innerRadius);
184+
const nextOuter = toOptionalPositiveNumber(ringDetails.outerRadius);
185+
if (nextInner !== null) {
186+
planet.ring.innerRadius = nextInner;
187+
}
188+
if (nextOuter !== null) {
189+
planet.ring.outerRadius = nextOuter;
190+
}
167191
} else if (typeof ringColor === 'string' && ringColor.trim()) {
168192
planet.ring = {
169193
innerRadius: Math.max(planet.radius + 2, planet.radius * 1.5),
@@ -178,6 +202,10 @@ export default class SolarSystemWorld {
178202
if (typeof skinMoon.color === 'string' && skinMoon.color.trim()) {
179203
moon.color = skinMoon.color.trim();
180204
}
205+
const skinMoonRadius = toOptionalPositiveNumber(skinMoon.radius);
206+
if (skinMoonRadius !== null) {
207+
moon.radius = skinMoonRadius;
208+
}
181209
});
182210
}
183211

0 commit comments

Comments
 (0)