Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a selection menu for the next spawn loadout #894

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Sources/Client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,18 @@ namespace spades {
}
}
yvt marked this conversation as resolved.
Show resolved Hide resolved

void Client::NextSpawnPressed() {
WeaponType weap = limbo->GetSelectedWeapon();
int team = limbo->GetSelectedTeam();
inGameLimbo = false;
if (team == 2)
team = 255;

this->hasNextSpawnConfig = true;
this->nextTeam = team;
this->nextWeapon = weap;
yvt marked this conversation as resolved.
Show resolved Hide resolved
}

void Client::ShowAlert(const std::string &contents, AlertType type) {
float timeout;
switch (type) {
Expand Down
5 changes: 5 additions & 0 deletions Sources/Client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,15 @@ namespace spades {

bool inGameLimbo;

bool hasNextSpawnConfig;
yvt marked this conversation as resolved.
Show resolved Hide resolved
yvt marked this conversation as resolved.
Show resolved Hide resolved
int nextTeam;
WeaponType nextWeapon;
yvt marked this conversation as resolved.
Show resolved Hide resolved

float GetLocalFireVibration();
void CaptureColor();
bool IsLimboViewActive();
void SpawnPressed();
void NextSpawnPressed();

Player *HotTrackedPlayer(hitTag_t *hitFlag);

Expand Down
10 changes: 10 additions & 0 deletions Sources/Client/Client_Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,16 @@ namespace spades {

if (player->IsAlive())
lastAliveTime = time;
else if (hasNextSpawnConfig) {
Player *p = world->GetLocalPlayer();
yvt marked this conversation as resolved.
Show resolved Hide resolved
if (p->GetTeamId() != nextTeam) {
net->SendTeamChange(nextTeam);
}
if (nextTeam != 2 && p->GetWeapon()->GetWeaponType() != nextWeapon) {
net->SendWeaponChange(nextWeapon);
}
hasNextSpawnConfig = false;
}

if (player->GetHealth() < lastHealth) {
// ouch!
Expand Down
13 changes: 12 additions & 1 deletion Sources/Client/LimboView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ namespace spades {

//! The "Spawn" button that you press when you're ready to "spawn".
items.push_back(MenuItem(MenuSpawn,
AABB2(left + contentsWidth - 266.f, firstY + 4.f, 256.f, 64.f),
AABB2(left + contentsWidth - 266.f, firstY, 256.f, 48.f),
_Tr("Client", "Spawn")));

//! The next spawn button to activate the settings the next time you spawn
items.push_back(MenuItem(MenuNextSpawn,
AABB2(left + contentsWidth - 266.f, firstY + 52.f, 256.f, 48.f),
_Tr("Client", "Set For Next Spawn")));

cursorPos = MakeVector2(renderer->ScreenWidth() * .5f, renderer->ScreenHeight() * .5f);

selectedTeam = 2;
Expand Down Expand Up @@ -116,6 +121,7 @@ namespace spades {
case MenuWeaponSMG: selectedWeapon = SMG_WEAPON; break;
case MenuWeaponShotgun: selectedWeapon = SHOTGUN_WEAPON; break;
case MenuSpawn: client->SpawnPressed(); break;
case MenuNextSpawn: client->NextSpawnPressed(); break;
}
}
}
Expand Down Expand Up @@ -156,6 +162,11 @@ namespace spades {
if (selectedTeam == 2) {
item.visible = false;
}
break;
case MenuNextSpawn:
if (client && client->GetWorld() && client->world->GetLocalPlayer() && client->world->GetLocalPlayer()->IsAlive() && client->world->GetLocalPlayer()->GetTeamId() >= 2)
item.visible = false;
yvt marked this conversation as resolved.
Show resolved Hide resolved
break;
default:;
}

Expand Down
3 changes: 2 additions & 1 deletion Sources/Client/LimboView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ namespace spades {
MenuWeaponRifle,
MenuWeaponSMG,
MenuWeaponShotgun,
MenuSpawn
MenuSpawn,
MenuNextSpawn
};
struct MenuItem {
MenuType type;
Expand Down