summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordP <dp@dpointer.org>2021-02-21 01:00:11 +0300
committerCharles Pigott <charlespigott@googlemail.com>2021-03-08 18:18:47 +0000
commit818bee3961d41dc830803792ab3cbe064c8b1f65 (patch)
tree4299165a6cccbed4a775beb5d678085549087670
parent3878c4781eb72e8f6a3218cb6feefac42daf0730 (diff)
downloadopenttd-818bee3961d41dc830803792ab3cbe064c8b1f65.tar.xz
Change: Don't show global goals in company goal windows
-rw-r--r--src/goal_gui.cpp93
-rw-r--r--src/lang/english.txt3
2 files changed, 20 insertions, 76 deletions
diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp
index 86f73dd0b..bf200050b 100644
--- a/src/goal_gui.cpp
+++ b/src/goal_gui.cpp
@@ -66,33 +66,13 @@ struct GoalListWindow : public Window {
if (widget != WID_GOAL_LIST) return;
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
- int num = 0;
for (const Goal *s : Goal::Iterate()) {
- if (s->company == INVALID_COMPANY) {
- y--;
+ if (s->company == this->window_number) {
if (y == 0) {
this->HandleClick(s);
return;
}
- num++;
- }
- }
-
- if (num == 0) {
- y--; // "None" line.
- if (y < 0) return;
- }
-
- y -= 2; // "Company specific goals:" line.
- if (y < 0) return;
-
- for (const Goal *s : Goal::Iterate()) {
- if (s->company == this->window_number && s->company != INVALID_COMPANY) {
y--;
- if (y == 0) {
- this->HandleClick(s);
- return;
- }
}
}
}
@@ -161,28 +141,21 @@ struct GoalListWindow : public Window {
uint CountLines()
{
/* Count number of (non) awarded goals. */
- uint num_global = 0;
- uint num_company = 0;
+ uint num = 0;
for (const Goal *s : Goal::Iterate()) {
- if (s->company == INVALID_COMPANY) {
- num_global++;
- } else if (s->company == this->window_number) {
- num_company++;
- }
+ if (s->company == this->window_number) num++;
}
/* Count the 'none' lines. */
- if (num_global == 0) num_global = 1;
- if (num_company == 0) num_company = 1;
+ if (num == 0) num = 1;
- /* Global, company and an empty line before the accepted ones. */
- return 3 + num_global + num_company;
+ return num;
}
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget != WID_GOAL_LIST) return;
- Dimension d = maxdim(GetStringBoundingBox(STR_GOALS_GLOBAL_TITLE), GetStringBoundingBox(STR_GOALS_COMPANY_TITLE));
+ Dimension d = GetStringBoundingBox(STR_GOALS_NONE);
resize->height = d.height;
@@ -193,26 +166,26 @@ struct GoalListWindow : public Window {
}
/**
- * Draws either the global goals or the company goal section.
- * This is a helper method for #DrawWidget.
- * @param[in,out] pos Vertical line number to draw.
- * @param cap Number of lines to draw in the window.
- * @param x Left edge of the text line to draw.
- * @param y Vertical position of the top edge of the window.
- * @param right Right edge of the text line to draw.
- * @param global_section Whether the global goals are printed.
+ * Draws a given column of the goal list.
* @param column Which column to draw.
+ * @param wid Pointer to the goal list widget.
+ * @param progress_col_width Width of the progress column.
+ * @return max width of drawn text
*/
- void DrawPartialGoalList(int &pos, const int cap, int x, int y, int right, uint progress_col_width, bool global_section, GoalColumn column) const
+ void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
{
- if (column == GC_GOAL && IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, global_section ? STR_GOALS_GLOBAL_TITLE : STR_GOALS_COMPANY_TITLE);
- pos++;
-
+ /* Get column draw area. */
+ int y = wid->pos_y + WD_FRAMERECT_TOP;
+ int x = wid->pos_x + WD_FRAMERECT_LEFT;
+ int right = x + wid->current_x - WD_FRAMERECT_RIGHT;
bool rtl = _current_text_dir == TD_RTL;
+ int pos = -this->vscroll->GetPosition();
+ const int cap = this->vscroll->GetCapacity();
+
uint num = 0;
for (const Goal *s : Goal::Iterate()) {
- if (global_section ? s->company == INVALID_COMPANY : (s->company == this->window_number && s->company != INVALID_COMPANY)) {
+ if (s->company == this->window_number) {
if (IsInsideMM(pos, 0, cap)) {
switch (column) {
case GC_GOAL: {
@@ -241,38 +214,12 @@ struct GoalListWindow : public Window {
if (num == 0) {
if (column == GC_GOAL && IsInsideMM(pos, 0, cap)) {
- StringID str = !global_section && this->window_number == INVALID_COMPANY ? STR_GOALS_SPECTATOR_NONE : STR_GOALS_NONE;
- DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, str);
+ DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_NONE);
}
pos++;
}
}
- /**
- * Draws a given column of the goal list.
- * @param column Which column to draw.
- * @param wid Pointer to the goal list widget.
- * @param progress_col_width Width of the progress column.
- * @return max width of drawn text
- */
- void DrawListColumn(GoalColumn column, NWidgetBase *wid, uint progress_col_width) const
- {
- /* Get column draw area. */
- int y = wid->pos_y + WD_FRAMERECT_TOP;
- int x = wid->pos_x + WD_FRAMERECT_LEFT;
- int right = x + wid->current_x - WD_FRAMERECT_RIGHT;
-
- int pos = -this->vscroll->GetPosition();
- const int cap = this->vscroll->GetCapacity();
-
- /* Draw partial list with global goals. */
- DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, true, column);
-
- /* Draw partial list with company goals. */
- pos++;
- DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, false, column);
- }
-
void OnPaint() override
{
this->DrawWidgets();
diff --git a/src/lang/english.txt b/src/lang/english.txt
index cc69584b0..29ffa5855 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3197,13 +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_TITLE :{BLACK}Global goals:
STR_GOALS_TEXT :{ORANGE}{RAW_STRING}
STR_GOALS_NONE :{ORANGE}- None -
-STR_GOALS_SPECTATOR_NONE :{ORANGE}- Not applicable -
STR_GOALS_PROGRESS :{ORANGE}{RAW_STRING}
STR_GOALS_PROGRESS_COMPLETE :{GREEN}{RAW_STRING}
-STR_GOALS_COMPANY_TITLE :{BLACK}Company goals:
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on goal to centre main view on industry/town/tile. Ctrl+Click opens a new viewport on industry/town/tile location
# Goal question window