Latest Posts

Topic: Developer

Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-11-14, 20:24

Careful – SoundOptions is shared between both the main menu Options menu (src/ui_fsmenu/options.h) and the in-game GameOptionsSoundMenu. So any changes made there will appear in the main menu Options as well.

So in-game-specific sound functionality needs to be added to the GameOptionsSoundMenu, not the SoundOptions.

Resource usage in terms of panel count is not much of a concern, any non-trivial UI layout can easily consist of a lot of deeply nested boxes.


Top Quote
andersand.net
Avatar
Topic Opener
Joined: 2024-11-12, 19:48
Posts: 12
OS: Linux
Version: Latest main branch
Ranking
Pry about Widelands
Location: Norway
Posted at: 2024-11-14, 20:27

Nordfriese wrote:

Careful – SoundOptions is shared between both the main menu Options menu (src/ui_fsmenu/options.h) and the in-game GameOptionsSoundMenu. So any changes made there will appear in the main menu Options as well.

So in-game-specific sound functionality needs to be added to the GameOptionsSoundMenu, not the SoundOptions.

Resource usage in terms of panel count is not much of a concern, any non-trivial UI layout can easily consist of a lot of deeply nested boxes.

Good to know. I'll go for option 2 then face-smile.png


Top Quote
andersand.net
Avatar
Topic Opener
Joined: 2024-11-12, 19:48
Posts: 12
OS: Linux
Version: Latest main branch
Ranking
Pry about Widelands
Location: Norway
Posted at: 2024-11-15, 23:06

So, I've made a little progress, nothing visible yet, but the panels are there with some dummy controls for tracks in the playlist. I tried to reuse implementation practices from SoundOptions. This compiles and runs without errors, but the problem is now I don't understand why those dummy controls are not showing up in the sound options window below the sound options panel (which do show up)?

Here's the work in progress code:
https://github.com/andersand/widelands/commit/1c5a51bca2046d23262ea60b19c29ba5404a73a1

I haven't figured out how to debug the code without resorting to writing to the log yet. I assume it would be helpful to be able to set breakpoints to figure things out faster. Any advice how to do that could be helpful face-smile.png

PS. Note that I plan to revert -Werror in CMakeLists.txt before I make a PR. I just removed it temporarily to be able to compile stubbed code.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 2054
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2024-11-16, 08:02

At a quick glance it seems you did not add() the enable_ checkbox to the MusicTrackControl, so the box does not know to layout it and is effectively empty. Also you'll want to use the UI::Box::Resizing::kFullSize argument to add(). This should probably also make max_w and set_checkbox_width superfluous.

For debugging I recommend gdb:

gdb ./widelands

b filename.cc:123  # To set a breakpoint in a line
b SomeFunction     # To set a breakpoint in a function
run  # Start the program

...

# Breakpoint hit
p VAR # (or "print") Print value of variable VAR. This can also be used to evaluate an expression and invoke functions and *change* variables, e.g. "print g_verbose=true" or "print do_something()"
n     # (or "next") Step to the next line
step  # Step into the function at the next line
bt    # Backtrace of the current call stack
c     # (or "continue") Continue execution

d  # Delete breakpoints
q  # (or "quit") Quit GDB
Edited: 2024-11-16, 08:06

Top Quote
andersand.net
Avatar
Topic Opener
Joined: 2024-11-12, 19:48
Posts: 12
OS: Linux
Version: Latest main branch
Ranking
Pry about Widelands
Location: Norway
Posted at: 2024-11-16, 09:06

Great, debugging works like a charm face-smile.png

It makes sense to actually add the checkbox control yeah, unfortunately adding it was not enough to make it visible. I tried adding it with add(&enable_, UI::Box::Resizing::kFullSize, UI::Align::kRight); but also without any parameters and with UI::Box::Resizing::kAlign.
I also edited GameOptionsSoundMenu constructor so UI::Box::Resizing::kFullSize is passed to add() for both sound_options_ and music_player_.
It's as if the music player panel is empty or not rendered for some reason.

Edit: My mistake, I removed the code to add(control) when removing the max_w and checkbox_width. It works now, with the changes you proposed. Thanks!

Edited: 2024-11-16, 09:46

Top Quote
andersand.net
Avatar
Topic Opener
Joined: 2024-11-12, 19:48
Posts: 12
OS: Linux
Version: Latest main branch
Ranking
Pry about Widelands
Location: Norway
Posted at: 2024-11-22, 21:59

Here's a little progress update.

As you can see the user interface work is mostly done, though I plan to make some more nested panels to improve the playlist padding, and standard panel background for the buttons, stuff like that.
Currently the sound handler event stuff does not work with stop/resume music so I may end up just removing that button. I think that one won't be much use anyway since you can already just toggle music on/off next to the music volume.

In the supporting code (in struct Songset), next I plan to converge the existing vector<string> songs_ to the newly introduced map<string, Song> playlist_

Any feedback on this is welcomed.


Attachment:
image_2024-11-22_214713446.png

Top Quote