Changeset - r25010:cc3b6b985580
[Not reviewed]
master
0 4 0
dP - 4 years ago 2021-02-20 23:32:45
dp@dpointer.org
Add: Buttons to open global goals from company goals and vice versa
4 files changed with 41 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/company_cmd.cpp
Show inline comments
 
@@ -120,6 +120,7 @@ void SetLocalCompany(CompanyID new_compa
 
	/* ... and redraw the whole screen. */
 
	MarkWholeScreenDirty();
 
	InvalidateWindowClassesData(WC_SIGN_LIST, -1);
 
	InvalidateWindowClassesData(WC_GOALS_LIST);
 
}
 

	
 
/**
src/goal_gui.cpp
Show inline comments
 
@@ -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;
 

	
 
			case WID_GOAL_COMPANY_BUTTON:
 
				ShowGoalsList(_local_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_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_l
 
	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),
src/lang/english.txt
Show inline comments
 
@@ -3197,6 +3197,10 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE
 
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}
src/widgets/goal_widget.h
Show inline comments
 
@@ -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. */
0 comments (0 inline, 0 general)