mirror of https://github.com/OpenTTD/OpenTTD
(svn r21019) -Add: Use center of industry to focus on in the industry gui.
parent
8f24ec9471
commit
cccbc8f418
|
@ -673,7 +673,7 @@ public:
|
||||||
|
|
||||||
this->InitNested(desc, window_number);
|
this->InitNested(desc, window_number);
|
||||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT);
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT);
|
||||||
nvp->InitializeViewport(this, Industry::Get(window_number)->location.tile + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
|
nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ZOOM_LVL_INDUSTRY);
|
||||||
|
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
@ -900,9 +900,9 @@ public:
|
||||||
case IVW_GOTO: {
|
case IVW_GOTO: {
|
||||||
Industry *i = Industry::Get(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(i->location.tile + TileDiffXY(1, 1));
|
ShowExtraViewPortWindow(i->location.GetCenterTile());
|
||||||
} else {
|
} else {
|
||||||
ScrollMainWindowToTile(i->location.tile + TileDiffXY(1, 1));
|
ScrollMainWindowToTile(i->location.GetCenterTile());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#ifndef TILEAREA_TYPE_H
|
#ifndef TILEAREA_TYPE_H
|
||||||
#define TILEAREA_TYPE_H
|
#define TILEAREA_TYPE_H
|
||||||
|
|
||||||
#include "tile_type.h"
|
#include "map_func.h"
|
||||||
|
|
||||||
/** Represents the covered area of e.g. a rail station */
|
/** Represents the covered area of e.g. a rail station */
|
||||||
struct TileArea {
|
struct TileArea {
|
||||||
|
@ -49,6 +49,15 @@ struct TileArea {
|
||||||
bool Intersects(const TileArea &ta) const;
|
bool Intersects(const TileArea &ta) const;
|
||||||
|
|
||||||
void ClampToMap();
|
void ClampToMap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the center tile.
|
||||||
|
* @return The tile at the center, or just north of it.
|
||||||
|
*/
|
||||||
|
TileIndex GetCenterTile() const
|
||||||
|
{
|
||||||
|
return TILE_ADDXY(this->tile, this->w / 2, this->h / 2);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TILEAREA_TYPE_H */
|
#endif /* TILEAREA_TYPE_H */
|
||||||
|
|
Loading…
Reference in New Issue