Commit 36f884fe authored by mercury233's avatar mercury233 Committed by GitHub

update announce number (#2242)

parent e7bac45b
......@@ -959,7 +959,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
FadingUnit fu;
fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
if(win == fit->guiFading && win != wOptions) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
if(win == fit->guiFading && win != wOptions && win != wANNumber) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
fu.fadingSize = fit->fadingSize;
irr::core::position2di center = fu.fadingSize.getCenter();
fu.fadingDiff.X = fu.fadingSize.getWidth() / 10;
......
......@@ -3494,12 +3494,44 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int count = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.lock();
mainGame->cbANNumber->clear();
bool quickmode = count <= 12;
if(quickmode) {
for(int i = 0; i < 12; ++i) {
mainGame->btnANNumber[i]->setEnabled(false);
mainGame->btnANNumber[i]->setPressed(false);
mainGame->btnANNumber[i]->setVisible(true);
}
}
for (int i = 0; i < count; ++i) {
int value = BufferIO::ReadInt32(pbuf);
myswprintf(textBuffer, L" % d", value);
mainGame->cbANNumber->addItem(textBuffer, value);
if(quickmode) {
if((value > 12 || value <= 0)) {
quickmode = false;
} else {
mainGame->btnANNumber[value - 1]->setEnabled(true);
}
}
}
mainGame->cbANNumber->setSelected(0);
if(quickmode) {
mainGame->cbANNumber->setVisible(false);
mainGame->btnANNumberOK->setRelativePosition(rect<s32>(20, 195, 210, 230));
mainGame->btnANNumberOK->setEnabled(false);
recti pos = mainGame->wANNumber->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 250;
mainGame->wANNumber->setRelativePosition(pos);
} else {
for(int i = 0; i < 12; ++i) {
mainGame->btnANNumber[i]->setVisible(false);
}
mainGame->cbANNumber->setVisible(true);
mainGame->btnANNumberOK->setRelativePosition(rect<s32>(80, 60, 150, 85));
recti pos = mainGame->wANNumber->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 95;
mainGame->wANNumber->setRelativePosition(pos);
}
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(565));
......
......@@ -320,6 +320,31 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
SetResponseSelectedOption();
break;
}
case BUTTON_ANNUMBER_1:
case BUTTON_ANNUMBER_2:
case BUTTON_ANNUMBER_3:
case BUTTON_ANNUMBER_4:
case BUTTON_ANNUMBER_5:
case BUTTON_ANNUMBER_6:
case BUTTON_ANNUMBER_7:
case BUTTON_ANNUMBER_8:
case BUTTON_ANNUMBER_9:
case BUTTON_ANNUMBER_10:
case BUTTON_ANNUMBER_11:
case BUTTON_ANNUMBER_12: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
for(int i = 0; i < mainGame->cbANNumber->getItemCount(); ++i) {
if(id - BUTTON_ANNUMBER_1 + 1 == mainGame->cbANNumber->getItemData(i)) {
mainGame->cbANNumber->setSelected(i);
break;
}
}
for(int i = 0; i < 12; ++i) {
mainGame->btnANNumber[i]->setPressed(event.GUIEvent.Caller == mainGame->btnANNumber[i]);
}
mainGame->btnANNumberOK->setEnabled(true);
break;
}
case BUTTON_ANNUMBER_OK: {
soundManager.PlaySoundEffect(SOUND_BUTTON);
DuelClient::SetResponseI(mainGame->cbANNumber->getSelected());
......
......@@ -452,11 +452,16 @@ bool Game::Initialize() {
scrDisplayList = env->addScrollBar(true, rect<s32>(30, 235, 650, 255), wCardDisplay, SCROLL_CARD_DISPLAY);
btnDisplayOK = env->addButton(rect<s32>(300, 265, 380, 290), wCardDisplay, BUTTON_CARD_DISP_OK, dataManager.GetSysString(1211));
//announce number
wANNumber = env->addWindow(rect<s32>(550, 200, 780, 295), false, L"");
wANNumber = env->addWindow(rect<s32>(550, 180, 780, 430), false, L"");
wANNumber->getCloseButton()->setVisible(false);
wANNumber->setVisible(false);
cbANNumber = env->addComboBox(rect<s32>(40, 30, 190, 50), wANNumber, -1);
cbANNumber->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
for(int i = 0; i < 12; ++i) {
myswprintf(strbuf, L"%d", i + 1);
btnANNumber[i] = env->addButton(rect<s32>(20 + 50 * (i % 4), 40 + 50 * (i / 4), 60 + 50 * (i % 4), 80 + 50 * (i / 4)), wANNumber, BUTTON_ANNUMBER_1 + i, strbuf);
btnANNumber[i]->setIsPushButton(true);
}
btnANNumberOK = env->addButton(rect<s32>(80, 60, 150, 85), wANNumber, BUTTON_ANNUMBER_OK, dataManager.GetSysString(1211));
//announce card
wANCard = env->addWindow(rect<s32>(510, 120, 820, 420), false, L"");
......@@ -1600,7 +1605,7 @@ void Game::OnResize() {
wOptions->setRelativePosition(ResizeWin(490, 200, 840, 340));
wPosSelect->setRelativePosition(ResizeWin(340, 200, 935, 410));
wCardSelect->setRelativePosition(ResizeWin(320, 100, 1000, 400));
wANNumber->setRelativePosition(ResizeWin(550, 200, 780, 295));
wANNumber->setRelativePosition(ResizeWin(550, 180, 780, 430));
wANCard->setRelativePosition(ResizeWin(510, 120, 820, 420));
wANAttribute->setRelativePosition(ResizeWin(500, 200, 830, 285));
wANRace->setRelativePosition(ResizeWin(480, 200, 850, 410));
......
......@@ -415,6 +415,7 @@ public:
//announce number
irr::gui::IGUIWindow* wANNumber;
irr::gui::IGUIComboBox* cbANNumber;
irr::gui::IGUIButton* btnANNumber[12];
irr::gui::IGUIButton* btnANNumberOK;
//announce card
irr::gui::IGUIWindow* wANCard;
......@@ -650,9 +651,18 @@ extern Game* mainGame;
#define BUTTON_CHAIN_WHENAVAIL 266
#define BUTTON_CANCEL_OR_FINISH 267
#define BUTTON_PHASE 268
#define BUTTON_CLEAR_LOG 270
#define LISTBOX_LOG 271
#define SCROLL_CARDTEXT 280
#define BUTTON_ANNUMBER_1 270
#define BUTTON_ANNUMBER_2 271
#define BUTTON_ANNUMBER_3 272
#define BUTTON_ANNUMBER_4 273
#define BUTTON_ANNUMBER_5 274
#define BUTTON_ANNUMBER_6 275
#define BUTTON_ANNUMBER_7 276
#define BUTTON_ANNUMBER_8 277
#define BUTTON_ANNUMBER_9 278
#define BUTTON_ANNUMBER_10 279
#define BUTTON_ANNUMBER_11 280
#define BUTTON_ANNUMBER_12 281
#define BUTTON_DISPLAY_0 290
#define BUTTON_DISPLAY_1 291
#define BUTTON_DISPLAY_2 292
......@@ -687,6 +697,9 @@ extern Game* mainGame;
#define BUTTON_MARKS_FILTER 322
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define BUTTON_CLEAR_LOG 350
#define LISTBOX_LOG 351
#define SCROLL_CARDTEXT 352
#define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362
......
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