X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcategory.cpp;h=e697aeefac209d456bb2ac30d6f8bb1474d75e55;hb=HEAD;hp=8b0d442ea8d572c016fe4f01fb9c891109b23ffd;hpb=74086c211f082f6f47c3d038dd308a257a81e006;p=poefilter.git diff --git a/source/category.cpp b/source/category.cpp index 8b0d442..e697aee 100644 --- a/source/category.cpp +++ b/source/category.cpp @@ -13,7 +13,14 @@ Category::Category(): order(0) { } +Category::Category(const string &n, unsigned o): + name(n), + condition(0), + order(o) +{ } + Category::Category(const Category &other): + name(other.name), condition(other.condition ? other.condition->clone() : 0), order(other.order), appearance(other.appearance) @@ -22,6 +29,7 @@ Category::Category(const Category &other): Category &Category::operator=(const Category &other) { delete condition; + name = other.name; condition = (other.condition ? other.condition->clone() : 0); order = other.order; appearance = other.appearance; @@ -35,27 +43,19 @@ Category::~Category() void Category::create_statements(list &st) const { - st.clear(); - st.push_back(FilterStatement()); - st.back().add_line(format("SetFontSize %d", appearance.get_font_size())); - - const Color &bg_color = appearance.get_background_color(); - if(bg_color.defined) - st.back().add_line(format("SetBackgroundColor %d %d %d", bg_color.r, bg_color.g, bg_color.b)); - - const Color &brd_color = appearance.get_border_color(); - if(brd_color.defined) - st.back().add_line(format("SetBorderColor %d %d %d", brd_color.r, brd_color.g, brd_color.b)); - - const Color &txt_color = appearance.get_text_color(); - if(txt_color.defined) - st.back().add_line(format("SetTextColor %d %d %d", txt_color.r, txt_color.g, txt_color.b)); - - if(appearance.get_sound_type()) - st.back().add_line(format("PlayAlertSound %d %d", appearance.get_sound_type(), appearance.get_sound_volume())); + if(st.empty()) + st.push_back(FilterStatement()); if(condition) - condition->add_lines(st); + { + Condition *flat = condition->flatten(); + if(flat) + { + flat->add_lines(st); + delete flat; + } + // TODO handle the case of the entire condition being non-viable + } } @@ -63,20 +63,20 @@ Category::Loader::Loader(Category &c, const PoeFilter &p, CompoundCondition *n): DataFile::ObjectLoader(c), poe(p), compound(n), - app_loader(c.appearance, p.get_theme()) + app_loader(c.appearance) { add("and", &Loader::and_); - add("appearance", &Loader::appearance); add("base_type", &Loader::condition); + add("category", &Loader::category); add("class", &Loader::condition); add_range("drop_level"); add_range("height"); add_range("item_level"); add("linked_colors", &Loader::linked_colors); add_range("linked_sockets"); + add_range("map_tier"); add_range("sockets"); add("or", &Loader::or_); - add("order", &Category::order); add_range("quality"); add_range("rarity"); add_range("width"); @@ -116,9 +116,10 @@ void Category::Loader::and_() add_condition(cond.release()); } -void Category::Loader::appearance(const std::string &name) +void Category::Loader::category(const string &name) { - obj.appearance = poe.get_theme().get_appearance(name); + const Category &categ = poe.get_category(name); + add_condition(categ.condition->clone()); } template