mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-19 19:26:36 +02:00
add sound tools
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user