diff --git a/src/app/core/constants.h b/src/app/core/constants.h index 94f957ba..c727b5a0 100644 --- a/src/app/core/constants.h +++ b/src/app/core/constants.h @@ -230,11 +230,26 @@ constexpr int overworldMapSizeHighByte = 0x12884; // all Large map would be : // 0000, 0000, 0400, 0400, 0800, 0800, 0C00, 0C00 +constexpr int overworldMapParentId = 0x125EC; + constexpr int overworldTransitionPositionY = 0x128C4; + constexpr int overworldTransitionPositionX = 0x12944; constexpr int overworldScreenSize = 0x1788D; +constexpr int OverworldScreenSizeForLoading = 0x4C635; + +constexpr int OverworldScreenTileMapChangeByScreen = 0x12634; + +constexpr int transition_target_north = 0x13ee2; + +constexpr int transition_target_west = 0x13f62; + +constexpr int overworldCustomMosaicASM = 0x1301D0; + +constexpr int overworldCustomMosaicArray = 0x1301F0; + // ============================================================================ // Overworld Exits/Entrances Variables // ============================================================================ @@ -482,7 +497,7 @@ constexpr int customAreaSpecificBGPalette = constexpr int customAreaSpecificBGASM = 0x140150; constexpr int customAreaSpecificBGEnabled = 0x140140; // 1 byte, not 0 if enabled -constexpr int overworldCustomMosaicArray = 0x1301F0; + // ============================================================================ // Dungeon Map Related Variables // ============================================================================ diff --git a/src/gui/canvas.cc b/src/gui/canvas.cc index 14b4ec86..07a34857 100644 --- a/src/gui/canvas.cc +++ b/src/gui/canvas.cc @@ -15,11 +15,8 @@ void Canvas::DrawBackground(ImVec2 canvas_size) { canvas_p0_ = ImGui::GetCursorScreenPos(); if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail(); if (canvas_size.x != 0) canvas_sz_ = canvas_size; - canvas_p1_ = ImVec2(canvas_p0_.x + canvas_sz_.x, canvas_p0_.y + canvas_sz_.y); - - // Draw border and background color - draw_list_ = ImGui::GetWindowDrawList(); + draw_list_ = ImGui::GetWindowDrawList(); // Draw border and background color draw_list_->AddRectFilled(canvas_p0_, canvas_p1_, IM_COL32(32, 32, 32, 255)); draw_list_->AddRect(canvas_p0_, canvas_p1_, IM_COL32(255, 255, 255, 255)); } @@ -63,7 +60,7 @@ void Canvas::DrawContextMenu() { } } -void Canvas::DrawTilePainter(const Bitmap &bitmap, int size) { +bool Canvas::DrawTilePainter(const Bitmap &bitmap, int size) { const ImGuiIO &io = ImGui::GetIO(); const bool is_hovered = ImGui::IsItemHovered(); // Hovered const ImVec2 origin(canvas_p0_.x + scrolling_.x, @@ -75,15 +72,17 @@ void Canvas::DrawTilePainter(const Bitmap &bitmap, int size) { if (!points_.empty()) { points_.clear(); } + ImVec2 draw_tile_outline_pos; draw_tile_outline_pos.x = std::floor((double)mouse_pos_in_canvas.x / size) * size; draw_tile_outline_pos.y = std::floor((double)mouse_pos_in_canvas.y / size) * size; + auto draw_tile_outline_pos_end = + ImVec2(draw_tile_outline_pos.x + size, draw_tile_outline_pos.y + size); points_.push_back(draw_tile_outline_pos); - points_.push_back( - ImVec2(draw_tile_outline_pos.x + size, draw_tile_outline_pos.y + size)); + points_.push_back(draw_tile_outline_pos_end); if (bitmap.IsActive()) { draw_list_->AddImage( @@ -94,9 +93,18 @@ void Canvas::DrawTilePainter(const Bitmap &bitmap, int size) { origin.y + draw_tile_outline_pos.y + bitmap.GetHeight())); } + if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { + // Draw the currently selected tile on the overworld here + // Save the coordinates of the selected tile. + drawn_tile_pos_ = mouse_pos_in_canvas; + return true; + } + } else { points_.clear(); } + + return false; } void Canvas::DrawTileSelector(int size) { diff --git a/src/gui/canvas.h b/src/gui/canvas.h index e0a6eb78..0503c22b 100644 --- a/src/gui/canvas.h +++ b/src/gui/canvas.h @@ -22,8 +22,10 @@ class Canvas { void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0)); void DrawContextMenu(); - void DrawTilePainter(const Bitmap& bitmap, int size); + + bool DrawTilePainter(const Bitmap& bitmap, int size); void DrawTileSelector(int size); + void DrawBitmap(const Bitmap& bitmap, int border_offset = 0, bool ready = true); void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset); @@ -36,6 +38,8 @@ class Canvas { auto Points() const { return points_; } auto GetDrawList() const { return draw_list_; } auto GetZeroPoint() const { return canvas_p0_; } + auto GetCurrentDrawnTilePosition() const { return drawn_tile_pos_; } + auto GetCanvasSize() const { return canvas_sz_; } void SetCanvasSize(ImVec2 canvas_size) { canvas_sz_ = canvas_size; custom_canvas_size_ = true; @@ -54,6 +58,7 @@ class Canvas { ImVec2 canvas_p0_; ImVec2 canvas_p1_; ImVec2 mouse_pos_in_canvas_; + ImVec2 drawn_tile_pos_; std::vector changed_tiles_; app::gfx::Bitmap current_tile_;