forked from SantiSev/jazz-jackrabbit-2-remake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aplicado muchos fixes y emprolijado la lista para joinear partidas. f…
…ixeados bugs de botones que seguian captando señales fuera de sus escenas. cambiados algunos colores de botones. testeado todos los posibles bugs, que pueden pasar mientras se joinea a una partida.
- Loading branch information
1 parent
634948f
commit 77ac104
Showing
16 changed files
with
250 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
#include "match_selector.h" | ||
|
||
MatchSelectorButton::MatchSelectorButton(SDL_Renderer* renderer, | ||
std::shared_ptr<engine::ResourcePool> resource_pool, | ||
SDL_Rect& d_rect, std::atomic<bool>& match_select_running, | ||
std::atomic<bool>& caracter_select_running, | ||
const std::string& label_info, uint16_t& selected_id, | ||
uint16_t& id_match): | ||
engine::Button(std::make_unique<engine::Label>(engine::Label( | ||
resource_pool->get_font(FONT), d_rect, {255, 255, 255, 255}, | ||
{0, 0, 0, 255}, label_info, renderer)), | ||
d_rect, {0, 0, 0, 255}, {255, 255, 255, 255}), | ||
MatchSelector::MatchSelector(SDL_Renderer* renderer, | ||
std::shared_ptr<engine::ResourcePool> resource_pool, int x, int y, | ||
std::atomic<bool>& match_select_running, | ||
std::atomic<bool>& caracter_select_running, | ||
std::atomic<bool>& is_joinning, const std::string& label_info, | ||
uint16_t id_match, uint16_t& selected_id): | ||
engine::Button(std::make_unique<engine::Label>( | ||
engine::Label(resource_pool->get_font(FONT), {x, y + 5, 280, 30}, | ||
{0, 0, 0, 255}, {0, 0, 0, 255}, label_info, renderer)), | ||
{x, y, 330, 40}, get_random_color(), get_random_color()), | ||
match_select_running(match_select_running), | ||
caracter_select_running(caracter_select_running), | ||
is_joinning(is_joinning), | ||
selected_id(selected_id), | ||
id_match(id_match) {} | ||
|
||
|
||
void MatchSelectorButton::on_click() { | ||
void MatchSelector::on_click() { | ||
#ifdef LOG | ||
std::cout << "Clicked Join match." << std::endl; | ||
#endif | ||
std::cout << "match button id: " << id_match << std::endl; | ||
selected_id = id_match; | ||
std::cout << "selected id: " << selected_id << std::endl; | ||
is_joinning.store(true); | ||
caracter_select_running.store(true); | ||
match_select_running.store(false); | ||
} | ||
|
||
MatchSelectorButton::~MatchSelectorButton() = default; | ||
SDL_Color MatchSelector::get_random_color() { | ||
const Uint8 minBrightValue = 128; | ||
Uint8 r = minBrightValue + rand() % (256 - minBrightValue); | ||
Uint8 g = minBrightValue + rand() % (256 - minBrightValue); | ||
Uint8 b = minBrightValue + rand() % (256 - minBrightValue); | ||
return SDL_Color{r, g, b, 255}; | ||
} | ||
|
||
MatchSelector::~MatchSelector() = default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "return_to_menu.h" | ||
|
||
ReturnToMenuButton::ReturnToMenuButton(SDL_Renderer* renderer, | ||
std::shared_ptr<engine::ResourcePool> resource_pool, | ||
SDL_Rect& d_rect, std::atomic<bool>& menu_running, | ||
std::atomic<bool>& match_select_running): | ||
engine::Button(std::make_unique<engine::Label>(engine::Label( | ||
resource_pool->get_font(FONT), {d_rect.x, d_rect.y, 50, d_rect.h}, | ||
{255, 255, 255, 255}, {0, 0, 0, 255}, "Return to menu", renderer)), | ||
d_rect, {0, 0, 0, 255}, {255, 255, 255, 255}), | ||
menu_running(menu_running), | ||
match_select_running(match_select_running) {} | ||
|
||
void ReturnToMenuButton::on_click() { | ||
#ifdef LOG | ||
std::cout << "Clicked Return to menu." << std::endl; | ||
#endif | ||
menu_running.store(true); | ||
match_select_running.store(false); | ||
} | ||
|
||
ReturnToMenuButton::~ReturnToMenuButton() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef TP_FINAL_RETURN_TO_MENU_H | ||
#define TP_FINAL_RETURN_TO_MENU_H | ||
|
||
#include <atomic> | ||
#include <memory> | ||
|
||
#include <SDL2/SDL.h> | ||
|
||
#include "../../common/assets.h" | ||
#include "../../game_engine/gui/basic/resource_pool.h" | ||
#include "../../game_engine/gui/widgets/button.h" | ||
#include "../../game_engine/gui/widgets/label.h" | ||
#include "../protocol/client_message_handler.h" | ||
|
||
class ReturnToMenuButton: public engine::Button { | ||
private: | ||
std::atomic<bool>& menu_running; | ||
std::atomic<bool>& match_select_running; | ||
|
||
public: | ||
ReturnToMenuButton(SDL_Renderer* renderer, std::shared_ptr<engine::ResourcePool> resource_pool, | ||
SDL_Rect& d_rect, std::atomic<bool>& menu_running, | ||
std::atomic<bool>& match_select_running); | ||
|
||
void on_click() override; | ||
|
||
~ReturnToMenuButton() override; | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.