palettes and overworld drawing

This commit is contained in:
scawful
2022-09-10 16:33:59 -05:00
parent 8cc9adf41a
commit 1244e6855c
14 changed files with 168 additions and 190 deletions

View File

@@ -37,15 +37,14 @@ void Canvas::DrawContextMenu() {
io.MousePos.y - origin.y);
// Add first and second point
if (is_hovered && !dragging_select_ &&
ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
points_.push_back(mouse_pos_in_canvas);
points_.push_back(mouse_pos_in_canvas);
dragging_select_ = true;
}
if (dragging_select_) {
points_.back() = mouse_pos_in_canvas;
if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) dragging_select_ = false;
if (is_hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
ImVec2 draw_tile_outline_pos;
draw_tile_outline_pos.x = std::round((double)mouse_pos_in_canvas.x / 32) * 32;
draw_tile_outline_pos.y = std::round((double)mouse_pos_in_canvas.y / 32) * 32;
points_.push_back(draw_tile_outline_pos);
points_.push_back(
ImVec2(draw_tile_outline_pos.x + 32, draw_tile_outline_pos.y + 32));
}
// Pan (we use a zero mouse threshold when there's no context menu)
@@ -62,8 +61,6 @@ void Canvas::DrawContextMenu() {
ImGui::OpenPopupOnItemClick("context", ImGuiPopupFlags_MouseButtonRight);
if (ImGui::BeginPopup("context")) {
if (dragging_select_) points_.resize(points_.size() - 2);
dragging_select_ = false;
if (ImGui::MenuItem("Remove all", nullptr, false, points_.Size > 0)) {
points_.clear();
}

View File

@@ -23,7 +23,6 @@ class Canvas {
void DrawContextMenu();
void DrawBitmap(const Bitmap& bitmap, int border_offset = 0);
void DrawBitmap(const Bitmap& bitmap, int x_offset, int y_offset);
// void DrawLargeBitmap(const Bitmap& tl, const Bitmap& tr, const Bitmap& bl, const Bitmap& br);
void DrawOutline(int x, int y, int w, int h);
void DrawGrid(float grid_step = 64.0f);
void DrawOverlay(); // last
@@ -38,7 +37,6 @@ class Canvas {
private:
bool enable_grid_ = true;
bool enable_context_menu_ = true;
bool dragging_select_ = false;
bool custom_canvas_size_ = false;
ImDrawList* draw_list_;