Commit 2608424b authored by Momobako's avatar Momobako

merge

parents d7b5c140 6dee40b8
......@@ -409,7 +409,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
int sel = mainGame->cbDBDecks->getSelected();
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel;
is_modified = false;
break;
......
......@@ -948,12 +948,13 @@ void Game::DrawSpec() {
showChat = false;
hideChatTimer--;
}
int maxChatLines = dInfo.isStarted ? 5 : 8;
for(int i = 0; i < maxChatLines; ++i) {
for(int i = 0; i < 8; ++i) {
static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040,
0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040};
if(chatTiming[i]) {
chatTiming[i]--;
if(mainGame->dInfo.isStarted && i >= 5)
continue;
if(!showChat && i > 2)
continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width;
......
......@@ -958,18 +958,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateDeclarableCode(true);
break;
}
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
}
break;
}
......@@ -1776,13 +1764,17 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX) {
mainGame->SetCursor(event.GUIEvent.Caller->isEnabled() ? ECI_IBEAM : ECI_NORMAL);
return true;
}
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX) {
mainGame->SetCursor(ECI_NORMAL);
return true;
}
break;
}
case irr::gui::EGET_BUTTON_CLICKED: {
......@@ -1872,6 +1864,24 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
return true;
}
break;
}
}
break;
}
default: break;
}
break;
......
......@@ -27,6 +27,8 @@ void UpdateDeck() {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
}
bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(mainGame->dField.OnCommonEvent(event))
return false;
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
......@@ -40,16 +42,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
mainGame->SetCursor(event.GUIEvent.Caller->isEnabled() ? ECI_IBEAM : ECI_NORMAL);
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
mainGame->SetCursor(ECI_NORMAL);
break;
}
case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110)
soundManager.PlaySoundEffect(SOUND_MENU);
......@@ -510,49 +502,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.isTag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
}
break;
}
default: break;
}
break;
}
case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_R: {
if(!event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
case irr::KEY_ESCAPE: {
if(!mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->device->minimizeWindow();
break;
}
default: break;
}
break;
......
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