Skip to content

Commit

Permalink
Feature: Add a button to the vehicle advisory news window to open the…
Browse files Browse the repository at this point in the history
… group window.
  • Loading branch information
stormcone committed Jul 22, 2019
1 parent 2b66fd5 commit 74edb63
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ 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 :{BLACK}Open group window
STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Open the group window and select 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}
Expand Down
21 changes: 21 additions & 0 deletions src/news_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ static const NWidgetPart _nested_small_news_widgets[] = {
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetPadding(1, 1, 1, 1), SetMinimalSize(274, 47), SetFill(1, 0),
EndContainer(),
NWidget(WWT_EMPTY, COLOUR_WHITE, WID_N_MESSAGE), SetMinimalSize(275, 20), SetFill(1, 0), SetPadding(0, 5, 0, 5),
NWidget(WWT_TEXTBTN, COLOUR_LIGHT_BLUE, WID_N_SHOW_GROUP), SetMinimalSize(275, 20), SetResize(1, 0), SetFill(1, 0),
SetDataTip(STR_NEWS_SHOW_VEHICLE_GROUP, STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP),
EndContainer(),
};

Expand Down Expand Up @@ -357,6 +359,19 @@ struct NewsWindow : Window {
str = GetEngineInfoString(engine);
break;
}

case WID_N_SHOW_GROUP:
if (this->ni->reftype1 != NR_VEHICLE) {
/* 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;
}
break;

default:
return; // Do nothing
}
Expand Down Expand Up @@ -452,6 +467,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);
Expand Down
1 change: 1 addition & 0 deletions src/script/api/game/game_window.hpp.sq
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,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");
Expand Down
1 change: 1 addition & 0 deletions src/script/api/script_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,7 @@ class ScriptWindow : public ScriptObject {
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. */
Expand Down
1 change: 1 addition & 0 deletions src/widgets/news_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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. */
Expand Down

0 comments on commit 74edb63

Please sign in to comment.