mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r23534) -Codechange: document and rename widgets to be consistent and understandable
This commit is contained in:
parent
f578edd3bc
commit
cb8e37197d
|
@ -198,7 +198,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const NWidgetPart _nested_highscore_widgets[] = {
|
static const NWidgetPart _nested_highscore_widgets[] = {
|
||||||
NWidget(WWT_PANEL, COLOUR_END, HSW_BACKGROUND), SetMinimalSize(641, 481), SetResize(1, 1), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_END, WID_H_BACKGROUND), SetMinimalSize(641, 481), SetResize(1, 1), EndContainer(),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _highscore_desc(
|
static const WindowDesc _highscore_desc(
|
||||||
|
|
|
@ -174,15 +174,15 @@ static const NWidgetPart _nested_build_industry_widgets[] = {
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, DPIW_MATRIX_WIDGET), SetDataTip(0x801, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(DPIW_SCROLLBAR),
|
NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_DPI_MATRIX_WIDGET), SetDataTip(0x801, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(WID_DPI_SCROLLBAR),
|
||||||
NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, DPIW_SCROLLBAR),
|
NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_DPI_SCROLLBAR),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, DPIW_INFOPANEL), SetResize(1, 0),
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_DPI_INFOPANEL), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, DPIW_DISPLAY_WIDGET), SetFill(1, 0), SetResize(1, 0),
|
NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, WID_DPI_DISPLAY_WIDGET), SetFill(1, 0), SetResize(1, 0),
|
||||||
SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, DPIW_FUND_WIDGET), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL),
|
NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, WID_DPI_FUND_WIDGET), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
|
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
@ -261,8 +261,8 @@ class BuildIndustryWindow : public Window {
|
||||||
/** Update status of the fund and display-chain widgets. */
|
/** Update status of the fund and display-chain widgets. */
|
||||||
void SetButtons()
|
void SetButtons()
|
||||||
{
|
{
|
||||||
this->SetWidgetDisabledState(DPIW_FUND_WIDGET, this->selected_type != INVALID_INDUSTRYTYPE && !this->enabled[this->selected_index]);
|
this->SetWidgetDisabledState(WID_DPI_FUND_WIDGET, this->selected_type != INVALID_INDUSTRYTYPE && !this->enabled[this->selected_index]);
|
||||||
this->SetWidgetDisabledState(DPIW_DISPLAY_WIDGET, this->selected_type == INVALID_INDUSTRYTYPE && this->enabled[this->selected_index]);
|
this->SetWidgetDisabledState(WID_DPI_DISPLAY_WIDGET, this->selected_type == INVALID_INDUSTRYTYPE && this->enabled[this->selected_index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -276,7 +276,7 @@ public:
|
||||||
this->callback_timer = DAY_TICKS;
|
this->callback_timer = DAY_TICKS;
|
||||||
|
|
||||||
this->CreateNestedTree(&_build_industry_desc);
|
this->CreateNestedTree(&_build_industry_desc);
|
||||||
this->vscroll = this->GetScrollbar(DPIW_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_DPI_SCROLLBAR);
|
||||||
this->FinishInitNested(&_build_industry_desc, 0);
|
this->FinishInitNested(&_build_industry_desc, 0);
|
||||||
|
|
||||||
this->SetButtons();
|
this->SetButtons();
|
||||||
|
@ -290,7 +290,7 @@ public:
|
||||||
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)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case DPIW_MATRIX_WIDGET: {
|
case WID_DPI_MATRIX_WIDGET: {
|
||||||
Dimension d = GetStringBoundingBox(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES);
|
Dimension d = GetStringBoundingBox(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES);
|
||||||
for (byte i = 0; i < this->count; i++) {
|
for (byte i = 0; i < this->count; i++) {
|
||||||
if (this->index[i] == INVALID_INDUSTRYTYPE) continue;
|
if (this->index[i] == INVALID_INDUSTRYTYPE) continue;
|
||||||
|
@ -303,7 +303,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DPIW_INFOPANEL: {
|
case WID_DPI_INFOPANEL: {
|
||||||
/* Extra line for cost outside of editor + extra lines for 'extra' information for NewGRFs. */
|
/* Extra line for cost outside of editor + extra lines for 'extra' information for NewGRFs. */
|
||||||
int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0);
|
int height = 2 + (_game_mode == GM_EDITOR ? 0 : 1) + (_loaded_newgrf_features.has_newindustries ? 4 : 0);
|
||||||
Dimension d = {0, 0};
|
Dimension d = {0, 0};
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DPIW_FUND_WIDGET: {
|
case WID_DPI_FUND_WIDGET: {
|
||||||
Dimension d = GetStringBoundingBox(STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY);
|
Dimension d = GetStringBoundingBox(STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY);
|
||||||
d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_PROSPECT_NEW_INDUSTRY));
|
d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_PROSPECT_NEW_INDUSTRY));
|
||||||
d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY));
|
d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY));
|
||||||
|
@ -362,7 +362,7 @@ public:
|
||||||
virtual void SetStringParameters(int widget) const
|
virtual void SetStringParameters(int widget) const
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case DPIW_FUND_WIDGET:
|
case WID_DPI_FUND_WIDGET:
|
||||||
/* Raw industries might be prospected. Show this fact by changing the string
|
/* Raw industries might be prospected. Show this fact by changing the string
|
||||||
* In Editor, you just build, while ingame, or you fund or you prospect */
|
* In Editor, you just build, while ingame, or you fund or you prospect */
|
||||||
if (_game_mode == GM_EDITOR) {
|
if (_game_mode == GM_EDITOR) {
|
||||||
|
@ -379,7 +379,7 @@ public:
|
||||||
virtual void DrawWidget(const Rect &r, int widget) const
|
virtual void DrawWidget(const Rect &r, int widget) const
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case DPIW_MATRIX_WIDGET:
|
case WID_DPI_MATRIX_WIDGET:
|
||||||
for (byte i = 0; i < this->vscroll->GetCapacity() && i + this->vscroll->GetPosition() < this->count; i++) {
|
for (byte i = 0; i < this->vscroll->GetCapacity() && i + this->vscroll->GetPosition() < this->count; i++) {
|
||||||
int x = r.left + WD_MATRIX_LEFT;
|
int x = r.left + WD_MATRIX_LEFT;
|
||||||
int y = r.top + WD_MATRIX_TOP + i * this->resize.step_height;
|
int y = r.top + WD_MATRIX_TOP + i * this->resize.step_height;
|
||||||
|
@ -398,7 +398,7 @@ public:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DPIW_INFOPANEL: {
|
case WID_DPI_INFOPANEL: {
|
||||||
int y = r.top + WD_FRAMERECT_TOP;
|
int y = r.top + WD_FRAMERECT_TOP;
|
||||||
int bottom = r.bottom - WD_FRAMERECT_BOTTOM;
|
int bottom = r.bottom - WD_FRAMERECT_BOTTOM;
|
||||||
int left = r.left + WD_FRAMERECT_LEFT;
|
int left = r.left + WD_FRAMERECT_LEFT;
|
||||||
|
@ -473,8 +473,8 @@ public:
|
||||||
virtual void OnClick(Point pt, int widget, int click_count)
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case DPIW_MATRIX_WIDGET: {
|
case WID_DPI_MATRIX_WIDGET: {
|
||||||
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, DPIW_MATRIX_WIDGET);
|
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_DPI_MATRIX_WIDGET);
|
||||||
if (y < this->count) { // Is it within the boundaries of available data?
|
if (y < this->count) { // Is it within the boundaries of available data?
|
||||||
this->selected_index = y;
|
this->selected_index = y;
|
||||||
this->selected_type = this->index[y];
|
this->selected_type = this->index[y];
|
||||||
|
@ -492,18 +492,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetButtons();
|
this->SetButtons();
|
||||||
if (this->enabled[this->selected_index] && click_count > 1) this->OnClick(pt, DPIW_FUND_WIDGET, 1);
|
if (this->enabled[this->selected_index] && click_count > 1) this->OnClick(pt, WID_DPI_FUND_WIDGET, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case DPIW_DISPLAY_WIDGET:
|
case WID_DPI_DISPLAY_WIDGET:
|
||||||
if (this->selected_type != INVALID_INDUSTRYTYPE) ShowIndustryCargoesWindow(this->selected_type);
|
if (this->selected_type != INVALID_INDUSTRYTYPE) ShowIndustryCargoesWindow(this->selected_type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DPIW_FUND_WIDGET: {
|
case WID_DPI_FUND_WIDGET: {
|
||||||
if (this->selected_type == INVALID_INDUSTRYTYPE) {
|
if (this->selected_type == INVALID_INDUSTRYTYPE) {
|
||||||
this->HandleButtonClick(DPIW_FUND_WIDGET);
|
this->HandleButtonClick(WID_DPI_FUND_WIDGET);
|
||||||
|
|
||||||
if (Town::GetNumItems() == 0) {
|
if (Town::GetNumItems() == 0) {
|
||||||
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
|
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
|
||||||
|
@ -515,9 +515,9 @@ public:
|
||||||
}
|
}
|
||||||
} else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
|
} else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
|
||||||
DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
|
DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
|
||||||
this->HandleButtonClick(DPIW_FUND_WIDGET);
|
this->HandleButtonClick(WID_DPI_FUND_WIDGET);
|
||||||
} else {
|
} else {
|
||||||
HandlePlacePushButton(this, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT);
|
HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -527,8 +527,8 @@ public:
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
{
|
{
|
||||||
/* Adjust the number of items in the matrix depending of the resize */
|
/* Adjust the number of items in the matrix depending of the resize */
|
||||||
this->vscroll->SetCapacityFromWidget(this, DPIW_MATRIX_WIDGET);
|
this->vscroll->SetCapacityFromWidget(this, WID_DPI_MATRIX_WIDGET);
|
||||||
this->GetWidget<NWidgetCore>(DPIW_MATRIX_WIDGET)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
this->GetWidget<NWidgetCore>(WID_DPI_MATRIX_WIDGET)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
||||||
|
@ -652,7 +652,7 @@ class IndustryViewWindow : public Window
|
||||||
InfoLine clicked_line; ///< The line of the button that has been clicked
|
InfoLine clicked_line; ///< The line of the button that has been clicked
|
||||||
byte clicked_button; ///< The button that has been clicked (to raise)
|
byte clicked_button; ///< The button that has been clicked (to raise)
|
||||||
int production_offset_y; ///< The offset of the production texts/buttons
|
int production_offset_y; ///< The offset of the production texts/buttons
|
||||||
int info_height; ///< Height needed for the #IVW_INFO panel
|
int info_height; ///< Height needed for the #WID_IV_INFO panel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
||||||
|
@ -664,7 +664,7 @@ public:
|
||||||
this->info_height = WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + 1; // Info panel has at least two lines text.
|
this->info_height = WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + 1; // Info panel has at least two lines text.
|
||||||
|
|
||||||
this->InitNested(desc, window_number);
|
this->InitNested(desc, window_number);
|
||||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT);
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_IV_VIEWPORT);
|
||||||
nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ZOOM_LVL_INDUSTRY);
|
nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ZOOM_LVL_INDUSTRY);
|
||||||
|
|
||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
|
@ -676,7 +676,7 @@ public:
|
||||||
|
|
||||||
if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
|
if (this->IsShaded()) return; // Don't draw anything when the window is shaded.
|
||||||
|
|
||||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(IVW_INFO);
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_IV_INFO);
|
||||||
uint expected = this->DrawInfo(nwi->pos_x, nwi->pos_x + nwi->current_x - 1, nwi->pos_y) - nwi->pos_y;
|
uint expected = this->DrawInfo(nwi->pos_x, nwi->pos_x + nwi->current_x - 1, nwi->pos_y) - nwi->pos_y;
|
||||||
if (expected > nwi->current_y - 1) {
|
if (expected > nwi->current_y - 1) {
|
||||||
this->info_height = expected + 1;
|
this->info_height = expected + 1;
|
||||||
|
@ -686,7 +686,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the text in the #IVW_INFO panel.
|
* Draw the text in the #WID_IV_INFO panel.
|
||||||
* @param left Left edge of the panel.
|
* @param left Left edge of the panel.
|
||||||
* @param right Right edge of the panel.
|
* @param right Right edge of the panel.
|
||||||
* @param top Top edge of the panel.
|
* @param top Top edge of the panel.
|
||||||
|
@ -798,18 +798,18 @@ public:
|
||||||
|
|
||||||
virtual void SetStringParameters(int widget) const
|
virtual void SetStringParameters(int widget) const
|
||||||
{
|
{
|
||||||
if (widget == IVW_CAPTION) SetDParam(0, this->window_number);
|
if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 == IVW_INFO) size->height = this->info_height;
|
if (widget == WID_IV_INFO) size->height = this->info_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget, int click_count)
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case IVW_INFO: {
|
case WID_IV_INFO: {
|
||||||
Industry *i = Industry::Get(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
InfoLine line = IL_NONE;
|
InfoLine line = IL_NONE;
|
||||||
|
|
||||||
|
@ -893,7 +893,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IVW_GOTO: {
|
case WID_IV_GOTO: {
|
||||||
Industry *i = Industry::Get(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(i->location.GetCenterTile());
|
ShowExtraViewPortWindow(i->location.GetCenterTile());
|
||||||
|
@ -903,7 +903,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IVW_DISPLAY: {
|
case WID_IV_DISPLAY: {
|
||||||
Industry *i = Industry::Get(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
ShowIndustryCargoesWindow(i->type);
|
ShowIndustryCargoesWindow(i->type);
|
||||||
break;
|
break;
|
||||||
|
@ -921,7 +921,7 @@ public:
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
{
|
{
|
||||||
if (this->viewport != NULL) {
|
if (this->viewport != NULL) {
|
||||||
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(IVW_VIEWPORT);
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_IV_VIEWPORT);
|
||||||
nvp->UpdateViewportCoordinates(this);
|
nvp->UpdateViewportCoordinates(this);
|
||||||
|
|
||||||
ScrollWindowToTile(Industry::Get(this->window_number)->location.GetCenterTile(), this, true); // Re-center viewport.
|
ScrollWindowToTile(Industry::Get(this->window_number)->location.GetCenterTile(), this, true); // Re-center viewport.
|
||||||
|
@ -993,21 +993,21 @@ static void UpdateIndustryProduction(Industry *i)
|
||||||
static const NWidgetPart _nested_industry_view_widgets[] = {
|
static const NWidgetPart _nested_industry_view_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_CREAM),
|
NWidget(WWT_CLOSEBOX, COLOUR_CREAM),
|
||||||
NWidget(WWT_CAPTION, COLOUR_CREAM, IVW_CAPTION), SetDataTip(STR_INDUSTRY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_CREAM, WID_IV_CAPTION), SetDataTip(STR_INDUSTRY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
NWidget(WWT_DEBUGBOX, COLOUR_CREAM),
|
NWidget(WWT_DEBUGBOX, COLOUR_CREAM),
|
||||||
NWidget(WWT_SHADEBOX, COLOUR_CREAM),
|
NWidget(WWT_SHADEBOX, COLOUR_CREAM),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_CREAM),
|
NWidget(WWT_STICKYBOX, COLOUR_CREAM),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_CREAM),
|
NWidget(WWT_PANEL, COLOUR_CREAM),
|
||||||
NWidget(WWT_INSET, COLOUR_CREAM), SetPadding(2, 2, 2, 2),
|
NWidget(WWT_INSET, COLOUR_CREAM), SetPadding(2, 2, 2, 2),
|
||||||
NWidget(NWID_VIEWPORT, INVALID_COLOUR, IVW_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetPadding(1, 1, 1, 1), SetResize(1, 1),
|
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_IV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetPadding(1, 1, 1, 1), SetResize(1, 1),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_CREAM, IVW_INFO), SetMinimalSize(260, 2), SetResize(1, 0),
|
NWidget(WWT_PANEL, COLOUR_CREAM, WID_IV_INFO), SetMinimalSize(260, 2), SetResize(1, 0),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, IVW_GOTO), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_INDUSTRY_VIEW_LOCATION_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_GOTO), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_INDUSTRY_VIEW_LOCATION_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, IVW_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_CREAM, WID_IV_DISPLAY), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_INDUSTRY_DISPLAY_CHAIN, STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_CREAM),
|
NWidget(WWT_RESIZEBOX, COLOUR_CREAM),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
};
|
};
|
||||||
|
@ -1036,14 +1036,14 @@ static const NWidgetPart _nested_industry_directory_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_BROWN, IDW_DROPDOWN_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_ID_DROPDOWN_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
|
||||||
NWidget(WWT_DROPDOWN, COLOUR_BROWN, IDW_DROPDOWN_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
|
NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_ID_DROPDOWN_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
|
||||||
NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetResize(1, 0), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_PANEL, COLOUR_BROWN, IDW_INDUSTRY_LIST), SetDataTip(0x0, STR_INDUSTRY_DIRECTORY_LIST_CAPTION), SetResize(1, 1), SetScrollbar(IDW_SCROLLBAR), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_ID_INDUSTRY_LIST), SetDataTip(0x0, STR_INDUSTRY_DIRECTORY_LIST_CAPTION), SetResize(1, 1), SetScrollbar(WID_ID_SCROLLBAR), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, IDW_SCROLLBAR),
|
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_ID_SCROLLBAR),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@ -1086,7 +1086,7 @@ protected:
|
||||||
|
|
||||||
if (!this->industries.Sort()) return;
|
if (!this->industries.Sort()) return;
|
||||||
IndustryDirectoryWindow::last_industry = NULL; // Reset name sorter sort cache
|
IndustryDirectoryWindow::last_industry = NULL; // Reset name sorter sort cache
|
||||||
this->SetWidgetDirty(IDW_INDUSTRY_LIST); // Set the modified widget dirty
|
this->SetWidgetDirty(WID_ID_INDUSTRY_LIST); // Set the modified widget dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1212,7 +1212,7 @@ public:
|
||||||
IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window()
|
IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window()
|
||||||
{
|
{
|
||||||
this->CreateNestedTree(desc);
|
this->CreateNestedTree(desc);
|
||||||
this->vscroll = this->GetScrollbar(IDW_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_ID_SCROLLBAR);
|
||||||
|
|
||||||
this->industries.SetListing(this->last_sorting);
|
this->industries.SetListing(this->last_sorting);
|
||||||
this->industries.SetSortFuncs(IndustryDirectoryWindow::sorter_funcs);
|
this->industries.SetSortFuncs(IndustryDirectoryWindow::sorter_funcs);
|
||||||
|
@ -1229,17 +1229,17 @@ public:
|
||||||
|
|
||||||
virtual void SetStringParameters(int widget) const
|
virtual void SetStringParameters(int widget) const
|
||||||
{
|
{
|
||||||
if (widget == IDW_DROPDOWN_CRITERIA) SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]);
|
if (widget == WID_ID_DROPDOWN_CRITERIA) SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DrawWidget(const Rect &r, int widget) const
|
virtual void DrawWidget(const Rect &r, int widget) const
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case IDW_DROPDOWN_ORDER:
|
case WID_ID_DROPDOWN_ORDER:
|
||||||
this->DrawSortButtonState(widget, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
this->DrawSortButtonState(widget, this->industries.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDW_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int y = r.top + WD_FRAMERECT_TOP;
|
int y = r.top + WD_FRAMERECT_TOP;
|
||||||
if (this->industries.Length() == 0) {
|
if (this->industries.Length() == 0) {
|
||||||
|
@ -1260,7 +1260,7 @@ public:
|
||||||
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)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case IDW_DROPDOWN_ORDER: {
|
case WID_ID_DROPDOWN_ORDER: {
|
||||||
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
||||||
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
|
||||||
d.height += padding.height;
|
d.height += padding.height;
|
||||||
|
@ -1268,7 +1268,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDW_DROPDOWN_CRITERIA: {
|
case WID_ID_DROPDOWN_CRITERIA: {
|
||||||
Dimension d = {0, 0};
|
Dimension d = {0, 0};
|
||||||
for (uint i = 0; IndustryDirectoryWindow::sorter_names[i] != INVALID_STRING_ID; i++) {
|
for (uint i = 0; IndustryDirectoryWindow::sorter_names[i] != INVALID_STRING_ID; i++) {
|
||||||
d = maxdim(d, GetStringBoundingBox(IndustryDirectoryWindow::sorter_names[i]));
|
d = maxdim(d, GetStringBoundingBox(IndustryDirectoryWindow::sorter_names[i]));
|
||||||
|
@ -1279,7 +1279,7 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDW_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
|
Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
|
||||||
for (uint i = 0; i < this->industries.Length(); i++) {
|
for (uint i = 0; i < this->industries.Length(); i++) {
|
||||||
d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
|
d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i])));
|
||||||
|
@ -1298,17 +1298,17 @@ public:
|
||||||
virtual void OnClick(Point pt, int widget, int click_count)
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case IDW_DROPDOWN_ORDER:
|
case WID_ID_DROPDOWN_ORDER:
|
||||||
this->industries.ToggleSortOrder();
|
this->industries.ToggleSortOrder();
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDW_DROPDOWN_CRITERIA:
|
case WID_ID_DROPDOWN_CRITERIA:
|
||||||
ShowDropDownMenu(this, IndustryDirectoryWindow::sorter_names, this->industries.SortType(), IDW_DROPDOWN_CRITERIA, 0, 0);
|
ShowDropDownMenu(this, IndustryDirectoryWindow::sorter_names, this->industries.SortType(), WID_ID_DROPDOWN_CRITERIA, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDW_INDUSTRY_LIST: {
|
case WID_ID_INDUSTRY_LIST: {
|
||||||
uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, IDW_INDUSTRY_LIST, WD_FRAMERECT_TOP);
|
uint p = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_ID_INDUSTRY_LIST, WD_FRAMERECT_TOP);
|
||||||
if (p < this->industries.Length()) {
|
if (p < this->industries.Length()) {
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(this->industries[p]->location.tile);
|
ShowExtraViewPortWindow(this->industries[p]->location.tile);
|
||||||
|
@ -1331,7 +1331,7 @@ public:
|
||||||
|
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
{
|
{
|
||||||
this->vscroll->SetCapacityFromWidget(this, IDW_INDUSTRY_LIST);
|
this->vscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
|
@ -1400,21 +1400,21 @@ void ShowIndustryDirectory()
|
||||||
static const NWidgetPart _nested_industry_cargoes_widgets[] = {
|
static const NWidgetPart _nested_industry_cargoes_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||||
NWidget(WWT_CAPTION, COLOUR_BROWN, ICW_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_IC_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
||||||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(WWT_PANEL, COLOUR_BROWN, ICW_PANEL), SetResize(1, 10), SetMinimalSize(200, 90), SetScrollbar(ICW_SCROLLBAR), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_IC_PANEL), SetResize(1, 10), SetMinimalSize(200, 90), SetScrollbar(WID_IC_SCROLLBAR), EndContainer(),
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_BROWN, ICW_NOTIFY),
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_IC_NOTIFY),
|
||||||
SetDataTip(STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP, STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP),
|
SetDataTip(STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP, STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP),
|
||||||
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 0), SetResize(1, 0), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 0), SetResize(1, 0), EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(NWID_VERTICAL),
|
NWidget(NWID_VERTICAL),
|
||||||
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, ICW_SCROLLBAR),
|
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_IC_SCROLLBAR),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@ -2022,7 +2022,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
typedef SmallVector<CargoesRow, 4> Fields;
|
typedef SmallVector<CargoesRow, 4> Fields;
|
||||||
|
|
||||||
Fields fields; ///< Fields to display in the #ICW_PANEL.
|
Fields fields; ///< Fields to display in the #WID_IC_PANEL.
|
||||||
uint ind_cargo; ///< If less than #NUM_INDUSTRYTYPES, an industry type, else a cargo id + NUM_INDUSTRYTYPES.
|
uint ind_cargo; ///< If less than #NUM_INDUSTRYTYPES, an industry type, else a cargo id + NUM_INDUSTRYTYPES.
|
||||||
|
|
||||||
Scrollbar *vscroll;
|
Scrollbar *vscroll;
|
||||||
|
@ -2031,7 +2031,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
{
|
{
|
||||||
this->OnInit();
|
this->OnInit();
|
||||||
this->CreateNestedTree(&_industry_cargoes_desc);
|
this->CreateNestedTree(&_industry_cargoes_desc);
|
||||||
this->vscroll = this->GetScrollbar(ICW_SCROLLBAR);
|
this->vscroll = this->GetScrollbar(WID_IC_SCROLLBAR);
|
||||||
this->FinishInitNested(&_industry_cargoes_desc, 0);
|
this->FinishInitNested(&_industry_cargoes_desc, 0);
|
||||||
this->OnInvalidateData(id);
|
this->OnInvalidateData(id);
|
||||||
}
|
}
|
||||||
|
@ -2070,7 +2070,7 @@ struct IndustryCargoesWindow : public 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 != ICW_PANEL) return;
|
if (widget != WID_IC_PANEL) return;
|
||||||
|
|
||||||
size->width = WD_FRAMETEXT_LEFT + CargoesField::industry_width * 3 + CargoesField::CARGO_FIELD_WIDTH * 2 + WD_FRAMETEXT_RIGHT;
|
size->width = WD_FRAMETEXT_LEFT + CargoesField::industry_width * 3 + CargoesField::CARGO_FIELD_WIDTH * 2 + WD_FRAMETEXT_RIGHT;
|
||||||
}
|
}
|
||||||
|
@ -2079,7 +2079,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
CargoesFieldType type; ///< Type of field.
|
CargoesFieldType type; ///< Type of field.
|
||||||
virtual void SetStringParameters (int widget) const
|
virtual void SetStringParameters (int widget) const
|
||||||
{
|
{
|
||||||
if (widget != ICW_CAPTION) return;
|
if (widget != WID_IC_CAPTION) return;
|
||||||
|
|
||||||
if (this->ind_cargo < NUM_INDUSTRYTYPES) {
|
if (this->ind_cargo < NUM_INDUSTRYTYPES) {
|
||||||
const IndustrySpec *indsp = GetIndustrySpec(this->ind_cargo);
|
const IndustrySpec *indsp = GetIndustrySpec(this->ind_cargo);
|
||||||
|
@ -2235,7 +2235,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
*/
|
*/
|
||||||
void NotifySmallmap()
|
void NotifySmallmap()
|
||||||
{
|
{
|
||||||
if (!this->IsWidgetLowered(ICW_NOTIFY)) return;
|
if (!this->IsWidgetLowered(WID_IC_NOTIFY)) return;
|
||||||
|
|
||||||
/* Only notify the smallmap window if it exists. In particular, do not
|
/* Only notify the smallmap window if it exists. In particular, do not
|
||||||
* bring it to the front to prevent messing up any nice layout of the user. */
|
* bring it to the front to prevent messing up any nice layout of the user. */
|
||||||
|
@ -2248,7 +2248,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
*/
|
*/
|
||||||
void ComputeIndustryDisplay(IndustryType it)
|
void ComputeIndustryDisplay(IndustryType it)
|
||||||
{
|
{
|
||||||
this->GetWidget<NWidgetCore>(ICW_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION;
|
this->GetWidget<NWidgetCore>(WID_IC_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION;
|
||||||
this->ind_cargo = it;
|
this->ind_cargo = it;
|
||||||
_displayed_industries = 1ULL << it;
|
_displayed_industries = 1ULL << it;
|
||||||
|
|
||||||
|
@ -2314,7 +2314,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
this->ShortenCargoColumn(1, 1, num_indrows);
|
this->ShortenCargoColumn(1, 1, num_indrows);
|
||||||
this->ShortenCargoColumn(3, 1, num_indrows);
|
this->ShortenCargoColumn(3, 1, num_indrows);
|
||||||
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
|
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
||||||
this->vscroll->SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
|
this->vscroll->SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
this->NotifySmallmap();
|
this->NotifySmallmap();
|
||||||
|
@ -2326,7 +2326,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
*/
|
*/
|
||||||
void ComputeCargoDisplay(CargoID cid)
|
void ComputeCargoDisplay(CargoID cid)
|
||||||
{
|
{
|
||||||
this->GetWidget<NWidgetCore>(ICW_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_CARGO_CAPTION;
|
this->GetWidget<NWidgetCore>(WID_IC_CAPTION)->widget_data = STR_INDUSTRY_CARGOES_CARGO_CAPTION;
|
||||||
this->ind_cargo = cid + NUM_INDUSTRYTYPES;
|
this->ind_cargo = cid + NUM_INDUSTRYTYPES;
|
||||||
_displayed_industries = 0;
|
_displayed_industries = 0;
|
||||||
|
|
||||||
|
@ -2382,7 +2382,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
this->ShortenCargoColumn(1, 1, num_indrows);
|
this->ShortenCargoColumn(1, 1, num_indrows);
|
||||||
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
|
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
||||||
this->vscroll->SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
|
this->vscroll->SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
this->NotifySmallmap();
|
this->NotifySmallmap();
|
||||||
|
@ -2399,9 +2399,9 @@ struct IndustryCargoesWindow : public Window {
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
if (data == NUM_INDUSTRYTYPES) {
|
if (data == NUM_INDUSTRYTYPES) {
|
||||||
if (this->IsWidgetLowered(ICW_NOTIFY)) {
|
if (this->IsWidgetLowered(WID_IC_NOTIFY)) {
|
||||||
this->RaiseWidget(ICW_NOTIFY);
|
this->RaiseWidget(WID_IC_NOTIFY);
|
||||||
this->SetWidgetDirty(ICW_NOTIFY);
|
this->SetWidgetDirty(WID_IC_NOTIFY);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2412,7 +2412,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
virtual void DrawWidget(const Rect &r, int widget) const
|
virtual void DrawWidget(const Rect &r, int widget) const
|
||||||
{
|
{
|
||||||
if (widget != ICW_PANEL) return;
|
if (widget != WID_IC_PANEL) return;
|
||||||
|
|
||||||
DrawPixelInfo tmp_dpi, *old_dpi;
|
DrawPixelInfo tmp_dpi, *old_dpi;
|
||||||
int width = r.right - r.left + 1;
|
int width = r.right - r.left + 1;
|
||||||
|
@ -2425,7 +2425,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::CARGO_FIELD_WIDTH) / 2;
|
if (this->ind_cargo >= NUM_INDUSTRYTYPES) left_pos += (CargoesField::industry_width + CargoesField::CARGO_FIELD_WIDTH) / 2;
|
||||||
int last_column = (this->ind_cargo < NUM_INDUSTRYTYPES) ? 4 : 2;
|
int last_column = (this->ind_cargo < NUM_INDUSTRYTYPES) ? 4 : 2;
|
||||||
|
|
||||||
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
|
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
||||||
int vpos = -this->vscroll->GetPosition() * nwp->resize_y;
|
int vpos = -this->vscroll->GetPosition() * nwp->resize_y;
|
||||||
for (uint i = 0; i < this->fields.Length(); i++) {
|
for (uint i = 0; i < this->fields.Length(); i++) {
|
||||||
int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
|
int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height;
|
||||||
|
@ -2454,14 +2454,14 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate in which field was clicked, and within the field, at what position.
|
* Calculate in which field was clicked, and within the field, at what position.
|
||||||
* @param pt Clicked position in the #ICW_PANEL widget.
|
* @param pt Clicked position in the #WID_IC_PANEL widget.
|
||||||
* @param fieldxy If \c true is returned, field x/y coordinate of \a pt.
|
* @param fieldxy If \c true is returned, field x/y coordinate of \a pt.
|
||||||
* @param xy If \c true is returned, x/y coordinate with in the field.
|
* @param xy If \c true is returned, x/y coordinate with in the field.
|
||||||
* @return Clicked at a valid position.
|
* @return Clicked at a valid position.
|
||||||
*/
|
*/
|
||||||
bool CalculatePositionInWidget(Point pt, Point *fieldxy, Point *xy)
|
bool CalculatePositionInWidget(Point pt, Point *fieldxy, Point *xy)
|
||||||
{
|
{
|
||||||
const NWidgetBase *nw = this->GetWidget<NWidgetBase>(ICW_PANEL);
|
const NWidgetBase *nw = this->GetWidget<NWidgetBase>(WID_IC_PANEL);
|
||||||
pt.x -= nw->pos_x;
|
pt.x -= nw->pos_x;
|
||||||
pt.y -= nw->pos_y;
|
pt.y -= nw->pos_y;
|
||||||
|
|
||||||
|
@ -2501,7 +2501,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
virtual void OnClick(Point pt, int widget, int click_count)
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case ICW_PANEL: {
|
case WID_IC_PANEL: {
|
||||||
Point fieldxy, xy;
|
Point fieldxy, xy;
|
||||||
if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
|
if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
|
||||||
|
|
||||||
|
@ -2531,12 +2531,12 @@ struct IndustryCargoesWindow : public Window {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ICW_NOTIFY:
|
case WID_IC_NOTIFY:
|
||||||
this->ToggleWidgetLoweredState(ICW_NOTIFY);
|
this->ToggleWidgetLoweredState(WID_IC_NOTIFY);
|
||||||
this->SetWidgetDirty(ICW_NOTIFY);
|
this->SetWidgetDirty(WID_IC_NOTIFY);
|
||||||
SndPlayFx(SND_15_BEEP);
|
SndPlayFx(SND_15_BEEP);
|
||||||
|
|
||||||
if (this->IsWidgetLowered(ICW_NOTIFY)) {
|
if (this->IsWidgetLowered(WID_IC_NOTIFY)) {
|
||||||
if (FindWindowByClass(WC_SMALLMAP) == NULL) ShowSmallMap();
|
if (FindWindowByClass(WC_SMALLMAP) == NULL) ShowSmallMap();
|
||||||
this->NotifySmallmap();
|
this->NotifySmallmap();
|
||||||
}
|
}
|
||||||
|
@ -2546,7 +2546,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
virtual void OnHover(Point pt, int widget)
|
virtual void OnHover(Point pt, int widget)
|
||||||
{
|
{
|
||||||
if (widget != ICW_PANEL) return;
|
if (widget != WID_IC_PANEL) return;
|
||||||
|
|
||||||
Point fieldxy, xy;
|
Point fieldxy, xy;
|
||||||
if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
|
if (!CalculatePositionInWidget(pt, &fieldxy, &xy)) return;
|
||||||
|
@ -2585,7 +2585,7 @@ struct IndustryCargoesWindow : public Window {
|
||||||
|
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
{
|
{
|
||||||
this->vscroll->SetCapacityFromWidget(this, ICW_PANEL);
|
this->vscroll->SetCapacityFromWidget(this, WID_IC_PANEL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
/** Widgets of the WC_HIGHSCORE / WC_ENDSCREEN. */
|
/** Widgets of the WC_HIGHSCORE / WC_ENDSCREEN. */
|
||||||
enum HighscoreWidgets {
|
enum HighscoreWidgets {
|
||||||
HSW_BACKGROUND,
|
WID_H_BACKGROUND, ///< Background of the window.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WIDGETS_HIGHSCORE_WIDGET_H */
|
#endif /* WIDGETS_HIGHSCORE_WIDGET_H */
|
||||||
|
|
|
@ -14,37 +14,36 @@
|
||||||
|
|
||||||
/** Widgets of the WC_BUILD_INDUSTRY. */
|
/** Widgets of the WC_BUILD_INDUSTRY. */
|
||||||
enum DynamicPlaceIndustriesWidgets {
|
enum DynamicPlaceIndustriesWidgets {
|
||||||
DPIW_MATRIX_WIDGET,
|
WID_DPI_MATRIX_WIDGET, ///< Matrix of the industries.
|
||||||
DPIW_SCROLLBAR,
|
WID_DPI_SCROLLBAR, ///< Scrollbar of the matrix.
|
||||||
DPIW_INFOPANEL,
|
WID_DPI_INFOPANEL, ///< Info panel about the industry.
|
||||||
DPIW_DISPLAY_WIDGET,
|
WID_DPI_DISPLAY_WIDGET, ///< Display chain button.
|
||||||
DPIW_FUND_WIDGET,
|
WID_DPI_FUND_WIDGET, ///< Fund button.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the WC_INDUSTRY_VIEW. */
|
/** Widgets of the WC_INDUSTRY_VIEW. */
|
||||||
enum IndustryViewWidgets {
|
enum IndustryViewWidgets {
|
||||||
IVW_CAPTION,
|
WID_IV_CAPTION, ///< Caption of the window.
|
||||||
IVW_VIEWPORT,
|
WID_IV_VIEWPORT, ///< Viewport of the industry.
|
||||||
IVW_INFO,
|
WID_IV_INFO, ///< Info of the industry.
|
||||||
IVW_GOTO,
|
WID_IV_GOTO, ///< Goto button.
|
||||||
IVW_DISPLAY,
|
WID_IV_DISPLAY, ///< Display chain button.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the WC_INDUSTRY_DIRECTORY. */
|
/** Widgets of the WC_INDUSTRY_DIRECTORY. */
|
||||||
enum IndustryDirectoryWidgets {
|
enum IndustryDirectoryWidgets {
|
||||||
IDW_DROPDOWN_ORDER,
|
WID_ID_DROPDOWN_ORDER, ///< Dropdown for the order of the sort.
|
||||||
IDW_DROPDOWN_CRITERIA,
|
WID_ID_DROPDOWN_CRITERIA, ///< Dropdown for the criteria of the sort.
|
||||||
IDW_INDUSTRY_LIST,
|
WID_ID_INDUSTRY_LIST, ///< Industry list.
|
||||||
IDW_SCROLLBAR,
|
WID_ID_SCROLLBAR, ///< Scrollbar of the list.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the WC_INDUSTRY_CARGOES */
|
/** Widgets of the WC_INDUSTRY_CARGOES */
|
||||||
enum IndustryCargoesWidgets {
|
enum IndustryCargoesWidgets {
|
||||||
ICW_CAPTION,
|
WID_IC_CAPTION, ///< Caption of the window.
|
||||||
ICW_NOTIFY,
|
WID_IC_NOTIFY, ///< Row of buttons at the bottom.
|
||||||
ICW_PANEL,
|
WID_IC_PANEL, ///< Panel that shows the chain.
|
||||||
ICW_SCROLLBAR,
|
WID_IC_SCROLLBAR, ///< Scrollbar of the panel.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* WIDGETS_INDUSTRY_WIDGET_H */
|
#endif /* WIDGETS_INDUSTRY_WIDGET_H */
|
||||||
|
|
Loading…
Reference in New Issue