mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-11-24 14:06:29 +08:00
fixed # 更改休息处和商店的样式
This commit is contained in:
+25
-20
@@ -2,12 +2,34 @@ import { ui } from "../../../../noname.js";
|
||||
import { mountMenu } from "./navigation.js";
|
||||
import { createRelicIcon } from "./relic-icon.js";
|
||||
|
||||
export const chooseButtons = (title, choices, description = "", options = {}) => new Promise(resolve => {
|
||||
export const chooseFlow = (title, render, { back } = {}) => new Promise(resolve => {
|
||||
const previousFocus = document.activeElement;
|
||||
const overlay = ui.create.div(".mengsan-overlay-shuying.mengsan-flow-overlay-shuying", ui.window);
|
||||
overlay.setAttribute("role", "dialog");
|
||||
overlay.setAttribute("aria-modal", "true");
|
||||
overlay.setAttribute("aria-label", title);
|
||||
const finish = id => {
|
||||
if (overlay.dataset.resolved) return;
|
||||
overlay.dataset.resolved = "true";
|
||||
overlay.remove();
|
||||
if (previousFocus?.isConnected) previousFocus.focus();
|
||||
resolve(id);
|
||||
};
|
||||
const initialFocus = render(overlay, finish);
|
||||
overlay.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape" && back) {
|
||||
event.preventDefault(); finish(back); return;
|
||||
}
|
||||
if (event.key !== "Tab") return;
|
||||
const focusable = [...overlay.querySelectorAll("button:not(:disabled)")];
|
||||
const first = focusable[0], last = focusable[focusable.length - 1];
|
||||
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
||||
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
||||
});
|
||||
initialFocus?.focus();
|
||||
});
|
||||
|
||||
export const chooseButtons = (title, choices, description = "", options = {}) => chooseFlow(title, (overlay, finish) => {
|
||||
const panel = ui.create.div(".mengsan-panel-shuying.mengsan-flow-panel-shuying", overlay);
|
||||
const eyebrow = document.createElement("p");
|
||||
eyebrow.className = "mengsan-flow-eyebrow-shuying";
|
||||
@@ -22,13 +44,6 @@ export const chooseButtons = (title, choices, description = "", options = {}) =>
|
||||
summary.textContent = description;
|
||||
}
|
||||
const buttons = ui.create.div(".mengsan-choice-list-shuying", panel);
|
||||
const finish = id => {
|
||||
if (overlay.dataset.resolved) return;
|
||||
overlay.dataset.resolved = "true";
|
||||
overlay.remove();
|
||||
if (previousFocus?.isConnected) previousFocus.focus();
|
||||
resolve(id);
|
||||
};
|
||||
choices.forEach(choice => {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
@@ -51,15 +66,5 @@ export const chooseButtons = (title, choices, description = "", options = {}) =>
|
||||
buttons.appendChild(button);
|
||||
});
|
||||
if (options.menu !== false) mountMenu(overlay);
|
||||
overlay.addEventListener("keydown", event => {
|
||||
if (event.key === "Escape" && options.back) {
|
||||
event.preventDefault(); finish(options.back); return;
|
||||
}
|
||||
if (event.key !== "Tab") return;
|
||||
const focusable = [...overlay.querySelectorAll("button:not(:disabled)")];
|
||||
const first = focusable[0], last = focusable[focusable.length - 1];
|
||||
if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
|
||||
else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
|
||||
});
|
||||
buttons.querySelector("button:not(:disabled)")?.focus();
|
||||
});
|
||||
return buttons.querySelector("button:not(:disabled)");
|
||||
}, options);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import { chooseFlow } from "./flow-ui.js";
|
||||
import { mountMenu } from "./navigation.js";
|
||||
import { createRelicIcon } from "./relic-icon.js";
|
||||
|
||||
const iconPaths = {
|
||||
heal: "M3 12h4l2-4 3 8 2-4h7M20.8 12.2c1.8-2.4.9-6.2-2-7.2-2.5-.9-4.9.3-6.8 2.3C10.1 5.3 7.7 4.1 5.2 5c-2.9 1-3.8 4.8-2 7.2 2.3 3 5.6 6.4 8.8 8.3 3.2-1.9 6.5-5.3 8.8-8.3Z",
|
||||
upgrade: "m15 10-9.5 9.5-2-2L13 8m2-4 5 5-3 3-5-5 3-3ZM19 4l2 2",
|
||||
relic: "m12 3 8 9-8 9-8-9 8-9Z",
|
||||
chevron: "m9 6 6 6-6 6",
|
||||
leave: "M4 12h15m-6-6 6 6-6 6",
|
||||
};
|
||||
|
||||
function element(tag, className, text) {
|
||||
const node = document.createElement(tag);
|
||||
node.className = `ms-rest-${className}`;
|
||||
if (text != null) node.textContent = text;
|
||||
return node;
|
||||
}
|
||||
|
||||
function icon(name) {
|
||||
const namespace = "http://www.w3.org/2000/svg";
|
||||
const svg = document.createElementNS(namespace, "svg");
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
const path = document.createElementNS(namespace, "path");
|
||||
path.setAttribute("d", iconPaths[name]);
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
|
||||
function actionButton(choice, core, finish) {
|
||||
const button = element("button", "action");
|
||||
button.type = "button";
|
||||
button.dataset.choice = choice.id;
|
||||
button.disabled = Boolean(choice.disabled);
|
||||
|
||||
const art = element("span", "action-art");
|
||||
art.append(createRelicIcon(choice.image) || icon(core ? choice.id : "relic"));
|
||||
const copy = element("span", "action-copy");
|
||||
const description = choice.disabled && choice.disabledReason ? choice.disabledReason : choice.description;
|
||||
copy.append(element("strong", "action-name", choice.name), element("span", "action-description", description));
|
||||
button.append(art, copy);
|
||||
if (core) button.append(icon("chevron"));
|
||||
button.addEventListener("click", () => {
|
||||
if (!button.disabled) finish(choice.id);
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
export const chooseRest = (choices, { tent, lastAction }) => chooseFlow("休息处", (overlay, finish) => {
|
||||
overlay.classList.add("mengsan-rest-overlay-shuying");
|
||||
|
||||
const header = element("header", "header");
|
||||
const brand = element("p", "brand");
|
||||
const mark = element("span", "mark", "夢");
|
||||
mark.setAttribute("aria-hidden", "true");
|
||||
brand.append(mark, element("span", "context", "梦三 · 征程"));
|
||||
header.append(brand);
|
||||
const menu = mountMenu(header);
|
||||
|
||||
const body = element("section", "body");
|
||||
const dock = element("div", "dock");
|
||||
const core = element("div", "core");
|
||||
const relics = element("section", "relics");
|
||||
const relicActions = element("div", "relic-actions");
|
||||
for (const choice of choices) {
|
||||
const isCore = choice.id === "heal" || choice.id === "upgrade";
|
||||
(isCore ? core : relicActions).append(actionButton(choice, isCore, finish));
|
||||
}
|
||||
if (core.childElementCount) dock.append(core);
|
||||
if (relicActions.childElementCount) {
|
||||
relics.append(element("h2", "relic-heading", "遗物选项"), relicActions);
|
||||
dock.append(relics);
|
||||
}
|
||||
|
||||
const footer = element("footer", "footer");
|
||||
const remaining = choices.filter(choice => !choice.disabled).length;
|
||||
const rule = remaining ? `还可执行 ${remaining} 项,每项限一次` : "已完成所有可用选项";
|
||||
const prefix = lastAction ? `已执行${lastAction}` : "微型帐篷";
|
||||
const status = element("p", "status", tent ? `${prefix} · ${rule}` : "选择一项后返回地图");
|
||||
status.setAttribute("role", "status");
|
||||
footer.append(status);
|
||||
if (tent) {
|
||||
const leave = element("button", "leave");
|
||||
leave.type = "button";
|
||||
leave.dataset.choice = "done";
|
||||
leave.append("离开休息处", icon("leave"));
|
||||
leave.addEventListener("click", () => finish("done"));
|
||||
footer.append(leave);
|
||||
}
|
||||
dock.append(footer);
|
||||
body.append(element("h1", "title", "休息处"), dock);
|
||||
overlay.append(header, body);
|
||||
return dock.querySelector("button:not(:disabled)") || menu;
|
||||
});
|
||||
@@ -0,0 +1,264 @@
|
||||
.mengsan-flow-overlay-shuying.mengsan-rest-overlay-shuying {
|
||||
--rest-paper: #fff1df;
|
||||
--rest-muted: #dfcbb9;
|
||||
--rest-accent: #ffbf79;
|
||||
--rest-edge: #826951;
|
||||
--rest-panel: #2d2a28;
|
||||
--rest-hover: #493629;
|
||||
--rest-ground: #12181b;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
color: var(--rest-paper);
|
||||
color-scheme: dark;
|
||||
background:
|
||||
linear-gradient(180deg, #0d131ade 0%, #11161d26 23%, #151a1c12 38%, #12181bed 94%, var(--rest-ground)),
|
||||
url("../assets/scenes/pinefire-camp.webp") center 86% / cover no-repeat,
|
||||
var(--rest-ground);
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying div { position: static; }
|
||||
.mengsan-rest-overlay-shuying :is(h1, h2, p) { margin: 0; }
|
||||
|
||||
.ms-rest-header,
|
||||
.ms-rest-body {
|
||||
width: min(100%, 1440px);
|
||||
margin-inline: auto;
|
||||
padding-left: max(clamp(16px, 4vw, 52px), env(safe-area-inset-left));
|
||||
padding-right: max(clamp(16px, 4vw, 52px), env(safe-area-inset-right));
|
||||
}
|
||||
|
||||
.ms-rest-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding-top: max(14px, env(safe-area-inset-top));
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.ms-rest-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 11px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ms-rest-brand > .ms-rest-context { letter-spacing: .14em; }
|
||||
|
||||
.ms-rest-mark {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: none;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 2px;
|
||||
color: #fff0d8;
|
||||
background: #843c2b;
|
||||
font: 700 19px/1 "KaiTi", "STKaiti", "SimSun", serif;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .mengsan-flow-menu-shuying {
|
||||
position: static !important;
|
||||
min-width: 82px;
|
||||
min-height: 44px;
|
||||
padding: 8px 12px;
|
||||
border-color: var(--rest-edge);
|
||||
color: var(--rest-paper);
|
||||
background: #272626;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .mengsan-flow-menu-shuying:hover { background: var(--rest-hover); }
|
||||
|
||||
.ms-rest-body {
|
||||
display: flex;
|
||||
flex: 1 0 auto;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
padding-top: clamp(28px, 10vh, 112px);
|
||||
padding-bottom: max(16px, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-title {
|
||||
margin-bottom: 22px;
|
||||
color: var(--rest-paper);
|
||||
text-shadow: 0 3px 16px #000;
|
||||
font: 700 clamp(44px, 6.8vw, 86px)/1.1 "KaiTi", "STKaiti", "SimSun", serif;
|
||||
letter-spacing: .075em;
|
||||
}
|
||||
|
||||
.ms-rest-dock {
|
||||
align-self: flex-end;
|
||||
width: min(100%, 680px);
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-core, .ms-rest-relic-actions) {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-relic-actions {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.ms-rest-relics { margin-top: 15px; }
|
||||
.ms-rest-dock > .ms-rest-relics:first-child { margin-top: 0; }
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-relic-heading {
|
||||
margin-bottom: 6px;
|
||||
color: var(--rest-muted);
|
||||
font-size: 13px;
|
||||
text-shadow: 0 1px 4px #000;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-action, .ms-rest-leave) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: 1px solid var(--rest-edge);
|
||||
border-radius: 4px;
|
||||
color: var(--rest-paper);
|
||||
font: inherit;
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
touch-action: manipulation;
|
||||
transition: background-color .16s, border-color .16s;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-action, .ms-rest-leave, .mengsan-flow-menu-shuying):focus-visible {
|
||||
outline: 2px solid var(--rest-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-action {
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
min-height: 78px;
|
||||
padding: 10px 12px;
|
||||
background: var(--rest-panel);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-action[data-choice="heal"] {
|
||||
border-color: #a67850;
|
||||
background: #362a23;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-action:enabled:hover {
|
||||
border-color: var(--rest-accent);
|
||||
background: var(--rest-hover);
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-action, .ms-rest-leave):enabled:active { filter: brightness(.88); }
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-action:disabled {
|
||||
border-style: dashed;
|
||||
color: #c0b8b2;
|
||||
background: #252729;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-action, .ms-rest-leave) svg {
|
||||
flex: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.5;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.ms-rest-action > svg { color: var(--rest-accent); }
|
||||
.ms-rest-action:disabled > svg { visibility: hidden; }
|
||||
|
||||
.ms-rest-action-art {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: 0 0 38px;
|
||||
height: 38px;
|
||||
border: 1px solid var(--rest-edge);
|
||||
border-radius: 50%;
|
||||
color: var(--rest-accent);
|
||||
background: #3d3028;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-action-art > .mengsan-relic-icon-shuying {
|
||||
position: static !important;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.ms-rest-action:disabled .ms-rest-action-art {
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
filter: grayscale(1);
|
||||
}
|
||||
|
||||
.ms-rest-action-copy { display: grid; flex: 1; min-width: 0; gap: 3px; }
|
||||
.ms-rest-action-name { font-size: 18px; line-height: 1.25; }
|
||||
.ms-rest-action-description { color: var(--rest-muted); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
|
||||
.ms-rest-action:disabled .ms-rest-action-description { color: inherit; }
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-relic-actions .ms-rest-action {
|
||||
min-height: 62px;
|
||||
gap: 7px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.ms-rest-relic-actions .ms-rest-action-art { flex-basis: 32px; height: 32px; }
|
||||
.ms-rest-relic-actions .ms-rest-action-name { font-size: 15px; }
|
||||
|
||||
.ms-rest-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 12px;
|
||||
min-height: 44px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.ms-rest-status { color: var(--rest-muted); font-size: 13px; text-shadow: 0 1px 4px #000; }
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-leave {
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
padding-inline: 12px;
|
||||
border-color: #efc69a;
|
||||
color: #292016;
|
||||
background: #efc69a;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mengsan-rest-overlay-shuying .ms-rest-leave:hover { background: #ffe0bb; }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.mengsan-rest-overlay-shuying .ms-rest-relic-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
}
|
||||
|
||||
@media (max-width: 460px) {
|
||||
.mengsan-flow-overlay-shuying.mengsan-rest-overlay-shuying { background-position: center, 39% center; }
|
||||
.mengsan-rest-overlay-shuying .ms-rest-title { margin-bottom: 16px; }
|
||||
.mengsan-rest-overlay-shuying .ms-rest-core .ms-rest-action {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
.ms-rest-core .ms-rest-action > svg { display: none; }
|
||||
}
|
||||
|
||||
@media (max-height: 500px) {
|
||||
.ms-rest-body { padding-top: 22px; }
|
||||
.mengsan-rest-overlay-shuying .ms-rest-title { font-size: 42px; margin-bottom: 14px; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.mengsan-rest-overlay-shuying :is(.ms-rest-action, .ms-rest-leave) { transition: none; }
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import { chooseFlow } from "./flow-ui.js";
|
||||
import { mountMenu } from "./navigation.js";
|
||||
import { createRelicIcon } from "./relic-icon.js";
|
||||
|
||||
const portraitUrl = new URL("../assets/portraits/sushuang-zhangshiping.png", import.meta.url).href;
|
||||
const iconPaths = {
|
||||
coin: "M20.5 12a8.5 8.5 0 1 1-17 0 8.5 8.5 0 0 1 17 0ZM10 10h4v4h-4z",
|
||||
heart: "M20 8.6c0 4-5.4 7.7-8 10-2.6-2.3-8-6-8-10A4.5 4.5 0 0 1 12 6a4.5 4.5 0 0 1 8 2.6Z",
|
||||
heal: "M9 3h6v6h6v6h-6v6H9v-6H3V9h6z",
|
||||
exit: "M13 4H6v16h7M12 12h9m-3-3 3 3-3 3",
|
||||
};
|
||||
|
||||
function element(tag, className, text) {
|
||||
const node = document.createElement(tag);
|
||||
node.className = `ms-shop-${className}`;
|
||||
if (text != null) node.textContent = text;
|
||||
return node;
|
||||
}
|
||||
|
||||
function icon(name) {
|
||||
const namespace = "http://www.w3.org/2000/svg";
|
||||
const svg = document.createElementNS(namespace, "svg");
|
||||
svg.setAttribute("viewBox", "0 0 24 24");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
const path = document.createElementNS(namespace, "path");
|
||||
path.setAttribute("d", iconPaths[name]);
|
||||
svg.append(path);
|
||||
return svg;
|
||||
}
|
||||
|
||||
function statusItem(symbol, label, value) {
|
||||
const item = element("span", "stat");
|
||||
item.append(icon(symbol), element("span", "stat-label", label), element("b", "value", value));
|
||||
return item;
|
||||
}
|
||||
|
||||
function offer(choice, relic, finish) {
|
||||
const card = element("article", "offer");
|
||||
const art = element("span", "art");
|
||||
art.setAttribute("aria-hidden", "true");
|
||||
const visual = relic ? createRelicIcon(choice.image) :
|
||||
choice.id === "card_sha" ? element("span", "card-face", "杀") : icon("heal");
|
||||
if (visual) art.append(visual);
|
||||
|
||||
const copy = element("div", "copy");
|
||||
const description = element("p", "description", choice.description);
|
||||
description.id = `ms-shop-description-${choice.id}`;
|
||||
copy.append(element("h3", "name", choice.name), description);
|
||||
|
||||
const button = element("button", "price");
|
||||
button.type = "button";
|
||||
button.disabled = Boolean(choice.disabled);
|
||||
button.dataset.choice = choice.id;
|
||||
button.setAttribute("aria-label", `${choice.name},${choice.price} 金币`);
|
||||
button.setAttribute("aria-describedby", description.id);
|
||||
const price = element("span", "amount");
|
||||
price.append(icon("coin"), element("b", "value", choice.price), element("span", "unit", "金币"));
|
||||
button.append(element("span", "buy", "购买"), price);
|
||||
button.addEventListener("click", () => finish(choice.id));
|
||||
card.append(art, copy, button);
|
||||
return card;
|
||||
}
|
||||
|
||||
function appendOffers(counter, label, group, choices, finish) {
|
||||
if (!choices.length) return;
|
||||
const section = element("section", group);
|
||||
const offers = element("div", "offers");
|
||||
for (const choice of choices) offers.append(offer(choice, group === "relics", finish));
|
||||
section.append(element("h2", "heading", label), offers);
|
||||
counter.append(section);
|
||||
}
|
||||
|
||||
export const chooseShop = (player, choices) => chooseFlow("商店", (overlay, finish) => {
|
||||
overlay.classList.add("mengsan-shop-overlay-shuying");
|
||||
const panel = element("section", "panel");
|
||||
const portrait = element("figure", "portrait");
|
||||
const image = document.createElement("img");
|
||||
image.alt = "";
|
||||
image.src = portraitUrl;
|
||||
image.addEventListener("error", () => image.remove(), { once: true });
|
||||
const caption = element("figcaption", "caption");
|
||||
caption.append(element("span", "merchant-label", "中山商贾"), element("b", "merchants", "苏双、张世平"));
|
||||
portrait.append(image, caption);
|
||||
|
||||
const counter = element("div", "counter");
|
||||
const header = element("header", "header");
|
||||
const heading = element("div", "title");
|
||||
heading.append(element("p", "context", "梦三 · 征程"), element("h1", "title-text", "商店"));
|
||||
const status = element("div", "status");
|
||||
status.append(
|
||||
statusItem("coin", "金币", player.gold),
|
||||
statusItem("heart", "生命", player.hp == null ? "未初始化" : `${player.hp}/${player.maxHp}`),
|
||||
);
|
||||
const menu = mountMenu(status);
|
||||
header.append(heading, status);
|
||||
counter.append(header);
|
||||
|
||||
const relics = [], supplies = [];
|
||||
for (const choice of choices) (choice.id.startsWith("relic:") ? relics : supplies).push(choice);
|
||||
appendOffers(counter, "遗物", "relics", relics, finish);
|
||||
appendOffers(counter, "补给", "supplies", supplies, finish);
|
||||
|
||||
const footer = element("footer", "footer");
|
||||
const leave = element("button", "leave");
|
||||
leave.type = "button";
|
||||
leave.dataset.choice = "leave";
|
||||
leave.append(icon("exit"), "离开商店");
|
||||
leave.addEventListener("click", () => finish("leave"));
|
||||
footer.append(leave);
|
||||
counter.append(footer);
|
||||
panel.append(portrait, counter);
|
||||
overlay.append(panel);
|
||||
return menu;
|
||||
});
|
||||
@@ -0,0 +1,265 @@
|
||||
.mengsan-flow-overlay-shuying.mengsan-shop-overlay-shuying {
|
||||
--shop-paper: #fff0d4;
|
||||
--shop-muted: #d6c6ad;
|
||||
--shop-gold: #edc795;
|
||||
--shop-edge: #8e7451;
|
||||
--shop-title-font: "KaiTi", "STKaiti", "SimSun", serif;
|
||||
overflow: hidden;
|
||||
padding: 20px;
|
||||
color: var(--shop-paper);
|
||||
background: radial-gradient(ellipse at 32% 34%, #494238, #20221e 62%, #171915);
|
||||
}
|
||||
|
||||
.mengsan-shop-overlay-shuying div { position: static; }
|
||||
.mengsan-shop-overlay-shuying :is(h1, h2, h3, p, figure) { margin: 0; }
|
||||
.mengsan-shop-overlay-shuying svg {
|
||||
flex: none;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.65;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.ms-shop-panel {
|
||||
display: grid;
|
||||
grid-template-columns: 38% minmax(0, 1fr);
|
||||
flex: none;
|
||||
width: min(1168px, 100%);
|
||||
min-height: min(650px, 100%);
|
||||
max-height: 100%;
|
||||
overflow: auto;
|
||||
border: 1px solid #b48c58;
|
||||
background: #26231d;
|
||||
box-shadow: 0 26px 68px #14110c9c;
|
||||
scrollbar-color: #96764e #26231d;
|
||||
}
|
||||
|
||||
.ms-shop-portrait {
|
||||
position: relative;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid #b48c58;
|
||||
background: #534638;
|
||||
}
|
||||
|
||||
.ms-shop-portrait img {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: 50% 28%;
|
||||
}
|
||||
|
||||
.ms-shop-portrait::after {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
content: "";
|
||||
background: linear-gradient(0deg, #1f1a12ef, transparent 46%);
|
||||
}
|
||||
|
||||
.ms-shop-caption {
|
||||
position: absolute;
|
||||
inset: auto 24px 24px;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ms-shop-merchant-label { color: #f2d39f; font-size: 14px; }
|
||||
.ms-shop-merchants { font: 700 34px/1.2 var(--shop-title-font); }
|
||||
|
||||
.ms-shop-counter {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
padding: 24px 25px 22px;
|
||||
background: radial-gradient(ellipse at 64% -8%, #494033, transparent 72%), #27241d;
|
||||
}
|
||||
|
||||
.ms-shop-header, .ms-shop-status, .ms-shop-stat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.ms-shop-header { justify-content: space-between; flex-wrap: wrap; }
|
||||
.ms-shop-status { flex-wrap: wrap; }
|
||||
.ms-shop-stat { gap: 6px; color: #f2dfb7; font-size: 13px; white-space: nowrap; }
|
||||
.ms-shop-stat + .ms-shop-stat { padding-left: 12px; border-left: 1px solid #8f755858; }
|
||||
.ms-shop-stat svg { width: 18px; height: 18px; color: #e7ad65; }
|
||||
.ms-shop-value {
|
||||
font: 700 20px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.mengsan-shop-overlay-shuying .ms-shop-context {
|
||||
color: #e9c18c;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .12em !important;
|
||||
}
|
||||
|
||||
.mengsan-shop-overlay-shuying .ms-shop-title-text {
|
||||
margin-top: 5px;
|
||||
font: 700 clamp(38px, 4.4vw, 56px)/1.1 var(--shop-title-font);
|
||||
}
|
||||
|
||||
.mengsan-shop-overlay-shuying .ms-shop-status > .mengsan-flow-menu-shuying {
|
||||
position: static !important;
|
||||
min-width: 64px;
|
||||
min-height: 44px;
|
||||
padding: 6px 9px;
|
||||
border-color: #9a7951;
|
||||
border-radius: 3px;
|
||||
background: #3e3224;
|
||||
color: #f2dfb7;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.mengsan-shop-overlay-shuying .ms-shop-status > .mengsan-flow-menu-shuying:hover { background: #58432d; }
|
||||
.ms-shop-relics { margin-top: 22px; }
|
||||
.ms-shop-supplies { margin-top: 17px; }
|
||||
|
||||
.mengsan-shop-overlay-shuying .ms-shop-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
color: var(--shop-gold);
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.ms-shop-heading::after {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
content: "";
|
||||
background: #8e745183;
|
||||
}
|
||||
|
||||
.ms-shop-offers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
|
||||
.ms-shop-offer {
|
||||
display: grid;
|
||||
grid-template-columns: 56px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 11px 12px;
|
||||
border: 1px solid var(--shop-edge);
|
||||
background: #3a3225;
|
||||
}
|
||||
|
||||
.ms-shop-art { display: grid; min-width: 0; place-items: center; color: var(--shop-gold); }
|
||||
.ms-shop-art .mengsan-relic-icon-shuying {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
filter: drop-shadow(0 5px 5px #17100966);
|
||||
}
|
||||
.ms-shop-name { font: 700 24px/1.25 var(--shop-title-font); }
|
||||
.mengsan-shop-overlay-shuying .ms-shop-description {
|
||||
margin-top: 4px;
|
||||
color: var(--shop-muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.ms-shop-price, .ms-shop-leave {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 7px;
|
||||
min-height: 44px;
|
||||
padding: 7px 11px;
|
||||
border: 1px solid #ab875b;
|
||||
border-radius: 3px;
|
||||
background: #4d3c28;
|
||||
color: #ffe5b3;
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
touch-action: manipulation;
|
||||
}
|
||||
|
||||
.ms-shop-price:hover:not(:disabled), .ms-shop-leave:hover { background: #725135; }
|
||||
.ms-shop-price:disabled { opacity: .56; cursor: not-allowed; }
|
||||
.ms-shop-price:focus-visible, .ms-shop-leave:focus-visible {
|
||||
outline: 2px solid #efc580;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.ms-shop-amount { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.ms-shop-amount svg { width: 16px; height: 16px; }
|
||||
.ms-shop-relics .ms-shop-price { grid-column: 1 / -1; justify-content: space-between; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child {
|
||||
grid-column: 1 / -1;
|
||||
grid-template-columns: 90px minmax(0, 1fr) auto;
|
||||
gap: 14px;
|
||||
padding: 13px 15px;
|
||||
background: radial-gradient(ellipse at 12% 50%, #80603e, transparent 63%), #433729;
|
||||
}
|
||||
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-price { grid-column: auto; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-buy { display: none; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-art .mengsan-relic-icon-shuying { width: 78px; height: 78px; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-name { font-size: 30px; }
|
||||
|
||||
.ms-shop-supplies .ms-shop-offer {
|
||||
grid-template-columns: 36px minmax(0, 1fr) auto;
|
||||
gap: 7px;
|
||||
padding: 8px;
|
||||
border-color: #765e43;
|
||||
background: #332e23;
|
||||
}
|
||||
.ms-shop-supplies .ms-shop-name { font: 700 16px/1.25 "Microsoft YaHei", sans-serif; }
|
||||
.mengsan-shop-overlay-shuying .ms-shop-supplies .ms-shop-description { font-size: 12px; }
|
||||
.ms-shop-supplies .ms-shop-art svg { width: 26px; height: 26px; }
|
||||
.ms-shop-supplies .ms-shop-price { padding-inline: 8px; }
|
||||
.ms-shop-supplies :is(.ms-shop-buy, .ms-shop-unit) { display: none; }
|
||||
.ms-shop-card-face {
|
||||
display: grid;
|
||||
width: 30px;
|
||||
height: 43px;
|
||||
place-items: center;
|
||||
border: 1px solid #6c543b;
|
||||
outline: 1px solid #d1a76f;
|
||||
background: linear-gradient(150deg, #f5dfa9, #b98751);
|
||||
color: #422d1f;
|
||||
font: 700 21px/1 var(--shop-title-font);
|
||||
}
|
||||
|
||||
.ms-shop-footer { display: flex; justify-content: flex-end; margin-top: auto; padding-top: 16px; }
|
||||
.ms-shop-leave { background: transparent; color: #e9d9ba; border-color: var(--shop-edge); }
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.ms-shop-panel { grid-template-columns: 31% minmax(0, 1fr); }
|
||||
.ms-shop-counter { padding: 19px; }
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.ms-shop-supplies .ms-shop-offers { grid-template-columns: minmax(0, 1fr); }
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.mengsan-flow-overlay-shuying.mengsan-shop-overlay-shuying { padding: 10px; }
|
||||
.ms-shop-panel { grid-template-columns: minmax(0, 1fr); min-height: 0; }
|
||||
.ms-shop-portrait {
|
||||
min-height: clamp(140px, 29vh, 210px);
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #b48c58;
|
||||
}
|
||||
.ms-shop-caption { inset: auto 14px 12px; }
|
||||
.ms-shop-merchants { font-size: 26px; }
|
||||
.ms-shop-counter { padding: 14px; }
|
||||
.ms-shop-status { gap: 8px; }
|
||||
.ms-shop-stat + .ms-shop-stat { padding-left: 8px; }
|
||||
.ms-shop-offers { grid-template-columns: minmax(0, 1fr); }
|
||||
.ms-shop-relics .ms-shop-offer:first-child { grid-template-columns: 56px minmax(0, 1fr); gap: 10px; padding: 11px 12px; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-price { grid-column: 1 / -1; justify-content: space-between; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-buy { display: inline; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-art .mengsan-relic-icon-shuying { width: 54px; height: 54px; }
|
||||
.ms-shop-relics .ms-shop-offer:first-child .ms-shop-name { font-size: 24px; }
|
||||
}
|
||||
Reference in New Issue
Block a user