Merging develop

--HG--
branch : item_group
This commit is contained in:
Guillaume Dupuy 2017-04-07 11:28:41 +02:00
commit ad347d09c8
9 changed files with 86 additions and 34 deletions

View file

@ -180,8 +180,8 @@ int main(int argc, char **argv)
for (uint j = 0; j < size; ++j) for (uint j = 0; j < size; ++j)
{ {
// TODO: find what computation do pRGBA->modulateFromColorRGBOnly(*pRGBA, color);
// *(pRGBA++)-> = color; ++pRGBA;
} }
NLMISC::COFile out; NLMISC::COFile out;

View file

@ -220,6 +220,21 @@
</parameter> </parameter>
</action> </action>
<action name="phrase_cancel_cast" hardtext="uiCancelCast" contexts="game, r2ed_anim_test"/> <action name="phrase_cancel_cast" hardtext="uiCancelCast" contexts="game, r2ed_anim_test"/>
<action name="item_group_equip" hardtext="uiMacroItemGroupEquip" contexts="game, r2ed_anim_test">
<parameter hardtext="uiMacroItemGroupName" type="%action_param_user_name" name="name" />
</action>
<action name="item_group_move" hardtext="uiMacroItemGroupMove" contexts="game, r2ed_anim_test">
<parameter hardtext="uiMacroItemGroupName" type="%action_param_user_name" name="name" />
<parameter hardtext="uiMacroItemGroupDestination" type="%action_param_constant" name="destination" value="bag">
<value value="bag" hardtext="uimMtBag" />
<value value="pet_animal1" hardtext="uimMtPaPacker0" />
<value value="pet_animal2" hardtext="uimMtPaPacker1" />
<value value="pet_animal3" hardtext="uimMtPaPacker2" />
<value value="pet_animal4" hardtext="uimMtPaPacker3" />
<value value="player_room" hardtext="uimMtRoom" />
<value value="guild" hardtext="uimMtGuild" />
</parameter>
</action>
</action_category> </action_category>
<action_category name="chat" hardtext="uiChat" contexts="game, r2ed, r2ed_anim_test"> <!-- not available in r2ed for now --> <action_category name="chat" hardtext="uiChat" contexts="game, r2ed, r2ed_anim_test"> <!-- not available in r2ed for now -->

View file

@ -200,7 +200,7 @@
</group> </group>
<group id="header_opened" x="0" y="0" h="20" posref="TL TL" > <group id="header_opened" x="0" y="0" h="20" posref="TL TL" >
</group> </group>
<group id="content" type="list" x="0" y="0" over="true" posref="TL TL" > <group id="content" type="list" x="0" y="0" sizeref="w" over="true" posref="TL TL" >
</group> </group>
</group> </group>
</template> </template>

View file

