1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Improve CButton::block and fix CToggleGroup->selectedID

CToggleGroup. Originally when I added initialization for selectedID I didn't find out that -1 is used for "random" buttons. So as result I fixed uninitialized variable usage, but break initial button state change in RMG options because setSelected ignore state change request because it's see -1 button already marked as selected.
This commit is contained in:
ArseniyShestakov 2015-03-16 15:55:36 +03:00
parent 120301ecc8
commit 448fbe44e9

View File

@ -144,7 +144,8 @@ bool CButton::isHighlighted()
void CButton::block(bool on)
{
setState(on?BLOCKED:NORMAL);
if(on || state == BLOCKED) //dont change button state if unblock requested, but it's not blocked
setState(on ? BLOCKED : NORMAL);
}
void CButton::onButtonClicked()
@ -424,7 +425,7 @@ void CToggleGroup::addToggle(int identifier, CToggleBase* bt)
}
CToggleGroup::CToggleGroup(const CFunctionList<void(int)> &OnChange, bool musicLikeButtons)
: onChange(OnChange), selectedID(-1), musicLike(musicLikeButtons)
: onChange(OnChange), selectedID(-2), musicLike(musicLikeButtons)
{}
void CToggleGroup::setSelected(int id)