1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "interface_options_ryzom.h"
25 #include "nel/gui/interface_options.h"
26 #include "interface_manager.h"
27 #include "nel/gui/group_menu.h"
28 #include "nel/misc/xml_auto_ptr.h"
29 #include "../net_manager.h"
30 #include "../sheet_manager.h"
31 #include "../entity_animation_manager.h"
32 #include "../client_sheets/animation_set_list_sheet.h"
33 #include "../client_sheets/emot_list_sheet.h"
34 #include "nel/3d/u_animation_set.h"
35 #include "nel/misc/algo.h"
37 // ----------------------------------------------------------------------------
40 using namespace NLMISC
;
42 extern CEntityAnimationManager
*EAM
;
44 NLMISC_REGISTER_OBJECT(CInterfaceOptions
, CMissionIconList
, std::string
, "mission_icons");
46 // ***************************************************************************
47 bool CMissionIconList::parse(xmlNodePtr cur
)
49 bool result
= CInterfaceOptions::parse(cur
);
50 if (!result
) return false;
51 CInterfaceManager
*im
= CInterfaceManager::getInstance();
52 CViewRenderer
&vr
= *CViewRenderer::getInstance();
53 for(std::map
<std::string
, CInterfaceOptionValue
>::iterator it
= _ParamValue
.begin(); it
!= _ParamValue
.end(); ++it
)
56 if (fromString(it
->first
, index
))
60 nlwarning("bad index for texture");
64 string sTmp
= it
->second
.getValStr();
66 if (sTmp
.find('|') != string::npos
)
68 sBack
= sTmp
.substr(0,sTmp
.find('|'));
69 sIcon
= sTmp
.substr(sTmp
.find('|')+1,sTmp
.size());
76 sint32 texID
= vr
.getTextureIdFromName(sBack
);
79 IconBackTexID
.resize(std::max((int) IconBackTexID
.size(), index
+ 1), -1);
80 IconBackTexID
[index
] = texID
;
82 texID
= vr
.getTextureIdFromName(sIcon
);
85 IconTexID
.resize(std::max((int) IconTexID
.size(), index
+ 1), -1);
86 IconTexID
[index
] = texID
;
91 NLMISC::contReset(_ParamValue
); // not needed anymore
96 // ***************************************************************************
97 NLMISC_REGISTER_OBJECT(CInterfaceOptions
, COptionsAnimationSet
, std::string
, "animation_set");
98 COptionsAnimationSet::COptionsAnimationSet( const TCtorParam
¶m
) :
99 CInterfaceOptions( param
)
104 // ***************************************************************************
105 COptionsAnimationSet::~COptionsAnimationSet()
109 /* Important Note: this CInterfaceOptions is released BEFORE any CCharacter3d is released himself
110 BUT this is OK, since the actual animationSet is kept by SmartPtr through UPlayList
111 (see deleteAnimationSet() doc)
113 CViewRenderer::getInstance()->getDriver()->deleteAnimationSet(AnimationSet
);
118 // ***************************************************************************
119 bool COptionsAnimationSet::parse (xmlNodePtr cur
)
121 bool result
= CInterfaceOptions::parse(cur
);
122 if (!result
) return false;
123 nlassert( CViewRenderer::getInstance()->getDriver() );
125 // create the animation set
126 AnimationSet
= CViewRenderer::getInstance()->getDriver()->createAnimationSet();
127 nlassert(AnimationSet
);
132 // Add all male/female animations
134 for(uint gender
=0; gender
<2; gender
++)
136 string prefix
= (gender
==0)?"m":"f";
141 sTmp
= getValStr(prefix
+toString(i
));
145 vector
<string
> params
;
146 splitString(sTmp
, "|", params
);
147 // if error or first param empty, abort all
148 if(params
.empty() || params
[0].empty())
154 string animName
= params
[0];
156 uint animID
= AnimationSet
->addAnimation (animName
.c_str(), animName
.c_str());
157 if (animID
== UAnimationSet::NotFound
)
158 nlwarning ("Character3D : not found anim : %s", animName
.c_str());
159 // try to add the Face animation for this one (not important if failed)
160 string faceAnimName
= getFaceAnimName(animName
);
161 AnimationSet
->addAnimation (faceAnimName
.c_str(), faceAnimName
.c_str());
163 // append the new anim desc
165 newAnim
.AnimId
= animID
;
166 newAnim
.ApplyRaceScalePos
= true;
168 for(uint p
=1;p
<params
.size();p
++)
170 if(params
[p
]=="no_race_scale_pos")
171 newAnim
.ApplyRaceScalePos
= false;
173 // append to the correct anim list
175 AnimMale
.push_back(newAnim
);
177 AnimFemale
.push_back(newAnim
);
181 } while(!sTmp
.empty());
185 AnimationSet
->build ();
190 // ***************************************************************************
191 string
COptionsAnimationSet::getFaceAnimName(const std::string
&animName
)
193 string faceAnimName
= animName
;
194 string::size_type extPos
= faceAnimName
.find(".anim");
195 if(extPos
!=string::npos
)
196 faceAnimName
= faceAnimName
.substr(0, extPos
);
197 faceAnimName
+= "_face";
198 if(extPos
!=string::npos
)
199 faceAnimName
+= ".anim";