(svn r25370) -Fix: Make the prefix for widget constants unique for the goal list window

pull/155/head
zuu 11 years ago
parent 88e4221d5a
commit be27dce443

@ -32,16 +32,16 @@ struct GoalListWindow : Window {
GoalListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) GoalListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{ {
this->CreateNestedTree(); this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_GL_SCROLLBAR); this->vscroll = this->GetScrollbar(WID_GOAL_SCROLLBAR);
this->FinishInitNested(window_number); this->FinishInitNested(window_number);
this->OnInvalidateData(0); this->OnInvalidateData(0);
} }
virtual void OnClick(Point pt, int widget, int click_count) virtual void OnClick(Point pt, int widget, int click_count)
{ {
if (widget != WID_GL_GOAL && widget != WID_GL_PROGRESS) return; if (widget != WID_GOAL_GOAL && widget != WID_GOAL_PROGRESS) return;
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GL_GOAL, WD_FRAMERECT_TOP); int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GOAL_GOAL, WD_FRAMERECT_TOP);
int num = 0; int num = 0;
const Goal *s; const Goal *s;
FOR_ALL_GOALS(s) { FOR_ALL_GOALS(s) {
@ -135,10 +135,10 @@ struct GoalListWindow : Window {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{ {
if (widget != WID_GL_GOAL && widget != WID_GL_PROGRESS) return; if (widget != WID_GOAL_GOAL && widget != WID_GOAL_PROGRESS) return;
Dimension d = maxdim(GetStringBoundingBox(STR_GOALS_GLOBAL_TITLE), GetStringBoundingBox(STR_GOALS_COMPANY_TITLE)); Dimension d = maxdim(GetStringBoundingBox(STR_GOALS_GLOBAL_TITLE), GetStringBoundingBox(STR_GOALS_COMPANY_TITLE));
if (widget == WID_GL_PROGRESS) { if (widget == WID_GOAL_PROGRESS) {
/* Get max progress width. */ /* Get max progress width. */
d.width = 0; d.width = 0;
Goal *s; Goal *s;
@ -168,7 +168,7 @@ struct GoalListWindow : Window {
*/ */
void DrawPartialGoalList(int widget, int &pos, const int cap, int x, int y, int right, bool global_section) const void DrawPartialGoalList(int widget, int &pos, const int cap, int x, int y, int right, bool global_section) const
{ {
if (widget == WID_GL_GOAL && IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, global_section ? STR_GOALS_GLOBAL_TITLE : STR_GOALS_COMPANY_TITLE); if (widget == WID_GOAL_GOAL && IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, global_section ? STR_GOALS_GLOBAL_TITLE : STR_GOALS_COMPANY_TITLE);
pos++; pos++;
uint num = 0; uint num = 0;
@ -177,13 +177,13 @@ struct GoalListWindow : Window {
if (global_section ? s->company == INVALID_COMPANY : s->company == _local_company && s->company != INVALID_COMPANY) { if (global_section ? s->company == INVALID_COMPANY : s->company == _local_company && s->company != INVALID_COMPANY) {
if (IsInsideMM(pos, 0, cap)) { if (IsInsideMM(pos, 0, cap)) {
switch (widget) { switch (widget) {
case WID_GL_GOAL: case WID_GOAL_GOAL:
/* Display the goal. */ /* Display the goal. */
SetDParamStr(0, s->text); SetDParamStr(0, s->text);
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT); DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_TEXT);
break; break;
case WID_GL_PROGRESS: case WID_GOAL_PROGRESS:
if (s->progress != NULL) { if (s->progress != NULL) {
SetDParamStr(0, s->progress); SetDParamStr(0, s->progress);
DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS, TC_FROMSTRING, SA_RIGHT | SA_FORCE); DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, s->completed ? STR_GOALS_PROGRESS_COMPLETE : STR_GOALS_PROGRESS, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
@ -196,7 +196,7 @@ struct GoalListWindow : Window {
} }
} }
if (widget == WID_GL_GOAL && num == 0) { if (widget == WID_GOAL_GOAL && num == 0) {
if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_NONE); if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * FONT_HEIGHT_NORMAL, STR_GOALS_NONE);
pos++; pos++;
} }
@ -204,7 +204,7 @@ struct GoalListWindow : Window {
virtual void DrawWidget(const Rect &r, int widget) const virtual void DrawWidget(const Rect &r, int widget) const
{ {
if (widget != WID_GL_GOAL && widget != WID_GL_PROGRESS) return; if (widget != WID_GOAL_GOAL && widget != WID_GOAL_PROGRESS) return;
YearMonthDay ymd; YearMonthDay ymd;
ConvertDateToYMD(_date, &ymd); ConvertDateToYMD(_date, &ymd);
@ -226,7 +226,7 @@ struct GoalListWindow : Window {
virtual void OnResize() virtual void OnResize()
{ {
this->vscroll->SetCapacityFromWidget(this, WID_GL_GOAL); this->vscroll->SetCapacityFromWidget(this, WID_GOAL_GOAL);
} }
/** /**
@ -250,16 +250,16 @@ static const NWidgetPart _nested_goals_list_widgets[] = {
NWidget(WWT_STICKYBOX, COLOUR_BROWN), NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(), EndContainer(),
NWidget(NWID_HORIZONTAL), SetFill(1, 1), NWidget(NWID_HORIZONTAL), SetFill(1, 1),
NWidget(WWT_PANEL, COLOUR_BROWN), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GL_SCROLLBAR), NWidget(WWT_PANEL, COLOUR_BROWN), SetDataTip(0x0, STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER), SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_GOAL_SCROLLBAR),
NWidget(NWID_VERTICAL), SetPIP(WD_FRAMERECT_TOP, 4, WD_FRAMETEXT_BOTTOM), NWidget(NWID_VERTICAL), SetPIP(WD_FRAMERECT_TOP, 4, WD_FRAMETEXT_BOTTOM),
NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2), NWidget(NWID_HORIZONTAL), SetPIP(2, 4, 2),
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GL_GOAL), SetResize(1, 1), SetMinimalTextLines(2, 0), SetFill(1, 0), NWidget(WWT_EMPTY, COLOUR_GREY, WID_GOAL_GOAL), SetResize(1, 1), SetMinimalTextLines(2, 0), SetFill(1, 0),
NWidget(WWT_EMPTY, COLOUR_GREY, WID_GL_PROGRESS), SetResize(0, 1), SetMinimalTextLines(2, 0), SetFill(0, 1), NWidget(WWT_EMPTY, COLOUR_GREY, WID_GOAL_PROGRESS), SetResize(0, 1), SetMinimalTextLines(2, 0), SetFill(0, 1),
EndContainer(), EndContainer(),
EndContainer(), EndContainer(),
EndContainer(), EndContainer(),
NWidget(NWID_VERTICAL), NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_GL_SCROLLBAR), NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_GOAL_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN), NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(), EndContainer(),
EndContainer(), EndContainer(),

@ -495,9 +495,9 @@ void SQGSWindow_Register(Squirrel *engine)
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_PROGRESS_BAR, "WID_GP_PROGRESS_BAR"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_PROGRESS_BAR, "WID_GP_PROGRESS_BAR");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_PROGRESS_TEXT, "WID_GP_PROGRESS_TEXT"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_PROGRESS_TEXT, "WID_GP_PROGRESS_TEXT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_ABORT, "WID_GP_ABORT"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GP_ABORT, "WID_GP_ABORT");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_GOAL, "WID_GL_GOAL"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GOAL_GOAL, "WID_GOAL_GOAL");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_PROGRESS, "WID_GL_PROGRESS"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GOAL_PROGRESS, "WID_GOAL_PROGRESS");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_SCROLLBAR, "WID_GL_SCROLLBAR"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GOAL_SCROLLBAR, "WID_GOAL_SCROLLBAR");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_CAPTION, "WID_GQ_CAPTION"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_CAPTION, "WID_GQ_CAPTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_QUESTION, "WID_GQ_QUESTION"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_QUESTION, "WID_GQ_QUESTION");
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_BUTTONS, "WID_GQ_BUTTONS"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GQ_BUTTONS, "WID_GQ_BUTTONS");

@ -1339,9 +1339,9 @@ public:
/* automatically generated from ../../widgets/goal_widget.h */ /* automatically generated from ../../widgets/goal_widget.h */
/** Widgets of the #GoalListWindow class. */ /** Widgets of the #GoalListWindow class. */
enum GoalListWidgets { enum GoalListWidgets {
WID_GL_GOAL = ::WID_GL_GOAL, ///< Goal text column of the goal list. WID_GOAL_GOAL = ::WID_GOAL_GOAL, ///< Goal text column of the goal list.
WID_GL_PROGRESS = ::WID_GL_PROGRESS, ///< Goal progress column of the goal list. WID_GOAL_PROGRESS = ::WID_GOAL_PROGRESS, ///< Goal progress column of the goal list.
WID_GL_SCROLLBAR = ::WID_GL_SCROLLBAR, ///< Scrollbar of the goal list. WID_GOAL_SCROLLBAR = ::WID_GOAL_SCROLLBAR, ///< Scrollbar of the goal list.
}; };
/** Widgets of the #GoalQuestionWindow class. */ /** Widgets of the #GoalQuestionWindow class. */

@ -15,9 +15,9 @@
/** Widgets of the #GoalListWindow class. */ /** Widgets of the #GoalListWindow class. */
enum GoalListWidgets { enum GoalListWidgets {
WID_GL_GOAL, ///< Goal text column of the goal list. WID_GOAL_GOAL, ///< Goal text column of the goal list.
WID_GL_PROGRESS, ///< Goal progress column of the goal list. WID_GOAL_PROGRESS, ///< Goal progress column of the goal list.
WID_GL_SCROLLBAR, ///< Scrollbar of the goal list. WID_GOAL_SCROLLBAR, ///< Scrollbar of the goal list.
}; };
/** Widgets of the #GoalQuestionWindow class. */ /** Widgets of the #GoalQuestionWindow class. */

Loading…
Cancel
Save