Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
SollyBunny committed Nov 20, 2024
1 parent 1b3463f commit 918f458
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 101 deletions.
8 changes: 4 additions & 4 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class IClient : public IInterface
};

/**
* More precise state for @see STATE_LOADING
* Sets what is actually happening in the client right now
*/
* More precise state for @see STATE_LOADING
* Sets what is actually happening in the client right now
*/
enum ELoadingStateDetail
{
LOADING_STATE_DETAIL_INITIAL,
Expand Down Expand Up @@ -268,7 +268,7 @@ class IClient : public IInterface

virtual IGraphics::CTextureHandle GetDebugFont() const = 0; // TODO: remove this function

//DDRace
// DDRace

virtual const char *GetCurrentMap() const = 0;
virtual const char *GetCurrentMapPath() const = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ class CClient : public IClient, public CDemoPlayer::IListener

IFriends *Foes() override { return &m_Foes; }

void GetSmoothFreezeTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;
void GetSmoothFreezeTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;
void GetSmoothTick(int *pSmoothTick, float *pSmoothIntraTick, float MixAmount) override;

void AddWarning(const SWarning &Warning) override;
Expand Down
10 changes: 4 additions & 6 deletions src/engine/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void CConfigManager::Init()
{ \
const size_t HelpSize = (size_t)str_length(Desc) + 32; \
char *pHelp = static_cast<char *>(m_ConfigHeap.Allocate(HelpSize)); \
const bool Alpha = ((Flags)&CFGFLAG_COLALPHA) != 0; \
const bool Alpha = ((Flags) & CFGFLAG_COLALPHA) != 0; \
str_format(pHelp, HelpSize, "%s (default: $%0*X)", Desc, Alpha ? 8 : 6, color_cast<ColorRGBA>(ColorHSLA(Def, Alpha)).Pack(Alpha)); \
AddVariable(m_ConfigHeap.Allocate<SColorConfigVariable>(m_pConsole, #ScriptName, SConfigVariable::VAR_COLOR, Flags, pHelp, &g_Config.m_##Name, Def)); \
}
Expand Down Expand Up @@ -455,19 +455,19 @@ bool CConfigManager::TSave()
char aEscapeBuf[1024 * 2];

#define MACRO_CONFIG_INT(Name, ScriptName, def, min, max, flags, desc) \
if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != def) \
if((flags) & CFGFLAG_SAVE && g_Config.m_##Name != def) \
{ \
str_format(aLineBuf, sizeof(aLineBuf), "%s %i", #ScriptName, g_Config.m_##Name); \
WriteLine(aLineBuf); \
}
#define MACRO_CONFIG_COL(Name, ScriptName, def, flags, desc) \
if((flags)&CFGFLAG_SAVE && g_Config.m_##Name != def) \
if((flags) & CFGFLAG_SAVE && g_Config.m_##Name != def) \
{ \
str_format(aLineBuf, sizeof(aLineBuf), "%s %u", #ScriptName, g_Config.m_##Name); \
WriteLine(aLineBuf); \
}
#define MACRO_CONFIG_STR(Name, ScriptName, len, def, flags, desc) \
if((flags)&CFGFLAG_SAVE && str_comp(g_Config.m_##Name, def) != 0) \
if((flags) & CFGFLAG_SAVE && str_comp(g_Config.m_##Name, def) != 0) \
{ \
EscapeParam(aEscapeBuf, g_Config.m_##Name, sizeof(aEscapeBuf)); \
str_format(aLineBuf, sizeof(aLineBuf), "%s \"%s\"", #ScriptName, aEscapeBuf); \
Expand All @@ -485,7 +485,6 @@ bool CConfigManager::TSave()
Callback.m_pfnFunc(this, Callback.m_pUserData);
}


if(io_sync(m_ConfigFile) != 0)
{
m_Failed = true;
Expand Down Expand Up @@ -522,7 +521,6 @@ void CConfigManager::RegisterTCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData
m_vTCallbacks.emplace_back(pfnFunc, pUserData);
}


void CConfigManager::WriteLine(const char *pLine)
{
if(!m_ConfigFile ||
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/binds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void CBinds::SetDefaults()
Bind(KEY_MOUSE_1, "+fire");
Bind(KEY_MOUSE_2, "+hook");
Bind(KEY_LSHIFT, "+emote");
Bind(KEY_Q, "+bindwheel");
Bind(KEY_Q, "+bindwheel");
Bind(KEY_RETURN, "+show_chat; chat all");
Bind(KEY_RIGHT, "spectate_next");
Bind(KEY_LEFT, "spectate_previous");
Expand Down
6 changes: 2 additions & 4 deletions src/game/client/components/bindwheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IConfigManager;

class CBindWheel : public CComponent
{
void DrawCircle(float x, float y, float r, int Segments);
void DrawCircle(float x, float y, float r, int Segments);

bool m_WasActive;
bool m_Active;
Expand All @@ -30,7 +30,6 @@ class CBindWheel : public CComponent
};
SClientBindWheel m_BindWheelList[NUM_BINDWHEEL];


CBindWheel();
virtual int Sizeof() const override { return sizeof(*this); }

Expand All @@ -40,10 +39,9 @@ class CBindWheel : public CComponent
virtual void OnRelease() override;
virtual bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override;
static void ConchainBindwheel(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);

void updateBinds(int Bindpos, char *Description, char *Command);
void Binwheel(int Bind);

};

#endif
6 changes: 1 addition & 5 deletions src/game/client/components/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,5 @@ bool CControls::CheckNewInput()

m_FastInput = TestInput;

if (NewInput)
{
return true;
}
return false;
return NewInput;
}
19 changes: 7 additions & 12 deletions src/game/client/components/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@ void CHud::RenderScoreHud()

if(GameFlags & GAMEFLAG_FLAGS)
{
int BlinkTimer = (m_pClient->m_aFlagDropTick[t] != 0 &&
(Client()->GameTick(g_Config.m_ClDummy) - m_pClient->m_aFlagDropTick[t]) / Client()->GameTickSpeed() >= 25) ?
10 :
20;
int BlinkTimer = (m_pClient->m_aFlagDropTick[t] != 0 && (Client()->GameTick(g_Config.m_ClDummy) - m_pClient->m_aFlagDropTick[t]) / Client()->GameTickSpeed() >= 25) ? 10 : 20;
if(aFlagCarrier[t] == FLAG_ATSTAND || (aFlagCarrier[t] == FLAG_TAKEN && ((Client()->GameTick(g_Config.m_ClDummy) / BlinkTimer) & 1)))
{
// draw flag
Expand Down Expand Up @@ -304,7 +301,6 @@ void CHud::RenderScoreHud()
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[Id].m_RenderInfo;
TeeInfo.m_Size = ScoreSingleBoxHeight;


const CAnimState *pIdleState = CAnimState::GetIdle();
vec2 OffsetToMid;
CRenderTools::GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid);
Expand Down Expand Up @@ -618,7 +614,7 @@ void CHud::RenderTextInfo()
}
}

//render team in freeze text and last notify
// render team in freeze text and last notify
if((g_Config.m_ClShowFrozenText > 0 || g_Config.m_ClShowFrozenHud > 0 || g_Config.m_ClNotifyWhenLast) && GameClient()->m_GameInfo.m_EntitiesDDRace)
{
int NumInTeam = 0;
Expand All @@ -644,7 +640,7 @@ void CHud::RenderTextInfo()
}
}

//Notify when last
// Notify when last
if(g_Config.m_ClNotifyWhenLast)
{
if(NumInTeam > 1 && NumInTeam - NumFrozen == 1)
Expand All @@ -656,7 +652,7 @@ void CHud::RenderTextInfo()
TextRender()->TextColor(TextRender()->DefaultTextColor());
}
}
//Show freeze text
// Show freeze text
char aBuf[64];
if(g_Config.m_ClShowFrozenText == 1)
str_format(aBuf, sizeof(aBuf), "%d / %d", NumInTeam - NumFrozen, NumInTeam);
Expand All @@ -665,9 +661,9 @@ void CHud::RenderTextInfo()
if(g_Config.m_ClShowFrozenText > 0)
TextRender()->Text(m_Width / 2.0f - TextRender()->TextWidth(10.f, aBuf) / 2.0f, 12.0f, 10.0f, aBuf);

//str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_PrevPredicted.m_FreezeEnd);
//str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_ClWhatsMyPing);
//TextRender()->Text(0, m_Width / 2 - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);
// str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_PrevPredicted.m_FreezeEnd);
// str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_ClWhatsMyPing);
// TextRender()->Text(0, m_Width / 2 - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);

if(g_Config.m_ClShowFrozenHud > 0 && !m_pClient->m_Scoreboard.Active() && !(LocalTeamID == 0 && g_Config.m_ClFrozenHudTeamOnly))
{
Expand All @@ -680,7 +676,6 @@ void CHud::RenderTextInfo()
FreezeInfo.m_ColorBody = ColorRGBA(1, 1, 1);
FreezeInfo.m_ColorFeet = ColorRGBA(1, 1, 1);
FreezeInfo.m_CustomColoredSkin = false;


float progressiveOffset = 0.0f;
float TeeSize = g_Config.m_ClFrozenHudTeeSize;
Expand Down
1 change: 0 additions & 1 deletion src/game/client/components/maplayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class CMapLayers : public CComponent
public:
bool m_OnlineOnly;


enum
{
TYPE_BACKGROUND = 0,
Expand Down
101 changes: 100 additions & 1 deletion src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
static CButtonContainer s_RandomizeColors;
if(*pUseCustomColor)
{
//RandomColorsButton.VSplitLeft(120.0f, &RandomColorsButton, 0);
// RandomColorsButton.VSplitLeft(120.0f, &RandomColorsButton, 0);
if(DoButton_Menu(&s_RandomizeColors, "Random Colors", 0, &RandomColorsButton, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0, 0, 0, 0.5f)))
{
if(m_Dummy)
Expand Down Expand Up @@ -3569,6 +3569,105 @@ void CMenus::RenderSettingsTClient(CUIRect MainView)
s_ScrollRegion.AddRect(ScrollRegion);
s_ScrollRegion.End();

static std::vector<const char *> s_DropDownNames = {Localize("Rainbow"), Localize("Pulse"), Localize("Black")};
static CUi::SDropDownState s_RainbowDropDownState;
static CScrollRegion s_RainbowDropDownScrollRegion;
s_RainbowDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_RainbowDropDownScrollRegion;
int RainbowSelectedOld = g_Config.m_ClRainbowMode - 1;
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRainbow, Localize("Rainbow"), &g_Config.m_ClRainbow, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRainbowOthers, Localize("Rainbow Others"), &g_Config.m_ClRainbowOthers, &RightView, LineSize);
CUIRect DropDownRect;
RightView.HSplitTop(LineSize, &DropDownRect, &RightView);
const int RainbowSelectedNew = Ui()->DoDropDown(&DropDownRect, RainbowSelectedOld, s_DropDownNames.data(), s_DropDownNames.size(), s_RainbowDropDownState);
if(RainbowSelectedOld != RainbowSelectedNew)
{
g_Config.m_ClRainbowMode = RainbowSelectedNew + 1;
RainbowSelectedOld = RainbowSelectedNew;
dbg_msg("rainbow", "rainbow mode changed to %d", g_Config.m_ClRainbowMode);
}

// ***** Miscellaneous ***** //

// A bit jank, but it works
MainView.y = maximum(LeftView.y, RightView.y) + MarginSmall;

MainView.HSplitTop(HeadlineHeight, &Label, &MainView);
Ui()->DoLabel(&Label, Localize("Miscellaneous"), HeadlineFontSize, TEXTALIGN_MIDDLE);
MainView.HSplitTop(MarginSmall, nullptr, &MainView);

MainView.VSplitMid(&LeftView, &RightView, MarginBetweenViews);

// ***** Miscellaneous Left ***** //

DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRunOnJoinConsole, Localize("Run cl_run_on_join as console command"), &g_Config.m_ClRunOnJoinConsole, &LeftView, LineSize);
LeftView.HSplitTop(LineSize, &Button, &LeftView);
if(g_Config.m_ClRunOnJoinConsole)
{
static int Value;
Value = g_Config.m_ClRunOnJoinDelay * 20;
Ui()->DoScrollbarOption(&g_Config.m_ClRunOnJoinDelay, &Value, &Button, Localize("Delay"), 140, 2000, &CUi::ms_LinearScrollbarScale, 0, "ms");
Value /= 20;
// Only set if the scroll value or already set is under psuedo-max of 100 (200ms)
if(Value < 100 || g_Config.m_ClRunOnJoinDelay < 100)
g_Config.m_ClRunOnJoinDelay = Value;
}
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeUpdateFix, Localize("Update tee skin faster after being frozen"), &g_Config.m_ClFreezeUpdateFix, &LeftView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowCenterLines, Localize("Show screen center"), &g_Config.m_ClShowCenterLines, &LeftView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClPingNameCircle, Localize("Show ping colored circle before names"), &g_Config.m_ClPingNameCircle, &LeftView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClMiniDebug, Localize("Show Position and angle (Mini debug)"), &g_Config.m_ClMiniDebug, &LeftView, LineSize);

DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClNotifyWhenLast, Localize("Show when you are the last alive"), &g_Config.m_ClNotifyWhenLast, &LeftView, LineSize);
CUIRect NotificationConfig;
LeftView.HSplitTop(LineSize, &NotificationConfig, &LeftView);
if(g_Config.m_ClNotifyWhenLast)
{
NotificationConfig.VSplitMid(&Button, &NotificationConfig);
static CLineInput s_LastInput(g_Config.m_ClNotifyWhenLastText, sizeof(g_Config.m_ClNotifyWhenLastText));
s_LastInput.SetEmptyText(Localize("Last Alive!"));
Ui()->DoEditBox(&s_LastInput, &Button, 12.0f);
static CButtonContainer s_ClientNotifyWhenLastColor;
DoLine_ColorPicker(&s_ClientNotifyWhenLastColor, ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &NotificationConfig, "", &g_Config.m_ClNotifyWhenLastColor, ColorRGBA(1.0f, 1.0f, 1.0f), false);
}

// ***** Miscellaneous Right ***** //

CUIRect ButtonVerify, EnableVerifySection;
RightView.HSplitTop(LineSize, &EnableVerifySection, &RightView);
EnableVerifySection.VSplitMid(&EnableVerifySection, &ButtonVerify);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClAutoVerify, Localize("Auto Verify"), &g_Config.m_ClAutoVerify, &EnableVerifySection, LineSize);
static CButtonContainer s_VerifyButton;
if(DoButton_Menu(&s_VerifyButton, Localize("Manual Verify"), 0, &ButtonVerify, 0, IGraphics::CORNER_ALL))
{
if(!open_link("https://ger10.ddnet.org/"))
dbg_msg("menus", "couldn't open link");
}

DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClHammerRotatesWithCursor, Localize("Make hammer rotate with cursor"), &g_Config.m_ClHammerRotatesWithCursor, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRenderNameplateSpec, Localize("Hide nameplates in spec"), &g_Config.m_ClRenderNameplateSpec, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRenderCursorSpec, Localize("Show your cursor when in free spectate"), &g_Config.m_ClRenderCursorSpec, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowSkinName, Localize("Show skin names in nameplate"), &g_Config.m_ClShowSkinName, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeStars, Localize("Freeze Stars"), &g_Config.m_ClFreezeStars, &RightView, LineSize);
DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClColorFreeze, Localize("Color Frozen Tee Skins"), &g_Config.m_ClColorFreeze, &RightView, LineSize);

DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClWhiteFeet, Localize("Render all custom colored feet as white feet skin"), &g_Config.m_ClWhiteFeet, &RightView, LineSize);
CUIRect FeetBox;
RightView.HSplitTop(LineSize, &FeetBox, &RightView);
if(g_Config.m_ClWhiteFeet)
{
FeetBox.VSplitMid(&FeetBox, nullptr);
static CLineInput s_WhiteFeet(g_Config.m_ClWhiteFeetSkin, sizeof(g_Config.m_ClWhiteFeetSkin));
s_WhiteFeet.SetEmptyText("x_ninja");
Ui()->DoEditBox(&s_WhiteFeet, &FeetBox, 12.0f);
}

// Scroll
CUIRect ScrollRegion;
ScrollRegion.x = MainView.x;
ScrollRegion.y = maximum(LeftView.y, RightView.y) + MarginSmall;
ScrollRegion.w = MainView.w;
ScrollRegion.h = 0.0f;
s_ScrollRegion.AddRect(ScrollRegion);
s_ScrollRegion.End();
}

if(s_CurCustomTab == TCLIENT_TAB_BINDWHEEL)
Expand Down
5 changes: 2 additions & 3 deletions src/game/client/components/players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void CPlayers::RenderPlayer(

bool Local = m_pClient->m_Snap.m_LocalClientId == ClientId;
bool OtherTeam = m_pClient->IsOtherTeam(ClientId);
//float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
// float Alpha = (OtherTeam || ClientId < 0) ? g_Config.m_ClShowOthersAlpha / 100.0f : 1.0f;
bool Spec = m_pClient->m_Snap.m_SpecInfo.m_Active;

float Alpha = 1.0f;
Expand Down Expand Up @@ -884,7 +884,6 @@ void CPlayers::RenderPlayerGhost(
if(!OtherTeam && FrozenSwappingHide)
Alpha = 1.0f;


// set size
RenderInfo.m_Size = 64.0f;

Expand Down Expand Up @@ -1413,7 +1412,7 @@ void CPlayers::OnRender()

bool Spec = m_pClient->m_Snap.m_SpecInfo.m_Active;

//If we are frozen and hiding frozen ghosts and not swapping render only the regular player
// If we are frozen and hiding frozen ghosts and not swapping render only the regular player
if(RenderGhost && g_Config.m_ClShowOthersGhosts && !Spec && Client()->State() != IClient::STATE_DEMOPLAYBACK)
RenderPlayerGhost(&m_pClient->m_aClients[ClientId].m_RenderPrev, &m_pClient->m_aClients[ClientId].m_RenderCur, &aRenderInfo[ClientId], ClientId);

Expand Down
2 changes: 1 addition & 1 deletion src/game/client/components/skinprofiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class CSkinProfiles : public CComponent
virtual int Sizeof() const override { return sizeof(*this); }
virtual void OnInit() override;
};
#endif
#endif
2 changes: 1 addition & 1 deletion src/game/client/components/tater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ void CTater::RandomFlag(void *pUserData)

// set the flag code as number
g_Config.m_PlayerCountry = pFlag->m_CountryCode;
}
}
2 changes: 1 addition & 1 deletion src/game/client/components/verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ void CVerify::OnRender()
}
return;
}
}
}
Loading

0 comments on commit 918f458

Please sign in to comment.