Don't play "Menu Click" sound for disabled (= cannot receive input) buttons, plus some redundancy fixes

actorid
scrawl 11 years ago
parent 0f5dc59176
commit d7f69205f6

@ -68,8 +68,7 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
MyGUI::Button* button = MyGUI::Button* button =
mList->createWidget<MyGUI::Button>( mList->createWidget<MyGUI::Button>("SandTextButton",
(price>playerGold) ? "SandTextGreyedOut" : "SandTextButton",
0, 0,
currentY, currentY,
0, 0,

@ -45,13 +45,14 @@ namespace MWGui
MyGUI::Button* toAdd = MyGUI::Button* toAdd =
mSpellsView->createWidget<MyGUI::Button>( mSpellsView->createWidget<MyGUI::Button>(
(price>playerGold) ? "SandTextGreyedOut" : "SandTextButton", "SandTextButton",
0, 0,
mCurrentY, mCurrentY,
200, 200,
sLineHeight, sLineHeight,
MyGUI::Align::Default MyGUI::Align::Default
); );
toAdd->setEnabled(price<=playerGold);
mCurrentY += sLineHeight; mCurrentY += sLineHeight;
@ -117,11 +118,6 @@ namespace MWGui
{ {
int price = *_sender->getUserData<int>(); int price = *_sender->getUserData<int>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
if (playerGold>=price)
{
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells(); MWMechanics::Spells& spells = stats.getSpells();
@ -131,7 +127,6 @@ namespace MWGui
MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0);
} }
}
void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender) void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender)
{ {

@ -83,11 +83,10 @@ namespace MWGui
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer
(mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true); (mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true);
std::string skin = (price > playerGold) ? "SandTextGreyedOut" : "SandTextButton"; MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>("SandTextButton",
MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(skin,
MyGUI::IntCoord(5, 5+i*18, mTrainingOptions->getWidth()-10, 18), MyGUI::Align::Default); MyGUI::IntCoord(5, 5+i*18, mTrainingOptions->getWidth()-10, 18), MyGUI::Align::Default);
button->setEnabled(price <= playerGold);
button->setUserData(bestSkills[i].first); button->setUserData(bestSkills[i].first);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected); button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);
@ -116,7 +115,6 @@ namespace MWGui
int skillId = *sender->getUserData<int>(); int skillId = *sender->getUserData<int>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
const MWWorld::ESMStore &store = const MWWorld::ESMStore &store =
@ -125,9 +123,6 @@ namespace MWGui
int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt (); int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt ();
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
if (playerGold<price)
return;
MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mPtr).getNpcStats (mPtr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mPtr).getNpcStats (mPtr);
if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ()) if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ())
{ {

@ -66,7 +66,8 @@ namespace MWGui
price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true);
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>playerGold) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>("SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default);
toAdd->setEnabled(price<=playerGold);
mCurrentY += sLineHeight; mCurrentY += sLineHeight;
if(interior) if(interior)
toAdd->setUserString("interior","y"); toAdd->setUserString("interior","y");

@ -555,7 +555,7 @@ namespace MWInput
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
{ {
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false); MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
if (b) if (b && b->getEnabled())
{ {
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f);
} }

@ -17,14 +17,6 @@
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/> <BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin> </Skin>
<!-- HTML colour: #9A9074 -->
<Skin name="SandTextGreyedOut" size="16 16">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Left Bottom"/>
<Property key="TextColour" value="0.6 0.56 0.45"/>
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin>
<!-- HTML colour: #BF9959 --> <!-- HTML colour: #BF9959 -->
<Skin name="SandText" size="16 16"> <Skin name="SandText" size="16 16">
<Property key="FontName" value="Default"/> <Property key="FontName" value="Default"/>

Loading…
Cancel
Save