Commit 024b36f0 authored by VanillaSalt's avatar VanillaSalt

add scale filter

parent 6b143051
......@@ -9,6 +9,36 @@
namespace ygo {
static int parse_filter(const wchar_t* pstr, unsigned int* type) {
if(*pstr == L'=') {
*type = 1;
return BufferIO::GetVal(pstr + 1);
} else if(*pstr >= L'0' && *pstr <= L'9') {
*type = 1;
return BufferIO::GetVal(pstr);
} else if(*pstr == L'>') {
if(*(pstr + 1) == L'=') {
*type = 2;
return BufferIO::GetVal(pstr + 2);
} else {
*type = 3;
return BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'<') {
if(*(pstr + 1) == L'=') {
*type = 4;
return BufferIO::GetVal(pstr + 2);
} else {
*type = 5;
return BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'?') {
*type = 6;
return 0;
}
*type = 0;
return 0;
}
bool DeckBuilder::OnEvent(const irr::SEvent& event) {
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
......@@ -95,91 +125,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
filter_attrib = mainGame->cbAttribute->getItemData(mainGame->cbAttribute->getSelected());
filter_race = mainGame->cbRace->getItemData(mainGame->cbRace->getSelected());
const wchar_t* pstr = mainGame->ebAttack->getText();
if(*pstr == 0) filter_atktype = 0;
else {
if(*pstr == L'=') {
filter_atktype = 1;
filter_atk = BufferIO::GetVal(pstr + 1);
} else if(*pstr >= L'0' && *pstr <= L'9') {
filter_atktype = 1;
filter_atk = BufferIO::GetVal(pstr);
} else if(*pstr == L'>') {
if(*(pstr + 1) == L'=') {
filter_atktype = 2;
filter_atk = BufferIO::GetVal(pstr + 2);
} else {
filter_atktype = 3;
filter_atk = BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'<') {
if(*(pstr + 1) == L'=') {
filter_atktype = 4;
filter_atk = BufferIO::GetVal(pstr + 2);
} else {
filter_atktype = 5;
filter_atk = BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'?') {
filter_atktype = 6;
} else filter_atktype = 0;
}
pstr = mainGame->ebDefence->getText();
if(*pstr == 0) filter_deftype = 0;
else {
if(*pstr == L'=') {
filter_deftype = 1;
filter_def = BufferIO::GetVal(pstr + 1);
} else if(*pstr >= L'0' && *pstr <= L'9') {
filter_deftype = 1;
filter_def = BufferIO::GetVal(pstr);
} else if(*pstr == L'>') {
if(*(pstr + 1) == L'=') {
filter_deftype = 2;
filter_def = BufferIO::GetVal(pstr + 2);
} else {
filter_deftype = 3;
filter_def = BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'<') {
if(*(pstr + 1) == L'=') {
filter_deftype = 4;
filter_def = BufferIO::GetVal(pstr + 2);
} else {
filter_deftype = 5;
filter_def = BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'?') {
filter_deftype = 6;
} else filter_deftype = 0;
}
pstr = mainGame->ebStar->getText();
if(*pstr == 0) filter_lvtype = 0;
else {
if(*pstr == L'=') {
filter_lvtype = 1;
filter_lv = BufferIO::GetVal(pstr + 1);
} else if(*pstr >= L'0' && *pstr <= L'9') {
filter_lvtype = 1;
filter_lv = BufferIO::GetVal(pstr);
} else if(*pstr == L'>') {
if(*(pstr + 1) == L'=') {
filter_lvtype = 2;
filter_lv = BufferIO::GetVal(pstr + 2);
} else {
filter_lvtype = 3;
filter_lv = BufferIO::GetVal(pstr + 1);
}
} else if(*pstr == L'<') {
if(*(pstr + 1) == L'=') {
filter_lvtype = 4;
filter_lv = BufferIO::GetVal(pstr + 2);
} else {
filter_lvtype = 5;
filter_lv = BufferIO::GetVal(pstr + 1);
}
} else filter_lvtype = 0;
}
filter_atk = parse_filter(mainGame->ebAttack->getText(), &filter_atktype);
filter_def = parse_filter(mainGame->ebDefence->getText(), &filter_deftype);
filter_lv = parse_filter(mainGame->ebStar->getText(), &filter_lvtype);
filter_scl = parse_filter(mainGame->ebScale->getText(), &filter_scltype);
FilterCards();
break;
}
......@@ -257,6 +206,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefence->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
break;
}
case 1: {
......@@ -267,6 +217,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebAttack->setEnabled(true);
mainGame->ebDefence->setEnabled(true);
mainGame->ebStar->setEnabled(true);
mainGame->ebScale->setEnabled(true);
mainGame->cbCardType2->clear();
mainGame->cbCardType2->addItem(dataManager.GetSysString(1080), 0);
mainGame->cbCardType2->addItem(dataManager.GetSysString(1054), TYPE_MONSTER + TYPE_NORMAL);
......@@ -293,6 +244,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefence->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
mainGame->cbCardType2->clear();
mainGame->cbCardType2->addItem(dataManager.GetSysString(1080), 0);
mainGame->cbCardType2->addItem(dataManager.GetSysString(1054), TYPE_SPELL);
......@@ -310,6 +262,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefence->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
mainGame->cbCardType2->clear();
mainGame->cbCardType2->addItem(dataManager.GetSysString(1080), 0);
mainGame->cbCardType2->addItem(dataManager.GetSysString(1054), TYPE_TRAP);
......@@ -691,7 +644,13 @@ void DeckBuilder::FilterCards() {
if(filter_lvtype) {
if((filter_lvtype == 1 && data.level != filter_lv) || (filter_lvtype == 2 && data.level < filter_lv)
|| (filter_lvtype == 3 && data.level <= filter_lv) || (filter_lvtype == 4 && data.level > filter_lv)
|| (filter_lvtype == 5 && data.level >= filter_lv))
|| (filter_lvtype == 5 && data.level >= filter_lv) || filter_lvtype == 6)
continue;
}
if(filter_scltype) {
if((filter_scltype == 1 && data.lscale != filter_scl) || (filter_scltype == 2 && data.lscale < filter_scl)
|| (filter_scltype == 3 && data.lscale <= filter_scl) || (filter_scltype == 4 && (data.lscale > filter_scl || data.lscale == 0))
|| (filter_scltype == 5 && (data.lscale >= filter_scl || data.lscale == 0)) || filter_scltype == 6)
continue;
}
break;
......@@ -764,6 +723,7 @@ void DeckBuilder::FilterCards() {
mainGame->ebAttack->setText(L"");
mainGame->ebDefence->setText(L"");
mainGame->ebStar->setText(L"");
mainGame->ebScale->setText(L"");
filter_effect = 0;
for(int i = 0; i < 32; ++i)
mainGame->chkCategory[i]->setChecked(false);
......
......@@ -24,6 +24,8 @@ public:
int filter_def;
unsigned int filter_lvtype;
unsigned int filter_lv;
unsigned int filter_scltype;
unsigned int filter_scl;
int filter_lm;
int hovered_code;
int hovered_pos;
......
......@@ -434,8 +434,10 @@ bool Game::Initialize() {
ebDefence = env->addEditBox(L"", rect<s32>(260, 49, 340, 69), true, wFilter);
ebDefence->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
env->addStaticText(dataManager.GetSysString(1324), rect<s32>(10, 74, 80, 94), false, false, wFilter);
ebStar = env->addEditBox(L"", rect<s32>(60, 72, 140, 92), true, wFilter);
ebStar = env->addEditBox(L"", rect<s32>(60, 72, 120, 92), true, wFilter);
ebStar->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
ebScale = env->addEditBox(L"", rect<s32>(130, 72, 190, 92), true, wFilter);
ebScale->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
env->addStaticText(dataManager.GetSysString(1325), rect<s32>(205, 74, 280, 94), false, false, wFilter);
ebCardName = env->addEditBox(L"", rect<s32>(260, 72, 390, 92), true, wFilter, EDITBOX_KEYWORD);
ebCardName->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
......
......@@ -358,6 +358,7 @@ public:
irr::gui::IGUIComboBox* cbAttribute;
irr::gui::IGUIComboBox* cbLimit;
irr::gui::IGUIEditBox* ebStar;
irr::gui::IGUIEditBox* ebScale;
irr::gui::IGUIEditBox* ebAttack;
irr::gui::IGUIEditBox* ebDefence;
irr::gui::IGUIEditBox* ebCardName;
......
......@@ -229,12 +229,14 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->ebAttack->setText(L"");
mainGame->ebDefence->setText(L"");
mainGame->ebStar->setText(L"");
mainGame->ebScale->setText(L"");
mainGame->cbCardType2->setEnabled(false);
mainGame->cbAttribute->setEnabled(false);
mainGame->cbRace->setEnabled(false);
mainGame->ebAttack->setEnabled(false);
mainGame->ebDefence->setEnabled(false);
mainGame->ebStar->setEnabled(false);
mainGame->ebScale->setEnabled(false);
mainGame->deckBuilder.filter_effect = 0;
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
......
Subproject commit 982039dd54e2bc70f6cfa4c62b2db52f49df91b7
Subproject commit 5dd0f9f7c90f077d8d9c9ddeba257241db036cb9
Subproject commit 4b1cad5517e638551d40b84331e33bdaacce909d
Subproject commit 384d2fe8d99af19407ece80363b1a2fe3939b64e
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