mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-31 19:33:34 +00:00
Add: Buttons to open global goals from company goals and vice versa
This commit is contained in:
parent
818bee3961
commit
56911a86ea
@ -120,6 +120,7 @@ void SetLocalCompany(CompanyID new_company)
|
||||
/* ... and redraw the whole screen. */
|
||||
MarkWholeScreenDirty();
|
||||
InvalidateWindowClassesData(WC_SIGN_LIST, -1);
|
||||
InvalidateWindowClassesData(WC_GOALS_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,6 +46,8 @@ struct GoalListWindow : public Window {
|
||||
this->vscroll = this->GetScrollbar(WID_GOAL_SCROLLBAR);
|
||||
this->FinishInitNested(window_number);
|
||||
this->owner = (Owner)this->window_number;
|
||||
NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_GOAL_SELECT_BUTTONS);
|
||||
wi->SetDisplayedPlane(window_number == INVALID_COMPANY ? 1 : 0);
|
||||
this->OnInvalidateData(0);
|
||||
}
|
||||
|
||||
@ -63,17 +65,31 @@ struct GoalListWindow : public Window {
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
if (widget != WID_GOAL_LIST) return;
|
||||
switch (widget) {
|
||||
case WID_GOAL_GLOBAL_BUTTON:
|
||||
ShowGoalsList(INVALID_COMPANY);
|
||||
break;
|
||||
|
||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
|
||||
for (const Goal *s : Goal::Iterate()) {
|
||||
if (s->company == this->window_number) {
|
||||
if (y == 0) {
|
||||
this->HandleClick(s);
|
||||
return;
|
||||
case WID_GOAL_COMPANY_BUTTON:
|
||||
ShowGoalsList(_local_company);
|
||||
break;
|
||||
|
||||
case WID_GOAL_LIST: {
|
||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
|
||||
for (const Goal *s : Goal::Iterate()) {
|
||||
if (s->company == this->window_number) {
|
||||
if (y == 0) {
|
||||
this->HandleClick(s);
|
||||
return;
|
||||
}
|
||||
y--;
|
||||
}
|
||||
}
|
||||
y--;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,6 +276,8 @@ struct GoalListWindow : public Window {
|
||||
{
|
||||
if (!gui_scope) return;
|
||||
this->vscroll->SetCount(this->CountLines());
|
||||
this->SetWidgetDisabledState(WID_GOAL_COMPANY_BUTTON, _local_company == COMPANY_SPECTATOR);
|
||||
this->SetWidgetDirty(WID_GOAL_COMPANY_BUTTON);
|
||||
this->SetWidgetDirty(WID_GOAL_LIST);
|
||||
}
|
||||
};
|
||||
@ -269,6 +287,10 @@ static const NWidgetPart _nested_goals_list_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_GOAL_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GOAL_SELECT_BUTTONS),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_GLOBAL_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_GLOBAL_BUTTON, STR_GOALS_GLOBAL_BUTTON_HELPTEXT),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_GOAL_COMPANY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GOALS_COMPANY_BUTTON, STR_GOALS_COMPANY_BUTTON_HELPTEXT),
|
||||
EndContainer(),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
|
@ -3197,6 +3197,10 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{YELLOW}Bribe t
|
||||
STR_GOALS_CAPTION :{WHITE}{COMPANY} Goals
|
||||
STR_GOALS_SPECTATOR_CAPTION :{WHITE}Global Goals
|
||||
STR_GOALS_SPECTATOR :Global Goals
|
||||
STR_GOALS_GLOBAL_BUTTON :{BLACK}Global
|
||||
STR_GOALS_GLOBAL_BUTTON_HELPTEXT :{BLACK}Show global goals
|
||||
STR_GOALS_COMPANY_BUTTON :{BLACK}Company
|
||||
STR_GOALS_COMPANY_BUTTON_HELPTEXT :{BLACK}Show company goals
|
||||
STR_GOALS_TEXT :{ORANGE}{RAW_STRING}
|
||||
STR_GOALS_NONE :{ORANGE}- None -
|
||||
STR_GOALS_PROGRESS :{ORANGE}{RAW_STRING}
|
||||
|
@ -13,9 +13,12 @@
|
||||
|
||||
/** Widgets of the #GoalListWindow class. */
|
||||
enum GoalListWidgets {
|
||||
WID_GOAL_CAPTION, ///< Caption of the window.
|
||||
WID_GOAL_LIST, ///< Goal list.
|
||||
WID_GOAL_SCROLLBAR, ///< Scrollbar of the goal list.
|
||||
WID_GOAL_CAPTION, ///< Caption of the window.
|
||||
WID_GOAL_SELECT_BUTTONS, ///< Selection widget for the title bar button.
|
||||
WID_GOAL_GLOBAL_BUTTON, ///< Button to show global goals.
|
||||
WID_GOAL_COMPANY_BUTTON, ///< Button to show company goals.
|
||||
WID_GOAL_LIST, ///< Goal list.
|
||||
WID_GOAL_SCROLLBAR, ///< Scrollbar of the goal list.
|
||||
};
|
||||
|
||||
/** Widgets of the #GoalQuestionWindow class. */
|
||||
|
Loading…
Reference in New Issue
Block a user