Jeck - Cleaned up filters a tiny bit (they no longer use idiotically duplicated vector<pair<string,string>>'s), added colorless mana filter ability, "exclusively X color" filter.
This commit is contained in:
@@ -428,6 +428,9 @@ public:
|
|||||||
void ButtonPressed(int controllerId, int controlId);
|
void ButtonPressed(int controllerId, int controlId);
|
||||||
void buildList();
|
void buildList();
|
||||||
protected:
|
protected:
|
||||||
|
void clearArgs();
|
||||||
|
void addArg(string display, string code);
|
||||||
|
vector< pair<string,string> > tempArgs; //TODO FIXME this is inefficient
|
||||||
bool bFinished;
|
bool bFinished;
|
||||||
WSrcCards* source;
|
WSrcCards* source;
|
||||||
SimpleMenu* subMenu;
|
SimpleMenu* subMenu;
|
||||||
@@ -464,10 +467,9 @@ public:
|
|||||||
END_FILTERS
|
END_FILTERS
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
void addArg(string display, string code);
|
string mCode;
|
||||||
int filterType;
|
int filterType;
|
||||||
int filterVal;
|
int filterVal;
|
||||||
vector< pair<string,string> > args;
|
|
||||||
int mState;
|
int mState;
|
||||||
bool mNew;
|
bool mNew;
|
||||||
WGuiFilters * mParent;
|
WGuiFilters * mParent;
|
||||||
|
|||||||
@@ -1435,9 +1435,8 @@ if(!list) return false;
|
|||||||
for(it=wgl->items.begin();it!=wgl->items.end();it++){
|
for(it=wgl->items.begin();it!=wgl->items.end();it++){
|
||||||
WGuiFilterItem * wgfi = dynamic_cast<WGuiFilterItem*>(*it);
|
WGuiFilterItem * wgfi = dynamic_cast<WGuiFilterItem*>(*it);
|
||||||
if(!wgfi || wgfi->mState != WGuiFilterItem::STATE_FINISHED) continue;
|
if(!wgfi || wgfi->mState != WGuiFilterItem::STATE_FINISHED) continue;
|
||||||
if(wgfi->filterVal < 0 || (int)wgfi->args.size() < wgfi->filterVal) continue;
|
if(!wgfi->mCode.size()) continue;
|
||||||
string s = wgfi->args[wgfi->filterVal].second;
|
if(wgfi->mCode == code)
|
||||||
if(s == code)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1459,6 +1458,7 @@ bool WGuiFilters::isAvailable(int type){
|
|||||||
case WGuiFilterItem::FILTER_PRODUCE:
|
case WGuiFilterItem::FILTER_PRODUCE:
|
||||||
if(wgfi->filterType == type)
|
if(wgfi->filterType == type)
|
||||||
ma++;
|
ma++;
|
||||||
|
break;
|
||||||
case WGuiFilterItem::FILTER_COLOR:
|
case WGuiFilterItem::FILTER_COLOR:
|
||||||
if(wgfi->filterType == type)
|
if(wgfi->filterType == type)
|
||||||
colors++;
|
colors++;
|
||||||
@@ -1476,6 +1476,16 @@ bool WGuiFilters::isAvailable(int type){
|
|||||||
}
|
}
|
||||||
return false; //For some reason, we don't have any rows?
|
return false; //For some reason, we don't have any rows?
|
||||||
}
|
}
|
||||||
|
void WGuiFilters::clearArgs(){
|
||||||
|
tempArgs.clear();
|
||||||
|
}
|
||||||
|
void WGuiFilters::addArg(string display, string code){
|
||||||
|
if(!subMenu || !isAvailableCode(code))
|
||||||
|
return;
|
||||||
|
subMenu->Add((int)tempArgs.size(),display.c_str());
|
||||||
|
tempArgs.push_back(pair<string,string>(display,code));
|
||||||
|
}
|
||||||
|
|
||||||
//WGuiFilterItem
|
//WGuiFilterItem
|
||||||
WGuiFilterItem::WGuiFilterItem(WGuiFilters * parent): WGuiItem("Cards..."){
|
WGuiFilterItem::WGuiFilterItem(WGuiFilters * parent): WGuiItem("Cards..."){
|
||||||
filterType = -1; filterVal = -1; mState = 0;
|
filterType = -1; filterVal = -1; mState = 0;
|
||||||
@@ -1495,7 +1505,7 @@ void WGuiFilterItem::updateValue(){
|
|||||||
case STATE_UNSET:
|
case STATE_UNSET:
|
||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
mState = STATE_CHOOSE_TYPE;
|
mState = STATE_CHOOSE_TYPE;
|
||||||
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter By...");
|
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter By...",10);
|
||||||
if(mParent->isAvailable(FILTER_SET)){
|
if(mParent->isAvailable(FILTER_SET)){
|
||||||
mParent->subMenu->Add(FILTER_SET,"Set");
|
mParent->subMenu->Add(FILTER_SET,"Set");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
@@ -1504,10 +1514,6 @@ void WGuiFilterItem::updateValue(){
|
|||||||
mParent->subMenu->Add(FILTER_COLOR,"Color");
|
mParent->subMenu->Add(FILTER_COLOR,"Color");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
}
|
}
|
||||||
if(mParent->isAvailable(FILTER_PRODUCE)){
|
|
||||||
mParent->subMenu->Add(FILTER_PRODUCE,"Mana Ability");
|
|
||||||
delMenu = false;
|
|
||||||
}
|
|
||||||
if(mParent->isAvailable(FILTER_TYPE)){
|
if(mParent->isAvailable(FILTER_TYPE)){
|
||||||
mParent->subMenu->Add(FILTER_TYPE,"Type");
|
mParent->subMenu->Add(FILTER_TYPE,"Type");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
@@ -1516,14 +1522,18 @@ void WGuiFilterItem::updateValue(){
|
|||||||
mParent->subMenu->Add(FILTER_RARITY,"Rarity");
|
mParent->subMenu->Add(FILTER_RARITY,"Rarity");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
}
|
}
|
||||||
if(mParent->isAvailable(FILTER_BASIC)){
|
|
||||||
mParent->subMenu->Add(FILTER_BASIC,"Ability");
|
|
||||||
delMenu = false;
|
|
||||||
}
|
|
||||||
if(mParent->isAvailable(FILTER_CMC)){
|
if(mParent->isAvailable(FILTER_CMC)){
|
||||||
mParent->subMenu->Add(FILTER_CMC,"Mana Cost");
|
mParent->subMenu->Add(FILTER_CMC,"Mana Cost");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
}
|
}
|
||||||
|
if(mParent->isAvailable(FILTER_BASIC)){
|
||||||
|
mParent->subMenu->Add(FILTER_BASIC,"Basic Ability");
|
||||||
|
delMenu = false;
|
||||||
|
}
|
||||||
|
if(mParent->isAvailable(FILTER_PRODUCE)){
|
||||||
|
mParent->subMenu->Add(FILTER_PRODUCE,"Mana Ability");
|
||||||
|
delMenu = false;
|
||||||
|
}
|
||||||
if(mParent->isAvailable(FILTER_POWER)){
|
if(mParent->isAvailable(FILTER_POWER)){
|
||||||
mParent->subMenu->Add(FILTER_POWER,"Power");
|
mParent->subMenu->Add(FILTER_POWER,"Power");
|
||||||
delMenu = false;
|
delMenu = false;
|
||||||
@@ -1546,60 +1556,66 @@ void WGuiFilterItem::updateValue(){
|
|||||||
break;
|
break;
|
||||||
case STATE_CHOOSE_TYPE:
|
case STATE_CHOOSE_TYPE:
|
||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
args.clear();
|
mParent->clearArgs();
|
||||||
mState = STATE_CHOOSE_VAL;
|
mState = STATE_CHOOSE_VAL;
|
||||||
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter:");
|
mParent->subMenu = NEW SimpleMenu(-1234,this,Constants::MENU_FONT,20,20,"Filter:");
|
||||||
if(filterType == FILTER_TYPE){
|
if(filterType == FILTER_TYPE){
|
||||||
addArg("Artifact","t:Artifact;");
|
mParent->addArg("Artifact","t:Artifact;");
|
||||||
addArg("Artifact Creature","t:Artifact;&t:Creature;");
|
mParent->addArg("Artifact Creature","t:Artifact;&t:Creature;");
|
||||||
addArg("Creature","t:Creature;");
|
mParent->addArg("Creature","t:Creature;");
|
||||||
addArg("Enchantment","t:Enchantment;");
|
mParent->addArg("Enchantment","t:Enchantment;");
|
||||||
addArg("Instant","t:Instant;");
|
mParent->addArg("Instant","t:Instant;");
|
||||||
addArg("Land","t:Land;");
|
mParent->addArg("Land","t:Land;");
|
||||||
addArg("Legendary","t:Legendary;");
|
mParent->addArg("Legendary","t:Legendary;");
|
||||||
addArg("Sorcery","t:Sorcery;");
|
mParent->addArg("Sorcery","t:Sorcery;");
|
||||||
}else if(filterType == FILTER_RARITY){
|
}else if(filterType == FILTER_RARITY){
|
||||||
addArg("Mythic","r:m;");
|
mParent->addArg("Mythic","r:m;");
|
||||||
addArg("Rare","r:r;");
|
mParent->addArg("Rare","r:r;");
|
||||||
addArg("Uncommon","r:u;");
|
mParent->addArg("Uncommon","r:u;");
|
||||||
addArg("Common","r:c;");
|
mParent->addArg("Common","r:c;");
|
||||||
}else if(filterType == FILTER_CMC){
|
}else if(filterType == FILTER_CMC){
|
||||||
for(int i=0;i<20;i++){
|
for(int i=0;i<20;i++){
|
||||||
sprintf(buf_code,"cmc:%i;",i);
|
sprintf(buf_code,"cmc:%i;",i);
|
||||||
sprintf(buf_name,"%i Mana",i);
|
sprintf(buf_name,"%i Mana",i);
|
||||||
addArg(buf_name,buf_code);
|
mParent->addArg(buf_name,buf_code);
|
||||||
}
|
}
|
||||||
}else if(filterType == FILTER_POWER){
|
}else if(filterType == FILTER_POWER){
|
||||||
for(int i=0;i<14;i++){
|
for(int i=0;i<14;i++){
|
||||||
sprintf(buf_code,"pow:%i;",i);
|
sprintf(buf_code,"pow:%i;",i);
|
||||||
sprintf(buf_name,"%i power",i);
|
sprintf(buf_name,"%i power",i);
|
||||||
addArg(buf_name,buf_code);
|
mParent->addArg(buf_name,buf_code);
|
||||||
}
|
}
|
||||||
}else if(filterType == FILTER_TOUGH){
|
}else if(filterType == FILTER_TOUGH){
|
||||||
for(int i=0;i<14;i++){
|
for(int i=0;i<14;i++){
|
||||||
sprintf(buf_code,"tgh:%i;",i);
|
sprintf(buf_code,"tgh:%i;",i);
|
||||||
sprintf(buf_name,"%i toughness",i);
|
sprintf(buf_name,"%i toughness",i);
|
||||||
addArg(buf_name,buf_code);
|
mParent->addArg(buf_name,buf_code);
|
||||||
}
|
}
|
||||||
}else if(filterType == FILTER_COLOR){
|
}else if(filterType == FILTER_COLOR){
|
||||||
addArg("White","c:w;");
|
mParent->addArg("White","c:w;");
|
||||||
addArg("Blue","c:u;");
|
mParent->addArg("Blue","c:u;");
|
||||||
addArg("Red","c:r;");
|
mParent->addArg("Black","c:b;");
|
||||||
addArg("Green","c:g;");
|
mParent->addArg("Red","c:r;");
|
||||||
addArg("Black","c:b;");
|
mParent->addArg("Green","c:g;");
|
||||||
|
mParent->addArg("Exclusively White","xc:w;");
|
||||||
|
mParent->addArg("Exclusively Blue","xc:u;");
|
||||||
|
mParent->addArg("Exclusively Black","xc:b;");
|
||||||
|
mParent->addArg("Exclusively Red","xc:r;");
|
||||||
|
mParent->addArg("Exclusively Green","xc:g;");
|
||||||
}else if(filterType == FILTER_PRODUCE){
|
}else if(filterType == FILTER_PRODUCE){
|
||||||
addArg("White mana abiltity","ma:w;");
|
mParent->addArg("White mana abiltity","ma:w;");
|
||||||
addArg("Blue mana abiltity","ma:u;");
|
mParent->addArg("Blue mana abiltity","ma:u;");
|
||||||
addArg("Red mana abiltity","ma:r;");
|
mParent->addArg("Black mana abiltity","ma:b;");
|
||||||
addArg("Green mana abiltity","ma:g;");
|
mParent->addArg("Red mana abiltity","ma:r;");
|
||||||
addArg("Black mana abiltity","ma:b;");
|
mParent->addArg("Green mana abiltity","ma:g;");
|
||||||
|
mParent->addArg("Colorless mana abiltity","ma:x;");
|
||||||
}else if(filterType == FILTER_BASIC){
|
}else if(filterType == FILTER_BASIC){
|
||||||
char buf[512];
|
char buf[512];
|
||||||
for(int i=0;i<Constants::NB_BASIC_ABILITIES;i++){
|
for(int i=0;i<Constants::NB_BASIC_ABILITIES;i++){
|
||||||
string s = Constants::MTGBasicAbilities[i];
|
string s = Constants::MTGBasicAbilities[i];
|
||||||
sprintf(buf,"a:%s;",s.c_str());
|
sprintf(buf,"a:%s;",s.c_str());
|
||||||
s[0] = toupper(s[0]);
|
s[0] = toupper(s[0]);
|
||||||
addArg(s,buf);
|
mParent->addArg(s,buf);
|
||||||
}
|
}
|
||||||
}else if(filterType == FILTER_SET){
|
}else if(filterType == FILTER_SET){
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@@ -1607,16 +1623,16 @@ void WGuiFilterItem::updateValue(){
|
|||||||
if(options[Options::optionSet(i)].number == 0)
|
if(options[Options::optionSet(i)].number == 0)
|
||||||
continue;
|
continue;
|
||||||
sprintf(buf,"s:%s;",setlist[i].c_str());
|
sprintf(buf,"s:%s;",setlist[i].c_str());
|
||||||
addArg((setlist.getInfo(i))->getName(),buf);
|
mParent->addArg((setlist.getInfo(i))->getName(),buf);
|
||||||
}
|
}
|
||||||
}else if(filterType == FILTER_ALPHA){
|
}else if(filterType == FILTER_ALPHA){
|
||||||
char buf[24], pretty[16];
|
char buf[24], pretty[16];
|
||||||
for(char c='a';c<='z';c++){
|
for(char c='a';c<='z';c++){
|
||||||
sprintf(buf,"alpha:%c;",c);
|
sprintf(buf,"alpha:%c;",c);
|
||||||
sprintf(pretty,"Letter %c",toupper(c));
|
sprintf(pretty,"Letter %c",toupper(c));
|
||||||
addArg(pretty,buf);
|
mParent->addArg(pretty,buf);
|
||||||
}
|
}
|
||||||
addArg("Digit","alpha:#;");
|
mParent->addArg("Digit","alpha:#;");
|
||||||
}
|
}
|
||||||
mParent->subMenu->Add(-1,"Cancel");
|
mParent->subMenu->Add(-1,"Cancel");
|
||||||
break;
|
break;
|
||||||
@@ -1625,19 +1641,14 @@ void WGuiFilterItem::updateValue(){
|
|||||||
if(mNew && mParent)
|
if(mNew && mParent)
|
||||||
mParent->addColumn();
|
mParent->addColumn();
|
||||||
mNew = false;
|
mNew = false;
|
||||||
if(filterVal > -1 && filterVal < (int) args.size())
|
if(filterVal > -1 && filterVal < (int) mParent->tempArgs.size()){
|
||||||
displayValue = args[filterVal].first;
|
displayValue = mParent->tempArgs[filterVal].first;
|
||||||
|
mCode = mParent->tempArgs[filterVal].second;
|
||||||
|
}
|
||||||
SAFE_DELETE(mParent->subMenu);
|
SAFE_DELETE(mParent->subMenu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WGuiFilterItem::addArg(string display, string code){
|
|
||||||
if(!mParent || !mParent->subMenu || !mParent->isAvailableCode(code))
|
|
||||||
return;
|
|
||||||
mParent->subMenu->Add((int)args.size(),display.c_str());
|
|
||||||
args.push_back(pair<string,string>(display,code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WGuiFilterItem::ButtonPressed(int controllerId, int controlId){
|
void WGuiFilterItem::ButtonPressed(int controllerId, int controlId){
|
||||||
if(!mParent) return;
|
if(!mParent) return;
|
||||||
|
|
||||||
@@ -1678,7 +1689,7 @@ bool WGuiFilterItem::isModal(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string WGuiFilterItem::getCode(){
|
string WGuiFilterItem::getCode(){
|
||||||
if(mState != STATE_FINISHED || filterVal < 0 || filterVal > (int) args.size())
|
if(mState != STATE_FINISHED || !mCode.size())
|
||||||
return "";
|
return "";
|
||||||
return args[filterVal].second;
|
return mCode;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user