last bits of the gui

actorid
scrawl 12 years ago
parent cf0596c216
commit f154031e54

@ -1,5 +1,7 @@
#include "spellcreationdialog.hpp"
#include <boost/lexical_cast.hpp>
#include <components/esm_store/store.hpp>
#include "../mwbase/windowmanager.hpp"
@ -49,21 +51,25 @@ namespace MWGui
getWidget(mEffectImage, "EffectImage");
getWidget(mEffectName, "EffectName");
getWidget(mAreaText, "AreaText");
getWidget(mDurationBox, "DurationBox");
getWidget(mAreaBox, "AreaBox");
getWidget(mMagnitudeBox, "MagnitudeBox");
mRangeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onRangeButtonClicked);
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onOkButtonClicked);
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onCancelButtonClicked);
mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onDeleteButtonClicked);
mMagnitudeMinSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMinChanged);
mMagnitudeMaxSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMaxChanged);
mDurationSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onDurationChanged);
mAreaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onAreaChanged);
}
void EditEffectDialog::open()
{
WindowModal::open();
center();
mEffect.mRange = ESM::RT_Self;
onRangeButtonClicked(mRangeButton);
}
void EditEffectDialog::newEffect (const ESM::MagicEffect *effect)
@ -72,6 +78,25 @@ namespace MWGui
mEditing = false;
mDeleteButton->setVisible (false);
mEffect.mRange = ESM::RT_Self;
onRangeButtonClicked(mRangeButton);
mMagnitudeMinSlider->setScrollPosition (0);
mMagnitudeMaxSlider->setScrollPosition (0);
mAreaSlider->setScrollPosition (0);
mDurationSlider->setScrollPosition (0);
mDurationValue->setCaption("1");
mMagnitudeMinValue->setCaption("1");
mMagnitudeMaxValue->setCaption("- 1");
mAreaValue->setCaption("0");
mEffect.mMagnMin = 1;
mEffect.mMagnMax = 1;
mEffect.mDuration = 1;
mEffect.mArea = 0;
}
void EditEffectDialog::editEffect (ESM::ENAMstruct effect)
@ -84,6 +109,16 @@ namespace MWGui
mEditing = true;
mDeleteButton->setVisible (true);
mMagnitudeMinSlider->setScrollPosition (effect.mMagnMin-1);
mMagnitudeMaxSlider->setScrollPosition (effect.mMagnMax-1);
mAreaSlider->setScrollPosition (effect.mArea);
mDurationSlider->setScrollPosition (effect.mDuration-1);
onMagnitudeMinChanged (mMagnitudeMinSlider, effect.mMagnMin-1);
onMagnitudeMaxChanged (mMagnitudeMinSlider, effect.mMagnMax-1);
onAreaChanged (mAreaSlider, effect.mArea);
onDurationChanged (mDurationSlider, effect.mDuration-1);
}
void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect)
@ -99,6 +134,39 @@ namespace MWGui
mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}");
mEffect.mEffectID = effect->mIndex;
mMagicEffect = effect;
updateBoxes();
}
void EditEffectDialog::updateBoxes()
{
static int startY = mMagnitudeBox->getPosition().top;
int curY = startY;
mMagnitudeBox->setVisible (false);
mDurationBox->setVisible (false);
mAreaBox->setVisible (false);
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude))
{
mMagnitudeBox->setPosition(mMagnitudeBox->getPosition().left, curY);
mMagnitudeBox->setVisible (true);
curY += mMagnitudeBox->getSize().height;
}
if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoDuration))
{
mDurationBox->setPosition(mDurationBox->getPosition().left, curY);
mDurationBox->setVisible (true);
curY += mDurationBox->getSize().height;
}
if (mEffect.mRange == ESM::RT_Target)
{
mAreaBox->setPosition(mAreaBox->getPosition().left, curY);
mAreaBox->setVisible (true);
curY += mAreaBox->getSize().height;
}
}
void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender)
@ -114,6 +182,16 @@ namespace MWGui
mAreaSlider->setVisible (mEffect.mRange != ESM::RT_Self);
mAreaText->setVisible (mEffect.mRange != ESM::RT_Self);
// cycle through range types until we find something that's allowed
if (mEffect.mRange == ESM::RT_Target && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget))
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))
onRangeButtonClicked(sender);
updateBoxes();
}
void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender)
@ -148,6 +226,42 @@ namespace MWGui
mEffect.mAttribute = attribute;
}
void EditEffectDialog::onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos)
{
mMagnitudeMinValue->setCaption(boost::lexical_cast<std::string>(pos+1));
mEffect.mMagnMin = pos+1;
// trigger the check again (see below)
onMagnitudeMaxChanged(mMagnitudeMaxSlider, mMagnitudeMaxSlider->getScrollPosition ());
}
void EditEffectDialog::onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos)
{
// make sure the max value is actually larger or equal than the min value
size_t magnMin = std::abs(mEffect.mMagnMin); // should never be < 0, this is just here to avoid the compiler warning
if (pos+1 < magnMin)
{
pos = mEffect.mMagnMin-1;
sender->setScrollPosition (pos);
}
mEffect.mMagnMax = pos+1;
mMagnitudeMaxValue->setCaption("- " + boost::lexical_cast<std::string>(pos+1));
}
void EditEffectDialog::onDurationChanged (MyGUI::ScrollBar* sender, size_t pos)
{
mDurationValue->setCaption(boost::lexical_cast<std::string>(pos+1));
mEffect.mDuration = pos+1;
}
void EditEffectDialog::onAreaChanged (MyGUI::ScrollBar* sender, size_t pos)
{
mAreaValue->setCaption(boost::lexical_cast<std::string>(pos));
mEffect.mArea = pos;
}
// ------------------------------------------------------------------------------------------------
SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager)
@ -356,6 +470,7 @@ namespace MWGui
params.mMagnMin = it->mMagnMin;
params.mMagnMax = it->mMagnMax;
params.mRange = it->mRange;
params.mArea = it->mArea;
MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default);
button->setUserData(i);

