refactor(editor): reorganize includes and enhance EditorManager initialization
- Moved the declaration of `AgentControlServer` to a forward declaration in the header file for better clarity and organization. - Updated the `EditorManager` constructor to initialize the version string and popup manager context. - Added conditional compilation for gRPC-related includes and commented out the agent control server initialization for future reference. - Ensured consistent definition of `IMGUI_DEFINE_MATH_OPERATORS` across multiple files to prevent potential issues with ImGui usage. Benefits: - Improved code organization and readability. - Enhanced maintainability by clarifying the initialization process and managing includes effectively.
This commit is contained in:
@@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
#if defined(YAZE_WITH_GRPC)
|
#if defined(YAZE_WITH_GRPC)
|
||||||
|
|
||||||
|
// Must define before any ImGui includes (test_manager.h includes ImGui headers)
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "absl/synchronization/mutex.h"
|
#include "absl/synchronization/mutex.h"
|
||||||
|
|||||||
@@ -47,25 +47,29 @@
|
|||||||
#ifdef YAZE_ENABLE_GTEST
|
#ifdef YAZE_ENABLE_GTEST
|
||||||
#include "app/test/unit_test_suite.h"
|
#include "app/test/unit_test_suite.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef YAZE_WITH_GRPC
|
|
||||||
#include "app/test/z3ed_test_suite.h"
|
|
||||||
#endif
|
|
||||||
#include "app/editor/system/settings_editor.h"
|
#include "app/editor/system/settings_editor.h"
|
||||||
#include "app/editor/system/toast_manager.h"
|
#include "app/editor/system/toast_manager.h"
|
||||||
#include "app/emu/emulator.h"
|
#include "app/emu/emulator.h"
|
||||||
#include "app/gfx/performance/performance_dashboard.h"
|
#include "app/gfx/performance/performance_dashboard.h"
|
||||||
#include "app/editor/editor.h"
|
#include "app/editor/editor.h"
|
||||||
|
|
||||||
#ifdef YAZE_WITH_GRPC
|
#ifdef YAZE_WITH_GRPC
|
||||||
#include "app/core/service/screenshot_utils.h"
|
#include "app/core/service/screenshot_utils.h"
|
||||||
#include "app/editor/agent/agent_chat_widget.h"
|
#include "app/editor/agent/agent_chat_widget.h"
|
||||||
#include "cli/service/agent/agent_control_server.h"
|
#include "cli/service/agent/agent_control_server.h"
|
||||||
#include "cli/service/agent/conversational_agent_service.h"
|
#include "cli/service/agent/conversational_agent_service.h"
|
||||||
#include "cli/service/ai/gemini_ai_service.h"
|
#include "cli/service/ai/gemini_ai_service.h"
|
||||||
|
#include "app/test/z3ed_test_suite.h"
|
||||||
|
|
||||||
#include "absl/flags/flag.h"
|
#include "absl/flags/flag.h"
|
||||||
#endif
|
|
||||||
#ifdef YAZE_WITH_GRPC
|
// Declare the agent_control flag (defined in src/cli/flags.cc)
|
||||||
|
// ABSL_DECLARE_FLAG(bool, agent_control);
|
||||||
|
|
||||||
#include "app/editor/agent/automation_bridge.h"
|
#include "app/editor/agent/automation_bridge.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
@@ -86,7 +90,15 @@ std::string GetEditorName(EditorType type) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
EditorManager::EditorManager() : blank_editor_set_(nullptr, &user_settings_) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << YAZE_VERSION_MAJOR << "." << YAZE_VERSION_MINOR << "."
|
||||||
|
<< YAZE_VERSION_PATCH;
|
||||||
|
ss >> version_;
|
||||||
|
context_.popup_manager = popup_manager_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorManager::~EditorManager() = default;
|
||||||
|
|
||||||
void EditorManager::InitializeTestSuites() {
|
void EditorManager::InitializeTestSuites() {
|
||||||
auto& test_manager = test::TestManager::Get();
|
auto& test_manager = test::TestManager::Get();
|
||||||
@@ -543,10 +555,10 @@ void EditorManager::Initialize(gfx::IRenderer* renderer, const std::string& file
|
|||||||
[this]() { proposal_drawer_.Toggle(); });
|
[this]() { proposal_drawer_.Toggle(); });
|
||||||
|
|
||||||
// Start the agent control server if the flag is set
|
// Start the agent control server if the flag is set
|
||||||
if (absl::GetFlag(FLAGS_agent_control)) {
|
// if (absl::GetFlag(FLAGS_agent_control)) {
|
||||||
agent_control_server_ = std::make_unique<agent::AgentControlServer>(&emulator_);
|
// agent_control_server_ = std::make_unique<agent::AgentControlServer>(&emulator_);
|
||||||
agent_control_server_->Start();
|
// agent_control_server_->Start();
|
||||||
}
|
// }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Testing shortcuts (only when tests are enabled)
|
// Testing shortcuts (only when tests are enabled)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#ifndef YAZE_APP_EDITOR_EDITOR_MANAGER_H
|
#ifndef YAZE_APP_EDITOR_EDITOR_MANAGER_H
|
||||||
#define YAZE_APP_EDITOR_EDITOR_MANAGER_H
|
#define YAZE_APP_EDITOR_EDITOR_MANAGER_H
|
||||||
|
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
|
||||||
#include "app/editor/system/user_settings.h"
|
#include "app/editor/system/user_settings.h"
|
||||||
#include "app/editor/ui/workspace_manager.h"
|
#include "app/editor/ui/workspace_manager.h"
|
||||||
#define IMGUI_DEFINE_MATH_OPERATORS
|
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
@@ -42,6 +43,10 @@
|
|||||||
#include "yaze_config.h"
|
#include "yaze_config.h"
|
||||||
|
|
||||||
#ifdef YAZE_WITH_GRPC
|
#ifdef YAZE_WITH_GRPC
|
||||||
|
// Forward declarations for gRPC-dependent types
|
||||||
|
namespace yaze::agent {
|
||||||
|
class AgentControlServer;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
@@ -103,13 +108,9 @@ class EditorSet {
|
|||||||
*/
|
*/
|
||||||
class EditorManager {
|
class EditorManager {
|
||||||
public:
|
public:
|
||||||
EditorManager() : blank_editor_set_(nullptr, &user_settings_) {
|
// Constructor and destructor must be defined in .cc file for std::unique_ptr with forward-declared types
|
||||||
std::stringstream ss;
|
EditorManager();
|
||||||
ss << YAZE_VERSION_MAJOR << "." << YAZE_VERSION_MINOR << "."
|
~EditorManager();
|
||||||
<< YAZE_VERSION_PATCH;
|
|
||||||
ss >> version_;
|
|
||||||
context_.popup_manager = popup_manager_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Initialize(gfx::IRenderer* renderer, const std::string& filename = "");
|
void Initialize(gfx::IRenderer* renderer, const std::string& filename = "");
|
||||||
|
|
||||||
@@ -278,7 +279,7 @@ class EditorManager {
|
|||||||
#ifdef YAZE_WITH_GRPC
|
#ifdef YAZE_WITH_GRPC
|
||||||
// Agent editor - manages chat, collaboration, and network coordination
|
// Agent editor - manages chat, collaboration, and network coordination
|
||||||
AgentEditor agent_editor_;
|
AgentEditor agent_editor_;
|
||||||
std::unique_ptr<agent::AgentControlServer> agent_control_server_;
|
std::unique_ptr<yaze::agent::AgentControlServer> agent_control_server_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string version_ = "";
|
std::string version_ = "";
|
||||||
|
|||||||
@@ -6,6 +6,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// Must define before including imgui.h
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
@@ -5,6 +5,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// Must define before including imgui.h
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Must define before including imgui.h
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
|
|||||||
@@ -5,6 +5,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// Must define before including imgui.h
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "app/gui/icons.h"
|
#include "app/gui/icons.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
// AppDelegate.mm
|
// AppDelegate.mm
|
||||||
|
|
||||||
|
// Must define before any ImGui includes (needed by imgui_test_engine via editor_manager.h)
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#import "app/platform/app_delegate.h"
|
#import "app/platform/app_delegate.h"
|
||||||
#import "app/core/controller.h"
|
#import "app/core/controller.h"
|
||||||
#import "util/file_util.h"
|
#import "util/file_util.h"
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// Must define before any ImGui includes
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
// Updated for DungeonEditorV2 architecture - uses ObjectDrawer (production system)
|
// Updated for DungeonEditorV2 architecture - uses ObjectDrawer (production system)
|
||||||
// instead of the obsolete ObjectRenderer
|
// instead of the obsolete ObjectRenderer
|
||||||
|
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "app/zelda3/dungeon/object_drawer.h"
|
#include "app/zelda3/dungeon/object_drawer.h"
|
||||||
#include "app/zelda3/dungeon/room.h"
|
#include "app/zelda3/dungeon/room.h"
|
||||||
#include "app/zelda3/dungeon/room_object.h"
|
#include "app/zelda3/dungeon/room_object.h"
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef YAZE_TEST_TEST_UTILS_H
|
#ifndef YAZE_TEST_TEST_UTILS_H
|
||||||
#define YAZE_TEST_TEST_UTILS_H
|
#define YAZE_TEST_TEST_UTILS_H
|
||||||
|
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
#define SDL_MAIN_HANDLED
|
#define SDL_MAIN_HANDLED
|
||||||
|
|
||||||
|
// Must define before any ImGui includes
|
||||||
|
#ifndef IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
Reference in New Issue
Block a user