From fd54abd90069705df99a6541f579ecb181ed6fe3 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Fri, 14 Dec 2018 04:09:51 +0100 Subject: [PATCH] add dialog for audio settings, flesh it out not functional yet tho --- CMakeLists.txt | 1 + melonDS.cbp | 2 + src/libui_sdl/DlgAudioSettings.cpp | 142 +++++++++++++++++++++++++++++ src/libui_sdl/DlgAudioSettings.h | 29 ++++++ src/libui_sdl/main.cpp | 22 +++-- 5 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 src/libui_sdl/DlgAudioSettings.cpp create mode 100644 src/libui_sdl/DlgAudioSettings.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 718287aa..4a6dc6c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ PROJECT(${PROJECT_WX}) SET(SOURCES src/libui_sdl/main.cpp src/libui_sdl/Platform.cpp + src/libui_sdl/DlgAudioSettings.cpp src/libui_sdl/DlgEmuSettings.cpp src/libui_sdl/DlgInputConfig.cpp src/ARM.cpp diff --git a/melonDS.cbp b/melonDS.cbp index 8831c704..38291874 100644 --- a/melonDS.cbp +++ b/melonDS.cbp @@ -144,6 +144,8 @@ + + diff --git a/src/libui_sdl/DlgAudioSettings.cpp b/src/libui_sdl/DlgAudioSettings.cpp new file mode 100644 index 00000000..cb161888 --- /dev/null +++ b/src/libui_sdl/DlgAudioSettings.cpp @@ -0,0 +1,142 @@ +/* + Copyright 2016-2019 StapleButter + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#include +#include + +#include "libui/ui.h" + +#include "../types.h" +#include "../Config.h" + +#include "DlgAudioSettings.h" + + +namespace DlgAudioSettings +{ + +bool opened; +uiWindow* win; + +// + + +int OnCloseWindow(uiWindow* window, void* blarg) +{ + opened = false; + return 1; +} + +void OnCancel(uiButton* btn, void* blarg) +{ + uiControlDestroy(uiControl(win)); + opened = false; +} + +void OnOk(uiButton* btn, void* blarg) +{ + /*Config::DirectBoot = uiCheckboxChecked(cbDirectBoot); + Config::Threaded3D = uiCheckboxChecked(cbThreaded3D); + Config::SocketBindAnyAddr = uiCheckboxChecked(cbBindAnyAddr);*/ + + Config::Save(); + + uiControlDestroy(uiControl(win)); + opened = false; +} + +void Open() +{ + if (opened) + { + uiControlSetFocus(uiControl(win)); + return; + } + + opened = true; + win = uiNewWindow("Audio settings - melonDS", 400, 100, 0, 0); + uiWindowSetMargined(win, 1); + uiWindowOnClosing(win, OnCloseWindow, NULL); + + uiBox* top = uiNewVerticalBox(); + uiWindowSetChild(win, uiControl(top)); + uiBoxSetPadded(top, 1); + + { + uiGroup* grp = uiNewGroup("Audio output"); + uiBoxAppend(top, uiControl(grp), 0); + uiGroupSetMargined(grp, 1); + + uiBox* in_ctrl = uiNewVerticalBox(); + uiGroupSetChild(grp, uiControl(in_ctrl)); + + uiLabel* label_vol = uiNewLabel("Volume:"); + uiBoxAppend(in_ctrl, uiControl(label_vol), 0); + + uiSlider* volslider = uiNewSlider(0, 255); + uiBoxAppend(in_ctrl, uiControl(volslider), 0); + } + + { + uiGroup* grp = uiNewGroup("Microphone input"); + uiBoxAppend(top, uiControl(grp), 0); + uiGroupSetMargined(grp, 1); + + uiBox* in_ctrl = uiNewVerticalBox(); + uiGroupSetChild(grp, uiControl(in_ctrl)); + + uiRadioButtons* mictypes = uiNewRadioButtons(); + uiRadioButtonsAppend(mictypes, "None"); + uiRadioButtonsAppend(mictypes, "Microphone"); + uiRadioButtonsAppend(mictypes, "White noise"); + uiRadioButtonsAppend(mictypes, "WAV file:"); + uiBoxAppend(in_ctrl, uiControl(mictypes), 0); + + uiBox* path_box = uiNewHorizontalBox(); + uiBoxAppend(in_ctrl, uiControl(path_box), 0); + + uiEntry* path_entry = uiNewEntry(); + uiBoxAppend(path_box, uiControl(path_entry), 1); + + uiButton* path_browse = uiNewButton("..."); + uiBoxAppend(path_box, uiControl(path_browse), 0); + } + + { + uiBox* in_ctrl = uiNewHorizontalBox(); + uiBoxSetPadded(in_ctrl, 1); + uiBoxAppend(top, uiControl(in_ctrl), 0); + + uiLabel* dummy = uiNewLabel(""); + uiBoxAppend(in_ctrl, uiControl(dummy), 1); + + uiButton* btncancel = uiNewButton("Cancel"); + uiButtonOnClicked(btncancel, OnCancel, NULL); + uiBoxAppend(in_ctrl, uiControl(btncancel), 0); + + uiButton* btnok = uiNewButton("Ok"); + uiButtonOnClicked(btnok, OnOk, NULL); + uiBoxAppend(in_ctrl, uiControl(btnok), 0); + } + + // shit + + uiControlShow(uiControl(win)); +} + +} diff --git a/src/libui_sdl/DlgAudioSettings.h b/src/libui_sdl/DlgAudioSettings.h new file mode 100644 index 00000000..23339678 --- /dev/null +++ b/src/libui_sdl/DlgAudioSettings.h @@ -0,0 +1,29 @@ +/* + Copyright 2016-2019 StapleButter + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. +*/ + +#ifndef DLGAUDIOSETTINGS_H +#define DLGAUDIOSETTINGS_H + +namespace DlgAudioSettings +{ + +void Open(); + +} + +#endif // DLGAUDIOSETTINGS_H diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 0f202fae..f58ea5f4 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -31,6 +31,7 @@ #include "DlgEmuSettings.h" #include "DlgInputConfig.h" +#include "DlgAudioSettings.h" #include "../NDS.h" #include "../GPU.h" @@ -1350,6 +1351,11 @@ void OnOpenHotkeyConfig(uiMenuItem* item, uiWindow* window, void* blarg) DlgInputConfig::Open(1); } +void OnOpenAudioSettings(uiMenuItem* item, uiWindow* window, void* blarg) +{ + DlgAudioSettings::Open(); +} + void OnSetSavestateSRAMReloc(uiMenuItem* item, uiWindow* window, void* param) { @@ -1615,12 +1621,16 @@ int main(int argc, char** argv) MenuItem_Stop = menuitem; menu = uiNewMenu("Config"); - menuitem = uiMenuAppendItem(menu, "Emu settings"); - uiMenuItemOnClicked(menuitem, OnOpenEmuSettings, NULL); - menuitem = uiMenuAppendItem(menu, "Input config"); - uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL); - menuitem = uiMenuAppendItem(menu, "Hotkey config"); - uiMenuItemOnClicked(menuitem, OnOpenHotkeyConfig, NULL); + { + menuitem = uiMenuAppendItem(menu, "Emu settings"); + uiMenuItemOnClicked(menuitem, OnOpenEmuSettings, NULL); + menuitem = uiMenuAppendItem(menu, "Input config"); + uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL); + menuitem = uiMenuAppendItem(menu, "Hotkey config"); + uiMenuItemOnClicked(menuitem, OnOpenHotkeyConfig, NULL); + menuitem = uiMenuAppendItem(menu, "Audio settings"); + uiMenuItemOnClicked(menuitem, OnOpenAudioSettings, NULL); + } uiMenuAppendSeparator(menu); { uiMenu* submenu = uiNewMenu("Savestate settings");