Font/Color refactor begin

This commit is contained in:
nullifiedcat 2017-01-26 12:46:00 +03:00
parent 39a872dafa
commit 805552ad76
27 changed files with 716 additions and 34 deletions

View File

@ -1,12 +1,12 @@
BEFORE RELEASE!!
Time DRM
Build DRM
SteamID DRM
HWID:
/etc/machine-id
/etc/fstab
GUI ELEMENTS:
List Entry
Main Menu (BIG)
Checkbox
Text Input
Slider
Counter
List
fullbright toggle
instant taunt

View File

@ -287,7 +287,7 @@ ESPStringCompound::ESPStringCompound() {
void draw::Initialize() {
draw::font_handle = interfaces::surface->CreateFont();
draw::font_handle_menu = interfaces::surface->CreateFont();
interfaces::surface->SetFontGlyphSet(draw::font_handle, "Ubuntu Mono Bold", 14, 0, 0, 0, 0x0); // Ubuntu Mono Bold
interfaces::surface->SetFontGlyphSet(draw::font_handle, "TF2 Build", 14, 0, 0, 0, 0x0); // Ubuntu Mono Bold
interfaces::surface->SetFontGlyphSet(draw::font_handle_menu, "Verdana", 12, 0, 0, 0, 0x0);
}
@ -299,6 +299,11 @@ void draw::DrawString(unsigned long font, int x, int y, Color color, const wchar
interfaces::surface->DrawUnicodeString(text, vgui::FONT_DRAW_DEFAULT);
}
void draw::DrawLine(int x, int y, int dx, int dy, Color color) {
interfaces::surface->DrawSetColor(color);
interfaces::surface->DrawLine(x, y, x + dx, y + dy);
}
void draw::DrawString(int x, int y, Color color, Color background, bool center, const char* text, ...) {
if (!text) return;
va_list list;
@ -316,7 +321,12 @@ void draw::DrawString(int x, int y, Color color, Color background, bool center,
draw::GetStringLength((char*)text, l, h);
Color clr = background;
clr[3] = (unsigned char)180;
draw::DrawRect(x, y + 1, l + 2, h - 4, clr);
//draw::DrawRect(x, y + 1, l + 2, h - 4, clr);
Color tb = color[3] == 255 ? colors::black : colors::Transparent(colors::black, (float)(color[3] / 255.0f) / 3.0f);
draw::DrawString(draw::font_handle, x + 1, y + 1, tb, string);
draw::DrawString(draw::font_handle, x - 1, y - 1, tb, string);
draw::DrawString(draw::font_handle, x + 1, y - 1, tb, string);
draw::DrawString(draw::font_handle, x - 1, y + 1, tb, string);
draw::DrawString(draw::font_handle, x, y, color, string);
}

View File

@ -62,6 +62,7 @@ extern int g_nStringsSide;
extern ESPStringCompound* g_pStringsCenter;
extern int g_nStringsCenter;
namespace draw {
extern unsigned long font_handle;
@ -71,10 +72,18 @@ extern int width;
extern int height;
void Initialize();
void DrawWideString(unsigned long font, int x, int y, unsigned color, const wchar_t* text);
void DrawString(unsigned long font, int x, int y, unsigned color, const char* text);
void DrawFormatString(unsigned long font, int x, int y, unsigned color, const char* text, ...);
void DrawShadowString(unsigned long font, int x, int y, unsigned color, const char* text, ...);
void DrawFormatShadowString(unsigned long font, int x, int y, unsigned color, const char* text, ...);
void DrawString(unsigned long font, int x, int y, Color color, const wchar_t* text);
void DrawString(int x, int y, Color color, Color background, bool center, const char* text, ...);
void DrawString(int x, int y, Color color, const char* text, ...);
void DrawRect(int x, int y, int w, int h, Color color);
void DrawLine(int x, int y, int dx, int dy, Color color);
bool WorldToScreen(Vector &origin, Vector &screen);
bool EntityCenterToScreen(CachedEntity* entity, Vector& out);
void OutlineRect(int x, int y, int w, int h, Color color);

View File

@ -0,0 +1,20 @@
/*
* CBaseWidget.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "CBaseWidget.h"
#include "../common.h"
void CBaseWidget::DrawBounds() {
int x, y;
GetAbsolutePosition(x, y);
int w, h;
GetSize(w, h);
draw::OutlineRect(x, y, w, h, colors::red);
for (int i = 0; i < m_nChildCount; i++) {
GetChildByIndex(i)->DrawBounds();
}
}

View File

@ -0,0 +1,129 @@
/*
* CBaseWidget.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef CBASEWIDGET_H_
#define CBASEWIDGET_H_
#include "IWidget.h"
class CBaseWidget : public virtual IWidget {
public:
inline ~CBaseWidget() {
delete [] m_pszName;
}
inline CBaseWidget(IWidget* parent, const char* name) {
m_pParentWidget = parent;
m_bMouseInside = false;
m_bMousePressed = false;
m_nOffsetX = 0;
m_nOffsetY = 0;
m_nSizeX = 0;
m_nSizeY = 0;
m_nChildCount = 0;
m_pszName = new char[128];
m_pChildrenList = new IWidget*[64];
strncpy((char*)m_pszName, name, 127);
}
virtual void DrawBounds();
inline virtual void Update() {};
inline virtual void OnMouseEnter() { m_bMouseInside = true; };
inline virtual void OnMouseLeave() { m_bMouseInside = false; };
inline virtual void OnMousePress() { m_bMousePressed = true; };
inline virtual void OnMouseRelease() { m_bMousePressed = false; };
inline virtual void OnKeyPress(ButtonCode_t key) {};
inline virtual void OnKeyRelease(ButtonCode_t key) {};
inline virtual void SetOffset(int x, int y) {
m_nOffsetX = x;
m_nOffsetY = y;
}
inline virtual void GetOffset(int& x, int& y) {
x = m_nOffsetX;
y = m_nOffsetY;
}
inline virtual void Draw() {};
inline virtual void GetSize(int& width, int& height) {
width = m_nSizeX;
height = m_nSizeY;
}
inline virtual void GetAbsolutePosition(int& x, int &y) {
int ox = 0;
int oy = 0;
GetOffset(ox, oy);
IWidget* parent = GetParent();
while (parent) {
int dx, dy;
parent->GetOffset(dx, dy);
ox += dx;
oy += dy;
parent = parent->GetParent();
}
x = ox;
y = oy;
}
inline virtual IWidget* GetParent() {
return m_pParentWidget;
}
virtual int GetChildrenCount() {
return m_nChildCount;
}
virtual IWidget* GetChildByIndex(int idx) {
if (idx < 0 || idx >= m_nChildCount) return 0;
return m_pChildrenList[idx];
}
virtual IWidget* GetChildByName(const char* name) {
for (int i = 0; i < m_nChildCount; i++) {
if (!strcmp(name, m_pszName)) return m_pChildrenList[i];
}
return 0;
}
virtual IWidget* GetChildByPoint(int x, int y) {
for (int i = 0; i < m_nChildCount; i++) {
IWidget* child = m_pChildrenList[i];
int ox, oy;
child->GetOffset(ox, oy);
int sx, sy;
child->GetSize(sx, sy);
if (x >= ox && x <= (ox + sx) && y >= oy && y <= (oy + sy)) {
return child;
}
}
return 0;
}
virtual void AddChild(IWidget* child) {
m_pChildrenList[m_nChildCount] = child;
m_nChildCount++;
}
virtual const char* GetName() {
return m_pszName;
}
const char* m_pszName;
int m_nChildCount;
bool m_bMouseInside;
bool m_bMousePressed;
int m_nSizeX;
int m_nSizeY;
int m_nOffsetX;
int m_nOffsetY;
IWidget** m_pChildrenList;
IWidget* m_pParentWidget;
};
#endif /* CBASEWIDGET_H_ */

View File

@ -0,0 +1,56 @@
/*
* CBaseWindow.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "CBaseWindow.h"
#include "../common.h"
#include "GUI.h"
void CBaseWindow::Update() {
int mx = 0, my = 0;
for (int i = 0; i < m_nChildCount; i++) {
m_pChildrenList[i]->Update();
int sx, sy, ox, oy;
m_pChildrenList[i]->GetOffset(ox, oy);
m_pChildrenList[i]->GetSize(sx, sy);
if (sx + ox > mx) mx = sx + ox;
if (sy + oy > my) my = sy + oy;
}
if (GetParent()) {
m_nSizeX = mx;
m_nSizeY = my;
}
}
void CBaseWindow::OnMousePress() {
int ax, ay;
this->GetAbsolutePosition(ax, ay);
logging::Info("%s MousePress! %i %i", GetName(), g_pGUI->m_iMouseX - ax, g_pGUI->m_iMouseY - ay);
pressed = GetChildByPoint(g_pGUI->m_iMouseX - ax, g_pGUI->m_iMouseY - ay);
if (pressed) {
logging::Info("%s Child MousePress! %s", GetName(), pressed->GetName());
pressed->OnMousePress();
}
}
void CBaseWindow::OnMouseRelease() {
if (pressed)
pressed->OnMouseRelease();
}
void CBaseWindow::Draw() {
int px = 0, py = 0;
GetAbsolutePosition(px, py);
int sx, sy;
GetSize(sx, sy);
draw::DrawRect(px, py, sx, sy, colors::Transparent(colors::black));
draw::OutlineRect(px, py, sx, sy, colors::pink);
for (int i = 0; i < m_nChildCount; i++) {
m_pChildrenList[i]->Draw();
}
}

View File

@ -0,0 +1,44 @@
/*
* CBaseWindow.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef CBASEWINDOW_H_
#define CBASEWINDOW_H_
#include "CBaseWidget.h"
#define BASEWINDOW_CAPACITY 128
class CBaseWindow : public CBaseWidget, public virtual IWidget {
public:
inline CBaseWindow(IWidget* parent, const char* name) : CBaseWidget(parent, name) {
pressed = 0;
}
inline virtual ~CBaseWindow() {};
virtual void Update();
/*virtual void OnMouseEnter();
virtual void OnMouseLeave();*/
virtual void OnMousePress();
virtual void OnMouseRelease();
/*virtual void OnKeyPress(ButtonCode_t key);
virtual void OnKeyRelease(ButtonCode_t key);
virtual void SetOffset(int x, int y);
virtual void GetOffset(int& x, int& y);*/
virtual void Draw();
/*virtual void GetSize(int& width, int& height);
virtual IWidget* GetParent();*/
IWidget* pressed;
};
#endif /* CBASEWINDOW_H_ */

View File

@ -0,0 +1,35 @@
/*
* CTextLabel.cpp
*
* Created on: Jan 26, 2017
* Author: nullifiedcat
*/
#include "CTextLabel.h"
#include "../common.h"
#include "../sdk.h"
CTextLabel::CTextLabel(IWidget* parent, const char* name) : CBaseWidget(parent, name) {
m_pszText = 0;
}
CTextLabel::~CTextLabel() {
if (m_pszText) delete [] m_pszText;
}
void CTextLabel::SetText(const char* text) {
m_pszText = new char[strlen(text) + 1];
strcpy(m_pszText, text);
draw::GetStringLength(m_pszText, m_nSizeX, m_nSizeY);
}
const char* CTextLabel::GetText() {
return (const char*)m_pszText;
}
void CTextLabel::Draw() {
int ax, ay;
GetAbsolutePosition(ax, ay);
draw::DrawString(ax, ay, colors::white, "%s", m_pszText);
}

View File

@ -0,0 +1,29 @@
/*
* CTextLabel.h
*
* Created on: Jan 26, 2017
* Author: nullifiedcat
*/
#ifndef CTEXTLABEL_H_
#define CTEXTLABEL_H_
#include "CBaseWidget.h"
#include "../fixsdk.h"
#include "Color.h"
class CTextLabel : public CBaseWidget {
public:
CTextLabel(IWidget* parent, const char* name);
~CTextLabel();
void SetText(const char* text);
const char* GetText();
virtual void Draw();
char* m_pszText;
};
#endif /* CTEXTLABEL_H_ */

73
cathook/src/gui/GUI.cpp Normal file
View File

@ -0,0 +1,73 @@
/*
* GUI.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "GUI.h"
#include "IWidget.h"
#include "RootWindow.h"
#include "../common.h"
#include "../sdk.h"
void GUIVisibleCallback(IConVar* var, const char* pOldValue, float flOldValue) {
interfaces::input->SetCursorPosition(0, 0);
}
CatGUI::CatGUI() {
m_pRootWindow = 0;
v_bGUIVisible = CREATE_CV(CV_SWITCH, "gui_visible", "0", "GUI Active");
v_bDrawBounds = CREATE_CV(CV_SWITCH, "gui_bounds", "0", "Draw Bounds");
}
CatGUI::~CatGUI() {
delete m_pRootWindow;
}
void CatGUI::Setup() {
m_pRootWindow = new RootWindow();
v_bGUIVisible->m_pConVar->InstallChangeCallback(GUIVisibleCallback);
}
void CatGUI::Update() {
for (int i = 0; i < ButtonCode_t::MOUSE_LAST; i++) {
bool down = interfaces::input->IsButtonDown((ButtonCode_t)(KEY_FIRST + i));
bool changed = m_bPressedState[i] != down;
if (changed && down) m_iPressedFrame[i] = interfaces::gvars->framecount;
m_bPressedState[i] = down;
if (m_bKeysInit) {
if (changed) {
//logging::Info("Key %i changed! Now %i.", i, down);
if (i >= ButtonCode_t::MOUSE_FIRST && i <= ButtonCode_t::MOUSE_LEFT) {
if (down) m_pRootWindow->OnMousePress();
else m_pRootWindow->OnMouseRelease();
} else {
if (down) m_pRootWindow->OnKeyPress((ButtonCode_t)i);
else m_pRootWindow->OnKeyRelease((ButtonCode_t)i);
}
}
}
}
m_iMouseX = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_X);
m_iMouseY = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_Y);
if (!m_bKeysInit) m_bKeysInit = 1;
if (v_bGUIVisible->GetBool()) {
m_pRootWindow->Update();
m_pRootWindow->Draw();
draw::DrawRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colors::Transparent(colors::white));
draw::OutlineRect(m_iMouseX - 5, m_iMouseY - 5, 10, 10, colors::pink);
if (v_bDrawBounds->GetBool()) {
m_pRootWindow->DrawBounds();
}
}
}
IWidget* CatGUI::GetRootWindow() {
return m_pRootWindow;
}

41
cathook/src/gui/GUI.h Normal file
View File

@ -0,0 +1,41 @@
/*
* GUI.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef GUI_H_
#define GUI_H_
class IWidget;
class CatVar;
#define GUI_ENABLED true
#include "../fixsdk.h"
#include "../inputsystem/ButtonCode.h"
class CatGUI {
public:
CatGUI();
~CatGUI();
void Update();
void Setup();
IWidget* GetRootWindow();
IWidget* m_pRootWindow;
CatVar* v_bGUIVisible;
CatVar* v_bDrawBounds;
bool m_bKeysInit;
bool m_bPressedState[ButtonCode_t::MOUSE_LAST];
int m_iPressedFrame[ButtonCode_t::MOUSE_LAST];
int m_iMouseX;
int m_iMouseY;
};
extern CatGUI* g_pGUI;
#endif /* GUI_H_ */

View File

@ -0,0 +1,10 @@
/*
* IWidget.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "IWidget.h"
IWidget::~IWidget() {}

46
cathook/src/gui/IWidget.h Normal file
View File

@ -0,0 +1,46 @@
/*
* IWidget.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef IWIDGET_H_
#define IWIDGET_H_
#include "../fixsdk.h"
#include "../inputsystem/ButtonCode.h"
class IWidget {
public:
virtual ~IWidget();
virtual void Update() = 0;
virtual void OnMouseEnter() = 0;
virtual void OnMouseLeave() = 0;
virtual void OnMousePress() = 0;
virtual void OnMouseRelease() = 0;
virtual void OnKeyPress(ButtonCode_t key) = 0;
virtual void OnKeyRelease(ButtonCode_t key) = 0;
virtual void DrawBounds() = 0;
virtual void SetOffset(int x, int y) = 0;
virtual void GetOffset(int& x, int& y) = 0;
virtual void GetAbsolutePosition(int& x, int& y) = 0;
virtual void Draw() = 0;
virtual void GetSize(int& width, int& height) = 0;
virtual IWidget* GetParent() = 0;
virtual const char* GetName() = 0;
virtual int GetChildrenCount() = 0;
virtual IWidget* GetChildByIndex(int idx) = 0;
virtual IWidget* GetChildByName(const char* name) = 0;
virtual IWidget* GetChildByPoint(int x, int y) = 0;
virtual void AddChild(IWidget* child) = 0;
};
#endif /* IWIDGET_H_ */

View File

@ -0,0 +1,21 @@
/*
* MenuList.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef MENULIST_H_
#define MENULIST_H_
#include "CBaseWindow.h"
class MenuList : public CBaseWindow {
public:
MenuList(IWidget* parent);
virtual void GetSize(int& x, int& y);
};
#endif /* MENULIST_H_ */

View File

@ -0,0 +1,8 @@
/*
* MenuWindow.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/

View File

@ -0,0 +1,18 @@
/*
* MenuWindow.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "CBaseWindow.h"
class MenuWindow : public CBaseWindow {
public:
MenuWindow();
~MenuWindow();
IWidget* m_pMenuList;
IWidget* m_pMenuContents;
};

View File

@ -0,0 +1,30 @@
/*
* RootWindow.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "RootWindow.h"
#include "TitleBar.h"
#include "CTextLabel.h"
#include "../common.h"
RootWindow::RootWindow() : CBaseWindow(0, "root") {
IWidget* wgt = new CBaseWindow(this, "testwindow");
this->m_nSizeX = draw::width;
this->m_nSizeY = draw::height;
CTextLabel* text = new CTextLabel(wgt, "testlabel");
text->SetText("Ayy Lmao!");
text->SetOffset(50, 50);
wgt->AddChild(text);
wgt->SetOffset(200, 200);
IWidget* title = new TitleBar(wgt, "Test Window");
wgt->AddChild(title);
this->AddChild(wgt);
}
RootWindow::~RootWindow() {
}

View File

@ -0,0 +1,19 @@
/*
* RootWindow.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef ROOTWINDOW_H_
#define ROOTWINDOW_H_
#include "CBaseWindow.h"
class RootWindow : public CBaseWindow {
public:
RootWindow();
~RootWindow();
};
#endif /* ROOTWINDOW_H_ */

View File

@ -0,0 +1,59 @@
/*
* TitleBar.cpp
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#include "TitleBar.h"
#include "GUI.h"
#include "../common.h"
#include "../sdk.h"
TitleBar::TitleBar(IWidget* parent, const char* name) : CBaseWidget(parent, "title") {
strncpy(m_Text, name, 255);
m_iDraggingStage = 0;
m_nLastX = 0;
m_nLastY = 0;
}
void TitleBar::GetSize(int& x, int& y) {
int sx, sy;
m_pParentWidget->GetSize(sx, sy);
if (sx < 100) x = 100;
else x = sx;
y = 16;
m_nSizeX = x;
m_nSizeY = y;
}
void TitleBar::Draw() {
int ox, oy;
int sx, sy;
GetAbsolutePosition(ox, oy);
draw::DrawRect(ox, oy, m_nSizeX, m_nSizeY, colors::pink);
int l, h;
draw::GetStringLength(m_Text, l, h);
draw::DrawString(draw::font_handle_menu, ox + (m_nSizeX - l) / 2, oy + 1, colors::white, "%s", m_Text);
}
void TitleBar::Update() {
if (!m_bMousePressed) {
m_iDraggingStage = 0;
return;
}
if (m_iDraggingStage == 0) {
m_iDraggingStage = 1;
} else {
int ox, oy;
int dx = g_pGUI->m_iMouseX - m_nLastX;
int dy = g_pGUI->m_iMouseY - m_nLastY;
this->m_pParentWidget->GetOffset(ox, oy);
this->m_pParentWidget->SetOffset(ox + dx, oy + dy);
logging::Info("Dragging %s: NEW %i %i", this->m_pParentWidget->GetName(), ox + dx, oy + dy);
}
m_nLastX = g_pGUI->m_iMouseX;
m_nLastY = g_pGUI->m_iMouseY;
}

View File

@ -0,0 +1,27 @@
/*
* TitleBar.h
*
* Created on: Jan 25, 2017
* Author: nullifiedcat
*/
#ifndef TITLEBAR_H_
#define TITLEBAR_H_
#include "CBaseWidget.h"
class TitleBar : public CBaseWidget {
public:
TitleBar(IWidget* parent, const char* text);
virtual void GetSize(int& x, int& y);
virtual void Draw();
virtual void Update();
char m_Text[256];
int m_iDraggingStage;
int m_nLastX;
int m_nLastY;
};
#endif /* TITLEBAR_H_ */

View File

@ -160,8 +160,8 @@ void GUIListElement_Var::Draw(int x, int y, bool selected) {
void GUIListElement_Var::KeyEvent(ButtonCode_t key) {
int factor = 1;
if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LSHIFT]) factor *= 10;
if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LCONTROL]) factor *= 100;
//if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LSHIFT]) factor *= 10;
//if (g_pGUI->m_bPressedState[ButtonCode_t::KEY_LCONTROL]) factor *= 100;
switch (key) {
case ButtonCode_t::KEY_SPACE:
case ButtonCode_t::KEY_ENTER:
@ -197,6 +197,6 @@ void GUIListElement_SubList::KeyEvent(ButtonCode_t key) {
case ButtonCode_t::KEY_SPACE:
case ButtonCode_t::KEY_RIGHT:
m_pList->Move(m_pParentList->x + LIST_WIDTH - 1, m_pParentList->y + VERTICAL_SPACING * m_nIndex - m_nIndex);
g_pGUI->PushList(m_pList->m_pszListID);
//g_pGUI->PushList(m_pList->m_pszListID);
}
}

