Ticket #948: 948_ButtonSoundAttribute.patch
File 948_ButtonSoundAttribute.patch, 2.8 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/gui/common/styles.xml
21 21 multiline="false" 22 22 /> 23 23 24 24 <!-- 25 25 ========================================== 26 - DEFAULT BUTTON STYLE: The style with the name 'default_button' is special, it will 27 - be called by every button object before any other style is loaded, except 'default'. 28 ========================================== 29 --> 30 31 <style name="default_button" 32 button_sound="audio/interface/ui/ui_button_click.ogg" 33 /> 34 35 <!-- 36 ========================================== 26 37 - STYLE - GLOBAL - PANES - WHEAT SKIN 27 38 ========================================== 28 39 --> -
source/gui/CButton.cpp
32 32 CButton::CButton() 33 33 { 34 34 AddSetting(GUIST_float, "buffer_zone"); 35 AddSetting(GUIST_CStr, "button_sound"); 35 36 AddSetting(GUIST_CGUIString, "caption"); 36 37 AddSetting(GUIST_int, "cell_id"); 37 38 AddSetting(GUIST_CStrW, "font"); -
source/gui/CGUI.cpp
1169 1169 if (m_Styles.count("default") == 1) 1170 1170 object->LoadStyle(*this, "default"); 1171 1171 1172 if (type.Find("button") != -1 && m_Styles.count("default_button") == 1) 1173 object->LoadStyle(*this, "default_button"); 1174 1172 1175 if (! argStyle.empty()) 1173 1176 { 1174 1177 // additional check -
source/gui/IGUIButtonBehavior.cpp
21 21 22 22 #include "precompiled.h" 23 23 #include "GUI.h" 24 #include "lib/res/sound/snd_mgr.h" 25 #include "ps/Filesystem.h" 26 #include "ps/CLogger.h" 24 27 25 26 28 //------------------------------------------------------------------- 27 29 // Constructor / Destructor 28 30 //------------------------------------------------------------------- … … 78 80 } 79 81 } 80 82 } break; 83 84 case GUIM_PRESSED: 85 { 86 // Play button sound if available 87 CStr button_sound; 88 if (PSRETURN_OK == GUI<CStr>::GetSetting(this, "button_sound", button_sound)) 89 { 90 Handle hvs = snd_open(g_VFS, button_sound.c_str()); 91 if (hvs > 0) 92 { 93 snd_set_pos(hvs, 0,0,0, true); 94 snd_play(hvs); 95 } 96 else 97 { 98 LOGWARNING(L"Unable to snd_open button_sound %hs in IGUIButtonBehavior", button_sound.c_str()); 99 } 100 } 101 // else no button_sound to play 81 102 103 } break; 104 82 105 default: 83 106 break; 84 107 }