mirror of https://github.com/OpenTTD/OpenTTD
(svn r5714) Backport from branches/TGP (r5701 and r5711)
-Fix: < > boxes in patch-settings didn't grey out when they hit the limit of their range -Codechange: while at it, prettyfied DrawArrowButtons() a bit -Fix: < > boxes in industry production window (when cheat enabled) had a minor glitchrelease/0.5
parent
5bcaef5d86
commit
76ea272c9c
2
gui.h
2
gui.h
|
@ -17,7 +17,7 @@ void ShowGameOptions(void);
|
||||||
void ShowGameDifficulty(void);
|
void ShowGameDifficulty(void);
|
||||||
void ShowPatchesSelection(void);
|
void ShowPatchesSelection(void);
|
||||||
void ShowNewgrf(void);
|
void ShowNewgrf(void);
|
||||||
void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled);
|
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right);
|
||||||
|
|
||||||
/* graph_gui.c */
|
/* graph_gui.c */
|
||||||
void ShowOperatingProfitGraph(void);
|
void ShowOperatingProfitGraph(void);
|
||||||
|
|
|
@ -270,6 +270,14 @@ void ShowBuildIndustryWindow(void)
|
||||||
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
|
AllocateWindowDescFront(_industry_window_desc[_patches.build_rawmaterial_ind][_opt_ptr->landscape],0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool isProductionMinimum(const Industry *i, int pt) {
|
||||||
|
return i->production_rate[pt] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool isProductionMaximum(const Industry *i, int pt) {
|
||||||
|
return i->production_rate[pt] == 255;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool IsProductionAlterable(const Industry *i)
|
static inline bool IsProductionAlterable(const Industry *i)
|
||||||
{
|
{
|
||||||
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) &&
|
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) &&
|
||||||
|
@ -314,8 +322,10 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
|
||||||
SetDParam(2, i->pct_transported[0] * 100 >> 8);
|
SetDParam(2, i->pct_transported[0] * 100 >> 8);
|
||||||
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
|
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
|
||||||
// Let's put out those buttons..
|
// Let's put out those buttons..
|
||||||
if (IsProductionAlterable(i))
|
if (IsProductionAlterable(i)) {
|
||||||
DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, true);
|
DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0,
|
||||||
|
!isProductionMinimum(i, 0), !isProductionMaximum(i, 0));
|
||||||
|
}
|
||||||
|
|
||||||
if (i->produced_cargo[1] != CT_INVALID) {
|
if (i->produced_cargo[1] != CT_INVALID) {
|
||||||
SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]);
|
SetDParam(0, _cargoc.names_long[i->produced_cargo[1]]);
|
||||||
|
@ -323,8 +333,10 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
|
||||||
SetDParam(2, i->pct_transported[1] * 100 >> 8);
|
SetDParam(2, i->pct_transported[1] * 100 >> 8);
|
||||||
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
|
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
|
||||||
// Let's put out those buttons..
|
// Let's put out those buttons..
|
||||||
if (IsProductionAlterable(i))
|
if (IsProductionAlterable(i)) {
|
||||||
DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, true);
|
DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0,
|
||||||
|
!isProductionMinimum(i, 1), !isProductionMaximum(i, 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,8 +362,10 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e)
|
||||||
if (IS_INT_INSIDE(x, 5, 25) ) {
|
if (IS_INT_INSIDE(x, 5, 25) ) {
|
||||||
/* Clicked buttons, decrease or increase production */
|
/* Clicked buttons, decrease or increase production */
|
||||||
if (x < 15) {
|
if (x < 15) {
|
||||||
|
if (isProductionMinimum(i, line)) return;
|
||||||
i->production_rate[line] = maxu(i->production_rate[line] / 2, 1);
|
i->production_rate[line] = maxu(i->production_rate[line] / 2, 1);
|
||||||
} else {
|
} else {
|
||||||
|
if (isProductionMaximum(i, line)) return;
|
||||||
i->production_rate[line] = minu(i->production_rate[line] * 2, 255);
|
i->production_rate[line] = minu(i->production_rate[line] * 2, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1776,7 +1776,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
/* Draw [<][>] boxes for settings of an integer-type */
|
/* Draw [<][>] boxes for settings of an integer-type */
|
||||||
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true);
|
DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true);
|
||||||
|
|
||||||
switch (ce->str) {
|
switch (ce->str) {
|
||||||
/* Display date for change date cheat */
|
/* Display date for change date cheat */
|
||||||
|
|
|
@ -734,11 +734,11 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
|
||||||
} else {
|
} else {
|
||||||
int32 value;
|
int32 value;
|
||||||
|
|
||||||
/* Draw [<][>] boxes for settings of an integer-type */
|
|
||||||
DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), editable);
|
|
||||||
|
|
||||||
value = (int32)ReadValue(var, sd->save.conv);
|
value = (int32)ReadValue(var, sd->save.conv);
|
||||||
|
|
||||||
|
/* Draw [<][>] boxes for settings of an integer-type */
|
||||||
|
DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
|
||||||
|
|
||||||
disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
|
disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
|
SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
|
||||||
|
@ -1049,20 +1049,29 @@ void ShowNewgrf(void)
|
||||||
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
|
w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draw [<][>] boxes
|
/**
|
||||||
* state: 0 = none clicked, 1 = first clicked, 2 = second clicked */
|
* Draw [<][>] boxes.
|
||||||
void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled)
|
* @param x the x position to draw
|
||||||
|
* @param y the y position to draw
|
||||||
|
* @param ctab the color of the buttons
|
||||||
|
* @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
|
||||||
|
* @param clickable_left is the left button clickable?
|
||||||
|
* @param clickable_right is the right button clickable?
|
||||||
|
*/
|
||||||
|
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
|
||||||
{
|
{
|
||||||
DrawFrameRect(x, y+1, x + 9, y+9, ctab, (state == 1) ? FR_LOWERED : 0);
|
int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
|
||||||
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) {
|
DrawFrameRect(x, y + 1, x + 9, y + 9, ctab, (state == 1) ? FR_LOWERED : 0);
|
||||||
int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
|
DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : 0);
|
||||||
GfxFillRect(x+ 1, y+1, x+ 1+8, y+8, color);
|
DrawStringCentered(x + 5, y + 1, STR_6819, 0); // [<]
|
||||||
GfxFillRect(x+11, y+1, x+11+8, y+8, color);
|
DrawStringCentered(x + 15, y + 1, STR_681A, 0); // [>]
|
||||||
}
|
|
||||||
|
/* Grey out the buttons that aren't clickable */
|
||||||
|
if (!clickable_left)
|
||||||
|
GfxFillRect(x + 1, y + 1, x + 1 + 8, y + 8, color);
|
||||||
|
if (!clickable_right)
|
||||||
|
GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char _str_separator[2];
|
static char _str_separator[2];
|
||||||
|
@ -1076,7 +1085,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
// exchange rate
|
// exchange rate
|
||||||
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
|
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true, true);
|
||||||
SetDParam(0, 1);
|
SetDParam(0, 1);
|
||||||
SetDParam(1, 1);
|
SetDParam(1, 1);
|
||||||
DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
|
DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
|
||||||
|
@ -1109,7 +1118,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// switch to euro
|
// switch to euro
|
||||||
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
|
DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true, true);
|
||||||
SetDParam(0, _custom_currency.to_euro);
|
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);
|
DrawString(x, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
|
||||||
x = 35;
|
x = 35;
|
||||||
|
|
Loading…
Reference in New Issue