View File

@ -52,8 +52,9 @@ void GUI::Draw() {
list->Draw();
}
draw::DrawRect(m_nMouseX - 5, m_nMouseY - 5, 10, 10, colors::Transparent(colors::white));
draw::OutlineRect(m_nMouseX - 5, m_nMouseY - 5, 10, 10, colors::pink);
draw::OutlineRect(m_nMouseX - 5, m_nMouseY - 5, 10, 10, colors::pink);
}
void GUI::UpdateKeys() {
@ -72,12 +73,6 @@ void GUI::UpdateKeys() {
if (!m_bKeysInit) m_bKeysInit = 1;
}
void GUIVisibleCallback(IConVar* var, const char* pOldValue, float flOldValue) {
if (g_pGUI->v_bGUIVisible) {
interfaces::input->SetCursorPosition(0, 0);
}
}
void GUI::UpdateMouse() {
m_nMouseX = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_X);
m_nMouseY = interfaces::input->GetAnalogValue(AnalogCode_t::MOUSE_Y);

View File

@ -16,6 +16,7 @@
class CatVar;
class GUI_List;
class IGUIListElement;
class GUI {
public:
@ -44,6 +45,6 @@ public:
IGUIListElement* m_pLastHoveredElement;
};
extern GUI* g_pGUI;
extern GUI* g_pGUIDeprecated;
#endif /* GUI_H_ */

View File

@ -31,8 +31,8 @@
#include "netmessage.h"
#include "targeting/ITargetSystem.h"
#include "profiler.h"
#include "gui/gui.h"
#include "gui/controls.h"
#include "gui/GUI.h"
//#include "gui/controls.h"
#include "cvwrapper.h"
#include "hooks/hookedmethods.h"
@ -135,7 +135,7 @@ void hack::Initialize() {
g_vEntityCacheProfiling = CREATE_CV(CV_SWITCH, "entity_cache_profiling", "0", "Entity cache profiling");
}
#endif
g_pGUI = new GUI();
g_pGUI = new CatGUI();
g_pGUI->Setup();
EndConVars();
logging::Info("Initializing NetVar tree...");

View File

@ -446,7 +446,7 @@ bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity) {
// TODO offset (GetProjectileSpeed)
rspeed = vfunc<GetProjectileData*>(RAW_ENT(weapon), 527)(RAW_ENT(weapon));
// TODO Wrong grenade launcher gravity
rgrav = 0.5f;
rgrav = 0.25f;
break;
case ClassID::CTFCompoundBow: {
rspeed = vfunc<GetProjectileData*>(RAW_ENT(weapon), 527)(RAW_ENT(weapon));
@ -460,7 +460,7 @@ bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity) {
break;
case ClassID::CTFFlareGun:
rspeed = 2000.0f;
rgrav = 0.5f;
rgrav = 0.25f;
break;
case ClassID::CTFSyringeGun:
rgrav = 0.2f;

View File

@ -9,7 +9,7 @@
#include "../common.h"
#include "../hack.h"
#include "hookedmethods.h"
#include "../gui/gui.h"
#include "../gui/GUI.h"
#include "../segvcatch/segvcatch.h"
void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
@ -28,6 +28,13 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
interfaces::surface->SetCursorAlwaysVisible(g_pGUI->v_bGUIVisible->GetBool());
if (call_default) SAFE_CALL(((PaintTraverse_t*)hooks::hkPanel->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar));
if (!g_Settings.bHackEnabled->GetBool()) return;
#if GUI_ENABLED == true
/*g_pGUI->UpdateKeys();
g_pGUI->UpdateMouse();
g_pGUI->Draw();*/
if (vp == draw::panel_top)
g_pGUI->Update();
#endif
// Because of single-multi thread shit I'm gonna put this thing riiiight here.
static bool autoexec_done = false;
if (!autoexec_done) {
@ -142,11 +149,6 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
RemoveCondition(g_pLocalPlayer->entity, condition::TFCond_Zoomed);
}
}
#if GUI_ENABLED == true
g_pGUI->UpdateKeys();
g_pGUI->UpdateMouse();
g_pGUI->Draw();
#endif
DrawStrings();
}
SEGV_END;

View File

@ -21,9 +21,9 @@ bool CanPacket_hook(void* thisptr) {
int IN_KeyEvent_hook(void* thisptr, int eventcode, int keynum, const char* pszCurrentBinding) {
SEGV_BEGIN;
if (eventcode == 1) {
/*if (eventcode == 1) {
if (g_pGUI->KeyEvent((ButtonCode_t)keynum)) return 1;
}
}*/
return ((IN_KeyEvent_t*)hooks::hkClient->GetMethod(hooks::offKeyEvent))(thisptr, eventcode, keynum, pszCurrentBinding);
SEGV_END;
return 0;