Show tooltip for non-affordable list items (Fixes #2025)

openmw-33
scrawl 10 years ago
parent 2106893563
commit 2be65a89a7

@ -73,7 +73,7 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
MyGUI::Button* button = MyGUI::Button* button =
mList->createWidget<MyGUI::Button>("SandTextButton", mList->createWidget<MyGUI::Button>(price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, 0,
currentY, currentY,
0, 0,
@ -83,7 +83,6 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
currentY += 18; currentY += 18;
button->setEnabled(price<=playerGold);
button->setUserString("Price", boost::lexical_cast<std::string>(price)); button->setUserString("Price", boost::lexical_cast<std::string>(price));
button->setUserData(*iter); button->setUserData(*iter);
button->setCaptionWithReplacing(name); button->setCaptionWithReplacing(name);
@ -124,6 +123,10 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
{ {
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
int price = boost::lexical_cast<int>(sender->getUserString("Price"));
if (price > player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId))
return;
// repair // repair
MWWorld::Ptr item = *sender->getUserData<MWWorld::Ptr>(); MWWorld::Ptr item = *sender->getUserData<MWWorld::Ptr>();
item.getCellRef().setCharge(item.getClass().getItemMaxHealth(item)); item.getCellRef().setCharge(item.getClass().getItemMaxHealth(item));
@ -132,7 +135,6 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender)
MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1); MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1);
int price = boost::lexical_cast<int>(sender->getUserString("Price"));
player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player); player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player);

@ -54,14 +54,13 @@ namespace MWGui
MyGUI::Button* toAdd = MyGUI::Button* toAdd =
mSpellsView->createWidget<MyGUI::Button>( mSpellsView->createWidget<MyGUI::Button>(
"SandTextButton", price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, 0,
mCurrentY, mCurrentY,
200, 200,
sLineHeight, sLineHeight,
MyGUI::Align::Default MyGUI::Align::Default
); );
toAdd->setEnabled(price<=playerGold);
mCurrentY += sLineHeight; mCurrentY += sLineHeight;
@ -140,6 +139,9 @@ namespace MWGui
int price = *_sender->getUserData<int>(); int price = *_sender->getUserData<int>();
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
if (price > player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId))
return;
MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player);
MWMechanics::Spells& spells = stats.getSpells(); MWMechanics::Spells& spells = stats.getSpells();
spells.add (mSpellsWidgetMap.find(_sender)->second); spells.add (mSpellsWidgetMap.find(_sender)->second);

@ -93,10 +93,9 @@ namespace MWGui
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer
(mPtr,pcStats.getSkill (skills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true); (mPtr,pcStats.getSkill (skills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true);
MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>("SandTextButton", MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
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(skills[i].first); button->setUserData(skills[i].first);
button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected); button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);
@ -133,6 +132,9 @@ 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 (price > player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId))
return;
MWMechanics::NpcStats& npcStats = mPtr.getClass().getNpcStats (mPtr); MWMechanics::NpcStats& npcStats = mPtr.getClass().getNpcStats (mPtr);
if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ()) if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ())
{ {

@ -100,6 +100,14 @@ color_misc=0,205,205 # ????
</BasisSkin> </BasisSkin>
</Resource> </Resource>
<Resource type="ResourceSkin" name="SandTextButtonDisabled" size="16 16">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Left Bottom"/>
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch">
<State name="normal" colour="#{fontcolour=disabled}" shift="0"/>
</BasisSkin>
</Resource>
<Resource type="ResourceSkin" name="SpellTextUnequipped" size="16 16"> <Resource type="ResourceSkin" name="SpellTextUnequipped" size="16 16">
<Property key="FontName" value="Default"/> <Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Left Bottom"/> <Property key="TextAlign" value="Left Bottom"/>

Loading…
Cancel
Save