The International Simutrans Forum


Author Topic: Automatic GUI patch from Standard  (Read 450 times)

0 Members and 1 Guest are viewing this topic.

Offline Phystam

  • Devotee
  • *
  • Posts: 433
  • Pak256.Ex developer
    • Pak256 wiki page
  • Languages: JP, EN, EO
Automatic GUI patch from Standard
« on: January 14, 2020, 06:57:51 AM »
Now we can see a lot of GUI improvement projects like Ves and Ranran are doing using "obsolete" workflow in Standard. I know that that is a very difficult project since the Extended GUI code is greatly changed so far from Standard one. But it is also worthwhile to do it since future workflow would become easier than the present one, and it also solves the length difference problem among languages that Ranran is facing.
This change is based on Standard code, so I think that maybe this work should be done by A.Carlotti, right? If this change does affect only the GUI code, another coder could do that too.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 19824
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic GUI patch from Standard
« Reply #1 on: January 14, 2020, 10:09:30 AM »
In principle, this is a worthwhile thing to do; but it depends on coder time availability. A. Carlotti has not been very active recently, I note; and it is of course up to him what, if anything, that he works on in what order. My own priorities are bug fixing and balance critical features.

Offline Ves

  • Devotee
  • *
  • Posts: 1796
  • Languages: EN, SV, DK
Re: Automatic GUI patch from Standard
« Reply #2 on: January 22, 2020, 04:55:22 PM »
Does anyone know more precisely *what* actually changed in Standard? Has the very fundamentics of the GUI been redone, things like gui_button_t, gui_combobox_t etc, or can those elements be reused, and just defined in another way?

Would it be possible to port the basics over to extended with the old and new existing together, so we can update the windows when we go along?

Offline Freahk

  • Devotee
  • *
  • Posts: 1073
  • Languages: DE, EN
Re: Automatic GUI patch from Standard
« Reply #3 on: January 22, 2020, 05:40:23 PM »
Here is the commit that incorporated the new GUI to standard.

As expected this seems like A LOT has been changed there.
Furthermore, from the Makefile it seems some GUI components were added whilst many remained, thus a coexistence of both is quite unlikely.
I did not have a look at changes of the components themselves however and won't do such kind of investigation before the second half auf February.

Offline Ves

  • Devotee
  • *
  • Posts: 1796
  • Languages: EN, SV, DK
Re: Automatic GUI patch from Standard
« Reply #4 on: January 22, 2020, 06:57:39 PM »
Whop, that was a massive commit, thanks for linking! How would anyone even start this task!?

Btw, it is interresting to see how some of the new GUI is done. It seems (from a very far away glance) a bit simpler than the existing GUI, would you think so as well? I have not played Standard in ages, so Im not sure what difference it makes in the game.

What advantages does the new GUI give against the old one? Except scaling and tuch screen friendly?

Offline Freahk

  • Devotee
  • *
  • Posts: 1073
  • Languages: DE, EN
Re: Automatic GUI patch from Standard
« Reply #5 on: January 22, 2020, 08:01:49 PM »
Except scaling and tuch screen friendly?
It's scaling and touch screen friendly :D
Many windows were reorganised using multiple tabs to better work with small displays and reduce the kind of annoying window spamming.
E.g. there is no convoy detail window, it's just another tab of the convoy window.

Some GUIs became even worse due to nonsense scaling imho but most of them ae fine.
Windows that do some strange nonsense scaling imho are the display setting and the network window. Maybe there are some more.

I can't say much about it from a technical perspective.
There seem to be some new components and I have read the UI is slightly easyer to code because one does not have to take care about the scaling.
« Last Edit: January 22, 2020, 08:24:46 PM by Freahk »

Offline Ves

  • Devotee
  • *
  • Posts: 1796
  • Languages: EN, SV, DK
Re: Automatic GUI patch from Standard
« Reply #6 on: January 22, 2020, 10:18:42 PM »
It's scaling and touch screen friendly
Haha, well ok  :P

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10001
  • Languages: De,EN,JP
Re: Automatic GUI patch from Standard
« Reply #7 on: January 23, 2020, 05:38:47 AM »
It is easier to program, more like a spread sheet. For example the new sound setting window.

Code: [Select]
  : gui_frame_t( translator::translate("Sound settings") ),

sound_mute_button.init( button_t::square_state, "mute sound");
sound_mute_button.pressed = sound_get_mute();
sound_mute_button.add_listener( this );

// Sound volume label
new_component<gui_label_t>( "Sound volume:" );

sound_volume_scrollbar.set_knob( L_KNOB_SIZE, 255 + L_KNOB_SIZE );
sound_volume_scrollbar.set_knob_offset( sound_get_global_volume() );
sound_volume_scrollbar.set_scroll_discrete( false );
sound_volume_scrollbar.add_listener( this );
add_component( &sound_volume_scrollbar );

new_component<gui_label_t>( "Sound range:" );

sound_range.set_value( env_t::sound_distance_scaling);
sound_range.set_limits( 1, 32 );
// sound_range.set_tooltip( "Lower values mean more local sounds" )

for( int i = 0; i < MAX_SOUND_TYPES; i++ ) {
new_component<gui_label_t>( specific_volume_names[i] );

specific_volume_scrollbar[ i ] = new scrollbar_t( scrollbar_t::horizontal );
specific_volume_scrollbar[i]->set_knob( L_KNOB_SIZE, 255 + L_KNOB_SIZE );
specific_volume_scrollbar[i]->set_knob_offset( sound_get_specific_volume((sound_type_t)i) );
specific_volume_scrollbar[i]->set_scroll_discrete( false );
specific_volume_scrollbar[i]->add_listener( this );
add_component( specific_volume_scrollbar[i] );


// Music
music_mute_button.init( button_t::square_state, "disable midi");
music_mute_button.pressed = midi_get_mute();
music_mute_button.add_listener( this );

new_component<gui_label_t>( "Music volume:" );

music_volume_scrollbar.set_knob( L_KNOB_SIZE, 255 + L_KNOB_SIZE );
music_volume_scrollbar.set_knob_offset( sound_get_midi_volume() );
music_volume_scrollbar.set_scroll_discrete( false );
music_volume_scrollbar.add_listener( this );
add_component( &music_volume_scrollbar );

// song selection
new_component<gui_label_t>( "Currently playing:" );

add_table( 3, 1 );
previous_song_button.set_typ( button_t::arrowleft );
previous_song_button.add_listener( this );
add_component( &previous_song_button );

next_song_button.set_typ( button_t::arrowright );
next_song_button.add_listener( this );
add_component( &next_song_button );

add_component( &song_name_label );

shuffle_song_button.init( button_t::square_state, "shuffle midis" );
shuffle_song_button.pressed = sound_get_shuffle_midi();


The components are the same as the old one, just the positioning is different.

For instance set_table_layout(1,0) make a dialog with a single row. But then I later need two rows, so I write add_table(2,0) .... end_table(); No fiddeling with offsets - it will work with almost any button and font size, and with an string length.

Still, even standard has one old dialog, the line window. This is actually four sub-windows, and probably should change into the selection area and three tabs. (Not done yet). But conversion is fairly straight forwards, as soon as one stops to force things. (Ok, there is an empty element to have some space reservation without showing something.)

There were also some follow-on patches, i.e. the conversion of the display settings, or that the tabs are going to the border of the windows. Still, you can still use the old windows too. Just will be looking weird sometimes.