Skip to content

Commit

Permalink
fix(engine): add toolbox requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Teresa Margarida Vargas De Matos authored and teres4 committed Nov 28, 2023
1 parent 8811c46 commit 2ab5765
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace tesseratos
/// ## Dependencies
/// - @ref imgui-plugin
/// - @ref assets-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Event sent when an asset is selected.
struct AssetSelectedEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace tesseratos
/// ## Dependencies
/// - @ref imgui-plugin
/// - @ref renderer-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace tesseratos
/// ## Dependencies
/// - @ref imgui-plugin
/// - @ref tesseratos-entity-selector-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ namespace tesseratos
///
/// ## Resources
/// - @ref EntitySelector - identifies the currently selected entity.
///
/// ## Dependencies
/// - @ref tesseratos-toolbox-plugin

/// @brief Resource which identifies the currently selected entity.
struct EntitySelector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace tesseratos
/// - @ref scene-plugin
/// - @ref tesseratos-asset-explorer-plugin
/// - @ref tesseratos-entity-selector-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace tesseratos
/// ## Dependencies
/// - @ref settings-plugin
/// - @ref imgui-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
35 changes: 28 additions & 7 deletions tools/tesseratos/include/tesseratos/toolbox/plugin.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// @dir
/// @brief @ref toolbox-plugin plugin directory.
/// @brief @ref tesseratos-toolbox-plugin plugin directory.

/// @file
/// @brief Plugin entry point.
/// @ingroup toolbox-plugin
/// @ingroup tesseratos-toolbox-plugin

#pragma once

Expand All @@ -14,33 +14,54 @@ namespace tesseratos
/// @defgroup tesseratos-toolbox-plugin Toolbox
/// @ingroup tesseratos
/// @brief Adds a resource used to keep track of whether each tool is open or not.
///
///
/// ## Resources
/// - @ref Toolbox
///
/// ## Dependencies
/// - @ref imguiPlugin

/// @brief Resource which manages other tools windows.
/// @ingroup tesseratos-toolbox-plugin
class Toolbox final
{
public:
/// @brief When called for the first time for a given name stores a new boolean for it, by default set to false.
/// @param toolName The tools name
///@return Tools associated boolean.
bool isOpen(std::string toolName);

/// @brief Opens a tool
/// @param toolName The tools name
void open(std::string toolName);

/// @brief Closes a tool
/// @param toolName The tools name
void close(std::string toolName);

/// @brief Sets the boolean of a tool to its logical opposite state
/// @param toolName The tools name
void doClick(std::string toolName);

auto begin();
/// @brief Returns the beggining of the ToolsMap
/// @return begginng of the map
auto begin() const
{
return mToolsMap.begin();
}

auto end();
/// @brief Returns the end of the ToolsMap
/// @return end of the map
auto end() const
{
return mToolsMap.end();
}

private:
std::unordered_map<std::string, bool> mToolsMap;
};

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
/// @ingroup toolbox-plugin
/// @ingroup tesseratos-toolbox-plugin
void toolboxPlugin(cubos::engine::Cubos& cubos);
} // namespace tesseratos
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace tesseratos
/// @defgroup tesseratos-voxel-palette-editor-plugin Palette editor
/// @ingroup tesseratos
/// @brief Allows the user to open and inspect/edit a palette asset.
///
/// ## Dependencies
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace tesseratos
/// ## Dependencies
/// - @ref imgui-plugin
/// - @ref tesseratos-entity-selector-plugin
/// - @ref tesseratos-toolbox-plugin

/// @brief Plugin entry function.
/// @param cubos @b CUBOS. main class
Expand Down
2 changes: 0 additions & 2 deletions tools/tesseratos/src/tesseratos/entity_inspector/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ static void inspectEntity(Write<World> world)
return;
}

auto selection = world->read<EntitySelector>().get().selection;

ImGui::Begin("Entity Inspector");
if (!ImGui::IsWindowCollapsed())
{
Expand Down
18 changes: 4 additions & 14 deletions tools/tesseratos/src/tesseratos/toolbox/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <tesseratos/toolbox/plugin.hpp>

using cubos::core::ecs::EventWriter;
using cubos::core::ecs::Read;
using cubos::core::ecs::Write;

using cubos::core::ecs::Write;
Expand Down Expand Up @@ -38,25 +37,16 @@ void Toolbox::doClick(std::string toolName)
mToolsMap[toolName] = !mToolsMap[toolName];
}

auto Toolbox::begin()
{
return mToolsMap.begin();
}

auto Toolbox::end()
{
return mToolsMap.end();
}

static void showToolbox(Write<Toolbox> toolbox)
{
ImGui::Begin("Toolbox");

for (auto it = toolbox->begin(); it != toolbox->end(); ++it)
for (const auto& [tool, open] : *toolbox)
{
if (ImGui::Button(data(it->first)))
bool check = open;
if (ImGui::Checkbox(data(tool), &check))
{
toolbox->doClick(it->first);
toolbox->doClick(tool);
}
}

Expand Down

0 comments on commit 2ab5765

Please sign in to comment.