diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 0fa9121b7d..e67a8512a5 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -173,6 +173,11 @@ namespace MWGui void AlchemyWindow::update() { + std::string suggestedName = mAlchemy.suggestPotionName(); + if (suggestedName != mSuggestedPotionName) + mNameEdit->setCaptionWithReplacing(suggestedName); + mSuggestedPotionName = suggestedName; + mSortModel->clearDragItems(); MWMechanics::Alchemy::TIngredientsIterator it = mAlchemy.beginIngredients (); diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index b538a1f808..36f540c1b6 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -23,6 +23,8 @@ namespace MWGui virtual void exit(); private: + std::string mSuggestedPotionName; + ItemView* mItemView; SortFilterItemModel* mSortModel; diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 5549c85ede..328f3a25d9 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -480,3 +480,14 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na return Result_Success; } + +std::string MWMechanics::Alchemy::suggestPotionName() +{ + std::set effects = listEffects(); + if (effects.empty()) + return ""; + + int effectId = effects.begin()->mId; + return MWBase::Environment::get().getWorld()->getStore().get().find( + ESM::MagicEffect::effectIdToString(effectId)); +} diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index c96356ebbe..caba26f149 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -109,6 +109,9 @@ namespace MWMechanics void removeIngredient (int index); ///< Remove ingredient from slot (calling this function on an empty slot is a no-op). + std::string suggestPotionName (); + ///< Suggest a name for the potion, based on the current effects + Result create (const std::string& name); ///< Try to create a potion from the ingredients, place it in the inventory of the alchemist and /// adjust the skills of the alchemist accordingly.