diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lang/english.txt | 2 | ||||
-rw-r--r-- | src/news_gui.cpp | 49 | ||||
-rw-r--r-- | src/script/api/game/game_window.hpp.sq | 1 | ||||
-rw-r--r-- | src/script/api/script_window.hpp | 1 | ||||
-rw-r--r-- | src/widgets/news_widget.h | 1 |
5 files changed, 54 insertions, 0 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index 7c59faa54..bc89cfee3 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -870,6 +870,8 @@ STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE :{BIG_FONT}{BLAC STR_NEWS_NEW_VEHICLE_TYPE :{BIG_FONT}{BLACK}{ENGINE} STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE :{BLACK}New {STRING} now available! - {ENGINE} +STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Open the group window focused on the vehicle's group + STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO :{WHITE}{STATION} no longer accepts {STRING} STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_OR_CARGO :{WHITE}{STATION} no longer accepts {STRING} or {STRING} STR_NEWS_STATION_NOW_ACCEPTS_CARGO :{WHITE}{STATION} now accepts {STRING} diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 6fd6ca38a..f963a876a 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -16,6 +16,7 @@ #include "vehicle_base.h" #include "vehicle_func.h" #include "vehicle_gui.h" +#include "roadveh.h" #include "station_base.h" #include "industry.h" #include "town.h" @@ -32,6 +33,7 @@ #include "company_base.h" #include "settings_internal.h" #include "guitimer_func.h" +#include "group_gui.h" #include "widgets/news_widget.h" @@ -181,6 +183,8 @@ static const NWidgetPart _nested_small_news_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX), NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, WID_N_CAPTION), SetFill(1, 0), + NWidget(WWT_TEXTBTN, COLOUR_LIGHT_BLUE, WID_N_SHOW_GROUP), SetMinimalSize(14, 11), SetResize(1, 0), + SetDataTip(STR_NULL /* filled in later */, STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP), EndContainer(), /* Main part */ @@ -279,6 +283,27 @@ struct NewsWindow : Window { /* For company news with a face we have a separate headline in param[0] */ if (desc == &_company_news_desc) this->GetWidget<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0]; + NWidgetCore *nwid = this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP); + if (ni->reftype1 == NR_VEHICLE && nwid != nullptr) { + const Vehicle *v = Vehicle::Get(ni->ref1); + switch (v->type) { + case VEH_TRAIN: + nwid->widget_data = STR_TRAIN; + break; + case VEH_ROAD: + nwid->widget_data = RoadVehicle::From(v)->IsBus() ? STR_BUS : STR_LORRY; + break; + case VEH_SHIP: + nwid->widget_data = STR_SHIP; + break; + case VEH_AIRCRAFT: + nwid->widget_data = STR_PLANE; + break; + default: + break; // Do nothing + } + } + this->FinishInitNested(0); /* Initialize viewport if it exists. */ @@ -354,6 +379,24 @@ struct NewsWindow : Window { str = GetEngineInfoString(engine); break; } + + case WID_N_SHOW_GROUP: + if (this->ni->reftype1 == NR_VEHICLE) { + Dimension d2 = GetStringBoundingBox(this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP)->widget_data); + d2.height += WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM; + d2.width += WD_CAPTIONTEXT_LEFT + WD_CAPTIONTEXT_RIGHT; + *size = d2; + } else { + /* Hide 'Show group window' button if this news is not about a vehicle. */ + size->width = 0; + size->height = 0; + resize->width = 0; + resize->height = 0; + fill->width = 0; + fill->height = 0; + } + return; + default: return; // Do nothing } @@ -449,6 +492,12 @@ struct NewsWindow : Window { case WID_N_VIEWPORT: break; // Ignore clicks + case WID_N_SHOW_GROUP: + if (this->ni->reftype1 == NR_VEHICLE) { + const Vehicle *v = Vehicle::Get(this->ni->ref1); + ShowCompanyGroupForVehicle(v); + } + break; default: if (this->ni->reftype1 == NR_VEHICLE) { const Vehicle *v = Vehicle::Get(this->ni->ref1); diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq index 7eca5023f..be8967604 100644 --- a/src/script/api/game/game_window.hpp.sq +++ b/src/script/api/game/game_window.hpp.sq @@ -870,6 +870,7 @@ void SQGSWindow_Register(Squirrel *engine) SQGSWindow.DefSQConst(engine, ScriptWindow::WID_N_VEH_NAME, "WID_N_VEH_NAME"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_N_VEH_SPR, "WID_N_VEH_SPR"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_N_VEH_INFO, "WID_N_VEH_INFO"); + SQGSWindow.DefSQConst(engine, ScriptWindow::WID_N_SHOW_GROUP, "WID_N_SHOW_GROUP"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_MH_STICKYBOX, "WID_MH_STICKYBOX"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_MH_BACKGROUND, "WID_MH_BACKGROUND"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_MH_SCROLLBAR, "WID_MH_SCROLLBAR"); diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp index 71647ee5b..4efcc5bb6 100644 --- a/src/script/api/script_window.hpp +++ b/src/script/api/script_window.hpp @@ -1940,6 +1940,7 @@ public: WID_N_VEH_NAME = ::WID_N_VEH_NAME, ///< Name of the new vehicle. WID_N_VEH_SPR = ::WID_N_VEH_SPR, ///< Graphical display of the new vehicle. WID_N_VEH_INFO = ::WID_N_VEH_INFO, ///< Some technical data of the new vehicle. + WID_N_SHOW_GROUP = ::WID_N_SHOW_GROUP, ///< Show vehicle's group }; /** Widgets of the #MessageHistoryWindow class. */ diff --git a/src/widgets/news_widget.h b/src/widgets/news_widget.h index 23a66c8af..e5b893443 100644 --- a/src/widgets/news_widget.h +++ b/src/widgets/news_widget.h @@ -31,6 +31,7 @@ enum NewsWidgets { WID_N_VEH_NAME, ///< Name of the new vehicle. WID_N_VEH_SPR, ///< Graphical display of the new vehicle. WID_N_VEH_INFO, ///< Some technical data of the new vehicle. + WID_N_SHOW_GROUP, ///< Show vehicle's group }; /** Widgets of the #MessageHistoryWindow class. */ |