Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Madman10K committed Oct 26, 2024
1 parent bd08571 commit 5f42f06
Show file tree
Hide file tree
Showing 35 changed files with 217 additions and 331 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
.vs/
.idea/
build/
cmake-build-debug/
cmake-build-release/
cmake-build-relwithdebinfo/
cmake-build-*/
Generated/
Exported/
UVKBuildTool/
Expand Down
19 changes: 7 additions & 12 deletions Source/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "IncusBindings/libUGM_Incus_InternalFuncs.h"
#include "Interfaces/RendererInterface.hpp"

UntitledGameSystemManager::Instance::Instance()
UntitledGameSystemManager::Instance::Instance() noexcept
{
initInfo = UImGui::InitInfo
{
Expand All @@ -29,7 +29,7 @@ UntitledGameSystemManager::Instance::Instance()
&connectionPopup,
&genericErrorPopup
},
.globalData = (void*)this,
.globalData = static_cast<void*>(this),
.bGlobalAllocatedOnHeap = false,
UIMGUI_INIT_INFO_DEFAULT_DIRS,
};
Expand All @@ -47,7 +47,7 @@ UntitledGameSystemManager::Instance::Instance()
std::filesystem::copy(UIMGUI_CONFIG_DIR"Dist", std::filesystem::path(configDir)/"scripts/");
}

void UntitledGameSystemManager::Instance::begin()
void UntitledGameSystemManager::Instance::begin() noexcept
{
beginAutohandle();
loadConfigData();
Expand All @@ -60,7 +60,7 @@ void UntitledGameSystemManager::Instance::begin()
}
}

void UntitledGameSystemManager::Instance::tick(float deltaTime)
void UntitledGameSystemManager::Instance::tick(const float deltaTime) noexcept
{
tickAutohandle(deltaTime);
if (bWorkerActive && bFinishedExecution && worker.joinable())
Expand All @@ -71,7 +71,7 @@ void UntitledGameSystemManager::Instance::tick(float deltaTime)
}
}

void UntitledGameSystemManager::Instance::end()
void UntitledGameSystemManager::Instance::end() noexcept
{
endAutohandle();
if (worker.joinable())
Expand All @@ -80,12 +80,7 @@ void UntitledGameSystemManager::Instance::end()
IncusDestroyConnection();
}

UntitledGameSystemManager::Instance::~Instance()
{

}

void UntitledGameSystemManager::Instance::onEventConfigureStyle(ImGuiStyle& style, ImGuiIO& io)
void UntitledGameSystemManager::Instance::onEventConfigureStyle(ImGuiStyle& style, ImGuiIO& io) noexcept
{
}

Expand Down Expand Up @@ -135,7 +130,7 @@ File in question: )", ULOG_LOG_TYPE_ERROR, configDir, "config/layout.yaml");
}
}

YAML::Node UntitledGameSystemManager::Instance::loadConfigGeneric() noexcept
YAML::Node UntitledGameSystemManager::Instance::loadConfigGeneric()
{
YAML::Node out;
try
Expand Down
16 changes: 8 additions & 8 deletions Source/Instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ namespace UntitledGameSystemManager
bool bFinishedExecution = false;
};

