1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
namespace palette{
//COLOR PALETTES
struct COLORS{
ALLEGRO_COLOR Black, White, LightGray, DarkGray, Pink, Red,
Maroon, Magenta, Brown, Yellow, LightGreen,
Green, DarkGreen, LightBlue, Blue, DarkBlue, Purple;
COLORS()
:Black (al_map_rgba(0,0,0,255)),
White (al_map_rgba(255,255,255,255)),
LightGray (al_map_rgba(195,195,195,255)),
DarkGray (al_map_rgba(127,127,127,255)),
Pink (al_map_rgba(255,174,201,255)),
Red (al_map_rgba(255,0,0,255)),
Maroon (al_map_rgba(136,0,21,255)),
Magenta (al_map_rgba(255,0,255,255)),
Brown (al_map_rgba(185,122,87,255)),
Yellow (al_map_rgba(255,255,0,255)),
LightGreen (al_map_rgba(128,255,128,255)),
Green (al_map_rgba(0,255,0,255)),
DarkGreen (al_map_rgba(0,128,0,255)),
LightBlue (al_map_rgba(128,128,255,255)),
Blue (al_map_rgba(0,0,255,255)),
DarkBlue (al_map_rgba(0,0,128,255)),
Purple (al_map_rgba(163,73,164,255))
{}
}Colors;
class COLOR{
private:
ALLEGRO_COLOR CLR;
public:
COLOR() :CLR(al_map_rgba(0,0,0,255)) {}
COLOR(int r, int g, int b, int a) :CLR(al_map_rgba(r,g,b,a)) {}
void Set(ALLEGRO_COLOR clr) { CLR = clr; }
void Set(int r=0,int g=0, int b=0, int a=255)
{
if (r < 0 || r > 255) r = 0;
if (g < 0 || g > 255) g = 0;
if (b < 0 || b > 255) b = 0;
if (a < 0 || a > 255) a = 255;
CLR = al_map_rgba(r,g,b,a);
}
ALLEGRO_COLOR Get() { return CLR; }
bool operator==(COLOR &Clr)
{
if (CLR.r == Clr.Get().r &&
CLR.g == Clr.Get().g &&
CLR.b == Clr.Get().b &&
CLR.a == Clr.Get().a) return true;
return false;
}
bool operator!=(COLOR &Clr)
{
if (CLR.r != Clr.Get().r ||
CLR.g != Clr.Get().g ||
CLR.b != Clr.Get().b ||
CLR.a != Clr.Get().a) return true;
return false;
}
};
//FONT PALETTE
class FONT{
private:
bool VALID;
int Size;
TEXT_ALIGN Alignment;
ALLEGRO_COLOR Clr;
string Name;
public:
FONT() :VALID(false), Size(12), Alignment(LEFT), Clr(al_map_rgb(0,0,0)), Name("arial.ttf") {}
void Initialize(string name, int size = 12, TEXT_ALIGN alignment = LEFT, ALLEGRO_COLOR clr = al_map_rgb(0,0,0))
{
VALID = false;
Size = size;
Alignment = alignment;
Clr = clr;
char * dir = _getcwd(NULL, 0);
stringstream ss;
ss << dir << "\\" << name;
string fPath = ss.str();
Name = fPath;
if (ifstream(fPath.c_str())) VALID = true;
}
string GetName() { return Name; }
ALLEGRO_COLOR GetColor() { return Clr; }
TEXT_ALIGN GetAlignment() { return Alignment; }
int GetSize() { return Size; }
bool IsValid() { return VALID; }
};
} //End of palette namespace
| |