Change: Use Rect helpers for widget drawing.
This replaces repetitive and sometimes unwieldy use of constants.
This commit is contained in:
@@ -192,9 +192,7 @@ struct GoalListWindow : public Window {
|
||||
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;
|
||||
Rect r = wid->GetCurrentRect().Shrink(WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM);
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
|
||||
int pos = -this->vscroll->GetPosition();
|
||||
@@ -209,7 +207,7 @@ struct GoalListWindow : public Window {
|
||||
/* Display the goal. */
|
||||
SetDParamStr(0, s->text);
|
||||
uint width_reduction = progress_col_width > 0 ? progress_col_width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT : 0;
|
||||
DrawString(x + (rtl ? width_reduction : 0), right - (rtl ? 0 : width_reduction), y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT);
|
||||
DrawString(r.Indent(width_reduction, !rtl), STR_GOALS_TEXT);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -217,12 +215,11 @@ struct GoalListWindow : public Window {
|
||||
if (s->progress != nullptr) {
|
||||
SetDParamStr(0, s->progress);
|
||||
StringID str = s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS;
|
||||
int progress_x = x;
|
||||
int progress_right = rtl ? x + progress_col_width : right;
|
||||
DrawString(progress_x, progress_right, y + pos * FONT_HEIGHT_NORMAL, str, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
|
||||
DrawString(r.WithWidth(progress_col_width, !rtl), str, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
r.top += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
pos++;
|
||||
num++;
|
||||
@@ -231,9 +228,8 @@ struct GoalListWindow : public Window {
|
||||
|
||||
if (num == 0) {
|
||||
if (column == GC_GOAL && IsInsideMM(pos, 0, cap)) {
|
||||
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_NONE);
|
||||
DrawString(r, STR_GOALS_NONE);
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,8 +293,7 @@ static const NWidgetPart _nested_goals_list_widgets[] = {
|
||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetScrollbar(WID_GOAL_SCROLLBAR),
|
||||
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GOAL_LIST), SetResize(1, 1), SetMinimalTextLines(2, 0), SetFill(1, 1), SetPadding(WD_FRAMERECT_TOP, 2, WD_FRAMETEXT_BOTTOM, 2),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_GOAL_LIST), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetScrollbar(WID_GOAL_SCROLLBAR), SetResize(1, 1), SetMinimalTextLines(2, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_GOAL_SCROLLBAR),
|
||||
@@ -412,7 +407,7 @@ struct GoalQuestionWindow : public Window {
|
||||
if (widget != WID_GQ_QUESTION) return;
|
||||
|
||||
SetDParamStr(0, this->question);
|
||||
DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, this->colour, SA_TOP | SA_HOR_CENTER);
|
||||
DrawStringMultiLine(r, STR_JUST_RAW_STRING, this->colour, SA_TOP | SA_HOR_CENTER);
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user