|
@@ -47,25 +47,25 @@ struct GoalListWindow : public Window {
|
|
|
this->vscroll = this->GetScrollbar(WID_GOAL_SCROLLBAR);
|
|
|
this->FinishInitNested(window_number);
|
|
|
this->owner = (Owner)this->window_number;
|
|
|
this->OnInvalidateData(0);
|
|
|
}
|
|
|
|
|
|
/* virtual */ void SetStringParameters(int widget) const
|
|
|
void SetStringParameters(int widget) const override
|
|
|
{
|
|
|
if (widget != WID_GOAL_CAPTION) return;
|
|
|
|
|
|
if (this->window_number == INVALID_COMPANY) {
|
|
|
SetDParam(0, STR_GOALS_SPECTATOR_CAPTION);
|
|
|
} else {
|
|
|
SetDParam(0, STR_GOALS_CAPTION);
|
|
|
SetDParam(1, this->window_number);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* virtual */ void OnClick(Point pt, int widget, int click_count)
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
|
|
{
|
|
|
if (widget != WID_GOAL_LIST) return;
|
|
|
|
|
|
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_LIST, WD_FRAMERECT_TOP);
|
|
|
int num = 0;
|
|
|
const Goal *s;
|
|
@@ -174,13 +174,13 @@ struct GoalListWindow : public Window {
|
|
|
if (num_company == 0) num_company = 1;
|
|
|
|
|
|
/* Global, company and an empty line before the accepted ones. */
|
|
|
return 3 + num_global + num_company;
|
|
|
}
|
|
|
|
|
|
/* virtual */ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
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));
|
|
|
|
|
|
resize->height = d.height;
|
|
|
|
|
@@ -269,13 +269,13 @@ struct GoalListWindow : public Window {
|
|
|
|
|
|
/* Draw partial list with company goals. */
|
|
|
pos++;
|
|
|
DrawPartialGoalList(pos, cap, x, y, right, progress_col_width, false, column);
|
|
|
}
|
|
|
|
|
|
/* virtual */ void OnPaint()
|
|
|
void OnPaint() override
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
|
|
|
if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
|
|
|
|
|
|
/* Calculate progress column width. */
|
|
@@ -296,23 +296,23 @@ struct GoalListWindow : public Window {
|
|
|
/* Draw goal list. */
|
|
|
this->DrawListColumn(GC_PROGRESS, wid, progress_col_width);
|
|
|
this->DrawListColumn(GC_GOAL, wid, progress_col_width);
|
|
|
|
|
|
}
|
|
|
|
|
|
/* virtual */ void OnResize()
|
|
|
void OnResize() override
|
|
|
{
|
|
|
this->vscroll->SetCapacityFromWidget(this, WID_GOAL_LIST);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Some data on this window has become invalid.
|
|
|
* @param data Information about the changed data.
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
*/
|
|
|
/* virtual */ void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
this->vscroll->SetCount(this->CountLines());
|
|
|
this->SetWidgetDirty(WID_GOAL_LIST);
|
|
|
}
|
|
|
};
|
|
@@ -385,13 +385,13 @@ struct GoalQuestionWindow : public Windo
|
|
|
|
|
|
~GoalQuestionWindow()
|
|
|
{
|
|
|
free(this->question);
|
|
|
}
|
|
|
|
|
|
/* virtual */ void SetStringParameters(int widget) const
|
|
|
void SetStringParameters(int widget) const override
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_GQ_CAPTION:
|
|
|
SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
|
|
|
break;
|
|
|
|
|
@@ -406,13 +406,13 @@ struct GoalQuestionWindow : public Windo
|
|
|
case WID_GQ_BUTTON_3:
|
|
|
SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[2]);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* virtual */ void OnClick(Point pt, int widget, int click_count)
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_GQ_BUTTON_1:
|
|
|
DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER);
|
|
|
delete this;
|
|
|
break;
|
|
@@ -426,21 +426,21 @@ struct GoalQuestionWindow : public Windo
|
|
|
DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER);
|
|
|
delete this;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* virtual */ void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
|
|
{
|
|
|
if (widget != WID_GQ_QUESTION) return;
|
|
|
|
|
|
SetDParamStr(0, this->question);
|
|
|
size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width) + WD_PAR_VSEP_WIDE;
|
|
|
}
|
|
|
|
|
|
/* virtual */ void DrawWidget(const Rect &r, int widget) const
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
|
|
{
|
|
|
if (widget != WID_GQ_QUESTION) return;
|
|
|
|
|
|
SetDParamStr(0, this->question);
|
|
|
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK, SA_TOP | SA_HOR_CENTER);
|
|
|
}
|