From 78bcaf65c24d7f1c1ac15b193ecb1393003b67cc Mon Sep 17 00:00:00 2001 From: Zangetsu38 Date: Thu, 24 Oct 2024 00:55:32 +0200 Subject: [PATCH] gui/(bgm player & themes): Add support of BGM. - Some small improvement and comment added. config & gui/settings dialog: Add control of bgm volume. - Change start screen delay min to 30 sec and max to 5 min. codec: Set default value to 0 for send of atrac 9. --- vita3k/codec/include/codec/state.h | 2 +- vita3k/config/include/config/config.h | 3 +- vita3k/gui/CMakeLists.txt | 5 +- vita3k/gui/include/gui/functions.h | 5 + vita3k/gui/src/bgm_player.cpp | 321 ++++++++++++++++++++++++++ vita3k/gui/src/gui.cpp | 1 + vita3k/gui/src/home_screen.cpp | 4 + vita3k/gui/src/settings.cpp | 18 +- vita3k/gui/src/settings_dialog.cpp | 5 +- vita3k/gui/src/themes.cpp | 15 ++ vita3k/interface.cpp | 2 + vita3k/main.cpp | 3 + 12 files changed, 375 insertions(+), 9 deletions(-) create mode 100644 vita3k/gui/src/bgm_player.cpp diff --git a/vita3k/codec/include/codec/state.h b/vita3k/codec/include/codec/state.h index 57333a0740..ade108dcc9 100644 --- a/vita3k/codec/include/codec/state.h +++ b/vita3k/codec/include/codec/state.h @@ -164,7 +164,7 @@ struct Atrac9DecoderState : public DecoderState { uint32_t get(DecoderQuery query) override; uint32_t get_es_size() override; - bool send(const uint8_t *data, uint32_t size) override; + bool send(const uint8_t *data, uint32_t size = 0) override; bool receive(uint8_t *data, DecoderSize *size) override; void flush() override; diff --git a/vita3k/config/include/config/config.h b/vita3k/config/include/config/config.h index 4b74d07c78..9d7f86f10a 100644 --- a/vita3k/config/include/config/config.h +++ b/vita3k/config/include/config/config.h @@ -89,6 +89,7 @@ enum ScreenshotFormat { code(std::string, "audio-backend", "SDL", audio_backend) \ code(int, "audio-volume", 100, audio_volume) \ code(bool, "ngs-enable", true, ngs_enable) \ + code(int, "bgm-volume", 100, bgm_volume) \ code(int, "sys-button", static_cast(SCE_SYSTEM_PARAM_ENTER_BUTTON_CROSS), sys_button) \ code(int, "sys-lang", static_cast(SCE_SYSTEM_PARAM_LANG_ENGLISH_US), sys_lang) \ code(int, "sys-date-format", (int)SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY, sys_date_format) \ @@ -96,7 +97,7 @@ enum ScreenshotFormat { code(int, "cpu-pool-size", 10, cpu_pool_size) \ code(int, "modules-mode", static_cast(ModulesMode::AUTOMATIC), modules_mode) \ code(int, "delay-background", 4, delay_background) \ - code(int, "delay-start", 10, delay_start) \ + code(int, "delay-start", 30, delay_start) \ code(float, "background-alpha", .300f, background_alpha) \ code(int, "log-level", static_cast(spdlog::level::trace), log_level) \ code(std::string, "cpu-backend", "Dynarmic", cpu_backend) \ diff --git a/vita3k/gui/CMakeLists.txt b/vita3k/gui/CMakeLists.txt index f9553f1b1c..b01482176d 100644 --- a/vita3k/gui/CMakeLists.txt +++ b/vita3k/gui/CMakeLists.txt @@ -9,6 +9,7 @@ add_library( include/gui/state.h src/app_context_menu.cpp src/archive_install_dialog.cpp + src/bgm_player src/common_dialog.cpp src/compile_shaders.cpp src/condvars_dialog.cpp @@ -50,6 +51,6 @@ add_library( ) target_include_directories(gui PUBLIC include ${CMAKE_SOURCE_DIR}/vita3k) -target_link_libraries(gui PUBLIC app compat config dialog emuenv ime imgui lang regmgr np) -target_link_libraries(gui PRIVATE audio cppcommon ctrl kernel miniz psvpfsparser pugixml::pugixml stb renderer packages sdl2 touch vkutil host::dialog concurrentqueue) +target_link_libraries(gui PUBLIC app codec compat config dialog emuenv ime imgui lang regmgr np) +target_link_libraries(gui PRIVATE audio cubeb cppcommon ctrl kernel miniz psvpfsparser pugixml::pugixml stb renderer packages sdl2 touch vkutil host::dialog concurrentqueue) target_link_libraries(gui PUBLIC tracy) diff --git a/vita3k/gui/include/gui/functions.h b/vita3k/gui/include/gui/functions.h index 33a28ae45d..4c2dd832d9 100644 --- a/vita3k/gui/include/gui/functions.h +++ b/vita3k/gui/include/gui/functions.h @@ -70,6 +70,8 @@ void init(GuiState &gui, EmuEnvState &emuenv); void init_app_background(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); void init_app_icon(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); void init_apps_icon(GuiState &gui, EmuEnvState &emuenv, const std::vector &app_list); +bool init_bgm(EmuEnvState &emuenv, const std::pair path_bgm); +void init_bgm_player(const float vol); void init_config(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); void init_content_manager(GuiState &gui, EmuEnvState &emuenv); vfs::FileBuffer init_default_icon(GuiState &gui, EmuEnvState &emuenv); @@ -103,8 +105,11 @@ void reset_controller_binding(EmuEnvState &emuenv); void save_apps_cache(GuiState &gui, EmuEnvState &emuenv); void save_user(GuiState &gui, EmuEnvState &emuenv, const std::string &user_id); void select_app(GuiState &gui, const std::string &title_id); +void set_bgm_volume(const float vol); void set_config(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); void set_shaders_compiled_display(GuiState &gui, EmuEnvState &emuenv); +void stop_bgm(); +void switch_bgm_state(const bool pause); void update_app(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); void update_last_time_app_used(GuiState &gui, EmuEnvState &emuenv, const std::string &app); void update_live_area_current_open_apps_list(GuiState &gui, EmuEnvState &emuenv, const std::string &app_path); diff --git a/vita3k/gui/src/bgm_player.cpp b/vita3k/gui/src/bgm_player.cpp new file mode 100644 index 0000000000..4f50c21666 --- /dev/null +++ b/vita3k/gui/src/bgm_player.cpp @@ -0,0 +1,321 @@ +// Vita3K emulator project +// Copyright (C) 2024 Vita3K team +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#include "private.h" + +#include