Skip to content

Switch to Nazara Next #69

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

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Xmake.Custom.props
Xmake.Custom.targets
build
src/CoreLib/VersionData.hpp
vsxmake*/

# Game binaries
Assets/*
Expand Down Expand Up @@ -45,6 +46,7 @@ Makefile
*.VC.opendb
*.VC.db*
*.leu
*.vsidx

# VS Code
.vscode
Expand Down
15 changes: 11 additions & 4 deletions include/ClientLib/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@

#include <ClientLib/Export.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Graphics/RenderTarget.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <NDK/EntityOwner.hpp>
#include <CoreLib/EntityOwner.hpp>

namespace Nz
{
class EnttWorld;
}

namespace bw
{
Expand All @@ -24,7 +29,7 @@ namespace bw
class BURGWAR_CLIENTLIB_API Camera : public Nz::HandledObject<Camera>
{
public:
Camera(Ndk::World& world, Nz::RenderTarget* renderTarget, bool perspective);
Camera(Nz::EnttWorld& world, std::shared_ptr<const Nz::RenderTarget> renderTarget, bool perspective);
Camera(const Camera&) = delete;
Camera(Camera&&) = delete;
~Camera() = default;
Expand Down Expand Up @@ -59,10 +64,12 @@ namespace bw
private:
void UpdateProjection();
void UpdateZoomFactor();
void UpdateZoomFactor(const Nz::Vector2ui& newRenderTargetSize);

NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, m_onTargetSizeChanged);

Ndk::EntityOwner m_cameraEntity;
Nz::Vector3f m_offset;
EntityOwner m_cameraEntity;
bool m_isPerspective;
float m_projectedDepth;
float m_invFovTan;
Expand Down
25 changes: 12 additions & 13 deletions include/ClientLib/Chatbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
#define BURGWAR_CLIENTLIB_CHATBOX_HPP

#include <ClientLib/Export.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <NDK/Canvas.hpp>
#include <NDK/Entity.hpp>
#include <NDK/EntityOwner.hpp>
#include <NDK/Widgets/RichTextAreaWidget.hpp>
#include <NDK/Widgets/ScrollAreaWidget.hpp>
#include <NDK/Widgets/TextAreaWidget.hpp>
#include <NazaraUtils/Signal.hpp>
#include <Nazara/Graphics/RenderTarget.hpp>
#include <Nazara/Widgets/Canvas.hpp>
#include <CoreLib/EntityOwner.hpp>
#include <Nazara/Widgets/RichTextAreaWidget.hpp>
#include <Nazara/Widgets/ScrollAreaWidget.hpp>
#include <Nazara/Widgets/TextAreaWidget.hpp>
#include <variant>

namespace bw
Expand All @@ -37,7 +36,7 @@ namespace bw

using Item = std::variant<ColorItem, TextItem>;

Chatbox(const Logger& logger, Nz::RenderTarget* rt, Ndk::Canvas* canvas);
Chatbox(const Logger& logger, const Nz::RenderTarget& renderTarget, Nz::Canvas* canvas);
Chatbox(const Chatbox&) = delete;
Chatbox(Chatbox&&) = delete;
~Chatbox();
Expand All @@ -60,15 +59,15 @@ namespace bw
NazaraSignal(OnChatMessage, const std::string& /*message*/);

private:
void OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget);
void OnRenderTargetSizeChange(const Nz::RenderTarget* renderTarget, const Nz::Vector2ui& newSize);
void Refresh();

NazaraSlot(Nz::RenderTarget, OnRenderTargetSizeChange, m_onTargetChangeSizeSlot);

std::vector<std::vector<Item>> m_chatLines;
Ndk::ScrollAreaWidget* m_chatboxScrollArea;
Ndk::RichTextAreaWidget* m_chatBox;
Ndk::TextAreaWidget* m_chatEnteringBox;
Nz::RichTextAreaWidget* m_chatBox;
Nz::ScrollAreaWidget* m_chatboxScrollArea;
Nz::TextAreaWidget* m_chatEnteringBox;
const Logger& m_logger;
};
}
Expand Down
14 changes: 7 additions & 7 deletions include/ClientLib/ClientAssetStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <ClientLib/Export.hpp>
#include <Nazara/Audio/SoundBuffer.hpp>
#include <Nazara/Graphics/Model.hpp>
#include <Nazara/Renderer/Texture.hpp>
#include <Nazara/Graphics/TextureAsset.hpp>

