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)
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));
}
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);
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);
#include <list>
#include <msp/datafile/objectloader.h>
#include "color.h"
+#include "effectcolor.h"
+#include "iconshape.h"
class FilterStatement;
class Theme;
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 &);
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();
--- /dev/null
+#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;
+ }
+}
--- /dev/null
+#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
--- /dev/null
+#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;
+ }
+}
--- /dev/null
+#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