Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / interface_options_ryzom.cpp
bloba839330b8449e297b275a235277e47706b326e3a
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
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"
23 #include "stdpch.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 // ----------------------------------------------------------------------------
38 using namespace std;
39 using namespace NL3D;
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)
55 int index;
56 if (fromString(it->first, index))
58 if (index > 255)
60 nlwarning("bad index for texture");
62 else
64 string sTmp = it->second.getValStr();
65 string sBack, sIcon;
66 if (sTmp.find('|') != string::npos)
68 sBack = sTmp.substr(0,sTmp.find('|'));
69 sIcon = sTmp.substr(sTmp.find('|')+1,sTmp.size());
71 else
73 sBack = sTmp;
76 sint32 texID = vr.getTextureIdFromName(sBack);
77 if (texID != -1)
79 IconBackTexID.resize(std::max((int) IconBackTexID.size(), index + 1), -1);
80 IconBackTexID[index] = texID;
82 texID = vr.getTextureIdFromName(sIcon);
83 if (texID != -1)
85 IconTexID.resize(std::max((int) IconTexID.size(), index + 1), -1);
86 IconTexID[index] = texID;
91 NLMISC::contReset(_ParamValue); // not needed anymore
92 return true;
96 // ***************************************************************************
97 NLMISC_REGISTER_OBJECT(CInterfaceOptions, COptionsAnimationSet, std::string, "animation_set");
98 COptionsAnimationSet::COptionsAnimationSet( const TCtorParam &param ) :
99 CInterfaceOptions( param )
101 AnimationSet= NULL;
104 // ***************************************************************************
105 COptionsAnimationSet::~COptionsAnimationSet()
107 if(AnimationSet)
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);
114 AnimationSet= NULL;
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);
129 AnimMale.clear();
130 AnimFemale.clear();
132 // Add all male/female animations
133 string sTmp;
134 for(uint gender=0; gender<2; gender++)
136 string prefix= (gender==0)?"m":"f";
138 uint i = 0;
141 sTmp = getValStr(prefix+toString(i));
142 if (!sTmp.empty())
144 // get params
145 vector<string> params;
146 splitString(sTmp, "|", params);
147 // if error or first param empty, abort all
148 if(params.empty() || params[0].empty())
150 sTmp.clear();
152 else
154 string animName= params[0];
155 animName += ".anim";
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
164 CAnim newAnim;
165 newAnim.AnimId= animID;
166 newAnim.ApplyRaceScalePos= true;
167 // parse param
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
174 if(gender==0)
175 AnimMale.push_back(newAnim);
176 else
177 AnimFemale.push_back(newAnim);
180 ++i;
181 } while(!sTmp.empty());
184 // build
185 AnimationSet->build ();
187 return true;
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";
200 return faceAnimName;