Works!
This commit is contained in:
parent
b65798c085
commit
eef689b01b
@ -72,9 +72,11 @@ void CBaseContainer::DrawBounds(int x, int y) {
|
||||
}
|
||||
|
||||
void CBaseContainer::FocusOn(IWidget* child) {
|
||||
if (GetFocusedChild()) GetFocusedChild()->OnFocusLose();
|
||||
m_pFocusedChild = child;
|
||||
if (child) child->OnFocusGain();
|
||||
if (GetFocusedChild() != child) {
|
||||
if (GetFocusedChild()) GetFocusedChild()->OnFocusLose();
|
||||
if (child) child->OnFocusGain();
|
||||
m_pFocusedChild = child;
|
||||
}
|
||||
}
|
||||
|
||||
IWidget* CBaseContainer::GetFocusedChild() {
|
||||
@ -138,7 +140,12 @@ void CBaseContainer::OnMouseRelease() {
|
||||
|
||||
void CBaseContainer::PressOn(IWidget* child) {
|
||||
m_pPressedChild = child;
|
||||
if (child) child->OnMousePress();
|
||||
if (child) {
|
||||
logging::Info("> MousePress %s", child->GetName().c_str());
|
||||
child->OnMousePress();
|
||||
if (child->DoesStealFocus())
|
||||
FocusOn(child);
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseContainer::SortByZIndex() {
|
||||
@ -157,7 +164,11 @@ void CBaseContainer::UpdateHovers() {
|
||||
|
||||
void CBaseContainer::Update() {
|
||||
SortByZIndex();
|
||||
MoveChildren();
|
||||
UpdateHovers();
|
||||
for (auto child : m_children) {
|
||||
child->Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,15 +9,18 @@
|
||||
#include "../common.h"
|
||||
|
||||
void CBaseWidget::DrawBounds(int x, int y) {
|
||||
if (!m_KeyValues->IsEmpty("bounds_color")) {
|
||||
if (m_KeyValues->IsEmpty("bounds_color")) {
|
||||
m_KeyValues->SetInt("bounds_color", colors::Create(rand() % 255, rand() % 255, rand() % 255, 255));
|
||||
}
|
||||
auto size = GetSize();
|
||||
draw::DrawRect(x, y, size.first, size.second, colors::Transparent(m_KeyValues->GetInt("bounds_color"), 0.25f));
|
||||
draw::OutlineRect(x, y, size.first, size.second, m_KeyValues->GetInt("bounds_color"));
|
||||
}
|
||||
|
||||
CBaseWidget::CBaseWidget(std::string name, IWidget* parent) : m_KeyValues(std::string("cat_widget_" + name).c_str()) {
|
||||
m_pParent = parent;
|
||||
Props()->SetString("name", name.c_str());
|
||||
SetPositionMode(INLINE);
|
||||
Show();
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
inline virtual bool IsFocused() { return m_KeyValues->GetBool("focus"); }
|
||||
inline virtual bool IsPressed() { return m_KeyValues->GetBool("press"); }
|
||||
|
||||
inline virtual bool DoesStealFocus() { return true; }
|
||||
|
||||
inline virtual void SetOffset(int x, int y) {
|
||||
if (x >= 0) m_KeyValues->SetInt("offset_x", x);
|
||||
if (y >= 0) m_KeyValues->SetInt("offset_y", y);
|
||||
|
@ -22,21 +22,30 @@ void CBaseWindow::MoveChildren() {
|
||||
size.first += off.first;
|
||||
size.second += off.second;
|
||||
}
|
||||
if (c->GetPositionMode() != FLOATING)
|
||||
if (c->GetPositionMode() != FLOATING && c->GetPositionMode() != ABSOLUTE)
|
||||
if (size.first > mx) mx = size.first;
|
||||
if (c->GetPositionMode() != FLOATING)
|
||||
my += (size.second + 2);
|
||||
c->Update();
|
||||
}
|
||||
if (GetParent()) {
|
||||
SetSize(mx + 4, my + 2);
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseWindow::OnFocusGain() {
|
||||
SetZIndex(GetZIndex() + 1);
|
||||
CBaseContainer::OnFocusGain();
|
||||
}
|
||||
|
||||
void CBaseWindow::OnFocusLose() {
|
||||
SetZIndex(GetZIndex() - 1);
|
||||
CBaseContainer::OnFocusLose();
|
||||
}
|
||||
|
||||
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));
|
||||
draw::DrawRect(abs.first, abs.second, size.first, size.second, colors::Transparent(colors::black, 0.75));
|
||||
draw::OutlineRect(abs.first, abs.second, size.first, size.second, colors::pink);
|
||||
CBaseContainer::Draw(x, y);
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ public:
|
||||
inline CBaseWindow(std::string name = "unnamed", IWidget* parent = nullptr) : CBaseContainer(name, parent) {}
|
||||
inline virtual ~CBaseWindow() {};
|
||||
|
||||
virtual void OnFocusGain() override;
|
||||
virtual void OnFocusLose() override;
|
||||
virtual void Draw(int x, int y) override;
|
||||
virtual void MoveChildren() override;
|
||||
};
|
||||
|
@ -18,7 +18,6 @@ public:
|
||||
|
||||
IWidget* m_pControl;
|
||||
IWidget* m_pLabel;
|
||||
IWidget* m_pTooltip;
|
||||
|
||||
CatVar* m_pVar;
|
||||
};
|
||||
|
77
cathook/src/gui/CDropdown.cpp
Normal file
77
cathook/src/gui/CDropdown.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* CDropdown.cpp
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "CDropdown.h"
|
||||
#include "CDropdownList.h"
|
||||
#include "RootWindow.h"
|
||||
|
||||
#include "../common.h"
|
||||
#include "../sdk.h"
|
||||
|
||||
CDropdown::CDropdown(std::string name, IWidget* parent) : CBaseButton(name, parent) {
|
||||
list = new CDropdownList(name + "_list", this);
|
||||
g_pGUI->GetRootWindow()->AddChild(list);
|
||||
SetSize(80, 18);
|
||||
list->SetSize(80, 0);
|
||||
CBaseButton::SetCallback([this](CBaseButton*) -> void {
|
||||
ShowList();
|
||||
});
|
||||
}
|
||||
|
||||
CDropdown::~CDropdown() {
|
||||
delete list;
|
||||
}
|
||||
|
||||
void CDropdown::SetCallback(DropdownCallbackFn_t callback) {
|
||||
m_pDropdownCallback = callback;
|
||||
}
|
||||
|
||||
void CDropdown::AddValue(std::string string) {
|
||||
list->AddEntry(string);
|
||||
m_values.push_back(string);
|
||||
}
|
||||
|
||||
std::string CDropdown::ValueName(int idx) {
|
||||
if (idx < 0 || idx >= m_values.size()) return "unknown";
|
||||
return m_values.at(idx);
|
||||
}
|
||||
|
||||
void CDropdown::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
auto ssize = draw::GetStringLength(fonts::MENU, ValueName(Value()));
|
||||
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()));
|
||||
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, ">");
|
||||
}
|
||||
|
||||
void CDropdown::OnFocusLose() {
|
||||
list->Hide();
|
||||
}
|
||||
|
||||
void CDropdown::SetValue(int value) {
|
||||
Props()->SetInt("value", value);
|
||||
if (m_pDropdownCallback)
|
||||
m_pDropdownCallback(this, value);
|
||||
}
|
||||
|
||||
void CDropdown::ShowList() {
|
||||
logging::Info("Showing Menu!");
|
||||
auto pos = AbsolutePosition();
|
||||
auto size = GetSize();
|
||||
list->SetOffset(pos.first + size.first, pos.second);
|
||||
list->Show();
|
||||
}
|
||||
|
||||
int CDropdown::Value() {
|
||||
return Props()->GetInt("value");
|
||||
}
|
||||
|
||||
int CDropdown::ValueCount() {
|
||||
return m_values.size();
|
||||
}
|
41
cathook/src/gui/CDropdown.h
Normal file
41
cathook/src/gui/CDropdown.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* CDropdown.h
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef CDROPDOWN_H_
|
||||
#define CDROPDOWN_H_
|
||||
|
||||
#include "CBaseButton.h"
|
||||
#include "CDropdownList.h"
|
||||
|
||||
class CDropdown;
|
||||
|
||||
typedef std::function<void(CDropdown*, int)> DropdownCallbackFn_t;
|
||||
|
||||
class CDropdown : public CBaseButton {
|
||||
public:
|
||||
CDropdown(std::string name = "unnamed", IWidget* parent = nullptr);
|
||||
~CDropdown();
|
||||
|
||||
void AddValue(std::string);
|
||||
int ValueCount();
|
||||
std::string ValueName(int idx);
|
||||
void SetValue(int value);
|
||||
int Value();
|
||||
|
||||
void ShowList();
|
||||
void SetCallback(DropdownCallbackFn_t callback);
|
||||
|
||||
virtual void Draw(int x, int y);
|
||||
virtual void OnFocusLose();
|
||||
|
||||
DropdownCallbackFn_t m_pDropdownCallback;
|
||||
CDropdownList* list;
|
||||
std::vector<std::string> m_values;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CDROPDOWN_H_ */
|
30
cathook/src/gui/CDropdownEntry.cpp
Normal file
30
cathook/src/gui/CDropdownEntry.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* CDropdownEntry.cpp
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "CDropdownEntry.h"
|
||||
|
||||
#include "../common.h"
|
||||
#include "../sdk.h"
|
||||
|
||||
CDropdownEntry::CDropdownEntry(std::string name, CDropdownList* parent, std::string text, int value) : CBaseButton(name, parent, text) {
|
||||
Props()->SetInt("value", value);
|
||||
SetCallback([this](CBaseButton*) -> void {
|
||||
CDropdownList* parent = dynamic_cast<CDropdownList*>(GetParent());
|
||||
if (!parent) return;
|
||||
parent->SetValue(Props()->GetInt("value"));
|
||||
});
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
CDropdownEntry::~CDropdownEntry() {
|
||||
|
||||
}
|
24
cathook/src/gui/CDropdownEntry.h
Normal file
24
cathook/src/gui/CDropdownEntry.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* CDropdownEntry.h
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef CDROPDOWNENTRY_H_
|
||||
#define CDROPDOWNENTRY_H_
|
||||
|
||||
#include "CBaseButton.h"
|
||||
#include "CDropdownList.h"
|
||||
|
||||
class CDropdownEntry : public CBaseButton {
|
||||
public:
|
||||
CDropdownEntry(std::string name = "unnamed", CDropdownList* parent = nullptr, std::string text = "unset", int value = 0);
|
||||
~CDropdownEntry();
|
||||
|
||||
virtual void Draw(int x, int y);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* CDROPDOWNENTRY_H_ */
|
53
cathook/src/gui/CDropdownList.cpp
Normal file
53
cathook/src/gui/CDropdownList.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* CDropdownList.cpp
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "CDropdownList.h"
|
||||
#include "CDropdownEntry.h"
|
||||
#include "CDropdown.h"
|
||||
|
||||
#include "../common.h"
|
||||
#include "../sdk.h"
|
||||
|
||||
CDropdownList::CDropdownList(std::string name, CDropdown* menu) : CBaseContainer(name, nullptr) {
|
||||
m_pMenu = menu;
|
||||
Hide();
|
||||
SetZIndex(5);
|
||||
}
|
||||
|
||||
CDropdownList::~CDropdownList() {
|
||||
for (auto entry : m_entries) {
|
||||
delete entry;
|
||||
}
|
||||
}
|
||||
|
||||
void CDropdownList::AddEntry(std::string name) {
|
||||
CDropdownEntry* entry = new CDropdownEntry("entry", this, name, m_entries.size());
|
||||
auto size = GetSize();
|
||||
entry->SetSize(size.first, 18);
|
||||
AddChild(entry);
|
||||
m_entries.push_back(entry);
|
||||
SetSize(size.first, m_entries.size() * 18);
|
||||
}
|
||||
|
||||
void CDropdownList::SetValue(int value) {
|
||||
m_pMenu->SetValue(value);
|
||||
Hide();
|
||||
}
|
||||
|
||||
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);
|
||||
CBaseContainer::Draw(x, y);
|
||||
}
|
||||
|
||||
void CDropdownList::MoveChildren() {
|
||||
for (int i = 0; i < ChildCount(); i++) {
|
||||
auto child = ChildByIndex(i);
|
||||
child->SetOffset(0, i * 18);
|
||||
}
|
||||
}
|
32
cathook/src/gui/CDropdownList.h
Normal file
32
cathook/src/gui/CDropdownList.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* CDropdownList.h
|
||||
*
|
||||
* Created on: Jan 31, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef CDROPDOWNLIST_H_
|
||||
#define CDROPDOWNLIST_H_
|
||||
|
||||
#include "CBaseContainer.h"
|
||||
|
||||
class CDropdown;
|
||||
class CDropdownEntry;
|
||||
|
||||
class CDropdownList : public CBaseContainer {
|
||||
public:
|
||||
CDropdownList(std::string name = "unnamed", CDropdown* menu = nullptr);
|
||||
~CDropdownList();
|
||||
|
||||
virtual void Draw(int x, int y);
|
||||
virtual void MoveChildren();
|
||||
inline virtual bool DoesStealFocus() { return false; }
|
||||
|
||||
void AddEntry(std::string name);
|
||||
void SetValue(int value);
|
||||
|
||||
CDropdown* m_pMenu;
|
||||
std::vector<CDropdownEntry*> m_entries;
|
||||
};
|
||||
|
||||
#endif /* CDROPDOWNLIST_H_ */
|
@ -20,7 +20,7 @@ CSlider::CSlider(std::string name, IWidget* parent) : CBaseWidget(name, parent)
|
||||
|
||||
void CSlider::Setup(float min, float max) {
|
||||
Props()->SetFloat("value_min", min);
|
||||
Props()->SetFloat("value_max", min);
|
||||
Props()->SetFloat("value_max", max);
|
||||
SetValue((min + max) / 2.0f);
|
||||
}
|
||||
|
||||
|
@ -17,10 +17,10 @@ void CSplitContainer::MoveChildren() {
|
||||
int width = ((size.first - 4) / ChildCount()) - 2; // TODO padding!
|
||||
for (int i = 0; i < ChildCount(); i++) {
|
||||
auto child = ChildByIndex(i);
|
||||
child->SetOffset(2 + i * width, newsize.second + 2);
|
||||
child->SetOffset(2 + i * width, 2);
|
||||
child->SetMaxSize(width, -1);
|
||||
child->Update();
|
||||
auto csize = child->GetSize();
|
||||
if (csize.second + 2 > newsize.second) newsize.second += csize.second + 2;
|
||||
if (csize.second + 2 > newsize.second) newsize.second = csize.second + 2;
|
||||
}
|
||||
SetSize(-1, newsize.second);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ TitleBar::TitleBar(IWidget* parent, std::string title) : CBaseWidget("titlebar",
|
||||
m_iDraggingStage = 0;
|
||||
m_nLastX = 0;
|
||||
m_nLastY = 0;
|
||||
SetPositionMode(ABSOLUTE);
|
||||
}
|
||||
|
||||
void TitleBar::Draw(int x, int y) {
|
||||
@ -30,7 +31,7 @@ void TitleBar::Update() {
|
||||
auto psize = GetParent()->GetSize();
|
||||
int l, h;
|
||||
draw::GetStringLength(fonts::MENU, (char*)m_strTitle.c_str(), l, h);
|
||||
SetSize(max(2 * TITLEBAR_PADDING_W + l, psize.first), 2 * TITLEBAR_PADDING_H + h);
|
||||
SetSize(psize.first, 2 * TITLEBAR_PADDING_H + h);
|
||||
if (!IsPressed()) {
|
||||
m_iDraggingStage = 0;
|
||||
return;
|
||||
@ -40,7 +41,7 @@ void TitleBar::Update() {
|
||||
} else {
|
||||
int dx = g_pGUI->m_iMouseX - m_nLastX;
|
||||
int dy = g_pGUI->m_iMouseY - m_nLastY;
|
||||
auto offset = GetOffset();
|
||||
auto offset = GetParent()->GetOffset();
|
||||
GetParent()->SetOffset(offset.first + dx, offset.second + dy);
|
||||
}
|
||||
m_nLastX = g_pGUI->m_iMouseX;
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
CTooltip::CTooltip(IWidget* parent) : CTextLabel("tooltip", parent) {}
|
||||
CTooltip::CTooltip(IWidget* parent) : CTextLabel("tooltip", parent) {
|
||||
SetZIndex(999);
|
||||
}
|
||||
|
||||
void CTooltip::Draw(int x, int y) {
|
||||
auto size = GetSize();
|
||||
|
@ -30,6 +30,7 @@ CatGUI::~CatGUI() {
|
||||
|
||||
void CatGUI::Setup() {
|
||||
m_pRootWindow = new RootWindow();
|
||||
m_pRootWindow->Setup();
|
||||
v_bGUIVisible->m_pConVar->InstallChangeCallback(GUIVisibleCallback);
|
||||
}
|
||||
|
||||
@ -106,7 +107,7 @@ bool CatGUI::ConsumesKey(ButtonCode_t key) {
|
||||
else return false;
|
||||
}
|
||||
|
||||
IWidget* CatGUI::GetRootWindow() {
|
||||
RootWindow* CatGUI::GetRootWindow() {
|
||||
return m_pRootWindow;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ class CatVar;
|
||||
#include "../inputsystem/ButtonCode.h"
|
||||
|
||||
class CTooltip;
|
||||
class RootWindow;
|
||||
|
||||
class CatGUI {
|
||||
public:
|
||||
@ -25,13 +26,13 @@ public:
|
||||
|
||||
void Update();
|
||||
void Setup();
|
||||
IWidget* GetRootWindow();
|
||||
RootWindow* GetRootWindow();
|
||||
bool ConsumesKey(ButtonCode_t key);
|
||||
|
||||
void ShowTooltip(const char* text);
|
||||
|
||||
CTooltip* m_pTooltip;
|
||||
IWidget* m_pRootWindow;
|
||||
RootWindow* m_pRootWindow;
|
||||
CatVar* v_bGUIVisible;
|
||||
CatVar* v_bDrawBounds;
|
||||
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
virtual bool IsFocused() = 0;
|
||||
virtual bool IsPressed() = 0;
|
||||
|
||||
virtual bool DoesStealFocus() = 0;
|
||||
|
||||
virtual void SetOffset(int x, int y) = 0;
|
||||
virtual void SetMaxSize(int x, int y) = 0;
|
||||
virtual std::pair<int, int> GetOffset() = 0;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "CSlider.h"
|
||||
#include "CTooltip.h"
|
||||
#include "CBaseContainer.h"
|
||||
#include "CDropdown.h"
|
||||
|
||||
#include "../common.h"
|
||||
#include "CTitleBar.h"
|
||||
@ -39,6 +40,10 @@ void TICallback(CTextInput* thisptr, std::string olds, std::string news) {
|
||||
}
|
||||
|
||||
RootWindow::RootWindow() : CBaseWindow("root") {
|
||||
|
||||
}
|
||||
|
||||
void RootWindow::Setup() {
|
||||
g_pGUI->m_pTooltip = new CTooltip();
|
||||
AddChild(g_pGUI->m_pTooltip);
|
||||
CBaseWindow* ws = new CBaseWindow("splitwindow");
|
||||
@ -49,17 +54,17 @@ RootWindow::RootWindow() : CBaseWindow("root") {
|
||||
ws->SetMaxSize(500, 0);
|
||||
//ws->SetMaxSize(500, 300);
|
||||
CSplitContainer* sc1 = new CSplitContainer("sc1", ws);
|
||||
ws->AddChild(wst);
|
||||
ws->AddChild(sc1);
|
||||
sc1->SetMaxSize(480, -1);
|
||||
sc1->SetSize(480, -1);
|
||||
sc1->SetMaxSize(480, -1);
|
||||
sc1->AddChild(new CTextLabel("tl1", sc1, ":thinking:"));
|
||||
CBaseButton* ccb1 = new CBaseButton("b1", sc1);
|
||||
ccb1->SetText("Ayy Lmao");
|
||||
ccb1->SetText("nut");
|
||||
CSlider* sl = new CSlider("sl", ws);
|
||||
sl->Props()->SetString("cvar", "cat_fov");
|
||||
sl->Setup(10.0f, 150.0f);
|
||||
sl->SetValue(13.37f);
|
||||
sl->SetCallback([](CSlider* slider, float oldv, float newv) {
|
||||
interfaces::cvar->FindVar(slider->Props()->GetString("cvar"))->SetValue(newv);
|
||||
});
|
||||
@ -77,8 +82,13 @@ RootWindow::RootWindow() : CBaseWindow("root") {
|
||||
CSplitContainer* sc3 = new CSplitContainer("sc3", ws);
|
||||
sc3->SetMaxSize(480, -1);
|
||||
sc3->SetSize(480, -1);
|
||||
sc3->AddChild(new CTextLabel("tl1", sc3, "ayy"));
|
||||
sc3->AddChild(new CTextLabel("tl2", sc3, "lmao"));
|
||||
sc3->AddChild(new CTextLabel("tl1", sc3, ":ok_hand:"));
|
||||
sc3->AddChild(new CTextLabel("tl2", sc3, ":skin-tone-1:"));
|
||||
CDropdown* dr = new CDropdown("dr1", sc3);
|
||||
dr->AddValue("testing");
|
||||
dr->AddValue("dropdown?!");
|
||||
dr->AddValue("wow!");
|
||||
sc3->AddChild(dr);
|
||||
ws->AddChild(sc3);
|
||||
AddChild(ws);
|
||||
ws->AddChild(sl);
|
||||
|
@ -14,6 +14,10 @@ class RootWindow : public CBaseWindow {
|
||||
public:
|
||||
RootWindow();
|
||||
~RootWindow();
|
||||
|
||||
void Setup();
|
||||
|
||||
inline virtual void MoveChildren() override {};
|
||||
};
|
||||
|
||||
#endif /* ROOTWINDOW_H_ */
|
||||
|
@ -261,6 +261,8 @@ Misc::Misc() {
|
||||
v_bFastCrouch = CreateConVar(CON_PREFIX "fakecrouch", "0", "Fast crouch");
|
||||
//v_bDumpEventInfo = CreateConVar(CON_PREFIX "debug_event_info", "0", "Show event info");
|
||||
CreateConCommand(CON_PREFIX "set", CC_SetValue, "Set ConVar value (if third argument is 1 the ^'s will be converted into newlines)");
|
||||
|
||||
v_bCleanChat = CREATE_CV(CV_SWITCH, "clean_chat", "1", "Remove newlines from messages");
|
||||
//interfaces::eventManager->AddListener(&listener, "player_death", false);
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@ public:
|
||||
ConCommand* c_Reset;
|
||||
ConCommand* c_Disconnect;
|
||||
ConCommand* c_DisconnectVAC;
|
||||
|
||||
CatVar* v_bCleanChat;
|
||||
};
|
||||
|
||||
DECLARE_HACK_SINGLETON(Misc);
|
||||
|
@ -109,10 +109,8 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
|
||||
g_pGUI->Draw();*/
|
||||
g_pGUI->Update();
|
||||
#endif
|
||||
|
||||
|
||||
if (g_Settings.bShowLogo->GetBool()) {
|
||||
AddSideString(colors::green, "cathook by d4rkc4t");
|
||||
AddSideString(colors::RainbowCurrent(), "cathook by d4rkc4t");
|
||||
#if _DEVELOPER
|
||||
AddSideString(colors::red, "[developer build]");
|
||||
#else
|
||||
|
@ -171,19 +171,21 @@ void OverrideView_hook(void* thisptr, CViewSetup* setup) {
|
||||
|
||||
bool DispatchUserMessage_hook(void* thisptr, int type, bf_read& buf) {
|
||||
SEGV_BEGIN;
|
||||
if (type == 4) {
|
||||
int s = buf.GetNumBytesLeft();
|
||||
char* data = new char[s];
|
||||
for (int i = 0; i < s; i++)
|
||||
data[i] = buf.ReadByte();
|
||||
int j = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
while (char c = data[j++]) {
|
||||
if (c == '\n') data[j - 1] = ' ';
|
||||
if (g_phMisc->v_bCleanChat->GetBool()) {
|
||||
if (type == 4) {
|
||||
int s = buf.GetNumBytesLeft();
|
||||
char* data = new char[s];
|
||||
for (int i = 0; i < s; i++)
|
||||
data[i] = buf.ReadByte();
|
||||
int j = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
while (char c = data[j++]) {
|
||||
if (c == '\n' && (i == 1 || i == 2)) data[j - 1] = ' ';
|
||||
}
|
||||
}
|
||||
buf = bf_read(data, s);
|
||||
buf.Seek(0);
|
||||
}
|
||||
buf = bf_read(data, s);
|
||||
buf.Seek(0);
|
||||
}
|
||||
return ((DispatchUserMessage_t*)hooks::hkClient->GetMethod(hooks::offFrameStageNotify + 1))(thisptr, type, buf);
|
||||
SEGV_END; return false;
|
||||
|
Reference in New Issue
Block a user