Import measurement patch
http://www.tt-forums.net/viewtopic.php?p=1086160#p1086160
This commit is contained in:

committed by
Jonathan G Rennison

parent
67366cf03d
commit
9dfdd8bce8
@@ -273,6 +273,7 @@ STR_MEASURE_LENGTH :{BLACK}Length:
|
||||
STR_MEASURE_AREA :{BLACK}Area: {NUM} x {NUM}
|
||||
STR_MEASURE_LENGTH_HEIGHTDIFF :{BLACK}Length: {NUM}{}Height difference: {HEIGHT}
|
||||
STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Area: {NUM} x {NUM}{}Height difference: {HEIGHT}
|
||||
STR_MEASURE_DIST_HEIGHTDIFF :{BLACK}Manhattan Distance: {NUM}{}Bird Fly Distance: {NUM}{}Distance from the nearest edge: {NUM}{}Height from sea level: {HEIGHT}{}Height difference: {HEIGHT}
|
||||
|
||||
|
||||
# These are used in buttons
|
||||
@@ -2475,6 +2476,7 @@ STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND :{BLACK}Lower a
|
||||
STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND :{BLACK}Raise a corner of land. Dragging raises the first selected corner and levels the selected area to the new corner height. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate
|
||||
STR_LANDSCAPING_LEVEL_LAND_TOOLTIP :{BLACK}Level an area of land to the height of the first selected corner. Ctrl selects the area diagonally. Shift toggles building/showing cost estimate
|
||||
STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND :{BLACK}Purchase land for future use. Shift toggles building/showing cost estimate
|
||||
STR_LANDSCAPING_TOOLTIP_RULER_TOOL :{BLACK}Use a virtual ruler to measure distance and height
|
||||
|
||||
# Object construction window
|
||||
STR_OBJECT_BUILD_CAPTION :{WHITE}Object Selection
|
||||
|
@@ -399,6 +399,7 @@ STR_MEASURE_LENGTH :{BLACK}Длин
|
||||
STR_MEASURE_AREA :{BLACK}Площадь: {NUM} x {NUM}
|
||||
STR_MEASURE_LENGTH_HEIGHTDIFF :{BLACK}Длина: {NUM}{}Разница высот: {HEIGHT}
|
||||
STR_MEASURE_AREA_HEIGHTDIFF :{BLACK}Площадь: {NUM} x {NUM}{}Разница высот: {HEIGHT}
|
||||
STR_MEASURE_DIST_HEIGHTDIFF :{BLACK}Расстояние «Манхэттэн»: {NUM}{}Расстояние по прямой: {NUM}{}Расстояние от ближайшего края: {NUM}{}Высота над уровнем моря: {HEIGHT}{}Разница высот: {HEIGHT}
|
||||
|
||||
|
||||
# These are used in buttons
|
||||
@@ -2655,6 +2656,7 @@ STR_LANDSCAPING_TOOLTIP_LOWER_A_CORNER_OF_LAND :{BLACK}Опус
|
||||
STR_LANDSCAPING_TOOLTIP_RAISE_A_CORNER_OF_LAND :{BLACK}Поднять угол земли. Перетаскивание поднимает первый выбранный угол и выравнивает выбранную область до новой высоты угла. Ctrl выбирает область по диагонали. При нажатом Shift - оценка стоимости строительства.
|
||||
STR_LANDSCAPING_LEVEL_LAND_TOOLTIP :{BLACK}Выровнять землю до высоты первого выбранного угла. Ctrl выбирает область по диагонали. При нажатом Shift - оценка стоимости выравнивания.
|
||||
STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND :{BLACK}Покупка земли. При нажатом Shift - оценка стоимости покупки.
|
||||
STR_LANDSCAPING_TOOLTIP_RULER_TOOL :{BLACK}Виртуальная линейка для измерения расстояний и высот
|
||||
|
||||
# Object construction window
|
||||
STR_OBJECT_BUILD_CAPTION :{WHITE}Выбор объекта
|
||||
|
@@ -147,6 +147,11 @@ void PlaceProc_DemolishArea(TileIndex tile)
|
||||
VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
|
||||
}
|
||||
|
||||
static void PlaceProc_Measure(TileIndex tile)
|
||||
{
|
||||
VpStartPlaceSizing(tile, VPM_A_B_LINE, DDSP_MEASURE);
|
||||
}
|
||||
|
||||
/** Terra form toolbar managing class. */
|
||||
struct TerraformToolbarWindow : Window {
|
||||
int last_user_action; ///< Last started user action.
|
||||
@@ -204,6 +209,11 @@ struct TerraformToolbarWindow : Window {
|
||||
ShowBuildTreesToolbar();
|
||||
break;
|
||||
|
||||
case WID_TT_MEASUREMENT_TOOL:
|
||||
HandlePlacePushButton(this, WID_TT_MEASUREMENT_TOOL, SPR_CURSOR_QUERY, HT_RECT);
|
||||
this->last_user_action = widget;
|
||||
break;
|
||||
|
||||
case WID_TT_PLACE_SIGN: // Place sign button
|
||||
HandlePlacePushButton(this, WID_TT_PLACE_SIGN, SPR_CURSOR_SIGN, HT_RECT);
|
||||
this->last_user_action = widget;
|
||||
@@ -240,6 +250,10 @@ struct TerraformToolbarWindow : Window {
|
||||
DoCommandP(tile, OBJECT_OWNED_LAND, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
|
||||
break;
|
||||
|
||||
case WID_TT_MEASUREMENT_TOOL:
|
||||
PlaceProc_Measure(tile);
|
||||
break;
|
||||
|
||||
case WID_TT_PLACE_SIGN: // Place sign button
|
||||
PlaceProc_Sign(tile);
|
||||
break;
|
||||
@@ -271,6 +285,9 @@ struct TerraformToolbarWindow : Window {
|
||||
case DDSP_LEVEL_AREA:
|
||||
GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
|
||||
break;
|
||||
case DDSP_MEASURE:
|
||||
//nothing to do, just draw a tooltip
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,6 +320,7 @@ static Hotkey terraform_hotkeys[] = {
|
||||
Hotkey('D' | WKC_GLOBAL_HOTKEY, "dynamite", WID_TT_DEMOLISH),
|
||||
Hotkey('U', "buyland", WID_TT_BUY_LAND),
|
||||
Hotkey('I', "trees", WID_TT_PLANT_TREES),
|
||||
Hotkey('R', "ruler", WID_TT_MEASUREMENT_TOOL),
|
||||
Hotkey('O', "placesign", WID_TT_PLACE_SIGN),
|
||||
Hotkey('P', "placeobject", WID_TT_PLACE_OBJECT),
|
||||
HOTKEY_LIST_END
|
||||
@@ -331,6 +349,8 @@ static const NWidgetPart _nested_terraform_widgets[] = {
|
||||
SetFill(0, 1), SetDataTip(SPR_IMG_BUY_LAND, STR_LANDSCAPING_TOOLTIP_PURCHASE_LAND),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_DARK_GREEN, WID_TT_PLANT_TREES), SetMinimalSize(22, 22),
|
||||
SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_SCENEDIT_TOOLBAR_PLANT_TREES),
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_MEASUREMENT_TOOL), SetMinimalSize(22,22),
|
||||
SetFill(0, 1), SetDataTip(SPR_IMG_QUERY, STR_LANDSCAPING_TOOLTIP_RULER_TOOL),
|
||||
NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_TT_PLACE_SIGN), SetMinimalSize(22, 22),
|
||||
SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_SCENEDIT_TOOLBAR_PLACE_SIGN),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_TT_SHOW_PLACE_OBJECT),
|
||||
|
@@ -3022,6 +3022,45 @@ calc_heightdiff_single_direction:;
|
||||
}
|
||||
break;
|
||||
|
||||
case VPM_A_B_LINE: { // drag an A to B line
|
||||
TileIndex t0 = TileVirtXY(sx, sy);
|
||||
TileIndex t1 = TileVirtXY(x, y);
|
||||
uint dx = Delta(TileX(t0), TileX(t1)) + 1;
|
||||
uint dy = Delta(TileY(t0), TileY(t1)) + 1;
|
||||
byte index = 0;
|
||||
uint64 params[5];
|
||||
memset( params, 0, sizeof( params ) );
|
||||
|
||||
/* 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 (style & HT_RECT) {
|
||||
if (dx == 1) {
|
||||
style = HT_LINE | HT_DIR_Y;
|
||||
} else if (dy == 1) {
|
||||
style = HT_LINE | HT_DIR_X;
|
||||
}
|
||||
}
|
||||
|
||||
int heightdiff = 0;
|
||||
|
||||
if (dx != 1 || dy != 1) {
|
||||
heightdiff = CalcHeightdiff(style, 0, t0, t1);
|
||||
params[index++] = DistanceManhattan(t0, t1);
|
||||
params[index++] = sqrtl(dx * dx + dy * dy); //DistanceSquare does not like big numbers
|
||||
|
||||
} else {
|
||||
index += 2;
|
||||
}
|
||||
|
||||
params[index++] = DistanceFromEdge(t1);
|
||||
params[index++] = GetTileMaxZ(t1) / TILE_HEIGHT * TILE_HEIGHT_STEP;
|
||||
params[index++] = heightdiff;
|
||||
//Show always the measurement tooltip
|
||||
GuiShowTooltips(_thd.GetCallbackWnd(),STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_LEFT_CLICK);
|
||||
break;
|
||||
}
|
||||
|
||||
case VPM_X_AND_Y_LIMITED: // Drag an X by Y constrained rect area.
|
||||
limit = (_thd.sizelimit - 1) * TILE_SIZE;
|
||||
x = sx + Clamp(x - sx, -limit, limit);
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "zoom_type.h"
|
||||
#include "strings_type.h"
|
||||
#include "table/strings.h"
|
||||
#include "math.h"
|
||||
|
||||
class LinkGraphOverlay;
|
||||
|
||||
@@ -85,6 +86,7 @@ enum ViewportPlaceMethod {
|
||||
VPM_FIX_VERTICAL = 6, ///< drag only in vertical direction
|
||||
VPM_X_LIMITED = 7, ///< Drag only in X axis with limited size
|
||||
VPM_Y_LIMITED = 8, ///< Drag only in Y axis with limited size
|
||||
VPM_A_B_LINE = 9, ///< Drag a line from tile A to tile B
|
||||
VPM_RAILDIRS = 0x40, ///< all rail directions
|
||||
VPM_SIGNALDIRS = 0x80, ///< similar to VMP_RAILDIRS, but with different cursor
|
||||
};
|
||||
@@ -105,6 +107,7 @@ enum ViewportDragDropSelectionProcess {
|
||||
DDSP_CREATE_RIVER, ///< Create rivers
|
||||
DDSP_PLANT_TREES, ///< Plant trees
|
||||
DDSP_BUILD_BRIDGE, ///< Bridge placement
|
||||
DDSP_MEASURE, ///< Measurement tool
|
||||
|
||||
/* Rail specific actions */
|
||||
DDSP_PLACE_RAIL, ///< Rail placement
|
||||
|
@@ -22,6 +22,7 @@ enum TerraformToolbarWidgets {
|
||||
WID_TT_DEMOLISH, ///< Demolish aka dynamite button.
|
||||
WID_TT_BUY_LAND, ///< Buy land button.
|
||||
WID_TT_PLANT_TREES, ///< Plant trees button (note: opens separate window, no place-push-button).
|
||||
WID_TT_MEASUREMENT_TOOL, ///< Ruler tool button
|
||||
WID_TT_PLACE_SIGN, ///< Place sign button.
|
||||
WID_TT_PLACE_OBJECT, ///< Place object button.
|
||||
};
|
||||
|
Reference in New Issue
Block a user