Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json vehicle parts #2641

Merged
merged 8 commits into from Aug 26, 2013
44 changes: 44 additions & 0 deletions color.cpp
@@ -1,4 +1,5 @@
#include "color.h"
#include "output.h"

#define HILIGHT COLOR_BLUE
void init_colors()
Expand Down Expand Up @@ -408,3 +409,46 @@ nc_color int_to_color(int key)
}
return c_black;
}

/**
* Given the name of a color, returns the nc_color constant that matches. If
* no match is found, c_white is returned.
* @param new_color The color to get, as a std::string.
* @return The nc_color constant that matches the input.
*/
nc_color color_from_string(std::string new_color){
if("red"==new_color){
return c_red;
} else if("blue"==new_color){
return c_blue;
} else if("green"==new_color){
return c_green;
} else if("light_cyan"==new_color){
return c_ltcyan;
} else if("brown"==new_color){
return c_brown;
} else if("light_red"==new_color){
return c_ltred;
} else if("white"==new_color){
return c_white;
} else if("light_blue"==new_color){
return c_ltblue;
} else if("yellow"==new_color){
return c_yellow;
} else if("magenta"==new_color){
return c_magenta;
} else if("cyan"==new_color){
return c_cyan;
} else if("light_gray"==new_color){
return c_ltgray;
} else if("dark_gray"==new_color){
return c_dkgray;
} else if("light_green"==new_color){
return c_ltgreen;
} else if("pink"==new_color){
return c_pink;
} else {
debugmsg("Received invalid color property %s. Color is required.", new_color.c_str());
return c_white;
}
}
2 changes: 2 additions & 0 deletions color.h
Expand Up @@ -5,6 +5,7 @@
#define _COLOR_LIST_

#include "cursesdef.h"
#include <string>

void init_colors();

Expand Down Expand Up @@ -169,6 +170,7 @@ c_unset = COLOR_PAIR(31),

int color_to_int(nc_color col);
nc_color int_to_color(int key);
nc_color color_from_string(std::string color);

void setattr(nc_color &col, col_attribute attr);

Expand Down