dialogxml parseColor use a map built from Colours constants
parseColor() was doing a big if-else with string comparisons, and returning values that differed from our Colours constants. Since I couldn't find an instance of the colour attribute in our existing xml, it should be safe to do away with those conflicting values and refactor parseColor() to match the constants and use cleaner code.
This commit is contained in:
@@ -17,6 +17,27 @@
|
||||
using boost::math::constants::pi;
|
||||
using pt_idx_t = decltype(((sf::Shape*)nullptr)->getPointCount());
|
||||
|
||||
std::map<std::string,sf::Color> colour_map = {
|
||||
{"white", Colours::WHITE},
|
||||
{"black", Colours::BLACK},
|
||||
{"grey", Colours::GREY},
|
||||
{"gray", Colours::GREY},
|
||||
{"red", Colours::RED},
|
||||
{"green", Colours::GREEN},
|
||||
{"blue", Colours::BLUE},
|
||||
{"teal", Colours::TEAL},
|
||||
{"pink", Colours::PINK},
|
||||
{"yellow", Colours::YELLOW},
|
||||
{"orange", Colours::ORANGE},
|
||||
{"shadow", Colours::SHADOW},
|
||||
{"title_blue", Colours::TITLE_BLUE},
|
||||
{"navy", Colours::NAVY},
|
||||
{"dark_blue", Colours::DARK_BLUE},
|
||||
{"dark_green", Colours::DARK_GREEN},
|
||||
{"light_green", Colours::LIGHT_GREEN},
|
||||
{"dark_red", Colours::DARK_RED}
|
||||
};
|
||||
|
||||
// TODO: Put these classes in a header?
|
||||
class EllipseShape : public sf::Shape {
|
||||
float divSz;
|
||||
|
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <SFML/Graphics/Shape.hpp>
|
||||
#include "location.hpp"
|
||||
|
||||
|
Reference in New Issue
Block a user