The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: z9999 on December 07, 2008, 04:43:40 pm

Title: [solved]r2157 - Problem of "Minimum load" of schedule window
Post by: z9999 on December 07, 2008, 04:43:40 pm
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.
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: prissi on December 07, 2008, 07:44:18 pm
The problem was somewhere else, all minus numbers were converted to unsigned char ...
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: Dwachs on December 07, 2008, 07:55:15 pm
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.
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: prissi on December 08, 2008, 12:04:49 am
Also done before reading this ...
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: Dwachs on December 08, 2008, 10:37:45 am
so we were simultaneously fixing the same bugs  :)
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: Dwachs on December 08, 2008, 04:35:36 pm
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.
Title: Re: r2157 - Problem of "Minimum load" of schedule window
Post by: prissi on December 08, 2008, 08:21:35 pm
When we are working on that: clamp is useless here too ... Thanks!