Skip to content

Commit 2bd794d

Browse files
committed
[NOT WORKING] Began refactor of UI
1 parent 27ff830 commit 2bd794d

26 files changed

+409
-156
lines changed

include/NovelRT/Ecs/Configurator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ namespace NovelRT::Ecs
6464

6565
target.RegisterSystem(std::make_shared<NovelRT::Ecs::UI::UISystem>(_uiPluginProvider,
6666
target.GetRegisteredIEcsSystemAs<NovelRT::Ecs::Input::InputSystem>(),
67-
target.GetRegisteredIEcsSystemAs<NovelRT::Ecs::Graphics::DefaultRenderingSystem>()));
67+
target.GetRegisteredIEcsSystemAs<NovelRT::Ecs::Graphics::DefaultRenderingSystem>(),
68+
_resourceManagementPluginProvider->GetResourceLoader()));
6869
}
6970

7071
public:

include/NovelRT/Ecs/UI/UISystem.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ namespace NovelRT::Ecs::UI
1414
{
1515
private:
1616
LoggingService _logger;
17-
std::shared_ptr<NovelRT::UI::IUIProvider> _uiProvider;
17+
std::shared_ptr<NovelRT::UI::UIProvider> _uiProvider;
1818

1919
public:
2020
UISystem(std::shared_ptr<NovelRT::PluginManagement::IUIPluginProvider> uiPluginProvider,
2121
std::shared_ptr<NovelRT::Ecs::Input::InputSystem> inputSystem,
22-
std::shared_ptr<NovelRT::Ecs::Graphics::DefaultRenderingSystem> renderingSystem);
22+
std::shared_ptr<NovelRT::Ecs::Graphics::DefaultRenderingSystem> renderingSystem,
23+
std::shared_ptr<NovelRT::ResourceManagement::ResourceLoader> resourceLoader);
2324

2425
void Update(Timing::Timestamp delta, Ecs::Catalogue catalogue) final;
2526

26-
inline std::shared_ptr<NovelRT::UI::IUIProvider> GetProvider() const
27+
inline std::shared_ptr<NovelRT::UI::UIProvider> GetProvider() const
2728
{
2829
return _uiProvider;
2930
}

include/NovelRT/NovelRT.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#include <fabulist/runtime/version.hpp>
5050

5151
//Dear ImGui
52-
#include <imgui.h>
52+
//#include <imgui.h>
5353

5454
// libpng
5555
#include <png.h>

include/NovelRT/PluginManagement/IUIPluginProvider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ namespace NovelRT::PluginManagement
1313
class IUIPluginProvider : public std::enable_shared_from_this<IUIPluginProvider>
1414
{
1515
protected:
16-
[[nodiscard]] virtual NovelRT::UI::IUIProvider* GetUIProviderInternal() = 0;
16+
[[nodiscard]] virtual NovelRT::UI::UIProvider* GetUIProviderInternal() = 0;
1717

1818
public:
19-
[[nodiscard]] inline std::shared_ptr<NovelRT::UI::IUIProvider> GetUIProvider()
19+
[[nodiscard]] inline std::shared_ptr<NovelRT::UI::UIProvider> GetUIProvider()
2020
{
2121
return GetUIProviderInternal()->shared_from_this();
2222
}

include/NovelRT/ResourceManagement/Desktop/DesktopResourceLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace NovelRT::ResourceManagement::Desktop
2525
[[nodiscard]] BinaryPackage LoadPackage(std::filesystem::path filePath) final;
2626
void SavePackage(std::filesystem::path filePath, const BinaryPackage& package) final;
2727
[[nodiscard]] AudioMetadata LoadAudioFrameData(std::filesystem::path filePath) override;
28+
[[nodiscard]] FontMetadata LoadFont(std::filesystem::path filePath) final;
2829
~DesktopResourceLoader() final = default;
2930
};
3031
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright © Matt Jones and Contributors. Licensed under the MIT Licence (MIT). See LICENCE.md in the repository root
2+
// for more information.
3+
4+
#ifndef NOVELRT_RESOURCEMANAGEMENT_FONTMETADATA_H
5+
#define NOVELRT_RESOURCEMANAGEMENT_FONTMETADATA_H
6+
7+
#ifndef NOVELRT_RESOURCEMANAGEMENT_H
8+
#error NovelRT does not support including types explicitly by default. Please include ResourceManagement.h instead for the ResourceManagement namespace subset.
9+
#endif
10+
11+
namespace NovelRT::ResourceManagement
12+
{
13+
struct FontMetadata
14+
{
15+
std::string name;
16+
void* fontData;
17+
uuids::uuid databaseHandle;
18+
};
19+
}
20+
21+
#endif // NOVELRT_RESOURCEMANAGEMENT_FONTMETADATA_H

include/NovelRT/ResourceManagement/ResourceLoader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ namespace NovelRT::ResourceManagement
8787

8888
[[nodiscard]] virtual AudioMetadata LoadAudioFrameData(std::filesystem::path filePath) = 0;
8989

90+
[[nodiscard]] virtual FontMetadata LoadFont(std::filesystem::path filePath) = 0;
91+
9092
virtual ~ResourceLoader() = default;
9193
};
9294
}

