Fully functional playerlist
Includes state changing!
This commit is contained in:
parent
4538111f56
commit
6be70d9beb
@ -1,6 +1,6 @@
|
||||
# Cathook Training Software
|
||||

|
||||
[](https://circleci.com/gh/nullworks/cathook) (Cathook developement takes place on `testing` branch)
|
||||
[](https://circleci.com/gh/nullworks/cathook)
|
||||
|
||||
## Risk of VAC detection
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
<TData height="15"><Text padding="2 0 0 4" id="steam">N/A</Text></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="username" team_color="1">N/A</Text></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="class" team_color="1">N/A</Text></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="alivestate">N/A</Text></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="state">N/A</Text></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="online">N/A</Text></TData>
|
||||
<TData height="15"><ColorSelector height="fill" width="40" id="color"/></TData>
|
||||
<TData height="15"><Text padding="2 0 0 4" id="kick">Kick</Text></TData>
|
||||
</TRow>
|
||||
</Prefab>
|
||||
</Prefab>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<Window width="content" height="content" x="200" y="200" name="Playerlist (Incomplete. Use cat_pl_set_state instead!)">
|
||||
<Window width="content" height="content" x="200" y="200" name="Playerlist">
|
||||
<Table id="special-player-list">
|
||||
<Column width="25"/>
|
||||
<Column width="70" />
|
||||
<Column width="120"/>
|
||||
<Column width="50"/>
|
||||
<Column width="60"/>
|
||||
<Column width="60"/>
|
||||
<Column width="70"/>
|
||||
<Column width="40"/>
|
||||
<Column width="60"/>
|
||||
<TRow id="header">
|
||||
@ -13,8 +13,8 @@
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">SteamID</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Username</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Class</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">State</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Online</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Status</Text></TData>
|
||||
<TData height="15" width="70"><Text height="fill" width="fill" padding="0 0 0 4">State</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Color</Text></TData>
|
||||
<TData height="15"><Text height="fill" padding="0 0 0 4">Kick</Text></TData>
|
||||
</TRow>
|
||||
|
@ -16,7 +16,7 @@ constexpr int SERIALIZE_VERSION = 3;
|
||||
|
||||
enum class k_EState
|
||||
{
|
||||
DEFAULT,
|
||||
DEFAULT = 0,
|
||||
FRIEND,
|
||||
RAGE,
|
||||
IPC,
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
int classId;
|
||||
int teamId;
|
||||
bool dead;
|
||||
std::string state;
|
||||
};
|
||||
|
||||
class PlayerListController : public IMessageHandler
|
||||
@ -27,6 +28,7 @@ class PlayerListController : public IMessageHandler
|
||||
public:
|
||||
typedef std::function<void(int)> kick_callback_type;
|
||||
typedef std::function<void(unsigned)> open_steam_callback_type;
|
||||
typedef std::function<void(unsigned /*steamid*/, int /*userid*/)> change_state_callback_type;
|
||||
|
||||
explicit PlayerListController(Table &table);
|
||||
|
||||
@ -45,7 +47,7 @@ public:
|
||||
|
||||
void updatePlayerLifeState(int id, bool dead);
|
||||
|
||||
void updatePlayerCO(int id);
|
||||
void updatePlayerState(int id, std::string state);
|
||||
|
||||
void removePlayer(int id);
|
||||
|
||||
@ -56,6 +58,8 @@ public:
|
||||
|
||||
void setOpenSteamCallback(open_steam_callback_type callback);
|
||||
|
||||
void setChangeStateCallback(change_state_callback_type callback);
|
||||
|
||||
void updateRow(TRow *row);
|
||||
|
||||
void changeRowColor(TRow *row, const rgba_t &color);
|
||||
@ -66,5 +70,6 @@ public:
|
||||
|
||||
kick_callback_type cb_kick;
|
||||
open_steam_callback_type cb_open_steam;
|
||||
change_state_callback_type cb_change_state;
|
||||
};
|
||||
} // namespace zerokernel::special
|
||||
|
@ -346,12 +346,8 @@ void CreateMove()
|
||||
if (hacks::shared::backtrack::isBacktrackEnabled)
|
||||
{
|
||||
if (*hacks::shared::backtrack::latency <= 190 && doRageBackstab())
|
||||
{
|
||||
logging::Info("Ragebackstab");
|
||||
break;
|
||||
}
|
||||
if (doBacktrackStab())
|
||||
logging::Info("Backtrackstab");
|
||||
doBacktrackStab();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ bool trace::FilterDefault::ShouldHitEntity(IHandleEntity *handle, int mask)
|
||||
{
|
||||
// TODO magic numbers: invisible entity ids
|
||||
case CL_CLASS(CFuncRespawnRoomVisualizer):
|
||||
case CL_CLASS(CTFKnife):
|
||||
case CL_CLASS(CTFMedigunShield):
|
||||
case CL_CLASS(CFuncAreaPortalWindow):
|
||||
return false;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ static zerokernel::special::PlayerListData createPlayerListData(int userid)
|
||||
data.teamId = g_pPlayerResource->getTeam(idx) - 1;
|
||||
data.dead = !g_pPlayerResource->isAlive(idx);
|
||||
data.steam = info.friendsID;
|
||||
data.state = playerlist::k_pszNames[static_cast<int>(playerlist::AccessData(info.friendsID).state)];
|
||||
snprintf(data.name, 31, "%s", info.name);
|
||||
return data;
|
||||
}
|
||||
@ -95,6 +96,14 @@ static void initPlayerlist()
|
||||
id.Set(steam, EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual);
|
||||
g_ISteamFriends->ActivateGameOverlayToUser("steamid", id);
|
||||
});
|
||||
controller->setChangeStateCallback([](unsigned steam, int userid) {
|
||||
auto &pl = playerlist::AccessData(steam);
|
||||
pl.state = playerlist::k_EState((int) pl.state + 1);
|
||||
if ((int) pl.state > (int) playerlist::k_EState::STATE_LAST)
|
||||
pl.state = playerlist::k_EState(0);
|
||||
logging::Info("%s", std::to_string(steam).c_str());
|
||||
controller->updatePlayerState(userid, playerlist::k_Names[(int) pl.state]);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -12,12 +12,12 @@
|
||||
Created on 26.07.18.
|
||||
*/
|
||||
|
||||
static settings::RVariable<rgba_t> color_team_red{ "zk.style.player-list.team.red", "ff0000" };
|
||||
static settings::RVariable<rgba_t> color_team_red{ "zk.style.player-list.team.red", "ce1015" };
|
||||
static settings::RVariable<rgba_t> color_team_red_dead{ "zk.style.player-list.team.red-dead", "660000" };
|
||||
static settings::RVariable<rgba_t> color_team_blue{ "zk.style.player-list.team.blue", "0000ff" };
|
||||
static settings::RVariable<rgba_t> color_team_blue_dead{ "zk.style.player-list.team.blue-dead", "000066" };
|
||||
static settings::RVariable<rgba_t> color_team_other{ "zk.style.player-list.team.other", "ffffff" };
|
||||
static settings::RVariable<rgba_t> color_team_other_dead{ "zk.style.player-list.team.other-dead", "666666" };
|
||||
static settings::RVariable<rgba_t> color_team_other{ "zk.style.player-list.team.other", "E6E6E6" };
|
||||
static settings::RVariable<rgba_t> color_team_other_dead{ "zk.style.player-list.team.other-dead", "E6E6E6" };
|
||||
|
||||
static const char *class_names[] = { "Unknown", "Scout", "Sniper", "Soldier", "Demoman", "Medic", "Heavy", "Pyro", "Spy", "Engineer" };
|
||||
|
||||
@ -35,6 +35,11 @@ void zerokernel::special::PlayerListController::setOpenSteamCallback(zerokernel:
|
||||
cb_open_steam = std::move(callback);
|
||||
}
|
||||
|
||||
void zerokernel::special::PlayerListController::setChangeStateCallback(zerokernel::special::PlayerListController::change_state_callback_type callback)
|
||||
{
|
||||
cb_change_state = std::move(callback);
|
||||
}
|
||||
|
||||
void zerokernel::special::PlayerListController::handleMessage(zerokernel::Message &msg, bool is_relayed)
|
||||
{
|
||||
if (is_relayed)
|
||||
@ -63,6 +68,17 @@ void zerokernel::special::PlayerListController::handleMessage(zerokernel::Messag
|
||||
cb_kick((int) msg.sender->kv["user_id"]);
|
||||
}
|
||||
}
|
||||
if (action == "change_state")
|
||||
{
|
||||
auto steamId = (std::string) msg.sender->kv["steam_id"];
|
||||
errno = 0;
|
||||
auto id = std::strtoul(steamId.c_str(), nullptr, 10);
|
||||
if (!errno)
|
||||
{
|
||||
if (cb_change_state)
|
||||
cb_change_state(id, (int) msg.sender->kv["user_id"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void zerokernel::special::PlayerListController::removeAll()
|
||||
@ -143,6 +159,24 @@ void zerokernel::special::PlayerListController::updatePlayerClass(int id, int cl
|
||||
});
|
||||
}
|
||||
|
||||
void zerokernel::special::PlayerListController::updatePlayerState(int id, std::string state_string)
|
||||
{
|
||||
table.iterateObjects([this, id, state_string](BaseMenuObject *a) {
|
||||
auto row = dynamic_cast<TRow *>(a);
|
||||
// Shouldn't happen
|
||||
if (row == nullptr)
|
||||
return;
|
||||
if ((int) row->kv["player_id"] == id)
|
||||
{
|
||||
auto state = dynamic_cast<Text *>(row->getElementById("state"));
|
||||
if (state)
|
||||
state->kv["state"] = state_string;
|
||||
updateRow(row);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void zerokernel::special::PlayerListController::addPlayer(int id, zerokernel::special::PlayerListData data)
|
||||
{
|
||||
auto row = ObjectFactory::createFromPrefab("player-list-row");
|
||||
@ -158,6 +192,7 @@ void zerokernel::special::PlayerListController::addPlayer(int id, zerokernel::sp
|
||||
auto steam = dynamic_cast<Text *>(trow->getElementById("steam"));
|
||||
auto username = dynamic_cast<Text *>(trow->getElementById("username"));
|
||||
auto kick = dynamic_cast<Text *>(trow->getElementById("kick"));
|
||||
auto state = dynamic_cast<Text *>(trow->getElementById("state"));
|
||||
if (uid)
|
||||
uid->set(std::to_string(id));
|
||||
if (steam)
|
||||
@ -175,6 +210,19 @@ void zerokernel::special::PlayerListController::addPlayer(int id, zerokernel::sp
|
||||
kick->kv["action"] = "kick";
|
||||
kick->addMessageHandler(*this);
|
||||
}
|
||||
if (state)
|
||||
{
|
||||
state->parent->bb.resize(70, 15);
|
||||
state->bb.width.setFill();
|
||||
state->bb.height.setFill();
|
||||
state->bb.updateFillSize();
|
||||
|
||||
state->kv["state"] = data.state;
|
||||
state->kv["user_id"] = id;
|
||||
state->kv["steam_id"] = std::to_string(data.steam);
|
||||
state->kv["action"] = "change_state";
|
||||
state->addMessageHandler(*this);
|
||||
}
|
||||
updateRow(trow);
|
||||
table.addObject(std::move(row));
|
||||
}
|
||||
@ -224,9 +272,15 @@ void zerokernel::special::PlayerListController::updateRow(zerokernel::TRow *row)
|
||||
changeRowColor(row, dead ? *color_team_other_dead : *color_team_other);
|
||||
}
|
||||
|
||||
auto el = dynamic_cast<Text *>(row->getElementById("class"));
|
||||
auto el = dynamic_cast<Text *>(row->getElementById("class"));
|
||||
auto alivestate = dynamic_cast<Text *>(row->getElementById("alivestate"));
|
||||
auto state = dynamic_cast<Text *>(row->getElementById("state"));
|
||||
if (el)
|
||||
{
|
||||
el->set(class_names[classId]);
|
||||
}
|
||||
if (alivestate)
|
||||
alivestate->set(dead ? "Dead" : "Alive");
|
||||
if (state)
|
||||
state->set(static_cast<std::string>(state->kv["state"]));
|
||||
}
|
||||
|
Reference in New Issue
Block a user