forked from teamnwah/openmw-tes3coop
Issue #61: Replaced apparatus handling in alchemy GUI with new implementation in Alchemy class
This commit is contained in:
parent
42f02f3ccd
commit
10c8360e07
2 changed files with 21 additions and 60 deletions
|
@ -28,7 +28,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager)
|
AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_alchemy_window.layout", parWindowManager)
|
: WindowBase("openmw_alchemy_window.layout", parWindowManager)
|
||||||
, ContainerBase(0)
|
, ContainerBase(0), mApparatus (4)
|
||||||
{
|
{
|
||||||
getWidget(mCreateButton, "CreateButton");
|
getWidget(mCreateButton, "CreateButton");
|
||||||
getWidget(mCancelButton, "CancelButton");
|
getWidget(mCancelButton, "CancelButton");
|
||||||
|
@ -36,10 +36,10 @@ namespace MWGui
|
||||||
getWidget(mIngredient2, "Ingredient2");
|
getWidget(mIngredient2, "Ingredient2");
|
||||||
getWidget(mIngredient3, "Ingredient3");
|
getWidget(mIngredient3, "Ingredient3");
|
||||||
getWidget(mIngredient4, "Ingredient4");
|
getWidget(mIngredient4, "Ingredient4");
|
||||||
getWidget(mApparatus1, "Apparatus1");
|
getWidget(mApparatus[0], "Apparatus1");
|
||||||
getWidget(mApparatus2, "Apparatus2");
|
getWidget(mApparatus[1], "Apparatus2");
|
||||||
getWidget(mApparatus3, "Apparatus3");
|
getWidget(mApparatus[2], "Apparatus3");
|
||||||
getWidget(mApparatus4, "Apparatus4");
|
getWidget(mApparatus[3], "Apparatus4");
|
||||||
getWidget(mEffectsBox, "CreatedEffects");
|
getWidget(mEffectsBox, "CreatedEffects");
|
||||||
getWidget(mNameEdit, "NameEdit");
|
getWidget(mNameEdit, "NameEdit");
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// check if mortar & pestle is available (always needed)
|
// check if mortar & pestle is available (always needed)
|
||||||
/// \todo check albemic, calcinator, retort (sometimes needed)
|
/// \todo check albemic, calcinator, retort (sometimes needed)
|
||||||
if (!mApparatus1->isUserString("ToolTipType"))
|
if (!mApparatus[0]->isUserString("ToolTipType"))
|
||||||
{
|
{
|
||||||
mWindowManager.messageBox("#{sNotifyMessage45}", std::vector<std::string>());
|
mWindowManager.messageBox("#{sNotifyMessage45}", std::vector<std::string>());
|
||||||
return;
|
return;
|
||||||
|
@ -253,60 +253,22 @@ namespace MWGui
|
||||||
|
|
||||||
void AlchemyWindow::open()
|
void AlchemyWindow::open()
|
||||||
{
|
{
|
||||||
openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr
|
openContainer (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr
|
||||||
setFilter(ContainerBase::Filter_Ingredients);
|
setFilter (ContainerBase::Filter_Ingredients);
|
||||||
|
|
||||||
mAlchemy.setAlchemist (mPtr);
|
mAlchemy.setAlchemist (mPtr);
|
||||||
|
|
||||||
// pick the best available apparatus
|
int index = 0;
|
||||||
MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr);
|
|
||||||
|
|
||||||
MWWorld::Ptr bestAlbemic;
|
for (MWMechanics::Alchemy::TToolsIterator iter (mAlchemy.beginTools());
|
||||||
MWWorld::Ptr bestMortarPestle;
|
iter!=mAlchemy.endTools() && index<static_cast<int> (mApparatus.size()); ++iter, ++index)
|
||||||
MWWorld::Ptr bestCalcinator;
|
|
||||||
MWWorld::Ptr bestRetort;
|
|
||||||
|
|
||||||
for (MWWorld::ContainerStoreIterator it(store.begin(MWWorld::ContainerStore::Type_Apparatus));
|
|
||||||
it != store.end(); ++it)
|
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Apparatus>* ref = it->get<ESM::Apparatus>();
|
if (!iter->isEmpty())
|
||||||
if (ref->base->data.type == ESM::Apparatus::Albemic
|
{
|
||||||
&& (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get<ESM::Apparatus>()->base->data.quality))
|
mApparatus[index]->setUserString ("ToolTipType", "ItemPtr");
|
||||||
bestAlbemic = *it;
|
mApparatus[index]->setUserData (*iter);
|
||||||
else if (ref->base->data.type == ESM::Apparatus::MortarPestle
|
mApparatus[index]->setImageTexture (getIconPath (*iter));
|
||||||
&& (bestMortarPestle.isEmpty() || ref->base->data.quality > bestMortarPestle.get<ESM::Apparatus>()->base->data.quality))
|
}
|
||||||
bestMortarPestle = *it;
|
|
||||||
else if (ref->base->data.type == ESM::Apparatus::Calcinator
|
|
||||||
&& (bestCalcinator.isEmpty() || ref->base->data.quality > bestCalcinator.get<ESM::Apparatus>()->base->data.quality))
|
|
||||||
bestCalcinator = *it;
|
|
||||||
else if (ref->base->data.type == ESM::Apparatus::Retort
|
|
||||||
&& (bestRetort.isEmpty() || ref->base->data.quality > bestRetort.get<ESM::Apparatus>()->base->data.quality))
|
|
||||||
bestRetort = *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bestMortarPestle.isEmpty())
|
|
||||||
{
|
|
||||||
mApparatus1->setUserString("ToolTipType", "ItemPtr");
|
|
||||||
mApparatus1->setUserData(bestMortarPestle);
|
|
||||||
mApparatus1->setImageTexture(getIconPath(bestMortarPestle));
|
|
||||||
}
|
|
||||||
if (!bestAlbemic.isEmpty())
|
|
||||||
{
|
|
||||||
mApparatus2->setUserString("ToolTipType", "ItemPtr");
|
|
||||||
mApparatus2->setUserData(bestAlbemic);
|
|
||||||
mApparatus2->setImageTexture(getIconPath(bestAlbemic));
|
|
||||||
}
|
|
||||||
if (!bestCalcinator.isEmpty())
|
|
||||||
{
|
|
||||||
mApparatus3->setUserString("ToolTipType", "ItemPtr");
|
|
||||||
mApparatus3->setUserData(bestCalcinator);
|
|
||||||
mApparatus3->setImageTexture(getIconPath(bestCalcinator));
|
|
||||||
}
|
|
||||||
if (!bestRetort.isEmpty())
|
|
||||||
{
|
|
||||||
mApparatus4->setUserString("ToolTipType", "ItemPtr");
|
|
||||||
mApparatus4->setUserData(bestRetort);
|
|
||||||
mApparatus4->setImageTexture(getIconPath(bestRetort));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef MWGUI_ALCHEMY_H
|
#ifndef MWGUI_ALCHEMY_H
|
||||||
#define MWGUI_ALCHEMY_H
|
#define MWGUI_ALCHEMY_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../mwmechanics/alchemy.hpp"
|
#include "../mwmechanics/alchemy.hpp"
|
||||||
|
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
|
@ -25,11 +27,6 @@ namespace MWGui
|
||||||
MyGUI::ImageBox* mIngredient3;
|
MyGUI::ImageBox* mIngredient3;
|
||||||
MyGUI::ImageBox* mIngredient4;
|
MyGUI::ImageBox* mIngredient4;
|
||||||
|
|
||||||
MyGUI::ImageBox* mApparatus1;
|
|
||||||
MyGUI::ImageBox* mApparatus2;
|
|
||||||
MyGUI::ImageBox* mApparatus3;
|
|
||||||
MyGUI::ImageBox* mApparatus4;
|
|
||||||
|
|
||||||
MyGUI::Widget* mEffectsBox;
|
MyGUI::Widget* mEffectsBox;
|
||||||
|
|
||||||
MyGUI::EditBox* mNameEdit;
|
MyGUI::EditBox* mNameEdit;
|
||||||
|
@ -52,6 +49,8 @@ namespace MWGui
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MWMechanics::Alchemy mAlchemy;
|
MWMechanics::Alchemy mAlchemy;
|
||||||
|
|
||||||
|
std::vector<MyGUI::ImageBox *> mApparatus;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue