]> git.tdb.fi Git - poefilter.git/commitdiff
Add support for the new visual indicators
authorMikko Rasa <tdb@tdb.fi>
Wed, 29 Aug 2018 18:09:49 +0000 (21:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 29 Aug 2018 18:09:49 +0000 (21:09 +0300)
source/appearance.cpp
source/appearance.h
source/effectcolor.cpp [new file with mode: 0644]
source/effectcolor.h [new file with mode: 0644]
source/iconshape.cpp [new file with mode: 0644]
source/iconshape.h [new file with mode: 0644]

index ffe47ff576600b13e4e11d1828bf91fb3c1e67cf..0500aa57fc826687a0ab9d3b8e47680a7348ee9a 100644 (file)
@@ -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);
index 9e6fb6996921ff62043be9bf437fc7b9836dfe43..538ea2e96709c7037d12dafc055f69da1bf121a2 100644 (file)
@@ -4,6 +4,8 @@
 #include <list>
 #include <msp/datafile/objectloader.h>
 #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 (file)
index 0000000..bd31fbf
--- /dev/null
@@ -0,0 +1,38 @@
+#include <msp/strings/format.h>
+#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<int>(color))); return;
+       }
+}
diff --git a/source/effectcolor.h b/source/effectcolor.h
new file mode 100644 (file)
index 0000000..e51f1be
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef EFFECTCOLOR_H_
+#define EFFECTCOLOR_H_
+
+#include <msp/strings/lexicalcast.h>
+
+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 (file)
index 0000000..e16eeea
--- /dev/null
@@ -0,0 +1,38 @@
+#include <msp/strings/format.h>
+#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<int>(shape))); return;
+       }
+}
diff --git a/source/iconshape.h b/source/iconshape.h
new file mode 100644 (file)
index 0000000..b395ba5
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef ICONSHAPE_H_
+#define ICONSHAPE_H_
+
+#include <msp/strings/lexicalcast.h>
+
+enum IconShape
+{
+       CIRCLE,
+       TRIANGLE,
+       SQUARE,
+       DIAMOND,
+       HEXAGON,
+       STAR
+};
+
+void operator>>(const Msp::LexicalConverter &, IconShape &);
+void operator<<(Msp::LexicalConverter &, IconShape);
+
+#endif