summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp52
-rw-r--r--src/actions/commands.h4
-rw-r--r--src/dyetool/actions/commands.cpp4
-rw-r--r--src/enums/input/inputaction.h4
-rw-r--r--src/gui/popups/popupmenu.cpp55
-rw-r--r--src/gui/popups/popupmenu.h3
-rw-r--r--src/gui/windows/skilldialog.cpp20
-rw-r--r--src/gui/windows/skilldialog.h6
-rw-r--r--src/input/inputactionmap.h24
-rw-r--r--src/resources/skill/skillinfo.cpp2
-rw-r--r--src/resources/skill/skillinfo.h2
11 files changed, 176 insertions, 0 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 6f2bba4a7..dc4d70765 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -1621,4 +1621,56 @@ impHandler(selectSkillType)
return false;
}
+impHandler(showSkillOffsetX)
+{
+ const std::string args = event.args;
+ if (args.empty())
+ return false;
+ const SkillInfo *restrict const skill = skillDialog->getSkill(
+ atoi(args.c_str()));
+ if (!skill)
+ return false;
+ popupMenu->showSkillOffsetPopup(skill, true);
+ return true;
+}
+
+impHandler(showSkillOffsetY)
+{
+ const std::string args = event.args;
+ if (args.empty())
+ return false;
+ const SkillInfo *restrict const skill = skillDialog->getSkill(
+ atoi(args.c_str()));
+ if (!skill)
+ return false;
+ popupMenu->showSkillOffsetPopup(skill, false);
+ return true;
+}
+
+impHandler(setSkillOffsetX)
+{
+ int skill = 0;
+ int offset = 0;
+
+ if (skillDialog && parse2Int(event.args, skill, offset))
+ {
+ skillDialog->setSkillOffsetX(skill, offset);
+ return true;
+ }
+ return false;
+}
+
+impHandler(setSkillOffsetY)
+{
+ int skill = 0;
+ int offset = 0;
+
+ if (skillDialog && parse2Int(event.args, skill, offset))
+ {
+ skillDialog->setSkillOffsetY(skill, offset);
+ return true;
+ }
+ return false;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index ce07d3b03..ff17da2d3 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -144,6 +144,10 @@ namespace Actions
decHandler(showSkillLevels);
decHandler(showSkillType);
decHandler(selectSkillType);
+ decHandler(showSkillOffsetX);
+ decHandler(showSkillOffsetY);
+ decHandler(setSkillOffsetX);
+ decHandler(setSkillOffsetY);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index 4356d3267..45daa68d4 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -144,5 +144,9 @@ impHandlerVoid(adoptChild)
impHandlerVoid(showSkillLevels)
impHandlerVoid(showSkillType)
impHandlerVoid(selectSkillType)
+impHandlerVoid(showSkillOffsetX)
+impHandlerVoid(showSkillOffsetY)
+impHandlerVoid(setSkillOffsetX)
+impHandlerVoid(setSkillOffsetY)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 60eb5bf82..4f7b61986 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -675,6 +675,10 @@ enumStart(InputAction)
SHOW_SKILL_LEVELS,
SHOW_SKILL_TYPE,
SELECT_SKILL_TYPE,
+ SHOW_SKILL_OFFSET_X,
+ SHOW_SKILL_OFFSET_Y,
+ SET_SKILL_OFFSET_X,
+ SET_SKILL_OFFSET_Y,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index b7a7a282e..8257033b4 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -2397,6 +2397,14 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info)
// TRANSLATORS: popup menu item
// TRANSLATORS: set skill cast type
_("Skill cast type..."));
+ mBrowserBox->addRow("/showskilloffsetx 'ITEMID'",
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: set skill cast offset by x
+ _("Skill offset by x..."));
+ mBrowserBox->addRow("/showskilloffsety 'ITEMID'",
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: set skill cast offset by y
+ _("Skill offset by y..."));
// TRANSLATORS: popup menu item
// TRANSLATORS: close menu
mBrowserBox->addRow("cancel", _("Cancel"));
@@ -2404,6 +2412,53 @@ void PopupMenu::showSkillPopup(const SkillInfo *const info)
showPopup(mX, mY);
}
+void PopupMenu::showSkillOffsetPopup(const SkillInfo *const info,
+ const bool isOffsetX)
+{
+ if (!info)
+ return;
+ setMousePos2();
+
+ // using mItemId as skill id
+ mItemId = info->id;
+ // using mItemIndex as skill level
+ mItemIndex = info->level;
+ mBrowserBox->clearRows();
+ char letter = ' ';
+
+ if (isOffsetX)
+ {
+ // TRANSLATORS: popup menu header
+ mBrowserBox->addRow(_("Skill cast offset by x"));
+ letter = 'x';
+ }
+ else
+ {
+ // TRANSLATORS: popup menu header
+ mBrowserBox->addRow(_("Skill cast offset by y"));
+ letter = 'y';
+ }
+ for (int f = -9; f <= 9; f ++)
+ {
+ const std::string command = strprintf(
+ "/setskilloffset%c 'ITEMID' %d", letter, f);
+ if (f == 0)
+ {
+ mBrowserBox->addRow(command,
+ strprintf("%d", f).c_str());
+ }
+ else
+ {
+ mBrowserBox->addRow(command,
+ strprintf("%+d", f).c_str());
+ }
+ }
+ // TRANSLATORS: popup menu item
+ // TRANSLATORS: close menu
+ mBrowserBox->addRow("cancel", _("Cancel"));
+ showPopup(mX, mY);
+}
+
void PopupMenu::showSkillLevelPopup(const SkillInfo *const info)
{
if (!info)
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index 45c9bdda7..7bd4c085e 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -167,6 +167,9 @@ class PopupMenu final : public Popup, public LinkHandler
void showSkillTypePopup(const SkillInfo *const info);
+ void showSkillOffsetPopup(const SkillInfo *const info,
+ const bool isOffsetX);
+
void showCraftPopup();
void showEmoteType();
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index d002f93aa..41f63899e 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -1161,3 +1161,23 @@ void SkillDialog::selectSkillCastType(const int skillId,
info->customCastType = type;
info->update();
}
+
+void SkillDialog::setSkillOffsetX(const int skillId,
+ const int offset)
+{
+ SkillInfo *const info = getSkill(skillId);
+ if (!info)
+ return;
+ info->customOffsetX = offset;
+ info->update();
+}
+
+void SkillDialog::setSkillOffsetY(const int skillId,
+ const int offset)
+{
+ SkillInfo *const info = getSkill(skillId);
+ if (!info)
+ return;
+ info->customOffsetY = offset;
+ info->update();
+}
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index aa3f479c1..4adf813af 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -165,6 +165,12 @@ class SkillDialog final : public Window,
void selectSkillCastType(const int skillId,
const CastTypeT type);
+ void setSkillOffsetX(const int skillId,
+ const int offset);
+
+ void setSkillOffsetY(const int skillId,
+ const int offset);
+
private:
static void useSkillDefault(const SkillInfo *const info,
const AutoTarget autoTarget,
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 58f25afbb..402056ecc 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5539,6 +5539,30 @@ static const InputActionData inputActionData
"selectskilltype",
UseArgs_true,
Protected_true},
+ {"keyShowSkillOffsetX",
+ defaultAction(&Actions::showSkillOffsetX),
+ InputCondition::INGAME,
+ "showskilloffsetx",
+ UseArgs_true,
+ Protected_true},
+ {"keyShowSkillOffsetY",
+ defaultAction(&Actions::showSkillOffsetY),
+ InputCondition::INGAME,
+ "showskilloffsety",
+ UseArgs_true,
+ Protected_true},
+ {"keySetSkillOffsetX",
+ defaultAction(&Actions::setSkillOffsetX),
+ InputCondition::INGAME,
+ "setskilloffsetx",
+ UseArgs_true,
+ Protected_true},
+ {"keySetSkillOffsetY",
+ defaultAction(&Actions::setSkillOffsetY),
+ InputCondition::INGAME,
+ "setskilloffsety",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction
diff --git a/src/resources/skill/skillinfo.cpp b/src/resources/skill/skillinfo.cpp
index 45106ab95..963ef3417 100644
--- a/src/resources/skill/skillinfo.cpp
+++ b/src/resources/skill/skillinfo.cpp
@@ -47,6 +47,8 @@ SkillInfo::SkillInfo() :
data(nullptr),
level(0),
customSelectedLevel(0),
+ customOffsetX(0),
+ customOffsetY(0),
skillLevelWidth(0),
id(0),
range(0),
diff --git a/src/resources/skill/skillinfo.h b/src/resources/skill/skillinfo.h
index 689ab20a0..929d680b5 100644
--- a/src/resources/skill/skillinfo.h
+++ b/src/resources/skill/skillinfo.h
@@ -59,6 +59,8 @@ struct SkillInfo final
SkillData *data;
int level;
int customSelectedLevel;
+ int customOffsetX;
+ int customOffsetY;
int skillLevelWidth;
unsigned int id;
int range;