mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r16488) -Codechange [FS#2941]: Use widget numbers of base grap window and cargo payment window in the window handling code (erikjanp)
This commit is contained in:
parent
292647b212
commit
743f12fad0
|
@ -153,6 +153,14 @@ static void ShowGraphLegend()
|
||||||
/* BASE OF GRAPHS */
|
/* BASE OF GRAPHS */
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
|
/** Widget numbers of a base graph window. */
|
||||||
|
enum CompanyValueWidgets {
|
||||||
|
BGW_CLOSEBOX,
|
||||||
|
BGW_CAPTION,
|
||||||
|
BGW_KEY_BUTTON,
|
||||||
|
BGW_BACKGROUND,
|
||||||
|
};
|
||||||
|
|
||||||
struct BaseGraphWindow : Window {
|
struct BaseGraphWindow : Window {
|
||||||
protected:
|
protected:
|
||||||
enum {
|
enum {
|
||||||
|
@ -449,18 +457,10 @@ public:
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
{
|
{
|
||||||
/* Clicked on legend? */
|
/* Clicked on legend? */
|
||||||
if (widget == 2) ShowGraphLegend();
|
if (widget == BGW_KEY_BUTTON) ShowGraphLegend();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widget numbers of a base graph window. */
|
|
||||||
enum CompanyValueWidgets {
|
|
||||||
BGW_CLOSEBOX,
|
|
||||||
BGW_CAPTION,
|
|
||||||
BGW_KEY_BUTTON,
|
|
||||||
BGW_BACKGROUND,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/********************/
|
/********************/
|
||||||
/* OPERATING PROFIT */
|
/* OPERATING PROFIT */
|
||||||
|
@ -716,6 +716,14 @@ void ShowCompanyValueGraph()
|
||||||
/* PAYMENT RATES */
|
/* PAYMENT RATES */
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
|
/** Widget numbers of the cargo payment rates. */
|
||||||
|
enum CargoPaymentRatesWidgets {
|
||||||
|
CPW_CLOSEBOX,
|
||||||
|
CPW_CAPTION,
|
||||||
|
CPW_BACKGROUND,
|
||||||
|
CPW_CARGO_FIRST,
|
||||||
|
};
|
||||||
|
|
||||||
struct PaymentRatesGraphWindow : BaseGraphWindow {
|
struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||||
PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
|
PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
|
||||||
BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
|
BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
|
||||||
|
@ -735,7 +743,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||||
|
|
||||||
/* Set the properties of each widget */
|
/* Set the properties of each widget */
|
||||||
for (uint i = 0; i != num_active; i++) {
|
for (uint i = 0; i != num_active; i++) {
|
||||||
Widget *wi = &this->widget[3 + i];
|
Widget *wi = &this->widget[CPW_CARGO_FIRST + i];
|
||||||
wi->type = WWT_PANEL;
|
wi->type = WWT_PANEL;
|
||||||
wi->display_flags = RESIZE_NONE;
|
wi->display_flags = RESIZE_NONE;
|
||||||
wi->colour = COLOUR_ORANGE;
|
wi->colour = COLOUR_ORANGE;
|
||||||
|
@ -746,7 +754,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||||
wi->data = 0;
|
wi->data = 0;
|
||||||
wi->tooltips = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO;
|
wi->tooltips = STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO;
|
||||||
|
|
||||||
if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + 3);
|
if (!HasBit(_legend_excluded_cargo, i)) this->LowerWidget(i + CPW_CARGO_FIRST);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
@ -778,12 +786,12 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||||
/* Only draw labels for widgets that exist. If the widget doesn't
|
/* Only draw labels for widgets that exist. If the widget doesn't
|
||||||
* exist then the local company has used the climate cheat or
|
* exist then the local company has used the climate cheat or
|
||||||
* changed the NewGRF configuration with this window open. */
|
* changed the NewGRF configuration with this window open. */
|
||||||
if (i + 3 < this->widget_count) {
|
if (i + CPW_CARGO_FIRST < this->widget_count) {
|
||||||
/* Since the buttons have no text, no images,
|
/* Since the buttons have no text, no images,
|
||||||
* both the text and the coloured box have to be manually painted.
|
* both the text and the coloured box have to be manually painted.
|
||||||
* clk_dif will move one pixel down and one pixel to the right
|
* clk_dif will move one pixel down and one pixel to the right
|
||||||
* when the button is clicked */
|
* when the button is clicked */
|
||||||
byte clk_dif = this->IsWidgetLowered(i + 3) ? 1 : 0;
|
byte clk_dif = this->IsWidgetLowered(i + CPW_CARGO_FIRST) ? 1 : 0;
|
||||||
|
|
||||||
GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
|
GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
|
||||||
GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
|
GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
|
||||||
|
@ -809,21 +817,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget)
|
virtual void OnClick(Point pt, int widget)
|
||||||
{
|
{
|
||||||
if (widget >= 3) {
|
if (widget >= CPW_CARGO_FIRST) {
|
||||||
ToggleBit(_legend_excluded_cargo, widget - 3);
|
ToggleBit(_legend_excluded_cargo, widget - CPW_CARGO_FIRST);
|
||||||
this->ToggleWidgetLoweredState(widget);
|
this->ToggleWidgetLoweredState(widget);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widget numbers of the cargo payment rates. */
|
|
||||||
enum CargoPaymentRatesWidgets {
|
|
||||||
CPW_CLOSEBOX,
|
|
||||||
CPW_CAPTION,
|
|
||||||
CPW_BACKGROUND,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Widget _cargo_payment_rates_widgets[] = {
|
static const Widget _cargo_payment_rates_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 567, 0, 13, STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 567, 0, 13, STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
|
||||||
|
|
Loading…
Reference in New Issue