[WINMINE] Add sound effects (#6969)

- Sound is disabled by default
- Use WinXP-compatible registry key and value
This commit is contained in:
Thamatip Chitpong 2024-06-03 21:57:44 +07:00 committed by GitHub
parent 890b9c0b93
commit 580574fba8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
40 changed files with 150 additions and 3 deletions

View File

@ -11,6 +11,6 @@ add_rc_deps(rsrc.rc ${winmine_rc_deps})
add_executable(winmine ${SOURCE} rsrc.rc)
set_module_type(winmine win32gui UNICODE)
target_link_libraries(winmine wine)
add_importlibs(winmine user32 gdi32 advapi32 shell32 msvcrt kernel32 ntdll)
add_importlibs(winmine user32 gdi32 advapi32 shell32 winmm msvcrt kernel32 ntdll)
add_pch(winmine main.h SOURCE)
add_cd_file(TARGET winmine DESTINATION reactos/system32 FOR all)

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Нов\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "Слагане на &питанка", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "На&чинаещ", IDM_BEGINNER
MENUITEM "&Напреднал", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nová\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Označovat nerozhodnuté", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Začátečník", IDM_BEGINNER
MENUITEM "&Pokročilý", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nyt spil\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Brug spørgsmålstegn", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Ny&begynder", IDM_BEGINNER
MENUITEM "&Avanceret", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Neu\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Merker", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Anfänger", IDM_BEGINNER
MENUITEM "&Fortgeschrittene", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&New\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Mark Question", IDM_MARKQ
MENUITEM "&Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Beginner", IDM_BEGINNER
MENUITEM "&Advanced", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nuevo\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Interrogación", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Principiante", IDM_BEGINNER
MENUITEM "&Avanzado", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Uusi\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Merkitse", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Aloittelija", IDM_BEGINNER
MENUITEM "&Kehittynyt", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nouveau\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Marquage des cases suspectes", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Débutant", IDM_BEGINNER
MENUITEM "&Avancé", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&חדש\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "סימון בשאלה", IDM_MARKQ // to be invented
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&מתחיל", IDM_BEGINNER
MENUITEM "מ&תקדם", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Új\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "K&érdőjelek engedélyezése", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Kez&dő", IDM_BEGINNER
MENUITEM "Kö&zéphaladó", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Baru\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "Beri &Tanda Tanya", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Pemula", IDM_BEGINNER
MENUITEM "Ti&ngkat Lanjut", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nuovo\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Contrassegna domanda", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Principiante", IDM_BEGINNER
MENUITEM "&Avanzato", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "スタート(&N)\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "?マークを使用(&M)", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "初級(&B)", IDM_BEGINNER
MENUITEM "中級(&A)", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "새 게임(&N)\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "물음표 표시(&M)", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "초보자(&B)", IDM_BEGINNER
MENUITEM "중급자(&A)", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Naujas\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Žymėti klaustuku", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "P&radedantis", IDM_BEGINNER
MENUITEM "&Pažengęs", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nieuw spel\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Markeer vraag", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Beginner", IDM_BEGINNER
MENUITEM "&Gevorderde", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Ny\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Merk spørsmål", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Ny&begynner", IDM_BEGINNER
MENUITEM "&Avansert", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nowa\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Znaczniki", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Początkujący", IDM_BEGINNER
MENUITEM "Z&aawansowany", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Novo\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Marcas", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Principiante", IDM_BEGINNER
MENUITEM "&Intermediário", IDM_ADVANCED

View File

@ -22,6 +22,7 @@ BEGIN
MENUITEM "&Nou\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Marcaje „?”", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "În&cepător", IDM_BEGINNER
MENUITEM "&Avansat", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Новая игра\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Вопросительные знаки", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Нови&чок", IDM_BEGINNER
MENUITEM "&Любитель", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nova igra\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Vprašaji", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Začetnik", IDM_BEGINNER
MENUITEM "&Napreden", IDM_ADVANCED

View File

@ -18,6 +18,7 @@ BEGIN
MENUITEM "&E re\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Marko pyetjen", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Fillestar", IDM_BEGINNER
MENUITEM "&I Avancuar", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Nytt\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Markera fråga", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Ny&börjare", IDM_BEGINNER
MENUITEM "&Avancerad", IDM_ADVANCED

View File

@ -18,6 +18,7 @@ BEGIN
MENUITEM "&Yeni\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Soru İşaretiyle İşaretleme", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "&Acemi", IDM_BEGINNER
MENUITEM "&Gelişmiş", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "&Нова\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Знаки питання", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "Н&овачок", IDM_BEGINNER
MENUITEM "&Майстер", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "新游戏(&N)\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "允许问号标记(&M)", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "初学者(&B)", IDM_BEGINNER
MENUITEM "高级(&A)", IDM_ADVANCED

View File

@ -22,6 +22,7 @@ BEGIN
MENUITEM "新遊戲(&N)\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "標出問題(&M)", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "新手(&B)", IDM_BEGINNER
MENUITEM "進階(&A)", IDM_ADVANCED

View File

@ -14,6 +14,7 @@ BEGIN
MENUITEM "新遊戲(&N)\tF2", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "標出問題(&M)", IDM_MARKQ
MENUITEM "Sound", IDM_SOUND
MENUITEM SEPARATOR
MENUITEM "初學者(&B)", IDM_BEGINNER
MENUITEM "高級(&A)", IDM_ADVANCED

View File

@ -26,6 +26,9 @@
#include <time.h>
#include <stdlib.h>
#include <shellapi.h>
#ifdef __REACTOS__
#include <mmsystem.h>
#endif
#include <wine/debug.h>
@ -106,6 +109,15 @@ static void LoadBoard( BOARD *p_board )
if( RegQueryValueExW( hkey, markW, NULL, &type, (BYTE*) &p_board->IsMarkQ, &size ) )
p_board->IsMarkQ = TRUE;
#ifdef __REACTOS__
/* WinXP SP3: Enabled when value >= 3, disabled when value < 3 */
size = sizeof(p_board->IsSoundEnabled);
if (RegQueryValueExW(hkey, L"Sound", NULL, &type, (BYTE*)&p_board->IsSoundEnabled, &size) == ERROR_SUCCESS)
p_board->IsSoundEnabled = (p_board->IsSoundEnabled >= 3 ? TRUE : FALSE);
else
p_board->IsSoundEnabled = FALSE;
#endif
for( i = 0; i < 3; i++ ) {
wsprintfW( key_name, nameW, i+1 );
size = sizeof( data );
@ -142,6 +154,9 @@ static void InitBoard( BOARD *p_board )
CheckMenuItem( hMenu, IDM_MARKQ, MF_CHECKED );
else
CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED );
#ifdef __REACTOS__
CheckMenuItem(hMenu, IDM_SOUND, p_board->IsSoundEnabled ? MF_CHECKED : MF_UNCHECKED);
#endif
CheckLevel( p_board );
}
@ -165,6 +180,11 @@ static void SaveBoard( BOARD *p_board )
RegSetValueExW( hkey, widthW, 0, REG_DWORD, (LPBYTE) &p_board->cols, sizeof(p_board->cols) );
RegSetValueExW( hkey, minesW, 0, REG_DWORD, (LPBYTE) &p_board->mines, sizeof(p_board->mines) );
RegSetValueExW( hkey, markW, 0, REG_DWORD, (LPBYTE) &p_board->IsMarkQ, sizeof(p_board->IsMarkQ) );
#ifdef __REACTOS__
/* WinXP SP3: Set to 3 when enabled, set to 0 when disabled */
p_board->IsSoundEnabled = (p_board->IsSoundEnabled ? 3 : 0);
RegSetValueExW(hkey, L"Sound", 0, REG_DWORD, (LPBYTE)&p_board->IsSoundEnabled, sizeof(p_board->IsSoundEnabled));
#endif
for( i = 0; i < 3; i++ ) {
wsprintfW( key_name, nameW, i+1 );
@ -542,13 +562,26 @@ static void DrawBoard( HDC hdc, HDC hMemDC, PAINTSTRUCT *ps, BOARD *p_board )
}
#ifdef __REACTOS__
static void PlaySoundEffect(BOARD *p_board, UINT id)
{
if (p_board->IsSoundEnabled)
PlaySoundW(MAKEINTRESOURCEW(id), p_board->hInst, SND_RESOURCE | SND_ASYNC);
}
#endif
static void AddFlag( BOARD *p_board, unsigned col, unsigned row )
{
if( p_board->box[col][row].FlagType != COMPLETE ) {
switch( p_board->box[col][row].FlagType ) {
case FLAG:
if( p_board->IsMarkQ )
if( p_board->IsMarkQ ) {
p_board->box[col][row].FlagType = QUESTION;
#ifdef __REACTOS__
PlaySoundEffect(p_board, IDW_QUESTION);
#endif
}
else
p_board->box[col][row].FlagType = NORMAL;
p_board->num_flags--;
@ -561,6 +594,9 @@ static void AddFlag( BOARD *p_board, unsigned col, unsigned row )
default:
p_board->box[col][row].FlagType = FLAG;
p_board->num_flags++;
#ifdef __REACTOS__
PlaySoundEffect(p_board, IDW_FLAG);
#endif
}
}
}
@ -640,7 +676,11 @@ static void PressBoxes( BOARD *p_board, unsigned col, unsigned row )
}
#ifdef __REACTOS__
static void CompleteBox( BOARD *p_board, unsigned col, unsigned row, BOOL is_first_box )
#else
static void CompleteBox( BOARD *p_board, unsigned col, unsigned row )
#endif
{
int i, j;
@ -653,15 +693,27 @@ static void CompleteBox( BOARD *p_board, unsigned col, unsigned row )
if( p_board->box[col][row].IsMine ) {
p_board->face_bmp = DEAD_BMP;
p_board->status = GAMEOVER;
#ifdef __REACTOS__
PlaySoundEffect(p_board, IDW_EXPLODE);
#endif
}
else if( p_board->status != GAMEOVER )
else if( p_board->status != GAMEOVER ) {
p_board->boxes_left--;
#ifdef __REACTOS__
if (is_first_box)
PlaySoundEffect(p_board, IDW_BOX);
#endif
}
if( p_board->box[col][row].NumMines == 0 )
{
for( i = -1; i <= 1; i++ )
for( j = -1; j <= 1; j++ )
#ifdef __REACTOS__
CompleteBox( p_board, col + i, row + j, FALSE );
#else
CompleteBox( p_board, col + i, row + j );
#endif
}
}
}
@ -683,7 +735,11 @@ static void CompleteBoxes( BOARD *p_board, unsigned col, unsigned row )
for( i = -1; i <= 1; i++ )
for( j = -1; j <= 1; j++ ) {
if( p_board->box[col+i][row+j].FlagType != FLAG )
#ifdef __REACTOS__
CompleteBox( p_board, col+i, row+j, FALSE );
#else
CompleteBox( p_board, col+i, row+j );
#endif
}
}
}
@ -722,7 +778,11 @@ static void TestMines( BOARD *p_board, POINT pt, int msg )
p_board->status = PLAYING;
PlaceMines( p_board, col, row );
}
#ifdef __REACTOS__
CompleteBox( p_board, col, row, TRUE );
#else
CompleteBox( p_board, col, row );
#endif
break;
case WM_MBUTTONDOWN:
@ -800,6 +860,10 @@ static void TestBoard( HWND hWnd, BOARD *p_board, int x, int y, int msg )
}
if( p_board->boxes_left == 0 ) {
#ifdef __REACTOS__
if (p_board->status != WON)
PlaySoundEffect(p_board, IDW_WIN);
#endif
p_board->status = WON;
if (p_board->num_flags < p_board->mines) {
@ -957,6 +1021,14 @@ static LRESULT WINAPI MainProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
CheckMenuItem( hMenu, IDM_MARKQ, MF_UNCHECKED );
return 0;
#ifdef __REACTOS__
case IDM_SOUND:
hMenu = GetMenu(hWnd);
board.IsSoundEnabled = !board.IsSoundEnabled;
CheckMenuItem(hMenu, IDM_SOUND, board.IsSoundEnabled ? MF_CHECKED : MF_UNCHECKED);
return 0;
#endif
case IDM_BEGINNER:
SetDifficulty( &board, BEGINNER );
CreateBoard( &board );

View File

@ -71,6 +71,9 @@ typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
typedef struct tagBOARD
{
BOOL IsMarkQ;
#ifdef __REACTOS__
BOOL IsSoundEnabled;
#endif
HDC hdc;
HINSTANCE hInst;
HWND hWnd;

View File

@ -0,0 +1,24 @@
box.wav
License: CC0 1.0 Universal
URL: https://freesound.org/people/amitYunger123/sounds/737638/
Date: 30-May-2024
explode.wav
License: CC0 1.0 Universal
URL: https://freesound.org/people/hoffy1138/sounds/276968/
Date: 31-May-2024
flag.wav
License: CC0 1.0 Universal
URL: https://freesound.org/people/profoundsounds/sounds/733230/
Date: 30-May-2024
question.wav
License: CC0 1.0 Universal
URL: https://freesound.org/people/Irolan/sounds/737510/
Date: 30-May-2024
win.wav
License: CC0 1.0 Universal
URL: https://freesound.org/people/David819/sounds/668436/
Date: 31-May-2024

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -32,6 +32,9 @@
#define IDM_EXPERT 1007
#define IDM_CUSTOM 1008
#define IDM_MARKQ 1009
#ifdef __REACTOS__
#define IDM_SOUND 1041
#endif
#define IDC_TIME1 1011
#define IDC_TIME2 1012
@ -62,3 +65,12 @@
#define DLG_TIMES 1
#define DLG_CONGRATS 2
#define DLG_CUSTOM 3
#ifdef __REACTOS__
/* Sound effects */
#define IDW_BOX 1301
#define IDW_FLAG 1302
#define IDW_QUESTION 1303
#define IDW_EXPLODE 1304
#define IDW_WIN 1305
#endif

View File

@ -44,6 +44,13 @@ IDI_LEDS BITMAP "rc/leds.bmp"
/* @makedep: mines.bmp */
IDI_MINES BITMAP "rc/mines.bmp"
/* Sound effects */
IDW_BOX WAVE "rc/box.wav"
IDW_FLAG WAVE "rc/flag.wav"
IDW_QUESTION WAVE "rc/question.wav"
IDW_EXPLODE WAVE "rc/explode.wav"
IDW_WIN WAVE "rc/win.wav"
#include <reactos/manifest_exe.rc>
/* include localised resources */