@ -38,6 +38,10 @@ namespace MWGui
MyGUI::Button* mRangeButton;
MyGUI::Widget* mDurationBox;
MyGUI::Widget* mMagnitudeBox;
MyGUI::Widget* mAreaBox;
MyGUI::TextBox* mMagnitudeMinValue;
MyGUI::TextBox* mMagnitudeMaxValue;
MyGUI::TextBox* mDurationValue;
@ -61,10 +65,19 @@ namespace MWGui
void onOkButtonClicked (MyGUI::Widget* sender);
void onCancelButtonClicked (MyGUI::Widget* sender);
void onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos);
void onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos);
void onDurationChanged (MyGUI::ScrollBar* sender, size_t pos);
void onAreaChanged (MyGUI::ScrollBar* sender, size_t pos);
void setMagicEffect(const ESM::MagicEffect* effect);
void updateBoxes();
protected:
ESM::ENAMstruct mEffect;
const ESM::MagicEffect* mMagicEffect;
};

@ -362,6 +362,7 @@ SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects)
params.mMagnMin = it->mMagnMin;
params.mMagnMax = it->mMagnMax;
params.mRange = it->mRange;
params.mArea = it->mArea;
result.push_back(params);
}
return result;
@ -437,6 +438,11 @@ void MWSpellEffect::updateWidgets()
spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs);
}
if (mEffectParams.mArea > 0)
{
spellLine += " #{sin} " + boost::lexical_cast<std::string>(mEffectParams.mArea) + " #{sfootarea}";
}
// potions have no target
if (!mEffectParams.mNoTarget)
{
@ -450,7 +456,7 @@ void MWSpellEffect::updateWidgets()
}
}
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(spellLine);
static_cast<MyGUI::TextBox*>(mTextWidget)->setCaptionWithReplacing(spellLine);
mRequestedWidth = mTextWidget->getTextSize().width + 24;
std::string path = std::string("icons\\") + magicEffect->mIcon;

