Skip to content

Commit

Permalink
feat(tesseratos): add Menu Bar plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbaracho committed Jan 31, 2025
1 parent 06856c9 commit 1a168f8
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- SSAO resolution scale (#1423, **@tomas7770**).
- Enable ImGui docking branch and modify Tesseratos to accommodate it (#839, **@jdbaracho**).
- Add a Menu Bar to Tesseratos (#1234, **@jdbaracho**).

### Changed

Expand Down
1 change: 1 addition & 0 deletions tools/tesseratos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ option(TESSERATOS_DISTRIBUTE "Build tesseratos for distribution" OFF)

set(TESSERATOS_SOURCE
"src/tesseratos/main.cpp"
"src/tesseratos/menu_bar/plugin.cpp"
"src/tesseratos/debugger/plugin.cpp"
"src/tesseratos/debugger/debugger.cpp"
"src/tesseratos/project/plugin.cpp"
Expand Down
6 changes: 5 additions & 1 deletion tools/tesseratos/src/tesseratos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include <cubos/engine/settings/plugin.hpp>
#include <cubos/engine/settings/settings.hpp>
#include <cubos/engine/tools/plugin.hpp>
#include <cubos/engine/tools/selection/plugin.hpp>
#include <cubos/engine/utils/free_camera/plugin.hpp>

#include "menu_bar/plugin.hpp"
#include "asset_explorer/plugin.hpp"
#include "debugger/plugin.hpp"
#include "importer/plugin.hpp"
Expand All @@ -32,7 +34,7 @@ int main(int argc, char** argv)
// The third block contains plugins which depend on plugins from the first and second blocks.
// And so on.

cubos.plugin(cubos::engine::toolsPlugin);
cubos.plugin(selectionPlugin);

cubos.plugin(debuggerPlugin);
cubos.plugin(assetExplorerPlugin);
Expand All @@ -43,6 +45,8 @@ int main(int argc, char** argv)
cubos.plugin(voxelPaletteEditorPlugin);
cubos.plugin(importerPlugin);

cubos.plugin(menuBarPlugin);

cubos.startupSystem("configure Assets plugin").before(cubos::engine::settingsTag).call([](Settings& settings) {
settings.setString("assets.app.osPath", APP_ASSETS_PATH);
settings.setString("assets.builtin.osPath", BUILTIN_ASSETS_PATH);
Expand Down
96 changes: 96 additions & 0 deletions tools/tesseratos/src/tesseratos/menu_bar/plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "plugin.hpp"

#include <cubos/engine/defaults/plugin.hpp>
#include <cubos/engine/imgui/plugin.hpp>

#include "../asset_explorer/plugin.hpp"
#include "../debugger/plugin.hpp"
#include "../importer/plugin.hpp"
#include "../project/plugin.hpp"
#include "../scene_editor/plugin.hpp"
#include "../voxel_palette_editor/plugin.hpp"

using namespace cubos::engine;
using namespace tesseratos;

void tesseratos::menuBarPlugin(Cubos& cubos)
{
cubos.depends(imguiPlugin);

cubos.depends(debuggerPlugin);
cubos.depends(assetExplorerPlugin);

cubos.depends(projectPlugin);

cubos.depends(sceneEditorPlugin);
cubos.depends(voxelPaletteEditorPlugin);
cubos.depends(importerPlugin);

cubos.system("setup Menu Bar")
.tagged(imguiTag)
.call([](AssetExplorerTool& assetExplorerTool, DebuggerTool& debuggerTool,ProjectTool& projectTool,
ImporterTool& importerTool, SceneEditorTool& sceneEditorTool, VoxelPalleteEditorTool& voxelPalleteEditorTool) {

ImGui::Begin("Tesseratos");

if (ImGui::BeginMenuBar())
{
if (ImGui::BeginMenu("Project"))
{
ImGui::MenuItem("New...", "Ctrl+N");
ImGui::MenuItem("Open...", "Ctrl+O");
ImGui::MenuItem("Browse in Bridge...", "Alt+Ctrl+O");
ImGui::MenuItem("Open As...", "Alt+Shift+Ctrl+O");
if(ImGui::BeginMenu("Open Recent")) {
ImGui::Text("No recent files...");
ImGui::EndMenu();
}
ImGui::Separator();

ImGui::MenuItem("Close", "Ctrl+W");
ImGui::MenuItem("Close All", "Alt+Ctrl+W");
ImGui::Separator();

ImGui::MenuItem("Save", "Ctrl+S");
ImGui::MenuItem("Save As", "Shift+Ctrl+S");
ImGui::MenuItem("Revert", "F12");
ImGui::Separator();

ImGui::MenuItem("Export");
ImGui::MenuItem("Generate");
ImGui::MenuItem("Share");
ImGui::Separator();

ImGui::MenuItem("Print...", "Ctrl+P");
ImGui::MenuItem("Print One Copy", "Ctrl+P");
ImGui::Separator();

ImGui::MenuItem("File Info...", "Alt+Shift+Ctrl+1");
ImGui::MenuItem("Exit", "Ctrl+Q");

ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit"))
{
ImGui::MenuItem("Fullscreen");
ImGui::MenuItem("Padding");
ImGui::EndMenu();
}
if (ImGui::BeginMenu("View"))
{
ImGui::MenuItem("Asset Explorer", "", &assetExplorerTool.isOpen);
ImGui::MenuItem("Debugger", "", &debuggerTool.isOpen);
ImGui::MenuItem("Importer", "", &importerTool.isOpen);
ImGui::MenuItem("Project", "", &projectTool.isOpen);
ImGui::MenuItem("Scene Editor", "", &sceneEditorTool.isOpen);
ImGui::MenuItem("Voxel Pallete Editor", "", &voxelPalleteEditorTool.isOpen);

ImGui::EndMenu();
}

ImGui::EndMenuBar();
}

ImGui::End();
});
}
22 changes: 22 additions & 0 deletions tools/tesseratos/src/tesseratos/menu_bar/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// @dir
/// @brief @ref tesseratos-menu-bar-plugin plugin directory.

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

#pragma once

#include <cubos/engine/prelude.hpp>

namespace tesseratos
{
/// @defgroup tesseratos-menu-bar-plugin Menu bar
/// @ingroup tesseratos
/// @brief Adds a menu bar to tesseratos.

/// @brief Plugin entry function.
/// @param cubos @b Cubos main class
/// @ingroup tesseratos-menu-bar-plugin
void menuBarPlugin(cubos::engine::Cubos& cubos);
} // namespace tesseratos

0 comments on commit 1a168f8

Please sign in to comment.