]> git.tdb.fi Git - poefilter.git/blobdiff - source/category.cpp
Associate categories and appearances at filter level
[poefilter.git] / source / category.cpp
index 8b0d442ea8d572c016fe4f01fb9c891109b23ffd..4ceed1883df32f7e971bd8dcb594795f64fa831c 100644 (file)
@@ -8,12 +8,14 @@
 using namespace std;
 using namespace Msp;
 
-Category::Category():
+Category::Category(const string &n):
+       name(n),
        condition(0),
        order(0)
 { }
 
 Category::Category(const Category &other):
+       name(other.name),
        condition(other.condition ? other.condition->clone() : 0),
        order(other.order),
        appearance(other.appearance)
@@ -22,6 +24,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,24 +38,8 @@ 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);
@@ -63,10 +50,9 @@ 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("class", &Loader::condition<ClassCondition>);
        add_range<DropLevelCondition>("drop_level");
@@ -116,11 +102,6 @@ void Category::Loader::and_()
        add_condition(cond.release());
 }
 
-void Category::Loader::appearance(const std::string &name)
-{
-       obj.appearance = poe.get_theme().get_appearance(name);
-}
-
 template<typename T>
 void Category::Loader::condition(typename T::Type value)
 {