mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 12:32:36 +00:00
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)
This commit is contained in:
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,6 +199,24 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
mEffect.mRange = (mEffect.mRange+1)%3;
|
mEffect.mRange = (mEffect.mRange+1)%3;
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
bool allowSelf = mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf;
|
||||||
|
bool allowTouch = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) && !constantEffect;
|
||||||
|
bool allowTarget = (mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) && !constantEffect;
|
||||||
|
if (mEffect.mRange == ESM::RT_Self && !allowSelf)
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
mAreaSlider->setScrollPosition(0);
|
||||||
|
onAreaChanged(mAreaSlider,0);
|
||||||
|
}
|
||||||
|
|
||||||
if (mEffect.mRange == ESM::RT_Self)
|
if (mEffect.mRange == ESM::RT_Self)
|
||||||
mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}");
|
mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}");
|
||||||
else if (mEffect.mRange == ESM::RT_Target)
|
else if (mEffect.mRange == ESM::RT_Target)
|
||||||
@ -197,19 +224,6 @@ namespace MWGui
|
|||||||
else if (mEffect.mRange == ESM::RT_Touch)
|
else if (mEffect.mRange == ESM::RT_Touch)
|
||||||
mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}");
|
mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}");
|
||||||
|
|
||||||
// cycle through range types until we find something that's allowed
|
|
||||||
if (mEffect.mRange == ESM::RT_Target && (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget) || constantEffect))
|
|
||||||
onRangeButtonClicked(sender);
|
|
||||||
if (mEffect.mRange == ESM::RT_Self && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf))
|
|
||||||
onRangeButtonClicked(sender);
|
|
||||||
if (mEffect.mRange == ESM::RT_Touch && (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch) || constantEffect))
|
|
||||||
onRangeButtonClicked(sender);
|
|
||||||
|
|
||||||
if(mEffect.mRange == ESM::RT_Self)
|
|
||||||
{
|
|
||||||
mAreaSlider->setScrollPosition(0);
|
|
||||||
onAreaChanged(mAreaSlider,0);
|
|
||||||
}
|
|
||||||
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…
x
Reference in New Issue
Block a user