diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-28 02:14:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-28 03:01:38 +0300 |
commit | c85d939d9b3f6c10288dc86ffa7811408e349657 (patch) | |
tree | b1ca825fde3bad322728df1c9133ec25b74b341e | |
parent | 5023a1d0b96071a35547dcc309ce45ba6a17eec1 (diff) | |
download | plus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.gz plus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.bz2 plus-c85d939d9b3f6c10288dc86ffa7811408e349657.tar.xz plus-c85d939d9b3f6c10288dc86ffa7811408e349657.zip |
Add different sound effects for different events.
Can be configured in audio tab in settings.
50 files changed, 237 insertions, 51 deletions
diff --git a/data/sfx/system/CMakeLists.txt b/data/sfx/system/CMakeLists.txt index bf6f0f0f3..0fa325a45 100644 --- a/data/sfx/system/CMakeLists.txt +++ b/data/sfx/system/CMakeLists.txt @@ -1,5 +1,21 @@ SET (FILES + attention.ogg + chat1.ogg + chat2.ogg + complete.ogg + email.ogg + error.ogg + finish.ogg + incoming.ogg + move.ogg + notify.ogg newmessage.ogg + offline.ogg + online.ogg + reminder.ogg + send.ogg + start.ogg + watcher.ogg ) INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/sfx/system) diff --git a/data/sfx/system/Makefile.am b/data/sfx/system/Makefile.am index e744932c3..d46934461 100644 --- a/data/sfx/system/Makefile.am +++ b/data/sfx/system/Makefile.am @@ -1,7 +1,23 @@ systemdir = $(pkgdatadir)/data/sfx/system system_DATA = \ - newmessage.ogg + attention.ogg \ + chat1.ogg \ + chat2.ogg \ + complete.ogg \ + email.ogg \ + error.ogg \ + finish.ogg \ + incoming.ogg \ + move.ogg \ + newmessage.ogg \ + notify.ogg \ + offline.ogg \ + online.ogg \ + reminder.ogg \ + send.ogg \ + start.ogg \ + watcher.ogg EXTRA_DIST = \ $(system_DATA) \ diff --git a/data/sfx/system/attention.ogg b/data/sfx/system/attention.ogg Binary files differnew file mode 100644 index 000000000..929265775 --- /dev/null +++ b/data/sfx/system/attention.ogg diff --git a/data/sfx/system/chat1.ogg b/data/sfx/system/chat1.ogg Binary files differnew file mode 100644 index 000000000..ad6c52a1d --- /dev/null +++ b/data/sfx/system/chat1.ogg diff --git a/data/sfx/system/chat2.ogg b/data/sfx/system/chat2.ogg Binary files differnew file mode 100644 index 000000000..155b15e1f --- /dev/null +++ b/data/sfx/system/chat2.ogg diff --git a/data/sfx/system/complete.ogg b/data/sfx/system/complete.ogg Binary files differnew file mode 100644 index 000000000..0975ff7c8 --- /dev/null +++ b/data/sfx/system/complete.ogg diff --git a/data/sfx/system/email.ogg b/data/sfx/system/email.ogg Binary files differnew file mode 100644 index 000000000..afb25909f --- /dev/null +++ b/data/sfx/system/email.ogg diff --git a/data/sfx/system/error.ogg b/data/sfx/system/error.ogg Binary files differnew file mode 100644 index 000000000..69dccfe7c --- /dev/null +++ b/data/sfx/system/error.ogg diff --git a/data/sfx/system/finish.ogg b/data/sfx/system/finish.ogg Binary files differnew file mode 100644 index 000000000..d8dbbf80f --- /dev/null +++ b/data/sfx/system/finish.ogg diff --git a/data/sfx/system/incoming.ogg b/data/sfx/system/incoming.ogg Binary files differnew file mode 100644 index 000000000..a8ff86676 --- /dev/null +++ b/data/sfx/system/incoming.ogg diff --git a/data/sfx/system/move.ogg b/data/sfx/system/move.ogg Binary files differnew file mode 100644 index 000000000..e5c703bbf --- /dev/null +++ b/data/sfx/system/move.ogg diff --git a/data/sfx/system/notify.ogg b/data/sfx/system/notify.ogg Binary files differnew file mode 100644 index 000000000..95d8fed4a --- /dev/null +++ b/data/sfx/system/notify.ogg diff --git a/data/sfx/system/offline.ogg b/data/sfx/system/offline.ogg Binary files differnew file mode 100644 index 000000000..cc1b8e938 --- /dev/null +++ b/data/sfx/system/offline.ogg diff --git a/data/sfx/system/online.ogg b/data/sfx/system/online.ogg Binary files differnew file mode 100644 index 000000000..3e55793fd --- /dev/null +++ b/data/sfx/system/online.ogg diff --git a/data/sfx/system/reminder.ogg b/data/sfx/system/reminder.ogg Binary files differnew file mode 100644 index 000000000..d7beeed6f --- /dev/null +++ b/data/sfx/system/reminder.ogg diff --git a/data/sfx/system/send.ogg b/data/sfx/system/send.ogg Binary files differnew file mode 100644 index 000000000..b5941323d --- /dev/null +++ b/data/sfx/system/send.ogg diff --git a/data/sfx/system/start.ogg b/data/sfx/system/start.ogg Binary files differnew file mode 100644 index 000000000..0b1f85643 --- /dev/null +++ b/data/sfx/system/start.ogg diff --git a/data/sfx/system/watcher.ogg b/data/sfx/system/watcher.ogg Binary files differnew file mode 100644 index 000000000..9a0dd1af2 --- /dev/null +++ b/data/sfx/system/watcher.ogg diff --git a/src/client.cpp b/src/client.cpp index 978c58eef..5f79176c7 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1327,14 +1327,16 @@ int Client::gameExec() case STATE_LOGIN_ERROR: logger->log1("State: LOGIN ERROR"); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&loginListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; case STATE_ACCOUNTCHANGE_ERROR: logger->log1("State: ACCOUNT CHANGE ERROR"); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; @@ -1370,7 +1372,7 @@ int Client::gameExec() case STATE_CHANGEPASSWORD_SUCCESS: logger->log1("State: CHANGE PASSWORD SUCCESS"); mCurrentDialog = new OkDialog(_("Password Change"), - _("Password changed successfully!")); + _("Password changed successfully!"), DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself loginData.password = loginData.newPassword; @@ -1390,7 +1392,7 @@ int Client::gameExec() case STATE_CHANGEEMAIL_SUCCESS: logger->log1("State: CHANGE EMAIL SUCCESS"); mCurrentDialog = new OkDialog(_("Email Change"), - _("Email changed successfully!")); + _("Email changed successfully!"), DIALOG_ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself break; @@ -1411,7 +1413,7 @@ int Client::gameExec() Net::getLoginHandler()->disconnect(); mCurrentDialog = new OkDialog(_("Unregister Successful"), - _("Farewell, come back any time...")); + _("Farewell, come back any time..."), DIALOG_ERROR); loginData.clear(); //The errorlistener sets the state to STATE_CHOOSE_SERVER mCurrentDialog->addActionListener(&errorListener); @@ -1468,7 +1470,8 @@ int Client::gameExec() case STATE_ERROR: logger->log1("State: ERROR"); logger->log("Error: %s\n", errorMessage.c_str()); - mCurrentDialog = new OkDialog(_("Error"), errorMessage); + mCurrentDialog = new OkDialog(_("Error"), + errorMessage, DIALOG_ERROR); mCurrentDialog->addActionListener(&errorListener); mCurrentDialog = nullptr; // OkDialog deletes itself Net::getGameHandler()->disconnect(); diff --git a/src/defaults.cpp b/src/defaults.cpp index 01907bfe8..cd2911192 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -229,6 +229,13 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "grabinput", false); AddDEF(configData, "gamma", 1); AddDEF(configData, "vsync", 0); + AddDEF(configData, "soundwhisper", "newmessage"); + AddDEF(configData, "soundhighlight", "reminder"); + AddDEF(configData, "soundglobal", "email"); + AddDEF(configData, "sounderror", "error"); + AddDEF(configData, "soundtrade", "start"); + AddDEF(configData, "soundinfo", "notify"); + AddDEF(configData, "soundrequest", "attention"); return configData; } diff --git a/src/game.cpp b/src/game.cpp index e016d02ff..ae8682972 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -561,7 +561,7 @@ void Game::logic() { errorMessage = _("The connection to the server was lost."); disconnectedDialog = new OkDialog(_("Network Error"), - errorMessage, false); + errorMessage, DIALOG_ERROR, false); disconnectedDialog->addActionListener(&errorListener); disconnectedDialog->requestMoveToTop(); } @@ -1796,8 +1796,8 @@ void Game::changeMap(const std::string &mapPath) if (!newMap) { logger->log("Error while loading %s", fullMap.c_str()); - new OkDialog(_("Could Not Load Map"), - strprintf(_("Error while loading %s"), fullMap.c_str())); + new OkDialog(_("Could Not Load Map"), strprintf( + _("Error while loading %s"), fullMap.c_str()), DIALOG_ERROR); } if (mCurrentMap) diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 518ed3da1..1a468d44f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -154,7 +154,8 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 8082b8d58..a58d8616b 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -144,7 +144,8 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 9f7436ad8..124476f1c 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -270,8 +270,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) else { new OkDialog(_("Error"), - _("Your name needs to be at least 4 characters."), - true, this); + _("Your name needs to be at least 4 characters."), + DIALOG_ERROR, true, this); } } else if (id == "cancel") diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index d2b74a632..b1b8009a4 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -253,7 +253,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) } else { - new OkDialog(_("Error"), _("Incorrect password")); + new OkDialog(_("Error"), _("Incorrect password"), DIALOG_ERROR); } mDeleteIndex = -1; } diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index 22acf5116..b6645db3c 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -97,7 +97,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, } setVisible(true); yesButton->requestFocus(); - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundrequest"); } void ConfirmDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp index 53e31c3c8..ca1afeaba 100644 --- a/src/gui/editserverdialog.cpp +++ b/src/gui/editserverdialog.cpp @@ -173,7 +173,7 @@ void EditServerDialog::action(const gcn::ActionEvent &event) { OkDialog *dlg = new OkDialog(_("Error"), _("Please at least type both the address and the port " - "of the server.")); + "of the server."), DIALOG_ERROR); dlg->addActionListener(this); } else diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 4a3bdf731..fe22cf008 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -22,6 +22,8 @@ #include "gui/okdialog.h" +#include "sound.h" + #include "gui/gui.h" #include "gui/widgets/button.h" @@ -34,7 +36,8 @@ #include "debug.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, - bool modal, bool showCenter, Window *parent): + int soundEvent, bool modal, bool showCenter, + Window *parent): Window(title, modal, parent, "ok.xml") { mTextBox = new TextBox; @@ -71,6 +74,11 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, centerHorisontally(); setVisible(true); okButton->requestFocus(); + + if (soundEvent == DIALOG_OK) + sound.playGuiSound("soundinfo"); + else if (soundEvent == DIALOG_ERROR) + sound.playGuiSound("sounderror"); } void OkDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 5705be568..b6f17480b 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -31,6 +31,13 @@ class TextBox; +enum +{ + DIALOG_OK = 0, + DIALOG_ERROR, + DIALOG_SILENCE +}; + /** * An 'Ok' button dialog. * @@ -45,8 +52,8 @@ class OkDialog : public Window, public gcn::ActionListener * @see Window::Window */ OkDialog(const std::string &title, const std::string &msg, - bool modal = true, bool showCenter = true, - Window *parent = nullptr); + int soundEvent = DIALOG_OK, bool modal = true, + bool showCenter = true, Window *parent = nullptr); /** * Called when receiving actions from the widgets. diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 2122e0d6b..bf0cb299e 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMsg); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg, DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 1f7db484c..a4c3110d9 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -25,9 +25,11 @@ #include "configuration.h" #include "sound.h" +#include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" @@ -35,6 +37,19 @@ #include "debug.h" +class SoundsModel : public NamesModel +{ +public: + SoundsModel() + { + mNames.push_back(gettext("(no sound)")); + Theme::fillSoundsList(mNames); + } + + virtual ~SoundsModel() + { } +}; + Setup_Audio::Setup_Audio() { setName(_("Audio")); @@ -44,6 +59,10 @@ Setup_Audio::Setup_Audio() ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); + mSoundModel = new SoundsModel(); + + new SetupItemLabel(_("Basic settings"), "", this); + new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent"); new SetupItemCheckBox(_("Enable music"), "", @@ -61,6 +80,31 @@ Setup_Audio::Setup_Audio() new SetupItemSlider(_("Music volume"), "", "musicVolume", this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true); + new SetupItemLabel(_("Sound effects"), "", this); + + new SetupItemSound(_("Information dialog sound"), "", + "soundinfo", this, "soundinfoEvent", mSoundModel); + + new SetupItemSound(_("Request dialog sound"), "", + "soundrequest", this, "soundrequestEvent", mSoundModel); + + new SetupItemSound(_("Whisper message sound"), "", + "soundwhisper", this, "soundwhisperEvent", mSoundModel); + + new SetupItemSound(_("Highlight message sound"), "", + "soundhighlight", this, "soundhighlightEvent", mSoundModel); + + new SetupItemSound(_("Global message sound"), "", + "soundglobal", this, "soundglobalEvent", mSoundModel); + + new SetupItemSound(_("Error message sound"), "", + "sounderror", this, "sounderrorEvent", mSoundModel); + + new SetupItemSound(_("Trade request sound"), "", + "soundtrade", this, "soundtradeEvent", mSoundModel); + + new SetupItemLabel(_("Other"), "", this); + new SetupItemCheckBox(_("Enable mumble voice chat"), "", "enableMumble", this, "enableMumbleEvent"); @@ -70,6 +114,12 @@ Setup_Audio::Setup_Audio() setDimension(gcn::Rectangle(0, 0, 550, 350)); } +Setup_Audio::~Setup_Audio() +{ + delete mSoundModel; + mSoundModel = nullptr; +} + void Setup_Audio::apply() { SetupTabScroll::apply(); diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index c08c49c7a..21b661bcb 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -34,7 +34,12 @@ class Setup_Audio : public SetupTabScroll public: Setup_Audio(); + ~Setup_Audio(); + void apply(); + + private: + gcn::ListModel *mSoundModel; }; #endif diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index bdd7c2083..ef024c5d9 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -131,7 +131,7 @@ void Setup_Keyboard::apply() if (keyboard.hasConflicts()) { new OkDialog(_("Key Conflict(s) Detected."), - keyboard.getBindError()); + keyboard.getBindError(), DIALOG_ERROR); } keyboard.setEnabled(true); keyboard.store(); diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index d3b9d0e3c..7386f496a 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -349,8 +349,8 @@ void Setup_Theme::apply() if (config.getValue("theme", config.getValue("selectedSkin", "")) != mTheme) { - new OkDialog(_("Theme Changed"), - _("Restart your client for the change to take effect.")); + new OkDialog(_("Theme Changed"), _("Restart your client for " + "the change to take effect.")); } config.setValue("selectedSkin", ""); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 6690f1452..24d42c83d 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -393,7 +393,7 @@ void Setup_Video::apply() else { new OkDialog(_("Switching to Full Screen"), - _("Restart needed for changes to take effect.")); + _("Restart needed for changes to take effect.")); } #endif config.setValue("screen", fullscreen); @@ -406,7 +406,7 @@ void Setup_Video::apply() // OpenGL can currently only be changed by restarting, notify user. new OkDialog(_("Changing to OpenGL"), - _("Applying change to OpenGL requires restart.")); + _("Applying change to OpenGL requires restart.")); } mFps = mFpsCheckBox->isSelected() ? @@ -498,13 +498,17 @@ void Setup_Video::action(const gcn::ActionEvent &event) { #if defined(_WIN32) if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) + { new OkDialog(_("Screen Resolution Changed"), - _("Restart your client for the change to take effect.") - + std::string("\n") + - _("Some windows may be moved to fit the lowered resolution.")); + _("Restart your client for the change to take effect.") + + std::string("\n") + _("Some windows may be moved to " + "fit the lowered resolution.")); + } else + { new OkDialog(_("Screen Resolution Changed"), - _("Restart your client for the change to take effect.")); + _("Restart your client for the change to take effect.")); + } #else Client::resize(width, height); #endif diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 1a27b8b0c..33ab32ca5 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -753,7 +753,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode) if (config.getBoolValue("autoShop")) { - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundtrade"); startTrade(); } else diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 287089790..f0ac9e128 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1630,13 +1630,13 @@ void SocialWindow::showPartyCreate() if (player_node->getParty()) { new OkDialog(_("Create Party"), - _("Cannot create party. You are already in a party"), - this); + _("Cannot create party. You are already in a party"), + DIALOG_ERROR, true, true, this); return; } mPartyCreateDialog = new TextDialog(_("Party Name"), - _("Choose your party's name."), this); + _("Choose your party's name."), this); mPartyCreateDialog->setActionEventId("create party"); mPartyCreateDialog->addActionListener(this); } diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index ca21263f1..9ba895ec8 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -134,7 +134,8 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); + OkDialog *dlg = new OkDialog(_("Error"), + errorMsg.str(), DIALOG_ERROR); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 018e35030..53842e887 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -301,7 +301,7 @@ void ChatTab::chatLog(std::string line, Own own, && !Client::getInputFocused())))) { if (own != BY_SERVER) - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundwhisper"); } } } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 581002a58..9eedfd58d 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "main.h" #include "logger.h" +#include "sound.h" #include "gui/editdialog.h" #include "gui/gui.h" @@ -872,7 +873,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::SetupItemSliderList(std::string text, @@ -892,7 +893,7 @@ SetupItemSliderList::SetupItemSliderList(std::string text, mOnTheFly(onTheFly) { mValueType = VSTR; - createControls(); +// createControls(); } SetupItemSliderList::~SetupItemSliderList() @@ -917,6 +918,8 @@ void SetupItemSliderList::createControls() mHorizont->add(mLabel, 5); mHorizont->add(mSlider); + addMoreControls(); + mParent->getContainer()->add2(mHorizont, true, 4); mParent->addControl(this); mParent->addActionListener(this); @@ -954,3 +957,36 @@ void SetupItemSliderList::apply(std::string eventName) fromWidget(); save(); } + +SetupItemSound::SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width, bool onTheFly, bool mainConfig) : + SetupItemSliderList(text, description, keyName, parent, eventName, + model, width, onTheFly, mainConfig), + mButton(nullptr) +{ + createControls(); +} + +void SetupItemSound::addMoreControls() +{ + mButton = new Button(_("Play"), mEventName + "_PLAY", this); + mHorizont->add(mButton); +} + +void SetupItemSound::action(const gcn::ActionEvent &event) +{ + if (event.getId() == mEventName + "_PLAY") + { + if (mSlider->getSelected()) + { + sound.playGuiSfx(branding.getStringValue("systemsounds") + + mSlider->getSelectedString() + ".ogg"); + } + } + else + { + SetupItemSliderList::action(event); + } +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index f883a5b94..38dec929e 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -377,10 +377,12 @@ class SetupItemSliderList : public SetupItem void toWidget(); - void action(const gcn::ActionEvent &event); + virtual void action(const gcn::ActionEvent &event); void apply(std::string eventName); + virtual void addMoreControls() = 0; + protected: HorizontContainer *mHorizont; Label *mLabel; @@ -390,4 +392,21 @@ class SetupItemSliderList : public SetupItem bool mOnTheFly; }; +class SetupItemSound : public SetupItemSliderList +{ + public: + SetupItemSound(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + int width = 150, bool onTheFly = false, + bool mainConfig = true); + + void action(const gcn::ActionEvent &event); + + void addMoreControls(); + + protected: + Button *mButton; +}; + #endif diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index a7b1a564c..b2239834d 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -63,6 +63,9 @@ class SliderList : public Container, void adjustSize(); + int getSelected() + { return mSelectedIndex; } + protected: void updateLabel(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 5114f868c..de1304240 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2204,7 +2204,8 @@ void LocalPlayer::changeAwayMode() if (outfitWindow) outfitWindow->wearAwayOutfit(); mAwayDialog = new OkDialog(_("Away"), - config.getStringValue("afkMessage"), true, false); + config.getStringValue("afkMessage"), + DIALOG_SILENCE, true, false); mAwayDialog->addActionListener(mAwayListener); sound.volumeOff(); } @@ -4147,7 +4148,7 @@ void LocalPlayer::checkNewName(Being *being) if (!mWaitFor.empty() && mWaitFor == nick) { debugMsg(_("You see ") + mWaitFor); - sound.playGuiSfx("system/newmessage.ogg"); + sound.playGuiSound("soundinfo"); mWaitFor = ""; } } diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 2dc51acf3..67894b0d9 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -167,7 +167,7 @@ void CharServerHandler::processCharCreateFailed(Net::MessageIn &msg) errorMessage = _("Incorrect race."); break; } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); if (mCharCreateDialog) mCharCreateDialog->unlock(); } @@ -185,7 +185,7 @@ void CharServerHandler::processCharDelete(Net::MessageIn &msg A_UNUSED) void CharServerHandler::processCharDeleteFailed(Net::MessageIn &msg A_UNUSED) { unlockCharSelectDialog(); - new OkDialog(_("Error"), _("Failed to delete character.")); + new OkDialog(_("Error"), _("Failed to delete character."), DIALOG_ERROR); } void CharServerHandler::clear() diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 6d021d6a9..c8c870dbd 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -101,7 +101,7 @@ void GameHandler::processCharSwitchResponse(Net::MessageIn &msg) void GameHandler::processMapQuitResponse(Net::MessageIn &msg) { if (msg.readInt8()) - new OkDialog(_("Game"), _("Request to quit denied!"), nullptr); + new OkDialog(_("Game"), _("Request to quit denied!"), DIALOG_ERROR); } } // namespace Ea diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 27aa4da80..ddcf7d9c0 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -336,7 +336,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) weightNotice = new OkDialog(_("Message"), _("You are carrying more than " "half your weight. You are " - "unable to regain health."), false); + "unable to regain health."), DIALOG_ERROR, false); weightNotice->addActionListener( &weightListener); } @@ -346,7 +346,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) weightNotice = new OkDialog(_("Message"), _("You are carrying less than " "half your weight. You " - "can regain health."), false); + "can regain health."), DIALOG_ERROR, false); weightNotice->addActionListener( &weightListener); } @@ -426,8 +426,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) if (PlayerInfo::getAttribute(HP) == 0 && !deathNotice) { deathNotice = new OkDialog(_("Message"), - randomDeathMessage(), - false); + randomDeathMessage(), false); deathNotice->addActionListener(&deathListener); player_node->setAction(Being::DEAD); } diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index cef4f497a..9468baaa1 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -335,7 +335,8 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg) }; std::string message(deadMsg[rand() % 13]); message.append(std::string(" ") + _("Press OK to respawn.")); - OkDialog *dlg = new OkDialog(_("You Died"), message, false); + OkDialog *dlg = new OkDialog(_("You Died"), + message, DIALOG_OK, false); dlg->addActionListener(&(ManaServ::respawnListener)); } } diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 300af5a2b..7977df909 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -181,7 +181,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) errorMessage = _("Unknown error."); break; } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); if (mCharCreateDialog) mCharCreateDialog->unlock(); @@ -224,7 +224,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg) default: errorMessage = strprintf(_("Unknown error (%d)."), errMsg); } - new OkDialog(_("Error"), errorMessage); + new OkDialog(_("Error"), errorMessage, DIALOG_ERROR); } mSelectedCharacter = 0; unlockCharSelectDialog(); diff --git a/src/sound.cpp b/src/sound.cpp index 25b37d578..2c7ecb53d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -325,6 +325,12 @@ void Sound::playSfx(const std::string &path, int x, int y) } } +void Sound::playGuiSound(const std::string &name) +{ + playGuiSfx(branding.getStringValue("systemsounds") + + config.getStringValue(name) + ".ogg"); +} + void Sound::playGuiSfx(const std::string &path) { if (!mInstalled || path.empty() || !mPlayGui) diff --git a/src/sound.h b/src/sound.h index 7f9fb64a4..cfa847a0b 100644 --- a/src/sound.h +++ b/src/sound.h @@ -109,6 +109,8 @@ class Sound : public ConfigListener */ void playGuiSfx(const std::string &path); + void playGuiSound(const std::string &name); + void changeAudio(); void volumeOff(); |