summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-15 20:53:32 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-15 20:53:32 +0300
commitf2b5d38744860360b4b592920c4732aea839ab75 (patch)
tree861f05e56f628d3fc3554ada44bfb98b1803ab01
parente5cdd67b71b9d26d5d8a4182a64379fe8a8b4f7a (diff)
downloadManaVerse-f2b5d38744860360b4b592920c4732aea839ab75.tar.gz
ManaVerse-f2b5d38744860360b4b592920c4732aea839ab75.tar.bz2
ManaVerse-f2b5d38744860360b4b592920c4732aea839ab75.tar.xz
ManaVerse-f2b5d38744860360b4b592920c4732aea839ab75.zip
Copy skill cast offset to shortcuts.
Also show offsets in skill popup in shortcuts.
-rw-r--r--src/gui/popups/skillpopup.cpp25
-rw-r--r--src/gui/popups/skillpopup.h6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp18
-rw-r--r--src/gui/widgets/skilllistbox.h11
4 files changed, 45 insertions, 15 deletions
diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp
index fa757b844..82debd83d 100644
--- a/src/gui/popups/skillpopup.cpp
+++ b/src/gui/popups/skillpopup.cpp
@@ -49,7 +49,9 @@ SkillPopup::SkillPopup() :
mSkillCastType(new TextBox(this)),
mCastType(CastType::Default),
mLastId(0U),
- mLastLevel(-1)
+ mLastLevel(-1),
+ mOffsetX(0),
+ mOffsetY(0)
{
mSkillName->setFont(boldFont);
mSkillName->setPosition(0, 0);
@@ -95,13 +97,17 @@ SkillPopup::~SkillPopup()
void SkillPopup::show(const SkillInfo *const skill,
const int level,
- const CastTypeT castType)
+ const CastTypeT castType,
+ const int offsetX,
+ const int offsetY)
{
if (!skill ||
!skill->data ||
(skill->id == mLastId &&
level == mLastLevel &&
- castType == mCastType))
+ castType == mCastType &&
+ offsetX == mOffsetX &&
+ offsetY == mOffsetY))
{
return;
}
@@ -109,6 +115,8 @@ void SkillPopup::show(const SkillInfo *const skill,
mLastId = skill->id;
mLastLevel = level;
mCastType = castType;
+ mOffsetX = offsetX;
+ mOffsetY = offsetY;
mSkillName->setCaption(skill->data->dispName);
mSkillName->adjustSize();
@@ -168,12 +176,12 @@ void SkillPopup::show(const SkillInfo *const skill,
castStr = _("Self position");
break;
}
- if (skill->customOffsetX != 0 ||
- skill->customOffsetY != 0)
+ if (offsetX != 0 ||
+ offsetY != 0)
{
castStr.append(strprintf(" (%+d,%+d)",
- skill->customOffsetX,
- skill->customOffsetY));
+ offsetX,
+ offsetY));
}
mSkillCastType->setTextWrapped(strprintf(
// TRANSLATORS: skill cast type
@@ -234,4 +242,7 @@ void SkillPopup::reset()
{
mLastId = 0;
mLastLevel = 0;
+ mCastType = CastType::Default;
+ mOffsetX = 0;
+ mOffsetY = 0;
}
diff --git a/src/gui/popups/skillpopup.h b/src/gui/popups/skillpopup.h
index 95d5a4133..b4bc95500 100644
--- a/src/gui/popups/skillpopup.h
+++ b/src/gui/popups/skillpopup.h
@@ -58,7 +58,9 @@ class SkillPopup final : public Popup
*/
void show(const SkillInfo *const skill,
const int level,
- const CastTypeT type);
+ const CastTypeT type,
+ const int offsetX,
+ const int offsetY);
void mouseMoved(MouseEvent &event) override final;
@@ -73,6 +75,8 @@ class SkillPopup final : public Popup
CastTypeT mCastType;
unsigned int mLastId;
int mLastLevel;
+ int mOffsetX;
+ int mOffsetY;
};
extern SkillPopup *skillPopup;
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 60519699e..e898c34d4 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -599,16 +599,28 @@ void ItemShortcutContainer::mouseMoved(MouseEvent &event)
if (!skill)
return;
- // +++ for now from data only get cast type
const std::string data = selShortcut->getItemData(index);
CastTypeT castType = CastType::Default;
+ int offsetX = 0;
+ int offsetY = 0;
if (!data.empty())
{
- castType = static_cast<CastTypeT>(atoi(data.c_str()));
+ std::vector<int> vect;
+ splitToIntVector(vect, data, ' ');
+ const size_t sz = vect.size();
+ if (sz > 0)
+ castType = static_cast<CastTypeT>(vect[0]);
+ if (sz > 2)
+ {
+ offsetX = vect[1];
+ offsetY = vect[2];
+ }
}
skillPopup->show(skill,
toInt(itemColor, int),
- castType);
+ castType,
+ offsetX,
+ offsetY);
skillPopup->position(viewport->mMouseX,
viewport->mMouseY);
}
diff --git a/src/gui/widgets/skilllistbox.h b/src/gui/widgets/skilllistbox.h
index 91023e4dd..720d51005 100644
--- a/src/gui/widgets/skilllistbox.h
+++ b/src/gui/widgets/skilllistbox.h
@@ -202,7 +202,9 @@ class SkillListBox final : public ListBox
return;
skillPopup->show(skill,
skill->customSelectedLevel,
- skill->customCastType);
+ skill->customCastType,
+ skill->customOffsetX,
+ skill->customOffsetY);
skillPopup->position(viewport->mMouseX,
viewport->mMouseY);
}
@@ -221,9 +223,10 @@ class SkillListBox final : public ListBox
return;
dragDrop.dragSkill(skill, DragDropSource::Skills);
dragDrop.setItem(skill->id + SKILL_MIN_ID);
- // +++ using only cast type in data
- dragDrop.setItemData(toString(CAST_S32(
- skill->customCastType)));
+ dragDrop.setItemData(strprintf("%d %d %d",
+ CAST_S32(skill->customCastType),
+ skill->customOffsetX,
+ skill->customOffsetY));
}
ListBox::mouseDragged(event);
}