summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-12-23 14:24:34 +0000
committeralberth <alberth@openttd.org>2010-12-23 14:24:34 +0000
commit90780fd25bab45fb97304337f10b78c9210a7190 (patch)
treee89a067d86fa4e9b8034660396cbb0fc2e0eb27a /src/viewport.cpp
parent1ba348914dc78ae72026aff568a2e09442be4bcb (diff)
downloadopenttd-90780fd25bab45fb97304337f10b78c9210a7190.tar.xz
(svn r21608) -Codechange: Move diagnonal rectangle dragging detection completely to tile highlighting.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r--src/viewport.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index b0116e39e..cf58fccf5 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2026,6 +2026,15 @@ static HighLightStyle GetAutorailHT(int x, int y)
}
/**
+ * Is the user dragging a 'diagonal rectangle'?
+ * @return User is dragging a rotated rectangle.
+ */
+bool TileHighlightData::IsDraggingDiagonal()
+{
+ return (this->place_mode & HT_DIAGONAL) != 0 && _ctrl_pressed && _left_button_down;
+}
+
+/**
* Updates tile highlighting for all cases.
* Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size
* Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice,
@@ -2049,7 +2058,7 @@ void UpdateTileSelection()
x1 &= ~TILE_UNIT_MASK;
y1 &= ~TILE_UNIT_MASK;
- if (IsDraggingDiagonal()) {
+ if (_thd.IsDraggingDiagonal()) {
new_diagonal = true;
} else {
if (x1 >= x2) Swap(x1, x2);
@@ -2724,7 +2733,7 @@ calc_heightdiff_single_direction:;
/* If dragging an area (eg dynamite tool) and it is actually a single
* row/column, change the type to 'line' to get proper calculation for height */
style = (HighLightStyle)_thd.next_drawstyle;
- if (IsDraggingDiagonal()) {
+ if (_thd.IsDraggingDiagonal()) {
/* Determine the "area" of the diagonal dragged selection.
* We assume the area is the number of tiles along the X
* edge and the number of tiles along the Y edge. However,