feat: configure outdoor texture scale and rotation per area
This commit is contained in:
1 parent
d8cf076019
commit
c56f1a5ba9
26 files changed
+1958
-1778
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
import { html, nothing, type TemplateResult } from "lit";
|
||||
import { formatNumber, type I18nKey } from "../../../i18n.ts";
|
||||
import { bounds, cutsOut, isAxisRect, uid, type FenceGate, type FreeWall, OUTDOOR_TOP, OUTDOOR_TYPES, outdoorStanding, SLOPE_DIRS, type Direction, type OutdoorArea, type OutdoorType, type SlopeDir, type Vec2 } from "../../../model.ts";
|
||||
import { bounds, cutsOut, isAxisRect, uid, type FenceGate, type FreeWall, OUTDOOR_TOP, OUTDOOR_TYPES, outdoorStanding, outdoorTextureSettings, SLOPE_DIRS, type Direction, type OutdoorArea, type OutdoorType, type SlopeDir, type Vec2 } from "../../../model.ts";
|
||||
import { checkField, entityField, hint, numberField, selectField, toThousandths } from "../fields.ts";
|
||||
import { entityOptions } from "../entities.ts";
|
||||
import type { EditorHost } from "../host.ts";
|
||||
@@ -24,12 +24,22 @@ export function renderOutdoorForm(host: EditorHost, area: OutdoorArea, actions:
|
||||
const t = host.t;
|
||||
const set = (patch: Partial<OutdoorArea>) => actions.update(patch);
|
||||
const box = bounds(area.points);
|
||||
const texture = outdoorTextureSettings(area);
|
||||
const types = OUTDOOR_TYPES.map((type): [OutdoorType, string] => [type, t(`out_${type}` as I18nKey)]);
|
||||
const slopeDirs = SLOPE_DIRS.map((d): [SlopeDir, string] => [d, t(`slope_${d.replace("-", "n")}` as I18nKey)]);
|
||||
return html`<section>
|
||||
<div class="nf-h3row"><h3>${t("outdoor")}</h3>${actions.lockButton}</div>
|
||||
<div class="nf-form">
|
||||
${selectField(host, t("outdoor_type"), area.type, types, (type) => set({ type }), { wide: true })}
|
||||
${numberField(host, t("outdoor_texture_scale"), texture.scale * 100, (v) => {
|
||||
const { scale } = outdoorTextureSettings({ texture_scale: v / 100 });
|
||||
set({ texture_scale: scale === 1 ? null : scale });
|
||||
}, 5, 5)}
|
||||
${numberField(host, t("outdoor_texture_rotation"), texture.rotation, (v) => {
|
||||
const { rotation } = outdoorTextureSettings({ texture_rotation: v });
|
||||
set({ texture_rotation: rotation || null });
|
||||
}, 5)}
|
||||
${hint(t("outdoor_texture_hint"))}
|
||||
${selectField(host, t("area"), area.area_id ?? "", [["", t("no_area")], ...Object.values(host.hass?.areas ?? {}).sort((a, b) => a.name.localeCompare(b.name)).map((a): [string, string] => [a.area_id, a.name])], (id) => set({ area_id: id || null }), { wide: true, title: t("outdoor_area_hint") })}
|
||||
${area.type === "pool" || area.type === "wild" || area.type === "bed"
|
||||
? html`${entityField(host, t("pool_temp"), area.temp_entity ?? null, undefined, entityOptions(host.hass, (id) => id.startsWith("sensor.") && host.hass?.states[id]?.attributes.device_class === "temperature"), (v) => set({ temp_entity: v && v !== "none" ? v : null }))}
|
||||
|
||||
@@ -31,6 +31,11 @@ test("a floor opening is the drawn rectangle, and an outdoor area its outline; c
|
||||
assert.equal(area.type, "lawn");
|
||||
assert.equal(area.points[2][1], 1.235);
|
||||
assert.deepEqual(copyOfOutdoorArea(area).points[0], [0.5, 0.5]);
|
||||
const textured = { ...area, texture_scale: 2.5, texture_rotation: 45 };
|
||||
const copy = copyOfOutdoorArea(textured);
|
||||
assert.equal(copy.texture_scale, 2.5);
|
||||
assert.equal(copy.texture_rotation, 45);
|
||||
assert.notEqual(copy.id, textured.id);
|
||||
});
|
||||
|
||||
test("new furniture has its type's size, and stairs reach to the floor above", () => {
|
||||
|
||||
Reference in new issue
Block a user