New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for Game-Specific Menu Music #11241
Conversation
ccf67cf
to
fd2a69e
Compare
Sure I'll get to it within the next few days, all good suggestions, wasn't
aware of game.id I believe.
Let me know if you see anything else Joker
…On Sun, May 16, 2021, 8:31 AM SmallJoker ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/server.cpp
<#11241 (comment)>:
> + for (std::unordered_set<session_t>::const_iterator si =
+ psound.clients.begin();
+ si != psound.clients.end(); ++si) {
How about for (session_t peer_id : psound.clients) { ? That's a bit
shorter.
Same for the m_playing_sounds loop.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11241 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKT7N2WJH5DDDMUK4ZJ5ZNTTN63LZANCNFSM44B3NSWA>
.
|
Okay, good to go, much cleaner implementation, thanks for the examples. 👍 |
Directory structure:
Log output:
The sound file is not played back (using a renamed Also: Menu content uses consistent names. Wouldn't it be possible to name the file |
So a few things:
Edit: My mistake, minetest's id is different from it's directory name, this is why I made the change originally I believe from using game.id. But I will make it work so that theme.ogg is the name not <game_name>.ogg |
Not quite as "clean" of a local function as before, but now menu music can simply be called "theme.ogg" / "theme.1.ogg" as you suggested. I have also made it so that re-clicking the game button does not restart the theme from the beginning. Thanks for the push |
Okay, sound_stop_all is no more. Instead added a music_player.lua to the main_menu builtin, it provides a single function that manages the current music handle. When you provide a new file to play, the current is stopped and the new one is played on loop. If you try to play the same theme.ogg again (or main_menu.ogg) nothing occurs and play continues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the way that the files are loaded should be cleaned up a bit, also there are some style things.
builtin/mainmenu/music_player.lua
Outdated
@@ -0,0 +1,32 @@ | |||
--Minetest | |||
--Copyright (C) 2014 sapier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This copyright notice should be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To what, particularly? That was copied from the other main menu lua files. Should we instead leave that for a future PR cleaning up the copyrights for all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just update the author and the date.
Okay besides the potentially postponed copyright update and possibly more efficient directory search, the requested changes have been committed. P.S. thanks for the timely review 👍 |
builtin/mainmenu/music_player.lua
Outdated
@@ -0,0 +1,32 @@ | |||
--Minetest | |||
--Copyright (C) 2014 sapier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just update the author and the date.
Allows Menu music to be provided for indivudal games in games/gamename/menu/gamename.ogg Add sound_stop_all() lua_api function, no handles required Conflicts: src/gui/guiEngine.cpp
- Use pkgmgr.games[j].id correctly - clean-up gui/guiEngine.cpp to use local function - use C++ goodies to clean up src/server.cpp
38839b4
to
805e419
Compare
…or full paths for menu music
9b67399
to
98dd502
Compare
Alrighty, @ShadowNinja @SmallJoker ready for hopefully final review/approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than some tiny nits that could be fixed when merging.
When you open a dialog, the game theme still applies (header.png / background.png) but the music stops. I'd consider changing |
Sounds reasonable,
I'll have to take a look at of that would still work without breaking the
current main menu music system (which plays for the multiplayer tab for
example).
Or are you saying just remove the main menu music system we have and use
this instead for all tabs/dialogs?
…On Sun, Oct 31, 2021, 4:58 PM rubenwardy ***@***.***> wrote:
When you open a dialog, the game theme still applies (header.png /
background.png) but the music stops.
I'd consider changing textures.lua to game_theme.lua, and merging the
sound stuff into it - allowing both to be controlled at the same time
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11241 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKT7N2SMMXZCAYLCV6L5HBTUJWUXXANCNFSM44B3NSWA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
The game theming already shows on the local tab, but not the multiplayer tab. So you'd just play the global mainmenu music when leaving the local tab, when you hide the game theme |
a347450
to
341e85f
Compare
- rename the internal textures.lua table to mm_game_theme - move the music play code to game_theme to fix dialogs stopping music - Fix Errant \n removal - Fix guiEngine extraneous \n
341e85f
to
3e9e8c5
Compare
Tested on local machine(working) and updated with your suggested changes, feel free to merge if you are satisfied with it |
@ShadowNinja: does your approval on this still hold? |
Yep, looks good. |
Goal of the PR
Allow games to provide their own menu music theme
, via a file of the same name as the game name in /menu. For example, The game labyrinth would have a music file at "/games/labyrinth/menu/theme.ogg"Implementation
Old menu music could be provided via a "/sounds/main_menu.ogg" file (or "main_menu.#.ogg") by users if they desired.
That functionality still exists in this implementation, but now in the single-player tab, a game can provide it's own music to be played when the tab is open. If the game does not provide it's own music, no music is played.
To safely stop main menu music when switching to this tab or vice versa, I implemented a function that I thought has been missing from minetest for sometime, and was needed in this case:#### sound_stop_all()This function stops all currently playing sounds, without a user needing to provide a handleHow to test
Download an example game with a menu music file: Labyrinth on ContentDB and click on that game in the singleplayer tab. You will hear some music playing. To test the main menu music, feel free to copy that music file to minetest_folder/sounds/ and rename it to "main_menu.ogg". I recommend using a different sound file to see the differences of when music plays or doesn't.
Relevant Issues
#8596
Ready for Review.