Commit 4325b5c4 authored by mercury233's avatar mercury233 Committed by GitHub

add tip for cards in select / display list (#2146)

parent 56c13662
......@@ -138,6 +138,7 @@ public:
void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable);
void ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* element, irr::gui::IGUIElement* parent);
void SetResponseSelectedCards() const;
void SetResponseSelectedOption() const;
void CancelOrFinish();
......
......@@ -976,6 +976,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) {
int pos = mainGame->scrCardList->getPos() / 10;
ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos];
SetShowMark(mcard, true);
ShowCardInfoInList(mcard, mainGame->btnCardSelect[id - BUTTON_CARD_0], mainGame->wCardSelect);
if(mcard->code) {
mainGame->ShowCardInfo(mcard->code);
} else {
......@@ -985,6 +987,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) {
int pos = mainGame->scrDisplayList->getPos() / 10;
ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos];
SetShowMark(mcard, true);
ShowCardInfoInList(mcard, mainGame->btnCardDisplay[id - BUTTON_DISPLAY_0], mainGame->wCardDisplay);
if(mcard->code) {
mainGame->ShowCardInfo(mcard->code);
} else {
......@@ -993,6 +997,21 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(id >= BUTTON_CARD_0 && id <= BUTTON_CARD_4) {
int pos = mainGame->scrCardList->getPos() / 10;
ClientCard* mcard = selectable_cards[id - BUTTON_CARD_0 + pos];
SetShowMark(mcard, false);
mainGame->stCardListTip->setVisible(false);
}
if(id >= BUTTON_DISPLAY_0 && id <= BUTTON_DISPLAY_4) {
int pos = mainGame->scrDisplayList->getPos() / 10;
ClientCard* mcard = display_cards[id - BUTTON_DISPLAY_0 + pos];
SetShowMark(mcard, false);
mainGame->stCardListTip->setVisible(false);
}
break;
}
default:
break;
}
......@@ -2202,6 +2221,34 @@ void ClientField::SetShowMark(ClientCard* pcard, bool enable) {
chit->chain_card->is_showchaintarget = enable;
}
}
void ClientField::ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* element, irr::gui::IGUIElement* parent) {
std::wstring str(L"");
if(pcard->code) {
str.append(dataManager.GetName(pcard->code));
}
for(size_t i = 0; i < chains.size(); ++i) {
wchar_t formatBuffer[2048];
auto chit = chains[i];
if(pcard == chit.chain_card) {
myswprintf(formatBuffer, dataManager.GetSysString(216), i + 1);
str.append(L"\n").append(formatBuffer);
}
if(chit.target.find(pcard) != chit.target.end()) {
myswprintf(formatBuffer, dataManager.GetSysString(217), i + 1, dataManager.GetName(chit.chain_card->code));
str.append(L"\n").append(formatBuffer);
}
}
if(str.length() > 0) {
parent->addChild(mainGame->stCardListTip);
irr::core::rect<s32> ePos = element->getRelativePosition();
s32 x = (ePos.UpperLeftCorner.X + ePos.LowerRightCorner.X) / 2;
s32 y = ePos.LowerRightCorner.Y;
mainGame->SetStaticText(mainGame->stCardListTip, 160, mainGame->guiFont, str.c_str());
irr::core::dimension2d<unsigned int> dTip = mainGame->guiFont->getDimension(mainGame->stCardListTip->getText()) + irr::core::dimension2d<unsigned int>(10, 10);
mainGame->stCardListTip->setRelativePosition(recti(x - dTip.Width / 2, y - 10, x + dTip.Width / 2, y - 10 + dTip.Height));
mainGame->stCardListTip->setVisible(true);
}
}
void ClientField::SetResponseSelectedCards() const {
unsigned char respbuf[64];
respbuf[0] = selected_cards.size();
......
......@@ -674,6 +674,11 @@ bool Game::Initialize() {
stTip->setBackgroundColor(0xc0ffffff);
stTip->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stTip->setVisible(false);
//tip for cards in select / display list
stCardListTip = env->addStaticText(L"", rect<s32>(0, 0, 150, 150), false, true, wCardSelect, -1, true);
stCardListTip->setBackgroundColor(0xc0ffffff);
stCardListTip->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
stCardListTip->setVisible(false);
device->setEventReceiver(&menuHandler);
LoadConfig();
if(!soundManager.Init()) {
......
......@@ -225,6 +225,7 @@ public:
//hint text
irr::gui::IGUIStaticText* stHintMsg;
irr::gui::IGUIStaticText* stTip;
irr::gui::IGUIStaticText* stCardListTip;
//infos
irr::gui::IGUITabControl* wInfos;
irr::gui::IGUIStaticText* stName;
......
......@@ -68,6 +68,8 @@
!system 213 已选择种族:
!system 214 已选择属性:
!system 215 已选择数字:
!system 216 在连锁%d发动
!system 217 被连锁%d的[%ls]选择为对象
!system 500 请选择要解放的卡
!system 501 请选择要丢弃的手卡
!system 502 请选择要破坏的卡
......
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