diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 755ccf3f..1979c327 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "dialog.hpp" #include "gfx/tiling.hpp" // for bg #include "fileio/resmgr/res_dialog.hpp" @@ -45,6 +46,8 @@ cDialog* cDialog::topWindow = nullptr; void (*cDialog::redraw_everything)() = nullptr; std::mt19937 cDialog::ui_rand; +extern std::map colour_map; + extern bool check_for_interrupt(std::string); std::string cDialog::generateRandomString(){ @@ -86,39 +89,9 @@ sf::Color cControl::parseColor(string what){ } } clr.r = r, clr.g = g, clr.b = b; - }else if(what == "black") - clr.r = 0x00, clr.g = 0x00, clr.b = 0x00; - else if(what == "red") - clr.r = 0xFF, clr.g = 0x00, clr.b = 0x00; - else if(what == "lime") - clr.r = 0x00, clr.g = 0xFF, clr.b = 0x00; - else if(what == "blue") - clr.r = 0x00, clr.g = 0x00, clr.b = 0xFF; - else if(what == "yellow") - clr.r = 0xFF, clr.g = 0xFF, clr.b = 0x00; - else if(what == "aqua") - clr.r = 0x00, clr.g = 0xFF, clr.b = 0xFF; - else if(what == "fuchsia") - clr.r = 0xFF, clr.g = 0x00, clr.b = 0xFF; - else if(what == "white") - clr.r = 0xFF, clr.g = 0xFF, clr.b = 0xFF; - else if(what == "gray" || what == "grey") - clr.r = 0x80, clr.g = 0x80, clr.b = 0x80; - else if(what == "maroon") - clr.r = 0x80, clr.g = 0x00, clr.b = 0x00; - else if(what == "green") - clr.r = 0x00, clr.g = 0x80, clr.b = 0x00; - else if(what == "navy") - clr.r = 0x00, clr.g = 0x00, clr.b = 0x80; - else if(what == "olive") - clr.r = 0x80, clr.g = 0x80, clr.b = 0x00; - else if(what == "teal") - clr.r = 0x00, clr.g = 0x80, clr.b = 0x80; - else if(what == "purple") - clr.r = 0x80, clr.g = 0x00, clr.b = 0x80; - else if(what == "silver") - clr.r = 0xC0, clr.g = 0xC0, clr.b = 0xC0; - else throw -1; + }else if(colour_map.find(what) != colour_map.end()){ + return colour_map[what]; + }else throw -1; return clr; } diff --git a/src/gfx/render_shapes.cpp b/src/gfx/render_shapes.cpp index e284547b..47c41360 100644 --- a/src/gfx/render_shapes.cpp +++ b/src/gfx/render_shapes.cpp @@ -17,6 +17,27 @@ using boost::math::constants::pi; using pt_idx_t = decltype(((sf::Shape*)nullptr)->getPointCount()); +std::map 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; diff --git a/src/gfx/render_shapes.hpp b/src/gfx/render_shapes.hpp index e043574b..90e98911 100644 --- a/src/gfx/render_shapes.hpp +++ b/src/gfx/render_shapes.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include "location.hpp"