Opened 13 years ago

Closed 11 years ago

Last modified 5 years ago

#948 closed enhancement (fixed)

[PATCH] Add buttonSound attribute to buttons

Reported by: brian Owned by: historic_bruno
Priority: Nice to Have Milestone: Alpha 14
Component: Core engine Keywords: patch simple
Cc: matt@… Patch:

Description (last modified by brian)

We want all buttons to sound the same. To avoid editing all the onPress functions scattered throughout, we should add an attribute that can reference the sound file. Ideally, this attribute would be included in the style so it would only have to be changed in one place.

It will probably involve adding another GUI property and making CButton detect it and do whatever PlaySound does.

Attachments (1)

948_ButtonSoundAttribute.patch (2.8 KB ) - added by Matt Lott 12 years ago.
This adds a button_sound attribute to buttons.

Download all attachments as: .zip

Change History (13)

comment:1 by brian, 13 years ago

Description: modified (diff)
Keywords: simple added

comment:2 by historic_bruno, 12 years ago

Owner: Sound Department removed

comment:3 by historic_bruno, 12 years ago

Component: Music & Sound FXCore engine

by Matt Lott, 12 years ago

This adds a button_sound attribute to buttons.

comment:4 by Matt Lott, 12 years ago

Cc: matt@… added
Keywords: review added
Milestone: BacklogAlpha 10
Summary: Add buttonSound attribute to buttons[PATCH] Add buttonSound attribute to buttons

comment:5 by Matt Lott, 12 years ago

948_ButtonSoundAttribute.patch​ and 948_ButtonSoundAttribute.2.patch​ are identical. I accidentally hit enter twice, and couldn't figure out how to remove one.

I tested the patch on Win7 by modifying the button_sound attribute via a new default_button style, the StoneButtonFancy style, and directly on the main menu single player button. Everything worked as expected.

comment:6 by Kieran P, 12 years ago

Keywords: patch added

comment:7 by Kieran P, 12 years ago

Milestone: Alpha 10Alpha 11

Hey mattlott. Thanks for your patch. We currently have someone working on a rewritten sound engine, at which point, your patch might not apply anymore.

So I'm going to push this to the next release, when the sound engine should hopefully be done in some basic form, and we'll reevaluate your work then.

Meantime, please feel free to take up another ticket and have a crack at completing it.

comment:8 by historic_bruno, 12 years ago

Keywords: review removed
Milestone: Alpha 11Alpha 12

I don't like the "default_button" style hack in CGUI.cpp, or at least I don't like it being hard coded that way, because then we have to potentially consider a default style for every other type of control, it would get messy in a hurry :) It's no big deal to leave "button_sound" as an optional property and make each button style set it - we don't have many button styles. Maybe we need style inheritance...

GUIM_PRESSED seems to be the wrong event handler for the sound, because it's confusingly sent after the button is released or activated in some other way. It seems like normally a button plays one sound when it's pressed and a different sound when it's released. It would be handy to have a few sound types with clear property names like "sound_pressed", "sound_released", "sound_pressed_disabled", to have symmetry with the other properties.

comment:9 by Kieran P, 11 years ago

Milestone: Alpha 12Backlog

Backlogged until the additional work is completed.

comment:10 by historic_bruno, 11 years ago

Milestone: BacklogAlpha 14
Owner: set to historic_bruno
Status: newassigned

comment:11 by ben, 11 years ago

Resolution: fixed
Status: assignedclosed

In 13521:

Adds UI sounds for buttons, dropdowns, lists, and checkboxes, fixes #948

comment:12 by elexis, 5 years ago

In 22756:

Introduce IGUIObject::PlaySound to unify 19 copies of the UI sound play following rP13521, refs #948.

Stops copying the CStrW each time a sound is played by using the reference GetSetting variant.

Differential Revision: https://code.wildfiregames.com/D2209

Note: See TracTickets for help on using tickets.