Remove old overlay and preview code
This commit is contained in:
@@ -549,33 +549,6 @@ void ObjectHighlight::AddTile(TileIndex tile, ObjectTileHighlight &&oh) {
|
||||
this->tiles.insert(std::make_pair(tile, std::move(oh)));
|
||||
}
|
||||
|
||||
void ObjectHighlight::AddStationOverlayData(int w, int h, int rad, StationCoverageType sct) {
|
||||
if (!_settings_game.station.modified_catchment) rad = CA_UNMODIFIED;
|
||||
auto production = citymania::GetProductionAroundTiles(this->tile, w, h, rad);
|
||||
bool has_header = false;
|
||||
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
||||
if (production[i] == 0) continue;
|
||||
|
||||
switch (sct) {
|
||||
case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
||||
case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
|
||||
case SCT_ALL: break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
const CargoSpec *cs = CargoSpec::Get(i);
|
||||
if (cs == nullptr) continue;
|
||||
|
||||
if (!has_header) {
|
||||
this->overlay_data.emplace_back(0, PAL_NONE, GetString(CM_STR_BUILD_INFO_OVERLAY_STATION_SUPPLIES));
|
||||
has_header = true;
|
||||
}
|
||||
SetDParam(0, i);
|
||||
SetDParam(1, production[i] >> 8);
|
||||
this->overlay_data.emplace_back(1, cs->GetCargoIcon(), GetString(CM_STR_BUILD_INFO_OVERLAY_STATION_CARGO));
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectHighlight::UpdateTiles() {
|
||||
this->tiles.clear();
|
||||
this->sprites.clear();
|
||||
@@ -639,7 +612,6 @@ void ObjectHighlight::UpdateTiles() {
|
||||
tile_track += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
|
||||
} while (--numtracks);
|
||||
|
||||
this->AddStationOverlayData(ta.w, ta.h, CA_TRAIN, SCT_ALL);
|
||||
break;
|
||||
}
|
||||
case Type::ROAD_STOP: {
|
||||
@@ -661,9 +633,6 @@ void ObjectHighlight::UpdateTiles() {
|
||||
for (TileIndex tile : ta) {
|
||||
this->AddTile(tile, ObjectTileHighlight::make_road_stop(palette, this->roadtype, this->ddir, this->is_truck, this->road_stop_spec_class, this->road_stop_spec_index));
|
||||
}
|
||||
auto sct = (this->is_truck ? SCT_NON_PASSENGERS_ONLY : SCT_PASSENGERS_ONLY);
|
||||
auto rad = (this->is_truck ? CA_BUS : CA_TRUCK);
|
||||
this->AddStationOverlayData(ta.w, ta.h, rad, sct);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -697,7 +666,6 @@ void ObjectHighlight::UpdateTiles() {
|
||||
for (AirportTileTableIterator iter(as->table[this->airport_layout], this->tile); iter != INVALID_TILE; ++iter) {
|
||||
this->AddTile(iter, ObjectTileHighlight::make_airport_tile(palette, iter.GetStationGfx()));
|
||||
}
|
||||
this->AddStationOverlayData(w, h, as->catchment, SCT_ALL);
|
||||
break;
|
||||
}
|
||||
case Type::BLUEPRINT:
|
||||
@@ -827,44 +795,6 @@ void ObjectHighlight::UpdateTiles() {
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectHighlight::UpdateOverlay() {
|
||||
HideBuildInfoOverlay();
|
||||
auto w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
||||
if (w == nullptr) return;
|
||||
auto vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y);
|
||||
if (vp == nullptr) return;
|
||||
|
||||
if (this->tile == INVALID_TILE) {
|
||||
HideBuildInfoOverlay();
|
||||
return;
|
||||
}
|
||||
|
||||
auto err = this->cost.GetErrorMessage();
|
||||
// auto extra_err = this->cost.GetExtraErrorMessage();
|
||||
bool no_money = (err == STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY);
|
||||
SetDParam(0, this->cost.GetCost());
|
||||
this->overlay_data.emplace_back(0, PAL_NONE, GetString(no_money ? CM_STR_BUILD_INFO_OVERLAY_COST_NO_MONEY : CM_STR_BUILD_INFO_OVERLAY_COST_OK));
|
||||
// if (this->cost.Failed() && err != STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY) {
|
||||
// if (err == INVALID_STRING_ID) {
|
||||
// this->overlay_data.emplace_back(PAL_NONE, GetString(CM_STR_BUILD_INFO_OVERLAY_ERROR_UNKNOWN));
|
||||
// } else {
|
||||
// SetDParam(0, err);
|
||||
// this->overlay_data.emplace_back(PAL_NONE, GetString(CM_STR_BUILD_INFO_OVERLAY_ERROR));
|
||||
// }
|
||||
// if (extra_err != INVALID_STRING_ID) {
|
||||
// SetDParam(0, extra_err);
|
||||
// this->overlay_data.emplace_back(PAL_NONE, GetString(CM_STR_BUILD_INFO_OVERLAY_ERROR));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Point pt = RemapCoords2(TileX(this->tile) * TILE_SIZE + TILE_SIZE / 2, TileY(this->tile) * TILE_SIZE + TILE_SIZE / 2);
|
||||
Point pt = RemapCoords2(TileX(this->tile) * TILE_SIZE, TileY(this->tile) * TILE_SIZE);
|
||||
pt.x = UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left;
|
||||
pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top;
|
||||
// this->overlay_pos = pt;
|
||||
ShowBuildInfoOverlay(pt.x, pt.y, this->overlay_data);
|
||||
}
|
||||
|
||||
void ObjectHighlight::MarkDirty() {
|
||||
for (const auto &kv: this->tiles) {
|
||||
MarkTileDirtyByTile(kv.first);
|
||||
@@ -2258,7 +2188,6 @@ HighLightStyle UpdateTileSelection(HighLightStyle new_drawstyle) {
|
||||
_thd.cm.MarkDirty();
|
||||
_thd.cm = _thd.cm_new;
|
||||
_thd.cm.UpdateTiles();
|
||||
_thd.cm.UpdateOverlay();
|
||||
_thd.cm.MarkDirty();
|
||||
}
|
||||
return new_drawstyle;
|
||||
@@ -2437,7 +2366,6 @@ PaletteID GetTreeShadePal(TileIndex tile) {
|
||||
|
||||
ActiveTool _at;
|
||||
|
||||
|
||||
static void ResetVanillaHighlight() {
|
||||
if (_thd.window_class != WC_INVALID) {
|
||||
/* Undo clicking on button and drag & drop */
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
|
||||
namespace citymania {
|
||||
|
||||
typedef std::function<up<Command>(TileIndex start_tile, TileIndex end_tile)> HighlightGenerator;
|
||||
|
||||
|
||||
enum ZoningBorder: uint8 {
|
||||
NONE = 0,
|
||||
TOP_LEFT = 1,
|
||||
@@ -76,19 +73,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class TileIndexWrapper {
|
||||
public:
|
||||
TileIndex tile;
|
||||
TileIndexWrapper() {}
|
||||
TileIndexWrapper(TileIndex tile)
|
||||
:tile{tile} {}
|
||||
|
||||
inline operator TileIndex () const
|
||||
{
|
||||
return this->tile;
|
||||
}
|
||||
};
|
||||
|
||||
class ObjectTileHighlight {
|
||||
public:
|
||||
enum class Type : uint8_t {
|
||||
@@ -405,25 +389,11 @@ public:
|
||||
void DrawOverlay(DrawPixelInfo *dpi);
|
||||
void AddStationOverlayData(int w, int h, int rad, StationCoverageType sct);
|
||||
void UpdateTiles();
|
||||
void UpdateOverlay();
|
||||
void MarkDirty();
|
||||
};
|
||||
|
||||
typedef std::tuple<HighlightMap, BuildInfoOverlayData, CommandCost> ToolGUIInfo;
|
||||
|
||||
class Preview {
|
||||
public:
|
||||
virtual ~Preview() {}
|
||||
virtual void Update(Point pt, TileIndex tile) = 0;
|
||||
virtual void HandleMouseMove() {};
|
||||
virtual bool HandleMousePress() { return false; };
|
||||
virtual void HandleMouseRelease() {};
|
||||
virtual bool HandleMouseClick(Viewport* /* vp */, Point /* pt */, TileIndex /* tile */, bool /* double_click */) { return false; };
|
||||
virtual std::pair<HighlightMap, BuildInfoOverlayData> GetGUIInfo() = 0;
|
||||
virtual CursorID GetCursor() = 0;
|
||||
virtual void OnStationRemoved(const Station* /* station */) {};
|
||||
};
|
||||
|
||||
class Action {
|
||||
public:
|
||||
virtual ~Action() = default;
|
||||
|
||||
@@ -110,30 +110,9 @@ void MarkTileAreaDirty(const TileArea &ta) {
|
||||
p2.y + MAX_TILE_EXTENT_BOTTOM);
|
||||
}
|
||||
|
||||
static void UpdateHiglightJoinArea(const Station *station) {
|
||||
if (!station) {
|
||||
MarkTileAreaDirty(_highlight_join_area);
|
||||
_highlight_join_area.tile = INVALID_TILE;
|
||||
return;
|
||||
}
|
||||
// auto &r = _station_to_join->rect;
|
||||
// auto d = (int)_settings_game.station.station_spread - 1;
|
||||
// TileArea ta(
|
||||
// TileXY(std::max<int>(r.right - d, 0),
|
||||
// std::max<int>(r.bottom - d, 0)),
|
||||
// TileXY(std::min<int>(r.left + d, Map::SizeX() - 1),
|
||||
// std::min<int>(r.top + d, Map::SizeY() - 1))
|
||||
// );
|
||||
// if (_highlight_join_area.tile == ta.tile &&
|
||||
// _highlight_join_area.w == ta.w &&
|
||||
// _highlight_join_area.h == ta.h) return;
|
||||
// _highlight_join_area = ta;
|
||||
MarkTileAreaDirty(_highlight_join_area);
|
||||
}
|
||||
|
||||
static void MarkCoverageAreaDirty(const Station *station) {
|
||||
MarkTileAreaDirty(station->catchment_tiles);
|
||||
}
|
||||
// static void MarkCoverageAreaDirty(const Station *station) {
|
||||
// MarkTileAreaDirty(station->catchment_tiles);
|
||||
// }
|
||||
|
||||
void MarkCoverageHighlightDirty() {
|
||||
MarkCatchmentTilesDirty();
|
||||
@@ -653,7 +632,7 @@ bool HasSelectedStationHighlight() {
|
||||
return _station_highlight_mode != StationHighlightMode::None;
|
||||
}
|
||||
|
||||
static HighlightMap PrepareHighilightMap(Station *st_join, std::optional<ObjectHighlight> ohl, SpriteID pal, bool show_join_area, bool show_coverage, StationCoverageType sct, uint rad) {
|
||||
static HighlightMap PrepareHighilightMap(Station *st_join, std::optional<ObjectHighlight> ohl, SpriteID pal, bool show_join_area, bool show_coverage, uint rad) {
|
||||
bool add_current = true; // FIXME
|
||||
|
||||
auto hlmap = ohl.has_value() ? ohl->GetHighlightMap(pal) : HighlightMap{};
|
||||
@@ -718,7 +697,6 @@ ToolGUIInfo GetSelectedStationGUIInfo() {
|
||||
CM_PALETTE_TINT_WHITE,
|
||||
false,
|
||||
_station_highlight_mode == StationHighlightMode::Coverage,
|
||||
SCT_ALL,
|
||||
0
|
||||
);
|
||||
return {hlmap, {}, {}};
|
||||
@@ -786,7 +764,6 @@ ToolGUIInfo PlacementAction::PrepareGUIInfo(std::optional<ObjectHighlight> ohl,
|
||||
cost.Succeeded() ? CM_PALETTE_TINT_WHITE : CM_PALETTE_TINT_RED_DEEP,
|
||||
true,
|
||||
show_coverage,
|
||||
sct,
|
||||
rad
|
||||
);
|
||||
|
||||
@@ -1417,7 +1394,7 @@ up<Command> AirportBuildTool::SizedPlacementHandler::GetCommand(TileIndex tile,
|
||||
tile,
|
||||
airport_type,
|
||||
layout,
|
||||
StationBuildTool::station_to_join,
|
||||
to_join,
|
||||
true
|
||||
);
|
||||
cmd->with_error(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE);
|
||||
|
||||
Reference in New Issue
Block a user