Skip to content

Commit

Permalink
update(scripting/vgui): ShowText add Font
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzzis committed Jan 16, 2025
1 parent 9ea9284 commit 2cb016e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/engine/vgui/ScreenText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ScreenText::~ScreenText()
}
}

void ScreenText::Create(Color color, char* font, int size)
void ScreenText::Create(Color color, std::string font, int size)
{
m_col = color;
m_font = font;
Expand All @@ -29,7 +29,7 @@ void ScreenText::Create(Color color, char* font, int size)
pMenuKV->SetInt("reorient_mode", 0);
pMenuKV->SetInt("fullbright", 1);
pMenuKV->SetFloat("font_size", size);
pMenuKV->SetString("font_name", font);
pMenuKV->SetString("font_name", font.c_str());
pMenuKV->SetColor("color", color);

pScreenEntity->DispatchSpawn(pMenuKV);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/vgui/ScreenText.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ScreenText
CHandle<CBaseEntity> pRenderingTo;

Color m_col;
char* m_font;
std::string m_font;
int m_size;
Player* m_player;
float m_posX;
Expand All @@ -27,7 +27,7 @@ class ScreenText
ScreenText();
~ScreenText();

void Create(Color color, char* font = "Verdana", int size = 35);
void Create(Color color, std::string font = "Verdana", int size = 35);
void SetupViewForPlayer(Player* player);
void SetText(std::string text);
void SetPosition(float posX = 0.0, float posY = 0.0);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/core/scripting.h
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ std::string m_plugin_name;
public:
PluginVGUI(std::string plugin_name);

uint64_t ShowText(int playerid, Color color, std::string text, float posX, float posY);
uint64_t ShowText(int playerid, Color color, std::string text, float posX, float posY, std::string font_name);
void RemoveText(uint64_t textID);
void SetTextMessage(uint64_t textID, std::string text);
void SetTextPosition(uint64_t textID, float posX, float posY);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/core/scripting/engine/vgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ PluginVGUI::PluginVGUI(std::string plugin_name)
m_plugin_name = plugin_name;
}

uint64_t PluginVGUI::ShowText(int playerid, Color color, std::string text, float posX, float posY)
uint64_t PluginVGUI::ShowText(int playerid, Color color, std::string text, float posX, float posY, std::string font_name)
{
REGISTER_CALLSTACK(m_plugin_name, string_format("PluginVGUI::ShowText(playerid=%d,color=\"%d,%d,%d,%d\",text=\"%s\",posX=%f,posY=%f)", playerid, color.r(), color.g(), color.b(), color.a(), text.c_str(), posX, posY));
REGISTER_CALLSTACK(m_plugin_name, string_format("PluginVGUI::ShowText(playerid=%d,color=\"%d,%d,%d,%d\",text=\"%s\",posX=%f,posY=%f,font_name=\"%s\")", playerid, color.r(), color.g(), color.b(), color.a(), text.c_str(), posX, posY, font_name.c_str()));

Player* player = g_playerManager->GetPlayer(playerid);
if(!player) return -1;
Expand All @@ -23,7 +23,7 @@ uint64_t PluginVGUI::ShowText(int playerid, Color color, std::string text, float
uint64_t textID = g_pVGUI->RegisterScreenText();
ScreenText* txt = g_pVGUI->GetScreenText(textID);

txt->Create(color);
txt->Create(color, font_name);
txt->SetupViewForPlayer(player);
txt->SetText(text);
txt->SetPosition(posX, posY);
Expand Down

0 comments on commit 2cb016e

Please sign in to comment.