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

Commit

Permalink
added content
Browse files Browse the repository at this point in the history
  • Loading branch information
BlaiZephyr committed Dec 8, 2023
1 parent 7c8dd1f commit 22d3aac
Show file tree
Hide file tree
Showing 11 changed files with 624 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,8 @@ if(CLIENT)
components/background.h
components/binds.cpp
components/binds.h
components/bindwheel.cpp
components/bindwheel.h
components/broadcast.cpp
components/broadcast.h
components/camera.cpp
Expand Down Expand Up @@ -2221,12 +2223,16 @@ if(CLIENT)
components/nameplates.h
components/particles.cpp
components/particles.h
components/parser.cpp
components/parser.h
components/players.cpp
components/players.h
components/race_demo.cpp
components/race_demo.h
components/scoreboard.cpp
components/scoreboard.h
components/skinprofiles.cpp
components/skinprofiles.h
components/skins.cpp
components/skins.h
components/sounds.cpp
Expand All @@ -2237,6 +2243,8 @@ if(CLIENT)
components/statboard.h
components/tooltips.cpp
components/tooltips.h
components/verify.cpp
components/verify.h
components/voting.cpp
components/voting.h
gameclient.cpp
Expand Down
1 change: 0 additions & 1 deletion src/engine/shared/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CConfig
char m_##Name[Len]; // Flawfinder: ignore
#include "config_variables.h"

