File indexing completed on 2024-04-28 05:38:11
0001 /*************************************************************************** 0002 * Copyright (C) 2010 by Renaud Guezennec * 0003 * * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef CHARACTERITEM_H 0021 #define CHARACTERITEM_H 0022 0023 #include <QAction> 0024 #include <QPointer> 0025 0026 #include "data/characterstate.h" 0027 #include "data/charactervision.h" 0028 #include "data/person.h" 0029 #include "diceparser/diceparser.h" 0030 #include "rwidgets/rwidgets_global.h" 0031 #include "visualitem.h" 0032 #include <memory> 0033 namespace vmap 0034 { 0035 class CharacterItemController; 0036 } 0037 /** 0038 * @brief represents any character on map. 0039 */ 0040 class RWIDGET_EXPORT CharacterItem : public VisualItem 0041 { 0042 Q_OBJECT 0043 public: 0044 enum Corner 0045 { 0046 TopLeft, 0047 TopRight, 0048 BottomRight, 0049 BottomLeft, 0050 SightAngle, 0051 SightLenght 0052 }; 0053 Q_ENUM(Corner) 0054 /** 0055 * @brief CharacterItem 0056 */ 0057 CharacterItem(vmap::CharacterItemController* ctrl); 0058 ~CharacterItem() override; 0059 0060 // Override 0061 virtual QRectF boundingRect() const override; 0062 virtual QPainterPath shape() const override; 0063 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget= nullptr) override; 0064 void updateChildPosition() override; 0065 virtual void addActionContextMenu(QMenu&) override; 0066 void setNewEnd(const QPointF& p) override; 0067 0068 // accessors 0069 void addChildPoint(ChildPointItem* item); 0070 void sendVisionMsg(); 0071 void updateCharacter(); 0072 0073 signals: 0074 void positionChanged(); 0075 void geometryChangeOnUnkownChild(qreal pointId, QPointF& F); 0076 void localItemZValueChange(CharacterItem*); 0077 void ownerChanged(Character* old, CharacterItem*); 0078 void runDiceCommand(QString cmd, QString uuid); 0079 0080 protected: 0081 virtual void wheelEvent(QGraphicsSceneWheelEvent* event) override; 0082 0083 private slots: 0084 void changeCharacter(); 0085 0086 private: 0087 QPointer<vmap::CharacterItemController> m_itemCtrl; 0088 QPointer<VectorialMapController> m_mapCtrl; 0089 0090 // QAction 0091 std::unique_ptr<QAction> m_visionShapeDisk; 0092 std::unique_ptr<QAction> m_visionShapeAngle; 0093 std::unique_ptr<QAction> m_reduceLife; 0094 std::unique_ptr<QAction> m_increaseLife; 0095 }; 0096 0097 #endif // CHARACTERITEM_H