namespace bw
{
Expand All @@ -23,14 +23,14 @@ namespace bw

void Clear() override;

const Nz::ModelRef& GetModel(const std::string& modelPath) const;
const Nz::SoundBufferRef& GetSoundBuffer(const std::string& soundPath) const;
const Nz::TextureRef& GetTexture(const std::string& texturePath) const;
const std::shared_ptr<Nz::Model>& GetModel(const std::string& modelPath) const;
const std::shared_ptr<Nz::SoundBuffer>& GetSoundBuffer(const std::string& soundPath) const;
const std::shared_ptr<Nz::TextureAsset>& GetTexture(const std::string& texturePath) const;

private:
mutable tsl::hopscotch_map<std::string, Nz::ModelRef> m_models;
mutable tsl::hopscotch_map<std::string, Nz::SoundBufferRef> m_soundBuffers;
mutable tsl::hopscotch_map<std::string, Nz::TextureRef> m_textures;
mutable tsl::hopscotch_map<std::string, std::shared_ptr<Nz::Model>> m_models;
mutable tsl::hopscotch_map<std::string, std::shared_ptr<Nz::SoundBuffer>> m_soundBuffers;
mutable tsl::hopscotch_map<std::string, std::shared_ptr<Nz::TextureAsset>> m_textures;
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/ClientLib/ClientConsole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace bw
class BURGWAR_CLIENTLIB_API ClientConsole : public Console
{
public:
ClientConsole(const Logger& logger, Nz::RenderTarget* window, Ndk::Canvas* canvas, std::shared_ptr<AbstractScriptingLibrary> scriptingLibrary, const std::shared_ptr<VirtualDirectory>& scriptDir);
ClientConsole(const Logger& logger, const Nz::RenderTarget& renderTarget, Nz::Canvas* canvas, std::shared_ptr<AbstractScriptingLibrary> scriptingLibrary, const std::shared_ptr<Nz::VirtualDirectory>& scriptDir);
ClientConsole(const ClientConsole&) = delete;
ClientConsole(ClientConsole&&) = delete;
~ClientConsole() = default;
Expand Down
24 changes: 16 additions & 8 deletions include/ClientLib/ClientEditorLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
#include <CoreLib/SharedLayer.hpp>
#include <ClientLib/Export.hpp>
#include <ClientLib/VisualLayer.hpp>
#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/Signal.hpp>
#include <NazaraUtils/Bitset.hpp>
#include <NazaraUtils/Signal.hpp>

namespace Nz
{
class EnttSystemGraph;
}

namespace bw
{
Expand All @@ -20,17 +25,20 @@ namespace bw
public:
ClientEditorLayer(SharedMatch& match, LayerIndex layerIndex);
ClientEditorLayer(const ClientEditorLayer&) = delete;
ClientEditorLayer(ClientEditorLayer&&) noexcept = default;
ClientEditorLayer(ClientEditorLayer&&) = delete;
~ClientEditorLayer() = default;

virtual void FrameUpdate(float elapsedTime);
virtual void PreFrameUpdate(float elapsedTime);
virtual void PostFrameUpdate(float elapsedTime);

void TickUpdate(float elapsedTime) override;
virtual void FrameUpdate(Nz::Time elapsedTime);
virtual void PreFrameUpdate(Nz::Time elapsedTime);
virtual void PostFrameUpdate(Nz::Time elapsedTime);

ClientEditorLayer& operator=(const ClientEditorLayer&) = delete;
ClientEditorLayer& operator=(ClientEditorLayer&&) = delete;

private:
Nz::EnttSystemGraph m_frameSystemGraph;
Nz::EnttSystemGraph m_preFrameSystemGraph;
Nz::EnttSystemGraph m_postFrameSystemGraph;
};
}

Expand Down
11 changes: 6 additions & 5 deletions include/ClientLib/ClientLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#ifndef BURGWAR_CLIENTLIB_CLIENTLAYER_HPP
#define BURGWAR_CLIENTLIB_CLIENTLAYER_HPP

#include <Nazara/Core/Bitset.hpp>
#include <Nazara/Core/Signal.hpp>
#include <NazaraUtils/Bitset.hpp>
#include <NazaraUtils/Signal.hpp>
#include <CoreLib/Components/DestructionWatcherComponent.hpp>
#include <CoreLib/Protocol/Packets.hpp>
#include <ClientLib/Export.hpp>
#include <ClientLib/ClientEditorLayer.hpp>
Expand All @@ -30,7 +31,7 @@ namespace bw
public:
ClientLayer(ClientMatch& match, LayerIndex layerIndex, const Nz::Color& backgroundColor);
ClientLayer(const ClientLayer&) = delete;
ClientLayer(ClientLayer&&) noexcept;
ClientLayer(ClientLayer&&) = delete;
~ClientLayer();

inline void Disable();
Expand All @@ -50,7 +51,7 @@ namespace bw
bool IsEnabled() const override;
inline bool IsPredictionEnabled() const;

void PostFrameUpdate(float elapsedTime) override;
void PostFrameUpdate(Nz::Time elapsedTime) override;

ClientLayerEntity& RegisterEntity(ClientLayerEntity layerEntity);
ClientLayerSound& RegisterSound(ClientLayerSound layerEntity);
Expand Down Expand Up @@ -91,7 +92,7 @@ namespace bw

ClientLayerEntity layerEntity;

NazaraSlot(Ndk::Entity, OnEntityDestruction, onDestruction);
NazaraSlot(DestructionWatcherComponent, OnDestruction, onDestruction);
};

