feat: Introduce Debugging and Testing Guide with enhanced startup options

- Added a new document, E5-debugging-guide.md, providing comprehensive strategies for debugging and testing the `yaze` application, including logging practices and testing frameworks.
- Updated E2-development-guide.md to include a new section on debugging and testing, detailing quick debugging methods using command-line flags for specific editors and UI cards.
- Enhanced the main application to support command-line flags for opening specific editors and cards on startup, improving the developer experience.
- Refactored the Controller class to handle startup editor and card initialization based on command-line inputs.
This commit is contained in:
scawful
2025-10-09 17:19:36 -04:00
parent b3c6fd6e12
commit e769cea1d9
32 changed files with 1044 additions and 413 deletions

View File

@@ -2,6 +2,8 @@
#include "app/editor/system/toast_manager.h"
#include "app/rom.h"
#include "absl/strings/str_format.h"
#include "util/file_util.h"
#include "util/platform_paths.h"
namespace yaze {
namespace editor {
@@ -31,6 +33,27 @@ absl::Status WorkspaceManager::ResetWorkspaceLayout() {
}
void WorkspaceManager::SaveWorkspacePreset(const std::string& name) {
if (name.empty()) return;
std::string ini_name = absl::StrFormat("yaze_workspace_%s.ini", name.c_str());
ImGui::SaveIniSettingsToDisk(ini_name.c_str());
if (!workspace_presets_loaded_) {
// RefreshWorkspacePresets(); // This will be implemented next
}
if (std::find(workspace_presets_.begin(), workspace_presets_.end(), name) ==
workspace_presets_.end()) {
workspace_presets_.emplace_back(name);
try {
std::ostringstream ss;
for (const auto& n : workspace_presets_)
ss << n << "\n";
// This should use a platform-agnostic path
util::SaveFile("workspace_presets.txt", ss.str());
} catch (const std::exception& e) {
// LOG_WARN("WorkspaceManager", "Failed to save presets: %s", e.what());
}
}
last_workspace_preset_ = name;
if (toast_manager_) {
toast_manager_->Show(absl::StrFormat("Preset '%s' saved", name),
@@ -39,6 +62,9 @@ void WorkspaceManager::SaveWorkspacePreset(const std::string& name) {
}
void WorkspaceManager::LoadWorkspacePreset(const std::string& name) {
if (name.empty()) return;
std::string ini_name = absl::StrFormat("yaze_workspace_%s.ini", name.c_str());
ImGui::LoadIniSettingsFromDisk(ini_name.c_str());
last_workspace_preset_ = name;
if (toast_manager_) {
toast_manager_->Show(absl::StrFormat("Preset '%s' loaded", name),
@@ -46,6 +72,34 @@ void WorkspaceManager::LoadWorkspacePreset(const std::string& name) {
}
}
void WorkspaceManager::RefreshPresets() {
try {
std::vector<std::string> new_presets;
auto config_dir = util::PlatformPaths::GetConfigDirectory();
if (config_dir.ok()) {
std::string presets_path = (*config_dir / "workspace_presets.txt").string();
auto data = util::LoadFile(presets_path);
if (!data.empty()) {
std::istringstream ss(data);
std::string name;
while (std::getline(ss, name)) {
name.erase(0, name.find_first_not_of(" \t\r\n"));
name.erase(name.find_last_not_of(" \t\r\n") + 1);
if (!name.empty() && name.length() < 256) {
new_presets.emplace_back(std::move(name));
}
}
}
}
workspace_presets_ = std::move(new_presets);
workspace_presets_loaded_ = true;
} catch (const std::exception& e) {
// LOG_ERROR("WorkspaceManager", "Error refreshing presets: %s", e.what());
workspace_presets_.clear();
workspace_presets_loaded_ = true;
}
}
void WorkspaceManager::LoadDeveloperLayout() {
// TODO: Load preset with all debug tools
if (toast_manager_) {