Skip to content

Commit 3a194c0

Browse files
committed
dialog yay
1 parent ded5ebc commit 3a194c0

File tree

8 files changed

+118
-16
lines changed

8 files changed

+118
-16
lines changed

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"generator": "Ninja",
88
"binaryDir": "${sourceDir}/build",
99
"cacheVariables": {
10-
"CMAKE_EXPORT_COMPILE_COMMANDS": true
10+
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
11+
"CMAKE_BUILD_TYPE": "Debug"
1112
}
1213
},
1314
{

src/Plugins.Win32.SDLAudio/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@ SPDX-License-Identifier: GPL-2.0-or-later
55
]===]
66

77
add_library(Mupen64RR.Plugins.Win32.SDLAudio MODULE
8+
"Config_Win32.cpp"
89
"Main.cpp"
910
"Main_Win32.cpp"
1011
"SDLBackend.cpp"
1112

1213
"Config.hpp"
14+
"Config_Win32.hpp"
1315
"Main.hpp"
1416
"Main_Win32.hpp"
1517
"SDLBackend.hpp"
18+
19+
"Resource.h"
20+
"Resource.rc"
1621
)
1722
set_target_properties(Mupen64RR.Plugins.Win32.SDLAudio PROPERTIES
1823
CXX_STANDARD 23
@@ -24,4 +29,5 @@ set_target_properties(Mupen64RR.Plugins.Win32.SDLAudio PROPERTIES
2429
target_link_libraries(Mupen64RR.Plugins.Win32.SDLAudio PRIVATE
2530
Mupen64RR.Plugins.Win32.Common
2631
SDL3::SDL3
32+
nlohmann_json::nlohmann_json
2733
)

src/Plugins.Win32.SDLAudio/Config.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66

77
#pragma once
88

9+
#include <ostream>
910
namespace SDLAudio
1011
{
1112
struct Config
1213
{
1314
uint32_t default_sample_rate = 33600;
14-
uint32_t src_buffer_size = 16384;
1515
uint32_t src_buffer_target = 2048;
16-
uint32_t dst_buffer_size = 1024;
1716
bool swap_channels = false;
18-
bool audio_sync = false;
17+
bool audio_sync = true;
18+
19+
// void write_to(std::ostream& out);
20+
21+
// void read_from(std::istream& in);
1922
};
2023
} // namespace SDLAudio
Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
1-
21
#include "Config_Win32.hpp"
2+
#include "Main_Win32.hpp"
3+
#include "Resource.h"
4+
5+
#include <minwindef.h>
6+
#include <windows.h>
7+
#include <winuser.h>
38

4-
namespace SDLAudio {
5-
void show_config_win32(HWND parent, Config &config) {
6-
9+
static __stdcall int config_dlgproc(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam)
10+
{
11+
switch (msg)
12+
{
13+
case WM_CLOSE: // "close" button clicked
14+
EndDialog(dialog, IDCANCEL);
15+
break;
16+
case WM_COMMAND: // bottom button clicked
17+
switch (LOWORD(wparam))
18+
{
19+
case IDOK:
20+
EndDialog(dialog, IDOK);
21+
break;
22+
case IDCANCEL:
23+
EndDialog(dialog, IDCANCEL);
24+
break;
25+
default:
26+
break;
27+
}
28+
break;
29+
default:
30+
break;
731
}
8-
}
32+
return FALSE;
33+
}
34+
35+
namespace SDLAudio
36+
{
37+
void show_config_win32(HWND parent, Config &config)
38+
{
39+
DialogBoxW(g_dll_handle, MAKEINTRESOURCE(IDD_CONFIG), parent, config_dlgproc);
40+
}
41+
} // namespace SDLAudio

src/Plugins.Win32.SDLAudio/Main_Win32.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include "Main_Win32.hpp"
2+
#include "Config.hpp"
3+
#include "Config_Win32.hpp"
24
#include <Views.Win32/ViewPlugin.h>
35
#include <filesystem>
4-
#include <libloaderapi.h>
5-
#include <minwindef.h>
6-
#include <string>
76
#include <vector>
8-
#include <winnt.h>
7+
#include <windows.h>
98

10-
HMODULE g_dll_handle = nullptr;
9+
HINSTANCE g_dll_handle = nullptr;
1110
std::filesystem::path g_dll_path {};
1211

13-
BOOL __stdcall DllMain(HMODULE hmod, DWORD reason, LPVOID)
12+
BOOL __stdcall DllMain(HINSTANCE hmod, DWORD reason, LPVOID)
1413
{
1514
if (reason == DLL_PROCESS_ATTACH)
1615
{
@@ -37,4 +36,9 @@ EXPORT void CALL DllAbout(void *hParent)
3736
L"\n\n"
3837
L"https://github.com/mupen64/mupen64-rr-lua";
3938
MessageBoxW((HWND)hParent, msg, L"About", 0x00000040L | 0x00000000L);
39+
}
40+
41+
EXPORT void CALL DllConfig(void* hParent) {
42+
SDLAudio::Config cfg {};
43+
SDLAudio::show_config_win32((HWND) hParent, cfg);
4044
}

src/Plugins.Win32.SDLAudio/Main_Win32.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
#include <filesystem>
55
#include "Main.hpp"
66

7-
extern HMODULE g_dll_handle;
7+
extern HINSTANCE g_dll_handle;
88
extern std::filesystem::path g_dll_path;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#define IDD_CONFIG 101
4+
// #define IDC_AI 1001
5+
// #define IDC_OLDSYNC 1002
6+
// #define IDC_VOLUME 1003
7+
// #define IDC_DISALLOWDS8 1004
8+
// #define IDC_DISALLOWXA2 1007
9+
// #define IDC_DEVICE 1017
10+
// #define IDC_SLIDER_BUFFERFPS 1021
11+
// #define IDC_SLIDER_BACKFPS 1022
12+
// #define IDC_BUFFERS 1024
13+
// #define IDC_BUFFERS_TEXT 1025
14+
// #define IDC_SLIDER_BACKFPS_TEXT 1026
15+
// #define IDC_SLIDER_BUFFERFPS_TEXT 1027
16+
17+
#define IDC_SWAP_CHANNELS 1002
18+
#define IDC_SYNC_AUDIO 1003
19+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "resource.h"
2+
#include <Windows.h>
3+
4+
#define IDC_STATIC -1
5+
6+
// VERTICAL LAYOUT DEFINITIONS
7+
// =====================================================
8+
9+
#define DDX_PLAYBACK_Y 5
10+
#define DDX_PLAYBACK_IY (DDX_PLAYBACK_Y + 15)
11+
#define DDX_PLAYBACK_H 52
12+
13+
#define DDX_DBTNS_Y (DDX_PLAYBACK_Y + DDX_PLAYBACK_H + 6)
14+
#define DDX_DBTNS_H 14
15+
16+
#define DDX_DIALOG_H (DDX_DBTNS_Y + DDX_DBTNS_H + 6)
17+
18+
// DIALOG_DEFINITION
19+
// =====================================================
20+
21+
IDD_CONFIG DIALOGEX 0, 0, 200, DDX_DIALOG_H
22+
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
23+
CAPTION "SDL Audio Settings"
24+
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
25+
FONT 8, "MS Shell Dlg"
26+
BEGIN
27+
// EDIT "Default"
28+
CONTROL "Playback options", IDC_STATIC, BUTTON, BS_GROUPBOX, 10, DDX_PLAYBACK_Y, 180, DDX_PLAYBACK_H
29+
30+
CONTROL "Swap channels", IDC_SWAP_CHANNELS, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 16, (DDX_PLAYBACK_IY + 0), 116, 9
31+
CONTROL "Sync audio", IDC_SYNC_AUDIO, BUTTON, BS_AUTOCHECKBOX | WS_TABSTOP, 16, (DDX_PLAYBACK_IY + 14), 116, 9
32+
33+
34+
PUSHBUTTON "Cancel", IDCANCEL, 87, DDX_DBTNS_Y, 50, DDX_DBTNS_H
35+
DEFPUSHBUTTON "&OK", IDOK, 140, DDX_DBTNS_Y, 50, DDX_DBTNS_H
36+
END

0 commit comments

Comments
 (0)