]> git.tdb.fi Git - poefilter.git/blobdiff - source/category.cpp
Correctly merge icon and light beam appearances
[poefilter.git] / source / category.cpp
index 8b0d442ea8d572c016fe4f01fb9c891109b23ffd..e697aeefac209d456bb2ac30d6f8bb1474d75e55 100644 (file)
@@ -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<FilterStatement> &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<Category>(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<BaseTypeCondition>);
+       add("category", &Loader::category);
        add("class", &Loader::condition<ClassCondition>);
        add_range<DropLevelCondition>("drop_level");
        add_range<HeightCondition>("height");
        add_range<ItemLevelCondition>("item_level");
        add("linked_colors", &Loader::linked_colors);
        add_range<LinkedSocketsCondition>("linked_sockets");
+       add_range<MapTierCondition>("map_tier");
        add_range<SocketsCondition>("sockets");
        add("or", &Loader::or_);
-       add("order", &Category::order);
        add_range<QualityCondition>("quality");
        add_range<RarityCondition>("rarity");
        add_range<WidthCondition>("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<typename T>