From 9ba29c68dec95c15408cbb5c6d050bb87f4ff15b Mon Sep 17 00:00:00 2001 From: hzqst <113660872@qq.com> Date: Thu, 18 Jan 2024 11:41:51 +0800 Subject: [PATCH] Update vgui::VGuiVertex and DrawTexturedPolygon. --- Plugins/CaptionMod/EngineSurfaceHook.cpp | 2 +- Plugins/CaptionMod/EngineSurfaceHook.h | 2 +- Plugins/CaptionMod/Surface2.cpp | 19 ++++++ Plugins/CaptionMod/SurfaceHook.cpp | 8 +-- include/VGUI/IEngineSurface.h | 3 +- include/VGUI/ISurface.h | 3 +- include/VGUI/VGuiVertex.h | 75 ++++++++++++++++++++++++ thirdparty/FreeImage_clone | 2 +- 8 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 include/VGUI/VGuiVertex.h diff --git a/Plugins/CaptionMod/EngineSurfaceHook.cpp b/Plugins/CaptionMod/EngineSurfaceHook.cpp index d5035281..53f4af9d 100644 --- a/Plugins/CaptionMod/EngineSurfaceHook.cpp +++ b/Plugins/CaptionMod/EngineSurfaceHook.cpp @@ -126,7 +126,7 @@ void CEngineSurfaceProxy::drawPolyLine(int* px, int* py, int numPoints) } -void CEngineSurfaceProxy::drawTexturedPolygon(int* p, int n) +void CEngineSurfaceProxy::drawTexturedPolygon(vgui::VGuiVertex* p, int n) { } diff --git a/Plugins/CaptionMod/EngineSurfaceHook.h b/Plugins/CaptionMod/EngineSurfaceHook.h index 9c48ad43..cc106b5e 100644 --- a/Plugins/CaptionMod/EngineSurfaceHook.h +++ b/Plugins/CaptionMod/EngineSurfaceHook.h @@ -9,7 +9,7 @@ class CEngineSurfaceProxy : public IEngineSurface void drawOutlinedRect(int x0, int y0, int x1, int y1) override; void drawLine(int x0, int y0, int x1, int y1) override; void drawPolyLine(int* px, int* py, int numPoints) override; - void drawTexturedPolygon(int* p, int n) override; + void drawTexturedPolygon(vgui::VGuiVertex* p, int n) override; void drawSetTextureRGBA(int id, const unsigned char* rgba, int wide, int tall, int hardwareFilter, bool forceReload) override; void drawSetTexture(int id) override; void drawTexturedRect(int x0, int y0, int x1, int y1) override; diff --git a/Plugins/CaptionMod/Surface2.cpp b/Plugins/CaptionMod/Surface2.cpp index a9917ccc..26c0e1be 100644 --- a/Plugins/CaptionMod/Surface2.cpp +++ b/Plugins/CaptionMod/Surface2.cpp @@ -1138,22 +1138,39 @@ void CSurface2::SurfaceSetCursorPos(int x, int y) // Source specific interfaces void CSurface2::DrawTexturedLine(const Vertex_t &a, const Vertex_t &b) { + } void CSurface2::DrawOutlinedCircle(int x, int y, int radius, int segments) { + } void CSurface2::DrawTexturedPolyLine(const Vertex_t *p, int n) { + } void CSurface2::DrawTexturedSubRect(int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1) { + } void CSurface2::DrawTexturedPolygon(int n, Vertex_t *pVertices) { + vgui::VGuiVertex GoldSrcVertices[32]; + + int maxVerts = min(n, 32); + + for (int i = 0; i < n; ++i) + { + GoldSrcVertices[i].SetVertex(pVertices[i].m_Position.x, pVertices[i].m_Position.y, pVertices[i].m_TexCoord.x, pVertices[i].m_TexCoord.y); + } + + if(g_pSurface_HL25) + g_pSurface_HL25->DrawTexturedPolygon(GoldSrcVertices, n); + else + g_pSurface->DrawTexturedPolygon(GoldSrcVertices, n); } const wchar_t *CSurface2::GetTitle(VPANEL panel) @@ -1256,6 +1273,7 @@ bool CSurface2::SetBitmapFontGlyphSet(HFont font, const char *windowsFontName, f //----------------------------------------------------------------------------- bool CSurface2::AddBitmapFontFile(const char *fontFileName) { + return false; } @@ -1287,6 +1305,7 @@ void CSurface2::DrawUnicodeString(const wchar_t *pwString, FontDrawType_t drawTy auto ch = (*pwString); if (!ch) break; + DrawUnicodeChar(ch); pwString++; diff --git a/Plugins/CaptionMod/SurfaceHook.cpp b/Plugins/CaptionMod/SurfaceHook.cpp index 893177b4..79745a4d 100644 --- a/Plugins/CaptionMod/SurfaceHook.cpp +++ b/Plugins/CaptionMod/SurfaceHook.cpp @@ -122,7 +122,7 @@ class CSurfaceProxy : public ISurface bool HasCursorPosFunctions(void) override; void SurfaceGetCursorPos(int &x, int &y) override; void SurfaceSetCursorPos(int x, int y) override; - void DrawTexturedPolygon(int *p, int n) override; + void DrawTexturedPolygon(vgui::VGuiVertex*p, int n) override; int GetFontAscent(HFont font, wchar_t wch) override; void SetAllowHTMLJavaScript(bool state) override; void SetLanguage(const char *pchLang) override; @@ -831,7 +831,7 @@ void CSurfaceProxy::SurfaceSetCursorPos(int x, int y) return m_pfnSurfaceSetCursorPos(this, 0, x, y); } -void CSurfaceProxy::DrawTexturedPolygon(int *p, int n) +void CSurfaceProxy::DrawTexturedPolygon(vgui::VGuiVertex*p, int n) { g_pSurface->DrawTexturedPolygon(p, n); } @@ -979,7 +979,7 @@ class CSurfaceProxy_HL25 : public ISurface_HL25 bool HasCursorPosFunctions(void) override; void SurfaceGetCursorPos(int& x, int& y) override; void SurfaceSetCursorPos(int x, int y) override; - void DrawTexturedPolygon(int* p, int n) override; + void DrawTexturedPolygon(vgui::VGuiVertex* p, int n) override; int GetFontAscent(HFont font, wchar_t wch) override; void SetAllowHTMLJavaScript(bool state) override; void SetLanguage(const char* szLanguage) override; @@ -1668,7 +1668,7 @@ void CSurfaceProxy_HL25::SurfaceSetCursorPos(int x, int y) return m_pfnSurfaceSetCursorPos(this, 0, x, y); } -void CSurfaceProxy_HL25::DrawTexturedPolygon(int *p, int n) +void CSurfaceProxy_HL25::DrawTexturedPolygon(vgui::VGuiVertex*p, int n) { g_pSurface_HL25->DrawTexturedPolygon(p, n); } diff --git a/include/VGUI/IEngineSurface.h b/include/VGUI/IEngineSurface.h index bdca1484..7ce35d2e 100644 --- a/include/VGUI/IEngineSurface.h +++ b/include/VGUI/IEngineSurface.h @@ -6,6 +6,7 @@ #endif #include "tier1/interface.h" +#include class IEngineSurface : public IBaseInterface { @@ -16,7 +17,7 @@ class IEngineSurface : public IBaseInterface virtual void drawOutlinedRect(int x0, int y0, int x1, int y1) = 0; virtual void drawLine(int x0, int y0, int x1, int y1) = 0; virtual void drawPolyLine(int *px, int *py, int numPoints) = 0; - virtual void drawTexturedPolygon(int *p, int n) = 0; + virtual void drawTexturedPolygon(vgui::VGuiVertex*p, int n) = 0; virtual void drawSetTextureRGBA(int id, const unsigned char *rgba, int wide, int tall, int hardwareFilter, bool forceReload) = 0; virtual void drawSetTexture(int id) = 0; virtual void drawTexturedRect(int x0, int y0, int x1, int y1) = 0; diff --git a/include/VGUI/ISurface.h b/include/VGUI/ISurface.h index bab9a3f9..2ca5dd09 100644 --- a/include/VGUI/ISurface.h +++ b/include/VGUI/ISurface.h @@ -6,6 +6,7 @@ #endif #include "VGUI.h" +#include "VGuiVertex.h" #include "IHTML.h" #include @@ -153,7 +154,7 @@ namespace vgui virtual bool HasCursorPosFunctions(void) = 0; virtual void SurfaceGetCursorPos(int &x, int &y) = 0; virtual void SurfaceSetCursorPos(int x, int y) = 0; - virtual void DrawTexturedPolygon(int *p, int n) = 0; + virtual void DrawTexturedPolygon(vgui::VGuiVertex*p, int n) = 0; virtual int GetFontAscent(HFont font, wchar_t wch) = 0; virtual void SetAllowHTMLJavaScript(bool state) = 0; virtual void SetLanguage(const char * szLanguage) = 0; diff --git a/include/VGUI/VGuiVertex.h b/include/VGUI/VGuiVertex.h new file mode 100644 index 00000000..1eb915c7 --- /dev/null +++ b/include/VGUI/VGuiVertex.h @@ -0,0 +1,75 @@ +//========= Copyright ?1996-2003, Valve LLC, All rights reserved. ============ +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUIVERTEX_H +#define VGUIVERTEX_H + +#ifdef _WIN32 +#pragma once +#endif + +namespace vgui +{ +class VGuiVertex +{ +public: + VGuiVertex() + { + SetVertex(0,0,0,0); + } + + VGuiVertex( int x, int y, float u, float v ) + { + SetVertex( x, y, u, v ); + } + + void SetX( int i ) { x = i; } + void SetY( int i ) { y = i; } + void SetU( float f ) { u = f; } + void SetV( float f ) { v = f; } + void SetVertex( int x, int y ) + { + SetX( x ); + SetY( y ); + } + void SetVertex( int x, int y, float u, float v ) + { + SetX( x ); + SetY( y ); + SetU( u ); + SetV( v ); + } + + int GetX() { return x; } + int GetY() { return y; } + float GetU() { return u; } + float GetV() { return v; } + void GetVertex( int &x, int &y, float &u, float &v ) + { + x = GetX(); + y = GetY(); + u = GetU(); + v = GetV(); + } + + bool operator==( VGuiVertex &from ) + { + return (from.x == x && from.y == y && from.u == u && from.v == v); + } + +private: + int x, y; + float u, v; +}; +} + +#endif // VGUIVERTEX_H diff --git a/thirdparty/FreeImage_clone b/thirdparty/FreeImage_clone index fe02fa78..9a3c363d 160000 --- a/thirdparty/FreeImage_clone +++ b/thirdparty/FreeImage_clone @@ -1 +1 @@ -Subproject commit fe02fa789870b7e0f843a4f07ebaf372e8274bf1 +Subproject commit 9a3c363db1d694eddbe73c41070d348154ea7c93