Add TilePainter left click return value
This commit is contained in:
@@ -230,11 +230,26 @@ constexpr int overworldMapSizeHighByte = 0x12884;
|
|||||||
// all Large map would be :
|
// all Large map would be :
|
||||||
// 0000, 0000, 0400, 0400, 0800, 0800, 0C00, 0C00
|
// 0000, 0000, 0400, 0400, 0800, 0800, 0C00, 0C00
|
||||||
|
|
||||||
|
constexpr int overworldMapParentId = 0x125EC;
|
||||||
|
|
||||||
constexpr int overworldTransitionPositionY = 0x128C4;
|
constexpr int overworldTransitionPositionY = 0x128C4;
|
||||||
|
|
||||||
constexpr int overworldTransitionPositionX = 0x12944;
|
constexpr int overworldTransitionPositionX = 0x12944;
|
||||||
|
|
||||||
constexpr int overworldScreenSize = 0x1788D;
|
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
|
// Overworld Exits/Entrances Variables
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -482,7 +497,7 @@ constexpr int customAreaSpecificBGPalette =
|
|||||||
constexpr int customAreaSpecificBGASM = 0x140150;
|
constexpr int customAreaSpecificBGASM = 0x140150;
|
||||||
constexpr int customAreaSpecificBGEnabled =
|
constexpr int customAreaSpecificBGEnabled =
|
||||||
0x140140; // 1 byte, not 0 if enabled
|
0x140140; // 1 byte, not 0 if enabled
|
||||||
constexpr int overworldCustomMosaicArray = 0x1301F0;
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Dungeon Map Related Variables
|
// Dungeon Map Related Variables
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
@@ -15,11 +15,8 @@ void Canvas::DrawBackground(ImVec2 canvas_size) {
|
|||||||
canvas_p0_ = ImGui::GetCursorScreenPos();
|
canvas_p0_ = ImGui::GetCursorScreenPos();
|
||||||
if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail();
|
if (!custom_canvas_size_) canvas_sz_ = ImGui::GetContentRegionAvail();
|
||||||
if (canvas_size.x != 0) canvas_sz_ = canvas_size;
|
if (canvas_size.x != 0) canvas_sz_ = canvas_size;
|
||||||
|
|
||||||
canvas_p1_ = ImVec2(canvas_p0_.x + canvas_sz_.x, canvas_p0_.y + canvas_sz_.y);
|
canvas_p1_ = ImVec2(canvas_p0_.x + canvas_sz_.x, canvas_p0_.y + canvas_sz_.y);
|
||||||
|
draw_list_ = ImGui::GetWindowDrawList(); // Draw border and background color
|
||||||
// Draw border and background color
|
|
||||||
draw_list_ = ImGui::GetWindowDrawList();
|
|
||||||
draw_list_->AddRectFilled(canvas_p0_, canvas_p1_, IM_COL32(32, 32, 32, 255));
|
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));
|
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 ImGuiIO &io = ImGui::GetIO();
|
||||||
const bool is_hovered = ImGui::IsItemHovered(); // Hovered
|
const bool is_hovered = ImGui::IsItemHovered(); // Hovered
|
||||||
const ImVec2 origin(canvas_p0_.x + scrolling_.x,
|
const ImVec2 origin(canvas_p0_.x + scrolling_.x,
|
||||||
@@ -75,15 +72,17 @@ void Canvas::DrawTilePainter(const Bitmap &bitmap, int size) {
|
|||||||
if (!points_.empty()) {
|
if (!points_.empty()) {
|
||||||
points_.clear();
|
points_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImVec2 draw_tile_outline_pos;
|
ImVec2 draw_tile_outline_pos;
|
||||||
draw_tile_outline_pos.x =
|
draw_tile_outline_pos.x =
|
||||||
std::floor((double)mouse_pos_in_canvas.x / size) * size;
|
std::floor((double)mouse_pos_in_canvas.x / size) * size;
|
||||||
draw_tile_outline_pos.y =
|
draw_tile_outline_pos.y =
|
||||||
std::floor((double)mouse_pos_in_canvas.y / size) * size;
|
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(draw_tile_outline_pos);
|
||||||
points_.push_back(
|
points_.push_back(draw_tile_outline_pos_end);
|
||||||
ImVec2(draw_tile_outline_pos.x + size, draw_tile_outline_pos.y + size));
|
|
||||||
|
|
||||||
if (bitmap.IsActive()) {
|
if (bitmap.IsActive()) {
|
||||||
draw_list_->AddImage(
|
draw_list_->AddImage(
|
||||||
@@ -94,9 +93,18 @@ void Canvas::DrawTilePainter(const Bitmap &bitmap, int size) {
|
|||||||
origin.y + draw_tile_outline_pos.y + bitmap.GetHeight()));
|
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 {
|
} else {
|
||||||
points_.clear();
|
points_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Canvas::DrawTileSelector(int size) {
|
void Canvas::DrawTileSelector(int size) {
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ class Canvas {
|
|||||||
|
|
||||||
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
|
void DrawBackground(ImVec2 canvas_size = ImVec2(0, 0));
|
||||||
void DrawContextMenu();
|
void DrawContextMenu();
|
||||||
void DrawTilePainter(const Bitmap& bitmap, int size);
|
|
||||||
|
bool DrawTilePainter(const Bitmap& bitmap, int size);
|
||||||
void DrawTileSelector(int size);
|
void DrawTileSelector(int size);
|
||||||
|
|
||||||
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
|
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0,
|
||||||
bool ready = true);
|
bool ready = true);
|
||||||
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
|
||||||
@@ -36,6 +38,8 @@ class Canvas {
|
|||||||
auto Points() const { return points_; }
|
auto Points() const { return points_; }
|
||||||
auto GetDrawList() const { return draw_list_; }
|
auto GetDrawList() const { return draw_list_; }
|
||||||
auto GetZeroPoint() const { return canvas_p0_; }
|
auto GetZeroPoint() const { return canvas_p0_; }
|
||||||
|
auto GetCurrentDrawnTilePosition() const { return drawn_tile_pos_; }
|
||||||
|
auto GetCanvasSize() const { return canvas_sz_; }
|
||||||
void SetCanvasSize(ImVec2 canvas_size) {
|
void SetCanvasSize(ImVec2 canvas_size) {
|
||||||
canvas_sz_ = canvas_size;
|
canvas_sz_ = canvas_size;
|
||||||
custom_canvas_size_ = true;
|
custom_canvas_size_ = true;
|
||||||
@@ -54,6 +58,7 @@ class Canvas {
|
|||||||
ImVec2 canvas_p0_;
|
ImVec2 canvas_p0_;
|
||||||
ImVec2 canvas_p1_;
|
ImVec2 canvas_p1_;
|
||||||
ImVec2 mouse_pos_in_canvas_;
|
ImVec2 mouse_pos_in_canvas_;
|
||||||
|
ImVec2 drawn_tile_pos_;
|
||||||
|
|
||||||
std::vector<app::gfx::Bitmap> changed_tiles_;
|
std::vector<app::gfx::Bitmap> changed_tiles_;
|
||||||
app::gfx::Bitmap current_tile_;
|
app::gfx::Bitmap current_tile_;
|
||||||
|
|||||||
Reference in New Issue
Block a user