5#define IM_PI 3.14159265358979323846f
13#include "absl/status/status.h"
14#include "absl/strings/str_format.h"
15#include "imgui/imgui.h"
84 bool show_context_menu =
158 if (canvas_rt.hovered) {
169 ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
172 if (hovered_entity->entity_type_ ==
185 ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
186 ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
187 ImVec2 mouse_delta = ImGui::GetIO().MouseDelta;
188 float scale = canvas_rt.scale;
197 ImGui::IsMouseReleased(ImGuiMouseButton_Left)) {
199 float end_scale = canvas_rt.scale;
244 for (
int i = 0; i < 0x40; i++) {
248 if (world_index < 0 ||
275 ImDrawList* draw_list = ImGui::GetWindowDrawList();
279 ImVec2 placeholder_pos = ImVec2(canvas_pos.x + scrolling.x + map_x,
280 canvas_pos.y + scrolling.y + map_y);
283 ImVec2 placeholder_size = ImVec2(scaled_size, scaled_size);
287 draw_list->AddRectFilled(
289 ImVec2(placeholder_pos.x + placeholder_size.x,
290 placeholder_pos.y + placeholder_size.y),
292 theme.editor_background));
295 ImVec2 spinner_pos = ImVec2(placeholder_pos.x + placeholder_size.x / 2,
296 placeholder_pos.y + placeholder_size.y / 2);
298 const float spinner_radius = 8.0f * scale;
299 const float rotation =
static_cast<float>(ImGui::GetTime()) * 3.0f;
300 const float start_angle = rotation;
301 const float end_angle = rotation +
IM_PI * 1.5f;
303 draw_list->PathArcTo(spinner_pos, spinner_radius, start_angle, end_angle,
305 draw_list->PathStroke(ImGui::GetColorU32(theme.status_active), 0,
336 "OwBlocksetSelector", selector_config);
345 "##Tile16SelectorScrollRegion",
360 if (result.selection_changed) {
368 if (result.tile_double_clicked) {
377 return absl::OkStatus();
396 int offset = 0x40 * (key + 1);
397 int top_left_y = canvas_rt.canvas_p0.y + 2;
399 top_left_y = canvas_rt.canvas_p0.y + 0x40 * key;
401 auto texture = value.texture();
402 canvas_rt.draw_list->AddImage(
403 (ImTextureID)(intptr_t)texture,
404 ImVec2(canvas_rt.canvas_p0.x + 2, top_left_y),
405 ImVec2(canvas_rt.canvas_p0.x + 0x100,
406 canvas_rt.canvas_p0.y + offset));
420 auto bmp = std::make_unique<gfx::Bitmap>();
458 return absl::OkStatus();
463 ImGui::TextWrapped(
"ZSCustomOverworld v3 settings");
471 const uint8_t asm_version =
473 ImGui::Text(
"ASM Version: 0x%02X", asm_version);
475 if (asm_version == 0x00 || asm_version == 0xFF || asm_version < 0x03) {
477 ImGui::TextColored(ImVec4(1.0f, 0.75f, 0.25f, 1.0f),
478 "v3 controls require ZSCustomOverworld v3+");
479 ImGui::TextDisabled(
"Apply the v3 patch to enable map-size editing.");
485 ImGui::TextDisabled(
"Current map is unavailable.");
491 ImGui::Text(
"Parent map: 0x%02X", map->parent());
493 static int selected_area_size = 0;
494 selected_area_size =
static_cast<int>(map->area_size());
495 const char* area_size_labels[] = {
"Small",
"Wide",
"Tall",
"Large"};
496 ImGui::SetNextItemWidth(220.0f);
497 ImGui::Combo(
"Area Size", &selected_area_size, area_size_labels,
498 IM_ARRAYSIZE(area_size_labels));
511 "Area-size changes update sibling map relationships for this parent "
517 static bool show_custom_bg_color_editor =
false;
518 static bool show_overlay_editor =
false;
519 static int game_state = 0;
524 show_custom_bg_color_editor, show_overlay_editor);
528 if (show_custom_bg_color_editor) {
529 ImGui::OpenPopup(
"CustomBGColorEditor");
530 show_custom_bg_color_editor =
false;
532 if (show_overlay_editor) {
533 ImGui::OpenPopup(
"OverlayEditor");
534 show_overlay_editor =
false;
537 if (ImGui::BeginPopup(
"CustomBGColorEditor")) {
545 if (ImGui::BeginPopup(
"OverlayEditor")) {
548 show_overlay_editor);
555 static bool init_properties =
false;
557 if (!init_properties) {
558 for (
int i = 0; i < 0x40; i++) {
559 std::string area_graphics_str = absl::StrFormat(
563 ->push_back(area_graphics_str);
565 area_graphics_str = absl::StrFormat(
570 ->push_back(area_graphics_str);
572 std::string area_palette_str = absl::StrFormat(
576 ->push_back(area_palette_str);
578 area_palette_str = absl::StrFormat(
582 ->push_back(area_palette_str);
584 std::string sprite_gfx_str = absl::StrFormat(
588 ->push_back(sprite_gfx_str);
590 sprite_gfx_str = absl::StrFormat(
594 ->push_back(sprite_gfx_str);
596 sprite_gfx_str = absl::StrFormat(
601 ->push_back(sprite_gfx_str);
603 sprite_gfx_str = absl::StrFormat(
608 ->push_back(sprite_gfx_str);
610 std::string sprite_palette_str = absl::StrFormat(
614 ->push_back(sprite_palette_str);
616 sprite_palette_str = absl::StrFormat(
620 ->push_back(sprite_palette_str);
622 sprite_palette_str = absl::StrFormat(
627 ->push_back(sprite_palette_str);
629 sprite_palette_str = absl::StrFormat(
634 ->push_back(sprite_palette_str);
636 init_properties =
true;
639 ImGui::Text(
"Area Gfx LW/DW");
647 ImGui::Text(
"Sprite Gfx LW/DW");
649 ImVec2(256, 256), 32,
653 ImVec2(256, 256), 32,
657 ImVec2(256, 256), 32,
661 ImVec2(256, 256), 32,
665 ImGui::Text(
"Area Pal LW/DW");
672 static bool show_gfx_group =
false;
673 ImGui::Checkbox(
"Show Gfx Group Editor", &show_gfx_group);
674 if (show_gfx_group) {
void set_dirty(bool dirty)
EditorDependencies dependencies_
absl::Status DrawTile16Selector()
Draw the tile16 selector panel.
OverworldCanvasRenderer(OverworldEditor *editor)
absl::Status DrawAreaGraphics()
Draw the area graphics panel.
void DrawMapProperties()
Draw the map properties panel (sidebar-based)
void DrawOverworldProperties()
Draw the overworld properties grid (debug/info view)
OverworldEditor * editor_
Non-owning pointer to the parent editor.
void DrawOverworldCanvas()
Draw the main overworld canvas with toolbar, maps, and entities. This is the primary entry point call...
void DrawV3Settings()
Draw the v3 settings panel.
void DrawTile8Selector()
Draw the tile8 selector panel (graphics bin)
void DrawOverworldMaps()
Render the 64 overworld map bitmaps to the canvas.
Main UI class for editing overworld maps in A Link to the Past.
std::unique_ptr< MapPropertiesSystem > map_properties_system_
void HandleMapInteraction()
bool map_blockset_loaded_
absl::Status CheckForCurrentMap()
Check for map changes and refresh if needed.
void RequestTile16Selection(int tile_id)
gfx::Tilemap tile16_blockset_
gui::Canvas ow_map_canvas_
ScratchSpace scratch_space_
zelda3::GameEntity * dragged_entity_
std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > maps_bmp_
bool show_map_properties_panel_
void RefreshOverworldMap()
void CheckForOverworldEdits()
Check for tile edits - delegates to TilePaintingManager.
void RefreshSiblingMapGraphics(int map_index, bool include_self=false)
gui::Canvas current_gfx_canvas_
bool show_overlay_editor_
std::unique_ptr< OverworldSidebar > sidebar_
void HandleOverworldPan()
bool dragged_entity_free_movement_
gui::Canvas blockset_canvas_
void UpdateBlocksetSelectorState()
std::unique_ptr< OverworldEntityRenderer > entity_renderer_
void EnsureMapTexture(int map_index)
Ensure a specific map has its texture created.
EntityEditMode entity_edit_mode_
std::unique_ptr< OverworldToolbar > toolbar_
GfxGroupEditor gfx_group_editor_
std::unique_ptr< gui::TileSelectorWidget > blockset_selector_
bool show_overlay_preview_
gui::Canvas graphics_bin_canvas_
gfx::BitmapTable current_graphics_set_
bool show_custom_bg_color_editor_
zelda3::Overworld overworld_
void HandleOverworldZoom()
gui::Canvas properties_canvas_
gfx::SnesPalette palette_
bool SelectItemByIdentity(const zelda3::OverworldItem &item_identity)
Select an overworld item using value identity matching.
bool OpenWindow(size_t session_id, const std::string &base_window_id)
void QueueTextureCommand(TextureCommandType type, Bitmap *bitmap)
std::array< gfx::Bitmap, 223 > & gfx_sheets()
Get reference to all graphics sheets.
Represents a bitmap image optimized for SNES ROM hacking.
void set_scrolling(ImVec2 scroll)
void DrawBitmap(Bitmap &bitmap, int border_offset, float scale)
auto global_scale() const
auto select_rect_active() const
void SetUsageMode(CanvasUsage usage)
auto selected_tiles() const
void UpdateInfoGrid(ImVec2 bg_size, float grid_size=64.0f, int label_id=0)
bool DrawTileSelector(int size, int size_y=0)
void ClearContextMenuItems()
auto mutable_labels(int i)
virtual void UpdateMapProperties(uint16_t map_id, const void *context=nullptr)=0
Update entity properties based on map position.
enum yaze::zelda3::GameEntity::EntityType entity_type_
const std::vector< uint8_t > & current_graphics() const
const gfx::SnesPalette & current_area_palette() const
auto overworld_map(int i) const
void set_current_map(int i)
absl::Status ConfigureMultiAreaMap(int parent_index, AreaSizeEnum size)
Configure a multi-area map structure (Large/Wide/Tall)
const AgentUITheme & GetTheme()
Editors are the view controllers for the application.
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize *8, kOverworldMapSize *8)
constexpr unsigned int kOverworldMapSize
constexpr ImVec2 kCurrentGfxCanvasSize(0x100+1, 0x10 *0x40+1)
void MoveEntityOnGrid(zelda3::GameEntity *entity, ImVec2 canvas_p0, ImVec2 scrolling, bool free_movement, float scale)
Move entity to grid-aligned position based on mouse.
constexpr ImVec2 kGraphicsBinCanvasSize(0x100+1, kNumSheetsToLoad *0x40+1)
void EndCanvas(Canvas &canvas)
void BeginChildBothScrollbars(int id)
void BeginCanvas(Canvas &canvas, ImVec2 child_size)
bool AcceptTileDrop(TileDragPayload *out)
Accept a tile16 drop. Returns true if a payload was accepted.
void CenterText(const char *text)
void EndWindowWithDisplaySettings()
void BeginWindowWithDisplaySettings(const char *id, bool *active, const ImVec2 &size, ImGuiWindowFlags flags)
void BeginChildWithScrollbar(const char *str_id)
constexpr int kNumTile16Individual
AreaSizeEnum
Area size enumeration for v3+ ROMs.
constexpr int OverworldCustomASMHasBeenApplied
WorkspaceWindowManager * window_manager
static constexpr const char * kTile16Editor
Bitmap atlas
Master bitmap containing all tiles.
std::optional< float > grid_step