Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions Minecraft.Client/Common/App_Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ enum EGameHostOptionWorldSize
#define GAMESETTING_VSYNC 0x01000000
#define GAMESETTING_EXCLUSIVEFULLSCREEN 0x02000000
#define GAMESETTING_CLASSICCRAFTING 0x04000000
#define GAMESETTING_CAVESOUNDS 0x08000000
#define GAMESETTING_MINECARTSOUNDS 0x10000000


// defines for languages
Expand Down
2 changes: 2 additions & 0 deletions Minecraft.Client/Common/App_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ enum eGameSetting

//TU25
eGameSetting_ClassicCrafting,
eGameSetting_CaveSounds,
eGameSetting_MinecartSounds,
};


Expand Down
118 changes: 75 additions & 43 deletions Minecraft.Client/Common/Audio/SoundEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,34 +605,8 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, floa
m_activeSounds.push_back(s);
}

/////////////////////////////////////////////
//
//
// startElytraSound / stopElytraSound
// Manages a single persistent looping sound for elytra gliding.
// Call startElytraSound every tick while gliding (it no-ops if already running,
// just updates volume). Call stopElytraSound when gliding ends.
//
// IMPORTANT: m_elytraLoopingSound is NOT added to m_activeSounds.
// The tick() cleanup loop deletes sounds where is_playing()==false.
// A looping sound briefly reports is_playing()==false at the loop point,
// which would cause tick() to free it and leave m_elytraLoopingSound dangling.
//
/////////////////////////////////////////////
void SoundEngine::startElytraSound(float x, float y, float z, float volume, float pitch)
MiniAudioSound* SoundEngine::startLoopingSound(const wstring& name, float x, float y, float z, float volume, float pitch, bool bIs3D)
{
// If already initialized just update volume and pitch - never reinitialize mid-flight.
if (m_elytraLoopingSound != nullptr)
{
float finalVolume = volume * m_MasterEffectsVolume * SFX_VOLUME_MULTIPLIER;
if (finalVolume > SFX_MAX_GAIN) finalVolume = SFX_MAX_GAIN;
ma_sound_set_volume(&m_elytraLoopingSound->sound, finalVolume);
ma_sound_set_pitch(&m_elytraLoopingSound->sound, pitch);
return;
}

// Resolve file path using the same logic as play().
wstring name = wchSoundNames[eSoundType_ITEM_ELYTRA_FLYING];
char* soundName = ConvertSoundPathToName(name);
char basePath[256];
sprintf_s(basePath, "Windows64Media/Sound/Minecraft/%s", soundName);
Expand All @@ -652,42 +626,100 @@ void SoundEngine::startElytraSound(float x, float y, float z, float volume, floa
break;
}
}
if (!found) return;
if (!found)
{
return nullptr;
}

MiniAudioSound* s = new MiniAudioSound();
memset(&s->info, 0, sizeof(AUDIO_INFO));
s->info.volume = volume; s->info.pitch = pitch;
s->info.bIs3D = false;
s->info.iSound = eSoundType_ITEM_ELYTRA_FLYING + eSFX_MAX;

// Synchronous load so the sound is immediately ready - no ASYNC gap.
if (ma_sound_init_from_file(&m_engine, finalPath, 0,
nullptr, nullptr, &s->sound) != MA_SUCCESS)
s->info.x = x;
s->info.y = y;
s->info.z = z;
s->info.volume = volume;
s->info.pitch = pitch;
s->info.bIs3D = bIs3D;
s->info.bUseSoundsPitchVal = false;

if (ma_sound_init_from_file(&m_engine, finalPath, 0, nullptr, nullptr, &s->sound) != MA_SUCCESS)
{
delete s;
return;
return nullptr;
}

ma_sound_set_spatialization_enabled(&s->sound, MA_FALSE);
ma_sound_set_spatialization_enabled(&s->sound, bIs3D ? MA_TRUE : MA_FALSE);
ma_sound_set_looping(&s->sound, MA_TRUE);

float finalVolume = volume * m_MasterEffectsVolume * SFX_VOLUME_MULTIPLIER;
if (finalVolume > SFX_MAX_GAIN) finalVolume = SFX_MAX_GAIN;
if (finalVolume > SFX_MAX_GAIN)
finalVolume = SFX_MAX_GAIN;
ma_sound_set_volume(&s->sound, finalVolume);
ma_sound_set_pitch(&s->sound, pitch);
if (bIs3D)
{
ma_sound_set_position(&s->sound, x, y, z);
}
ma_sound_start(&s->sound);
return s;
}

void SoundEngine::updateLoopingSound(MiniAudioSound* sound, float x, float y, float z, float volume, float pitch)
{
if (sound == nullptr)
{
return;
}

float finalVolume = volume * m_MasterEffectsVolume * SFX_VOLUME_MULTIPLIER;
if (finalVolume > SFX_MAX_GAIN)
finalVolume = SFX_MAX_GAIN;
ma_sound_set_volume(&sound->sound, finalVolume);
ma_sound_set_pitch(&sound->sound, pitch);
ma_sound_set_position(&sound->sound, x, y, z);
}

