Add OverworldMap tile editing

This commit is contained in:
scawful
2023-08-26 15:03:18 -04:00
parent fafbcbe2af
commit c4ef29f329
21 changed files with 418 additions and 66 deletions

View File

@@ -9,6 +9,8 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace gui {
constexpr uint32_t kRectangleColor = IM_COL32(32, 32, 32, 255);
@@ -209,4 +211,5 @@ void Canvas::DrawOverlay() {
}
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -10,6 +10,7 @@
#include "app/rom.h"
namespace yaze {
namespace app {
namespace gui {
using app::gfx::Bitmap;
@@ -83,6 +84,7 @@ class Canvas {
};
} // namespace gui
} // namespace app
} // namespace yaze
#endif

View File

@@ -9,6 +9,8 @@
#include "app/gfx/snes_palette.h"
namespace yaze {
namespace app {
namespace gui {
void DisplayPalette(app::gfx::SNESPalette& palette, bool loaded) {
@@ -83,4 +85,5 @@ void DisplayPalette(app::gfx::SNESPalette& palette, bool loaded) {
}
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -10,11 +10,14 @@
#include "app/gfx/snes_palette.h"
namespace yaze {
namespace app {
namespace gui {
void DisplayPalette(app::gfx::SNESPalette& palette, bool loaded);
} // namespace gui
} // namespace app
} // namespace yaze
#endif

View File

@@ -6,6 +6,7 @@
#include "absl/strings/string_view.h"
namespace yaze {
namespace app {
namespace gui {
const int kStepOneHex = 0x01;
@@ -67,4 +68,5 @@ void ItemLabel(absl::string_view title, ItemLabelFlags flags) {
}
} // namespace gui
} // namespace yaze
} // namespace app
} // namespace yaze

View File

@@ -10,6 +10,7 @@
#include "absl/strings/string_view.h"
namespace yaze {
namespace app {
namespace gui {
constexpr ImVec2 kDefaultModalSize = ImVec2(200, 0);
@@ -27,6 +28,7 @@ using ItemLabelFlags = enum ItemLabelFlag {
IMGUI_API void ItemLabel(absl::string_view title, ItemLabelFlags flags);
} // namespace gui
} // namespace app
} // namespace yaze
#endif

View File

@@ -4,6 +4,8 @@
#include "imgui/imgui_internal.h"
namespace yaze {
namespace app {
namespace gui {
void TextWithSeparators(const absl::string_view &text) {
@@ -111,4 +113,5 @@ void ColorsYaze() {
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
}
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -7,6 +7,7 @@
#include "absl/strings/string_view.h"
namespace yaze {
namespace app {
namespace gui {
void TextWithSeparators(const absl::string_view& text);
@@ -14,6 +15,7 @@ void TextWithSeparators(const absl::string_view& text);
void ColorsYaze();
} // namespace gui
} // namespace app
} // namespace yaze
#endif

View File

@@ -7,6 +7,7 @@
#include "app/core/constants.h"
namespace yaze {
namespace app {
namespace gui {
namespace widgets {
@@ -93,4 +94,5 @@ TextEditor::LanguageDefinition GetAssemblyLanguageDef() {
} // namespace widgets
} // namespace gui
} // namespace app
} // namespace yaze

View File

@@ -2,18 +2,72 @@
#define YAZE_GUI_WIDGETS_H
#include <ImGuiColorTextEdit/TextEditor.h>
#include <imgui/imgui.h>
#include <imgui/misc/cpp/imgui_stdlib.h>
#include <vector>
#include "absl/status/status.h"
#include "app/core/constants.h"
#include "app/gfx/bitmap.h"
namespace yaze {
namespace app {
namespace gui {
namespace widgets {
TextEditor::LanguageDefinition GetAssemblyLanguageDef();
class BitmapViewer {
public:
BitmapViewer() : current_bitmap_index_(0) {}
void Display(const std::vector<gfx::Bitmap>& bitmaps) {
if (bitmaps.empty()) {
ImGui::Text("No bitmaps available.");
return;
}
// Display the current bitmap index and total count.
ImGui::Text("Viewing Bitmap %d / %zu", current_bitmap_index_ + 1,
bitmaps.size());
// Buttons to navigate through bitmaps.
if (ImGui::Button("<- Prev")) {
if (current_bitmap_index_ > 0) {
--current_bitmap_index_;
}
}
ImGui::SameLine();
if (ImGui::Button("Next ->")) {
if (current_bitmap_index_ < bitmaps.size() - 1) {
++current_bitmap_index_;
}
}
// Display the current bitmap.
const gfx::Bitmap& current_bitmap = bitmaps[current_bitmap_index_];
// Assuming Bitmap has a function to get its texture ID, and width and
// height.
ImTextureID tex_id = current_bitmap.texture();
ImVec2 size(current_bitmap.width(), current_bitmap.height());
ImGui::Image(tex_id, size);
// Scroll if the image is larger than the display area.
if (ImGui::BeginChild("BitmapScrollArea", ImVec2(0, 0), false,
ImGuiWindowFlags_HorizontalScrollbar)) {
ImGui::Image(tex_id, size);
ImGui::EndChild();
}
}
private:
int current_bitmap_index_;
};
} // namespace widgets
} // namespace gui
} // namespace app
} // namespace yaze
#endif