UPD: Added LobbyScene
This commit is contained in:
parent
6c2f580134
commit
452bf92e20
@ -329,6 +329,10 @@ add_executable(ColorRace
|
||||
game/src/multiplayer/LudoGameClient.cpp
|
||||
game/src/multiplayer/LudoGameClient.h
|
||||
game/src/multiplayer/LudoNetworkEvents.h
|
||||
game/src/multiplayer/lobby/LobbyScene.cpp
|
||||
game/src/multiplayer/lobby/LobbyScene.h
|
||||
game/src/multiplayer/lobby/LobbyUiLayer.cpp
|
||||
game/src/multiplayer/lobby/LobbyUiLayer.h
|
||||
)
|
||||
|
||||
target_link_libraries(ColorRace PRIVATE
|
||||
|
||||
@ -22,6 +22,8 @@ namespace engine {
|
||||
using T = std::decay_t<decltype(e)>;
|
||||
if constexpr (std::is_same_v<T, QuitRequested>) {
|
||||
m_window->requestWindowClose();
|
||||
} else if constexpr (std::is_same_v<T, SceneSwitchRequested>) {
|
||||
m_sceneManager.switchTo(e.nextScene, std::move(e.onSceneLoaded));
|
||||
}
|
||||
}, event);
|
||||
});
|
||||
|
||||
@ -6,8 +6,15 @@
|
||||
#define COLORRACE_APPLICATIONEVENTS_H
|
||||
#include <variant>
|
||||
|
||||
#include "layer/Scene.h"
|
||||
|
||||
struct QuitRequested {};
|
||||
|
||||
struct SceneSwitchRequested {
|
||||
std::unique_ptr<engine::Scene> nextScene;
|
||||
std::function<void()> onSceneLoaded;
|
||||
};
|
||||
|
||||
|
||||
using ApplicationEvents = std::variant<QuitRequested>;
|
||||
#endif //COLORRACE_APPLICATIONEVENTS_H
|
||||
|
||||
2
external/NetworkCore
vendored
2
external/NetworkCore
vendored
@ -1 +1 @@
|
||||
Subproject commit 944f2f63e06e1d368f85c11916046312b1d0067f
|
||||
Subproject commit 79214c855ac1c414fe85ffe76af4e2e57b8305ec
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include "imgui.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "multiplayer/lobby/LobbyScene.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
void MainMenuUiLayer::onRender() {
|
||||
@ -70,7 +71,8 @@ void MainMenuUiLayer::onAttachImpl() {
|
||||
if (e.success) {
|
||||
spdlog::info("Received positive Connection Result");
|
||||
m_connectionError = false;
|
||||
m_closeConnectPopup = true;
|
||||
std::unique_ptr<LobbyScene> lobbyScene = std::make_unique<LobbyScene>(m_applicationEventBus, getInputStack(), getKeyboard(), getMouse());
|
||||
|
||||
} else {
|
||||
spdlog::info("Received negative Connection Result");
|
||||
m_connectionError = true;
|
||||
|
||||
19
game/src/multiplayer/lobby/LobbyScene.cpp
Normal file
19
game/src/multiplayer/lobby/LobbyScene.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by sebastian on 06.08.26.
|
||||
//
|
||||
|
||||
#include "LobbyScene.h"
|
||||
|
||||
std::vector<engine::AssetRequest> LobbyScene::getRequiredAssets() const {
|
||||
std::vector<engine::AssetRequest> requests;
|
||||
requests.emplace_back(engine::TextureRequest("lobby_background", "assets/textures/multiplayer_lobby.png"));
|
||||
return requests;
|
||||
}
|
||||
|
||||
void LobbyScene::onEnter() {
|
||||
Scene::onEnter();
|
||||
}
|
||||
|
||||
void LobbyScene::onExit() {
|
||||
Scene::onExit();
|
||||
}
|
||||
23
game/src/multiplayer/lobby/LobbyScene.h
Normal file
23
game/src/multiplayer/lobby/LobbyScene.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by sebastian on 06.08.26.
|
||||
//
|
||||
|
||||
#ifndef COLORRACE_LOBBYSCENE_H
|
||||
#define COLORRACE_LOBBYSCENE_H
|
||||
#include "layer/Scene.h"
|
||||
|
||||
|
||||
class LobbyScene : public engine::Scene {
|
||||
public:
|
||||
LobbyScene(const std::shared_ptr<engine::EventBus<ApplicationEvents>> &applicationEventbus,
|
||||
engine::InputContextStack &inputStack, engine::Keyboard &keyboard, engine::Mouse &mouse)
|
||||
: Scene(applicationEventbus, inputStack, keyboard, mouse) {
|
||||
}
|
||||
|
||||
std::vector<engine::AssetRequest> getRequiredAssets() const override;
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
};
|
||||
|
||||
|
||||
#endif //COLORRACE_LOBBYSCENE_H
|
||||
19
game/src/multiplayer/lobby/LobbyUiLayer.cpp
Normal file
19
game/src/multiplayer/lobby/LobbyUiLayer.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by sebastian on 06.08.26.
|
||||
//
|
||||
|
||||
#include "LobbyUiLayer.h"
|
||||
|
||||
void LobbyUiLayer::onAttachImpl() {
|
||||
Layer::onAttachImpl();
|
||||
|
||||
auto backgroundTexture = m_assetManager.getTexture("lobby_background");
|
||||
|
||||
backgroundImage = std::make_unique<engine::GUITexture>(backgroundTexture, glm::vec2(0,0), glm::vec2(1,1));
|
||||
}
|
||||
|
||||
void LobbyUiLayer::onRender() {
|
||||
std::vector<engine::GUITexture> guiElements;
|
||||
guiElements.emplace_back(*backgroundImage);
|
||||
m_guiRenderer.render(guiElements);
|
||||
}
|
||||
40
game/src/multiplayer/lobby/LobbyUiLayer.h
Normal file
40
game/src/multiplayer/lobby/LobbyUiLayer.h
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// Created by sebastian on 06.08.26.
|
||||
//
|
||||
|
||||
#ifndef COLORRACE_LOBBYUILAYER_H
|
||||
#define COLORRACE_LOBBYUILAYER_H
|
||||
#include "layer/Layer.h"
|
||||
#include "loader/assets/AssetManager.h"
|
||||
#include "renderer/GuiRenderer.h"
|
||||
#include "renderer/ui/GUITexture.h"
|
||||
|
||||
|
||||
class LobbyUiLayer : public engine::Layer {
|
||||
public:
|
||||
LobbyUiLayer(engine::Keyboard &keyboard, engine::Mouse &mouse,
|
||||
engine::EventBus<engine::animation::AnimationMarkerEvent> &animationEventBus, engine::AssetManager& assetManager)
|
||||
: Layer(keyboard, mouse, animationEventBus), m_assetManager(assetManager) {
|
||||
}
|
||||
|
||||
LobbyUiLayer(engine::Keyboard &keyboard, engine::Mouse &mouse,
|
||||
engine::EventBus<engine::animation::AnimationMarkerEvent> &animationEventBus,
|
||||
const std::shared_ptr<engine::EventBus<std::variant<QuitRequested>>> &applicationEventBus, engine::AssetManager& assetManager)
|
||||
: Layer(keyboard, mouse, animationEventBus, applicationEventBus), m_assetManager(assetManager) {
|
||||
}
|
||||
|
||||
void onRender() override;
|
||||
void onUpdate(float deltaTime) override;
|
||||
|
||||
protected:
|
||||
void onAttachImpl() override;
|
||||
void onDetachImpl() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<engine::GUITexture> backgroundImage;
|
||||
engine::AssetManager& m_assetManager;
|
||||
engine::renderer::GuiRenderer m_guiRenderer;
|
||||
};
|
||||
|
||||
|
||||
#endif //COLORRACE_LOBBYUILAYER_H
|
||||
Loading…
Reference in New Issue
Block a user