Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file added assets/.goutputstream-WLDR82
Binary file not shown.
Binary file added assets/PARAFLOR-01[1].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/gfx/guns/bomb_hub.xcf
Binary file not shown.
Binary file modified assets/gfx/guns/guns.xcf
Binary file not shown.
Binary file modified assets/gfx/hud/guns_inventory.xcf
Binary file not shown.
Binary file added assets/gfx/listTeams/rusty-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/gui/hud_component/hud_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ void SdlHud::update_pointer_position(int x, int y) { pointer_component->update_p

bool SdlHud::start_game_click(int x, int y) { return controls_component->start_game_click(x, y); }


void SdlHud::update_winner(Team t) { scores_component->update__winner_score(t); }
void SdlHud::update_mute_icon() { scores_component->update_mute_icon(); }
1 change: 1 addition & 0 deletions client/gui/hud_component/hud_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class SdlHud {
void update_pointer_position(int x, int y);
void update_mute_icon();
bool start_game_click(int x, int y);
void update_winner(Team winner);

private:
void initialize_layout();
Expand Down
12 changes: 10 additions & 2 deletions client/gui/hud_component/hud_scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void HudScores::render_team_scores() {
paral_height);
parallelogram_blue.render(src_parallelogram1, dest_parallelogram1);

score_text.setTextString(std::to_string(0)); // TODO : Replace with actual score
score_text.setTextString(std::to_string(score_ct)); // TODO : Replace with actual score
score_text.render(Area(trapecio_x - paral_width / 4 + margin * 6, layout.padding * 3,
layout.size_width / 1.75, layout.size_height / 2));

Expand All @@ -59,7 +59,7 @@ void HudScores::render_team_scores() {
paral_height);
parallelogram_red.render(src_parallelogram, dest_parallelogram);

score_text.setTextString(std::to_string(0)); // TODO : Replace with actual score
score_text.setTextString(std::to_string(score_tt)); // TODO : Replace with actual score
score_text.render(
Area(trapecio_x + trapecio_width + margin + paral_width / 2 - layout.size_width / 4,
layout.padding * 3, layout.size_width / 1.75, layout.size_height / 2));
Expand All @@ -83,3 +83,11 @@ void HudScores::render_mute_icon() {
}

void HudScores::update_mute_icon() { is_muted = !is_muted; }

void HudScores::update__winner_score(Team winner) {
if (winner == Team::CT) {
score_ct++;
} else if (winner == Team::TT) {
score_tt++;
}
}
3 changes: 3 additions & 0 deletions client/gui/hud_component/hud_scores.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ class HudScores {
SdlTexture parallelogram_red;
const HudLayout& layout;
bool is_muted = false;
int score_ct = 0;
int score_tt = 0;

public:
explicit HudScores(SdlWindow& window, const HudLayout& layout);
void render(const GameUpdate& state);
void render_mute_icon();
void update_mute_icon();
void update__winner_score(Team winner);

private:
void render_background();
Expand Down
10 changes: 6 additions & 4 deletions client/gui/map_view/sdl_world_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,28 @@ void SdlWorldItem::render() {
if (game_state.get_bomb().has_value()) {
const auto& bomb = game_state.get_bomb().value();
Vector2D pos = bomb.hitbox.get_pos();
double angle = bomb.hitbox.get_rotation_deg();
Area origin(0, 0, 24, 24);
Vector2D pos_cam = camera.get_screen_pos(pos);
Area dest(pos_cam.get_x(), pos_cam.get_y(), 32, 32);
if (camera.can_see(pos_cam))
bomb_t.render(origin, dest);
bomb_t.render(origin, dest, angle);
}
for (const auto& [gun_type, gun_item]: // cppcheck-suppress[unassignedVariable]
game_state.get_dropped_guns()) {
Vector2D pos = gun_item.get_pos();
float angle = gun_item.get_rotation_deg();
if (!camera.can_see(pos))
return;
Vector2D pos_cam = camera.get_screen_pos(pos);
Area dest(pos_cam.get_x(), pos_cam.get_y(), 32, 32);
Area origin(10, 0, 54, 32);
if (gun_type == GunType::AWP) {
awp_t.render(origin, dest);
awp_t.render(origin, dest, angle);
} else if (gun_type == GunType::M3) {
m3_t.render(origin, dest);
m3_t.render(origin, dest, angle);
} else if (gun_type == GunType::AK47) {
ak_t.render(origin, dest);
ak_t.render(origin, dest, angle);
}
}
}
14 changes: 11 additions & 3 deletions client/gui/pre_game_view/list_skins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@ skinSelect::skinSelect(SdlWindow& window, const GameUpdate& state, const std::st
background(BACKGROUND1_PATH, window),
skins_tt(SKIN_PATHS_TT, window),
skins_ct(SKIN_PATHS_CT, window),
skin_labels{{SdlText(TEXT1_PATH, 100, {255, 255, 255, 255}, window),
SdlText(TEXT1_PATH, 100, {255, 255, 255, 255}, window),
SdlText(TEXT1_PATH, 100, {255, 255, 255, 255}, window),
SdlText(TEXT1_PATH, 100, {255, 255, 255, 255}, window)}},
selected_skin(-1),
active(true) {


for (int i = 0; i < 4; ++i) {
skin_labels[i].setTextString("Skin " + std::to_string(i + 1));
}


float BASE_WIDTH = 800.0f;
float BASE_HEIGHT = 600.0f;

Expand Down Expand Up @@ -91,10 +101,8 @@ void skinSelect::renderSkins() {
SDL_RenderDrawRect(window.getRenderer(), &highlight);
}

// Draw skin label
text.setTextString("Skin " + std::to_string(i + 1));
Area label_area(x + 10, y + slot_height + 10, 100, 30);
text.render(label_area);
skin_labels[i].render(label_area);
}
}

Expand Down
3 changes: 2 additions & 1 deletion client/gui/pre_game_view/list_skins.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <algorithm>
#include <array>
#include <string>
#include <vector>

Expand All @@ -12,7 +13,6 @@
#include "common/commands.h"
#include "common/message.h"
#include "common/models.h"

class skinSelect {
public:
explicit skinSelect(SdlWindow& window, const GameUpdate& state, const std::string& player_name);
Expand All @@ -36,6 +36,7 @@ class skinSelect {
SdlTexture background;
SdlTexture skins_tt;
SdlTexture skins_ct;
std::array<SdlText, 4> skin_labels;

float widthRatio, heightRatio, scaleRatio;
float slot_width, slot_height;
Expand Down
84 changes: 40 additions & 44 deletions client/gui/pre_game_view/list_teams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ listTeams::listTeams(SdlWindow& window, const GameUpdate& state, const std::stri
DISPLAY_HEIGHT(window.getHeight()),
text(TEXT_PATH, 100, {255, 255, 255, 255}, window),
smaller_text(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window),
team_labels{{SdlText(TEXT_PATH, 100, {255, 255, 255, 255}, window),
SdlText(TEXT_PATH, 100, {255, 255, 255, 255}, window)}},
tt_descriptions{SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window),
SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window),
SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window)},
ct_descriptions{SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window),
SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window),
SdlText(SMALLER_TEXT_PATH, 100, {255, 255, 255, 255}, window)},
rectangulo_horizontal(RECTANGULE_HORIZONTAL, window),
background(BACKGROUND_PATH_1, window),
terrorist(TERRORIST_PATH, window),
Expand Down Expand Up @@ -54,8 +62,22 @@ listTeams::listTeams(SdlWindow& window, const GameUpdate& state, const std::stri
select_skin_height = 50 * heightRatio;
select_skin_x = DISPLAY_WIDTH - select_skin_width - padding * 4;
select_skin_y = padding * 4;
// Set preloaded labels
team_labels[0].setTextString("Terrorist");
team_labels[1].setTextString("Counter-Terrorist");

// Set TT descriptions
tt_descriptions[0].setTextString("Plant the bomb and defend it until ");
tt_descriptions[1].setTextString("it explodes, or eliminate all ");
tt_descriptions[2].setTextString("Counter-Terrorists to secure victory.");

// Set CT descriptions
ct_descriptions[0].setTextString("Prevent the terrorist from ");
ct_descriptions[1].setTextString("detonating their bomb or ");
ct_descriptions[2].setTextString("eliminate them all to win.");
}


void listTeams::render() {
if (active) {
Area src(0, 0, 250, 250);
Expand Down Expand Up @@ -101,58 +123,32 @@ void listTeams::renderSlots() {
Area terrorist_dest(terrorist_x, terrorist_y, slot_width, slot_height);
Area counter_terrorist_dest(counter_terrorist_x, counter_terrorist_y, slot_width, slot_height);

// Render the terrorist and counter-terrorist images
terrorist.render(src, terrorist_dest);
counter_terrorist.render(src1, counter_terrorist_dest);

// Add text below the terrorist image
text.setTextString("Terrorist");
Area terrorist_text_dest(terrorist_x + (size_slots_w) / 4,
Area terrorist_text_dest(terrorist_x + size_slots_w / 4,
terrorist_y + DISPLAY_WIDTH * 0.30 - 50, 150, 50);
text.render(terrorist_text_dest);

// Add text below the counter-terrorist image
text.setTextString("Counter-Terrorist");
Area counter_terrorist_text_dest(counter_terrorist_x + (size_slots_w) / 4,
counter_terrorist_y + DISPLAY_WIDTH * 0.30 - 50, 200, 50);
text.render(counter_terrorist_text_dest);
team_labels[0].render(terrorist_text_dest);

int text_terrorist_y = terrorist_y + DISPLAY_WIDTH * 0.30;
int text_counter_terrorist_y = counter_terrorist_y + DISPLAY_WIDTH * 0.30;
int text_terrorist_x = terrorist_x + (size_slots_w) / 4;
int text_counter_terrorist_x = counter_terrorist_x + (size_slots_w) / 4;
Area counter_text_dest(counter_terrorist_x + size_slots_w / 4,
counter_terrorist_y + DISPLAY_WIDTH * 0.30 - 50, 200, 50);
team_labels[1].render(counter_text_dest);

std::optional<Team> team_choosen = game_state.get_players().at(player_name).get_optional_team();

if (team_choosen == Team::TT) {
smaller_text.setTextString("Plant the bomb and defend it until ");
Area terrorist_text_dest_1(text_terrorist_x + padding, text_terrorist_y, 400 * scale, 50);
smaller_text.render(terrorist_text_dest_1);

smaller_text.setTextString("it explodes, or eliminate all ");
Area terrorist_text_dest_2(text_terrorist_x + padding, text_terrorist_y + padding * 3,
400 * scale, 50);
smaller_text.render(terrorist_text_dest_2);

smaller_text.setTextString("Counter-Terrorists to secure victory.");
Area terrorist_text_dest_3(text_terrorist_x + padding, text_terrorist_y + padding * 6,
400 * scale, 50);
smaller_text.render(terrorist_text_dest_3);
} else {
smaller_text.setTextString("Prevent the terrorist from ");
Area counter_terrorist_text_dest_1(text_counter_terrorist_x + padding,
text_counter_terrorist_y, 400 * scale, 50);
smaller_text.render(counter_terrorist_text_dest_1);

smaller_text.setTextString("detonating their bomb or ");
Area counter_terrorist_text_dest_2(text_counter_terrorist_x + padding,
text_counter_terrorist_y + padding * 3, 400 * scale, 50);
smaller_text.render(counter_terrorist_text_dest_2);

smaller_text.setTextString("eliminate them all to win.");
Area counter_terrorist_text_dest_3(text_counter_terrorist_x + padding,
text_counter_terrorist_y + padding * 6, 400 * scale, 50);
smaller_text.render(counter_terrorist_text_dest_3);
int base_y_text = team_choosen == Team::TT ? terrorist_y + DISPLAY_WIDTH * 0.30 :
counter_terrorist_y + DISPLAY_WIDTH * 0.30;

int base_x_text = team_choosen == Team::TT ? terrorist_x + size_slots_w / 4 :
counter_terrorist_x + size_slots_w / 4;

for (int i = 0; i < 3; ++i) {
Area line_area(base_x_text + padding, base_y_text + padding * (i * 3), 400 * scale, 50);
if (team_choosen == Team::TT) {
tt_descriptions[i].render(line_area);
} else {
ct_descriptions[i].render(line_area);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions client/gui/pre_game_view/list_teams.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef LIST_TEAMS_H
#define LIST_TEAMS_H

#include <array>
#include <atomic>
#include <optional>
#include <string>
Expand Down Expand Up @@ -36,6 +37,11 @@ class listTeams {
int base_y;
SdlText text;
SdlText smaller_text;

std::array<SdlText, 2> team_labels;
std::array<SdlText, 3> tt_descriptions;
std::array<SdlText, 3> ct_descriptions;

SdlTexture rectangulo_horizontal;
SdlTexture background;
SdlTexture terrorist;
Expand Down
17 changes: 13 additions & 4 deletions client/gui/shop_view/shop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ shopDisplay::shopDisplay(SdlWindow& window, const GameUpdate& state):
gunNumber(std::string(GameConfig::Paths::FONT_PAT), 20, {255, 255, 255, 255}, window),
gun_buy(-1),
guns({{"1", "", "1000"}, {"2", "", "1500"}, {"3", "", "20"}}),
ammo({{"4", "", "200"},
{"5", "", "300"},
{"6", "", "400"},
{"7", "", "500"},
ammo({{"4", "AK47", "200"},
{"5", "M3", "300"},
{"6", "AWP", "400"},
{"7", "Glock", "500"},
{"8", "", ""}}) {

float BASE_WIDTH = 800.0f;
Expand Down Expand Up @@ -171,10 +171,19 @@ void shopDisplay::renderItem() {
Area iconDest(x + 30, y, size_guns_w - 60, size_guns_h + 10);
ammo_icons.render(src, iconDest);

// ID number
gunNumber.setTextString(ammo[i].id);
Area numDest(x, y - 10, 15, 15);
gunNumber.render(numDest);

// Gun name (new line)
if (!ammo[i].name.empty()) {
cost_money.setTextString(ammo[i].name); // You can use another font if needed
Area nameDest(x + 30, y + size_guns_h + 5, 100, 20); // Positioned under the icon
cost_money.render(nameDest);
}

// Price
if (ammo[i].price.empty()) {
cost_money.setTextString("Not Available");
} else {
Expand Down
1 change: 0 additions & 1 deletion client/gui/shop_view/shop.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@ class shopDisplay {
std::vector<GameConfig::AmmoInfo> ammo; // Moved ammo into the class
void renderSlots();
void renderItem();
void get_item_slots(int id_slot);
};
#endif // SHOP_DISPLAY_H
15 changes: 11 additions & 4 deletions client/gui/window_elements/sdl_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,18 @@ SDL_Texture* SdlText::createTextureFromText(const std::string& text) {
return newTexture;
}

void SdlText::setTextString(const std::string& text) {
if (texture) {

void SdlText::setTextString(const std::string& str) {
if (str == current_text)
return; // No change
current_text = str;

if (texture)
SDL_DestroyTexture(texture);
}
texture = createTextureFromText(text);

SDL_Surface* surface = TTF_RenderText_Blended(font, current_text.c_str(), color);
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_FreeSurface(surface);
}

int SdlText::render(const Area& dest) const {
Expand Down
4 changes: 2 additions & 2 deletions client/gui/window_elements/sdl_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class SdlText {
SDL_Renderer* renderer;
SDL_Texture* texture;
TTF_Font* font;
std::string current_text;
SDL_Color color;

SDL_Texture* createTextureFromText(const std::string& text);

public:
SdlText(const std::string& fontFile, int fontSize, SDL_Color color, const SdlWindow& window);
~SdlText();
void setTextString(const std::string& text);
int render(const Area& dest) const;
SDL_Texture* getText() const { return texture; }
SDL_Texture* createTextureFromText(const std::string& text);
};

#endif // SDLTEXT_H
12 changes: 12 additions & 0 deletions client/gui/window_elements/sdl_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,24 @@ void SdlTexture::render(int x, int y, SDL_Rect* clip, double angle, SDL_Point* c

void SdlTexture::render(int x, int y, double angle) { render(x, y, nullptr, angle); }


void SdlTexture::render(const Area& src, const Area& dest, double angle) const {
SDL_Rect sdlSrc = {src.getX(), src.getY(), src.getWidth(), src.getHeight()};
SDL_Rect sdlDest = {dest.getX(), dest.getY(), dest.getWidth(), dest.getHeight()};

if (SDL_RenderCopyEx(this->renderer, this->texture, &sdlSrc, &sdlDest, angle, nullptr,
SDL_FLIP_NONE) != 0) {
std::cout << "Render failed: " << SDL_GetError() << std::endl;
}
}

void SdlTexture::render(int x, int y, int w, int h, SDL_Rect* clip, double angle, SDL_Point* center,
SDL_RendererFlip flip) {
SDL_Rect renderQuad = {x, y, w, h};

if (SDL_RenderCopyEx(this->renderer, this->texture, clip, &renderQuad, angle, center, flip) !=
0) {

std::cout << "Render failed: " << SDL_GetError() << std::endl;
}
}
Loading