summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-21 18:43:26 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-21 18:43:26 +0300
commitd8a7eaa14ef0fad24e19f6363db708a397f7f98b (patch)
treefdf3f32c4c300be74c3371bd47a60d84fdd70ff8
parent529d5ac21229ba7678bba9832f69448898b159b9 (diff)
downloadmv-d8a7eaa14ef0fad24e19f6363db708a397f7f98b.tar.gz
mv-d8a7eaa14ef0fad24e19f6363db708a397f7f98b.tar.bz2
mv-d8a7eaa14ef0fad24e19f6363db708a397f7f98b.tar.xz
mv-d8a7eaa14ef0fad24e19f6363db708a397f7f98b.zip
Allow copy items from outfit into chat.
-rw-r--r--src/actions/commands.cpp11
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/dyetool/actions/commands.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/popups/popupmenu.cpp4
-rw-r--r--src/gui/windows/outfitwindow.cpp24
-rw-r--r--src/gui/windows/outfitwindow.h2
-rw-r--r--src/input/inputactionmap.h8
8 files changed, 51 insertions, 1 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index 4f809411c..df86fefc2 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -1888,4 +1888,15 @@ impHandler(partyAutoItemShare)
return true;
}
+impHandler0(outfitToChat)
+{
+ if (!outfitWindow || !chatWindow)
+ return false;
+
+ const std::string str = outfitWindow->getOutfitString();
+ if (!str.empty())
+ chatWindow->addInputText(str);
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index 627390860..3cf383f74 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -152,6 +152,7 @@ namespace Actions
decHandler(partyItemShare);
decHandler(partyExpShare);
decHandler(partyAutoItemShare);
+ decHandler(outfitToChat);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index 56541134c..b066cd290 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -152,5 +152,6 @@ impHandlerVoid(setSkillOffsetY)
impHandlerVoid(partyItemShare)
impHandlerVoid(partyExpShare)
impHandlerVoid(partyAutoItemShare)
+impHandlerVoid(outfitToChat)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 519a7535c..4f2f12e9c 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -685,6 +685,7 @@ enumStart(InputAction)
PARTY_EXP_SHARE,
PARTY_AUTO_ITEM_SHARE,
CREATE_ITEM,
+ COPY_OUTFIT_TO_CHAT,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 5eb9d5813..2284e4cda 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -783,6 +783,10 @@ void PopupMenu::showOutfitsWindowPopup(const int x, const int y)
// TRANSLATORS: popup menu header
mBrowserBox->addRow(_("Outfits"));
// TRANSLATORS: popup menu item
+ // TRANSLATORS: copy selected outfit to chat input
+ mBrowserBox->addRow("/outfittochat", _("Add to chat"));
+ mBrowserBox->addRow("##3---");
+ // TRANSLATORS: popup menu item
// TRANSLATORS: clear selected outfit
mBrowserBox->addRow("clear outfit", _("Clear outfit"));
mBrowserBox->addRow("##3---");
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index 290cf924c..2a6ba3d6e 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -722,3 +722,27 @@ void OutfitWindow::clearCurrentOutfit()
}
save();
}
+
+std::string OutfitWindow::getOutfitString() const
+{
+ std::string str;
+ for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++)
+ {
+ const int id = mItems[mCurrentOutfit][i];
+ if (id < 0)
+ continue;
+
+ const ItemColor color = mItemColors[mCurrentOutfit][i];
+ std::vector<int> ids;
+ ids.push_back(id);
+ ids.push_back(CAST_S32(color));
+
+ const std::string name = ItemDB::getNamesStr(ids);
+ if (name.empty())
+ continue;
+ str.append("[");
+ str.append(name);
+ str.append("] ");
+ }
+ return str;
+}
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index a6d31d3be..227a16737 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -97,6 +97,8 @@ class OutfitWindow final : public Window,
void clearCurrentOutfit();
+ std::string getOutfitString() const;
+
private:
int getIndexFromGrid(const int pointX,
const int pointY) const A_WARN_UNUSED;
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 7d8cc6a0b..ab7ab9e81 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5599,7 +5599,13 @@ static const InputActionData inputActionData
InputCondition::INGAME,
"createitem",
UseArgs_true,
- Protected_false},
+ Protected_true},
+ {"keyCopyOutfitToChat",
+ defaultAction(&Actions::outfitToChat),
+ InputCondition::INGAME,
+ "outfittochat|copyoutfittochat",
+ UseArgs_false,
+ Protected_true},
};
#undef defaultAction