include/NovelRT/ResourceManagement/ResourceManagement.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace NovelRT::ResourceManagement
2525
struct BinaryPackage;
2626
struct ShaderMetadata;
2727
struct AudioMetadata;
28+
struct FontMetadata;
2829
}
2930

3031
// clang-format off
@@ -35,6 +36,7 @@ namespace NovelRT::ResourceManagement
3536
#include "BinaryPackage.h"
3637
#include "ShaderMetadata.h"
3738
#include "AudioMetadata.h"
39+
#include "FontMetadata.h"
3840
// clang-format on
3941

4042
#endif // NOVELRT_RESOURCEMANAGEMENT_H

include/NovelRT/UI/DearImGui/GlfwVulkan/GlfwVulkanUIProvider.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010

1111
namespace NovelRT::UI::DearImGui::GlfwVulkan
1212
{
13-
class GlfwVulkanUIProvider final : public UI::IUIProvider
13+
class GlfwVulkanUIProvider final : public UI::UIProvider
1414
{
1515
private:
16-
std::list<std::shared_ptr<ImGuiTextbox>> _textboxes;
17-
std::list<std::shared_ptr<ImGuiButton>> _buttons;
16+
// std::list<std::shared_ptr<ImGuiTextbox>> _textboxes;
17+
// std::list<std::shared_ptr<ImGuiButton>> _buttons;
1818
NovelRT::Maths::GeoVector2F _windowSize;
19+
std::map<std::string, ImFont*> _fontNameMapping;
1920

2021
void Render();
2122
ImGuiKey GlfwVulkanUIProvider::GlfwToImGuiKey(int32_t key);
23+
void GenerateCommand(UIElement& element);
24+
25+
void GeneratePanelCommand(UIPanel& panel);
2226

2327
protected:
2428
bool _isInitialised;
@@ -27,7 +31,8 @@ namespace NovelRT::UI::DearImGui::GlfwVulkan
2731
public:
2832
GlfwVulkanUIProvider() noexcept;
2933
~GlfwVulkanUIProvider() final;
30-
void Initialise(std::shared_ptr<NovelRT::Graphics::GraphicsDevice> gfxDevice,
34+
void Initialise(std::shared_ptr<NovelRT::ResourceManagement::ResourceLoader> resourceLoader,
35+
std::shared_ptr<NovelRT::Graphics::GraphicsDevice> gfxDevice,
3136
std::shared_ptr<NovelRT::Windowing::IWindowingDevice> windowingDevice,
3237
std::shared_ptr<NovelRT::Input::IInputDevice> inputDevice,
3338
std::shared_ptr<NovelRT::Graphics::GraphicsProvider> gfxProvider,
@@ -36,18 +41,6 @@ namespace NovelRT::UI::DearImGui::GlfwVulkan
3641
void Begin();
3742
void End(std::shared_ptr<NovelRT::Graphics::GraphicsContext> context);
3843

39-
std::shared_ptr<IUITextbox> CreateTextbox(const std::string& identifier,
40-
const std::string& text,
41-
bool wordWrap,
42-
NovelRT::Maths::GeoVector2F position,
43-
NovelRT::Maths::GeoVector2F scale,
44-
float fontSize,
45-
NovelRT::Graphics::RGBAColour backgroundColour) final;
46-
47-
std::shared_ptr<IUIButton> CreateButton(const std::string& identifier,
48-
NovelRT::Maths::GeoVector2F position,
49-
NovelRT::Maths::GeoVector2F scale,
50-
NovelRT::Graphics::RGBAColour backgroundColour) final;
5144
};
5245
}
5346

include/NovelRT/UI/DearImGui/GlfwVulkan/UI.DearImGui.GlfwVulkan.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ namespace NovelRT::UI::DearImGui::GlfwVulkan
1919
#include "../../../Windowing/Glfw/Windowing.Glfw.h"
2020
#include "../../../Input/Glfw/Input.Glfw.h"
2121
#include "../../../PluginManagement/PluginManagement.h"
22-
#include "../UI.DearImGui.h"
22+
//#include "../UI.DearImGui.h"
23+
24+
#define IMGUI_USER_CONFIG "UI.DearImGui.GlfwVulkan.h"
25+
#define IM_VEC2_CLASS_EXTRA \
26+
constexpr ImVec2(const NovelRT::Maths::GeoVector2F& f) : x(f.x), y(f.y) {} \
27+
operator NovelRT::Maths::GeoVector2F() const { return NovelRT::Maths::GeoVector2F(x,y); }
28+
#define IM_VEC4_CLASS_EXTRA \
29+
constexpr ImVec4(const NovelRT::Graphics::RGBAColour& f) : x(f.r), y(f.g), z(f.b), w(f.a) {} \
30+
ImVec4(NovelRT::Graphics::RGBAColour& f) : x(f.r), y(f.g), z(f.b), w(f.a) {}
31+
#include <imgui.h>
2332
#include <imgui_impl_glfw.h>
2433
#include <imgui_impl_vulkan.h>
2534

0 commit comments

Comments
 (0)