shoved everything into two files, also rgb works now
This commit is contained in:
parent
363634d185
commit
cb59f53b68
@ -63,6 +63,7 @@
|
|||||||
#include <visual/atlas.hpp>
|
#include <visual/atlas.hpp>
|
||||||
#include <visual/EffectChams.hpp>
|
#include <visual/EffectChams.hpp>
|
||||||
#include <visual/drawmgr.hpp>
|
#include <visual/drawmgr.hpp>
|
||||||
|
#include "menu/compatlayer.hpp"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ extern CatVar gui_visible;
|
|||||||
extern CatVar gui_draw_bounds;
|
extern CatVar gui_draw_bounds;
|
||||||
constexpr bool gui_nullcore = true;
|
constexpr bool gui_nullcore = true;
|
||||||
|
|
||||||
|
int NCGUIColor();
|
||||||
|
|
||||||
class CatGUI {
|
class CatGUI {
|
||||||
public:
|
public:
|
||||||
CatGUI();
|
CatGUI();
|
||||||
|
46
include/menu/compatlayer.hpp
Normal file
46
include/menu/compatlayer.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
namespace colorsint
|
||||||
|
{
|
||||||
|
constexpr int Create(int r, int g, int b, int a) {
|
||||||
|
unsigned char _r = (r) & 0xFF;
|
||||||
|
unsigned char _g = (g) & 0xFF;
|
||||||
|
unsigned char _b = (b) & 0xFF;
|
||||||
|
unsigned char _a = (a) & 0xFF;
|
||||||
|
return (int)(_r) | (int)(_g << 8) | (int)(_b << 16) | (int)(_a << 24);
|
||||||
|
}
|
||||||
|
constexpr int Transparent(int base, float mod = 0.5f) {
|
||||||
|
unsigned char _a = (base >> 24) & 0xFF;
|
||||||
|
unsigned char _b = (base >> 16) & 0xFF;
|
||||||
|
unsigned char _g = (base >> 8) & 0xFF;
|
||||||
|
unsigned char _r = (base) & 0xFF;
|
||||||
|
return Create(_r, _g, _b, (int)((float)(_a) * mod));
|
||||||
|
}
|
||||||
|
int FromHSL(float h, float s, float l);
|
||||||
|
int RainbowCurrent();
|
||||||
|
constexpr int pink = Create(255, 105, 180, 255);
|
||||||
|
|
||||||
|
constexpr int white = Create(255, 255, 255, 255);
|
||||||
|
constexpr int black = Create(0, 0, 0, 255);
|
||||||
|
|
||||||
|
constexpr int red = Create(237, 42, 42, 255), blu = Create(28, 108, 237, 255);
|
||||||
|
constexpr int red_b = Create(64, 32, 32, 178), blu_b = Create(32, 32, 64, 178); // Background
|
||||||
|
constexpr int red_v = Create(196, 102, 108, 255), blu_v = Create(102, 182, 196, 255); // Vaccinator
|
||||||
|
constexpr int red_u = Create(216, 34, 186, 255), blu_u = Create(167, 75, 252, 255); // Ubercharged
|
||||||
|
constexpr int yellow = Create(255, 255, 0, 255);
|
||||||
|
constexpr int orange = Create(255, 120, 0, 255);
|
||||||
|
constexpr int green = Create(0, 255, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace draw
|
||||||
|
{
|
||||||
|
void String (unsigned long font, int x, int y, int color, int shadow, const char* text);
|
||||||
|
void String (unsigned long font, int x, int y, int color, int shadow, std::string text);
|
||||||
|
void WString(unsigned long font, int x, int y, int color, int shadow, const wchar_t* text);
|
||||||
|
void FString(unsigned long font, int x, int y, int color, int shadow, const char* text, ...);
|
||||||
|
|
||||||
|
void DrawRect(int x, int y, int w, int h, int color);
|
||||||
|
void DrawLine(int x, int y, int dx, int dy, int color);
|
||||||
|
void OutlineRect(int x, int y, int w, int h, int color);
|
||||||
|
void DrawCircle(float cx, float cy, float r, int num_segments, int color);
|
||||||
|
void GetStringLength(unsigned long font, char* string, int& length, int& height);
|
||||||
|
std::pair<int, int> GetStringLength(unsigned long font, std::string string);
|
||||||
|
}
|
@ -15,7 +15,7 @@ public:
|
|||||||
Texture(unsigned char* start, unsigned w, unsigned h);
|
Texture(unsigned char* start, unsigned w, unsigned h);
|
||||||
~Texture();
|
~Texture();
|
||||||
void Load();
|
void Load();
|
||||||
void Draw(int x, int y, int w, int h, int color = colors2::Create(255, 255, 255, 255));
|
void Draw(int x, int y, int w, int h, int color = colorsint::Create(255, 255, 255, 255));
|
||||||
public:
|
public:
|
||||||
int id { 0 };
|
int id { 0 };
|
||||||
const unsigned char* const start_addr;
|
const unsigned char* const start_addr;
|
||||||
|
@ -10,37 +10,6 @@
|
|||||||
|
|
||||||
class CachedEntity;
|
class CachedEntity;
|
||||||
|
|
||||||
namespace colors2
|
|
||||||
{
|
|
||||||
constexpr int Create(int r, int g, int b, int a) {
|
|
||||||
unsigned char _r = (r) & 0xFF;
|
|
||||||
unsigned char _g = (g) & 0xFF;
|
|
||||||
unsigned char _b = (b) & 0xFF;
|
|
||||||
unsigned char _a = (a) & 0xFF;
|
|
||||||
return (int)(_r) | (int)(_g << 8) | (int)(_b << 16) | (int)(_a << 24);
|
|
||||||
}
|
|
||||||
constexpr int Transparent(int base, float mod = 0.5f) {
|
|
||||||
unsigned char _a = (base >> 24) & 0xFF;
|
|
||||||
unsigned char _b = (base >> 16) & 0xFF;
|
|
||||||
unsigned char _g = (base >> 8) & 0xFF;
|
|
||||||
unsigned char _r = (base) & 0xFF;
|
|
||||||
return Create(_r, _g, _b, (int)((float)(_a) * mod));
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr int pink = Create(255, 105, 180, 255);
|
|
||||||
|
|
||||||
constexpr int white = Create(255, 255, 255, 255);
|
|
||||||
constexpr int black = Create(0, 0, 0, 255);
|
|
||||||
|
|
||||||
constexpr int red = Create(237, 42, 42, 255), blu = Create(28, 108, 237, 255);
|
|
||||||
constexpr int red_b = Create(64, 32, 32, 178), blu_b = Create(32, 32, 64, 178); // Background
|
|
||||||
constexpr int red_v = Create(196, 102, 108, 255), blu_v = Create(102, 182, 196, 255); // Vaccinator
|
|
||||||
constexpr int red_u = Create(216, 34, 186, 255), blu_u = Create(167, 75, 252, 255); // Ubercharged
|
|
||||||
constexpr int yellow = Create(255, 255, 0, 255);
|
|
||||||
constexpr int orange = Create(255, 120, 0, 255);
|
|
||||||
constexpr int green = Create(0, 255, 0, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace colors
|
namespace colors
|
||||||
{
|
{
|
||||||
namespace chat
|
namespace chat
|
||||||
|
@ -44,10 +44,6 @@ constexpr rgba_t GUIColor()
|
|||||||
return colors::white;
|
return colors::white;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int GUIColor2() {
|
|
||||||
return colors2::white;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitStrings();
|
void InitStrings();
|
||||||
void ResetStrings();
|
void ResetStrings();
|
||||||
void AddCenterString(const std::string &string,
|
void AddCenterString(const std::string &string,
|
||||||
@ -68,18 +64,6 @@ extern float fov;
|
|||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
void String (unsigned long font, int x, int y, int color, int shadow, const char* text);
|
|
||||||
void String (unsigned long font, int x, int y, int color, int shadow, std::string text);
|
|
||||||
void WString(unsigned long font, int x, int y, int color, int shadow, const wchar_t* text);
|
|
||||||
void FString(unsigned long font, int x, int y, int color, int shadow, const char* text, ...);
|
|
||||||
|
|
||||||
void DrawRect(int x, int y, int w, int h, int color);
|
|
||||||
void DrawLine(int x, int y, int dx, int dy, int color);
|
|
||||||
void OutlineRect(int x, int y, int w, int h, int color);
|
|
||||||
void DrawCircle(float cx, float cy, float r, int num_segments, int color);
|
|
||||||
void GetStringLength(unsigned long font, char* string, int& length, int& height);
|
|
||||||
std::pair<int, int> GetStringLength(unsigned long font, std::string string);
|
|
||||||
|
|
||||||
void UpdateWTS();
|
void UpdateWTS();
|
||||||
bool WorldToScreen(const Vector &origin, Vector &screen);
|
bool WorldToScreen(const Vector &origin, Vector &screen);
|
||||||
bool EntityCenterToScreen(CachedEntity *entity, Vector &out);
|
bool EntityCenterToScreen(CachedEntity *entity, Vector &out);
|
||||||
|
@ -21,13 +21,13 @@ void CBaseButton::SetCallback(ButtonCallbackFn_t callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CBaseButton::Draw(int x, int y) {
|
void CBaseButton::Draw(int x, int y) {
|
||||||
int textcolor = GUIColor2();
|
int textcolor = NCGUIColor();
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
if (IsPressed()) {
|
if (IsPressed()) {
|
||||||
draw::DrawRect(x, y, size.first, size.second, GUIColor2());
|
draw::DrawRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
textcolor = colors2::white;
|
textcolor = colorsint::white;
|
||||||
}
|
}
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), textcolor, 1, GetText());
|
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), textcolor, 1, GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
void CBaseWidget::DrawBounds(int x, int y) {
|
void CBaseWidget::DrawBounds(int x, int y) {
|
||||||
if (m_KeyValues->IsEmpty("bounds_color")) {
|
if (m_KeyValues->IsEmpty("bounds_color")) {
|
||||||
m_KeyValues->SetInt("bounds_color", colors2::Create(rand() % 255, rand() % 255, rand() % 255, 255));
|
m_KeyValues->SetInt("bounds_color", colorsint::Create(rand() % 255, rand() % 255, rand() % 255, 255));
|
||||||
}
|
}
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(m_KeyValues->GetInt("bounds_color"), 0.25f));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(m_KeyValues->GetInt("bounds_color"), 0.25f));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, m_KeyValues->GetInt("bounds_color"));
|
draw::OutlineRect(x, y, size.first, size.second, m_KeyValues->GetInt("bounds_color"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void CBaseWindow::OnFocusLose() {
|
|||||||
void CBaseWindow::Draw(int x, int y) {
|
void CBaseWindow::Draw(int x, int y) {
|
||||||
auto abs = AbsolutePosition();
|
auto abs = AbsolutePosition();
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(abs.first, abs.second, size.first, size.second, colors2::Transparent(colors2::black, 0.9));
|
draw::DrawRect(abs.first, abs.second, size.first, size.second, colorsint::Transparent(colorsint::black, 0.9));
|
||||||
draw::OutlineRect(abs.first, abs.second, size.first, size.second, GUIColor2());
|
draw::OutlineRect(abs.first, abs.second, size.first, size.second, NCGUIColor());
|
||||||
CBaseContainer::Draw(x, y);
|
CBaseContainer::Draw(x, y);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ CTitleBar::CTitleBar(IWidget* parent, std::string title) : CBaseWidget("titlebar
|
|||||||
|
|
||||||
void CTitleBar::Draw(int x, int y) {
|
void CTitleBar::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, GUIColor2());
|
draw::DrawRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
int l, h;
|
int l, h;
|
||||||
draw::GetStringLength(fonts::MENU, (char*)m_strTitle.c_str(), 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, colors2::white, 1, m_strTitle.c_str());
|
draw::String(fonts::MENU, x + (size.first - l) / 2, y + TITLEBAR_PADDING_H, colorsint::white, 1, m_strTitle.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTitleBar::Update() {
|
void CTitleBar::Update() {
|
||||||
|
@ -22,9 +22,9 @@ void CCheckbox::SetWidth(int width) {
|
|||||||
|
|
||||||
void CCheckbox::Draw(int x, int y) {
|
void CCheckbox::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
if (Value()) {
|
if (Value()) {
|
||||||
draw::DrawRect(x + 3, y + 3, size.first - 6, size.second - 6, GUIColor2());
|
draw::DrawRect(x + 3, y + 3, size.first - 6, size.second - 6, NCGUIColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ std::string CDropdown::ValueName(int idx) {
|
|||||||
void CDropdown::Draw(int x, int y) {
|
void CDropdown::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
auto ssize = draw::GetStringLength(fonts::MENU, ValueName(Value() - Props()->GetInt("offset")));
|
auto ssize = draw::GetStringLength(fonts::MENU, ValueName(Value() - Props()->GetInt("offset")));
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(colors2::black));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(colorsint::black));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, GUIColor2(), 1, ValueName(Value() - Props()->GetInt("offset")));
|
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, NCGUIColor(), 1, ValueName(Value() - Props()->GetInt("offset")));
|
||||||
auto asize = draw::GetStringLength(fonts::MENU, ">");
|
auto asize = draw::GetStringLength(fonts::MENU, ">");
|
||||||
draw::String(fonts::MENU, x + size.first - asize.first - 2, y + (size.second - asize.second) / 2, GUIColor2(), 1, ">");
|
draw::String(fonts::MENU, x + size.first - asize.first - 2, y + (size.second - asize.second) / 2, NCGUIColor(), 1, ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDropdown::OnFocusLose() {
|
void CDropdown::OnFocusLose() {
|
||||||
|
@ -22,7 +22,7 @@ CDropdownEntry::CDropdownEntry(std::string name, CDropdownList* parent, std::str
|
|||||||
void CDropdownEntry::Draw(int x, int y) {
|
void CDropdownEntry::Draw(int x, int y) {
|
||||||
auto ssize = draw::GetStringLength(fonts::MENU, GetText());
|
auto ssize = draw::GetStringLength(fonts::MENU, GetText());
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, GUIColor2(), 1, GetText());
|
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, NCGUIColor(), 1, GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
CDropdownEntry::~CDropdownEntry() {
|
CDropdownEntry::~CDropdownEntry() {
|
||||||
|
@ -40,8 +40,8 @@ void CDropdownList::SetValue(int value) {
|
|||||||
|
|
||||||
void CDropdownList::Draw(int x, int y) {
|
void CDropdownList::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(colors2::black, 0.85));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(colorsint::black, 0.85));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
CBaseContainer::Draw(x, y);
|
CBaseContainer::Draw(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ void CKeyInput::SetValue(int value) {
|
|||||||
|
|
||||||
void CKeyInput::Draw(int x, int y) {
|
void CKeyInput::Draw(int x, int y) {
|
||||||
std::string key = "";
|
std::string key = "";
|
||||||
int color = colors2::white;
|
int color = colorsint::white;
|
||||||
if (Props()->GetBool("capturing")) {
|
if (Props()->GetBool("capturing")) {
|
||||||
key = "< PRESS >";
|
key = "< PRESS >";
|
||||||
color = GUIColor2();
|
color = NCGUIColor();
|
||||||
} else {
|
} else {
|
||||||
if (!Value()) {
|
if (!Value()) {
|
||||||
if (!IsFocused()) {
|
if (!IsFocused()) {
|
||||||
|
@ -37,6 +37,6 @@ void CMenuContainer::MoveChildren() {
|
|||||||
void CMenuContainer::Draw(int x, int y) {
|
void CMenuContainer::Draw(int x, int y) {
|
||||||
CBaseContainer::Draw(x, y);
|
CBaseContainer::Draw(x, y);
|
||||||
for (int i = 0; i < Props()->GetInt("columns"); i++) {
|
for (int i = 0; i < Props()->GetInt("columns"); i++) {
|
||||||
draw::DrawLine(x + (350 + 3) * (i + 1), y, 0, GetMaxSize().second, GUIColor2());
|
draw::DrawLine(x + (350 + 3) * (i + 1), y, 0, GetMaxSize().second, NCGUIColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,14 @@ void CMenuListEntry::Draw(int x, int y) {
|
|||||||
auto texts = draw::GetStringLength(fonts::MENU_BIG, GetText());
|
auto texts = draw::GetStringLength(fonts::MENU_BIG, GetText());
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
if (IsSelected()) {
|
if (IsSelected()) {
|
||||||
draw::DrawLine(x, y, size.first, 0, GUIColor2());
|
draw::DrawLine(x, y, size.first, 0, NCGUIColor());
|
||||||
draw::DrawLine(x, y + size.second, size.first, 0, GUIColor2());
|
draw::DrawLine(x, y + size.second, size.first, 0, NCGUIColor());
|
||||||
draw::DrawLine(x, y, 0, size.second, GUIColor2());
|
draw::DrawLine(x, y, 0, size.second, NCGUIColor());
|
||||||
} else {
|
} else {
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
}
|
}
|
||||||
if (IsHovered()) {
|
if (IsHovered()) {
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(GUIColor2(), 0.25));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(NCGUIColor(), 0.25));
|
||||||
}
|
}
|
||||||
draw::String(fonts::MENU_BIG, x + (size.first - texts.first) / 2, y + (size.second - texts.second) / 2, IsSelected() ? colors2::white : GUIColor2(), 1, GetText());
|
draw::String(fonts::MENU_BIG, x + (size.first - texts.first) / 2, y + (size.second - texts.second) / 2, IsSelected() ? colorsint::white : NCGUIColor(), 1, GetText());
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ void CSlider::Update() {
|
|||||||
|
|
||||||
void CSlider::Draw(int x, int y) {
|
void CSlider::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Create(0, 0, 0, 200));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Create(0, 0, 0, 200));
|
||||||
draw::DrawRect(x, y, m_nSliderPos, size.second, GUIColor2());
|
draw::DrawRect(x, y, m_nSliderPos, size.second, NCGUIColor());
|
||||||
char* s = strfmt("%.2f", Value());
|
char* s = strfmt("%.2f", Value());
|
||||||
std::string str(s);
|
std::string str(s);
|
||||||
delete [] s;
|
delete [] s;
|
||||||
auto sl = draw::GetStringLength(fonts::MENU, str);
|
auto sl = draw::GetStringLength(fonts::MENU, str);
|
||||||
draw::String(fonts::MENU, x + (size.first - sl.first) / 2, y + (size.second - sl.second) / 2, colors2::white, 1, str);
|
draw::String(fonts::MENU, x + (size.first - sl.first) / 2, y + (size.second - sl.second) / 2, colorsint::white, 1, str);
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ void CTextInput::SetValue(std::string value) {
|
|||||||
void CTextInput::Draw(int x, int y) {
|
void CTextInput::Draw(int x, int y) {
|
||||||
auto wsize = draw::GetStringLength(fonts::MENU, "W");
|
auto wsize = draw::GetStringLength(fonts::MENU, "W");
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
int color = colors2::Create(0, 0, 0, 80);
|
int color = colorsint::Create(0, 0, 0, 80);
|
||||||
if (IsFocused()) color = colors2::Transparent(GUIColor2(), 0.25);
|
if (IsFocused()) color = colorsint::Transparent(NCGUIColor(), 0.25);
|
||||||
draw::DrawRect(x, y, size.first, size.second, color);
|
draw::DrawRect(x, y, size.first, size.second, color);
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
int ml = 0;
|
int ml = 0;
|
||||||
int md = 0;
|
int md = 0;
|
||||||
auto dotssize = draw::GetStringLength(fonts::MENU, "..."); // TODO static?
|
auto dotssize = draw::GetStringLength(fonts::MENU, "..."); // TODO static?
|
||||||
@ -52,9 +52,9 @@ void CTextInput::Draw(int x, int y) {
|
|||||||
if (strsize.first + 8 > size.first) ml = i;
|
if (strsize.first + 8 > size.first) ml = i;
|
||||||
}
|
}
|
||||||
if (ml) {
|
if (ml) {
|
||||||
draw::FString(fonts::MENU, x + 2, y + 2, colors2::white, 1, "...%s", value.substr(md).c_str());
|
draw::FString(fonts::MENU, x + 2, y + 2, colorsint::white, 1, "...%s", value.substr(md).c_str());
|
||||||
} else {
|
} else {
|
||||||
draw::String(fonts::MENU, x + 2, y + 2, colors2::white, 1, value); // TODO recalc on update
|
draw::String(fonts::MENU, x + 2, y + 2, colorsint::white, 1, value); // TODO recalc on update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,6 @@ void CTextLabel::Draw(int x, int y) {
|
|||||||
if (Props()->GetBool("centered")) {
|
if (Props()->GetBool("centered")) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
auto ssize = draw::GetStringLength(fonts::MENU, GetText());
|
auto ssize = draw::GetStringLength(fonts::MENU, GetText());
|
||||||
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, colors2::white, 1, GetText());
|
draw::String(fonts::MENU, x + (size.first - ssize.first) / 2, y + (size.second - ssize.second) / 2, colorsint::white, 1, GetText());
|
||||||
} else draw::String(fonts::MENU, x, y, colors2::white, 1, GetText());
|
} else draw::String(fonts::MENU, x, y, colorsint::white, 1, GetText());
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ CTooltip::CTooltip(IWidget* parent) : CTextLabel("tooltip", parent) {
|
|||||||
|
|
||||||
void CTooltip::Draw(int x, int y) {
|
void CTooltip::Draw(int x, int y) {
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Create(0, 0, 0, 230));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Create(0, 0, 0, 230));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), GUIColor2(), 1, GetText());
|
draw::String(fonts::MENU, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), NCGUIColor(), 1, GetText());
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,11 @@ bool CatGUI::Visible() {
|
|||||||
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_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_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);
|
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", "RGB all the things!!!");
|
static CatVar gui_rainbow(CV_SWITCH, "gui_rainbow", "0", "Rainbow GUI", "RGB all the things!!!");
|
||||||
//int GUIColor2() {
|
|
||||||
// return gui_rainbow ? colors2::RainbowCurrent() : colors2::Create((int)gui_color_r, (int)gui_color_g, (int)gui_color_b, 255);
|
int NCGUIColor() {
|
||||||
//}
|
return gui_rainbow ? colorsint::RainbowCurrent() : colorsint::Create((int)gui_color_r, (int)gui_color_g, (int)gui_color_b, 255);
|
||||||
|
}
|
||||||
|
|
||||||
void CatGUI::Setup() {
|
void CatGUI::Setup() {
|
||||||
m_pRootWindow = new RootWindow();
|
m_pRootWindow = new RootWindow();
|
||||||
@ -164,8 +164,8 @@ void CatGUI::Update() {
|
|||||||
if (!m_bShowTooltip && m_pTooltip->IsVisible()) m_pTooltip->Hide();
|
if (!m_bShowTooltip && m_pTooltip->IsVisible()) m_pTooltip->Hide();
|
||||||
root->Draw(0, 0);
|
root->Draw(0, 0);
|
||||||
if (Visible()) {
|
if (Visible()) {
|
||||||
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colors2::Transparent(colors2::white));
|
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colorsint::Transparent(colorsint::white));
|
||||||
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, GUIColor2());
|
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, NCGUIColor());
|
||||||
}
|
}
|
||||||
if (gui_draw_bounds) {
|
if (gui_draw_bounds) {
|
||||||
root->DrawBounds(0, 0);
|
root->DrawBounds(0, 0);
|
||||||
@ -176,8 +176,8 @@ void CatGUI::Update() {
|
|||||||
root->Update();
|
root->Update();
|
||||||
if (!m_bShowTooltip && m_pTooltip->IsVisible()) m_pTooltip->Hide();
|
if (!m_bShowTooltip && m_pTooltip->IsVisible()) m_pTooltip->Hide();
|
||||||
root->Draw(0, 0);
|
root->Draw(0, 0);
|
||||||
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colors2::Transparent(colors2::white));
|
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colorsint::Transparent(colorsint::white));
|
||||||
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, GUIColor2());
|
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, NCGUIColor());
|
||||||
if (gui_draw_bounds) {
|
if (gui_draw_bounds) {
|
||||||
root->DrawBounds(0, 0);
|
root->DrawBounds(0, 0);
|
||||||
}
|
}
|
||||||
|
177
src/menu/compatibilitylayer.cpp
Normal file
177
src/menu/compatibilitylayer.cpp
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
#include "common.hpp"
|
||||||
|
|
||||||
|
namespace fonts {
|
||||||
|
template<typename T>
|
||||||
|
constexpr T _clamp(T _min, T _max, T _val) {
|
||||||
|
return ((_val > _max) ? _max : ((_val < _min) ? _min : _val));
|
||||||
|
}
|
||||||
|
unsigned long ESP = 0;
|
||||||
|
unsigned long MENU = 0;
|
||||||
|
unsigned long MENU_BIG = 0;
|
||||||
|
const std::vector<std::string> fonts = {"Tahoma Bold", "Tahoma", "TF2 Build", "Verdana", "Verdana Bold", "Arial", "Courier New", "Ubuntu Mono Bold"};
|
||||||
|
CatEnum family_enum(fonts);
|
||||||
|
CatVar esp_family(family_enum, "font_esp_family", "2", "ESP font", "ESP font family");
|
||||||
|
CatVar esp_height(CV_INT, "font_esp_height", "14", "ESP height", "ESP font height");
|
||||||
|
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
fonts::ESP = g_ISurface->CreateFont();
|
||||||
|
g_ISurface->SetFontGlyphSet(fonts::ESP, fonts::fonts[_clamp(0, 7, (int)fonts::esp_family)].c_str(), (int)fonts::esp_height, 0, 0, 0, 0); // or Ubuntu Mono Bold
|
||||||
|
//g_ISurface->ResetFontCaches();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int colorsint::FromHSL(float h, float s, float v) {
|
||||||
|
double hh, p, q, t, ff;
|
||||||
|
long i;
|
||||||
|
|
||||||
|
if(s <= 0.0) { // < is bogus, just shuts up warnings
|
||||||
|
return colorsint::Create(v * 255, v * 255, v * 255, 255);
|
||||||
|
}
|
||||||
|
hh = h;
|
||||||
|
if(hh >= 360.0) hh = 0.0;
|
||||||
|
hh /= 60.0;
|
||||||
|
i = (long)hh;
|
||||||
|
ff = hh - i;
|
||||||
|
p = v * (1.0 - s);
|
||||||
|
q = v * (1.0 - (s * ff));
|
||||||
|
t = v * (1.0 - (s * (1.0 - ff)));
|
||||||
|
|
||||||
|
switch(i) {
|
||||||
|
case 0:
|
||||||
|
return colorsint::Create(v * 255, t * 255, p * 255, 255);
|
||||||
|
case 1:
|
||||||
|
return colorsint::Create(q * 255, v * 255, p * 255, 255);
|
||||||
|
case 2:
|
||||||
|
return colorsint::Create(p * 255, v * 255, t * 255, 255);
|
||||||
|
case 3:
|
||||||
|
return colorsint::Create(p * 255, q * 255, v * 255, 255);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
return colorsint::Create(t * 255, p * 255, v * 255, 255);
|
||||||
|
case 5:
|
||||||
|
default:
|
||||||
|
return colorsint::Create(v * 255, p * 255, q * 255, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int colorsint::RainbowCurrent() {
|
||||||
|
return colorsint::FromHSL(fabs(sin(g_GlobalVars->curtime / 2.0f)) * 360.0f, 0.85f, 0.9f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::DrawRect(int x, int y, int w, int h, int color) {
|
||||||
|
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
||||||
|
g_ISurface->DrawFilledRect(x, y, x + w, y + h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::DrawLine(int x, int y, int dx, int dy, int color) {
|
||||||
|
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
||||||
|
g_ISurface->DrawLine(x, y, x + dx, y + dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::OutlineRect(int x, int y, int w, int h, int color) {
|
||||||
|
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
||||||
|
g_ISurface->DrawOutlinedRect(x, y, x + w, y + h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::DrawCircle(float x, float y, float r, int num_segments, int color) {
|
||||||
|
if (num_segments < 3 || r == 0 ) return;
|
||||||
|
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
||||||
|
float Step = PI * 2.0 / num_segments;
|
||||||
|
for (float a = 0; a < (PI*2.0); a += Step) {
|
||||||
|
float x1 = r * cos(a) + x;
|
||||||
|
float y1 = r * sin(a) + y;
|
||||||
|
float x2 = r * cos(a + Step) + x;
|
||||||
|
float y2 = r * sin(a + Step) + y;
|
||||||
|
g_ISurface->DrawLine(x1, y1, x2, y2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::GetStringLength(unsigned long font, char* string, int& length, int& height) {
|
||||||
|
wchar_t buf[512];
|
||||||
|
memset(buf, 0, sizeof(wchar_t) * 512);
|
||||||
|
mbstowcs(buf, string, strlen(string));
|
||||||
|
g_ISurface->GetTextSize(font, buf, length, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::String (unsigned long font, int x, int y, int color, int shadow, const char* text) {
|
||||||
|
bool newlined;
|
||||||
|
int w, h, s, n;
|
||||||
|
char ch[512];
|
||||||
|
wchar_t string[512];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
newlined = false;
|
||||||
|
len = strlen(text);
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
if (text[i] == '\n') {
|
||||||
|
newlined = true; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newlined) {
|
||||||
|
memset(ch, 0, sizeof(char) * 512);
|
||||||
|
GetStringLength(font, "W", w, h);
|
||||||
|
strncpy(ch, text, 511);
|
||||||
|
s = 0;
|
||||||
|
n = 0;
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
if (ch[i] == '\n') {
|
||||||
|
ch[i] = 0;
|
||||||
|
draw::String(font, x, y + n * (h), color, shadow, &ch[0] + s);
|
||||||
|
n++;
|
||||||
|
s = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
draw::String(font, x, y + n * (h), color, shadow, &ch[0] + s);
|
||||||
|
} else {
|
||||||
|
memset(string, 0, sizeof(wchar_t) * 512);
|
||||||
|
mbstowcs(string, text, 511);
|
||||||
|
draw::WString(font, x, y, color, shadow, string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::String(unsigned long font, int x, int y, int color, int shadow, std::string text) {
|
||||||
|
draw::String(font, x, y, color, shadow, text.c_str());
|
||||||
|
}
|
||||||
|
CatVar fast_outline(CV_SWITCH, "fast_outline", "0", "Fast font outline", "Use only single repaint to increase performance");
|
||||||
|
void draw::WString(unsigned long font, int x, int y, int color, int shadow, const wchar_t* text) {
|
||||||
|
unsigned char alpha;
|
||||||
|
int black_t;
|
||||||
|
|
||||||
|
if (shadow) {
|
||||||
|
alpha = (color >> 24);
|
||||||
|
black_t = ((alpha == 255) ? colorsint::black : colorsint::Create(0, 0, 0, alpha / shadow));
|
||||||
|
if (shadow > 0) {
|
||||||
|
draw::WString(font, x + 1, y + 1, black_t, false, text);
|
||||||
|
}
|
||||||
|
if (shadow > 1 && !fast_outline) {
|
||||||
|
draw::WString(font, x - 1, y + 1, black_t, false, text);
|
||||||
|
draw::WString(font, x - 1, y - 1, black_t, false, text);
|
||||||
|
draw::WString(font, x + 1, y - 1, black_t, false, text);
|
||||||
|
draw::WString(font, x + 1, y, black_t, false, text);
|
||||||
|
draw::WString(font, x, y + 1, black_t, false, text);
|
||||||
|
draw::WString(font, x, y - 1, black_t, false, text);
|
||||||
|
draw::WString(font, x - 1, y, black_t, false, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_ISurface->DrawSetTextPos(x, y);
|
||||||
|
g_ISurface->DrawSetTextColor(*reinterpret_cast<Color*>(&color));
|
||||||
|
g_ISurface->DrawSetTextFont(font);
|
||||||
|
g_ISurface->DrawUnicodeString(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw::FString(unsigned long font, int x, int y, int color, int shadow, const char* text, ...) {
|
||||||
|
va_list list;
|
||||||
|
char buffer[2048] = { '\0' };
|
||||||
|
va_start(list, text);
|
||||||
|
vsprintf(buffer, text, list);
|
||||||
|
va_end(list);
|
||||||
|
draw::String(font, x, y, color, shadow, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> draw::GetStringLength(unsigned long font, std::string string) {
|
||||||
|
int l, h;
|
||||||
|
draw::GetStringLength(font, (char*)string.c_str(), l, h);
|
||||||
|
return std::make_pair(l, h);
|
||||||
|
}
|
||||||
|
|
@ -79,9 +79,9 @@ void Background::Draw(int x, int y) {
|
|||||||
while (current) {
|
while (current) {
|
||||||
Particle* next = current->next;
|
Particle* next = current->next;
|
||||||
if (!current->show_in) {
|
if (!current->show_in) {
|
||||||
int color = colors2::white;
|
int color = colorsint::white;
|
||||||
if (current->y > (int)particle_safe) {
|
if (current->y > (int)particle_safe) {
|
||||||
color = colors2::Create(255, 255, 255, ((int)particle_safe + 255) - current->y);
|
color = colorsint::Create(255, 255, 255, ((int)particle_safe + 255) - current->y);
|
||||||
}
|
}
|
||||||
current->texture->Draw((int)current->x, (int)current->y, 16, 16, color);
|
current->texture->Draw((int)current->x, (int)current->y, 16, 16, color);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ void CritIndicator::Draw(int x, int y) {
|
|||||||
} else {
|
} else {
|
||||||
tx = &crit_disabled;
|
tx = &crit_disabled;
|
||||||
}
|
}
|
||||||
draw::DrawRect(x, y, 64, 72, colors2::Transparent(colors2::black));
|
draw::DrawRect(x, y, 64, 72, colorsint::Transparent(colorsint::black));
|
||||||
tx->Draw(x, y, 64, 64);
|
tx->Draw(x, y, 64, 64);
|
||||||
draw::OutlineRect(x, y, 64, 72, critkey ? colors2::pink : GUIColor2());
|
draw::OutlineRect(x, y, 64, 72, critkey ? colorsint::pink : NCGUIColor());
|
||||||
draw::DrawLine(x, y + 64, 64, 0, critkey ? colors2::pink : GUIColor2());
|
draw::DrawLine(x, y + 64, 64, 0, critkey ? colorsint::pink : NCGUIColor());
|
||||||
if (crits) {
|
if (crits) {
|
||||||
draw::DrawRect(x + 1, y + 65, 1 + 61.0f * (hacks::shared::misc::last_bucket / 1000.0f), 6, (!crits) ? colors2::Create(235, 20, 20, 255) : colors2::Create(20, 235, 20, 255));
|
draw::DrawRect(x + 1, y + 65, 1 + 61.0f * (hacks::shared::misc::last_bucket / 1000.0f), 6, (!crits) ? colorsint::Create(235, 20, 20, 255) : colorsint::Create(20, 235, 20, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ Item::Item(std::string name) : CBaseWidget(name, nullptr) {
|
|||||||
|
|
||||||
void Item::Draw(int x, int y) {
|
void Item::Draw(int x, int y) {
|
||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
//draw::DrawRect(x, y, size.first, size.second, colors2::red);
|
//draw::DrawRect(x, y, size.first, size.second, colorsint::red);
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Create(0, 0, 0, 77));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Create(0, 0, 0, 77));
|
||||||
if (IsHovered()) {
|
if (IsHovered()) {
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(GUIColor2(), 0.32f));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(NCGUIColor(), 0.32f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ void ItemSublist::Draw(int x, int y) {
|
|||||||
if (!parent) throw std::runtime_error("Sublist parent can't be casted to List!");
|
if (!parent) throw std::runtime_error("Sublist parent can't be casted to List!");
|
||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
if (parent->open_sublist == list)
|
if (parent->open_sublist == list)
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Transparent(GUIColor2(), 0.5f));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Transparent(NCGUIColor(), 0.5f));
|
||||||
draw::String(font_item, x + 2, y, colors2::white, 2, format((IsHovered() ? "[-] " : "[+] "), title));
|
draw::String(font_item, x + 2, y, colorsint::white, 2, format((IsHovered() ? "[-] " : "[+] "), title));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemSublist::OnKeyPress(ButtonCode_t code, bool repeated) {
|
void ItemSublist::OnKeyPress(ButtonCode_t code, bool repeated) {
|
||||||
|
@ -20,7 +20,7 @@ void ItemTitle::Draw(int x, int y) {
|
|||||||
bool brackets3 = Props()->GetBool("brackets3", false);
|
bool brackets3 = Props()->GetBool("brackets3", false);
|
||||||
std::string str = format(brackets3 ? ">>> " : ">> ", title, brackets3 ? " <<<" : " <<");
|
std::string str = format(brackets3 ? ">>> " : ">> ", title, brackets3 ? " <<<" : " <<");
|
||||||
const auto& size = draw::GetStringLength(font_title, str);
|
const auto& size = draw::GetStringLength(font_title, str);
|
||||||
draw::String(font_title, x + ((Item::size_x - size.first) / 2), y, colors2::white, 2, str);
|
draw::String(font_title, x + ((Item::size_x - size.first) / 2), y, colorsint::white, 2, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@ -124,7 +124,7 @@ void ItemVariable::Draw(int x, int y) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
draw::String(menu::ncc::font_item, x + 2, y, colors2::white, 2, format(catvar.desc_short, ": ", val));
|
draw::String(menu::ncc::font_item, x + 2, y, colorsint::white, 2, format(catvar.desc_short, ": ", val));
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@ -159,9 +159,9 @@ void List::OnMouseLeave() {
|
|||||||
|
|
||||||
void List::Draw(int x, int y) {
|
void List::Draw(int x, int y) {
|
||||||
//const auto& size = GetSize();
|
//const auto& size = GetSize();
|
||||||
draw::OutlineRect(x, y, 2 + Item::size_x, Props()->GetInt("items") * Item::size_y + 2, GUIColor2());
|
draw::OutlineRect(x, y, 2 + Item::size_x, Props()->GetInt("items") * Item::size_y + 2, NCGUIColor());
|
||||||
for (int i = 1; i < Props()->GetInt("items"); i++) {
|
for (int i = 1; i < Props()->GetInt("items"); i++) {
|
||||||
draw::DrawLine(x + 1, y + Item::size_y * i, Item::size_x, 0, GUIColor2());
|
draw::DrawLine(x + 1, y + Item::size_y * i, Item::size_x, 0, NCGUIColor());
|
||||||
}
|
}
|
||||||
//CBaseContainer::Draw(x, y);
|
//CBaseContainer::Draw(x, y);
|
||||||
for (int i = 0; i < ChildCount(); i++) {
|
for (int i = 0; i < ChildCount(); i++) {
|
||||||
|
@ -23,7 +23,7 @@ bool Logo::AlwaysVisible() {
|
|||||||
void Logo::Draw(int x, int y) {
|
void Logo::Draw(int x, int y) {
|
||||||
if (logo) {
|
if (logo) {
|
||||||
if (!texture.id) texture.Load();
|
if (!texture.id) texture.Load();
|
||||||
texture.Draw(x, y, 576, 288, GUIColor2());
|
texture.Draw(x, y, 576, 288, NCGUIColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ bool PlayerList::IsVisible() {
|
|||||||
void PlayerList::Draw(int x, int y) {
|
void PlayerList::Draw(int x, int y) {
|
||||||
if (g_Settings.bInvalid) return;
|
if (g_Settings.bInvalid) return;
|
||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, colors2::Create(0, 0, 0, 77));
|
draw::DrawRect(x, y, size.first, size.second, colorsint::Create(0, 0, 0, 77));
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
for (int i = 0; i < Props()->GetInt("vischildren"); i++) {
|
for (int i = 0; i < Props()->GetInt("vischildren"); i++) {
|
||||||
draw::DrawLine(x, y + i * (Item::size_y + 2), size_table_width(), 0, GUIColor2());
|
draw::DrawLine(x, y + i * (Item::size_y + 2), size_table_width(), 0, NCGUIColor());
|
||||||
}
|
}
|
||||||
int accum = 0;
|
int accum = 0;
|
||||||
for (int i = 0; i < sizeof(size_table) / sizeof(int); i++) {
|
for (int i = 0; i < sizeof(size_table) / sizeof(int); i++) {
|
||||||
draw::DrawLine(x + accum, y, 0, size.second, GUIColor2());
|
draw::DrawLine(x + accum, y, 0, size.second, NCGUIColor());
|
||||||
accum += (size_table[i] + 1) * (float)scale;
|
accum += (size_table[i] + 1) * (float)scale;
|
||||||
}
|
}
|
||||||
CBaseContainer::Draw(x, y);
|
CBaseContainer::Draw(x, y);
|
||||||
|
@ -44,9 +44,9 @@ void PlayerListEntry::Update() {
|
|||||||
clazz->color_bg = 0;
|
clazz->color_bg = 0;
|
||||||
if (idx != g_IEngine->GetLocalPlayer()) {
|
if (idx != g_IEngine->GetLocalPlayer()) {
|
||||||
if (team == TEAM_RED) {
|
if (team == TEAM_RED) {
|
||||||
clazz->color_bg = colors2::red;
|
clazz->color_bg = colorsint::red;
|
||||||
} else if (team == TEAM_BLU) {
|
} else if (team == TEAM_BLU) {
|
||||||
clazz->color_bg = colors2::blu;
|
clazz->color_bg = colorsint::blu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iclazz && iclazz < 10) {
|
if (iclazz && iclazz < 10) {
|
||||||
@ -120,7 +120,7 @@ void SubBase::Draw(int x, int y) {
|
|||||||
const auto& size = GetSize();
|
const auto& size = GetSize();
|
||||||
draw::DrawRect(x, y, size.first, size.second, color_bg);
|
draw::DrawRect(x, y, size.first, size.second, color_bg);
|
||||||
}
|
}
|
||||||
draw::String(menu::ncc::font_item, x + 2, y + 2, color_fg ? color_fg : colors2::white, 2, text);
|
draw::String(menu::ncc::font_item, x + 2, y + 2, color_fg ? color_fg : colorsint::white, 2, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubTitle::SubTitle(PlayerListEntry& parent, const std::string& title) : SubBase(parent) {
|
SubTitle::SubTitle(PlayerListEntry& parent, const std::string& title) : SubBase(parent) {
|
||||||
@ -128,7 +128,7 @@ SubTitle::SubTitle(PlayerListEntry& parent, const std::string& title) : SubBase(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SubTitle::Draw(int x, int y) {
|
void SubTitle::Draw(int x, int y) {
|
||||||
draw::String(menu::ncc::font_title, x + 2, y + 2, colors2::white, 2, text);
|
draw::String(menu::ncc::font_title, x + 2, y + 2, colorsint::white, 2, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubColorComponent::SubColorComponent(PlayerListEntry& parent, Component component) : SubBase(parent), component(component) {}
|
SubColorComponent::SubColorComponent(PlayerListEntry& parent, Component component) : SubBase(parent), component(component) {}
|
||||||
|
@ -36,10 +36,10 @@ void Tooltip::Draw(int x, int y) {
|
|||||||
int originy = y;
|
int originy = y;
|
||||||
if (originx + size.first > draw::width) originx -= size.first;
|
if (originx + size.first > draw::width) originx -= size.first;
|
||||||
if (originx + size.second > draw::height) originy -= size.second;
|
if (originx + size.second > draw::height) originy -= size.second;
|
||||||
static int bgcolor = colors2::Create(0, 0, 0, 77); //colors2::Create(70, 86, 47, 28);
|
static int bgcolor = colorsint::Create(0, 0, 0, 77); //colorsint::Create(70, 86, 47, 28);
|
||||||
static int fgcolor = colors2::Create(200, 200, 190, 255);
|
static int fgcolor = colorsint::Create(200, 200, 190, 255);
|
||||||
draw::DrawRect(x, y, size.first, size.second, bgcolor);
|
draw::DrawRect(x, y, size.first, size.second, bgcolor);
|
||||||
draw::OutlineRect(x, y, size.first, size.second, GUIColor2());
|
draw::OutlineRect(x, y, size.first, size.second, NCGUIColor());
|
||||||
draw::String(font_item, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), fgcolor, 2, GetText());
|
draw::String(font_item, x + Props()->GetInt("padding_x"), y + Props()->GetInt("padding_y"), fgcolor, 2, GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,27 +78,6 @@ namespace fonts
|
|||||||
draw_api::font_handle_t main_font;
|
draw_api::font_handle_t main_font;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace fonts {
|
|
||||||
template<typename T>
|
|
||||||
constexpr T _clamp(T _min, T _max, T _val) {
|
|
||||||
return ((_val > _max) ? _max : ((_val < _min) ? _min : _val));
|
|
||||||
}
|
|
||||||
unsigned long ESP = 0;
|
|
||||||
unsigned long MENU = 0;
|
|
||||||
unsigned long MENU_BIG = 0;
|
|
||||||
const std::vector<std::string> fonts = {"Tahoma Bold", "Tahoma", "TF2 Build", "Verdana", "Verdana Bold", "Arial", "Courier New", "Ubuntu Mono Bold"};
|
|
||||||
CatEnum family_enum(fonts);
|
|
||||||
CatVar esp_family(family_enum, "font_esp_family", "2", "ESP font", "ESP font family");
|
|
||||||
CatVar esp_height(CV_INT, "font_esp_height", "14", "ESP height", "ESP font height");
|
|
||||||
|
|
||||||
void Update() {
|
|
||||||
fonts::ESP = g_ISurface->CreateFont();
|
|
||||||
g_ISurface->SetFontGlyphSet(fonts::ESP, fonts::fonts[_clamp(0, 7, (int)fonts::esp_family)].c_str(), (int)fonts::esp_height, 0, 0, 0, 0); // or Ubuntu Mono Bold
|
|
||||||
//g_ISurface->ResetFontCaches();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::Initialize()
|
void draw::Initialize()
|
||||||
{
|
{
|
||||||
if (!draw::width || !draw::height)
|
if (!draw::width || !draw::height)
|
||||||
@ -156,122 +135,4 @@ bool draw::WorldToScreen(const Vector &origin, Vector &screen)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void draw::DrawRect(int x, int y, int w, int h, int color) {
|
|
||||||
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
|
||||||
g_ISurface->DrawFilledRect(x, y, x + w, y + h);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::DrawLine(int x, int y, int dx, int dy, int color) {
|
|
||||||
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
|
||||||
g_ISurface->DrawLine(x, y, x + dx, y + dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::OutlineRect(int x, int y, int w, int h, int color) {
|
|
||||||
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
|
||||||
g_ISurface->DrawOutlinedRect(x, y, x + w, y + h);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::DrawCircle(float x, float y, float r, int num_segments, int color) {
|
|
||||||
if (num_segments < 3 || r == 0 ) return;
|
|
||||||
g_ISurface->DrawSetColor(*reinterpret_cast<Color*>(&color));
|
|
||||||
float Step = PI * 2.0 / num_segments;
|
|
||||||
for (float a = 0; a < (PI*2.0); a += Step) {
|
|
||||||
float x1 = r * cos(a) + x;
|
|
||||||
float y1 = r * sin(a) + y;
|
|
||||||
float x2 = r * cos(a + Step) + x;
|
|
||||||
float y2 = r * sin(a + Step) + y;
|
|
||||||
g_ISurface->DrawLine(x1, y1, x2, y2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::GetStringLength(unsigned long font, char* string, int& length, int& height) {
|
|
||||||
wchar_t buf[512];
|
|
||||||
memset(buf, 0, sizeof(wchar_t) * 512);
|
|
||||||
mbstowcs(buf, string, strlen(string));
|
|
||||||
g_ISurface->GetTextSize(font, buf, length, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::String (unsigned long font, int x, int y, int color, int shadow, const char* text) {
|
|
||||||
bool newlined;
|
|
||||||
int w, h, s, n;
|
|
||||||
char ch[512];
|
|
||||||
wchar_t string[512];
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
newlined = false;
|
|
||||||
len = strlen(text);
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
if (text[i] == '\n') {
|
|
||||||
newlined = true; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newlined) {
|
|
||||||
memset(ch, 0, sizeof(char) * 512);
|
|
||||||
GetStringLength(font, "W", w, h);
|
|
||||||
strncpy(ch, text, 511);
|
|
||||||
s = 0;
|
|
||||||
n = 0;
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
if (ch[i] == '\n') {
|
|
||||||
ch[i] = 0;
|
|
||||||
draw::String(font, x, y + n * (h), color, shadow, &ch[0] + s);
|
|
||||||
n++;
|
|
||||||
s = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
draw::String(font, x, y + n * (h), color, shadow, &ch[0] + s);
|
|
||||||
} else {
|
|
||||||
memset(string, 0, sizeof(wchar_t) * 512);
|
|
||||||
mbstowcs(string, text, 511);
|
|
||||||
draw::WString(font, x, y, color, shadow, string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::String(unsigned long font, int x, int y, int color, int shadow, std::string text) {
|
|
||||||
draw::String(font, x, y, color, shadow, text.c_str());
|
|
||||||
}
|
|
||||||
CatVar fast_outline(CV_SWITCH, "fast_outline", "0", "Fast font outline", "Use only single repaint to increase performance");
|
|
||||||
void draw::WString(unsigned long font, int x, int y, int color, int shadow, const wchar_t* text) {
|
|
||||||
unsigned char alpha;
|
|
||||||
int black_t;
|
|
||||||
|
|
||||||
if (shadow) {
|
|
||||||
alpha = (color >> 24);
|
|
||||||
black_t = ((alpha == 255) ? colors2::black : colors2::Create(0, 0, 0, alpha / shadow));
|
|
||||||
if (shadow > 0) {
|
|
||||||
draw::WString(font, x + 1, y + 1, black_t, false, text);
|
|
||||||
}
|
|
||||||
if (shadow > 1 && !fast_outline) {
|
|
||||||
draw::WString(font, x - 1, y + 1, black_t, false, text);
|
|
||||||
draw::WString(font, x - 1, y - 1, black_t, false, text);
|
|
||||||
draw::WString(font, x + 1, y - 1, black_t, false, text);
|
|
||||||
draw::WString(font, x + 1, y, black_t, false, text);
|
|
||||||
draw::WString(font, x, y + 1, black_t, false, text);
|
|
||||||
draw::WString(font, x, y - 1, black_t, false, text);
|
|
||||||
draw::WString(font, x - 1, y, black_t, false, text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_ISurface->DrawSetTextPos(x, y);
|
|
||||||
g_ISurface->DrawSetTextColor(*reinterpret_cast<Color*>(&color));
|
|
||||||
g_ISurface->DrawSetTextFont(font);
|
|
||||||
g_ISurface->DrawUnicodeString(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw::FString(unsigned long font, int x, int y, int color, int shadow, const char* text, ...) {
|
|
||||||
va_list list;
|
|
||||||
char buffer[2048] = { '\0' };
|
|
||||||
va_start(list, text);
|
|
||||||
vsprintf(buffer, text, list);
|
|
||||||
va_end(list);
|
|
||||||
draw::String(font, x, y, color, shadow, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<int, int> draw::GetStringLength(unsigned long font, std::string string) {
|
|
||||||
int l, h;
|
|
||||||
draw::GetStringLength(font, (char*)string.c_str(), l, h);
|
|
||||||
return std::make_pair(l, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user