class UIMGUI_PUBLIC_API Instance : public UImGui::Instance
class UIMGUI_PUBLIC_API Instance final : public UImGui::Instance
{
public:
Instance();
virtual void begin() override;
virtual void tick(float deltaTime) override;
virtual void end() override;
virtual ~Instance() override;
Instance() noexcept;
virtual void begin() noexcept override;
virtual void tick(float deltaTime) noexcept override;
virtual void end() noexcept override;
virtual ~Instance() noexcept override = default;

virtual void onEventConfigureStyle(ImGuiStyle& style, ImGuiIO& io) override;
virtual void onEventConfigureStyle(ImGuiStyle& style, ImGuiIO& io) noexcept override;

void loadConfigData();

Expand All @@ -63,7 +63,7 @@ namespace UntitledGameSystemManager

GenericErrorPopup genericErrorPopup{};

YAML::Node loadConfigGeneric() noexcept;
YAML::Node loadConfigGeneric();
void outputConfig(const YAML::Node& node) const noexcept;
private:
friend class MainBar;
Expand Down
21 changes: 5 additions & 16 deletions Source/MainView/MainBar.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#include "MainBar.hpp"
#include "Instance.hpp"

UntitledGameSystemManager::MainBar::MainBar()
{

}

void UntitledGameSystemManager::MainBar::begin()
void UntitledGameSystemManager::MainBar::begin() noexcept
{
beginAutohandle();

}

void UntitledGameSystemManager::MainBar::tick(float deltaTime)
void UntitledGameSystemManager::MainBar::tick(const float deltaTime) noexcept
{
tickAutohandle(deltaTime);
if (ImGui::BeginMainMenuBar())
{
// Get the instance from the global
auto* inst = (Instance*)Instance::getGlobal();
auto* inst = static_cast<Instance*>(Instance::getGlobal());
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("New Container"))
Expand Down Expand Up @@ -56,14 +51,8 @@ void UntitledGameSystemManager::MainBar::tick(float deltaTime)

}

void UntitledGameSystemManager::MainBar::end()
void UntitledGameSystemManager::MainBar::end() noexcept
{
endAutohandle();

}

UntitledGameSystemManager::MainBar::~MainBar()
{

}

}
12 changes: 6 additions & 6 deletions Source/MainView/MainBar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace UntitledGameSystemManager
{
class UIMGUI_PUBLIC_API MainBar : public UImGui::TitlebarComponent
class UIMGUI_PUBLIC_API MainBar final : public UImGui::TitlebarComponent
{
public:
MainBar();
virtual void begin() override;
virtual void tick(float deltaTime) override;
virtual void end() override;
virtual ~MainBar() override;
MainBar() noexcept = default;
virtual void begin() noexcept override;
virtual void tick(float deltaTime) noexcept override;
virtual void end() noexcept override;
virtual ~MainBar() noexcept override = default;
private:

};
Expand Down
22 changes: 6 additions & 16 deletions Source/MainView/MainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@
#include <ranges>
#include "Instance.hpp"

UntitledGameSystemManager::MainView::MainView()
{

}

void UntitledGameSystemManager::MainView::begin()
void UntitledGameSystemManager::MainView::begin() noexcept
{
beginAutohandle();

}

void UntitledGameSystemManager::MainView::tick(float deltaTime)
void UntitledGameSystemManager::MainView::tick(const float deltaTime) noexcept
{
tickAutohandle(deltaTime);

ImGui::Begin("Main", (void*)nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_MenuBar);
auto* inst = (Instance*)UImGui::Instance::getGlobal();
ImGui::Begin("Main", static_cast<void*>(nullptr), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_MenuBar);
auto* inst = static_cast<Instance*>(UImGui::Instance::getGlobal());

if (inst->selectedContainer != nullptr)
{
Expand Down Expand Up @@ -110,13 +105,8 @@ void UntitledGameSystemManager::MainView::tick(float deltaTime)
ImGui::End();
}

void UntitledGameSystemManager::MainView::end()
void UntitledGameSystemManager::MainView::end() noexcept
{
endAutohandle();

}

UntitledGameSystemManager::MainView::~MainView()
{

}
}
12 changes: 6 additions & 6 deletions Source/MainView/MainView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace UntitledGameSystemManager
{
class UIMGUI_PUBLIC_API MainView : public UImGui::WindowComponent
class UIMGUI_PUBLIC_API MainView final : public UImGui::WindowComponent
{
public:
MainView();
virtual void begin() override;
virtual void tick(float deltaTime) override;
virtual void end() override;
virtual ~MainView() override;
MainView() noexcept = default;
virtual void begin() noexcept override;
virtual void tick(float deltaTime) noexcept override;
virtual void end() noexcept override;
virtual ~MainView() noexcept override = default;
private:

};
Expand Down
26 changes: 7 additions & 19 deletions Source/MainView/SidePanel.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
#include "SidePanel.hpp"
#include "Instance.hpp"

UntitledGameSystemManager::SidePanel::SidePanel()
{

}

void UntitledGameSystemManager::SidePanel::begin()
void UntitledGameSystemManager::SidePanel::begin() noexcept
{
beginAutohandle();

}

void UntitledGameSystemManager::SidePanel::tick(float deltaTime)
void UntitledGameSystemManager::SidePanel::tick(const float deltaTime) noexcept
{
tickAutohandle(deltaTime);

ImGui::Begin("Sidebar", (bool*)nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_MenuBar);
ImGui::Begin("Sidebar", static_cast<bool*>(nullptr), ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_MenuBar);

auto* inst = (Instance*)UImGui::Instance::getGlobal();
auto* inst = static_cast<Instance*>(UImGui::Instance::getGlobal());
if (ImGui::BeginMenuBar())
{
if (ImGui::MenuItem("* Refresh"))
Expand Down Expand Up @@ -50,11 +45,10 @@ void UntitledGameSystemManager::SidePanel::tick(float deltaTime)
ImGui::EndMenuBar();
}

bool bSelected;
size_t i = 0; // Generates unique IDs
for (auto& a : inst->containers)
{
bSelected = false;
bool bSelected = false;
if (inst->selectedContainer == &a)
{
ImGui::PushStyleColor(ImGuiCol_Button, { 0.87f, 0.64f, 0.03, 1.0f });
Expand All @@ -78,14 +72,8 @@ void UntitledGameSystemManager::SidePanel::tick(float deltaTime)
ImGui::End();
}

void UntitledGameSystemManager::SidePanel::end()
void UntitledGameSystemManager::SidePanel::end() noexcept
{
endAutohandle();

}

UntitledGameSystemManager::SidePanel::~SidePanel()
{

}

}
12 changes: 6 additions & 6 deletions Source/MainView/SidePanel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

namespace UntitledGameSystemManager
{
class UIMGUI_PUBLIC_API SidePanel : public UImGui::WindowComponent
class UIMGUI_PUBLIC_API SidePanel final : public UImGui::WindowComponent
{
public:
SidePanel();
virtual void begin() override;
virtual void tick(float deltaTime) override;
virtual void end() override;
virtual ~SidePanel() override;
SidePanel() noexcept = default;
virtual void begin() noexcept override;
virtual void tick(float deltaTime) noexcept override;
virtual void end() noexcept override;
virtual ~SidePanel() noexcept override = default;
private:
};
}
Expand Down
26 changes: 10 additions & 16 deletions Source/Submenus/Edit/Delete.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#include "Delete.hpp"
#include "Instance.hpp"

UntitledGameSystemManager::Delete::Delete()
UntitledGameSystemManager::Delete::Delete() noexcept
{
state = UIMGUI_COMPONENT_STATE_PAUSED;
}

void UntitledGameSystemManager::Delete::begin()
void UntitledGameSystemManager::Delete::begin() noexcept
{
beginAutohandle();

}

void UntitledGameSystemManager::Delete::tick(float deltaTime)
void UntitledGameSystemManager::Delete::tick(const float deltaTime) noexcept
{
tickAutohandle(deltaTime);
auto* inst = (Instance*)UImGui::Instance::getGlobal();
auto* inst = static_cast<Instance*>(UImGui::Instance::getGlobal());
if (inst->selectedContainer != nullptr)
{
if (!ImGui::IsPopupOpen("Delete"))
ImGui::OpenPopup("Delete");
if (ImGui::BeginPopupModal("Delete", (bool*)nullptr))
if (ImGui::BeginPopupModal("Delete", static_cast<bool*>(nullptr)))
{
ImGui::TextWrapped("This action WILL DELETE the currently selected container! This CANNOT be undone!");

Expand All @@ -29,8 +29,8 @@ void UntitledGameSystemManager::Delete::tick(float deltaTime)
inst->bWorkerActive = true;
inst->worker = std::thread([inst, this]() -> void
{
UImGui::FString name;
UImGui::FString configDir;
UImGui::FString name;
UImGui::FString configDir;

{
const std::lock_guard<std::mutex> lock(mutex);
Expand Down Expand Up @@ -63,7 +63,7 @@ void UntitledGameSystemManager::Delete::tick(float deltaTime)
inst->outputConfig(o);

state = UIMGUI_COMPONENT_STATE_PAUSED;
((Instance*)UImGui::Instance::getGlobal())->bFinishedExecution = true;
static_cast<Instance*>(UImGui::Instance::getGlobal())->bFinishedExecution = true;

inst->loadConfigData();
inst->selectedContainer = nullptr;
Expand All @@ -77,14 +77,8 @@ void UntitledGameSystemManager::Delete::tick(float deltaTime)
}
}

void UntitledGameSystemManager::Delete::end()
void UntitledGameSystemManager::Delete::end() noexcept
{
endAutohandle();

}

UntitledGameSystemManager::Delete::~Delete()
{

}

}
Loading

0 comments on commit 5f42f06

Please sign in to comment.