(svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.

pull/155/head
Darkvater 19 years ago
parent 6ab5bb6070
commit b4794ddc3b

@ -17,6 +17,7 @@ void ShowGameOptions(void);
void ShowGameDifficulty(void);
void ShowPatchesSelection(void);
void ShowNewgrf(void);
void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled);
/* graph_gui.c */
void ShowOperatingProfitGraph(void);

@ -22,7 +22,6 @@ extern const byte _build_industry_types[4][12];
extern const byte _industry_type_costs[37];
static void UpdateIndustryProduction(Industry *i);
extern void DrawArrowButtons(int x, int y, int state);
static void BuildIndustryWndProc(Window *w, WindowEvent *e)
{
@ -311,7 +310,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawString(4 + (NEED_ALTERB ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
if (NEED_ALTERB)
DrawArrowButtons(5, 127, (WP(w,vp2_d).data_2 == 1 ? WP(w,vp2_d).data_3 : 0));
DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, true);
if (i->produced_cargo[1] != CT_INVALID) {
SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]);
@ -320,7 +319,7 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
DrawString(4 + (NEED_ALTERB ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
if (NEED_ALTERB) {
DrawArrowButtons(5, 137, (WP(w,vp2_d).data_2 == 2 ? WP(w,vp2_d).data_3 : 0));
DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, true);
}
}
}

@ -1791,10 +1791,8 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
} else {
int32 val;
DrawFrameRect(x + 20, y + 1, x + 20 + 9, y + 9, 3, clk == i * 2 + 1 ? FR_LOWERED : 0);
DrawFrameRect(x + 30, y + 1, x + 30 + 9, y + 9, 3, clk == i * 2 + 2 ? FR_LOWERED : 0);
DrawStringCentered(x + 25, y + 1, STR_6819, 0);
DrawStringCentered(x + 35, y + 1, STR_681A, 0);
/* Draw [<][>] boxes for settings of an integer-type */
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true);
val = ReadCE(ce);

@ -865,15 +865,8 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
DrawFrameRect(x+5, y+1, x+15+9, y+9, (*(bool*)pe->variable) ? 7 : 9, (*(bool*)pe->variable) ? FR_LOWERED : 0);
SetDParam(0, *(bool*)pe->variable ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
} else {
DrawFrameRect(x+5, y+1, x+5+9, y+9, 3, clk == i*2+1 ? FR_LOWERED : 0);
DrawFrameRect(x+15, y+1, x+15+9, y+9, 3, clk == i*2+2 ? FR_LOWERED : 0);
if (!editable) {
int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
GfxFillRect(x+6, y+2, x+6+8, y+9, color);
GfxFillRect(x+16, y+2, x+16+8, y+9, color);
}
DrawStringCentered(x+10, y+1, STR_6819, 0);
DrawStringCentered(x+20, y+1, STR_681A, 0);
/* Draw [<][>] boxes for settings of an integer-type */
DrawArrowButtons(x, y, 3, clk - (i * 2), editable);
val = ReadPE(pe);
if (pe->type == PE_CURRENCY) val /= _currency->rate;
@ -1300,13 +1293,20 @@ void ShowNewgrf(void)
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
}
/* state: 0 = none clicked, 0x01 = first clicked, 0x02 = second clicked */
void DrawArrowButtons(int x, int y, int state)
/** Draw [<][>] boxes
* state: 0 = none clicked, 1 = first clicked, 2 = second clicked */
void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled)
{
DrawFrameRect(x, y+1, x+9, y+9, 3, (state & 0x01) ? FR_LOWERED : 0);
DrawFrameRect(x+10, y+1, x+19, y+9, 3, (state & 0x02) ? FR_LOWERED : 0);
DrawStringCentered(x+5, y+1, STR_6819, 0);
DrawStringCentered(x+15, y+1, STR_681A, 0);
DrawFrameRect(x, y+1, x + 9, y+9, ctab, (state == 1) ? FR_LOWERED : 0);
DrawFrameRect(x+10, y+1, x +19, y+9, ctab, (state == 2) ? FR_LOWERED : 0);
DrawStringCentered(x+ 5, y+1, STR_6819, 0); // [<]
DrawStringCentered(x+15, y+1, STR_681A, 0); // [>]
if (!enabled) {
int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
GfxFillRect(x+ 1, y+1, x+ 1+8, y+8, color);
GfxFillRect(x+11, y+1, x+11+8, y+8, color);
}
}
static char _str_separator[2];
@ -1320,7 +1320,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
DrawWindowWidgets(w);
// exchange rate
DrawArrowButtons(10, y, (clk >> (i*2)) & 0x03);
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
SetDParam(0, 1);
SetDParam(1, 1);
DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
@ -1353,7 +1353,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
i++;
// switch to euro
DrawArrowButtons(10, y, (clk >> (i*2)) & 0x03);
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
SetDParam(0, _custom_currency.to_euro);
DrawString(x, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
x = 35;

Loading…
Cancel
Save