1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 13:23:53 +00:00

Fix enchanting dialog effect labels showing a duration for constant effects

This commit is contained in:
scrawl 2015-01-05 05:33:51 +01:00
parent 5e7e40aac9
commit c1955ef7fa
3 changed files with 32 additions and 11 deletions

View file

@ -120,19 +120,19 @@ namespace MWGui
{ {
case ESM::Enchantment::CastOnce: case ESM::Enchantment::CastOnce:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastOnce","Cast Once"));
mAddEffectDialog.constantEffect=false; setConstantEffect(false);
break; break;
case ESM::Enchantment::WhenStrikes: case ESM::Enchantment::WhenStrikes:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenStrikes", "When Strikes"));
mAddEffectDialog.constantEffect=false; setConstantEffect(false);
break; break;
case ESM::Enchantment::WhenUsed: case ESM::Enchantment::WhenUsed:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastWhenUsed", "When Used"));
mAddEffectDialog.constantEffect=false; setConstantEffect(false);
break; break;
case ESM::Enchantment::ConstantEffect: case ESM::Enchantment::ConstantEffect:
mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant")); mTypeButton->setCaption(MWBase::Environment::get().getWindowManager()->getGameSettingString("sItemCastConstant", "Cast Constant"));
mAddEffectDialog.constantEffect=true; setConstantEffect(true);
break; break;
} }
} }
@ -283,6 +283,7 @@ namespace MWGui
{ {
mEnchanting.nextCastStyle(); mEnchanting.nextCastStyle();
updateLabels(); updateLabels();
updateEffectsView();
} }
void EnchantingDialog::onBuyButtonClicked(MyGUI::Widget* sender) void EnchantingDialog::onBuyButtonClicked(MyGUI::Widget* sender)

View file

@ -42,6 +42,7 @@ namespace MWGui
: WindowModal("openmw_edit_effect.layout") : WindowModal("openmw_edit_effect.layout")
, mEditing(false) , mEditing(false)
, mMagicEffect(NULL) , mMagicEffect(NULL)
, mConstantEffect(false)
{ {
getWidget(mCancelButton, "CancelButton"); getWidget(mCancelButton, "CancelButton");
getWidget(mOkButton, "OkButton"); getWidget(mOkButton, "OkButton");
@ -71,7 +72,11 @@ namespace MWGui
mMagnitudeMaxSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMaxChanged); mMagnitudeMaxSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMaxChanged);
mDurationSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onDurationChanged); mDurationSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onDurationChanged);
mAreaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onAreaChanged); mAreaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onAreaChanged);
constantEffect=false; }
void EditEffectDialog::setConstantEffect(bool constant)
{
mConstantEffect = constant;
} }
void EditEffectDialog::open() void EditEffectDialog::open()
@ -92,8 +97,8 @@ namespace MWGui
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect) void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
{ {
bool allowSelf = effect->mData.mFlags & ESM::MagicEffect::CastSelf; bool allowSelf = effect->mData.mFlags & ESM::MagicEffect::CastSelf;
bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !constantEffect; bool allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect;
bool allowTarget = (effect->mData.mFlags & ESM::MagicEffect::CastTarget) && !constantEffect; bool allowTarget = (effect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect;
if (!allowSelf && !allowTouch && !allowTarget) if (!allowSelf && !allowTouch && !allowTarget)
return; // TODO: Show an error message popup? return; // TODO: Show an error message popup?
@ -183,7 +188,7 @@ namespace MWGui
mMagnitudeBox->setVisible (true); mMagnitudeBox->setVisible (true);
curY += mMagnitudeBox->getSize().height; curY += mMagnitudeBox->getSize().height;
} }
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)&&constantEffect==false) if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)&&mConstantEffect==false)
{ {
mDurationBox->setPosition(mDurationBox->getPosition().left, curY); mDurationBox->setPosition(mDurationBox->getPosition().left, curY);
mDurationBox->setVisible (true); mDurationBox->setVisible (true);
@ -204,8 +209,8 @@ namespace MWGui
// cycle through range types until we find something that's allowed // cycle through range types until we find something that's allowed
// does not handle the case where nothing is allowed (this should be prevented before opening the Add Effect dialog) // does not handle the case where nothing is allowed (this should be prevented before opening the Add Effect dialog)
bool allowSelf = mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf; bool allowSelf = mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf;
bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !constantEffect; bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !mConstantEffect;
bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !constantEffect; bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !mConstantEffect;
if (mEffect.mRange == ESM::RT_Self && !allowSelf) if (mEffect.mRange == ESM::RT_Self && !allowSelf)
mEffect.mRange = (mEffect.mRange+1)%3; mEffect.mRange = (mEffect.mRange+1)%3;
if (mEffect.mRange == ESM::RT_Touch && !allowTouch) if (mEffect.mRange == ESM::RT_Touch && !allowTouch)
@ -468,6 +473,7 @@ namespace MWGui
, mSelectedEffect(0) , mSelectedEffect(0)
, mSelectedKnownEffectId(0) , mSelectedKnownEffectId(0)
, mType(type) , mType(type)
, mConstantEffect(false)
{ {
mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded); mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded);
mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &EffectEditorBase::onEffectModified); mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &EffectEditorBase::onEffectModified);
@ -659,6 +665,7 @@ namespace MWGui
params.mMagnMax = it->mMagnMax; params.mMagnMax = it->mMagnMax;
params.mRange = it->mRange; params.mRange = it->mRange;
params.mArea = it->mArea; params.mArea = it->mArea;
params.mIsConstant = mConstantEffect;
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);
button->setUserData(i); button->setUserData(i);
@ -703,4 +710,10 @@ namespace MWGui
mAddEffectDialog.editEffect (mEffects[id]); mAddEffectDialog.editEffect (mEffects[id]);
mAddEffectDialog.setVisible (true); mAddEffectDialog.setVisible (true);
} }
void EffectEditorBase::setConstantEffect(bool constant)
{
mAddEffectDialog.setConstantEffect(constant);
mConstantEffect = constant;
}
} }

View file

@ -23,12 +23,13 @@ namespace MWGui
virtual void open(); virtual void open();
virtual void exit(); virtual void exit();
void setConstantEffect(bool constant);
void setSkill(int skill); void setSkill(int skill);
void setAttribute(int attribute); void setAttribute(int attribute);
void newEffect (const ESM::MagicEffect* effect); void newEffect (const ESM::MagicEffect* effect);
void editEffect (ESM::ENAMstruct effect); void editEffect (ESM::ENAMstruct effect);
bool constantEffect;
typedef MyGUI::delegates::CMultiDelegate1<ESM::ENAMstruct> EventHandle_Effect; typedef MyGUI::delegates::CMultiDelegate1<ESM::ENAMstruct> EventHandle_Effect;
EventHandle_Effect eventEffectAdded; EventHandle_Effect eventEffectAdded;
@ -82,6 +83,8 @@ namespace MWGui
ESM::ENAMstruct mOldEffect; ESM::ENAMstruct mOldEffect;
const ESM::MagicEffect* mMagicEffect; const ESM::MagicEffect* mMagicEffect;
bool mConstantEffect;
}; };
@ -97,6 +100,8 @@ namespace MWGui
EffectEditorBase(Type type); EffectEditorBase(Type type);
virtual ~EffectEditorBase(); virtual ~EffectEditorBase();
void setConstantEffect(bool constant);
protected: protected:
std::map<int, short> mButtonMapping; // maps button ID to effect ID std::map<int, short> mButtonMapping; // maps button ID to effect ID
@ -110,6 +115,8 @@ namespace MWGui
int mSelectedEffect; int mSelectedEffect;
short mSelectedKnownEffectId; short mSelectedKnownEffectId;
bool mConstantEffect;
std::vector<ESM::ENAMstruct> mEffects; std::vector<ESM::ENAMstruct> mEffects;
void onEffectAdded(ESM::ENAMstruct effect); void onEffectAdded(ESM::ENAMstruct effect);