Skip to main content
Topic: [solved]r2157 - Problem of "Minimum load" of schedule window (Read 4157 times) previous topic - next topic

[solved]r2157 - Problem of "Minimum load" of schedule window

simutrans r2157 GDI

With "Minimum load" of schedule window, when I press arrow or scroll mouse wheel, valuse of minimum load toggles only 0 and 100.
I can't select other value without inputting the value from keyboard.

Maybe, gui_numberinput_t::PROGRESS isn't working well as intended.

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #1
The problem was somewhere else, all minus numbers were converted to unsigned char ...

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #2
while you are at it: this line should fix the positioning of the number-input element in fahrplan_gui:


Code: [Select]
numimp_load.setze_groesse( koord( 60, BUTTON_HEIGHT ) );

(to be inserted in the constructor line 263.
Parsley, sage, rosemary, and maggikraut.

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #3
Also done before reading this ...

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #4
so we were simultaneously fixing the same bugs  :)
Parsley, sage, rosemary, and maggikraut.

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #5
another small patch for numberinput:

Code: [Select]
Index: gui_numberinput.cc
===================================================================
--- gui_numberinput.cc (revision 2159)
+++ gui_numberinput.cc (working copy)
@@ -151,8 +151,8 @@
  {
  sint64 diff = max_value-min_value;
  for( int i=0;  i<7;  i++  ) {
- if(  value<((diff*(sint64)percent[i])/100l)  ) {
- return clamp( (sint32)((diff*percent[i])/100l), min_value, max_value );
+ if(  value-min_value<((diff*(sint64)percent[i])/100l)  ) {
+ return clamp(min_value + (sint32)((diff*percent[i])/100l), min_value, max_value );
  }
  }
  return max_value;
@@ -192,8 +192,8 @@
  {
  sint64 diff = max_value-min_value;
  for( int i=6;  i>=0;  i--  ) {
- if(  value>((diff*percent[i])/100l)  ) {
- return clamp( (sint32)((diff*percent[i])/100l), min_value, max_value );
+ if(  value-min_value>((diff*percent[i])/100l)  ) {
+ return clamp( min_value+(sint32)((diff*percent[i])/100l), min_value, max_value );
  }
  }
  return min_value;

min_value was not recognized here, false behaviour would be visible for min_value !=0.
Parsley, sage, rosemary, and maggikraut.

 

Re: r2157 - Problem of "Minimum load" of schedule window

Reply #6
When we are working on that: clamp is useless here too ... Thanks!