Skip to content

Commit

Permalink
Merge pull request #372 from DrAbcOfficial/main
Browse files Browse the repository at this point in the history
expose scheme manager
  • Loading branch information
hzqst authored Jan 18, 2024
2 parents 0876d65 + 86e996f commit e2702f2
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 13 deletions.
10 changes: 6 additions & 4 deletions Plugins/CaptionMod/Scheme2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ static CSchemeManager g_SchemeManagerNew;

CSchemeManager* g_pVGuiSchemeManager = &g_SchemeManagerNew;

EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CSchemeManager, ISchemeManager2, VGUI_SCHEME2_INTERFACE_VERSION, g_SchemeManagerNew);

CSchemeManager::CSchemeManager(void)
{
CScheme *nullScheme = new CScheme();
Expand Down Expand Up @@ -721,7 +723,7 @@ int CSchemeManager::GetProportionalNormalizedValue_HD(int rootWide, int rootTall

//LD

int CSchemeManager::GetProportionalScaledValueEx(CScheme *pScheme, int normalizedValue)
int CSchemeManager::GetProportionalScaledValueEx(IScheme2*pScheme, int normalizedValue)
{
VPANEL sizing = pScheme->GetSizingPanel();

Expand All @@ -733,7 +735,7 @@ int CSchemeManager::GetProportionalScaledValueEx(CScheme *pScheme, int normalize
return GetProportionalScaledValue_LD(w, h, normalizedValue);
}

int CSchemeManager::GetProportionalNormalizedValueEx(CScheme *pScheme, int scaledValue)
int CSchemeManager::GetProportionalNormalizedValueEx(IScheme2*pScheme, int scaledValue)
{
auto sizing = pScheme->GetSizingPanel();

Expand Down Expand Up @@ -789,7 +791,7 @@ int CSchemeManager::GetProportionalNormalizedValue(int scaledValue)

//HD

int CSchemeManager::GetHDProportionalScaledValueEx(CScheme* pScheme, int normalizedValue)
int CSchemeManager::GetHDProportionalScaledValueEx(IScheme2* pScheme, int normalizedValue)
{
VPANEL sizing = pScheme->GetSizingPanel();

Expand All @@ -801,7 +803,7 @@ int CSchemeManager::GetHDProportionalScaledValueEx(CScheme* pScheme, int normali
return GetProportionalScaledValue_HD(w, h, normalizedValue);
}

int CSchemeManager::GetHDProportionalNormalizedValueEx(CScheme* pScheme, int scaledValue)
int CSchemeManager::GetHDProportionalNormalizedValueEx(IScheme2* pScheme, int scaledValue)
{
auto sizing = pScheme->GetSizingPanel();

Expand Down
20 changes: 11 additions & 9 deletions Plugins/CaptionMod/Scheme2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// $NoKeywords: $
//=============================================================================//

#ifndef ISCHEME2_H
#define ISCHEME2_H
#ifndef CSCHEME2_H
#define CSCHEME2_H

#ifdef _WIN32
#pragma once
Expand All @@ -20,6 +20,8 @@
#include "Border.h"
#include "Color.h"

#include <IScheme2.h>

namespace vgui
{

Expand All @@ -35,7 +37,7 @@ class IImage;

//Simple wrapper around original g_SchemeManager and g_SchemeManager_HL25

class CScheme : public IScheme_HL25
class CScheme : public IScheme2
{
public:
CScheme(void);
Expand Down Expand Up @@ -103,7 +105,7 @@ class CScheme : public IScheme_HL25
int m_nScreenTall;
};

class CSchemeManager : public ISchemeManager_HL25
class CSchemeManager : public ISchemeManager2
{
public:
CSchemeManager(void);
Expand All @@ -130,13 +132,13 @@ class CSchemeManager : public ISchemeManager_HL25
//LD
int GetProportionalScaledValueEx(HScheme scheme, int normalizedValue);
int GetProportionalNormalizedValueEx(HScheme scheme, int scaledValue);
int GetProportionalScaledValueEx(CScheme* pScheme, int normalizedValue);
int GetProportionalNormalizedValueEx(CScheme* pScheme, int scaledValue);
int GetProportionalScaledValueEx(IScheme2* pScheme, int normalizedValue);
int GetProportionalNormalizedValueEx(IScheme2* pScheme, int scaledValue);
//HD
int GetHDProportionalScaledValueEx(HScheme scheme, int normalizedValue);
int GetHDProportionalNormalizedValueEx(HScheme scheme, int scaledValue);
int GetHDProportionalScaledValueEx(CScheme* pScheme, int normalizedValue);
int GetHDProportionalNormalizedValueEx(CScheme* pScheme, int scaledValue);
int GetHDProportionalScaledValueEx(IScheme2* pScheme, int normalizedValue);
int GetHDProportionalNormalizedValueEx(IScheme2* pScheme, int scaledValue);

HScheme LoadSchemeFromFileEx(VPANEL sizingPanel, const char* fileName, const char* tag);

Expand Down Expand Up @@ -165,4 +167,4 @@ class CSchemeManager : public ISchemeManager_HL25

} // namespace vgui

#endif // ISCHEME_H
#endif // CSCHEME_H
52 changes: 52 additions & 0 deletions include/VGUI/IScheme2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//========= Copyright ?1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//

#ifndef ISCHEME2_H
#define ISCHEME2_H

#ifdef _WIN32
#pragma once
#endif

#include "VGUI.h"
#include <IScheme.h>

namespace vgui
{
class IScheme2 : public IScheme_HL25
{
public:
virtual void Shutdown(bool full) = 0;
virtual void LoadFromFile(VPANEL sizingPanel, const char* filename, const char* tag, KeyValues* inKeys) = 0;
virtual const char* GetName(void) = 0;
virtual const char* GetFileName(void) = 0;
virtual char const* GetFontName(const HFont& font) = 0;
virtual void ReloadFontGlyphs(void) = 0;
virtual VPANEL GetSizingPanel(void) = 0;
};

class ISchemeManager2 : public ISchemeManager_HL25
{
public:
//LD
virtual int GetProportionalScaledValueEx(HScheme scheme, int normalizedValue) = 0;
virtual int GetProportionalNormalizedValueEx(HScheme scheme, int scaledValue) = 0;
virtual int GetProportionalScaledValueEx(IScheme2* pScheme, int normalizedValue) = 0;
virtual int GetProportionalNormalizedValueEx(IScheme2* pScheme, int scaledValue) = 0;
//HD
virtual int GetHDProportionalScaledValueEx(HScheme scheme, int normalizedValue) = 0;
virtual int GetHDProportionalNormalizedValueEx(HScheme scheme, int scaledValue) = 0;
virtual int GetHDProportionalScaledValueEx(IScheme2* pScheme, int normalizedValue) = 0;
virtual int GetHDProportionalNormalizedValueEx(IScheme2* pScheme, int scaledValue) = 0;

virtual HScheme LoadSchemeFromFileEx(VPANEL sizingPanel, const char* fileName, const char* tag) = 0;
};

#define VGUI_SCHEME2_INTERFACE_VERSION "VGUI_Scheme2_001"
} // namespace vgui

#endif // ISCHEME2_H

0 comments on commit e2702f2

Please sign in to comment.