X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcategory.cpp;h=4ceed1883df32f7e971bd8dcb594795f64fa831c;hb=0388bdcffe5c2c3e720afa9aa911268eac9c32de;hp=2ea4818b9ae460871b520fc84504fcd4f450b8e4;hpb=fc27eb63c05d915d606e17992ecd5b7f68478101;p=poefilter.git diff --git a/source/category.cpp b/source/category.cpp index 2ea4818..4ceed18 100644 --- a/source/category.cpp +++ b/source/category.cpp @@ -1,38 +1,33 @@ #include "category.h" #include "choicecondition.h" #include "filter.h" +#include "poefilter.h" #include "rangecondition.h" #include "theme.h" using namespace std; using namespace Msp; -Category::Category(): +Category::Category(const string &n): + name(n), condition(0), - font_size(1.0f), - order(0), - sound_type(0), - sound_volume(100) + order(0) { } Category::Category(const Category &other): + name(other.name), condition(other.condition ? other.condition->clone() : 0), - font_size(other.font_size), - border_color(other.border_color), order(other.order), - sound_type(other.sound_type), - sound_volume(other.sound_volume) + appearance(other.appearance) { } Category &Category::operator=(const Category &other) { delete condition; + name = other.name; condition = (other.condition ? other.condition->clone() : 0); - font_size = other.font_size; - border_color = other.border_color; order = other.order; - sound_type = other.sound_type; - sound_volume = other.sound_volume; + appearance = other.appearance; return *this; } @@ -41,34 +36,26 @@ Category::~Category() delete condition; } -void Category::create_statements(list &st, const Theme &theme) const +void Category::create_statements(list &st) const { - st.clear(); - st.push_back(FilterStatement()); - st.back().add_line(format("SetFontSize %d", static_cast(font_size*theme.get_base_font_size()+0.5))); - if(!border_color.empty()) - { - const Color &color = theme.get_color(border_color); - st.back().add_line(format("SetBorderColor %d %d %d", color.r, color.g, color.b)); - } - if(sound_type) - st.back().add_line(format("PlayAlertSound %d %d", sound_type, sound_volume)); + if(st.empty()) + st.push_back(FilterStatement()); + if(condition) condition->add_lines(st); } -Category::Loader::Loader(Category &c, CompoundCondition *n): +Category::Loader::Loader(Category &c, const PoeFilter &p, CompoundCondition *n): DataFile::ObjectLoader(c), - compound(n) + poe(p), + compound(n), + app_loader(c.appearance) { - add("alert_sound", &Category::sound_type, &Category::sound_volume); add("and", &Loader::and_); add("base_type", &Loader::condition); - add("border_color", &Category::border_color); add("class", &Loader::condition); add_range("drop_level"); - add("font_size", &Category::font_size); add_range("height"); add_range("item_level"); add("linked_colors", &Loader::linked_colors); @@ -79,6 +66,8 @@ Category::Loader::Loader(Category &c, CompoundCondition *n): add_range("quality"); add_range("rarity"); add_range("width"); + + add_auxiliary_loader(app_loader); } template @@ -108,7 +97,7 @@ void Category::Loader::add_condition(Condition *cond) void Category::Loader::and_() { RefPtr cond = new AndCondition; - Loader sub_ldr(obj, cond.get()); + Loader sub_ldr(obj, poe, cond.get()); load_sub_with(sub_ldr); add_condition(cond.release()); } @@ -145,7 +134,7 @@ void Category::Loader::linked_colors(const LinkedColorsCondition::Colors &colors void Category::Loader::or_() { RefPtr cond = new OrCondition; - Loader sub_ldr(obj, cond.get()); + Loader sub_ldr(obj, poe, cond.get()); load_sub_with(sub_ldr); add_condition(cond.release()); }