From: Mikko Rasa Date: Wed, 29 Aug 2018 18:09:49 +0000 (+0300) Subject: Add support for the new visual indicators X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b4df72b647f47c25a0ccada832eda9bc0dfb5504;p=poefilter.git Add support for the new visual indicators --- diff --git a/source/appearance.cpp b/source/appearance.cpp index ffe47ff..0500aa5 100644 --- a/source/appearance.cpp +++ b/source/appearance.cpp @@ -9,7 +9,13 @@ using namespace Msp; Appearance::Appearance(): font_size(0), sound_type(0), - sound_volume(100) + sound_volume(100), + show_icon(false), + icon_shape(CIRCLE), + icon_color(WHITE), + icon_size(1), + show_beam(false), + beam_color(WHITE) { } void Appearance::merge_from(const Appearance &other) @@ -43,8 +49,14 @@ void Appearance::add_lines(FilterStatement &st) const if(text_color.defined) st.add_line(format("SetTextColor %d %d %d %d", text_color.r, text_color.g, text_color.b, text_color.a)); + if(show_icon) + st.add_line(format("MinimapIcon %d %s %s", icon_size, icon_color, icon_shape)); + if(sound_type) st.add_line(format("PlayAlertSound %d %d", sound_type, sound_volume)); + + if(show_beam) + st.add_line(format("PlayEffect %s", beam_color)); } @@ -61,6 +73,9 @@ Appearance::Loader::Loader(Appearance &a, const Theme *t): add("border_color", &Loader::border_color_named); add("font_size", &Loader::font_size); add("inherit", &Loader::inherit); + add("light_beam", &Loader::light_beam); + add("minimap_icon", &Loader::minimap_icon); + add("minimap_icon", &Loader::minimap_icon_size); add("text_color", &Loader::text_color); add("text_color", &Loader::text_color_alpha); add("text_color", &Loader::text_color_named); @@ -113,6 +128,25 @@ void Appearance::Loader::inherit(const string &name) obj = theme->get_appearance(name); } +void Appearance::Loader::light_beam(EffectColor color) +{ + obj.show_beam = true; + obj.beam_color = color; +} + +void Appearance::Loader::minimap_icon(EffectColor color, IconShape shape) +{ + minimap_icon_size(color, shape, 1); +} + +void Appearance::Loader::minimap_icon_size(EffectColor color, IconShape shape, unsigned size) +{ + obj.show_icon = true; + obj.icon_shape = shape; + obj.icon_color = color; + obj.icon_size = size; +} + void Appearance::Loader::text_color(unsigned r, unsigned g, unsigned b) { obj.text_color = Color(r, g, b); diff --git a/source/appearance.h b/source/appearance.h index 9e6fb69..538ea2e 100644 --- a/source/appearance.h +++ b/source/appearance.h @@ -4,6 +4,8 @@ #include #include #include "color.h" +#include "effectcolor.h" +#include "iconshape.h" class FilterStatement; class Theme; @@ -27,6 +29,9 @@ public: void border_color_named(const std::string &); void font_size(float); void inherit(const std::string &); + void light_beam(EffectColor); + void minimap_icon(EffectColor, IconShape); + void minimap_icon_size(EffectColor, IconShape, unsigned); void text_color(unsigned, unsigned, unsigned); void text_color_alpha(unsigned, unsigned, unsigned, unsigned); void text_color_named(const std::string &); @@ -39,6 +44,12 @@ private: Color text_color; unsigned sound_type; unsigned sound_volume; + bool show_icon; + IconShape icon_shape; + EffectColor icon_color; + unsigned icon_size; + bool show_beam; + EffectColor beam_color; public: Appearance(); diff --git a/source/effectcolor.cpp b/source/effectcolor.cpp new file mode 100644 index 0000000..bd31fbf --- /dev/null +++ b/source/effectcolor.cpp @@ -0,0 +1,38 @@ +#include +#include "effectcolor.h" + +using namespace std; +using namespace Msp; + +void operator>>(const LexicalConverter &conv, EffectColor &color) +{ + const string &str = conv.get(); + if(str=="White") + color = WHITE; + else if(str=="Red") + color = RED; + else if(str=="Green") + color = GREEN; + else if(str=="Blue") + color = BLUE; + else if(str=="Brown") + color = BROWN; + else if(str=="Yellow") + color = YELLOW; + else + throw lexical_error(format("Conversion of %s to EffectColor", str)); +} + +void operator<<(LexicalConverter &conv, EffectColor color) +{ + switch(color) + { + case WHITE: conv.result("White"); return; + case RED: conv.result("Red"); return; + case GREEN: conv.result("Green"); return; + case BLUE: conv.result("Blue"); return; + case BROWN: conv.result("Brown"); return; + case YELLOW: conv.result("Yellow"); return; + default: conv.result(format("EffectColor(%d)", static_cast(color))); return; + } +} diff --git a/source/effectcolor.h b/source/effectcolor.h new file mode 100644 index 0000000..e51f1be --- /dev/null +++ b/source/effectcolor.h @@ -0,0 +1,19 @@ +#ifndef EFFECTCOLOR_H_ +#define EFFECTCOLOR_H_ + +#include + +enum EffectColor +{ + WHITE, + RED, + GREEN, + BLUE, + BROWN, + YELLOW +}; + +void operator>>(const Msp::LexicalConverter &, EffectColor &); +void operator<<(Msp::LexicalConverter &, EffectColor); + +#endif diff --git a/source/iconshape.cpp b/source/iconshape.cpp new file mode 100644 index 0000000..e16eeea --- /dev/null +++ b/source/iconshape.cpp @@ -0,0 +1,38 @@ +#include +#include "iconshape.h" + +using namespace std; +using namespace Msp; + +void operator>>(const LexicalConverter &conv, IconShape &shape) +{ + const string &str = conv.get(); + if(str=="Circle") + shape = CIRCLE; + else if(str=="Triangle") + shape = TRIANGLE; + else if(str=="Square") + shape = SQUARE; + else if(str=="Diamond") + shape = DIAMOND; + else if(str=="Hexagon") + shape = HEXAGON; + else if(str=="Star") + shape = STAR; + else + throw lexical_error(format("Conversion of %s to IconShape", str)); +} + +void operator<<(LexicalConverter &conv, IconShape shape) +{ + switch(shape) + { + case CIRCLE: conv.result("Circle"); return; + case TRIANGLE: conv.result("Triangle"); return; + case SQUARE: conv.result("Square"); return; + case DIAMOND: conv.result("Diamond"); return; + case HEXAGON: conv.result("Hexagon"); return; + case STAR: conv.result("Star"); return; + default: conv.result(format("IconShape(%d)", static_cast(shape))); return; + } +} diff --git a/source/iconshape.h b/source/iconshape.h new file mode 100644 index 0000000..b395ba5 --- /dev/null +++ b/source/iconshape.h @@ -0,0 +1,19 @@ +#ifndef ICONSHAPE_H_ +#define ICONSHAPE_H_ + +#include + +enum IconShape +{ + CIRCLE, + TRIANGLE, + SQUARE, + DIAMOND, + HEXAGON, + STAR +}; + +void operator>>(const Msp::LexicalConverter &, IconShape &); +void operator<<(Msp::LexicalConverter &, IconShape); + +#endif