Custom colors!!!
This commit is contained in:
parent
0b45138372
commit
d15919e221
@ -21,13 +21,13 @@ void CBaseButton::SetCallback(ButtonCallbackFn_t callback) {
|
||||
}
|
||||
|
||||
void CBaseButton::Draw(int x, int y) {
|
||||
int textcolor = colors::pink;
|
||||
int textcolor = GUIColor();
|
||||
auto size = GetSize();
|
||||
if (IsPressed()) {
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::DrawRect(x, y, size.first, size.second, GUIColor());
|
||||
textcolor = colors::white;
|
||||
}
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), textcolor, 1, GetText());
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,6 @@ void CBaseWindow::Draw(int x, int y) {
|
||||
auto abs = AbsolutePosition();
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(abs.first, abs.second, size.first, size.second, colors::Transparent(colors::black, 0.9));
|
||||
draw::OutlineRect(abs.first, abs.second, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(abs.first, abs.second, size.first, size.second, GUIColor());
|
||||
CBaseContainer::Draw(x, y);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ CTitleBar::CTitleBar(IWidget* parent, std::string title) : CBaseWidget("titlebar
|
||||
|
||||
void CTitleBar::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::DrawRect(x, y, size.first, size.second, GUIColor());
|
||||
int l, h;
|
||||
draw::GetStringLength(fonts::MENU, (char*)m_strTitle.c_str(), l, h);
|
||||
draw::String(fonts::MENU, x + (size.first - l) / 2, y + TITLEBAR_PADDING_H, colors::white, 1, m_strTitle.c_str());
|
||||
|
@ -22,9 +22,9 @@ void CCheckbox::SetWidth(int width) {
|
||||
|
||||
void CCheckbox::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
if (Value()) {
|
||||
draw::DrawRect(x + 3, y + 3, size.first - 6, size.second - 6, colors::pink);
|
||||
draw::DrawRect(x + 3, y + 3, size.first - 6, size.second - 6, GUIColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ void CDropdown::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
auto ssize = draw::GetStringLength(fonts::MENU, ValueName(Value() - Props()->GetInt("offset")));
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(colors::black));
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, colors::pink, 1, ValueName(Value() - Props()->GetInt("offset")));
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, GUIColor(), 1, ValueName(Value() - Props()->GetInt("offset")));
|
||||
auto asize = draw::GetStringLength(fonts::MENU, ">");
|
||||
draw::String(fonts::MENU, x + size.first - asize.first - 2, y + (size.second - asize.second) / 2, colors::pink, 1, ">");
|
||||
draw::String(fonts::MENU, x + size.first - asize.first - 2, y + (size.second - asize.second) / 2, GUIColor(), 1, ">");
|
||||
}
|
||||
|
||||
void CDropdown::OnFocusLose() {
|
||||
|
@ -22,7 +22,7 @@ CDropdownEntry::CDropdownEntry(std::string name, CDropdownList* parent, std::str
|
||||
void CDropdownEntry::Draw(int x, int y) {
|
||||
auto ssize = draw::GetStringLength(fonts::MENU, GetText());
|
||||
auto size = GetSize();
|
||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, colors::pink, 1, GetText());
|
||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, GUIColor(), 1, GetText());
|
||||
}
|
||||
|
||||
CDropdownEntry::~CDropdownEntry() {
|
||||
|
@ -41,7 +41,7 @@ void CDropdownList::SetValue(int value) {
|
||||
void CDropdownList::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(colors::black, 0.85));
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
CBaseContainer::Draw(x, y);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ void CKeyInput::Draw(int x, int y) {
|
||||
int color = colors::white;
|
||||
if (Props()->GetBool("capturing")) {
|
||||
key = "< PRESS >";
|
||||
color = colors::pink;
|
||||
color = GUIColor();
|
||||
} else {
|
||||
if (!Value()) {
|
||||
if (!IsFocused()) {
|
||||
|
@ -37,6 +37,6 @@ void CMenuContainer::MoveChildren() {
|
||||
void CMenuContainer::Draw(int x, int y) {
|
||||
CBaseContainer::Draw(x, y);
|
||||
for (int i = 0; i < Props()->GetInt("columns"); i++) {
|
||||
draw::DrawLine(x + (350 + 3) * (i + 1), y, 0, GetMaxSize().second, colors::pink);
|
||||
draw::DrawLine(x + (350 + 3) * (i + 1), y, 0, GetMaxSize().second, GUIColor());
|
||||
}
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ void CMenuListEntry::Draw(int x, int y) {
|
||||
auto texts = draw::GetStringLength(fonts::MENU_BIG, GetText());
|
||||
auto size = GetSize();
|
||||
if (IsSelected()) {
|
||||
draw::DrawLine(x, y, size.first, 0, colors::pink);
|
||||
draw::DrawLine(x, y + size.second, size.first, 0, colors::pink);
|
||||
draw::DrawLine(x, y, 0, size.second, colors::pink);
|
||||
draw::DrawLine(x, y, size.first, 0, GUIColor());
|
||||
draw::DrawLine(x, y + size.second, size.first, 0, GUIColor());
|
||||
draw::DrawLine(x, y, 0, size.second, GUIColor());
|
||||
} else {
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
}
|
||||
if (IsHovered()) {
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(colors::pink, 0.25));
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(GUIColor(), 0.25));
|
||||
}
|
||||
draw::String(fonts::MENU_BIG, x + (size.first - texts.first) / 2, y + (size.second - texts.second) / 2, IsSelected() ? colors::white : colors::pink, 1, GetText());
|
||||
draw::String(fonts::MENU_BIG, x + (size.first - texts.first) / 2, y + (size.second - texts.second) / 2, IsSelected() ? colors::white : GUIColor(), 1, GetText());
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void CSlider::Update() {
|
||||
void CSlider::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 200));
|
||||
draw::DrawRect(x, y, m_nSliderPos, size.second, colors::pink);
|
||||
draw::DrawRect(x, y, m_nSliderPos, size.second, GUIColor());
|
||||
char* s = strfmt("%.2f", Value());
|
||||
std::string str(s);
|
||||
delete [] s;
|
||||
|
@ -39,9 +39,9 @@ void CTextInput::Draw(int x, int y) {
|
||||
auto wsize = draw::GetStringLength(fonts::MENU, "W");
|
||||
auto size = GetSize();
|
||||
int color = colors::Create(0, 0, 0, 80);
|
||||
if (IsFocused()) color = colors::Transparent(colors::pink, 0.25);
|
||||
if (IsFocused()) color = colors::Transparent(GUIColor(), 0.25);
|
||||
draw::DrawRect(x, y, size.first, size.second, color);
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
int ml = 0;
|
||||
int md = 0;
|
||||
auto dotssize = draw::GetStringLength(fonts::MENU, "..."); // TODO static?
|
||||
|
@ -22,6 +22,6 @@ CTooltip::CTooltip(IWidget* parent) : CTextLabel("tooltip", parent) {
|
||||
void CTooltip::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 230));
|
||||
draw::OutlineRect(x, y, size.first, size.second, colors::pink);
|
||||
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), colors::pink, 1, GetText());
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), GUIColor(), 1, GetText());
|
||||
}
|
||||
|
@ -40,6 +40,15 @@ CatGUI::~CatGUI() {
|
||||
delete m_pRootWindow;
|
||||
}
|
||||
|
||||
CatVar gui_color_r(CV_INT, "gui_color_r", "255", "Main GUI color (red)", "Defines red component of main gui color", 0, 255);
|
||||
CatVar gui_color_g(CV_INT, "gui_color_g", "105", "Main GUI color (green)", "Defines green component of main gui color", 0, 255);
|
||||
CatVar gui_color_b(CV_INT, "gui_color_b", "180", "Main GUI color (blue)", "Defines blue component of main gui color", 0, 255);
|
||||
|
||||
static CatVar gui_rainbow(CV_SWITCH, "gui_rainbow", "0", "Rainbow GUI");
|
||||
int GUIColor() {
|
||||
return gui_rainbow ? colors::RainbowCurrent() : colors::Create((int)gui_color_r, (int)gui_color_g, (int)gui_color_b, 255);
|
||||
}
|
||||
|
||||
void CatGUI::Setup() {
|
||||
m_pRootWindow = new RootWindow();
|
||||
m_pRootWindow->Setup();
|
||||
@ -111,7 +120,7 @@ void CatGUI::Update() {
|
||||
if (!m_bShowTooltip && m_pTooltip->IsVisible()) m_pTooltip->Hide();
|
||||
root->Draw(0, 0);
|
||||
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colors::Transparent(colors::white));
|
||||
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, gui_nullcore ? menu::ncc::color_fg : colors::pink);
|
||||
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, GUIColor());
|
||||
if (gui_draw_bounds) {
|
||||
root->DrawBounds(0, 0);
|
||||
}
|
||||
|
@ -26,6 +26,11 @@ class CatVar;
|
||||
class CTooltip;
|
||||
class RootWindow;
|
||||
|
||||
extern CatVar gui_color_r;
|
||||
extern CatVar gui_color_g;
|
||||
extern CatVar gui_color_b;
|
||||
int GUIColor();
|
||||
|
||||
extern CatVar gui_visible;
|
||||
extern CatVar gui_draw_bounds;
|
||||
extern CatVar gui_nullcore;
|
||||
|
@ -19,7 +19,7 @@ Item::Item() : CBaseWidget("ncc_menu_item", nullptr) {
|
||||
|
||||
void Item::Draw(int x, int y) {
|
||||
const auto& size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, IsHovered() ? color_bg_hover : color_bg);
|
||||
draw::DrawRect(x, y, size.first, size.second, IsHovered() ? colors::Transparent(GUIColor(), 0.32f) : colors::Transparent(GUIColor(), 0.07f));
|
||||
}
|
||||
|
||||
}}
|
||||
|
@ -20,9 +20,9 @@ List::List(std::string title) : open_sublist(nullptr), title(title), items {} {
|
||||
|
||||
void List::Draw(int x, int y) {
|
||||
const auto& size = GetSize();
|
||||
draw::OutlineRect(x, y, size.first, size.second, color_fg);
|
||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor());
|
||||
for (int i = 1; i < ChildCount(); i++) {
|
||||
draw::DrawLine(x + 1, y + 15 * i, 220, 0, color_fg);
|
||||
draw::DrawLine(x + 1, y + 15 * i, 220, 0, GUIColor());
|
||||
}
|
||||
CBaseContainer::Draw(x, y);
|
||||
}
|
||||
|
@ -17,10 +17,6 @@ namespace menu { namespace ncc {
|
||||
extern unsigned long font_title; // Verdana Bold 10px
|
||||
extern unsigned long font_item; // Verdana 10px
|
||||
|
||||
const int color_fg = colors::Create(255, 105, 180, 255);//colors::Create(15, 150, 150, 255);
|
||||
const int color_bg = colors::Transparent(color_fg, 0.07f);
|
||||
const int color_bg_hover = colors::Transparent(color_fg, 0.32f);
|
||||
|
||||
void Init();
|
||||
List& MainList();
|
||||
|
||||
|
Reference in New Issue
Block a user