summaryrefslogtreecommitdiff
path: root/industry_gui.c
diff options
context:
space:
mode:
authormiham <miham@openttd.org>2006-08-02 18:36:53 +0000
committermiham <miham@openttd.org>2006-08-02 18:36:53 +0000
commit76ea272c9c77f50a8e7bddcdb0990636ad88a3ca (patch)
tree5808ffc33c21cc65ee80f87219493ff2890ea615 /industry_gui.c
parent5bcaef5d8640598a5d3252f961bcd16e60bf0efb (diff)
downloadopenttd-76ea272c9c77f50a8e7bddcdb0990636ad88a3ca.tar.xz
(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 glitch
Diffstat (limited to 'industry_gui.c')
-rw-r--r--industry_gui.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/industry_gui.c b/industry_gui.c
index 5810009cc..cec302b55 100644
--- a/industry_gui.c
+++ b/industry_gui.c
@@ -270,6 +270,14 @@ void ShowBuildIndustryWindow(void)
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)
{
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);
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
- if (IsProductionAlterable(i))
- DrawArrowButtons(5, 127, 3, (WP(w,vp2_d).data_2 == 1) ? WP(w,vp2_d).data_3 : 0, true);
+ if (IsProductionAlterable(i)) {
+ 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) {
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);
DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0);
// Let's put out those buttons..
- if (IsProductionAlterable(i))
- DrawArrowButtons(5, 137, 3, (WP(w,vp2_d).data_2 == 2) ? WP(w,vp2_d).data_3 : 0, true);
+ if (IsProductionAlterable(i)) {
+ 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) ) {
/* Clicked buttons, decrease or increase production */
if (x < 15) {
+ if (isProductionMinimum(i, line)) return;
i->production_rate[line] = maxu(i->production_rate[line] / 2, 1);
} else {
+ if (isProductionMaximum(i, line)) return;
i->production_rate[line] = minu(i->production_rate[line] * 2, 255);
}