void SoundEngine::stopLoopingSound(MiniAudioSound* sound)
{
if (sound == nullptr)
{
return;
}

ma_sound_stop(&sound->sound);
ma_sound_uninit(&sound->sound);
delete sound;
}

/////////////////////////////////////////////
//
//
// startElytraSound / stopElytraSound
// Manages a single persistent looping sound for elytra gliding.
// Call startElytraSound every tick while gliding (it no-ops if already running,
// just updates volume). Call stopElytraSound when gliding ends.
//
// IMPORTANT: m_elytraLoopingSound is NOT added to m_activeSounds.
// The tick() cleanup loop deletes sounds where is_playing()==false.
// A looping sound briefly reports is_playing()==false at the loop point,
// which would cause tick() to free it and leave m_elytraLoopingSound dangling.
//
/////////////////////////////////////////////
void SoundEngine::startElytraSound(float x, float y, float z, float volume, float pitch)
{
// If already initialized just update volume and pitch - never reinitialize mid-flight.
if (m_elytraLoopingSound != nullptr)
{
updateLoopingSound(m_elytraLoopingSound, x, y, z, volume, pitch);
return;
}
// NOT added to m_activeSounds - tick() cleanup would delete it at loop boundaries.
m_elytraLoopingSound = s;
m_elytraLoopingSound = startLoopingSound(wchSoundNames[eSoundType_ITEM_ELYTRA_FLYING], x, y, z, volume, pitch, false);
}

void SoundEngine::stopElytraSound()
{
if (m_elytraLoopingSound == nullptr) return;

ma_sound_stop(&m_elytraLoopingSound->sound);
ma_sound_uninit(&m_elytraLoopingSound->sound);
delete m_elytraLoopingSound;
stopLoopingSound(m_elytraLoopingSound);
m_elytraLoopingSound = nullptr;
}
/////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions Minecraft.Client/Common/Audio/SoundEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class SoundEngine : public ConsoleSoundEngine
void GetSoundName(char *szSoundName,int iSound);
#endif
void play(int iSound, float x, float y, float z, float volume, float pitch) override;
MiniAudioSound* startLoopingSound(const wstring& name, float x, float y, float z, float volume, float pitch, bool bIs3D = true);
void updateLoopingSound(MiniAudioSound* sound, float x, float y, float z, float volume, float pitch);
void stopLoopingSound(MiniAudioSound* sound);
void startElytraSound(float x, float y, float z, float volume, float pitch);
void stopElytraSound();
void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) override;
Expand Down
47 changes: 47 additions & 0 deletions Minecraft.Client/Common/Consoles_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,10 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con

//TU25
SetGameSettings(iPad, eGameSetting_ClassicCrafting, 0);
SetGameSettings(iPad, eGameSetting_CaveSounds, 1);

//TU34
SetGameSettings(iPad, eGameSetting_MinecartSounds, 1);

// 4J-PB - leave these in, or remove from everywhere they are referenced!
// Although probably best to leave in unless we split the profile settings into platform specific classes - having different meaning per platform for the same bitmask could get confusing
Expand Down Expand Up @@ -1502,6 +1506,8 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad)

//TU25
ActionGameSettings(iPad, eGameSetting_ClassicCrafting);
ActionGameSettings(iPad, eGameSetting_CaveSounds);
ActionGameSettings(iPad, eGameSetting_MinecartSounds);
}

void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
Expand Down Expand Up @@ -2512,6 +2518,36 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV
GameSettingsA[iPad]->bSettingsChanged = true;
}
break;
case eGameSetting_CaveSounds:
if ((GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_CAVESOUNDS) != (ucVal & 0x01) << 27)
{
if (ucVal == 1)
{
GameSettingsA[iPad]->uiBitmaskValues |= GAMESETTING_CAVESOUNDS;
}
else
{
GameSettingsA[iPad]->uiBitmaskValues &= ~GAMESETTING_CAVESOUNDS;
}
ActionGameSettings(iPad, eVal);
GameSettingsA[iPad]->bSettingsChanged = true;
}
break;
case eGameSetting_MinecartSounds:
if ((GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_MINECARTSOUNDS) != (ucVal & 0x01) << 28)
{
if (ucVal == 1)
{
GameSettingsA[iPad]->uiBitmaskValues |= GAMESETTING_MINECARTSOUNDS;
}
else
{
GameSettingsA[iPad]->uiBitmaskValues &= ~GAMESETTING_MINECARTSOUNDS;
}
ActionGameSettings(iPad, eVal);
GameSettingsA[iPad]->bSettingsChanged = true;
}
break;
}
}

Expand All @@ -2524,6 +2560,11 @@ unsigned char CMinecraftApp::GetGameSettings(eGameSetting eVal)

unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal)
{
if (iPad < 0 || iPad >= XUSER_MAX_COUNT || GameSettingsA[iPad] == nullptr)
{
return 0;
}

switch(eVal)
{
case eGameSetting_MusicVolume:
Expand Down Expand Up @@ -2650,6 +2691,12 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal)
case eGameSetting_ClassicCrafting:
return (GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_CLASSICCRAFTING) >> 26;

case eGameSetting_CaveSounds:
return (GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_CAVESOUNDS) >> 27;

case eGameSetting_MinecartSounds:
return (GameSettingsA[iPad]->uiBitmaskValues & GAMESETTING_MINECARTSOUNDS) >> 28;

case eGameSetting_VSync:
return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_VSYNC)>>24;

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Minecraft.Client/Common/Media/MediaWindows64/SettingsMenu1080.swf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion Minecraft.Client/Common/UI/UI.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#include "UIScene_SettingsMenu.h"
#include "UIScene_SettingsOptionsMenu.h"
#include "UIScene_SettingsAudioMenu.h"
#include "UIScene_SettingsControlMenu.h"
#include "UIScene_SettingsGraphicsMenu.h"
#include "UIScene_SettingsUIMenu.h"
#include "UIScene_SkinSelectMenu.h"
Expand Down
1 change: 0 additions & 1 deletion Minecraft.Client/Common/UI/UIEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ enum EUIScene
eUIScene_ControlsMenu,
eUIScene_SettingsOptionsMenu,
eUIScene_SettingsAudioMenu,
eUIScene_SettingsControlMenu,
eUIScene_SettingsGraphicsMenu,
eUIScene_SettingsUIMenu,
eUIScene_SettingsMenu,
Expand Down
3 changes: 0 additions & 3 deletions Minecraft.Client/Common/UI/UILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ bool UILayer::NavigateToScene(int iPad, EUIScene scene, void *initData)
case eUIScene_SettingsAudioMenu:
newScene = new UIScene_SettingsAudioMenu(iPad, initData, this);
break;
case eUIScene_SettingsControlMenu:
newScene = new UIScene_SettingsControlMenu(iPad, initData, this);
break;
case eUIScene_SettingsGraphicsMenu:
newScene = new UIScene_SettingsGraphicsMenu(iPad, initData, this);
break;
Expand Down
17 changes: 17 additions & 0 deletions Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ UIScene_SettingsAudioMenu::UIScene_SettingsAudioMenu(int iPad, void *initData, U
swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),app.GetGameSettings(m_iPad,eGameSetting_SoundFXVolume));
m_sliderSound.init(TempString,eControl_Sound,0,100,app.GetGameSettings(m_iPad,eGameSetting_SoundFXVolume));

m_checkboxCaveSounds.init(L"Cave Sounds",eControl_CaveSounds,(app.GetGameSettings(m_iPad,eGameSetting_CaveSounds)!=0));

m_checkboxMinecartSounds.init(L"Minecart Sounds",eControl_MinecartSounds,(app.GetGameSettings(m_iPad,eGameSetting_MinecartSounds)!=0));

doHorizontalResizeCheck();

if(app.GetLocalPlayerCount()>1)
Expand Down Expand Up @@ -114,3 +118,16 @@ void UIScene_SettingsAudioMenu::handleSliderMove(F64 sliderId, F64 currentValue)
break;
}
}

void UIScene_SettingsAudioMenu::handleCheckboxToggled(F64 controlId, bool selected)
{
switch(static_cast<int>(controlId))
{
case eControl_CaveSounds:
app.SetGameSettings(m_iPad, eGameSetting_CaveSounds, selected ? 1 : 0);
break;
case eControl_MinecartSounds:
app.SetGameSettings(m_iPad, eGameSetting_MinecartSounds, selected ? 1 : 0);
break;
}
}
11 changes: 8 additions & 3 deletions Minecraft.Client/Common/UI/UIScene_SettingsAudioMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ class UIScene_SettingsAudioMenu : public UIScene
enum EControls
{
eControl_Music,
eControl_Sound
eControl_Sound,
eControl_CaveSounds,
eControl_MinecartSounds
};

UIControl_Slider m_sliderMusic, m_sliderSound; // Sliders
UIControl_CheckBox m_checkboxCaveSounds; // Checkboxes
UIControl_CheckBox m_checkboxMinecartSounds;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_ELEMENT( m_sliderMusic, "Music")
UI_MAP_ELEMENT( m_sliderSound, "Sound")
UI_MAP_ELEMENT( m_checkboxCaveSounds, "CaveSounds")
UI_MAP_ELEMENT( m_checkboxMinecartSounds, "MinecartSounds")
UI_END_MAP_ELEMENTS_AND_NAMES()

public:
Expand All @@ -34,5 +40,4 @@ class UIScene_SettingsAudioMenu : public UIScene
// INPUT
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);

virtual void handleSliderMove(F64 sliderId, F64 currentValue);
};
virtual void handleSliderMove(F64 sliderId, F64 currentValue); virtual void handleCheckboxToggled(F64 controlId, bool selected);};
Loading
Loading