Added task loop for async stuff and getters for the loop and the VFS.

This commit is contained in:
Patrick 2025-03-04 00:56:39 +01:00
parent eb5def0070
commit 830fdd434b
3 changed files with 33 additions and 2 deletions

View File

@ -96,6 +96,8 @@ int Application::run(int argc, char** argv)
ImGui::Begin("##main", nullptr, mMainWindowFlags); ImGui::Begin("##main", nullptr, mMainWindowFlags);
render(); render();
mTaskLoop.tick();
ImGui::End(); ImGui::End();
ImGui::Render(); ImGui::Render();

View File

@ -8,13 +8,34 @@
namespace ImRaid namespace ImRaid
{ {
inline bool ToggleImageButton(const char* strId, ImTextureID textureId, const ImVec2& imageSize, bool& toggled) inline bool ToggleButton(const char* label, bool& toggled, const ImVec2& size = ImVec2(0, 0))
{ {
if (toggled) if (toggled)
{ {
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive)); ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive));
} }
const bool clicked = ImGui::ImageButton(strId, textureId, imageSize); const bool clicked = ImGui::Button(label, size);
if (toggled)
{
ImGui::PopStyleColor();
}
if (clicked)
{
toggled = !toggled;
}
return clicked;
}
inline bool ToggleImageButton(const char* strId, ImTextureID textureId, const ImVec2& imageSize, bool& toggled,
const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1),
const ImVec4& bgCol = ImVec4(0, 0, 0, 0), const ImVec4& tintCol = ImVec4(1, 1, 1, 1))
{
if (toggled)
{
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyleColorVec4(ImGuiCol_ButtonActive));
}
const bool clicked = ImGui::ImageButton(strId, textureId, imageSize, uv0, uv1, bgCol, tintCol);
if (toggled) if (toggled)
{ {
ImGui::PopStyleColor(); ImGui::PopStyleColor();

View File

@ -8,6 +8,7 @@
#include <functional> #include <functional>
#include <fmt/format.h> #include <fmt/format.h>
#include <imgui.h> #include <imgui.h>
#include <mijin/async/coroutine.hpp>
#include <mijin/virtual_filesystem/stacked.hpp> #include <mijin/virtual_filesystem/stacked.hpp>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
@ -40,6 +41,7 @@ private:
SDL_GLContext mGLContext = nullptr; SDL_GLContext mGLContext = nullptr;
mijin::StackedFileSystemAdapter mFS; mijin::StackedFileSystemAdapter mFS;
mijin::SimpleTaskLoop mTaskLoop;
std::unordered_map<fs::path, ImTextureID> mTextures; std::unordered_map<fs::path, ImTextureID> mTextures;
bool mRunning = true; bool mRunning = true;
@ -72,6 +74,12 @@ private:
public: public:
virtual ~Application() = default; virtual ~Application() = default;
[[nodiscard]]
const mijin::StackedFileSystemAdapter& getFS() const { return mFS; }
[[nodiscard]]
mijin::SimpleTaskLoop& getLoop() { return mTaskLoop; }
[[nodiscard]] [[nodiscard]]
ImGuiWindowFlags getMainWindowFlags() const { return mMainWindowFlags; } ImGuiWindowFlags getMainWindowFlags() const { return mMainWindowFlags; }