mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04:00
improved the ingredient GUI code (this didnt fix anything, though)
This commit is contained in:
parent
475163bd4a
commit
b2b9254718
@ -151,46 +151,15 @@ namespace MWGui
|
|||||||
void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender)
|
void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
removeIngredient(_sender);
|
removeIngredient(_sender);
|
||||||
drawItems();
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlchemyWindow::onSelectedItemImpl(MWWorld::Ptr item)
|
void AlchemyWindow::onSelectedItemImpl(MWWorld::Ptr item)
|
||||||
{
|
{
|
||||||
MyGUI::ImageBox* add = NULL;
|
int res = mAlchemy.addIngredient(item);
|
||||||
|
|
||||||
// don't allow to add an ingredient that is already added
|
if (res != -1)
|
||||||
// (which could happen if two similiar ingredients don't stack because of script / owner)
|
|
||||||
bool alreadyAdded = false;
|
|
||||||
std::string name = MWWorld::Class::get(item).getName(item);
|
|
||||||
for (int i=0; i<4; ++i)
|
|
||||||
if (mIngredients[i]->isUserString("ToolTipType"))
|
|
||||||
{
|
|
||||||
MWWorld::Ptr item2 = *mIngredients[i]->getUserData<MWWorld::Ptr>();
|
|
||||||
std::string name2 = MWWorld::Class::get(item2).getName(item2);
|
|
||||||
if (name == name2)
|
|
||||||
alreadyAdded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alreadyAdded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i=0; i<4; ++i)
|
|
||||||
if (!mIngredients[i]->isUserString("ToolTipType"))
|
|
||||||
{
|
|
||||||
add = mIngredients[i];
|
|
||||||
|
|
||||||
mAlchemy.addIngredient(item);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (add != NULL)
|
|
||||||
{
|
{
|
||||||
add->setUserString("ToolTipType", "ItemPtr");
|
|
||||||
add->setUserData(item);
|
|
||||||
add->setImageTexture(getIconPath(item));
|
|
||||||
drawItems();
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
|
std::string sound = MWWorld::Class::get(item).getUpSoundId(item);
|
||||||
@ -211,17 +180,27 @@ namespace MWGui
|
|||||||
|
|
||||||
void AlchemyWindow::update()
|
void AlchemyWindow::update()
|
||||||
{
|
{
|
||||||
|
MWMechanics::Alchemy::TIngredientsIterator it = mAlchemy.beginIngredients ();
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
{
|
{
|
||||||
MyGUI::ImageBox* ingredient = mIngredients[i];
|
MyGUI::ImageBox* ingredient = mIngredients[i];
|
||||||
|
|
||||||
if (!ingredient->isUserString("ToolTipType"))
|
MWWorld::Ptr item = *it;
|
||||||
continue;
|
++it;
|
||||||
|
|
||||||
// update ingredient count labels
|
|
||||||
if (ingredient->getChildCount())
|
if (ingredient->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0));
|
||||||
|
|
||||||
|
ingredient->setImageTexture("");
|
||||||
|
ingredient->clearUserStrings ();
|
||||||
|
|
||||||
|
if (item.isEmpty ())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ingredient->setUserString("ToolTipType", "ItemPtr");
|
||||||
|
ingredient->setUserData(item);
|
||||||
|
ingredient->setImageTexture(getIconPath(item));
|
||||||
|
|
||||||
MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label"));
|
||||||
text->setTextAlign(MyGUI::Align::Right);
|
text->setTextAlign(MyGUI::Align::Right);
|
||||||
text->setNeedMouseFocus(false);
|
text->setNeedMouseFocus(false);
|
||||||
@ -230,6 +209,8 @@ namespace MWGui
|
|||||||
text->setCaption(getCountString(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount()));
|
text->setCaption(getCountString(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawItems();
|
||||||
|
|
||||||
std::vector<ESM::ENAMstruct> effects;
|
std::vector<ESM::ENAMstruct> effects;
|
||||||
ESM::EffectList list;
|
ESM::EffectList list;
|
||||||
list.mList = effects;
|
list.mList = effects;
|
||||||
@ -256,13 +237,10 @@ namespace MWGui
|
|||||||
|
|
||||||
void AlchemyWindow::removeIngredient(MyGUI::Widget* ingredient)
|
void AlchemyWindow::removeIngredient(MyGUI::Widget* ingredient)
|
||||||
{
|
{
|
||||||
ingredient->clearUserStrings();
|
|
||||||
static_cast<MyGUI::ImageBox*>(ingredient)->setImageTexture("");
|
|
||||||
if (ingredient->getChildCount())
|
|
||||||
MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0));
|
|
||||||
|
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
if (mIngredients[i] == ingredient)
|
if (mIngredients[i] == ingredient)
|
||||||
mAlchemy.removeIngredient (i);
|
mAlchemy.removeIngredient (i);
|
||||||
|
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user