Compare commits
9 Commits
fd61870ebe
...
8880056b1c
| Author | SHA1 | Date | |
|---|---|---|---|
| 8880056b1c | |||
| 9bb5c85f41 | |||
| c6c811ca17 | |||
| 40c551a4dc | |||
| a5bb2f74dd | |||
| d9cc43a7a1 | |||
| 9a297026cd | |||
| 2f141698ad | |||
| af5f084234 |
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace blitz {
|
||||
namespace maths {
|
||||
|
||||
class EMASmoother {
|
||||
private:
|
||||
@@ -16,4 +17,5 @@ class EMASmoother {
|
||||
void SetSmoothingTime(float t);
|
||||
};
|
||||
|
||||
} // namespace maths
|
||||
} // namespace blitz
|
||||
@@ -43,6 +43,8 @@ class ObjectNotifier {
|
||||
|
||||
/**
|
||||
* \brief Notify listeners that were bound
|
||||
* \param function the function to call
|
||||
* \param args the parameters of the function to call
|
||||
*/
|
||||
template <typename Func, typename... Args>
|
||||
void NotifyListeners(Func function, Args... args) const {
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace blitz {
|
||||
|
||||
class DataBuffer;
|
||||
|
||||
namespace protocol {
|
||||
|
||||
/**
|
||||
* \class VarInt
|
||||
* \brief Variable-length format such that smaller numbers use fewer bytes.
|
||||
@@ -55,4 +57,5 @@ class VarInt {
|
||||
friend DataBuffer& operator>>(DataBuffer& in, VarInt& var);
|
||||
};
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace blitz
|
||||
@@ -20,11 +20,11 @@ struct ColoredPart {
|
||||
/**
|
||||
* \brief The color of the part.
|
||||
*/
|
||||
Vec4f color;
|
||||
Vec4f m_Color;
|
||||
/**
|
||||
* \brief The text of the part.
|
||||
*/
|
||||
std::string text;
|
||||
std::string m_Text;
|
||||
};
|
||||
|
||||
typedef std::vector<ColoredPart> ColoredText;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* \brief File containing the blitz::protocol::KeepAlivePacket class
|
||||
*/
|
||||
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
#include "blitz/protocol/Protocol.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace protocol {
|
||||
* \brief Represents information about a player.
|
||||
*/
|
||||
struct PlayerInfo {
|
||||
std::string name;
|
||||
std::string m_Name;
|
||||
};
|
||||
|
||||
typedef std::map<std::uint8_t, PlayerInfo> PlayerList;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "blitz/misc/ObjectNotifier.h"
|
||||
#include "blitz/misc/Time.h"
|
||||
#include "blitz/protocol/packets/ChatPacket.h"
|
||||
#include "client/Listeners.h"
|
||||
#include "client/config/BlitzConfig.h"
|
||||
#include "client/game/Listeners.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -14,19 +14,17 @@ namespace blitz {
|
||||
|
||||
static const int PlayerUpdatePosRate = 50;
|
||||
|
||||
namespace client {
|
||||
class ClientConnexion;
|
||||
class ClientGame;
|
||||
} // namespace client
|
||||
|
||||
namespace server {
|
||||
class Server;
|
||||
} // namespace server
|
||||
|
||||
namespace client {
|
||||
|
||||
class ClientConnexion;
|
||||
class ClientGame;
|
||||
|
||||
// Singleton
|
||||
class Client : public utils::ObjectNotifier<game::ClientListener>, public game::PlayerInputListener {
|
||||
class Client : public utils::ObjectNotifier<client::ClientListener>, public client::PlayerInputListener {
|
||||
private:
|
||||
std::unique_ptr<server::Server> m_Server;
|
||||
std::unique_ptr<client::ClientConnexion> m_Connexion;
|
||||
@@ -78,4 +76,5 @@ class Client : public utils::ObjectNotifier<game::ClientListener>, public game::
|
||||
void UpdatePosition(std::uint64_t delta);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
} // namespace blitz
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
#include "blitz/network/Connexion.h"
|
||||
|
||||
namespace blitz {
|
||||
namespace client {
|
||||
|
||||
class Client;
|
||||
|
||||
namespace client {
|
||||
|
||||
class ClientConnexion : public network::Connexion {
|
||||
private:
|
||||
Client* m_Client;
|
||||
|
||||
@@ -13,7 +13,7 @@ typedef std::vector<ColoredPart> ColoredText;
|
||||
|
||||
} // namespace protocol
|
||||
|
||||
namespace game {
|
||||
namespace client {
|
||||
|
||||
class PlayerInputListener {
|
||||
public:
|
||||
@@ -25,7 +25,7 @@ class ClientListener {
|
||||
public:
|
||||
virtual void OnTextChatReceived(const protocol::ColoredText& text) {}
|
||||
virtual void OnSpectatorChange(game::PlayerID player) {}
|
||||
virtual void OnPlayerShoot(PlayerID player, const Vec3f& position, float yaw, float pitch) {}
|
||||
virtual void OnPlayerShoot(game::PlayerID player, const Vec3f& position, float yaw, float pitch) {}
|
||||
virtual void OnClientPlayerJoin() {}
|
||||
virtual void OnGameConfigUpdate() {}
|
||||
virtual void OnGameJoin() {}
|
||||
@@ -3,12 +3,14 @@
|
||||
#include "blitz/game/Listeners.h"
|
||||
#include "client/audio/AudioListener.h"
|
||||
#include "client/audio/AudioSource.h"
|
||||
#include "client/game/Listeners.h"
|
||||
#include "client/Listeners.h"
|
||||
#include <map>
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace game {
|
||||
class Player;
|
||||
@@ -21,9 +23,9 @@ struct PlayerSound {
|
||||
AudioSourcePtr m_Laser;
|
||||
};
|
||||
|
||||
class AudioManager : public game::ClientListener, public game::GameListener {
|
||||
class AudioManager : public client::ClientListener, public game::GameListener {
|
||||
private:
|
||||
Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
game::Player* m_Player;
|
||||
AudioListener m_Listener;
|
||||
AudioSourcePtr m_MenuMusic;
|
||||
@@ -32,7 +34,7 @@ class AudioManager : public game::ClientListener, public game::GameListener {
|
||||
std::map<game::PlayerID, PlayerSound> m_PlayerSources;
|
||||
|
||||
public:
|
||||
AudioManager(Client* client);
|
||||
AudioManager(client::Client* client);
|
||||
~AudioManager();
|
||||
|
||||
virtual void OnGameJoin() override;
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace input {
|
||||
|
||||
/**
|
||||
* \enum KeyAction
|
||||
* \brief Enum containing the key actions
|
||||
@@ -24,7 +26,9 @@ enum KeyAction {
|
||||
kaMax,
|
||||
};
|
||||
|
||||
typedef std::array<int, kaMax> Keybinds;
|
||||
} // namespace input
|
||||
|
||||
typedef std::array<int, input::kaMax> Keybinds;
|
||||
|
||||
/**
|
||||
* \class BlitzConfig
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
#include <vector>
|
||||
|
||||
namespace blitz {
|
||||
namespace client {
|
||||
|
||||
class Client;
|
||||
|
||||
namespace client {
|
||||
|
||||
class ClientGame : public game::Game, public protocol::PacketHandler {
|
||||
private:
|
||||
Client* m_Client;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -14,7 +16,7 @@ class BlitzGui : public GuiWidget {
|
||||
enum SubMenu { Main = 0 };
|
||||
|
||||
public:
|
||||
BlitzGui(Client* client, input::InputManager& inputManager);
|
||||
BlitzGui(client::Client* client, input::InputManager& inputManager);
|
||||
|
||||
virtual void Render() override;
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -14,7 +16,7 @@ class CreateGameMenu : public GuiWidget {
|
||||
input::InputManager& m_InputManager;
|
||||
|
||||
public:
|
||||
CreateGameMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager);
|
||||
CreateGameMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager);
|
||||
|
||||
virtual void Render() override;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
#include "GuiWidget.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
class CrossHair : public GuiWidget {
|
||||
@@ -10,7 +15,7 @@ class CrossHair : public GuiWidget {
|
||||
std::uint64_t m_CrossHairTexture;
|
||||
|
||||
public:
|
||||
CrossHair(Client* client);
|
||||
CrossHair(client::Client* client);
|
||||
|
||||
virtual void Render() override;
|
||||
};
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
class FPSMenu : public GuiWidget {
|
||||
public:
|
||||
FPSMenu(GuiWidget* parent, Client* client) : GuiWidget(parent, client) {}
|
||||
FPSMenu(GuiWidget* parent, client::Client* client) : GuiWidget(parent, client) {}
|
||||
|
||||
virtual void Render() override;
|
||||
};
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/Client.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
class GameChatGui : public GuiWidget, game::ClientListener {
|
||||
class GameChatGui : public GuiWidget, client::ClientListener {
|
||||
private:
|
||||
char InputBuf[256];
|
||||
std::vector<protocol::ColoredText> m_Lines;
|
||||
@@ -27,7 +31,7 @@ class GameChatGui : public GuiWidget, game::ClientListener {
|
||||
void DrawMini(const char* title, bool* p_open);
|
||||
|
||||
public:
|
||||
GameChatGui(GuiWidget* parent, Client* client, input::InputManager& inputManager);
|
||||
GameChatGui(GuiWidget* parent, client::Client* client, input::InputManager& inputManager);
|
||||
virtual ~GameChatGui();
|
||||
|
||||
virtual void OnTextChatReceived(const protocol::ColoredText& text) override;
|
||||
|
||||
@@ -7,19 +7,21 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
class GuiWidget {
|
||||
protected:
|
||||
bool m_Enabled;
|
||||
Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
GuiWidget* m_Parent;
|
||||
std::vector<std::unique_ptr<GuiWidget>> m_SubWidgets;
|
||||
|
||||
public:
|
||||
GuiWidget(GuiWidget* parent, Client* client) : m_Enabled(false), m_Client(client), m_Parent(parent) {}
|
||||
GuiWidget(GuiWidget* parent, client::Client* client) : m_Enabled(false), m_Client(client), m_Parent(parent) {}
|
||||
virtual ~GuiWidget() {}
|
||||
|
||||
void Enable() {
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace game {
|
||||
class Player;
|
||||
@@ -19,7 +21,7 @@ class Hud : public GuiWidget {
|
||||
utils::DelayTimer<float> m_Timer{5.0f};
|
||||
|
||||
public:
|
||||
Hud(GuiWidget* parent, Client* client);
|
||||
Hud(GuiWidget* parent, client::Client* client);
|
||||
virtual void Render() override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -14,7 +16,7 @@ class JoinGameMenu : public GuiWidget {
|
||||
input::InputManager& m_InputManager;
|
||||
|
||||
public:
|
||||
JoinGameMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager);
|
||||
JoinGameMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager);
|
||||
|
||||
virtual void Render() override;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
class LeaderBoardGui : public GuiWidget {
|
||||
private:
|
||||
@@ -12,7 +16,7 @@ class LeaderBoardGui : public GuiWidget {
|
||||
utils::DelayTimer<float> m_Timer{5.0f};
|
||||
|
||||
public:
|
||||
LeaderBoardGui(GuiWidget* parent, Client* client);
|
||||
LeaderBoardGui(GuiWidget* parent, client::Client* client);
|
||||
~LeaderBoardGui();
|
||||
|
||||
virtual void Render() override;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/game/Listeners.h"
|
||||
#include "client/Listeners.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace input {
|
||||
class InputManager;
|
||||
@@ -13,14 +15,14 @@ class InputManager;
|
||||
|
||||
namespace gui {
|
||||
|
||||
class MainMenu : public GuiWidget, public game::ClientListener {
|
||||
class MainMenu : public GuiWidget, public client::ClientListener {
|
||||
private:
|
||||
enum SubMenu { CREATE_MENU = 0, JOIN_MENU, OPTION_MENU };
|
||||
|
||||
input::InputManager& m_InputManager;
|
||||
|
||||
public:
|
||||
MainMenu(Client* client, input::InputManager& inputManager);
|
||||
MainMenu(client::Client* client, input::InputManager& inputManager);
|
||||
virtual ~MainMenu();
|
||||
|
||||
virtual void OnGameLeave() override;
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
#include "GuiWidget.h"
|
||||
#include "blitz/misc/Time.h"
|
||||
#include "client/config/BlitzConfig.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -20,11 +22,11 @@ class OptionsMenu : public GuiWidget, public input::InputListener {
|
||||
bool m_IsKeyPopupOpen;
|
||||
bool m_KeyPopupShouldClose;
|
||||
utils::Timer m_Timer{100};
|
||||
KeyAction m_CurrentAction;
|
||||
input::KeyAction m_CurrentAction;
|
||||
input::InputManager& m_InputManager;
|
||||
|
||||
public:
|
||||
OptionsMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager);
|
||||
OptionsMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager);
|
||||
virtual ~OptionsMenu();
|
||||
|
||||
virtual void Render() override;
|
||||
@@ -32,7 +34,7 @@ class OptionsMenu : public GuiWidget, public input::InputListener {
|
||||
virtual void OnKeyDown(int key) override;
|
||||
|
||||
private:
|
||||
std::string GetKeyActionCodeName(KeyAction);
|
||||
std::string GetKeyActionCodeName(input::KeyAction);
|
||||
void HotkeyBindingButton();
|
||||
void HotkeyBindingPopUp();
|
||||
};
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "GuiWidget.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
|
||||
class ServerGui : public GuiWidget {
|
||||
@@ -11,7 +16,7 @@ class ServerGui : public GuiWidget {
|
||||
input::InputManager& m_InputManager;
|
||||
|
||||
public:
|
||||
ServerGui(GuiWidget* parent, Client* client, input::InputManager& inputManager);
|
||||
ServerGui(GuiWidget* parent, client::Client* client, input::InputManager& inputManager);
|
||||
|
||||
virtual void Render() override;
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* \brief File containing the blitz::Display class
|
||||
*/
|
||||
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/display/PlayerController.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/input/PlayerController.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -14,12 +14,16 @@ class SDL_Window;
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace gui {
|
||||
class BlitzGui;
|
||||
} // namespace gui
|
||||
|
||||
namespace input {
|
||||
|
||||
/**
|
||||
* \class Display
|
||||
* \brief Class used to manage the display
|
||||
@@ -37,7 +41,7 @@ class Display {
|
||||
bool m_ShouldClose;
|
||||
bool m_FullScreen;
|
||||
|
||||
Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
input::InputManager& m_InputManager;
|
||||
std::unique_ptr<gui::BlitzGui> m_BlitzGui;
|
||||
input::PlayerController m_PlayerController;
|
||||
@@ -51,7 +55,7 @@ class Display {
|
||||
* \param client The client
|
||||
* \param inputManager The InputManager
|
||||
*/
|
||||
Display(int width, int height, const std::string& windowName, Client* client, input::InputManager& inputManager);
|
||||
Display(int width, int height, const std::string& windowName, client::Client* client, input::InputManager& inputManager);
|
||||
~Display();
|
||||
|
||||
/**
|
||||
@@ -112,4 +116,5 @@ class Display {
|
||||
void InitImGui();
|
||||
};
|
||||
|
||||
} // namespace input
|
||||
} // namespace blitz
|
||||
@@ -5,15 +5,17 @@
|
||||
* \brief File containing the blitz::input::PlayerController class.
|
||||
*/
|
||||
|
||||
#include "blitz/common/Smoothing.h"
|
||||
#include "blitz/maths/Smoothing.h"
|
||||
#include "blitz/misc/ObjectNotifier.h"
|
||||
#include "blitz/misc/Time.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/game/Listeners.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/Listeners.h"
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace game {
|
||||
|
||||
@@ -28,14 +30,14 @@ namespace input {
|
||||
* \details This class is responsible for handling player input and sending it to the server.
|
||||
* It also handles the player's velocity and position.
|
||||
*/
|
||||
class PlayerController : public utils::ObjectNotifier<game::PlayerInputListener>, game::ClientListener, InputListener {
|
||||
class PlayerController : public utils::ObjectNotifier<client::PlayerInputListener>, client::ClientListener, InputListener {
|
||||
private:
|
||||
game::Player* m_Player;
|
||||
Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
input::InputManager& m_InputManager;
|
||||
utils::CooldownTimer<float> m_ShootTimer{1.0f};
|
||||
EMASmoother m_DxSmoother;
|
||||
EMASmoother m_DySmoother;
|
||||
maths::EMASmoother m_DxSmoother;
|
||||
maths::EMASmoother m_DySmoother;
|
||||
// current (target) velocity
|
||||
Vec3f m_Velocity;
|
||||
/// maximum x-axis velocity
|
||||
@@ -47,7 +49,7 @@ class PlayerController : public utils::ObjectNotifier<game::PlayerInputListener>
|
||||
/**
|
||||
* \brief Default constructor
|
||||
*/
|
||||
PlayerController(Client* client, input::InputManager& inputManager);
|
||||
PlayerController(client::Client* client, input::InputManager& inputManager);
|
||||
virtual ~PlayerController();
|
||||
|
||||
/**
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/Client.h"
|
||||
#include "client/display/PlayerController.h"
|
||||
#include "client/input/PlayerController.h"
|
||||
#include "client/render/BulletRenderer.h"
|
||||
#include "client/render/Camera.h"
|
||||
#include "client/render/loader/GLLoader.h"
|
||||
@@ -9,6 +8,10 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
namespace client {
|
||||
class Client;
|
||||
} // namespace client
|
||||
|
||||
namespace shader {
|
||||
|
||||
class EntityShader;
|
||||
@@ -20,9 +23,9 @@ class GunShader;
|
||||
|
||||
namespace render {
|
||||
|
||||
class MainRenderer : public game::ClientListener, public game::PlayerInputListener {
|
||||
class MainRenderer : public client::ClientListener, public client::PlayerInputListener {
|
||||
private:
|
||||
Client* m_Client;
|
||||
client::Client* m_Client;
|
||||
ModelLoader::Model m_PlayerModel;
|
||||
ModelLoader::Model m_WorldModel;
|
||||
ModelLoader::Model m_GunModel;
|
||||
@@ -36,7 +39,7 @@ class MainRenderer : public game::ClientListener, public game::PlayerInputListen
|
||||
input::PlayerController& m_PlayerController;
|
||||
|
||||
public:
|
||||
MainRenderer(Client* client, input::PlayerController& playerController);
|
||||
MainRenderer(client::Client* client, input::PlayerController& playerController);
|
||||
~MainRenderer();
|
||||
|
||||
virtual void OnSpectatorChange(game::PlayerID player) override;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "blitz/network/Network.h"
|
||||
#include "client/Client.h"
|
||||
#include "client/audio/AudioManager.h"
|
||||
#include "client/display/Display.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/Display.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/render/MainRenderer.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
blitz::Client client;
|
||||
blitz::client::Client client;
|
||||
blitz::input::InputManager inputManager;
|
||||
blitz::Display display(1920, 1080, "BlitzKrieg", &client, inputManager);
|
||||
blitz::input::Display display(1920, 1080, "BlitzKrieg", &client, inputManager);
|
||||
|
||||
if (!display.Create())
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
|
||||
#include "blitz/common/DataBuffer.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
|
||||
static constexpr int SEGMENT_BITS = 0x7F;
|
||||
static constexpr int CONTINUE_BIT = 0x80;
|
||||
@@ -49,4 +50,5 @@ DataBuffer& operator>>(DataBuffer& in, VarInt& var) {
|
||||
return in;
|
||||
}
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace blitz
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "blitz/common/Smoothing.h"
|
||||
#include "blitz/maths/Smoothing.h"
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
namespace blitz {
|
||||
namespace maths {
|
||||
|
||||
EMASmoother::EMASmoother() : Alpha(1.0f), Current(0.0f) {}
|
||||
|
||||
@@ -27,4 +28,5 @@ void EMASmoother::SetSmoothingTime(float t) {
|
||||
SetAlpha(std::pow(1.0f - 0.999f, 1.0f / t));
|
||||
};
|
||||
|
||||
} // namespace maths
|
||||
} // namespace blitz
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "blitz/misc/Compression.h"
|
||||
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
#include <cassert>
|
||||
#include <zlib.h>
|
||||
|
||||
@@ -37,7 +37,7 @@ DataBuffer Compress(const DataBuffer& buffer) {
|
||||
|
||||
if (buffer.GetSize() < COMPRESSION_THRESHOLD) {
|
||||
// Don't compress since it's a small packet
|
||||
VarInt compressedDataLength = 0;
|
||||
protocol::VarInt compressedDataLength = 0;
|
||||
std::uint64_t packetLength = compressedDataLength.GetSerializedLength() + buffer.GetSize();
|
||||
|
||||
packet << packetLength;
|
||||
@@ -48,7 +48,7 @@ DataBuffer Compress(const DataBuffer& buffer) {
|
||||
|
||||
DataBuffer compressedData = Deflate(buffer.data(), buffer.GetSize());
|
||||
|
||||
VarInt uncompressedDataLength = buffer.GetSize();
|
||||
protocol::VarInt uncompressedDataLength = buffer.GetSize();
|
||||
std::uint64_t packetLength = uncompressedDataLength.GetSerializedLength() + compressedData.GetSize();
|
||||
|
||||
packet << packetLength;
|
||||
@@ -58,7 +58,7 @@ DataBuffer Compress(const DataBuffer& buffer) {
|
||||
}
|
||||
|
||||
DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength) {
|
||||
VarInt uncompressedLength;
|
||||
protocol::VarInt uncompressedLength;
|
||||
buffer >> uncompressedLength;
|
||||
|
||||
std::uint64_t compressedLength = packetLength - uncompressedLength.GetSerializedLength();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "blitz/protocol/packets/ChatPacket.h"
|
||||
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
#include "blitz/maths/Vector.h"
|
||||
#include "blitz/misc/Log.h"
|
||||
#include <map>
|
||||
@@ -26,7 +26,7 @@ DataBuffer ChatPacket::Serialize(bool packetID) const {
|
||||
|
||||
data << VarInt{m_Message.size()};
|
||||
for (const auto& part : m_Message) {
|
||||
data << part.color << part.text;
|
||||
data << part.m_Color << part.m_Text;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ void ChatPacket::Deserialize(DataBuffer& data) {
|
||||
m_Message.resize(partsNumber.GetValue());
|
||||
|
||||
for (std::size_t i = 0; i < partsNumber.GetValue(); ++i) {
|
||||
data >> m_Message[i].color >> m_Message[i].text;
|
||||
data >> m_Message[i].m_Color >> m_Message[i].m_Text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ std::string ChatPacket::GetColoredTextString(const ColoredText& text) {
|
||||
std::string result;
|
||||
|
||||
for (auto& part : text) {
|
||||
result += GetTextColor({static_cast<std::uint8_t>(part.color.x * 255), static_cast<std::uint8_t>(part.color.y * 255),
|
||||
static_cast<std::uint8_t>(part.color.z * 255)})
|
||||
result += GetTextColor({static_cast<std::uint8_t>(part.m_Color.x * 255), static_cast<std::uint8_t>(part.m_Color.y * 255),
|
||||
static_cast<std::uint8_t>(part.m_Color.z * 255)})
|
||||
.c_str();
|
||||
result += part.text.c_str();
|
||||
result += part.m_Text.c_str();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "blitz/protocol/packets/KeepAlivePacket.h"
|
||||
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "blitz/protocol/packets/PlayerListPacket.h"
|
||||
|
||||
#include "blitz/common/VarInt.h"
|
||||
#include "blitz/protocol/VarInt.h"
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
@@ -11,7 +11,7 @@ DataBuffer PlayerListPacket::Serialize(bool packetID) const {
|
||||
WritePacketID(data, packetID);
|
||||
data << VarInt(m_Players.size());
|
||||
for (auto [playerID, playerInfo] : m_Players) {
|
||||
data << playerID << playerInfo.name;
|
||||
data << playerID << playerInfo.m_Name;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ void PlayerListPacket::Deserialize(DataBuffer& data) {
|
||||
for (std::size_t i = 0; i < playerCount.GetValue(); i++) {
|
||||
std::uint8_t playerID;
|
||||
PlayerInfo playerInfo;
|
||||
data >> playerID >> playerInfo.name;
|
||||
data >> playerID >> playerInfo.m_Name;
|
||||
m_Players.insert({playerID, playerInfo});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
#include <cassert>
|
||||
|
||||
namespace blitz {
|
||||
namespace client {
|
||||
|
||||
Client::Client() :
|
||||
m_Server(std::make_unique<server::Server>()),
|
||||
m_Connexion(std::make_unique<client::ClientConnexion>(this)),
|
||||
m_Game(std::make_unique<client::ClientGame>(this, m_Connexion->GetDispatcher())) {}
|
||||
m_Connexion(std::make_unique<ClientConnexion>(this)),
|
||||
m_Game(std::make_unique<ClientGame>(this, m_Connexion->GetDispatcher())) {}
|
||||
|
||||
Client::~Client() {
|
||||
Disconnect();
|
||||
@@ -75,7 +76,7 @@ void Client::Disconnect() {
|
||||
}
|
||||
m_Connexion->CloseConnection();
|
||||
|
||||
NotifyListeners(&game::ClientListener::OnGameLeave);
|
||||
NotifyListeners(&client::ClientListener::OnGameLeave);
|
||||
|
||||
Reset();
|
||||
}
|
||||
@@ -96,7 +97,7 @@ void Client::SendChatText(const std::string& text) {
|
||||
}
|
||||
|
||||
void Client::ChatTextReceived(const protocol::ColoredText& text) {
|
||||
NotifyListeners(&game::ClientListener::OnTextChatReceived, text);
|
||||
NotifyListeners(&client::ClientListener::OnTextChatReceived, text);
|
||||
}
|
||||
|
||||
void Client::SendPlayerPosAndLook(const Vec3f& position, float yaw, float pitch) {
|
||||
@@ -134,4 +135,5 @@ void Client::UpdatePosition(std::uint64_t delta) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
} // namespace blitz
|
||||
@@ -16,9 +16,9 @@ namespace client {
|
||||
static std::string PrintColoredText(const protocol::ColoredText& coloredText) {
|
||||
std::string text;
|
||||
for (const auto& part : coloredText) {
|
||||
text += utils::GetTextColor({static_cast<std::uint8_t>(part.color.r * 255), static_cast<std::uint8_t>(part.color.g * 255),
|
||||
static_cast<std::uint8_t>(part.color.b * 255)}) +
|
||||
part.text;
|
||||
text += utils::GetTextColor({static_cast<std::uint8_t>(part.m_Color.r * 255), static_cast<std::uint8_t>(part.m_Color.g * 255),
|
||||
static_cast<std::uint8_t>(part.m_Color.b * 255)}) +
|
||||
part.m_Text;
|
||||
}
|
||||
text += utils::GetTextColorReset();
|
||||
return text;
|
||||
@@ -54,7 +54,7 @@ void ClientConnexion::HandlePacket(const protocol::ChatPacket* packet) {
|
||||
|
||||
void ClientConnexion::HandlePacket(const protocol::DisconnectPacket* packet) {
|
||||
utils::LOG("[ClientConnexion] Disconnected ! Reason : " + packet->GetReason());
|
||||
m_Client->NotifyListeners(&game::ClientListener::OnGameLeave);
|
||||
m_Client->NotifyListeners(&client::ClientListener::OnGameLeave);
|
||||
m_Client->Disconnect();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace blitz {
|
||||
namespace audio {
|
||||
|
||||
AudioManager::AudioManager(Client* client) : m_Client(client), m_Player(nullptr) {
|
||||
AudioManager::AudioManager(client::Client* client) : m_Client(client), m_Player(nullptr) {
|
||||
m_Listener.SetGain(1.0f);
|
||||
InitSounds();
|
||||
m_MenuMusic->Play();
|
||||
|
||||
@@ -50,15 +50,15 @@ void ClientGame::RegisterHandlers() {
|
||||
void ClientGame::HandlePacket(const protocol::PlayerJoinPacket* packet) {
|
||||
|
||||
if (packet->GetPlayerID() == m_Client->GetPlayerID()) {
|
||||
m_Client->NotifyListeners(&game::ClientListener::OnGameJoin);
|
||||
m_Client->NotifyListeners(&client::ClientListener::OnGameJoin);
|
||||
}
|
||||
|
||||
AddPlayer(packet->GetPlayerID(), packet->GetPlayerName());
|
||||
|
||||
// Initialize camera
|
||||
if (packet->GetPlayerID() == m_Client->GetPlayerID()) {
|
||||
m_Client->NotifyListeners(&game::ClientListener::OnSpectatorChange, packet->GetPlayerID());
|
||||
m_Client->NotifyListeners(&game::ClientListener::OnClientPlayerJoin);
|
||||
m_Client->NotifyListeners(&client::ClientListener::OnSpectatorChange, packet->GetPlayerID());
|
||||
m_Client->NotifyListeners(&client::ClientListener::OnClientPlayerJoin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ void ClientGame::HandlePacket(const protocol::PlayerLeavePacket* packet) {
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::PlayerListPacket* packet) {
|
||||
for (const auto& [playerID, playerInfo] : packet->GetPlayers()) {
|
||||
AddPlayer(playerID, playerInfo.name);
|
||||
AddPlayer(playerID, playerInfo.m_Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ void ClientGame::HandlePacket(const protocol::UpdateGameStatePacket* packet) {
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::ServerConfigPacket* packet) {
|
||||
m_Config = packet->GetGameConfig();
|
||||
m_Client->NotifyListeners(&game::ClientListener::OnGameConfigUpdate);
|
||||
m_Client->NotifyListeners(&client::ClientListener::OnGameConfigUpdate);
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::PlayerShootPacket* packet) {
|
||||
m_Client->NotifyListeners(
|
||||
&game::ClientListener::OnPlayerShoot, packet->GetPlayer(), packet->GetPosition(), packet->GetYaw(), packet->GetPitch());
|
||||
&client::ClientListener::OnPlayerShoot, packet->GetPlayer(), packet->GetPosition(), packet->GetYaw(), packet->GetPitch());
|
||||
}
|
||||
|
||||
void ClientGame::HandlePacket(const protocol::PlayerPositionAndRotationPacket* packet) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
BlitzGui::BlitzGui(Client* client, input::InputManager& inputManager) : GuiWidget(nullptr, client) {
|
||||
BlitzGui::BlitzGui(client::Client* client, input::InputManager& inputManager) : GuiWidget(nullptr, client) {
|
||||
Enable();
|
||||
AddWidget(std::make_unique<GameChatGui>(this, client, inputManager));
|
||||
AddWidget(std::make_unique<MainMenu>(client, inputManager));
|
||||
|
||||
@@ -12,7 +12,7 @@ void RenderColorfulText(const protocol::ColoredText& parts, float alpha) {
|
||||
const bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set
|
||||
if (need_backup)
|
||||
ImGui::PushTextWrapPos(0.0f);
|
||||
ImGui::TextColored({part.color.r, part.color.g, part.color.b, alpha}, "%s", part.text.c_str());
|
||||
ImGui::TextColored({part.m_Color.r, part.m_Color.g, part.m_Color.b, alpha}, "%s", part.m_Text.c_str());
|
||||
if (need_backup)
|
||||
ImGui::PopTextWrapPos();
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
CreateGameMenu::CreateGameMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager) :
|
||||
CreateGameMenu::CreateGameMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager) :
|
||||
GuiWidget(parent, client), m_InputManager(inputManager) {}
|
||||
|
||||
void CreateGameMenu::Render() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
CrossHair::CrossHair(Client* client) : GuiWidget(nullptr, client) {
|
||||
CrossHair::CrossHair(client::Client* client) : GuiWidget(nullptr, client) {
|
||||
m_CrossHairTexture = TextureLoader::LoadGLTexture("textures/crosshair.png");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "blitz/misc/Easing.h"
|
||||
#include "blitz/misc/Format.h"
|
||||
#include "blitz/misc/Log.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/gui/ColorFulText.h"
|
||||
#include "client/gui/GuiWidget.h"
|
||||
#include <client/Client.h>
|
||||
@@ -15,7 +15,7 @@ namespace gui {
|
||||
|
||||
static const float ChatFadeTime = 2.0f;
|
||||
|
||||
GameChatGui::GameChatGui(GuiWidget* parent, Client* client, input::InputManager& inputManager) :
|
||||
GameChatGui::GameChatGui(GuiWidget* parent, client::Client* client, input::InputManager& inputManager) :
|
||||
GuiWidget(parent, client), m_InputManager(inputManager) {
|
||||
m_Client->BindListener(this);
|
||||
InputBuf[0] = '\0';
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
Hud::Hud(GuiWidget* parent, Client* client) : GuiWidget(parent, client) {
|
||||
Hud::Hud(GuiWidget* parent, client::Client* client) : GuiWidget(parent, client) {
|
||||
m_GunTexture = TextureLoader::LoadGLTexture("textures/fingergun.png");
|
||||
m_JPTexture = TextureLoader::LoadGLTexture("textures/jp.png");
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include "blitz/misc/Format.h"
|
||||
#include "blitz/misc/Log.h"
|
||||
#include "client/Client.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
JoinGameMenu::JoinGameMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager) :
|
||||
JoinGameMenu::JoinGameMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager) :
|
||||
GuiWidget(parent, client), m_InputManager(inputManager) {}
|
||||
|
||||
void JoinGameMenu::Render() {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
LeaderBoardGui::LeaderBoardGui(GuiWidget* parent, Client* client) : GuiWidget(parent, client) {}
|
||||
LeaderBoardGui::LeaderBoardGui(GuiWidget* parent, client::Client* client) : GuiWidget(parent, client) {}
|
||||
|
||||
LeaderBoardGui::~LeaderBoardGui() {}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
MainMenu::MainMenu(Client* client, input::InputManager& inputManager) : GuiWidget(nullptr, client), m_InputManager(inputManager) {
|
||||
MainMenu::MainMenu(client::Client* client, input::InputManager& inputManager) : GuiWidget(nullptr, client), m_InputManager(inputManager) {
|
||||
Enable();
|
||||
AddWidget(std::make_unique<CreateGameMenu>(this, client, inputManager));
|
||||
AddWidget(std::make_unique<JoinGameMenu>(this, client, inputManager));
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
#include "blitz/misc/Format.h"
|
||||
#include "blitz/misc/Log.h"
|
||||
#include "client/Client.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/gui/FPSMenu.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <imgui.h>
|
||||
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
static std::string ActionNames[kaMax] = {
|
||||
static std::string ActionNames[input::kaMax] = {
|
||||
"Avancer",
|
||||
"Reculer",
|
||||
"Droite",
|
||||
@@ -23,7 +23,7 @@ static std::string ActionNames[kaMax] = {
|
||||
|
||||
|
||||
|
||||
static std::string GetActionName(KeyAction action) {
|
||||
static std::string GetActionName(input::KeyAction action) {
|
||||
return ActionNames[action];
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ static std::string GetImGuiKeyName(int key) {
|
||||
|
||||
|
||||
|
||||
OptionsMenu::OptionsMenu(GuiWidget* parent, Client* client, input::InputManager& inputManager) :
|
||||
OptionsMenu::OptionsMenu(GuiWidget* parent, client::Client* client, input::InputManager& inputManager) :
|
||||
GuiWidget(parent, client), m_IsKeyPopupOpen(false), m_KeyPopupShouldClose(false), m_InputManager(inputManager) {
|
||||
AddWidget(std::make_unique<FPSMenu>(this, client));
|
||||
|
||||
@@ -69,13 +69,13 @@ OptionsMenu::~OptionsMenu() {
|
||||
|
||||
void OptionsMenu::HotkeyBindingButton() {
|
||||
for (std::size_t i = 0; i < m_Client->GetConfig()->GetKeys().size(); i++) {
|
||||
if (ImGui::Button(utils::Format("%s##%i", GetKeyActionCodeName(KeyAction(i)).c_str(), i).c_str())) {
|
||||
if (ImGui::Button(utils::Format("%s##%i", GetKeyActionCodeName(input::KeyAction(i)).c_str(), i).c_str())) {
|
||||
m_IsKeyPopupOpen = true;
|
||||
m_CurrentAction = KeyAction(i);
|
||||
m_CurrentAction = input::KeyAction(i);
|
||||
ImGui::OpenPopup("Changer de touche");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", GetActionName(KeyAction(i)).c_str());
|
||||
ImGui::Text("%s", GetActionName(input::KeyAction(i)).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void OptionsMenu::OnKeyDown(int key) {
|
||||
|
||||
|
||||
|
||||
std::string OptionsMenu::GetKeyActionCodeName(KeyAction act) {
|
||||
std::string OptionsMenu::GetKeyActionCodeName(input::KeyAction act) {
|
||||
return GetImGuiKeyName(static_cast<int>(m_Client->GetConfig()->GetKeys()[act]));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "client/gui/ServerGui.h"
|
||||
|
||||
#include "client/Client.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/game/ClientGame.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "server/Server.h"
|
||||
#include "server/game/ServerGame.h"
|
||||
#include <imgui.h>
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace blitz {
|
||||
namespace gui {
|
||||
|
||||
ServerGui::ServerGui(GuiWidget* parent, Client* client, input::InputManager& inputManager) :
|
||||
ServerGui::ServerGui(GuiWidget* parent, client::Client* client, input::InputManager& inputManager) :
|
||||
GuiWidget(parent, client), m_InputManager(inputManager) {}
|
||||
|
||||
void ServerGui::Render() {
|
||||
@@ -18,7 +18,7 @@ void ServerGui::Render() {
|
||||
return;
|
||||
|
||||
Keybinds keys = m_Client->GetConfig()->GetKeys();
|
||||
if (ImGui::IsKeyPressed(ImGuiKey(keys[kaFenetreAdmin])) && m_InputManager.MouseGrabbed()) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey(keys[input::kaFenetreAdmin])) && m_InputManager.MouseGrabbed()) {
|
||||
ImGui::OpenPopup("FENETRE D'ADMIN");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "client/display/Display.h"
|
||||
#include "client/input/Display.h"
|
||||
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/render/OpenGL.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
@@ -19,8 +19,9 @@
|
||||
#endif
|
||||
|
||||
namespace blitz {
|
||||
namespace input {
|
||||
|
||||
Display::Display(int width, int height, const std::string& windowName, Client* client, input::InputManager& inputManager) :
|
||||
Display::Display(int width, int height, const std::string& windowName, client::Client* client, input::InputManager& inputManager) :
|
||||
m_WindowWidth(width),
|
||||
m_WindowHeight(height),
|
||||
m_AspectRatio(m_WindowHeight / static_cast<float>(m_WindowWidth)),
|
||||
@@ -236,4 +237,5 @@ void Display::InitImGui() {
|
||||
m_BlitzGui = std::make_unique<gui::BlitzGui>(m_Client, m_InputManager);
|
||||
}
|
||||
|
||||
} // namespace input
|
||||
} // namespace blitz
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
|
||||
#include "imgui.h"
|
||||
#include <vector>
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "client/display/PlayerController.h"
|
||||
#include "client/input/PlayerController.h"
|
||||
|
||||
#include "blitz/game/Player.h"
|
||||
#include "blitz/maths/Maths.h"
|
||||
#include "blitz/misc/Log.h"
|
||||
#include "client/Client.h"
|
||||
#include "client/config/BlitzConfig.h"
|
||||
#include "client/display/InputManager.h"
|
||||
#include "client/input/InputManager.h"
|
||||
#include "client/game/ClientGame.h"
|
||||
#include "imgui.h"
|
||||
#include <algorithm>
|
||||
@@ -20,7 +20,7 @@ static constexpr float DEFAULT_MAX_FB_SPEED = 10.;
|
||||
static constexpr float DEFAULT_LR_SPEED_SMOOTHING_TIME = 1.0;
|
||||
static constexpr float DEFAULT_FB_SPEED_SMOOTHING_TIME = 1.0;
|
||||
|
||||
PlayerController::PlayerController(Client* client, input::InputManager& inputManager) :
|
||||
PlayerController::PlayerController(client::Client* client, input::InputManager& inputManager) :
|
||||
m_Player(nullptr),
|
||||
m_Client(client),
|
||||
m_InputManager(inputManager),
|
||||
@@ -87,13 +87,13 @@ void PlayerController::Update(float delta) {
|
||||
|
||||
if (ImGui::IsKeyDown(ImGuiKey::ImGuiKey_Space) && m_OnGround) {
|
||||
m_Velocity.z = m_MaxVelocity.z;
|
||||
NotifyListeners(&game::PlayerInputListener::OnLocalPlayerJump);
|
||||
NotifyListeners(&client::PlayerInputListener::OnLocalPlayerJump);
|
||||
}
|
||||
|
||||
bool canShoot = m_ShootTimer.Update(ImGui::GetIO().DeltaTime);
|
||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && canShoot) {
|
||||
NotifyListeners(
|
||||
&game::PlayerInputListener::OnLocalPlayerShoot, m_Player->GetPosition(), m_Player->GetYaw(), m_Player->GetPitch());
|
||||
&client::PlayerInputListener::OnLocalPlayerShoot, m_Player->GetPosition(), m_Player->GetYaw(), m_Player->GetPitch());
|
||||
m_ShootTimer.ApplyCooldown();
|
||||
}
|
||||
} else {
|
||||
@@ -24,7 +24,7 @@ namespace render {
|
||||
static const Vec4f SkyColor = {0.6f, 0.8f, 1.0f, 1.0f};
|
||||
static const Vec4f MenuColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
MainRenderer::MainRenderer(Client* client, input::PlayerController& playerController) :
|
||||
MainRenderer::MainRenderer(client::Client* client, input::PlayerController& playerController) :
|
||||
m_Client(client), m_ShootTime(0), m_BulletRenderer(m_Camera), m_PlayerController(playerController) {
|
||||
|
||||
LoadModels();
|
||||
|
||||
Reference in New Issue
Block a user