@ -233,14 +233,20 @@ NLMISC_COMMAND(equipGroup, "equip group <name>", "name")
if(CItemGroupManager::getInstance()->equipGroup(args[0])) if(CItemGroupManager::getInstance()->equipGroup(args[0]))
{ {
ucstring msg = CI18N::get("cmdEquipGroupSuccess"); ucstring msg = CI18N::get("cmdEquipGroupSuccess");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdEquipGroupError"); ucstring msg = CI18N::get("cmdEquipGroupError");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
} }
@ -261,7 +267,10 @@ NLMISC_COMMAND(moveGroup, "move group <name> to <dst>", "name dst")
if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1])))
{ {
ucstring msg = CI18N::get("cmdMoveGroupSuccess"); ucstring msg = CI18N::get("cmdMoveGroupSuccess");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
strFindReplace(msg, "%inventory", args[1]); strFindReplace(msg, "%inventory", args[1]);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
@ -269,7 +278,10 @@ NLMISC_COMMAND(moveGroup, "move group <name> to <dst>", "name dst")
else else
{ {
ucstring msg = CI18N::get("cmdMoveGroupError"); ucstring msg = CI18N::get("cmdMoveGroupError");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
strFindReplace(msg, "%inventory", args[1]); strFindReplace(msg, "%inventory", args[1]);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -297,14 +309,20 @@ NLMISC_COMMAND(createGroup, "create group <name> [true](create a <remove> for ev
msg = CI18N::get("cmdCreateGroupSuccess2"); msg = CI18N::get("cmdCreateGroupSuccess2");
else else
msg = CI18N::get("cmdCreateGroupSuccess1"); msg = CI18N::get("cmdCreateGroupSuccess1");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdCreateGroupError"); ucstring msg = CI18N::get("cmdCreateGroupError");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
} }
@ -325,14 +343,20 @@ NLMISC_COMMAND(deleteGroup, "delete group <name>", "name")
if(CItemGroupManager::getInstance()->deleteGroup(args[0])) if(CItemGroupManager::getInstance()->deleteGroup(args[0]))
{ {
ucstring msg = CI18N::get("cmdDeleteGroupSuccess"); ucstring msg = CI18N::get("cmdDeleteGroupSuccess");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdDeleteGroupError"); ucstring msg = CI18N::get("cmdDeleteGroupError");
strFindReplace(msg, "%name", args[0]); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
} }

View file

@ -2041,7 +2041,10 @@ class CHandlerItemMenuCheck : public IActionHandler
{ {
std::string name = groupNames[i]; std::string name = groupNames[i];
std::string ahParams = "name=" + name; std::string ahParams = "name=" + name;
pGroupMenu->addLine(ucstring(name), "", "", name); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(name);
pGroupMenu->addLine(nameUC, "", "", name);
CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam()); CGroupSubMenu* pNewSubMenu = new CGroupSubMenu(CViewBase::TCtorParam());
pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu); pGroupMenu->setSubMenu(pGroupMenu->getNumLine()-1, pNewSubMenu);
if(pNewSubMenu) if(pNewSubMenu)
@ -2322,14 +2325,8 @@ REGISTER_ACTION_HANDLER( CHandlerRingXpCatalyserStopUse, "ring_xp_catalyser_stop
// item groups // item groups
class CHandlerItemGroupMove : public IActionHandler class CHandlerItemGroupMove : public IActionHandler
{ {
void execute (CCtrlBase *caller, const std::string &sParams) void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
{ {
CDBCtrlSheet* pCS = dynamic_cast<CDBCtrlSheet*>(caller);
if(!pCS)
{
nlinfo("Wrong cast");
return;
}
std::string destination = getParam(sParams, "destination"); std::string destination = getParam(sParams, "destination");
std::string name = getParam(sParams, "name"); std::string name = getParam(sParams, "name");
if(name.empty()) if(name.empty())
@ -2347,14 +2344,8 @@ REGISTER_ACTION_HANDLER(CHandlerItemGroupMove, "item_group_move");
// *************************************************************************** // ***************************************************************************
class CHandlerItemGroupEquip : public IActionHandler class CHandlerItemGroupEquip : public IActionHandler
{ {
void execute (CCtrlBase *caller, const std::string & sParams) void execute (CCtrlBase * /* pCaller */, const std::string & sParams)
{ {
CDBCtrlSheet* pCS = dynamic_cast<CDBCtrlSheet*>(caller);
if(!pCS)
{
nlinfo("Wrong cast");
return;
}
std::string name = getParam(sParams, "name"); std::string name = getParam(sParams, "name");
if(name.empty()) if(name.empty())
{ {

View file

@ -187,8 +187,8 @@ static inline bool isUrlTag(const ucstring &s, ucstring::size_type index, ucstri
if (isUrl && i > 0 && !markdown) if (isUrl && i > 0 && !markdown)
{ {
// '}' is in the list because of color tags, ie "@{FFFF}http://..." // '}' is in the list because of color tags, ie "@{FFFF}http://..."
const ucchar chars[] = {' ', '"', '\'', '(', '[', '}'}; const vector<ucchar> chars {' ', '"', '\'', '(', '[', '}'};
isUrl = std::find(std::begin(chars), std::end(chars), s[i - 1]) != std::end(chars); isUrl = std::find(chars.begin(), chars.end(), s[i - 1]) != chars.end();
} }
return isUrl; return isUrl;
} }

View file

@ -353,6 +353,11 @@ public:
continue; continue;
} }
if (!CFile::fileExists(filenames[i])) {
nlwarning("Ignore non-existing file '%s'", filenames[i].c_str());
continue;
}
CMusicPlayer::CSongs song; CMusicPlayer::CSongs song;
song.Filename = filenames[i]; song.Filename = filenames[i];
SoundMngr->getMixer()->getSongTitle(filenames[i], song.Title, song.Length); SoundMngr->getMixer()->getSongTitle(filenames[i], song.Title, song.Length);

View file

@ -13,6 +13,9 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "item_group_manager.h" #include "item_group_manager.h"
#include "interface_v3/inventory_manager.h" #include "interface_v3/inventory_manager.h"
#include "nel/gui/widget_manager.h" #include "nel/gui/widget_manager.h"
@ -473,6 +476,7 @@ bool CItemGroupManager::equipGroup(std::string name, bool pullBefore)
} }
// For some reason, there is no (visual) invalidation (server still blocks any action), force one // For some reason, there is no (visual) invalidation (server still blocks any action), force one
// Unfortunately, there is no clean way to do this, so we'll simulate one // Unfortunately, there is no clean way to do this, so we'll simulate one
if(maxEquipTime > 0)
fakeInvalidActions((NLMISC::TGameCycle)maxEquipTime); fakeInvalidActions((NLMISC::TGameCycle)maxEquipTime);
return true; return true;
@ -489,8 +493,10 @@ bool CItemGroupManager::createGroup(std::string name, bool removeUnequiped)
{ {
SLOT_EQUIPMENT::TSlotEquipment slot = (SLOT_EQUIPMENT::TSlotEquipment)i; SLOT_EQUIPMENT::TSlotEquipment slot = (SLOT_EQUIPMENT::TSlotEquipment)i;
//Instead of doing two separate for, just be a bit tricky for hand equipment //Instead of doing two separate for, just be a bit tricky for hand equipment
if(slot == SLOT_EQUIPMENT::HANDR || slot == SLOT_EQUIPMENT::HANDL) if(slot == SLOT_EQUIPMENT::HANDR)
pCS = CInventoryManager::getInstance()->getHandSheet((uint32)(slot - SLOT_EQUIPMENT::HANDL)); pCS = CInventoryManager::getInstance()->getHandSheet(0);
else if(slot == SLOT_EQUIPMENT::HANDL)
pCS = CInventoryManager::getInstance()->getHandSheet(1);
else else
pCS = CInventoryManager::getInstance()->getEquipSheet(i); pCS = CInventoryManager::getInstance()->getEquipSheet(i);
if(!pCS) continue; if(!pCS) continue;
@ -534,7 +540,10 @@ void CItemGroupManager::listGroup()
{ {
CItemGroup group = _Groups[i]; CItemGroup group = _Groups[i];
ucstring msg = NLMISC::CI18N::get("cmdListGroupLine"); ucstring msg = NLMISC::CI18N::get("cmdListGroupLine");
NLMISC::strFindReplace(msg, "%name", group.name); //Use ucstring because group name can contain accentued characters (and stuff like that)
ucstring nameUC;
nameUC.fromUtf8(group.name);
NLMISC::strFindReplace(msg, "%name", nameUC);
NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size())); NLMISC::strFindReplace(msg, "%size", NLMISC::toString(group.Items.size()));
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
} }
@ -604,7 +613,14 @@ std::vector<CInventoryItem> CItemGroupManager::matchingItems(CItemGroup *group,
SLOT_EQUIPMENT::TSlotEquipment slot; SLOT_EQUIPMENT::TSlotEquipment slot;
if(group->contains(pCS, slot)) if(group->contains(pCS, slot))
{ {
out.push_back(CInventoryItem(pCS, inventory, i, slot)); //Sometimes, index in the list differ from the index in DB, and we need the index in DB, not the one from the list
std::string dbPath = pCS->getSheet();
std::size_t found = dbPath.find_last_of(":");
std::string indexS = dbPath.substr(found+1);
uint32 index;
NLMISC::fromString(indexS, index);
if(i != index) nldebug("Index from list is %d, where index from DB is %d", i, index);
out.push_back(CInventoryItem(pCS, inventory, index, slot));
} }
} }

View file

@ -22,6 +22,7 @@
#include <memory> #include <memory>
#include <iterator> #include <iterator>
#include <limits>
#include "nel/misc/common.h" #include "nel/misc/common.h"
@ -61,7 +62,7 @@ struct TTimeSlice
uint32 EndDate; uint32 EndDate;
}; };
const TTimeSlice FullTimeSlice = {0, ~0}; const TTimeSlice FullTimeSlice = {0, std::numeric_limits<uint32>::max()};
/// Defile the complete selected time line /// Defile the complete selected time line
typedef std::vector<TTimeSlice> TTimeLine; typedef std::vector<TTimeSlice> TTimeLine;