@ -32,6 +32,7 @@ namespace MWGui
, mRange(-1)
, mDuration(-1)
, mSkill(-1)
, mArea(0)
, mAttribute(-1)
, mEffectID(-1)
, mNoTarget(false)
@ -51,6 +52,9 @@ namespace MWGui
// value of -1 here means the value is unavailable
int mMagnMin, mMagnMax, mRange, mDuration;
// value of 0 -> no area effect
int mArea;
bool operator==(const SpellEffectParams& other) const
{
if (mEffectID != other.mEffectID)
@ -66,7 +70,7 @@ namespace MWGui
|| mEffectID == 21 // drain skill
|| mEffectID == 83 // fortify skill
|| mEffectID == 26); // damage skill
return ((other.mSkill == mSkill) || !involvesSkill) && ((other.mAttribute == mAttribute) && !involvesAttribute);
return ((other.mSkill == mSkill) || !involvesSkill) && ((other.mAttribute == mAttribute) && !involvesAttribute) && (other.mArea == mArea);
}
};

@ -298,7 +298,7 @@
}
else
{
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
float fogValue = shSaturate((length(cameraPos.xyz-position.xyz) - fogParams.y) * fogParams.w);
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, gammaCorrectRead(fogColor), fogValue);
}

@ -21,49 +21,60 @@
</Widget>
<!-- Magnitude -->
<Widget type="TextBox" skin="NormalText" position="8 80 400 24">
<Property key="Caption" value="#{sMagnitude}"/>
<Property key="TextAlign" value="Left HCenter"/>
</Widget>
<Widget type="Widget" position="8 80 400 70" name="MagnitudeBox">
<Widget type="TextBox" skin="NormalText" position="0 0 400 24">
<Property key="Caption" value="#{sMagnitude}"/>
<Property key="TextAlign" value="Left HCenter"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 80 210 20" name="MagnitudeMinValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 100 210 13" name="MagnitudeMinSlider">
</Widget>
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="MagnitudeMinValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="MagnitudeMinSlider">
<Property key="Range" value="100"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 112 210 20" name="MagnitudeMaxValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 132 210 13" name="MagnitudeMaxSlider">
<Widget type="TextBox" skin="SandText" position="122 32 210 20" name="MagnitudeMaxValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="122 52 210 13" name="MagnitudeMaxSlider">
<Property key="Range" value="100"/>
</Widget>
</Widget>
<!-- Duration -->
<Widget type="TextBox" skin="NormalText" position="8 173 400 24">
<Property key="Caption" value="#{sDuration}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="Widget" position="8 153 400 40" name="DurationBox">
<Widget type="TextBox" skin="NormalText" position="0 20 400 24">
<Property key="Caption" value="#{sDuration}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 153 210 20" name="DurationValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 173 210 13" name="DurationSlider">
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="DurationValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="DurationSlider">
<Property key="Range" value="1440"/>
</Widget>
</Widget>
<!-- Area -->
<Widget type="TextBox" skin="NormalText" position="8 217 400 24" name="AreaText">
<Property key="Caption" value="#{sArea}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="Widget" position="8 197 400 40" name="AreaBox">
<Widget type="TextBox" skin="NormalText" position="0 20 400 24" name="AreaText">
<Property key="Caption" value="#{sArea}"/>
<Property key="TextAlign" value="Left Top"/>
</Widget>
<Widget type="TextBox" skin="SandText" position="130 197 210 20" name="AreaValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="130 217 210 13" name="AreaSlider">
<Widget type="TextBox" skin="SandText" position="122 0 210 20" name="AreaValue">
<Property key="TextAlign" value="Center"/>
<Property key="Caption" value="0"/>
</Widget>
<Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="AreaSlider">
<Property key="Range" value="51"/>
</Widget>
</Widget>
<Widget type="HBox" position="8 266 336 24">

Loading…
Cancel
Save