Merge branch 'master' into jgrpp
Replace build and refit, and group collapse implementations Fix template creation build and refit # Conflicts: # Makefile.bundle.in # config.lib # src/animated_tile.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.hpp # src/blitter/null.hpp # src/build_vehicle_gui.cpp # src/command.cpp # src/command_func.h # src/console_gui.cpp # src/core/smallstack_type.hpp # src/date.cpp # src/debug.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.h # src/main_gui.cpp # src/misc_gui.cpp # src/network/core/game.h # src/network/core/packet.cpp # src/network/core/udp.cpp # src/network/core/udp.h # src/network/network_content.cpp # src/network/network_type.h # src/network/network_udp.cpp # src/newgrf_house.h # src/openttd.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/os/unix/crashlog_unix.cpp # src/os/windows/crashlog_win.cpp # src/osk_gui.cpp # src/pathfinder/opf/opf_ship.cpp # src/rail_cmd.cpp # src/rail_gui.cpp # src/saveload/saveload.cpp # src/settings.cpp # src/settings_gui.cpp # src/smallmap_gui.h # src/station_base.h # src/station_cmd.cpp # src/table/gameopt_settings.ini # src/table/newgrf_debug_data.h # src/table/settings.ini # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehiclelist.cpp # src/viewport.cpp # src/widgets/dropdown.cpp # src/window_gui.h
This commit is contained in:
@@ -180,7 +180,7 @@ protected:
|
||||
|
||||
DEBUG(misc, 3, "Building station list for company %d", owner);
|
||||
|
||||
this->stations.Clear();
|
||||
this->stations.clear();
|
||||
|
||||
const Station *st;
|
||||
FOR_ALL_STATIONS(st) {
|
||||
@@ -191,23 +191,23 @@ protected:
|
||||
if (st->goods[j].HasRating()) {
|
||||
num_waiting_cargo++; // count number of waiting cargo
|
||||
if (HasBit(this->cargo_filter, j)) {
|
||||
*this->stations.Append() = st;
|
||||
this->stations.push_back(st);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* stations without waiting cargo */
|
||||
if (num_waiting_cargo == 0 && this->include_empty) {
|
||||
*this->stations.Append() = st;
|
||||
this->stations.push_back(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->stations.Compact();
|
||||
this->stations.shrink_to_fit();
|
||||
this->stations.RebuildDone();
|
||||
|
||||
this->vscroll->SetCount(this->stations.Length()); // Update the scrollbar
|
||||
this->vscroll->SetCount(this->stations.size()); // Update the scrollbar
|
||||
}
|
||||
|
||||
/** Sort stations by their name */
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
this->last_sorting = this->stations.GetListing();
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_STL_SORTBY: {
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
this->BuildStationsList((Owner)this->window_number);
|
||||
this->SortStationsList();
|
||||
@@ -403,7 +403,7 @@ public:
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_STL_SORTBY:
|
||||
@@ -413,7 +413,7 @@ public:
|
||||
|
||||
case WID_STL_LIST: {
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length());
|
||||
int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
|
||||
int y = r.top + WD_FRAMERECT_TOP;
|
||||
for (int i = this->vscroll->GetPosition(); i < max; ++i) { // do until max number of stations of owner
|
||||
const Station *st = this->stations[i];
|
||||
@@ -487,7 +487,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
if (widget == WID_STL_CAPTION) {
|
||||
SetDParam(0, this->window_number);
|
||||
@@ -495,12 +495,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_STL_LIST: {
|
||||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
|
||||
if (id_v >= this->stations.Length()) return; // click out of list bound
|
||||
if (id_v >= this->stations.size()) return; // click out of list bound
|
||||
|
||||
const Station *st = this->stations[id_v];
|
||||
/* do not check HasStationInUse - it is slow and may be invalid */
|
||||
@@ -611,7 +611,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
if (this->stations.SortType() != index) {
|
||||
this->stations.SetSortType(index);
|
||||
@@ -623,7 +623,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnGameTick()
|
||||
void OnGameTick() override
|
||||
{
|
||||
if (this->stations.NeedResort()) {
|
||||
DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number);
|
||||
@@ -631,7 +631,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
}
|
||||
@@ -641,7 +641,7 @@ public:
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (data == 0) {
|
||||
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
|
||||
@@ -1367,7 +1367,7 @@ struct StationViewWindow : public Window {
|
||||
data->Update(count);
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SV_WAITING:
|
||||
@@ -1391,7 +1391,7 @@ struct StationViewWindow : public Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnPaint()
|
||||
void OnPaint() override
|
||||
{
|
||||
const Station *st = Station::Get(this->window_number);
|
||||
CargoDataEntry cargo;
|
||||
@@ -1447,7 +1447,7 @@ struct StationViewWindow : public Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetStringParameters(int widget) const
|
||||
void SetStringParameters(int widget) const override
|
||||
{
|
||||
const Station *st = Station::Get(this->window_number);
|
||||
SetDParam(0, st->index);
|
||||
@@ -1882,7 +1882,7 @@ struct StationViewWindow : public Window {
|
||||
this->SetWidgetDirty(WID_SV_WAITING);
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_SV_WAITING:
|
||||
@@ -2048,7 +2048,7 @@ struct StationViewWindow : public Window {
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
virtual void OnDropdownSelect(int widget, int index)
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
{
|
||||
if (widget == WID_SV_SORT_BY) {
|
||||
this->SelectSortBy(index);
|
||||
@@ -2057,14 +2057,14 @@ struct StationViewWindow : public Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnQueryTextFinished(char *str)
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
|
||||
DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), NULL, str);
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_SV_WAITING, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
}
|
||||
@@ -2074,7 +2074,7 @@ struct StationViewWindow : public Window {
|
||||
* @param data Information about the changed data. If it's a valid cargo ID, invalidate the cargo data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (gui_scope) {
|
||||
if (data >= 0 && data < NUM_CARGO) {
|
||||
@@ -2127,8 +2127,8 @@ struct TileAndStation {
|
||||
StationID station; ///< StationID
|
||||
};
|
||||
|
||||
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
|
||||
static SmallVector<StationID, 8> _stations_nearby_list;
|
||||
static std::vector<TileAndStation> _deleted_stations_nearby;
|
||||
static std::vector<StationID> _stations_nearby_list;
|
||||
|
||||
/**
|
||||
* Add station on this tile to _stations_nearby_list if it's fully within the
|
||||
@@ -2143,11 +2143,11 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
|
||||
TileArea *ctx = (TileArea *)user_data;
|
||||
|
||||
/* First check if there were deleted stations here */
|
||||
for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
|
||||
TileAndStation *ts = _deleted_stations_nearby.Get(i);
|
||||
for (uint i = 0; i < _deleted_stations_nearby.size(); i++) {
|
||||
auto ts = _deleted_stations_nearby.begin() + i;
|
||||
if (ts->tile == tile) {
|
||||
*_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
|
||||
_deleted_stations_nearby.Erase(ts);
|
||||
_stations_nearby_list.push_back(_deleted_stations_nearby[i].station);
|
||||
_deleted_stations_nearby.erase(ts);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
@@ -2161,10 +2161,10 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
|
||||
if (!T::IsValidID(sid)) return false;
|
||||
|
||||
T *st = T::Get(sid);
|
||||
if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
|
||||
if (st->owner != _local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end()) return false;
|
||||
|
||||
if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST).Succeeded()) {
|
||||
*_stations_nearby_list.Append() = sid;
|
||||
_stations_nearby_list.push_back(sid);
|
||||
}
|
||||
|
||||
return false; // We want to include *all* nearby stations
|
||||
@@ -2184,8 +2184,8 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join)
|
||||
{
|
||||
TileArea ctx = ta;
|
||||
|
||||
_stations_nearby_list.Clear();
|
||||
_deleted_stations_nearby.Clear();
|
||||
_stations_nearby_list.clear();
|
||||
_deleted_stations_nearby.clear();
|
||||
|
||||
/* Check the inside, to return, if we sit on another station */
|
||||
TILE_AREA_LOOP(t, ta) {
|
||||
@@ -2198,9 +2198,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join)
|
||||
if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
|
||||
/* Include only within station spread (yes, it is strictly less than) */
|
||||
if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) {
|
||||
TileAndStation *ts = _deleted_stations_nearby.Append();
|
||||
ts->tile = st->xy;
|
||||
ts->station = st->index;
|
||||
_deleted_stations_nearby.push_back({st->xy, st->index});
|
||||
|
||||
/* Add the station when it's within where we're going to build */
|
||||
if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
|
||||
@@ -2260,13 +2258,13 @@ struct SelectStationWindow : Window {
|
||||
this->OnInvalidateData(0);
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
if (widget != WID_JS_PANEL) return;
|
||||
|
||||
/* Determine the widest string */
|
||||
Dimension d = GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
|
||||
for (uint i = 0; i < _stations_nearby_list.Length(); i++) {
|
||||
for (uint i = 0; i < _stations_nearby_list.size(); i++) {
|
||||
const T *st = T::Get(_stations_nearby_list[i]);
|
||||
SetDParam(0, st->index);
|
||||
SetDParam(1, st->facilities);
|
||||
@@ -2280,7 +2278,7 @@ struct SelectStationWindow : Window {
|
||||
*size = d;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
if (widget != WID_JS_PANEL) return;
|
||||
|
||||
@@ -2290,7 +2288,7 @@ struct SelectStationWindow : Window {
|
||||
y += this->resize.step_height;
|
||||
}
|
||||
|
||||
for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += this->resize.step_height) {
|
||||
for (uint i = max<uint>(1, this->vscroll->GetPosition()); i <= _stations_nearby_list.size(); ++i, y += this->resize.step_height) {
|
||||
/* Don't draw anything if it extends past the end of the window. */
|
||||
if (i - this->vscroll->GetPosition() >= this->vscroll->GetCapacity()) break;
|
||||
|
||||
@@ -2301,7 +2299,7 @@ struct SelectStationWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnClick(Point pt, int widget, int click_count)
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
if (widget != WID_JS_PANEL) return;
|
||||
|
||||
@@ -2309,7 +2307,7 @@ struct SelectStationWindow : Window {
|
||||
bool distant_join = (st_index > 0);
|
||||
if (distant_join) st_index--;
|
||||
|
||||
if (distant_join && st_index >= _stations_nearby_list.Length()) return;
|
||||
if (distant_join && st_index >= _stations_nearby_list.size()) return;
|
||||
|
||||
/* Insert station to be joined into stored command */
|
||||
SB(this->select_station_cmd.p2, 16, 16,
|
||||
@@ -2322,7 +2320,7 @@ struct SelectStationWindow : Window {
|
||||
DeleteWindowById(WC_SELECT_STATION, 0);
|
||||
}
|
||||
|
||||
virtual void OnRealtimeTick(uint delta_ms)
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
if (_thd.dirty & 2) {
|
||||
_thd.dirty &= ~2;
|
||||
@@ -2330,7 +2328,7 @@ struct SelectStationWindow : Window {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnResize()
|
||||
void OnResize() override
|
||||
{
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_JS_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
||||
}
|
||||
@@ -2340,11 +2338,11 @@ struct SelectStationWindow : Window {
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
FindStationsNearby<T>(this->area, true);
|
||||
this->vscroll->SetCount(_stations_nearby_list.Length() + 1);
|
||||
this->vscroll->SetCount(_stations_nearby_list.size() + 1);
|
||||
this->SetDirty();
|
||||
}
|
||||
};
|
||||
@@ -2389,7 +2387,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
|
||||
* If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
|
||||
* but join the other station immediately. */
|
||||
const T *st = FindStationsNearby<T>(ta, false);
|
||||
return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0);
|
||||
return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.size() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user