mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
Buttons for client options
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "color.h"
|
||||
|
||||
// NOTE: AABBGGRR order
|
||||
const Color Color::alpha = 0x00000000;
|
||||
const Color Color::alpha = 0x00000000U;
|
||||
const Color Color::white = 0xffffffff;
|
||||
const Color Color::black = 0xff000000;
|
||||
const Color Color::red = 0xff0000ff;
|
||||
@@ -42,3 +42,9 @@ const Color Color::gray = 0xffa0a0a0;
|
||||
const Color Color::darkGray = 0xff808080;
|
||||
const Color Color::lightGray = 0xffc0c0c0;
|
||||
const Color Color::orange = 0xffff8c00;
|
||||
|
||||
Color::Color(const std::string& coltext)
|
||||
{
|
||||
std::stringstream ss(coltext);
|
||||
ss >> *this;
|
||||
}
|
||||
|
@@ -37,6 +37,7 @@ public:
|
||||
Color(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { }
|
||||
Color(int r, int g, int b, int a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { }
|
||||
Color(float r, float g, float b, float a = 1.0f) : m_r(r), m_g(g), m_b(b), m_a(a) { }
|
||||
Color(const std::string& coltext);
|
||||
|
||||
uint8 a() const { return m_a*255.0f; }
|
||||
uint8 b() const { return m_b*255.0f; }
|
||||
@@ -76,6 +77,14 @@ public:
|
||||
bool operator==(const Color& other) const { return other.rgba() == rgba(); }
|
||||
bool operator!=(const Color& other) const { return other.rgba() != rgba(); }
|
||||
|
||||
static uint8 to8bit(const Color& color) {
|
||||
uint8 c = 0;
|
||||
c += (color.r() / 51) * 36;
|
||||
c += (color.g() / 51) * 6;
|
||||
c += (color.b() / 51);
|
||||
return c;
|
||||
};
|
||||
|
||||
static Color from8bit(int color) {
|
||||
if(color >= 216 || color <= 0)
|
||||
return Color(0, 0, 0);
|
||||
|
Reference in New Issue
Block a user