Commit fa4add3a authored by Chunchi Che's avatar Chunchi Che

udpate singleSlot.tsx and cardListModal.tsx

parent 05ed6e30
Pipeline #19765 passed with stages
in 4 minutes and 52 seconds
...@@ -13,7 +13,14 @@ export const setCardListModalIsOpenImpl: CaseReducer< ...@@ -13,7 +13,14 @@ export const setCardListModalIsOpenImpl: CaseReducer<
// 更新卡牌列表数据 // 更新卡牌列表数据
export const setCardListModalInfoImpl: CaseReducer< export const setCardListModalInfoImpl: CaseReducer<
DuelState, DuelState,
PayloadAction<{ name?: string; desc?: string; imgUrl?: string }[]> PayloadAction<
{
name?: string;
desc?: string;
imgUrl?: string;
interactivies: { desc: string; response: number }[];
}[]
>
> = (state, action) => { > = (state, action) => {
const list = action.payload; const list = action.payload;
......
...@@ -16,6 +16,7 @@ export interface ModalState { ...@@ -16,6 +16,7 @@ export interface ModalState {
name?: string; name?: string;
desc?: string; desc?: string;
imgUrl?: string; imgUrl?: string;
interactivies: { desc: string; response: number }[];
}[]; }[];
}; };
// 卡牌选择弹窗 // 卡牌选择弹窗
......
...@@ -5,10 +5,13 @@ import { ...@@ -5,10 +5,13 @@ import {
selectCardListModalIsOpen, selectCardListModalIsOpen,
selectCardListModalInfo, selectCardListModalInfo,
} from "../../reducers/duel/modal/mod"; } from "../../reducers/duel/modal/mod";
import { setCardListModalIsOpen } from "../../reducers/duel/mod"; import {
import { Modal, List, Popover, Card } from "antd"; clearAllIdleInteractivities,
setCardListModalIsOpen,
} from "../../reducers/duel/mod";
import { Modal, List, Button } from "antd";
import { sendSelectIdleCmdResponse } from "../../api/ocgcore/ocgHelper";
const { Meta } = Card;
const CARD_WIDTH = 100; const CARD_WIDTH = 100;
const CardListModal = () => { const CardListModal = () => {
...@@ -26,21 +29,30 @@ const CardListModal = () => { ...@@ -26,21 +29,30 @@ const CardListModal = () => {
itemLayout="horizontal" itemLayout="horizontal"
dataSource={list} dataSource={list}
renderItem={(item) => ( renderItem={(item) => (
<Popover <List.Item
content={ actions={item.interactivies.map((interactivy, idx) => (
<Card <Button
hoverable key={idx}
style={{ width: CARD_WIDTH }} onClick={() => {
cover={<img alt={item.name} src={item.imgUrl} />} sendSelectIdleCmdResponse(interactivy.response);
dispatch(setCardListModalIsOpen(false));
dispatch(clearAllIdleInteractivities(0));
dispatch(clearAllIdleInteractivities(1));
}}
> >
<Meta title={item.name} /> {interactivy.desc}
</Card> </Button>
))}
extra={
<img
alt={item.name}
src={item.imgUrl}
style={{ width: CARD_WIDTH }}
/>
} }
> >
<List.Item> <List.Item.Meta title={item.name} description={item.desc} />
<List.Item.Meta title={item.name} description={item.desc} /> </List.Item>
</List.Item>
</Popover>
)} )}
></List> ></List>
</Modal> </Modal>
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
setCardListModalInfo, setCardListModalInfo,
setCardListModalIsOpen, setCardListModalIsOpen,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { interactTypeToString } from "./util";
const shape = CONFIG.SingleSlotShape; const shape = CONFIG.SingleSlotShape;
export const Depth = 0.005; export const Depth = 0.005;
...@@ -20,8 +21,8 @@ const SingleSlot = (props: { ...@@ -20,8 +21,8 @@ const SingleSlot = (props: {
const boxRef = useRef(null); const boxRef = useRef(null);
const dispatch = store.dispatch; const dispatch = store.dispatch;
const edgeRender = const edgeRender =
props.state.find( props.state.find((item) =>
(item) => item.placeInteractivities || item.idleInteractivities.length > 0 item === undefined ? false : item.idleInteractivities.length > 0
) !== undefined; ) !== undefined;
const edgesWidth = 2.0; const edgesWidth = 2.0;
...@@ -39,6 +40,12 @@ const SingleSlot = (props: { ...@@ -39,6 +40,12 @@ const SingleSlot = (props: {
name: item.occupant?.text.name, name: item.occupant?.text.name,
desc: item.occupant?.text.desc, desc: item.occupant?.text.desc,
imgUrl: `https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${item.occupant?.id}.jpg`, imgUrl: `https://cdn02.moecube.com:444/images/ygopro-images-zh-CN/${item.occupant?.id}.jpg`,
interactivies: item.idleInteractivities.map((interactivy) => {
return {
desc: interactTypeToString(interactivy.interactType),
response: interactivy.response,
};
}),
}; };
}) })
) )
......
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