14using namespace std::literals;
22 for (
const auto& [name, enabled] : channels) {
23 buf.appendf(
"showChannels.%s=%d\n", name.c_str(), enabled);
31 }
else if (name.starts_with(
"showChannels.")) {
38 if (!motherBoard)
return;
40 showChipSettings(*motherBoard);
46 for (
const auto& info : infos) {
47 const auto& name = info.device->getName();
48 auto [it, inserted] = channels.try_emplace(name,
false);
49 auto& enabled = it->second;
51 showChannelSettings(*motherBoard, name, &enabled);
59 return channel.mute->getBoolean() || !channel.record->getString().empty();
63void ImGuiSoundChip::showChipSettings(MSXMotherBoard& motherBoard)
65 auto restoreDefaultPopup = [](
const char* label, Setting&
setting) {
67 if (ImGui::Button(label)) {
69 ImGui::CloseCurrentPopup();
75 const auto& msxMixer = motherBoard.getMSXMixer();
76 auto& infos = msxMixer.getDeviceInfos();
77 im::Table(
"table", narrow<int>(infos.size()), ImGuiTableFlags_ScrollX, [&]{
78 for (auto& info : infos) {
79 if (ImGui::TableNextColumn()) {
80 const auto& device = *info.device;
81 ImGui::TextUnformatted(device.getName());
82 simpleToolTip(device.getDescription());
85 for (
auto& info : infos) {
86 if (ImGui::TableNextColumn()) {
87 auto& volumeSetting = *info.volumeSetting;
88 int volume = volumeSetting.getInt();
89 int min = volumeSetting.getMinValue();
90 int max = volumeSetting.getMaxValue();
92 std::string
id =
"##volume-" + info.device->getName();
93 if (ImGui::VSliderInt(
id.c_str(), ImVec2(18, 120), &volume, min, max)) {
94 volumeSetting.setInt(volume);
96 restoreDefaultPopup(
"Set default", volumeSetting);
99 for (
auto& info : infos) {
100 if (ImGui::TableNextColumn()) {
101 auto& balanceSetting = *info.balanceSetting;
102 int balance = balanceSetting.getInt();
103 int min = balanceSetting.getMinValue();
104 int max = balanceSetting.getMaxValue();
106 std::string
id =
"##balance-" + info.device->getName();
107 if (ImGui::SliderInt(
id.c_str(), &balance, min, max)) {
108 balanceSetting.setInt(balance);
110 restoreDefaultPopup(
"Set center", balanceSetting);
113 for (
auto& info : infos) {
114 if (ImGui::TableNextColumn()) {
115 bool special = anySpecialChannelSettings(info);
122 const auto& name = info.device->getName();
123 std::string
id =
"##channels-" + name;
124 auto [it, inserted] = channels.try_emplace(name,
false);
125 auto& enabled = it->second;
126 ImGui::Checkbox(
id.c_str(), &enabled);
133void ImGuiSoundChip::showChannelSettings(MSXMotherBoard& motherBoard,
const std::string& name,
bool* enabled)
135 const auto& msxMixer = motherBoard.getMSXMixer();
136 auto* info = msxMixer.findDeviceInfo(name);
139 std::string label = name +
" channel setting";
141 const auto& hotKey = manager.getReactor().getHotKey();
142 im::Table(
"table", 3, [&]{
143 im::ID_for_range(info->channelSettings.size(), [&](int i) {
144 auto& channel = info->channelSettings[i];
145 if (ImGui::TableNextColumn()) {
146 ImGui::StrCat(
"channel ", i);
148 if (ImGui::TableNextColumn()) {
149 Checkbox(hotKey,
"mute", *channel.mute);
151 if (ImGui::TableNextColumn()) {
152 InputText(
"record", *channel.record);
void paint(MSXMotherBoard *motherBoard) override
static constexpr auto persistentElements
void save(ImGuiTextBuffer &buf) override
void loadLine(std::string_view name, zstring_view value) override
bool showSoundChipSettings
const auto & getDeviceInfos() const
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
void TextUnformatted(const std::string &str)
bool stringToBool(string_view str)
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
void Table(const char *str_id, int column, ImGuiTableFlags flags, const ImVec2 &outer_size, float inner_width, std::invocable<> auto next)
void Window(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
void PopupContextItem(const char *str_id, ImGuiPopupFlags popup_flags, std::invocable<> auto next)
void StyleColor(bool active, Args &&...args)
This file implemented 3 utility functions:
bool loadOnePersistent(std::string_view name, zstring_view value, C &c, const std::tuple< Elements... > &tup)
void savePersistent(ImGuiTextBuffer &buf, C &c, const std::tuple< Elements... > &tup)
ImU32 getColor(imColor col)
constexpr bool any_of(InputRange &&range, UnaryPredicate pred)
dynarray< ChannelSettings > channelSettings