diff --git a/gui/design.lua b/gui/design.lua index 7c27aaf1fd..0005263944 100644 --- a/gui/design.lua +++ b/gui/design.lua @@ -1795,14 +1795,18 @@ DimensionsOverlay.ATTRS{ local selection_rect = df.global.selection_rect local function is_choosing_area() - return selection_rect.start_x >= 0 and dfhack.gui.getMousePos() + return selection_rect.start_z >= 0 and dfhack.gui.getMousePos(true) end local function get_cur_area_dims() - local pos1 = dfhack.gui.getMousePos() - if not pos1 or selection_rect.start_x < 0 then return 1, 1, 1 end + local pos1 = dfhack.gui.getMousePos(true) + if not pos1 or selection_rect.start_z < 0 then return 1, 1, 1 end -- clamp to map edges (since you can start selection out of bounds) + pos1 = xyz2pos( + math.max(0, math.min(df.global.world.map.x_count-1, pos1.x)), + math.max(0, math.min(df.global.world.map.y_count-1, pos1.y)), + math.max(0, math.min(df.global.world.map.z_count-1, pos1.z))) local pos2 = xyz2pos( math.max(0, math.min(df.global.world.map.x_count-1, selection_rect.start_x)), math.max(0, math.min(df.global.world.map.y_count-1, selection_rect.start_y)),