Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Optimization | Bug fixes - parser.cpp peoples with unicode can use st…
Browse files Browse the repository at this point in the history
…ats aswell
  • Loading branch information
StormAxs committed Mar 3, 2024
1 parent 2bca2e6 commit c492681
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3307,6 +3307,8 @@ void CMenus::RenderSettingsStA(CUIRect MainView)
UI()->DoScrollbarOption(&g_Config.m_ClOutlineAlpha, &g_Config.m_ClOutlineAlpha, &Button, Localize("Outline Opacity"), 0, 100, &CUI::ms_LinearScrollbarScale, 0u, "%");

static CButtonContainer s_aResetIDs[24];
static CUI::SDropDownState s_BackendDropDownState;
static CScrollRegion s_BackendDropDownScrollRegion;
int i = 0;

DoLine_ColorPicker(&s_aResetIDs[i++],
Expand Down Expand Up @@ -3401,8 +3403,6 @@ void CMenus::RenderSettingsStA(CUIRect MainView)
for(auto &Bind : vBindsList)
vBindsName.push_back(Bind.m_aName);

static CUI::SDropDownState s_BackendDropDownState;
static CScrollRegion s_BackendDropDownScrollRegion;
s_BackendDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_BackendDropDownScrollRegion;
s_SelectedBind = UI()->DoDropDown(&BindWheelList, s_SelectedBind, vBindsName.data(), vBindsName.size(), s_BackendDropDownState);

Expand Down
44 changes: 33 additions & 11 deletions src/game/client/components/menus_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,28 @@ std::vector<std::string> quotes = {
"W's in the shhhhhaaat :screamin':",
"SpinbrosTV... you'r onto something, you'r onto something man",
"Also try M-Client v3 :D",
"Choo-Choo",
"Super rare text you might see once in your life",



};

// Function to get a random quote
std::string GetRandomQuote() {
// Get a random index
int index = rand() % quotes.size();

// Return the random quote
return quotes[index];
std::srand(std::time(nullptr));


int randomNum = std::rand() % 10000 + 1;

if (randomNum == 1) {
return quotes.back(); // Return the super rare quote
} else {

int index = std::rand() % quotes.size();
return quotes[index];
}
}

void CMenus::RenderStartMenu(CUIRect MainView)
Expand Down Expand Up @@ -293,10 +303,10 @@ void CMenus::RenderStartMenu(CUIRect MainView)
VersionUpdate.VMargin(VMargin, &VersionUpdate);

CUIRect RandomText;
RandomText.x = 595.0f;
RandomText.y = 110.0f;
RandomText.w = 230.0f;
RandomText.h = 150.0f;
RandomText.x = 605.0f;
RandomText.y = 130.0f;
RandomText.w = 330.0f;
RandomText.h = 60.0f;
static bool Quote = false;

if (!Quote)
Expand All @@ -305,9 +315,21 @@ void CMenus::RenderStartMenu(CUIRect MainView)
dbg_msg("Quotes", "%s", randomQuote.c_str());
}

TextRender()->TextColor(1.0f, 1.0f, 0.0f, 1.0f);
UI()->DoLabel(&RandomText, randomQuote.c_str(), 20.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

if(!str_comp(randomQuote.c_str(), "Super rare text you might see once in your life"))
{
ColorRGBA color = color_cast<ColorRGBA>(ColorHSVA(round_to_int(LocalTime() * 25) % 255 / 255.f, 1.f, 1.f));
color.a = 0.9f;
TextRender()->TextColor(color);
UI()->DoLabel(&RandomText, "Super rare text you might see once in your life", 20.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
else
{
TextRender()->TextColor(1.0f, 1.0f, 0.0f, 1.0f);
UI()->DoLabel(&RandomText, randomQuote.c_str(), 20.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}

#if defined(CONF_AUTOUPDATE)

Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void CStats::FetchPlayer(CStatsPlayer *pStatsDest, const char *pPlayer)
{
char aUrl_DDStats[256];
char aUrl_DDNet[256];
char aEscapedName[MAX_NAME_LENGTH];
char aEscapedName[MAX_NAME_LENGTH * 4];
EscapeUrl(aEscapedName, sizeof(aEscapedName), pPlayer);
str_format(aUrl_DDStats, sizeof(aUrl_DDStats), "%s%s", STATS_URL_DDSTATS, aEscapedName);
pStatsDest->m_pGetStatsDDStats = HttpGet(aUrl_DDStats);
Expand Down

0 comments on commit c492681

Please sign in to comment.