diff --git a/src/cdc/math/Vector.cpp b/src/cdc/math/Vector.cpp new file mode 100644 index 0000000..120919a --- /dev/null +++ b/src/cdc/math/Vector.cpp @@ -0,0 +1,31 @@ +#include "Vector.h" + +void cdc::Vector::operator +=(Vector* b) +{ + vec128 = _mm_add_ps(vec128, b->vec128); +} + +void cdc::Vector::operator -=(Vector* b) +{ + vec128 = _mm_sub_ps(vec128, b->vec128); +} + +void cdc::Vector::operator *=(Vector* b) +{ + vec128 = _mm_mul_ps(vec128, b->vec128); +} + +void cdc::Vector::operator /=(Vector* b) +{ + vec128 = _mm_div_ps(vec128, b->vec128); +} + +void cdc::Vector::operator *=(float b) +{ + vec128 = _mm_mul_ps(vec128, _mm_shuffle_ps(_mm_set_ss(b), _mm_set_ss(b), _MM_SHUFFLE(0, 0, 0, 0))); +} + +void cdc::Vector::operator /=(float b) +{ + vec128 = _mm_div_ps(vec128, _mm_shuffle_ps(_mm_set_ss(b), _mm_set_ss(b), _MM_SHUFFLE(0, 0, 0, 0))); +} \ No newline at end of file diff --git a/src/cdc/math/Vector.h b/src/cdc/math/Vector.h index 1bdcd22..2f9231e 100644 --- a/src/cdc/math/Vector.h +++ b/src/cdc/math/Vector.h @@ -19,6 +19,14 @@ namespace cdc float w; }; }; + + void operator +=(Vector* b); + void operator -=(Vector* b); + void operator *=(Vector* b); + void operator /=(Vector* b); + + void operator *=(float b); + void operator /=(float b); }; class Vector2 : public Vector diff --git a/src/render/Font.cpp b/src/render/Font.cpp index d059d26..016e9f0 100644 --- a/src/render/Font.cpp +++ b/src/render/Font.cpp @@ -29,6 +29,11 @@ void Font::SetCursor(float x, float y) Hooking::Call(0x433C70, x, y); } +void Font::GetCursor(float* x, float* y) +{ + Hooking::Call(0x433C90, x, y); +} + void Font::SetScale(float scaleX, float scaleY) { Hooking::Call(0x433E60, scaleX, scaleY); @@ -45,11 +50,33 @@ void Font::Print(const char* fmt, ...) PrintFormatted(s_formatted); } +void Font::PrintCentered(const char* fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vsprintf_s(s_formatted, fmt, va); + va_end(va); + + float x, y; + GetCursor(&x, &y); + + auto width = GetTextWidth(s_formatted); + SetCursor(x - width / 2, y); + + PrintFormatted(s_formatted); +} + void Font::PrintFormatted(const char* formatted, int backdrop) { Hooking::ThisCall(0x434A70, this, formatted, backdrop); } +float Font::GetTextWidth(const char* text) +{ + return Hooking::ThisCallReturn(0x434510, this, text); +} + void Font::OnFlush(std::function callback) { if (!s_callback) diff --git a/src/render/Font.h b/src/render/Font.h index b9a0ab5..f86dfa2 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -11,10 +11,14 @@ class Font static Font* GetMainFont(); static void SetCursor(float x, float y); + static void GetCursor(float* x, float* y); static void SetScale(float scaleX, float scaleY); void Print(const char* fmt, ...); + void PrintCentered(const char* fmt, ...); void PrintFormatted(const char* formatted, int backdrop = 0); + float GetTextWidth(const char* text); + static void OnFlush(std::function callback); }; \ No newline at end of file