struct SoundData
Expand Down
10 changes: 5 additions & 5 deletions include/ClientLib/ClientLayerEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <Nazara/Core/ObjectHandle.hpp>
#include <Nazara/Graphics/Sprite.hpp>
#include <Nazara/Graphics/TextSprite.hpp>
#include <NDK/EntityOwner.hpp>
#include <CoreLib/EntityOwner.hpp>
#include <memory>
#include <optional>
#include <vector>
Expand All @@ -31,7 +31,7 @@ namespace bw
class BURGWAR_CLIENTLIB_API ClientLayerEntity final : public LayerVisualEntity
{
public:
ClientLayerEntity(ClientLayer& layer, const Ndk::EntityHandle& entity, Nz::UInt32 serverEntityId, EntityId uniqueId);
ClientLayerEntity(ClientLayer& layer, entt::handle entity, Nz::UInt32 serverEntityId, EntityId uniqueId);
ClientLayerEntity(const ClientLayerEntity&) = delete;
ClientLayerEntity(ClientLayerEntity&& entity) noexcept = default;
~ClientLayerEntity();
Expand Down Expand Up @@ -72,16 +72,16 @@ namespace bw

struct DebugEntityIdData
{
Nz::TextSpriteRef entityIdSprite;
std::shared_ptr<Nz::TextSprite> entityIdSprite;
};

struct HealthData
{
float spriteWidth;
Nz::UInt16 currentHealth;
Nz::UInt16 maxHealth;
Nz::SpriteRef healthSprite;
Nz::SpriteRef lostHealthSprite;
std::shared_ptr<Nz::Sprite> healthSprite;
std::shared_ptr<Nz::Sprite> lostHealthSprite;
};

std::unique_ptr<ClientLayerEntity> m_ghostEntity;
Expand Down
14 changes: 7 additions & 7 deletions include/ClientLib/ClientLayerSound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <Nazara/Audio/SoundBuffer.hpp>
#include <Nazara/Core/HandledObject.hpp>
#include <Nazara/Core/ObjectHandle.hpp>
#include <Nazara/Utility/Node.hpp>
#include <Nazara/Core/Node.hpp>
#include <optional>
#include <vector>

Expand All @@ -36,15 +36,15 @@ namespace bw
inline ClientLayerSound(ClientLayerSound&& entity) noexcept;
~ClientLayerSound() = default;

float GetSoundDuration(std::size_t soundIndex) const;
Nz::Time GetSoundDuration(std::size_t soundIndex) const;

LayerIndex GetLayerIndex() const;
inline Nz::Vector2f GetPosition() const;

std::size_t PlaySound(const Nz::SoundBufferRef& soundBuffer, bool isLooping, bool isSpatialized);
std::size_t PlaySound(const std::shared_ptr<Nz::SoundBuffer>& soundBuffer, bool isLooping, bool isSpatialized);
void StopSound(std::size_t soundIndex);

bool Update(float elapsedTime);
bool Update(Nz::Time elapsedTime);

inline void UpdatePosition(const Nz::Vector2f& position);

Expand All @@ -60,9 +60,9 @@ namespace bw

struct PlayingSound
{
Nz::SoundBufferRef soundBuffer;
float currentOffset = 0.f;
float duration = 0.f;
std::shared_ptr<Nz::SoundBuffer> soundBuffer;
Nz::Time currentOffset = Nz::Time::Zero();
Nz::Time duration = Nz::Time::Zero();
bool isLooping;
bool isSpatialized;
};
Expand Down
Loading
Loading