Commit a6b96c02 authored by fallenstardust's avatar fallenstardust

额外禁卡表&聊天消息同步

parent 2514e293
...@@ -391,6 +391,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -391,6 +391,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
int sel = mainGame->cbDBDecks->getSelected(); int sel = mainGame->cbDBDecks->getSelected();
if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel)); deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel; prev_deck = sel;
is_modified = false; is_modified = false;
......
...@@ -11,8 +11,44 @@ DeckManager deckManager; ...@@ -11,8 +11,44 @@ DeckManager deckManager;
void DeckManager::LoadLFList(const char* path) { void DeckManager::LoadLFList(const char* path) {
LFList* cur = NULL; LFList* cur = NULL;
FILE* fp = fopen(path, "r"); FILE* fp = fopen(path, "r");
FILE* fp_custom = fopen((workingDir + path("/expansions/lflist.conf")).c_str(), "r");
char linebuf[256]; char linebuf[256];
wchar_t strBuffer[256]; wchar_t strBuffer[256];
if(fp_custom) {
while(fgets(linebuf, 256, fp_custom)) {
if(linebuf[0] == '#')
continue;
int p = 0, sa = 0, code, count;
if(linebuf[0] == '!') {
sa = BufferIO::DecodeUTF8((const char*)(&linebuf[1]), strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) sa--;
LFList newlist;
_lfList.push_back(newlist);
cur = &_lfList[_lfList.size() - 1];
memcpy(cur->listName, (const void*)strBuffer, 40);
cur->listName[sa] = 0;
cur->content = new std::unordered_map<int, int>;
cur->hash = 0x7dfcee6a;
continue;
}
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
if(linebuf[p] == 0)
continue;
linebuf[p++] = 0;
sa = p;
code = atoi(linebuf);
if(code == 0)
continue;
while(linebuf[p] == ' ' || linebuf[p] == '\t') p++;
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
linebuf[p] = 0;
count = atoi(&linebuf[sa]);
if(cur == NULL) continue;
(*cur->content)[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
}
fclose(fp_custom);
}
if(fp) { if(fp) {
while(fgets(linebuf, 256, fp)) { while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#') if(linebuf[0] == '#')
......
...@@ -984,12 +984,13 @@ void Game::DrawSpec() { ...@@ -984,12 +984,13 @@ void Game::DrawSpec() {
showChat = false; showChat = false;
hideChatTimer--; hideChatTimer--;
} }
int maxChatLines = mainGame->dInfo.isStarted ? 5 : 8; for(int i = 0; i < 8; ++i) {
for(int i = 0; i < maxChatLines; ++i) {
static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040, static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040,
0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040}; 0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040};
if(chatTiming[i]) { if(chatTiming[i]) {
chatTiming[i]--; chatTiming[i]--;
if(mainGame->dInfo.isStarted && i >= 5)
continue;
if(!showChat && i > 2) if(!showChat && i > 2)
continue; continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width; int w = textFont->getDimension(chatMsg[i].c_str()).Width;
......
...@@ -472,6 +472,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -472,6 +472,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
list_command = COMMAND_SPSUMMON; list_command = COMMAND_SPSUMMON;
mainGame->wCardSelect->setText(dataManager.GetSysString(509)); mainGame->wCardSelect->setText(dataManager.GetSysString(509));
ShowSelectCard(); ShowSelectCard();
select_ready = false;
ShowCancelOrFinishButton(1); ShowCancelOrFinishButton(1);
} }
break; break;
...@@ -967,18 +968,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -967,18 +968,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
UpdateDeclarableCode(true); UpdateDeclarableCode(true);
break; 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; break;
} }
...@@ -1844,6 +1833,19 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1844,6 +1833,19 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
u32 pos = mainGame->scrCardText->getPos(); u32 pos = mainGame->scrCardText->getPos();
mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->textFont, mainGame->showingtext, pos); mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->textFont, mainGame->showingtext, pos);
return true; return true;
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;
} }
} }
......
...@@ -505,49 +505,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -505,49 +505,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
break; 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; default: break;
} }
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