Otclient  14/8/2020
uicreature.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "uicreature.h"
24 #include <framework/otml/otml.h>
26 
28 {
29  if((drawPane & Fw::ForegroundPane) == 0)
30  return;
31 
32  UIWidget::drawSelf(drawPane);
33 
34  if(m_creature) {
35  Rect drawRect = getPaddingRect();
38  }
39 }
40 
41 void UICreature::setOutfit(const Outfit& outfit)
42 {
43  if(!m_creature)
46  m_creature->setOutfit(outfit);
47 }
48 
49 void UICreature::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
50 {
51  UIWidget::onStyleApply(styleName, styleNode);
52 
53  for(const OTMLNodePtr& node : styleNode->children()) {
54  if(node->tag() == "fixed-creature-size")
55  setFixedCreatureSize(node->value<bool>());
56  else if(node->tag() == "outfit-id") {
57  Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
58  outfit.setId(node->value<int>());
59  setOutfit(outfit);
60  }
61  else if(node->tag() == "outfit-head") {
62  Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
63  outfit.setHead(node->value<int>());
64  setOutfit(outfit);
65  }
66  else if(node->tag() == "outfit-body") {
67  Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
68  outfit.setBody(node->value<int>());
69  setOutfit(outfit);
70  }
71  else if(node->tag() == "outfit-legs") {
72  Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
73  outfit.setLegs(node->value<int>());
74  setOutfit(outfit);
75  }
76  else if(node->tag() == "outfit-feet") {
77  Outfit outfit = (m_creature ? m_creature->getOutfit() : Outfit());
78  outfit.setFeet(node->value<int>());
79  setOutfit(outfit);
80  }
81  }
82 }
Painter::setColor
virtual void setColor(const Color &color)
Definition: painter.h:77
UIWidget::getPaddingRect
Rect getPaddingRect()
Definition: uiwidget.cpp:1054
graphics.h
Creature::drawOutfit
void drawOutfit(const Rect &destRect, bool resize)
Definition: creature.cpp:196
Outfit::setBody
void setBody(int body)
Definition: outfit.h:44
UICreature::onStyleApply
void onStyleApply(const std::string &styleName, const OTMLNodePtr &styleNode)
Definition: uicreature.cpp:49
Outfit::setFeet
void setFeet(int feet)
Definition: outfit.h:46
otml.h
TRect< int >
UIWidget::onStyleApply
virtual void onStyleApply(const std::string &styleName, const OTMLNodePtr &styleNode)
Definition: uiwidget.cpp:1461
UICreature::setFixedCreatureSize
void setFixedCreatureSize(bool fixed)
Definition: uicreature.h:36
Creature::setDirection
void setDirection(Otc::Direction direction)
Definition: creature.cpp:659
Creature
Definition: creature.h:37
UIWidget::drawSelf
virtual void drawSelf(Fw::DrawPane drawPane)
Definition: uiwidget.cpp:88
OTMLNode::children
OTMLNodeList children()
Definition: otmlnode.cpp:170
CreaturePtr
stdext::shared_object_ptr< Creature > CreaturePtr
Definition: declarations.h:63
UIWidget::m_imageColor
Color m_imageColor
Definition: uiwidget.h:417
Outfit
Definition: outfit.h:29
Outfit::setId
void setId(int id)
Definition: outfit.h:41
Outfit::setHead
void setHead(int head)
Definition: outfit.h:43
uicreature.h
Creature::getOutfit
Outfit getOutfit()
Definition: creature.h:85
UICreature::m_fixedCreatureSize
stdext::boolean< false > m_fixedCreatureSize
Definition: uicreature.h:46
UICreature::m_creature
CreaturePtr m_creature
Definition: uicreature.h:45
Otc::South
@ South
Definition: const.h:164
UICreature::drawSelf
void drawSelf(Fw::DrawPane drawPane)
Definition: uicreature.cpp:27
Fw::DrawPane
DrawPane
Definition: const.h:285
stdext::shared_object_ptr< OTMLNode >
Fw::ForegroundPane
@ ForegroundPane
Definition: const.h:286
g_painter
Painter * g_painter
Definition: painter.cpp:28
UICreature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: uicreature.cpp:41
Creature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: creature.cpp:665
Outfit::setLegs
void setLegs(int legs)
Definition: outfit.h:45