Skip to content

Conversation

@Totto16
Copy link
Collaborator

@Totto16 Totto16 commented Jan 21, 2024

This adds a Settings Menu and a rudimentary Slider to control the volume
It also adds some more keyboard shortcuts, notably:

  • "+" / "-" for general volume control
  • "P" for opening the settings while playing

This also fixes some uncaught logic bugs in the music manager with the fading in and out logic

Some screenshots:
image
image

- also exit the whole application if pressing esc in the min menu
- use that slider in the settings menu for the volume
- add left and rightCrossPlatformActions
- disable the volume changing via +/- in the settings menu (by exiting, if a scene handled an event, and not continuing)
- use that, to detect if the settings menu is open on top of the ingame menu, than render it differently
@Totto16 Totto16 force-pushed the volume-control branch 2 times, most recently from 2940f33 to 0a6dba8 Compare January 21, 2024 01:28
@Totto16 Totto16 added the enhancement New feature or request label Jan 21, 2024
…e might have changed

- set volume in music manager constructor, so that it silences the volume of SDL_Mix (not only internally) , when it starts with the silent flag
- this fixes a bug, where "E" was caught twice, opening the settings and holding a piece
…support per scene "bound" keys

- use another key for opening the settings (P)
@github-actions
Copy link

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format reports: 1 file(s) not formatted
  • src/capabilities.hpp
clang-tidy reports: 11 concern(s)
  • src/application.cpp

    src/application.cpp:69:11: warning: [readability-else-after-return]

    do not use 'else' after 'return'

            } else if (event.key.keysym.sym == SDLK_MINUS or event.key.keysym.sym == SDLK_KP_MINUS) {
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • src/music_manager.hpp

    src/music_manager.hpp:18:25: warning: [cppcoreguidelines-avoid-non-const-global-variables]

    variable 'step_width' is non-const and globally accessible, consider making it const

        static inline float step_width = 0.05F;
                            ^
    /home/runner/work/oopetris/oopetris/src/music_manager.hpp:18:38: warning: 0.05F is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
        static inline float step_width = 0.05F;
                                         ^

    src/music_manager.hpp:44:21: warning: [readability-avoid-const-params-in-decls]

    parameter 'new_volume' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

        void set_volume(const tl::optional<float> new_volume, const bool force_update = false);
                        ^~~~~~

    src/music_manager.hpp:44:59: warning: [readability-avoid-const-params-in-decls]

    parameter 'force_update' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

        void set_volume(const tl::optional<float> new_volume, const bool force_update = false);
                                                              ^~~~~~

    src/music_manager.hpp:46:39: warning: [readability-avoid-const-params-in-decls]

    parameter 'steps' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

        tl::optional<float> change_volume(const std::int8_t steps);
                                          ^~~~~~
  • src/scenes/scene.cpp

    src/scenes/scene.cpp:8:26: warning: [readability-identifier-length]

    parameter name 'id' is too short, expected at least 3 characters

        Scene::Scene(SceneId id, ServiceProvider* service_provider) : m_id{ id }, m_service_provider{ service_provider } { }
                             ^
  • src/scenes/scene.hpp

    src/scenes/scene.hpp:45:32: warning: [readability-identifier-length]

    parameter name 'id' is too short, expected at least 3 characters

            explicit Scene(SceneId id, ServiceProvider* service_provider);
                                   ^
  • src/ui/slider.hpp

    src/ui/slider.hpp:47:17: warning: [modernize-pass-by-value]

    pass by value and use std::move

                    const Range& range,
                    ^~~~~~~~~~~~
                    Range 

    src/ui/slider.hpp:48:17: warning: [modernize-pass-by-value]

    pass by value and use std::move

                    const Getter& getter,
                    ^~~~~~~~~~~~~
                    Getter 

    src/ui/slider.hpp:49:17: warning: [modernize-pass-by-value]

    pass by value and use std::move

                    const Setter& setter,
                    ^~~~~~~~~~~~~
                    Setter 
  • src/utils.hpp

    /home/runner/work/oopetris/src/utils.hpp:89:9: warning: [cppcoreguidelines-macro-usage]

    function-like macro 'UNUSED' used; consider a 'constexpr' template function

    #define UNUSED(x) (void(x))
            ^

Have any feedback or feature suggestions? Share it here.

@Totto16 Totto16 merged commit 5510610 into main Feb 1, 2024
@Totto16 Totto16 deleted the volume-control branch February 1, 2024 21:50
@Totto16 Totto16 mentioned this pull request Feb 5, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants