Enchanting: fixed case where no range types at all are allowed (e.g. a Constant Effect item with an effect that does not allow the Self range-type)

moveref
scrawl 10 years ago
parent 74c345f790
commit 619ea846b4

@ -89,15 +89,22 @@ 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 allowTouch = (effect->mData.mFlags & ESM::MagicEffect::CastTouch) && !constantEffect;
bool allowTarget = (effect->mData.mFlags & ESM::MagicEffect::CastTarget) && !constantEffect;
if (!allowSelf && !allowTouch && !allowTarget)
return; // TODO: Show an error message popup?
setMagicEffect(effect); setMagicEffect(effect);
mEditing = false; mEditing = false;
mDeleteButton->setVisible (false); mDeleteButton->setVisible (false);
mEffect.mRange = ESM::RT_Self; mEffect.mRange = ESM::RT_Self;
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf)) if (!allowSelf)
mEffect.mRange = ESM::RT_Touch; mEffect.mRange = ESM::RT_Touch;
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch)) if (!allowTouch)
mEffect.mRange = ESM::RT_Target; mEffect.mRange = ESM::RT_Target;
mEffect.mMagnMin = 1; mEffect.mMagnMin = 1;
mEffect.mMagnMax = 1; mEffect.mMagnMax = 1;
@ -118,6 +125,8 @@ namespace MWGui
mMagnitudeMinValue->setCaption("1"); mMagnitudeMinValue->setCaption("1");
mMagnitudeMaxValue->setCaption("- 1"); mMagnitudeMaxValue->setCaption("- 1");
mAreaValue->setCaption("0"); mAreaValue->setCaption("0");
setVisible(true);
} }
void EditEffectDialog::editEffect (ESM::ENAMstruct effect) void EditEffectDialog::editEffect (ESM::ENAMstruct effect)
@ -190,26 +199,31 @@ namespace MWGui
{ {
mEffect.mRange = (mEffect.mRange+1)%3; mEffect.mRange = (mEffect.mRange+1)%3;
if (mEffect.mRange == ESM::RT_Self)
mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}");
else if (mEffect.mRange == ESM::RT_Target)
mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}");
else if (mEffect.mRange == ESM::RT_Touch)
mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}");
// cycle through range types until we find something that's allowed // cycle through range types until we find something that's allowed
if (mEffect.mRange == ESM::RT_Target && (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) || constantEffect)) // does not handle the case where nothing is allowed (this should be prevented before opening the Add Effect dialog)
onRangeButtonClicked(sender); bool allowSelf = mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf;
if (mEffect.mRange == ESM::RT_Self && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf)) bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !constantEffect;
onRangeButtonClicked(sender); bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !constantEffect;
if (mEffect.mRange == ESM::RT_Touch && (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) || constantEffect)) if (mEffect.mRange == ESM::RT_Self && !allowSelf)
onRangeButtonClicked(sender); mEffect.mRange = (mEffect.mRange+1)%3;
if (mEffect.mRange == ESM::RT_Touch && !allowTouch)
mEffect.mRange = (mEffect.mRange+1)%3;
if (mEffect.mRange == ESM::RT_Target && !allowTarget)
mEffect.mRange = (mEffect.mRange+1)%3;
if(mEffect.mRange == ESM::RT_Self) if(mEffect.mRange == ESM::RT_Self)
{ {
mAreaSlider->setScrollPosition(0); mAreaSlider->setScrollPosition(0);
onAreaChanged(mAreaSlider,0); onAreaChanged(mAreaSlider,0);
} }
if (mEffect.mRange == ESM::RT_Self)
mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}");
else if (mEffect.mRange == ESM::RT_Target)
mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}");
else if (mEffect.mRange == ESM::RT_Touch)
mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}");
updateBoxes(); updateBoxes();
eventEffectModified(mEffect); eventEffectModified(mEffect);
} }
@ -542,7 +556,6 @@ namespace MWGui
mAddEffectDialog.newEffect(effect); mAddEffectDialog.newEffect(effect);
mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId()); mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId());
mAddEffectDialog.setVisible(true);
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog); MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog);
mSelectAttributeDialog = 0; mSelectAttributeDialog = 0;
} }
@ -554,7 +567,6 @@ namespace MWGui
mAddEffectDialog.newEffect(effect); mAddEffectDialog.newEffect(effect);
mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId()); mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId());
mAddEffectDialog.setVisible(true);
MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog); MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog);
mSelectSkillDialog = 0; mSelectSkillDialog = 0;
} }
@ -611,7 +623,6 @@ namespace MWGui
else else
{ {
mAddEffectDialog.newEffect(effect); mAddEffectDialog.newEffect(effect);
mAddEffectDialog.setVisible(true);
} }
} }

Loading…
Cancel
Save