Commit 79f8700c authored by timel's avatar timel

feat: dropdown menu icon

parent bc8d435b
Pipeline #22855 failed with stages
in 12 minutes
...@@ -21,7 +21,7 @@ import { ...@@ -21,7 +21,7 @@ import {
displayOptionModal, displayOptionModal,
displaySimpleSelectCardsModal, displaySimpleSelectCardsModal,
} from "../../Message"; } from "../../Message";
import { interactTypeToString } from "../../utils"; import { interactTypeToIcon, interactTypeToString } from "../../utils";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { import {
attack, attack,
...@@ -31,6 +31,7 @@ import { ...@@ -31,6 +31,7 @@ import {
type MoveOptions, type MoveOptions,
} from "./springs"; } from "./springs";
import type { SpringApiProps } from "./springs/types"; import type { SpringApiProps } from "./springs/types";
import { IconFont } from "@/ui/Shared";
const { HAND, GRAVE, REMOVED, EXTRA, MZONE, SZONE, TZONE } = ygopro.CardZone; const { HAND, GRAVE, REMOVED, EXTRA, MZONE, SZONE, TZONE } = ygopro.CardZone;
...@@ -152,6 +153,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -152,6 +153,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
([action, cards], key) => ({ ([action, cards], key) => ({
key, key,
label: interactTypeToString(action), label: interactTypeToString(action),
icon: interactTypeToIcon(action),
onClick: async () => { onClick: async () => {
if (!isField) { if (!isField) {
// 单卡: 直接召唤/特殊召唤/... // 单卡: 直接召唤/特殊召唤/...
...@@ -185,6 +187,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => { ...@@ -185,6 +187,7 @@ export const Card: React.FC<{ idx: number }> = React.memo(({ idx }) => {
const effectItem: DropdownItem = { const effectItem: DropdownItem = {
key: nonEffectItem.length, key: nonEffectItem.length,
label: interactTypeToString(InteractType.ACTIVATE), label: interactTypeToString(InteractType.ACTIVATE),
icon: interactTypeToIcon(InteractType.ACTIVATE),
onClick: async () => { onClick: async () => {
let tmpCard: CardType; let tmpCard: CardType;
if (!isField) { if (!isField) {
......
body { body {
background-image: url(/neos-assets/play-mat.png); // background-image: url(/neos-assets/play-mat.png);
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
} }
......
...@@ -2,7 +2,6 @@ import { ...@@ -2,7 +2,6 @@ import {
ArrowRightOutlined, ArrowRightOutlined,
CheckOutlined, CheckOutlined,
CloseCircleFilled, CloseCircleFilled,
createFromIconfontCN,
MessageFilled, MessageFilled,
StepForwardFilled, StepForwardFilled,
} from "@ant-design/icons"; } from "@ant-design/icons";
...@@ -26,14 +25,11 @@ import { ...@@ -26,14 +25,11 @@ import {
ygopro, ygopro,
} from "@/api"; } from "@/api";
import { cardStore, ChainSetting, matStore } from "@/stores"; import { cardStore, ChainSetting, matStore } from "@/stores";
import { IconFont } from "@/ui/Shared";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType; import PhaseType = ygopro.StocGameMessage.MsgNewPhase.PhaseType;
const IconFont = createFromIconfontCN({
scriptUrl: ["//at.alicdn.com/t/c/font_4188978_z6f9ellbtoc.js"],
});
const { phase } = matStore; const { phase } = matStore;
const { useToken } = theme; const { useToken } = theme;
export const Menu = () => { export const Menu = () => {
......
export * from "./groupBy"; export * from "./groupBy";
export * from "./interactTypeToString"; export * from "./interactTypeToStringIcon";
export * from "./zip"; export * from "./zip";
import { ygopro } from "@/api";
import { InteractType } from "@/stores"; import { InteractType } from "@/stores";
import { IconFont } from "@/ui/Shared";
import CardPosition = ygopro.CardPosition;
export function interactTypeToString(t: InteractType): string { export function interactTypeToString(t: InteractType): string {
switch (t) { switch (t) {
...@@ -20,3 +24,47 @@ export function interactTypeToString(t: InteractType): string { ...@@ -20,3 +24,47 @@ export function interactTypeToString(t: InteractType): string {
return "未知选项"; return "未知选项";
} }
} }
const Icon: React.FC<{ type: string; size?: number }> = ({
type,
size = 24,
}) => (
<IconFont
type={type}
size={size}
style={{
width: 24,
height: 30,
marginRight: 6,
justifyContent: "center",
}}
/>
);
export function interactTypeToIcon(
t: InteractType,
position?: CardPosition
): JSX.Element {
switch (t) {
case InteractType.POS_CHANGE:
if (position === CardPosition.FACEDOWN_ATTACK)
return <IconFont type="icon-back-defence" />;
else if (position === CardPosition.FACEDOWN_DEFENSE)
return <IconFont type="icon-back" size={22} />;
else if (position === CardPosition.FACEUP_DEFENSE)
return <IconFont type="icon-front" size={22} />;
return <Icon type="icon-front-defence" />;
case InteractType.MSET:
return <Icon type="icon-back-defence" />;
case InteractType.SSET:
return <Icon type="icon-back" size={22} />;
case InteractType.ACTIVATE:
return <Icon type="icon-activate" />;
case InteractType.ATTACK:
return <Icon type="icon-attack" size={20} />;
case InteractType.SUMMON:
case InteractType.SP_SUMMON:
default:
return <Icon type="icon-summon" size={20} />;
}
}
import { createFromIconfontCN } from "@ant-design/icons";
const _IconFont = createFromIconfontCN({
scriptUrl: ["//at.alicdn.com/t/c/font_4188978_14gvq0ry2bk.js"],
});
export const IconFont: React.FC<{
type: string;
size?: number;
style?: React.CSSProperties;
}> = ({ type, size = 14, style }) => (
<_IconFont type={type} style={{ ...style, fontSize: size }} />
);
export * from "./css"; export * from "./css";
export * from "./YgoCard"; export * from "./YgoCard";
export * from "./IconFont";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment