Commit 2f59f2df authored by Chunchi Che's avatar Chunchi Che

Merge branch 'optimize/hint' into 'main'

Optimize/hint

See merge request !282
parents a28e035e ede54487
Pipeline #23242 passed with stages
in 11 minutes and 14 seconds
import { message, notification } from "antd";
import { message } from "antd";
import React, { useEffect } from "react";
import { useSnapshot } from "valtio";
......@@ -9,12 +9,6 @@ import { HandResult, matStore } from "@/stores";
import styles from "./index.module.scss";
const style = {
// borderStyle: "groove",
// borderRadius: "8px",
backgroundColor: "#444",
};
const NeosConfig = useConfig();
let globalMsgApi: ReturnType<typeof message.useMessage>[0] | undefined;
......@@ -25,30 +19,19 @@ export const HintNotification = () => {
const handResults = snap.handResults;
const currentPhase = snap.phase.currentPhase;
const [notify, notifyContextHolder] = notification.useNotification({
maxCount: NeosConfig.ui.hint.maxCount,
});
const [msgApi, msgContextHolder] = message.useMessage({
maxCount: NeosConfig.ui.hint.maxCount,
});
globalMsgApi = msgApi;
useEffect(() => {
if (hintState && hintState.msg) {
notify.open({
message: `${hintState.msg}`,
placement: "topLeft",
style: style,
});
msgApi.info(`${hintState.msg}`);
}
}, [hintState.msg]);
useEffect(() => {
if (toss) {
notify.open({
message: `${toss}`,
placement: "topLeft",
style: style,
});
msgApi.info(`${toss}`);
}
}, [toss]);
......@@ -57,13 +40,11 @@ export const HintNotification = () => {
const meHand = handResults.me;
const opHand = handResults.op;
if (meHand !== HandResult.UNKNOWN && opHand !== HandResult.UNKNOWN) {
notify.open({
message: `{我方出示${getHandResultText(
meHand,
)},对方出示${getHandResultText(opHand)}}`,
placement: "topLeft",
style: style,
});
msgApi.info(
`{我方出示${getHandResultText(meHand)},对方出示${getHandResultText(
opHand,
)}}`,
);
}
}, [handResults]);
......@@ -73,23 +54,14 @@ export const HintNotification = () => {
Region.System,
Phase2StringCodeMap.get(currentPhase) ?? 0,
);
notify.open({
message,
placement: "topRight",
style: style,
});
msgApi.info(message);
console.color("DeepPink")(
`${message}(${matStore.isMe(matStore.currentPlayer) ? "me" : "op"})`,
);
}
}, [currentPhase]);
return (
<>
{notifyContextHolder}
{msgContextHolder}
</>
);
return <>{msgContextHolder}</>;
};
// 防抖的waiting msg
......
......@@ -109,6 +109,12 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
disabled: !submitable,
}}
open={isOpen}
afterClose={() => {
// Modal每次展示时都会消费`esHint`和`esSelectHint`,
// 否则这些提示会保留到下一次Modal展示,可能会疑惑玩家
matStore.hint.esHint = undefined;
matStore.hint.esSelectHint = undefined;
}}
footer={
<>
{cancelable && <Button onClick={onCancel}>{cancelText}</Button>}
......
......@@ -26,6 +26,7 @@ export const YesNoModal: React.FC = () => {
title={`${preHintMsg} ${msg}`}
open={isOpen}
width={400}
afterClose={() => (matStore.hint.esHint = undefined)}
footer={
<>
<Button
......
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