Merge branch 'save_ext' into cargo_type_order

# Conflicts:
#	src/core/smallstack_type.hpp
This commit is contained in:
Jonathan G Rennison
2018-07-02 18:52:22 +01:00
534 changed files with 24037 additions and 9447 deletions

View File

@@ -298,7 +298,7 @@ Point LinkGraphOverlay::GetStationMiddle(const Station *st) const
* Set a new cargo mask and rebuild the cache.
* @param cargo_mask New cargo mask.
*/
void LinkGraphOverlay::SetCargoMask(uint32 cargo_mask)
void LinkGraphOverlay::SetCargoMask(CargoTypes cargo_mask)
{
this->cargo_mask = cargo_mask;
this->RebuildCache();
@@ -319,7 +319,7 @@ void LinkGraphOverlay::SetCompanyMask(uint32 company_mask)
/** Make a number of rows with buttons for each company for the linkgraph legend window. */
NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI(int *biggest_index)
{
return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, 3, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES);
return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, 3, STR_NULL);
}
NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index)
@@ -435,7 +435,7 @@ void LinkGraphLegendWindow::SetOverlay(LinkGraphOverlay *overlay) {
this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, HasBit(companies, c));
}
}
uint32 cargoes = this->overlay->GetCargoMask();
CargoTypes cargoes = this->overlay->GetCargoMask();
for (uint c = 0; c < NUM_CARGO; c++) {
if (!this->IsWidgetDisabled(WID_LGL_CARGO_FIRST + c)) {
this->SetWidgetLoweredState(WID_LGL_CARGO_FIRST + c, HasBit(cargoes, c));
@@ -496,10 +496,48 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const
if (this->IsWidgetDisabled(widget)) return;
CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST);
GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, cargo->legend_colour);
DrawString(r.left, r.right, (r.top + r.bottom + 1 - FONT_HEIGHT_SMALL) / 2, cargo->abbrev, TC_BLACK, SA_HOR_CENTER);
DrawString(r.left, r.right, (r.top + r.bottom + 1 - FONT_HEIGHT_SMALL) / 2, cargo->abbrev, GetContrastColour(cargo->legend_colour, 73), SA_HOR_CENTER);
}
}
bool LinkGraphLegendWindow::OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond)
{
if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) {
GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_SELECT_COMPANIES, 0, NULL, close_cond);
} else {
uint64 params[2];
CompanyID cid = (CompanyID)(widget - WID_LGL_COMPANY_FIRST);
params[0] = STR_LINKGRAPH_LEGEND_SELECT_COMPANIES;
params[1] = cid;
GuiShowTooltips(this, STR_LINKGRAPH_LEGEND_COMPANY_TOOLTIP, 2, params, close_cond);
}
return true;
}
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
if (this->IsWidgetDisabled(widget)) return false;
CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST);
uint64 params[1];
params[0] = cargo->name;
GuiShowTooltips(this, STR_BLACK_STRING, 1, params, close_cond);
return true;
}
return false;
}
void LinkGraphLegendWindow::OnHover(Point pt, int widget)
{
this->OnHoverCommon(pt, widget, TCC_HOVER);
}
bool LinkGraphLegendWindow::OnRightClick(Point pt, int widget)
{
if (_settings_client.gui.hover_delay_ms == 0) {
return this->OnHoverCommon(pt, widget, TCC_RIGHT_CLICK);
}
return false;
}
/**
* Update the overlay with the new company selection.
*/
@@ -519,7 +557,7 @@ void LinkGraphLegendWindow::UpdateOverlayCompanies()
*/
void LinkGraphLegendWindow::UpdateOverlayCargoes()
{
uint32 mask = 0;
CargoTypes mask = 0;
for (uint c = 0; c < NUM_CARGO; c++) {
if (this->IsWidgetDisabled(c + WID_LGL_CARGO_FIRST)) continue;
if (!this->IsWidgetLowered(c + WID_LGL_CARGO_FIRST)) continue;

View File

@@ -15,6 +15,7 @@
#include "../company_func.h"
#include "../station_base.h"
#include "../widget_type.h"
#include "../window_gui.h"
#include "linkgraph_base.h"
#include <map>
#include <vector>
@@ -51,17 +52,17 @@ public:
* @param company_mask Bitmask of companies to be shown.
* @param scale Desired thickness of lines and size of station dots.
*/
LinkGraphOverlay(const Window *w, uint wid, uint32 cargo_mask, uint32 company_mask, uint scale) :
LinkGraphOverlay(const Window *w, uint wid, CargoTypes cargo_mask, uint32 company_mask, uint scale) :
window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale)
{}
void RebuildCache();
void Draw(const DrawPixelInfo *dpi) const;
void SetCargoMask(uint32 cargo_mask);
void SetCargoMask(CargoTypes cargo_mask);
void SetCompanyMask(uint32 company_mask);
/** Get a bitmask of the currently shown cargoes. */
uint32 GetCargoMask() { return this->cargo_mask; }
CargoTypes GetCargoMask() { return this->cargo_mask; }
/** Get a bitmask of the currently shown companies. */
uint32 GetCompanyMask() { return this->company_mask; }
@@ -69,7 +70,7 @@ public:
protected:
const Window *window; ///< Window to be drawn into.
const uint widget_id; ///< ID of Widget in Window to be drawn to.
uint32 cargo_mask; ///< Bitmask of cargos to be displayed.
CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed.
uint32 company_mask; ///< Bitmask of companies to be displayed.
LinkMap cached_links; ///< Cache for links to reduce recalculation.
StationSupplyList cached_stations; ///< Cache for stations to be drawn.
@@ -77,7 +78,6 @@ protected:
Point GetStationMiddle(const Station *st) const;
void DrawForwBackLinks(Point pta, StationID sta, Point ptb, StationID stb) const;
void AddLinks(const Station *sta, const Station *stb);
void DrawLinks(const DrawPixelInfo *dpi) const;
void DrawStationDots(const DrawPixelInfo *dpi) const;
@@ -102,6 +102,8 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize);
virtual void DrawWidget(const Rect &r, int widget) const;
virtual void OnHover(Point pt, int widget);
virtual bool OnRightClick(Point pt, int widget);
virtual void OnClick(Point pt, int widget, int click_count);
virtual void OnInvalidateData(int data = 0, bool gui_scope = true);
@@ -110,6 +112,7 @@ private:
void UpdateOverlayCompanies();
void UpdateOverlayCargoes();
bool OnHoverCommon(Point pt, int widget, TooltipCloseCondition close_cond);
};
#endif /* LINKGRAPH_GUI_H */

View File

@@ -61,7 +61,7 @@ void LinkGraphJob::EraseFlows(NodeID from)
*/
void LinkGraphJob::SpawnThread()
{
if (!ThreadObject::New(&(LinkGraphSchedule::Run), this, &this->thread)) {
if (!ThreadObject::New(&(LinkGraphSchedule::Run), this, &this->thread, "ottd:linkgraph")) {
this->thread = NULL;
/* Of course this will hang a bit.
* On the other hand, if you want to play games which make this hang noticably