summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-03-01 20:24:22 +0000
committerDarkvater <Darkvater@openttd.org>2006-03-01 20:24:22 +0000
commitb4794ddc3bcd397e7918ad160822526567948674 (patch)
tree4ea032f84cad520199f1d60a28f869c07cd88b21
parent6ab5bb607053d4368bc52f8657e328dc99ce71a0 (diff)
downloadopenttd-b4794ddc3bcd397e7918ad160822526567948674.tar.xz
(svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.
-rw-r--r--gui.h1
-rw-r--r--industry_gui.c5
-rw-r--r--misc_gui.c6
-rw-r--r--settings_gui.c34
4 files changed, 22 insertions, 24 deletions
diff --git a/gui.h b/gui.h
index 960b2741a..8b37b64a9 100644
--- a/gui.h
+++ b/gui.h
@@ -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);
diff --git a/industry_gui.c b/industry_gui.c
index 08c743f29..676cdd5f2 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -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);
}
}
}
diff --git a/misc_gui.c b/misc_gui.c
index c9d27e90b..0641f4d34 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -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);
diff --git a/settings_gui.c b/settings_gui.c
index 6c67a96e5..d3f7945b3 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -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;