Import combined Enhanced viewport: zoom out, overlays & tooltips (r53_27127) patch

https://www.tt-forums.net/viewtopic.php?f=33&t=53394
This commit is contained in:
patch-import
2015-08-02 19:37:42 +01:00
committed by Jonathan G Rennison
parent fd3388467f
commit 536a95dfd0
105 changed files with 3509 additions and 325 deletions

View File

@@ -16,6 +16,9 @@
#include "strings_func.h"
#include "zoom_func.h"
#include "window_func.h"
#include "gfx_func.h"
#include "industry.h"
#include "town_map.h"
#include "widgets/viewport_widget.h"
@@ -78,6 +81,7 @@ public:
this->viewport->scrollpos_y = pt.y - this->viewport->virtual_height / 2;
this->viewport->dest_scrollpos_x = this->viewport->scrollpos_x;
this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y;
this->viewport->map_type = (ViewportMapType) _settings_client.gui.default_viewport_map_mode;
}
virtual void SetStringParameters(int widget) const
@@ -138,10 +142,24 @@ public:
virtual void OnMouseWheel(int wheel)
{
if (_settings_client.gui.scrollwheel_scrolling == 0) {
if (_ctrl_pressed) {
/* Cycle through the drawing modes */
this->viewport->map_type = ChangeRenderMode(this->viewport, wheel < 0);
this->SetDirty();
} else if (_settings_client.gui.scrollwheel_scrolling == 0) {
ZoomInOrOutToCursorWindow(wheel < 0, this);
}
}
virtual void OnMouseOver(Point pt, int widget)
{
if (pt.x != -1) {
/* Show tooltip with last month production or town name */
const Point p = GetTileBelowCursor();
const TileIndex tile = TileVirtXY(p.x, p.y);
if (tile < MapSize()) ShowTooltipForTile(this, tile);
}
}
/**
* Some data on this window has become invalid.
@@ -189,3 +207,38 @@ void ShowExtraViewPortWindowForTileUnderCursor()
Point pt = GetTileBelowCursor();
ShowExtraViewPortWindow(pt.x != -1 ? TileVirtXY(pt.x, pt.y) : INVALID_TILE);
}
void ShowTooltipForTile(Window *w, const TileIndex tile)
{
switch (GetTileType(tile)) {
case MP_ROAD:
if (IsRoadDepot(tile)) return;
/* FALL THROUGH */
case MP_HOUSE: {
if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES)) return; // No need for a town name tooltip when it is already displayed
SetDParam(0, GetTownIndex(tile));
GuiShowTooltips(w, STR_TOWN_NAME_TOOLTIP, 0, NULL, TCC_HOVER);
break;
}
case MP_INDUSTRY: {
const Industry *ind = Industry::GetByTile(tile);
const IndustrySpec *indsp = GetIndustrySpec(ind->type);
StringID str = STR_INDUSTRY_VIEW_TRANSPORTED_TOOLTIP;
uint prm_count = 0;
SetDParam(prm_count++, indsp->name);
for (byte i = 0; i < lengthof(ind->produced_cargo); i++) {
if (ind->produced_cargo[i] != CT_INVALID) {
SetDParam(prm_count++, ind->produced_cargo[i]);
SetDParam(prm_count++, ind->last_month_production[i]);
SetDParam(prm_count++, ToPercent8(ind->last_month_pct_transported[i]));
str++;
}
}
GuiShowTooltips(w, str, 0, NULL, TCC_HOVER);
break;
}
default:
return;
}
}