mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 22:11:43 +00:00
- use submenus for soundfont selection both for better overview and avoiding a music restart for each selection change.
This commit is contained in:
parent
918d188263
commit
36e8358763
8 changed files with 83 additions and 152 deletions
|
@ -1384,91 +1384,40 @@ static void InitCrosshairsList()
|
|||
static void InitMusicMenus()
|
||||
{
|
||||
DMenuDescriptor **advmenu = MenuDescriptors.CheckKey("AdvSoundOptions");
|
||||
DMenuDescriptor **gusmenu = MenuDescriptors.CheckKey("GusConfigMenu");
|
||||
DMenuDescriptor **timiditymenu = MenuDescriptors.CheckKey("TimidityExeMenu");
|
||||
DMenuDescriptor **wildmidimenu = MenuDescriptors.CheckKey("WildMidiConfigMenu");
|
||||
DMenuDescriptor **timiditycfgmenu = MenuDescriptors.CheckKey("TimidityConfigMenu");
|
||||
DMenuDescriptor **fluidmenu = MenuDescriptors.CheckKey("FluidPatchsetMenu");
|
||||
auto soundfonts = sfmanager.GetList();
|
||||
std::tuple<const char *, int, const char *> sfmenus[] = { std::make_tuple("GusConfigMenu", SF_SF2 | SF_GUS, "midi_config"),
|
||||
std::make_tuple("WildMidiConfigMenu", SF_GUS, "wildmidi_config"),
|
||||
std::make_tuple("TimidityConfigMenu", SF_SF2 | SF_GUS, "timidity_config"),
|
||||
std::make_tuple("FluidPatchsetMenu", SF_SF2, "fluid_patchset") };
|
||||
|
||||
const char *key, *value;
|
||||
if (GameConfig->SetSection("SoundFonts"))
|
||||
for (auto &p : sfmenus)
|
||||
{
|
||||
while (GameConfig->NextInSection(key, value))
|
||||
DMenuDescriptor **menu = MenuDescriptors.CheckKey(std::get<0>(p));
|
||||
|
||||
if (menu != nullptr)
|
||||
{
|
||||
if (FileExists(value))
|
||||
if (soundfonts.Size() > 0)
|
||||
{
|
||||
if (fluidmenu != nullptr)
|
||||
for (auto &entry : soundfonts)
|
||||
{
|
||||
auto it = CreateOptionMenuItemCommand(key, FStringf("fluid_patchset %s", NicePath(value).GetChars()), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*fluidmenu)->mItems.Push(it);
|
||||
if (entry.type & std::get<1>(p))
|
||||
{
|
||||
FString display = entry.mName;
|
||||
display.ReplaceChars("_", ' ');
|
||||
auto it = CreateOptionMenuItemCommand(display, FStringf("%s %s", std::get<2>(p), entry.mName), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*menu)->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (advmenu != nullptr)
|
||||
{
|
||||
// Remove the item for this submenu
|
||||
auto d = static_cast<DOptionMenuDescriptor*>(*advmenu);
|
||||
auto it = d->GetItem(std::get<0>(p));
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (advmenu != nullptr)
|
||||
{
|
||||
// Remove the item for this submenu
|
||||
auto d = static_cast<DOptionMenuDescriptor*>(*advmenu);
|
||||
auto it = d->GetItem("FluidPatchsetMenu");
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
}
|
||||
if (GameConfig->SetSection("PatchSets"))
|
||||
{
|
||||
while (GameConfig->NextInSection(key, value))
|
||||
{
|
||||
if (FileExists(value))
|
||||
{
|
||||
if (gusmenu != nullptr)
|
||||
{
|
||||
auto it = CreateOptionMenuItemCommand(key, FStringf("midi_config %s", NicePath(value).GetChars()), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*gusmenu)->mItems.Push(it);
|
||||
}
|
||||
if (wildmidimenu != nullptr)
|
||||
{
|
||||
auto it = CreateOptionMenuItemCommand(key, FStringf("wildmidi_config %s", NicePath(value).GetChars()), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*wildmidimenu)->mItems.Push(it);
|
||||
}
|
||||
if (timiditycfgmenu != nullptr)
|
||||
{
|
||||
auto it = CreateOptionMenuItemCommand(key, FStringf("timidity_config \"%s\"", NicePath(value).GetChars()), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*timiditycfgmenu)->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (advmenu != nullptr)
|
||||
{
|
||||
// Remove the item for this submenu
|
||||
auto d = static_cast<DOptionMenuDescriptor*>(*advmenu);
|
||||
auto it = d->GetItem("GusConfigMenu");
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
it = d->GetItem("WildMidiConfigMenu");
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
it = d->GetItem("TimidityConfigMenu");
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
}
|
||||
#ifdef _WIN32 // Different Timidity paths only make sense if they can be stored in arbitrary paths with local configs (i.e. not if things are done the Linux way)
|
||||
if (GameConfig->SetSection("TimidityExes"))
|
||||
{
|
||||
while (GameConfig->NextInSection(key, value))
|
||||
{
|
||||
if (FileExists(value))
|
||||
{
|
||||
if (timiditymenu != nullptr)
|
||||
{
|
||||
auto it = CreateOptionMenuItemCommand(key, FStringf("timidity_exe %s", NicePath(value).GetChars()), true);
|
||||
static_cast<DOptionMenuDescriptor*>(*timiditymenu)->mItems.Push(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto d = static_cast<DOptionMenuDescriptor*>(*advmenu);
|
||||
auto it = d->GetItem("TimidityExeMenu");
|
||||
if (it != nullptr) d->mItems.Delete(d->mItems.Find(it));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -1538,27 +1487,6 @@ void M_CreateMenus()
|
|||
{
|
||||
I_BuildALResamplersList(*opt);
|
||||
}
|
||||
opt = OptionValues.CheckKey(NAME_GUSConfig);
|
||||
if (opt != nullptr)
|
||||
{
|
||||
I_BuildSoundFontList(*opt, SF_GUS|SF_SF2);
|
||||
}
|
||||
opt = OptionValues.CheckKey(NAME_TimidityConfig);
|
||||
if (opt != nullptr)
|
||||
{
|
||||
I_BuildSoundFontList(*opt, SF_GUS | SF_SF2);
|
||||
}
|
||||
opt = OptionValues.CheckKey(NAME_WildmidiConfig);
|
||||
if (opt != nullptr)
|
||||
{
|
||||
I_BuildSoundFontList(*opt, SF_GUS);
|
||||
}
|
||||
opt = OptionValues.CheckKey(NAME_FluidConfig);
|
||||
if (opt != nullptr)
|
||||
{
|
||||
I_BuildSoundFontList(*opt, SF_SF2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -946,9 +946,3 @@ xx(snd_output)
|
|||
xx(snd_output_format)
|
||||
xx(snd_speakermode)
|
||||
xx(snd_resampler)
|
||||
|
||||
// soundfont options
|
||||
xx(GUSConfig)
|
||||
xx(FluidConfig)
|
||||
xx(TimidityConfig)
|
||||
xx(WildmidiConfig)
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "i_system.h"
|
||||
#include "gameconfigfile.h"
|
||||
#include "resourcefiles/resourcefile.h"
|
||||
#include "menu/menu.h"
|
||||
|
||||
FSoundFontManager sfmanager;
|
||||
|
||||
|
@ -469,25 +468,4 @@ void I_InitSoundFonts()
|
|||
sfmanager.CollectSoundfonts();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void I_BuildSoundFontList(FOptionValues *opt, int allowed)
|
||||
{
|
||||
auto &list = sfmanager.GetList();
|
||||
for (auto &entry : list)
|
||||
{
|
||||
if (entry.type & allowed)
|
||||
{
|
||||
FString display = entry.mName;
|
||||
display.ReplaceChars("_", ' ');
|
||||
FOptionValues::Pair pair;
|
||||
pair.Text = display;
|
||||
pair.TextValue = entry.mName;
|
||||
opt->mValues.Push(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,5 +150,3 @@ public:
|
|||
|
||||
|
||||
extern FSoundFontManager sfmanager;
|
||||
struct FOptionValues;
|
||||
void I_BuildSoundFontList(FOptionValues *opt, int allowed);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <atomic>
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
@ -5027,11 +5028,13 @@ int Player::compute_data(float *buffer, int32_t count)
|
|||
timidity_drum_power = ::timidity_drum_power;
|
||||
timidity_key_adjust = ::timidity_key_adjust;
|
||||
timidity_tempo_adjust = ::timidity_tempo_adjust;
|
||||
std::atomic_thread_fence(std::memory_order_acq_rel);
|
||||
effect->timidity_chorus = timidity_chorus;
|
||||
|
||||
if (::timidity_reverb != timidity_reverb)
|
||||
{
|
||||
timidity_reverb = ::timidity_reverb;
|
||||
std::atomic_thread_fence(std::memory_order_acq_rel);
|
||||
reverb->timidity_reverb = timidity_reverb;
|
||||
|
||||
// If the reverb mode has changed some buffers need to be reallocated before doing any sound generation.
|
||||
|
|
|
@ -2451,7 +2451,7 @@ OPTSTR_SPLINE = "Spline";
|
|||
OPTSTR_OPENAL = "OpenAL";
|
||||
|
||||
|
||||
|
||||
NOTSET = "Not set";
|
||||
SAFEMESSAGE = "Do you really want to do this?";
|
||||
MNU_COLORPICKER = "SELECT COLOR";
|
||||
|
||||
|
|
|
@ -1657,25 +1657,6 @@ OptionValue OplCores
|
|||
3, "$OPTVAL_NUKEDOPL3"
|
||||
}
|
||||
|
||||
OptionValue GUSConfig
|
||||
{
|
||||
// filled in by the sound code
|
||||
}
|
||||
|
||||
OptionValue WildMidiConfig
|
||||
{
|
||||
// filled in by the sound code
|
||||
}
|
||||
|
||||
OptionValue TimidityConfig
|
||||
{
|
||||
// filled in by the sound code
|
||||
}
|
||||
|
||||
OptionValue FluidConfig
|
||||
{
|
||||
// filled in by the sound code
|
||||
}
|
||||
|
||||
OptionMenu AdvSoundOptions protected
|
||||
{
|
||||
|
@ -1689,13 +1670,13 @@ OptionMenu AdvSoundOptions protected
|
|||
Option "$ADVSNDMNU_OPLCORES", "opl_core", "OplCores"
|
||||
StaticText " "
|
||||
StaticText "$ADVSNDMNU_GUSEMULATION", 1
|
||||
Option "$ADVSNDMNU_GUSCONFIG", "midi_config", GUSConfig
|
||||
LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "midi_config", "GusConfigMenu"
|
||||
Slider "$ADVSNDMNU_MIDIVOICES", "midi_voices", 16, 256, 4, 0
|
||||
Option "$ADVSNDMNU_DMXGUS", "midi_dmxgus", "OnOff"
|
||||
Option "$ADVSNDMNU_GUSMEMSIZE", "gus_memsize", "GusMemory"
|
||||
StaticText " "
|
||||
StaticText "$ADVSNDMNU_FLUIDSYNTH", 1
|
||||
Option "$ADVSNDMNU_FLUIDPATCHSET", "fluid_patchset", FluidConfig
|
||||
LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "fluid_patchset", "FluidPatchsetMenu"
|
||||
Slider "$ADVSNDMNU_FLUIDGAIN", "fluid_gain", 0, 10, 0.5, 1
|
||||
Option "$ADVSNDMNU_REVERB", "fluid_reverb", "OnOff"
|
||||
Option "$ADVSNDMNU_CHORUS", "fluid_chorus", "OnOff"
|
||||
|
@ -1703,15 +1684,36 @@ OptionMenu AdvSoundOptions protected
|
|||
// Leaving out the more advanced stuff for now.
|
||||
StaticText " "
|
||||
StaticText "$ADVSNDMNU_TIMIDITY", 1
|
||||
Option "$ADVSNDMNU_TIMIDITYCONFIG", "timidity_config", TimidityConfig
|
||||
Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff"
|
||||
|
||||
LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "timidity_config", "TimidityConfigMenu"
|
||||
// This one needs reworking
|
||||
//Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff"
|
||||
Option "$ADVSNDMNU_CHORUS", "timidity_chorus", "OnOff"
|
||||
StaticText " "
|
||||
StaticText "$ADVSNDMNU_WILDMIDI", 1
|
||||
Option "$ADVSNDMNU_WILDMIDICONFIG", "wildmidi_config", WildmidiConfig
|
||||
LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "wildmidi_config", "WildMidiConfigMenu"
|
||||
Option "$ADVSNDMNU_REVERB", "wildmidi_reverb", "OnOff"
|
||||
}
|
||||
|
||||
OptionMenu GusConfigMenu protected
|
||||
{
|
||||
Title "$ADVSNDMNU_SELCONFIG"
|
||||
}
|
||||
|
||||
OptionMenu WildMidiConfigMenu protected
|
||||
{
|
||||
Title "$ADVSNDMNU_SELCONFIG"
|
||||
}
|
||||
|
||||
OptionMenu TimidityConfigMenu protected
|
||||
{
|
||||
Title "$ADVSNDMNU_SELCONFIG"
|
||||
}
|
||||
|
||||
OptionMenu FluidPatchsetMenu protected
|
||||
{
|
||||
Title "$ADVSNDMNU_SELCONFIG"
|
||||
}
|
||||
|
||||
/*=======================================
|
||||
*
|
||||
|
|
|
@ -118,6 +118,34 @@ class OptionMenuItemSubmenu : OptionMenuItem
|
|||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// opens a submenu, command is a submenu name
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class OptionMenuItemLabeledSubmenu : OptionMenuItemSubmenu
|
||||
{
|
||||
CVar mLabelCVar;
|
||||
OptionMenuItemSubmenu Init(String label, CVar labelcvar, Name command, int param = 0)
|
||||
{
|
||||
Super.init(label, command, false);
|
||||
mLabelCVar = labelcvar;
|
||||
return self;
|
||||
}
|
||||
|
||||
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
|
||||
{
|
||||
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
|
||||
|
||||
String text = mLabelCVar.GetString();
|
||||
if (text.Length() == 0) text = Stringtable.Localize("$notset");
|
||||
screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true);
|
||||
|
||||
return indent;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Executes a CCMD, command is a CCMD name
|
||||
|
|
Loading…
Reference in a new issue