#include "sta_variables.h"
#undef MACRO_CONFIG_INT
#undef MACRO_CONFIG_COL
#undef MACRO_CONFIG_STR
Expand Down
9 changes: 9 additions & 0 deletions src/engine/shared/config_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,15 @@ MACRO_CONFIG_INT(ClVideoRecorderFPS, cl_video_recorder_fps, 60, 1, 1000, CFGFLAG
/*
* Add config variables for mods below this comment to avoid merge conflicts.
*/

MACRO_CONFIG_INT(ClShowFrozenText, sc_frozen_tees_text, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show how many tees in your team are currently frozen. (0 - off, 1 - show alive, 2 - show frozen)")
MACRO_CONFIG_INT(ClShowFrozenHud, sc_frozen_tees_hud, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show frozen tee HUD")
MACRO_CONFIG_INT(ClShowFrozenHudSkins, sc_frozen_tees_hud_skins, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Use ninja skin, or darkened skin for frozen tees on hud")

MACRO_CONFIG_INT(ClFrozenHudTeeSize, sc_frozen_tees_size, 15, 8, 20, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Size of tees in frozen tee hud. (Default : 15)")
MACRO_CONFIG_INT(ClFrozenMaxRows, sc_frozen_tees_max_rows, 1, 1, 6, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Maximum number of rows in frozen tee HUD display")
MACRO_CONFIG_INT(ClFrozenHudTeamOnly, sc_frozen_tees_only_inteam, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Only render frozen tee HUD display while in team")

MACRO_CONFIG_COL(ScPlayerOwnColor, sc_player_own_color, 6684927, CFGFLAG_CLIENT | CFGFLAG_SAVE, "You'r color in TAB list")
MACRO_CONFIG_COL(ScLocalConsoleColor, sc_local_console_color, 51, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Local console color")
MACRO_CONFIG_COL(ScRemoteConsoleColor, sc_remote_console_color, 21837, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Remote console color")
Expand Down
184 changes: 184 additions & 0 deletions src/game/client/components/bindwheel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#include "bindwheel.h"

#include <engine/shared/config.h>
#include <engine/shared/datafile.h>
#include <game/client/gameclient.h>
#include <game/client/render.h>
#include <game/client/ui.h>

// Concept by sjrc6
// https://github.com/sjrc6/TaterClient-ddnet/blob/master/src/game/client/components/bindwheel.cpp

void CBindWheel::OnInit()
{
CDataFileReader DF;
if(!DF.Open(Storage(), "bind_wheel.binds", IStorageTW::TYPE_ALL))
return;

int Start, Num;
DF.GetType(0, &Start, &Num);

for(int i = 0; i < Num; i++)
{
const SBind *pBind = (SBind *)DF.GetItem(Start + i);
m_vBinds.push_back(*pBind);
}

DF.Close();
}

void CBindWheel::OnShutdown()
{
CDataFileWriter DF;
DF.Open(Storage(), "bind_wheel.binds", IStorageTW::TYPE_ALL);

int ID = 0;
for(const SBind &Bind : m_vBinds)
{
DF.AddItem(0, ID, sizeof(SBind), &Bind);
ID++;
}

DF.Finish();
}

void CBindWheel::UseBind()
{
Console()->ExecuteLine(m_vBinds[m_Choose].m_aBind);
}

void CBindWheel::ConBindWheel(IConsole::IResult *pResult, void *pUserData)
{
CBindWheel *pSelf = (CBindWheel *)pUserData;

if(pSelf->Client()->State() != IClient::STATE_DEMOPLAYBACK)
pSelf->m_Active = pResult->GetInteger(0) != 0;
}

void CBindWheel::ConNewBindWheel(IConsole::IResult *pResult, void *pUserData)
{
CBindWheel *pSelf = (CBindWheel *)pUserData;

const char *pName = pResult->GetString(0);
const char *pBind = pResult->GetString(1);

for(const SBind &Bind : pSelf->m_vBinds)
{
if(!str_comp(Bind.m_aName, pName) || !str_comp(Bind.m_aBind, pBind))
{
dbg_msg("bind_wheel", "this bind is already in wheel");
return;
}
}

SBind NewBind;
str_copy(NewBind.m_aName, pName);
str_copy(NewBind.m_aBind, pBind);

pSelf->m_vBinds.push_back(NewBind);

dbg_msg("bind_wheel", "bind '%s' with name '%s' added to wheel", pBind, pName);
}

void CBindWheel::ConRemBindWheel(IConsole::IResult *pResult, void *pUserData)
{
CBindWheel *pSelf = (CBindWheel *)pUserData;

const char *pArg = pResult->GetString(0);

for(int i = 0; i < pSelf->m_vBinds.size(); i++)
{
const SBind &Bind = pSelf->m_vBinds[i];

if(!str_comp(Bind.m_aName, pArg) || !str_comp(Bind.m_aBind, pArg))
{
dbg_msg("bind_wheel", "bind '%s' removed from wheel", Bind.m_aName);
pSelf->m_vBinds.erase(pSelf->m_vBinds.begin() + i);

return;
}
}
}

void CBindWheel::OnConsoleInit()
{
Console()->Register("+bind_wheel", "", CFGFLAG_CLIENT, ConBindWheel, this, "Open bind wheel");
Console()->Register("bind_wheel", "s[name] s[bind]", CFGFLAG_CLIENT, ConNewBindWheel, this, "Add new bind to bind wheel");
Console()->Register("bind_wheel_rem", "s[name_or_bind]", CFGFLAG_CLIENT, ConRemBindWheel, this, "Remove bind from bind wheel");
}

bool CBindWheel::OnCursorMove(float x, float y, IInput::ECursorType CursorType)
{
if(!m_Active)
return false;

UI()->ConvertMouseMove(&x, &y, CursorType);
m_MousePos += vec2(x, y);

return true;
}

void CBindWheel::OnRender()
{
if(!m_Active)
{
if(m_WasActive && !m_vBinds.empty() && m_Choose != -1)
UseBind();
m_WasActive = false;

return;
}
m_WasActive = true;

CUIRect Screen = *UI()->Screen();

// Clear & map screen
UI()->MapScreen();
Graphics()->BlendNormal();
Graphics()->TextureClear();

// Render chircle
Graphics()->QuadsBegin();
Graphics()->SetColor(0, 0, 0, 0.3f);
Graphics()->DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64);
Graphics()->QuadsEnd();

if(length(m_MousePos) > 170.f)
m_MousePos = normalize(m_MousePos) * 170.0f;

// Get chose bind
float SelectedAngle = angle(m_MousePos) + 2 * pi / 24;
if(SelectedAngle < 0)
SelectedAngle += 2 * pi;

m_Choose = -1;
if(length(m_MousePos) > 110.f)
m_Choose = (int)(SelectedAngle / (2 * pi) * m_vBinds.size());

// Render binds
if(!m_vBinds.empty())
{
const float Theta = pi * 2 / m_vBinds.size();

for(int i = 0; i < m_vBinds.size(); i++)
{
const SBind &Bind = m_vBinds[i];

const float a = Theta * i;
vec2 Pos = {cosf(a), sinf(a)};
Pos *= 140.f;

const float FontSize = (i == m_Choose) ? 20.f : 12.f;
float W = TextRender()->TextWidth(FontSize, Bind.m_aName);
TextRender()->Text(Screen.w / 2.f + Pos.x - W / 2.f, Screen.h / 2.f + Pos.y - FontSize / 2.f, FontSize, Bind.m_aName);
}
}
else
{
const char *pEmpty = "Empty. Example of adding new bind(in f1): bind_wheel \"Text\" \"say hi t-client :D\"";
float W = TextRender()->TextWidth(8.f, pEmpty);
TextRender()->Text(Screen.w / 2.f - W / 2.f, Screen.h / 2.f - 12.f, 8.f, pEmpty);
}

RenderTools()->RenderCursor(m_MousePos + vec2(Screen.w, Screen.h) / 2.f, 24.0f);
}
45 changes: 45 additions & 0 deletions src/game/client/components/bindwheel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef GAME_CLIENT_MACHO_BIND_WHEEL_H
#define GAME_CLIENT_MACHO_BIND_WHEEL_H

#include <base/vmath.h>
#include <engine/console.h>
#include <game/client/component.h>

enum
{
BIND_WHEEL_MAX_NAME = 64,
BIND_WHEEL_MAX_BIND = 256
};

class CBindWheel : public CComponent
{
vec2 m_MousePos;
bool m_Active;
bool m_WasActive;
int m_Choose;

static void ConBindWheel(IConsole::IResult *pResult, void *pUserData);
static void ConNewBindWheel(IConsole::IResult *pResult, void *pUserData);
static void ConRemBindWheel(IConsole::IResult *pResult, void *pUserData);

void UseBind();

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

struct SBind
{
char m_aName[BIND_WHEEL_MAX_NAME];
char m_aBind[BIND_WHEEL_MAX_BIND];
};

std::vector<SBind> m_vBinds;

void OnInit() override;
void OnShutdown() override;
void OnConsoleInit() override;
void OnRender() override;
bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override;
};

#endif
Loading

0 comments on commit 22d3aac

Please sign in to comment.