backend-infra-engineer: Release v0.3.0 snapshot
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include "assembly_editor.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/modules/text_editor.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
namespace yaze::editor {
|
||||
|
||||
using core::FileDialogWrapper;
|
||||
|
||||
@@ -18,22 +21,21 @@ std::vector<std::string> RemoveIgnoredFiles(
|
||||
std::vector<std::string> filtered_files;
|
||||
for (const auto& file : files) {
|
||||
// Remove subdirectory files
|
||||
if (file.find('/') != std::string::npos) {
|
||||
if (file.contains('/')) {
|
||||
continue;
|
||||
}
|
||||
// Make sure the file has an extension
|
||||
if (file.find('.') == std::string::npos) {
|
||||
if (!file.contains('.')) {
|
||||
continue;
|
||||
}
|
||||
if (std::find(ignored_files.begin(), ignored_files.end(), file) ==
|
||||
ignored_files.end()) {
|
||||
if (std::ranges::find(ignored_files, file) == ignored_files.end()) {
|
||||
filtered_files.push_back(file);
|
||||
}
|
||||
}
|
||||
return filtered_files;
|
||||
}
|
||||
|
||||
core::FolderItem LoadFolder(const std::string& folder) {
|
||||
FolderItem LoadFolder(const std::string& folder) {
|
||||
// Check if .gitignore exists in the folder
|
||||
std::ifstream gitignore(folder + "/.gitignore");
|
||||
std::vector<std::string> ignored_files;
|
||||
@@ -51,28 +53,27 @@ core::FolderItem LoadFolder(const std::string& folder) {
|
||||
}
|
||||
}
|
||||
|
||||
core::FolderItem current_folder;
|
||||
FolderItem current_folder;
|
||||
current_folder.name = folder;
|
||||
auto root_files = FileDialogWrapper::GetFilesInFolder(current_folder.name);
|
||||
current_folder.files = RemoveIgnoredFiles(root_files, ignored_files);
|
||||
|
||||
for (const auto& subfolder :
|
||||
FileDialogWrapper::GetSubdirectoriesInFolder(current_folder.name)) {
|
||||
core::FolderItem folder_item;
|
||||
FolderItem folder_item;
|
||||
folder_item.name = subfolder;
|
||||
std::string full_folder = current_folder.name + "/" + subfolder;
|
||||
auto folder_files = FileDialogWrapper::GetFilesInFolder(full_folder);
|
||||
for (const auto& files : folder_files) {
|
||||
// Remove subdirectory files
|
||||
if (files.find('/') != std::string::npos) {
|
||||
if (files.contains('/')) {
|
||||
continue;
|
||||
}
|
||||
// Make sure the file has an extension
|
||||
if (files.find('.') == std::string::npos) {
|
||||
if (!files.contains('.')) {
|
||||
continue;
|
||||
}
|
||||
if (std::find(ignored_files.begin(), ignored_files.end(), files) !=
|
||||
ignored_files.end()) {
|
||||
if (std::ranges::find(ignored_files, files) != ignored_files.end()) {
|
||||
continue;
|
||||
}
|
||||
folder_item.files.push_back(files);
|
||||
@@ -80,7 +81,7 @@ core::FolderItem LoadFolder(const std::string& folder) {
|
||||
|
||||
for (const auto& subdir :
|
||||
FileDialogWrapper::GetSubdirectoriesInFolder(full_folder)) {
|
||||
core::FolderItem subfolder_item;
|
||||
FolderItem subfolder_item;
|
||||
subfolder_item.name = subdir;
|
||||
subfolder_item.files = FileDialogWrapper::GetFilesInFolder(subdir);
|
||||
folder_item.subfolders.push_back(subfolder_item);
|
||||
@@ -93,6 +94,12 @@ core::FolderItem LoadFolder(const std::string& folder) {
|
||||
|
||||
} // namespace
|
||||
|
||||
void AssemblyEditor::Initialize() {
|
||||
// Set the language definition
|
||||
}
|
||||
|
||||
absl::Status AssemblyEditor::Load() { return absl::OkStatus(); }
|
||||
|
||||
void AssemblyEditor::OpenFolder(const std::string& folder_path) {
|
||||
current_folder_ = LoadFolder(folder_path);
|
||||
}
|
||||
@@ -119,7 +126,6 @@ void AssemblyEditor::Update(bool& is_loaded) {
|
||||
}
|
||||
|
||||
void AssemblyEditor::InlineUpdate() {
|
||||
ChangeActiveFile("assets/asm/template_song.asm");
|
||||
auto cpos = text_editor_.GetCursorPosition();
|
||||
SetEditorText();
|
||||
ImGui::Text("%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
|
||||
@@ -225,8 +231,8 @@ void AssemblyEditor::DrawFileTabView() {
|
||||
|
||||
if (ImGui::BeginTabBar("AssemblyFileTabBar", ImGuiTabBarFlags_None)) {
|
||||
if (ImGui::TabItemButton(ICON_MD_ADD, ImGuiTabItemFlags_None)) {
|
||||
if (std::find(active_files_.begin(), active_files_.end(),
|
||||
current_file_id_) != active_files_.end()) {
|
||||
if (std::ranges::find(active_files_, current_file_id_) !=
|
||||
active_files_.end()) {
|
||||
// Room is already open
|
||||
next_tab_id++;
|
||||
}
|
||||
@@ -354,5 +360,4 @@ absl::Status AssemblyEditor::Redo() {
|
||||
|
||||
absl::Status AssemblyEditor::Update() { return absl::OkStatus(); }
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
} // namespace yaze::editor
|
||||
|
||||
@@ -3,21 +3,27 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/core/common.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/gui/modules/text_editor.h"
|
||||
#include "app/gui/style.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
|
||||
struct FolderItem {
|
||||
std::string name;
|
||||
std::vector<FolderItem> subfolders;
|
||||
std::vector<std::string> files;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class AssemblyEditor
|
||||
* @brief Text editor for modifying assembly code.
|
||||
*/
|
||||
class AssemblyEditor : public Editor {
|
||||
public:
|
||||
AssemblyEditor() {
|
||||
explicit AssemblyEditor(Rom* rom = nullptr) : rom_(rom) {
|
||||
text_editor_.SetLanguageDefinition(gui::GetAssemblyLanguageDef());
|
||||
text_editor_.SetPalette(TextEditor::GetDarkPalette());
|
||||
text_editor_.SetShowWhitespaces(false);
|
||||
@@ -28,6 +34,8 @@ class AssemblyEditor : public Editor {
|
||||
file_is_loaded_ = false;
|
||||
}
|
||||
|
||||
void Initialize() override;
|
||||
absl::Status Load() override;
|
||||
void Update(bool &is_loaded);
|
||||
void InlineUpdate();
|
||||
|
||||
@@ -43,28 +51,32 @@ class AssemblyEditor : public Editor {
|
||||
|
||||
absl::Status Update() override;
|
||||
|
||||
absl::Status Save() override { return absl::UnimplementedError("Save"); }
|
||||
|
||||
void OpenFolder(const std::string &folder_path);
|
||||
|
||||
void set_rom(Rom* rom) { rom_ = rom; }
|
||||
Rom* rom() const { return rom_; }
|
||||
|
||||
private:
|
||||
void DrawFileMenu();
|
||||
void DrawEditMenu();
|
||||
|
||||
void SetEditorText();
|
||||
|
||||
void DrawCurrentFolder();
|
||||
|
||||
void DrawFileTabView();
|
||||
|
||||
bool file_is_loaded_ = false;
|
||||
int current_file_id_ = 0;
|
||||
|
||||
std::vector<std::string> files_;
|
||||
std::vector<TextEditor> open_files_;
|
||||
ImVector<int> active_files_;
|
||||
int current_file_id_ = 0;
|
||||
|
||||
std::string current_file_;
|
||||
core::FolderItem current_folder_;
|
||||
FolderItem current_folder_;
|
||||
TextEditor text_editor_;
|
||||
|
||||
Rom* rom_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -1,31 +1,13 @@
|
||||
#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||
#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_H
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/core/constants.h"
|
||||
#include "app/core/platform/file_dialog.h"
|
||||
#include "app/core/project.h"
|
||||
#include "app/editor/code/assembly_editor.h"
|
||||
#include "app/editor/code/memory_editor.h"
|
||||
#include "app/editor/dungeon/dungeon_editor.h"
|
||||
#include "app/editor/editor.h"
|
||||
#include "app/editor/graphics/graphics_editor.h"
|
||||
#include "app/editor/graphics/palette_editor.h"
|
||||
#include "app/editor/graphics/screen_editor.h"
|
||||
#include "app/editor/music/music_editor.h"
|
||||
#include "app/editor/overworld/overworld_editor.h"
|
||||
#include "app/editor/sprite/sprite_editor.h"
|
||||
#include "app/emu/emulator.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/gui/canvas.h"
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/input.h"
|
||||
#include "app/gui/style.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/snes.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/misc/cpp/imgui_stdlib.h"
|
||||
#include "imgui_memory_editor.h"
|
||||
#include "util/macro.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
@@ -33,7 +15,9 @@ namespace editor {
|
||||
using ImGui::SameLine;
|
||||
using ImGui::Text;
|
||||
|
||||
struct MemoryEditorWithDiffChecker : public SharedRom {
|
||||
struct MemoryEditorWithDiffChecker {
|
||||
explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
|
||||
|
||||
void Update(bool &show_memory_editor) {
|
||||
static MemoryEditor mem_edit;
|
||||
static MemoryEditor comp_edit;
|
||||
@@ -49,7 +33,7 @@ struct MemoryEditorWithDiffChecker : public SharedRom {
|
||||
static uint64_t convert_address = 0;
|
||||
gui::InputHex("SNES to PC", (int *)&convert_address, 6, 200.f);
|
||||
SameLine();
|
||||
Text("%x", core::SnesToPc(convert_address));
|
||||
Text("%x", SnesToPc(convert_address));
|
||||
|
||||
// mem_edit.DrawWindow("Memory Editor", (void*)&(*rom()), rom()->size());
|
||||
BEGIN_TABLE("Memory Comparison", 2, ImGuiTableFlags_Resizable);
|
||||
@@ -74,6 +58,15 @@ struct MemoryEditorWithDiffChecker : public SharedRom {
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// Set the ROM pointer
|
||||
void set_rom(Rom* rom) { rom_ = rom; }
|
||||
|
||||
// Get the ROM pointer
|
||||
Rom* rom() const { return rom_; }
|
||||
|
||||
private:
|
||||
Rom* rom_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user