summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/interface/audio.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-06-25 03:56:09 +1000
committer Vas Crabb <vas@vastheman.com>2025-06-25 03:56:09 +1000
commitaf10f3f21cc03a6dcbfde08850f640e26d9cbb9f (patch)
tree05895657ff111b3f0ad10640f6ad0cb253cdfadb /src/osd/interface/audio.cpp
parent72251989ad8df6f6a1f401c56a1b02ec60938e25 (diff)
Various fixes:
ui: The new menus were unusable with a touchscreen, and not conducive to localisation. It's still not possible to add sound routes with a touchscreen, but at least it's possible to configure routes that exist. emu/sound.cpp: Fixed localisation issues, less temporary objects. emu/audio_effects: Fixed some localisation issues. plugins/autofire, plugins/inputmacro: Allow deleting autofire buttons or input macros without needing to use the UI Clear input. ui/selmenu.cpp, ui/imgcntrl.cpp: Use terse messages for bad media. Making these messages longer hasn't reduced support burden. Adding the version will just perpetuate the myth that you need to redownload all your ROMs for every release. ui/ui.cpp: Allow info screens to be dismissed by mouse clicks or touches. ui/sliders.cpp: Hiding the menu should preserve state. This is a design choice. sound: Avoid anything that could possibly depend on static initialisation order across transaltion units. Allow speaker position names to be localised. sound/none.cpp: Don't pretend it can create output streams.
Diffstat (limited to 'src/osd/interface/audio.cpp')
-rw-r--r--src/osd/interface/audio.cpp66
1 files changed, 42 insertions, 24 deletions
diff --git a/src/osd/interface/audio.cpp b/src/osd/interface/audio.cpp
index 2f04f949642..a9663b04fe5 100644
--- a/src/osd/interface/audio.cpp
+++ b/src/osd/interface/audio.cpp
@@ -1,33 +1,51 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
-#include "emu.h"
#include "audio.h"
-bool osd::channel_position::is_lfe() const { return *this == LFE; }
-bool osd::channel_position::is_onreq() const { return *this == ONREQ; }
-bool osd::channel_position::is_unknown() const { return *this == UNKNOWN; }
-
-const osd::detail::position_name_mapping osd::detail::position_name_mappings[] = {
- { channel_position::FC, "Front center" },
- { channel_position::FL, "Front left" },
- { channel_position::FR, "Front right" },
- { channel_position::RC, "Rear center" },
- { channel_position::RL, "Rear left" },
- { channel_position::RR, "Rear right" },
- { channel_position::HC, "Headrest center" },
- { channel_position::HL, "Headrest left" },
- { channel_position::HR, "Headrest right" },
- { channel_position::BACKREST, "Backrest" },
- { channel_position::LFE, "Subwoofer" },
- { channel_position::ONREQ, "Auxiliary" },
- { channel_position::UNKNOWN, "Unknown" }
+#include "util/language.h"
+#include "util/strformat.h"
+
+#include <algorithm>
+#include <iterator>
+
+
+namespace osd {
+
+namespace {
+
+struct position_name_mapping {
+ channel_position m_pos;
+ const char *m_name;
};
-std::string osd::channel_position::name() const
+const position_name_mapping f_position_name_mappings[] = {
+ { channel_position::FC(), N_p("audio-position", "Front center") },
+ { channel_position::FL(), N_p("audio-position", "Front left") },
+ { channel_position::FR(), N_p("audio-position", "Front right") },
+ { channel_position::RC(), N_p("audio-position", "Rear center") },
+ { channel_position::RL(), N_p("audio-position", "Rear left") },
+ { channel_position::RR(), N_p("audio-position", "Rear right") },
+ { channel_position::HC(), N_p("audio-position", "Headrest center") },
+ { channel_position::HL(), N_p("audio-position", "Headrest left") },
+ { channel_position::HR(), N_p("audio-position", "Headrest right") },
+ { channel_position::BACKREST(), N_p("audio-position", "Backrest") },
+ { channel_position::LFE(), N_p("audio-position", "Subwoofer") },
+ { channel_position::ONREQ(), N_p("audio-position", "Auxiliary") },
+ { channel_position::UNKNOWN(), N_p("audio-position", "Unknown") } };
+
+} // anonymous namespace
+
+std::string channel_position::name() const
{
- for(unsigned int i = 0; i != sizeof(detail::position_name_mappings) / sizeof(detail::position_name_mappings[0]); i++)
- if(*this == detail::position_name_mappings[i].m_pos)
- return detail::position_name_mappings[i].m_name;
- return util::string_format("[%f %f %f]", m_x, m_y, m_z);
+ auto const found = std::find_if(
+ std::begin(f_position_name_mappings),
+ std::end(f_position_name_mappings),
+ [this] (const position_name_mapping &val) { return *this == val.m_pos; });
+ if (std::end(f_position_name_mappings) != found)
+ return _("audio-position", found->m_name);
+ else
+ return util::string_format(_("audio-position", "[%1$f %2$f %3$f]"), m_x, m_y, m_z);
}
+
+} // anonymous namespace