FuncDoodle
Loading...
Searching...
No Matches
AssetLoader.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#include "UI/Gui.h"
22#include <filesystem>
23
24#include "Audio/AudioManager.h"
25
26#include "Util/Ptr.h"
27
28namespace FuncDoodle {
38 public:
45 explicit AssetLoader(std::filesystem::path assetsPath);
53 [[nodiscard]] const std::filesystem::path& GetPath() const {
54 return m_AssetsPath;
55 };
56
62 void SetPath(const std::filesystem::path& assetsPath) {
63 m_AssetsPath = assetsPath;
64 };
65
69 void InitAssets();
74 void UnloadAssets();
79 void LoadAssets();
90 void RenderImage(const char* name, ImDrawList* drawList,
91 const ImVec2& pos, const ImVec2& size,
92 const ImVec4& tint = ImVec4(1, 1, 1, 1));
100 uint32_t LoadImage(const char* name);
108 AudioData LoadSound(std::filesystem::path soundPath);
115 void PlaySound(AudioData data);
122 [[nodiscard]] ImFont* GetFontRegular() const { return m_FontRegular; }
129 [[nodiscard]] ImFont* GetFontBold() const { return m_FontBold; }
130
131 private:
132 std::filesystem::path m_AssetsPath;
134 ImFont* m_FontRegular = nullptr;
135 ImFont* m_FontBold = nullptr;
136 };
137} // namespace FuncDoodle
Audio loading and playback system for FuncDoodle.
ImGui/OpenGL/GLFW integration utilities and file dialog wrapper.
Convenience type aliases for standard smart pointers.
std::unique_ptr< T > UniquePtr
Alias for an exclusively owned smart pointer.
Definition Ptr.h:28
void LoadAssets()
Loads shared textures and sounds from disk.
Definition LoadedAssets.cc:24
void InitAssets()
Initializes fonts and other asset-backed runtime state.
Definition AssetLoader.cc:28
std::filesystem::path m_AssetsPath
Definition AssetLoader.h:132
uint32_t LoadImage(const char *name)
Loads an image asset and returns its texture handle.
Definition AssetLoader.cc:88
AssetLoader(std::filesystem::path assetsPath)
Creates an asset loader rooted at the given assets directory.
Definition AssetLoader.cc:19
ImFont * GetFontBold() const
Returns the bold UI font.
Definition AssetLoader.h:129
AudioData LoadSound(std::filesystem::path soundPath)
Loads a sound asset into memory.
Definition AssetLoader.cc:114
ImFont * GetFontRegular() const
Returns the regular UI font.
Definition AssetLoader.h:122
~AssetLoader()
Definition AssetLoader.cc:24
ImFont * m_FontRegular
Definition AssetLoader.h:134
void RenderImage(const char *name, ImDrawList *drawList, const ImVec2 &pos, const ImVec2 &size, const ImVec4 &tint=ImVec4(1, 1, 1, 1))
Draws a loaded image into an ImGui draw list.
Definition AssetLoader.cc:59
void PlaySound(AudioData data)
Plays decoded audio data through the audio manager.
Definition AssetLoader.cc:120
const std::filesystem::path & GetPath() const
Returns the current assets directory.
Definition AssetLoader.h:53
void UnloadAssets()
Releases loaded asset resources.
Definition AssetLoader.cc:53
void SetPath(const std::filesystem::path &assetsPath)
Changes the assets directory used for future loads.
Definition AssetLoader.h:62
UniquePtr< AudioManager > m_AudioManager
Definition AssetLoader.h:133
ImFont * m_FontBold
Definition AssetLoader.h:135
The FuncDoodle C++ namespace.
Definition Common.h:12
Represents raw PCM audio data.
Definition Audio.h:18