Commit eb45db9c authored by fallenstardust's avatar fallenstardust

设置内开关&选择禁卡表

sync gframe
parent bdd8e9b8
......@@ -79,8 +79,7 @@ void DeckBuilder::Initialize() {
mainGame->btnSideShuffle->setVisible(false);
mainGame->btnSideSort->setVisible(false);
mainGame->btnSideReload->setVisible(false);
filterList = deckManager._lfList[0].content;
mainGame->cbLFList->setSelected(0);
filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content;
ClearSearch();
rnd.reset((unsigned int)time(nullptr));
mouse_pos.set(0, 0);
......@@ -851,10 +850,6 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_LFLIST: {
filterList = deckManager._lfList[mainGame->cbLFList->getSelected()].content;
break;
}
case COMBOBOX_DBCATEGORY: {
if(havePopupWindow()) {
mainGame->cbDBCategory->setSelected(prev_category);
......@@ -1487,13 +1482,15 @@ void DeckBuilder::FilterCards() {
if(filter_lm) {
if(filter_lm <= 3 && (!filterList->count(ptr->first) || (*filterList).at(ptr->first) != filter_lm - 1))
continue;
if(filter_lm == 4 && data.ot != 1)
if(filter_lm == 4 && !(data.ot & AVAIL_OCG))
continue;
if(filter_lm == 5 && !(data.ot & AVAIL_TCG))
continue;
if(filter_lm == 5 && data.ot != 2)
if(filter_lm == 6 && !(data.ot & AVAIL_SC))
continue;
if(filter_lm == 6 && data.ot != 3)
if(filter_lm == 7 && !(data.ot & AVAIL_CUSTOM))
continue;
if(filter_lm == 7 && data.ot != 4)
if(filter_lm == 8 && ((data.ot & AVAIL_OCGTCG) != AVAIL_OCGTCG))
continue;
}
bool is_target = true;
......
......@@ -8,8 +8,8 @@ namespace ygo {
DeckManager deckManager;
void DeckManager::LoadLFList(const char* path, bool load_none) {
LFList* cur = NULL;
void DeckManager::LoadLFListSingle(const char* path) {
LFList* cur = nullptr;
FILE* fp = fopen(path, "r");
char linebuf[256];
wchar_t strBuffer[256];
......@@ -17,62 +17,65 @@ void DeckManager::LoadLFList(const char* path, bool load_none) {
while(fgets(linebuf, 256, fp)) {
if(linebuf[0] == '#')
continue;
int p = 0, sa = 0, code, count;
if(linebuf[0] == '!') {
sa = BufferIO::DecodeUTF8((const char*)(&linebuf[1]), strBuffer);
int sa = BufferIO::DecodeUTF8(&linebuf[1], strBuffer);
while(strBuffer[sa - 1] == L'\r' || strBuffer[sa - 1] == L'\n' ) sa--;
strBuffer[sa] = 0;
LFList newlist;
_lfList.push_back(newlist);
cur = &_lfList[_lfList.size() - 1];
memcpy(cur->listName, (const void*)strBuffer, 20 * sizeof(wchar_t));
cur->listName[sa] = 0;
cur->content = new std::unordered_map<int, int>;
cur->listName = strBuffer;
cur->hash = 0x7dfcee6a;
continue;
}
int p = 0;
while(linebuf[p] != ' ' && linebuf[p] != '\t' && linebuf[p] != 0) p++;
if(linebuf[p] == 0)
continue;
linebuf[p++] = 0;
sa = p;
code = atoi(linebuf);
int sa = p;
int 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;
int count = atoi(&linebuf[sa]);
if(!cur) continue;
cur->content[code] = count;
cur->hash = cur->hash ^ ((code << 18) | (code >> 14)) ^ ((code << (27 + count)) | (code >> (5 - count)));
}
fclose(fp);
}
if(!load_none)
return;
LFList nolimit;
myswprintf(nolimit.listName, L"N/A");
nolimit.hash = 0;
nolimit.content = new std::unordered_map<int, int>;
_lfList.push_back(nolimit);
}
wchar_t* DeckManager::GetLFListName(int lfhash) {
for(size_t i = 0; i < _lfList.size(); ++i) {
if(_lfList[i].hash == (unsigned int)lfhash) {
return _lfList[i].listName;
}
}
return (wchar_t*)dataManager.unknown_string;
const wchar_t* DeckManager::GetLFListName(int lfhash) {
auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) {
return list.hash == lfhash;
});
if(lit != _lfList.end())
return lit->listName.c_str();
return dataManager.unknown_string;
}
std::unordered_map<int, int>* DeckManager::GetLFListContent(int lfhash) {
auto lit = std::find_if(_lfList.begin(), _lfList.end(), [lfhash](const ygo::LFList& list) {
return list.hash == lfhash;
});
if(lit != _lfList.end())
return &lit->content;
return nullptr;
}
static int checkAvail(int ot, int avail) {
if((ot & avail) == avail)
return 0;
if((ot & AVAIL_OCG) && !(avail == AVAIL_OCG))
return DECKERROR_OCGONLY;
if((ot & AVAIL_TCG) && !(avail == AVAIL_TCG))
return DECKERROR_TCGONLY;
return DECKERROR_NOTAVAIL;
}
int DeckManager::CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg) {
int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
std::unordered_map<int, int> ccount;
std::unordered_map<int, int>* list = 0;
for(size_t i = 0; i < _lfList.size(); ++i) {
if(_lfList[i].hash == (unsigned int)lfhash) {
list = _lfList[i].content;
break;
}
}
auto list = GetLFListContent(lfhash);
if(!list)
return 0;
int dc = 0;
......@@ -82,13 +85,13 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tc
return (DECKERROR_EXTRACOUNT << 28) + deck.extra.size();
if(deck.side.size() > 15)
return (DECKERROR_SIDECOUNT << 28) + deck.side.size();
const int rule_map[6] = { AVAIL_OCG, AVAIL_TCG, AVAIL_SC, AVAIL_CUSTOM, AVAIL_OCGTCG, 0 };
int avail = rule_map[rule];
for(size_t i = 0; i < deck.main.size(); ++i) {
code_pointer cit = deck.main[i];
if(!allow_ocg && (cit->second.ot == 0x1))
return (DECKERROR_OCGONLY << 28) + cit->first;
if(!allow_tcg && (cit->second.ot == 0x2))
return (DECKERROR_TCGONLY << 28) + cit->first;
int gameruleDeckError = checkAvail(cit->second.ot, avail);
if(gameruleDeckError)
return (gameruleDeckError << 28) + cit->first;
if(cit->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_TOKEN | TYPE_LINK))
return (DECKERROR_EXTRACOUNT << 28);
int code = cit->second.alias ? cit->second.alias : cit->first;
......@@ -102,10 +105,9 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tc
}
for(size_t i = 0; i < deck.extra.size(); ++i) {
code_pointer cit = deck.extra[i];
if(!allow_ocg && (cit->second.ot == 0x1))
return (DECKERROR_OCGONLY << 28) + cit->first;
if(!allow_tcg && (cit->second.ot == 0x2))
return (DECKERROR_TCGONLY << 28) + cit->first;
int gameruleDeckError = checkAvail(cit->second.ot, avail);
if(gameruleDeckError)
return (gameruleDeckError << 28) + cit->first;
int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++;
dc = ccount[code];
......@@ -117,10 +119,9 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tc
}
for(size_t i = 0; i < deck.side.size(); ++i) {
code_pointer cit = deck.side[i];
if(!allow_ocg && (cit->second.ot == 0x1))
return (DECKERROR_OCGONLY << 28) + cit->first;
if(!allow_tcg && (cit->second.ot == 0x2))
return (DECKERROR_TCGONLY << 28) + cit->first;
int gameruleDeckError = checkAvail(cit->second.ot, avail);
if(gameruleDeckError)
return (gameruleDeckError << 28) + cit->first;
int code = cit->second.alias ? cit->second.alias : cit->first;
ccount[code]++;
dc = ccount[code];
......
......@@ -10,8 +10,8 @@ namespace ygo {
struct LFList {
unsigned int hash;
wchar_t listName[20];
std::unordered_map<int, int>* content;
std::wstring listName;
std::unordered_map<int, int> content;
};
struct Deck {
std::vector<code_pointer> main;
......@@ -35,9 +35,10 @@ public:
Deck current_deck;
std::vector<LFList> _lfList;
void LoadLFList(const char* path, bool load_none);
wchar_t* GetLFListName(int lfhash);
int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg);
void LoadLFListSingle(const char* path);
const wchar_t* GetLFListName(int lfhash);
std::unordered_map<int, int>* GetLFListContent(int lfhash);
int CheckDeck(Deck& deck, int lfhash, int rule);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
......
......@@ -1198,9 +1198,7 @@ void Game::WaitFrameSignal(int frame) {
signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame;
frameSignal.Wait();
}
void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist) {
const int width = 44; //standard pic size, maybe it should be defined in game.h
const int height = 64;
void Game::DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int, int>* lflist, bool drag) {
int code = cp->first;
int lcode = cp->second.alias;
if(lcode == 0)
......@@ -1209,39 +1207,50 @@ void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, i
if(img == NULL)
return; //NULL->getSize() will cause a crash
dimension2d<u32> size = img->getOriginalSize();
driver->draw2DImage(img, rect<s32>(pos.X, pos.Y, pos.X + width * mainGame->xScale, pos.Y + height * mainGame->yScale), rect<s32>(0, 0, size.Width, size.Height));
recti dragloc = recti(pos.X, pos.Y, pos.X + CARD_THUMB_WIDTH * mainGame->xScale, pos.Y + CARD_THUMB_HEIGHT * mainGame->yScale);
recti limitloc = recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale);
recti otloc = recti(pos.X + 7 * mainGame->xScale, pos.Y + 50 * mainGame->yScale, pos.X + 37 * mainGame->xScale, pos.Y + 65 * mainGame->yScale);
if(drag) {}
driver->draw2DImage(img, dragloc, rect<s32>(0, 0, size.Width, size.Height));
if(lflist->count(lcode)) {
switch((*lflist)[lcode]) {
switch((*lflist).at(lcode)) {
case 0:
driver->draw2DImage(imageManager.tLim, recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale), recti(0, 0, 64, 64), 0, 0, true);
break;
case 1:
driver->draw2DImage(imageManager.tLim, recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale), recti(64, 0, 128, 64), 0, 0, true);
driver->draw2DImage(imageManager.tLim, limitloc, recti(0, 0, 64, 64), 0, 0, true);
break;
case 2:
driver->draw2DImage(imageManager.tLim, recti(pos.X, pos.Y, pos.X + 20 * mainGame->xScale, pos.Y + 20 * mainGame->yScale), recti(0, 64, 64, 128), 0, 0, true);
break;
}
}
if(cbLimit->getSelected() >= 4 && (cp->second.ot & gameConf.defaultOT)) {
switch(cp->second.ot) {
case 1:
driver->draw2DImage(imageManager.tOT, recti(pos.X + 0 * mainGame->xScale, pos.Y + 45 * mainGame->yScale, pos.X + 40 * mainGame->xScale, pos.Y + 65 * mainGame->yScale), recti(0, 128, 128, 192), 0, 0, true);
driver->draw2DImage(imageManager.tLim, limitloc, recti(64, 0, 128, 64), 0, 0, true);
break;
case 2:
driver->draw2DImage(imageManager.tOT, recti(pos.X + 0 * mainGame->xScale, pos.Y + 45 * mainGame->yScale, pos.X + 40 * mainGame->xScale, pos.Y + 65 * mainGame->yScale), recti(0, 192, 128, 256), 0, 0, true);
driver->draw2DImage(imageManager.tLim, limitloc, recti(0, 64, 64, 128), 0, 0, true);
break;
}
} else if(cbLimit->getSelected() >= 4 || !(cp->second.ot & gameConf.defaultOT)) {
switch(cp->second.ot) {
case 1:
driver->draw2DImage(imageManager.tOT, recti(pos.X + 0 * mainGame->xScale, pos.Y + 45 * mainGame->yScale, pos.X + 40 * mainGame->xScale, pos.Y + 65 * mainGame->yScale), recti(0, 0, 128, 64), 0, 0, true);
break;
case 2:
driver->draw2DImage(imageManager.tOT, recti(pos.X + 0 * mainGame->xScale, pos.Y + 45 * mainGame->yScale, pos.X + 40 * mainGame->xScale, pos.Y + 65 * mainGame->yScale), recti(0, 64, 128, 128), 0, 0, true);
break;
}
bool showAvail = false;
bool showNotAvail = false;
int filter_lm = cbLimit->getSelected();
bool avail = !((filter_lm == 4 && !(cp->second.ot & AVAIL_OCG)
|| (filter_lm == 5 && !(cp->second.ot & AVAIL_TCG))
|| (filter_lm == 6 && !(cp->second.ot & AVAIL_SC))
|| (filter_lm == 7 && !(cp->second.ot & AVAIL_CUSTOM))
|| (filter_lm == 8 && (cp->second.ot & AVAIL_OCGTCG) != AVAIL_OCGTCG)));
if(filter_lm >= 4) {
showAvail = avail;
showNotAvail = !avail;
} else if(!(cp->second.ot & gameConf.defaultOT)) {
showNotAvail = true;
}
if(showAvail) {
if((cp->second.ot & AVAIL_OCG) && !(cp->second.ot & AVAIL_TCG))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 128, 128, 192), 0, 0, true);
else if((cp->second.ot & AVAIL_TCG) && !(cp->second.ot & AVAIL_OCG))
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 192, 128, 256), 0, 0, true);
} else if(showNotAvail) {
if(cp->second.ot & AVAIL_OCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 0, 128, 64), 0, 0, true);
else if(cp->second.ot & AVAIL_TCG)
driver->draw2DImage(imageManager.tOT, otloc, recti(0, 64, 128, 128), 0, 0, true);
else if(!avail)
driver->draw2DImage(imageManager.tLim, otloc, recti(0, 0, 64, 64), 0, 0, true);
}
}
void Game::DrawDeckBd() {
......@@ -1370,32 +1379,30 @@ void Game::DrawDeckBd() {
if(ptr->second.attack < 0)
myswprintf(textBuffer, L"?/-");
else myswprintf(textBuffer, L"%d/-", ptr->second.attack);
}//*
}
if(ptr->second.type & TYPE_PENDULUM) {
wchar_t scaleBuffer[16];
myswprintf(scaleBuffer, L" %d/%d", ptr->second.lscale, ptr->second.rscale);
mywcscat(textBuffer, scaleBuffer);
}
if((ptr->second.ot & 0x3) == 1)
mywcscat(textBuffer, L" [OCG]");
else if((ptr->second.ot & 0x3) == 2)
mywcscat(textBuffer, L" [TCG]");
else if((ptr->second.ot & 0x7) == 4)
mywcscat(textBuffer, L" [Custom]");
DrawShadowText(textFont, textBuffer, recti(850 * mainGame->xScale, (208 + i * 66) * mainGame->yScale, 1000 * mainGame->xScale, (229 + i * 66) * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), 0xffffffff, 0xff000000, false, false);
wcscat(textBuffer, scaleBuffer);
}
if((ptr->second.ot & AVAIL_OCGTCG) == AVAIL_OCG)
wcscat(textBuffer, L" [OCG]");
else if((ptr->second.ot & AVAIL_OCGTCG) == AVAIL_TCG)
wcscat(textBuffer, L" [TCG]");
else if((ptr->second.ot & AVAIL_CUSTOM) == AVAIL_CUSTOM)
wcscat(textBuffer, L" [Custom]");
} else {
myswprintf(textBuffer, L"%ls", dataManager.GetName(ptr->first));
DrawShadowText(textFont, textBuffer, recti(850 * mainGame->xScale, (164 + i * 66) * mainGame->yScale, 1000 * mainGame->xScale, (185 + i * 66) * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), 0xffffffff, 0xff000000, false, false);
const wchar_t* ptype = dataManager.FormatType(ptr->second.type);
DrawShadowText(textFont, ptype, recti(850 * mainGame->xScale, (186 + i * 66) * mainGame->yScale, 1000 * mainGame->xScale, (207 + i * 66) * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), 0xffffffff, 0xff000000, false, false);
textBuffer[0] = 0;
if((ptr->second.ot & 0x3) == 1)
mywcscat(textBuffer, L"[OCG]");
else if((ptr->second.ot & 0x3) == 2)
mywcscat(textBuffer, L"[TCG]");
else if((ptr->second.ot & 0x7) == 4)
mywcscat(textBuffer, L"[Custom]");
DrawShadowText(textFont, textBuffer, recti(850 * mainGame->xScale, (208 + i * 66) * mainGame->yScale, 1000 * mainGame->xScale, (229 + i * 66) * mainGame->yScale), recti(0, 1 * mainGame->yScale, 2 * mainGame->xScale, 0), 0xffffffff, 0xff000000, false, false);
if((ptr->second.ot & AVAIL_OCGTCG) == AVAIL_OCG)
wcscat(textBuffer, L"[OCG]");
else if((ptr->second.ot & AVAIL_OCGTCG) == AVAIL_TCG)
wcscat(textBuffer, L"[TCG]");
else if((ptr->second.ot & AVAIL_CUSTOM) == AVAIL_CUSTOM)
wcscat(textBuffer, L"[Custom]");
}
}
#endif
......
......@@ -125,7 +125,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
if(bot_mode) {
BufferIO::CopyWStr(L"Bot Game", cscg.name, 20);
BufferIO::CopyWStr(L"", cscg.pass, 20);
cscg.info.rule = 2;
cscg.info.rule = 5;
cscg.info.mode = 0;
cscg.info.start_hand = 5;
cscg.info.start_lp = 8000;
......@@ -145,7 +145,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
cscg.info.start_lp = _wtoi(mainGame->ebStartLP->getText());
cscg.info.draw_count = _wtoi(mainGame->ebDrawCount->getText());
cscg.info.time_limit = _wtoi(mainGame->ebTimeLimit->getText());
cscg.info.lflist = mainGame->cbLFlist->getItemData(mainGame->cbLFlist->getSelected());
cscg.info.lflist = mainGame->cbHostLFlist->getItemData(mainGame->cbHostLFlist->getSelected());
cscg.info.duel_rule = mainGame->cbDuelRule->getSelected() + 1;
cscg.info.no_check_deck = mainGame->chkNoCheckDeck->isChecked();
cscg.info.no_shuffle_deck = mainGame->chkNoShuffleDeck->isChecked();
......@@ -306,6 +306,10 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
myswprintf(msgbuf, dataManager.GetSysString(1419), code);
break;
}
case DECKERROR_NOTAVAIL: {
myswprintf(msgbuf, dataManager.GetSysString(1432), dataManager.GetName(code));
break;
}
default: {
myswprintf(msgbuf, dataManager.GetSysString(1406));
break;
......@@ -424,7 +428,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
wchar_t msgbuf[256];
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist));
str.append(msgbuf);
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1240 + pkt->info.rule));
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1481 + pkt->info.rule));
str.append(msgbuf);
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1227), dataManager.GetSysString(1244 + pkt->info.mode));
str.append(msgbuf);
......@@ -473,12 +477,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.time_left[0] = 0;
mainGame->dInfo.time_left[1] = 0;
mainGame->RefreshTimeDisplay();
mainGame->deckBuilder.filterList = 0;
for(auto lit = deckManager._lfList.begin(); lit != deckManager._lfList.end(); ++lit)
if(lit->hash == pkt->info.lflist)
mainGame->deckBuilder.filterList = lit->content;
if(mainGame->deckBuilder.filterList == 0)
mainGame->deckBuilder.filterList = deckManager._lfList[0].content;
mainGame->deckBuilder.filterList = deckManager.GetLFListContent(pkt->info.lflist);
if(mainGame->deckBuilder.filterList == nullptr)
mainGame->deckBuilder.filterList = &deckManager._lfList[0].content;
mainGame->stHostPrepDuelist[0]->setText(L"");
mainGame->stHostPrepDuelist[1]->setText(L"");
mainGame->stHostPrepDuelist[2]->setText(L"");
......@@ -4132,7 +4133,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
hoststr.append(L"[");
hoststr.append(deckManager.GetLFListName(pHP->host.lflist));
hoststr.append(L"][");
hoststr.append(dataManager.GetSysString(pHP->host.rule + 1240));
hoststr.append(dataManager.GetSysString(pHP->host.rule + 1481));
hoststr.append(L"][");
hoststr.append(dataManager.GetSysString(pHP->host.mode + 1244));
hoststr.append(L"][");
......
......@@ -2006,6 +2006,15 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case CHECKBOX_LFLIST: {
mainGame->gameConf.use_lflist = mainGame->chkLFlist->isChecked() ? 1 : 0;
mainGame->cbLFlist->setEnabled(mainGame->gameConf.use_lflist);
mainGame->cbLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbLFlist->getItemCount() - 1);
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbHostLFlist->getItemCount() - 1);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->cbLFlist->getSelected()].content;
return true;
break;
}
case CHECKBOX_DRAW_FIELD_SPELL: {
mainGame->gameConf.draw_field_spell = mainGame->chkDrawFieldSpell->isChecked() ? 1 : 0;
return true;
......@@ -2029,6 +2038,18 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_LFLIST: {
mainGame->gameConf.default_lflist = mainGame->cbLFlist->getSelected();
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.default_lflist);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->gameConf.default_lflist].content;
return true;
break;
}
}
break;
}
case irr::gui::EGET_LISTBOX_CHANGED: {
switch(id) {
case LISTBOX_LOG: {
......
This diff is collapsed.
......@@ -45,6 +45,8 @@ struct Config {
int chkWaitChain;
int chkIgnore1;
int chkIgnore2;
int use_lflist;
int default_lflist;
int default_rule;
int hide_setname;
int hide_hint_button;
......@@ -165,7 +167,7 @@ public:
void HideElement(irr::gui::IGUIElement* element, bool set_action = false);
void PopupElement(irr::gui::IGUIElement* element, int hideframe = 0);
void WaitFrameSignal(int frame);
void DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist);
void DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawDeckBd();
void LoadConfig();
void SaveConfig();
......@@ -318,6 +320,8 @@ public:
irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUICheckBox* chkMultiKeywords;
irr::gui::IGUICheckBox* chkPreferExpansionScript;
irr::gui::IGUICheckBox* chkLFlist;
irr::gui::IGUIComboBox* cbLFlist;
//sound
irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic;
......@@ -354,7 +358,7 @@ public:
//create host
irr::gui::IGUIWindow* wCreateHost;
irr::gui::IGUIImage* bgCreateHost;
irr::gui::IGUIComboBox* cbLFlist;
irr::gui::IGUIComboBox* cbHostLFlist;
irr::gui::IGUIComboBox* cbMatchMode;
irr::gui::IGUIComboBox* cbRule;
irr::gui::IGUIEditBox* ebTimeLimit;
......@@ -698,7 +702,8 @@ private:
#define CARD_IMG_WIDTH 177
#define CARD_IMG_HEIGHT 254
// no need thumb
#define CARD_THUMB_WIDTH 44
#define CARD_THUMB_HEIGHT 64
#define UEVENT_EXIT 0x1
#define UEVENT_TOWINDOW 0x2
......@@ -901,11 +906,18 @@ private:
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DRAW_SINGLE_CHAIN 374
#define CHECKBOX_LFLIST 375
#define BUTTON_BIG_CARD_CLOSE 380
#define BUTTON_BIG_CARD_ZOOM_IN 381
#define BUTTON_BIG_CARD_ZOOM_OUT 382
#define BUTTON_BIG_CARD_ORIG_SIZE 383
#define AVAIL_OCG 0x1
#define AVAIL_TCG 0x2
#define AVAIL_CUSTOM 0x4
#define AVAIL_SC 0x8
#define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG)
#define DEFAULT_DUEL_RULE 5
#define CARD_ARTWORK_VERSIONS_OFFSET 10
......
......@@ -233,8 +233,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
duel_mode = new TagDuel();
duel_mode->etimer = event_new(net_evbase, 0, EV_TIMEOUT | EV_PERSIST, TagDuel::TagTimer, duel_mode);
}
if(pkt->info.rule > 3)
pkt->info.rule = 0;
if(pkt->info.rule > 5)
pkt->info.rule = 5;
if(pkt->info.mode > 2)
pkt->info.mode = 0;
unsigned int hash = 1;
......
......@@ -217,6 +217,7 @@ public:
#define DECKERROR_MAINCOUNT 0x6
#define DECKERROR_EXTRACOUNT 0x7
#define DECKERROR_SIDECOUNT 0x8
#define DECKERROR_NOTAVAIL 0x9
#define MODE_SINGLE 0x0
#define MODE_MATCH 0x1
......
......@@ -251,9 +251,7 @@ void SingleDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
if(deck_error[dp->type]) {
deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type];
} else {
bool allow_ocg = host_info.rule == 0 || host_info.rule == 2;
bool allow_tcg = host_info.rule == 1 || host_info.rule == 2;
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg);
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule);
}
}
if(deckerror) {
......
......@@ -226,9 +226,7 @@ void TagDuel::PlayerReady(DuelPlayer* dp, bool is_ready) {
if(deck_error[dp->type]) {
deckerror = (DECKERROR_UNKNOWNCARD << 28) + deck_error[dp->type];
} else {
bool allow_ocg = host_info.rule == 0 || host_info.rule == 2;
bool allow_tcg = host_info.rule == 1 || host_info.rule == 2;
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, allow_ocg, allow_tcg);
deckerror = deckManager.CheckDeck(pdeck[dp->type], host_info.lflist, host_info.rule);
}
}
if(deckerror) {
......
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