mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-05 03:33:27 +01:00
add sound tools
This commit is contained in:
parent
3471b949cc
commit
8e8ac6c0be
@ -100,6 +100,9 @@ target_link_libraries(imgui_tools
|
||||
################## imgui_sound
|
||||
|
||||
add_library(imgui_sound
|
||||
./src/mm/services/sound_tools.hpp
|
||||
./src/mm/services/sound_tools.cpp
|
||||
|
||||
./src/mm/imgui/sound_info.hpp
|
||||
./src/mm/imgui/sound_pref.hpp
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
namespace MM {
|
||||
|
||||
void ImGuiSoundInfo(Engine& engine) {
|
||||
if (ImGui::Begin("Sound Info")) {
|
||||
void ImGuiSoundInfo(Engine& engine, bool* show) {
|
||||
if (ImGui::Begin("Sound Info", show)) {
|
||||
auto& sound = engine.getService<MM::Services::SoundService>();
|
||||
|
||||
ImGui::Text("SoLoud v%d", sound.engine.getVersion());
|
||||
|
@ -3,6 +3,6 @@
|
||||
namespace MM {
|
||||
class Engine; // fwd
|
||||
|
||||
void ImGuiSoundInfo(Engine& engine);
|
||||
void ImGuiSoundInfo(Engine& engine, bool* show = nullptr);
|
||||
} // MM
|
||||
|
||||
|
@ -7,9 +7,6 @@
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <mm/logger.hpp>
|
||||
#define LOGIGS(x) LOG("ImGuiSceneToolsService", x)
|
||||
|
||||
namespace MM::Services {
|
||||
|
||||
bool ImGuiEngineTools::enable(Engine& engine) {
|
||||
|
75
framework/imgui/src/mm/services/sound_tools.cpp
Normal file
75
framework/imgui/src/mm/services/sound_tools.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "./sound_tools.hpp"
|
||||
#include "mm/imgui/sound_info.hpp"
|
||||
|
||||
#include <mm/engine.hpp>
|
||||
#include <entt/core/hashed_string.hpp>
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include <mm/services/sound_service.hpp>
|
||||
|
||||
#include <mm/logger.hpp>
|
||||
#define LOGIGS(x) LOG("ImGuiSceneToolsService", x)
|
||||
|
||||
namespace MM::Services {
|
||||
|
||||
bool ImGuiSoundTools::enable(Engine& engine) {
|
||||
auto& menu_bar = engine.getService<MM::Services::ImGuiMenuBar>();
|
||||
|
||||
//menu_bar.menu_tree["Engine"]["Stop Engine"] = [](Engine& e) {
|
||||
//ImGui::Separator();
|
||||
//if (ImGui::MenuItem("Stop Engine")) {
|
||||
//e.stop();
|
||||
//}
|
||||
//};
|
||||
|
||||
menu_bar.menu_tree["Sound"]["GlobalVolume"] = [](Engine& e) {
|
||||
auto& sound_e = e.getService<MM::Services::SoundService>().engine;
|
||||
|
||||
auto gvolume = sound_e.getGlobalVolume();
|
||||
ImGui::SliderFloat("Global Volume", &gvolume, 0.f, 1.f);
|
||||
sound_e.setGlobalVolume(gvolume);
|
||||
};
|
||||
|
||||
menu_bar.menu_tree["Sound"]["Info"] = [this](Engine&) {
|
||||
ImGui::MenuItem("Info", NULL, &_show_info);
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGuiSoundTools::disable(Engine& engine) {
|
||||
auto& menu_bar = engine.getService<MM::Services::ImGuiMenuBar>();
|
||||
|
||||
menu_bar.menu_tree["Sound"].erase("GlobalVolume");
|
||||
menu_bar.menu_tree["Sound"].erase("Info");
|
||||
}
|
||||
|
||||
std::vector<UpdateStrategies::UpdateCreationInfo> ImGuiSoundTools::registerUpdates(void) {
|
||||
using namespace entt::literals;
|
||||
return {
|
||||
{
|
||||
"ImGuiSoundTools::render"_hs,
|
||||
"ImGuiSoundTools::render",
|
||||
[this](Engine& e){ renderImGui(e); },
|
||||
UpdateStrategies::update_phase_t::MAIN,
|
||||
true,
|
||||
{
|
||||
"ImGuiMenuBar::render"_hs
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void ImGuiSoundTools::renderImGui(Engine& engine) {
|
||||
if (_show_info) {
|
||||
MM::ImGuiSoundInfo(engine, &_show_info);
|
||||
}
|
||||
|
||||
//if (_show_services) {
|
||||
//renderServices(engine);
|
||||
//}
|
||||
}
|
||||
|
||||
} // namespace MM::Services
|
||||
|
24
framework/imgui/src/mm/services/sound_tools.hpp
Normal file
24
framework/imgui/src/mm/services/sound_tools.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "./imgui_menu_bar.hpp"
|
||||
|
||||
namespace MM::Services {
|
||||
|
||||
class ImGuiSoundTools : public Service {
|
||||
public:
|
||||
const char* name(void) override { return "ImGuiSoundTools"; }
|
||||
|
||||
bool enable(Engine& engine) override;
|
||||
void disable(Engine& engine) override;
|
||||
|
||||
std::vector<UpdateStrategies::UpdateCreationInfo> registerUpdates(void) override;
|
||||
|
||||
private:
|
||||
bool _show_info = false;
|
||||
|
||||
private:
|
||||
void renderImGui(Engine& engine);
|
||||
};
|
||||
|
||||
} // namespace MM::Services
|
||||
|
@ -67,7 +67,7 @@ target_link_libraries(imgui_sound_test
|
||||
imgui_service
|
||||
imgui_render_task
|
||||
imgui_sound
|
||||
#imgui_tools
|
||||
imgui_tools
|
||||
gtest_main
|
||||
)
|
||||
add_test(NAME imgui_sound_test COMMAND imgui_sound_test)
|
||||
|
@ -10,9 +10,13 @@
|
||||
#include <mm/services/sound_service.hpp>
|
||||
#include <mm/services/opengl_renderer.hpp>
|
||||
#include <mm/services/imgui_s.hpp>
|
||||
#include <mm/services/imgui_menu_bar.hpp>
|
||||
#include <mm/services/engine_tools.hpp>
|
||||
|
||||
#include <mm/opengl/render_tasks/imgui.hpp>
|
||||
|
||||
#include <mm/services/sound_tools.hpp>
|
||||
|
||||
#include <mm/imgui/sound_info.hpp>
|
||||
#include <mm/imgui/sound_pref.hpp>
|
||||
#include <mm/imgui/widgets/soloud.hpp>
|
||||
@ -61,9 +65,6 @@ class ImGuiSpeechy : public MM::Services::Service {
|
||||
"testwindow"_hs,
|
||||
"testwindow",
|
||||
[this](MM::Engine& engine) {
|
||||
MM::ImGuiSoundInfo(engine);
|
||||
MM::ImGuiSoundPref(engine);
|
||||
|
||||
renderImGui(engine);
|
||||
}
|
||||
}};
|
||||
@ -149,6 +150,15 @@ TEST(imgui_sound, basic) {
|
||||
engine.addService<MM::Services::ImGuiService>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiService>());
|
||||
|
||||
engine.addService<MM::Services::ImGuiMenuBar>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiMenuBar>());
|
||||
|
||||
engine.addService<MM::Services::ImGuiEngineTools>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiEngineTools>());
|
||||
|
||||
engine.addService<MM::Services::ImGuiSoundTools>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::ImGuiSoundTools>());
|
||||
|
||||
auto& rs = engine.addService<MM::Services::OpenGLRenderer>();
|
||||
ASSERT_TRUE(engine.enableService<MM::Services::OpenGLRenderer>());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user