File indexing completed on 2024-07-14 04:00:47

0001 /***************************************************************************
0002                                cmaproom.h
0003                              -------------------
0004     begin                : Sat Mar 10 2001
0005     copyright            : (C) 2001 by Kmud Developer Team
0006     email                : kmud-devel@kmud.de
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #ifndef CMAPROOM_H
0019 #define CMAPROOM_H
0020 
0021 #include <qcolor.h>
0022 #include <qstringlist.h>
0023 #include <QList>
0024 
0025 #include "cmapelement.h"
0026 
0027 class CMapPath;
0028 class CMapText;
0029 
0030 #include "kmemconfig.h"
0031 
0032 /**The class used to store room data
0033   *@author Kmud Developer Team
0034   */
0035 class KMUDDY_EXPORT CMapRoom : public CMapElement
0036 {
0037 public:
0038     enum labelPosTyp { NORTH =0, SOUTH , WEST , EAST , NORTHWEST, NORTHEAST, SOUTHEAST , SOUTHWEST, HIDE, CUSTOM } ;
0039 
0040 public: 
0041     CMapRoom(CMapManager *manager,QRect rect,CMapLevel *level);
0042     ~CMapRoom() override;
0043 
0044     elementTyp getElementType(void) override    { return ROOM ; }
0045 
0046         void setLevel(CMapLevel *level) override;
0047 
0048     void setLabel(QString str);
0049     QString getLabel(void)                      { return label; }
0050     void setDescription (QString str)           { description = str; }
0051     QString getDescription (void)               { return description; }
0052 
0053     /** Used to add a exit from the room */
0054     void addPath(CMapPath *path);
0055     /** Used to find the path for the give direction. If a path can't be found then
0056         null is returned                                                             */
0057         CMapPath *getPathDirection(directionTyp dir,QString specialCmd);
0058     CMapRoom *getPathTarget(directionTyp dir,QString specialCmd);
0059         directionTyp bestDirectionToRoom(CMapRoom *room);
0060     /** Get a list of the paths from this room */
0061     QList<CMapPath *> *getPathList() { return &pathList; }
0062     /** Get a list of the paths connecting with this room */
0063     QList<CMapPath *> *getConnectingPathList() { return &connectingPaths; }
0064     /** Get a pointer to the contents list */
0065     QStringList *getContentsList(void)          { return &contentsList; }
0066 
0067     void setUseDefaultCol(bool b)               { useDefaultCol = b; }
0068     bool getUseDefaultCol(void)                 { return useDefaultCol; }
0069     void setColor(QColor col)                  { color = col; }
0070     QColor getColor(void)                      { return color; }
0071 
0072     void setCurrentRoom(bool currentRoom);
0073     bool getCurrentRoom(void)                   { return current; }
0074     void setLoginRoom(bool loginRoom);
0075     bool getLoginRoom(void)                     { return login; }
0076 
0077     void setCopiedRoom(CMapRoom *room)          { copiedRoom = room; }
0078     CMapRoom *getCopiedRoom(void)               { return copiedRoom; }
0079 
0080     void setMoveTime(int moveTime)              { time = moveTime; }
0081     int getMoveTime(void)                       { return time; }
0082 
0083     void paint(QPainter *p,CMapZone *) override;
0084     void dragPaint(QPoint offset,QPainter *p,CMapZone *) override;
0085     void lowerPaint(QPainter *p,CMapZone *) override;
0086     void higherPaint(QPainter *p,CMapZone *) override;
0087 
0088     CMapElement *copy(void) override;
0089 
0090     labelPosTyp getLabelPosition(void);
0091     void setLabelPosition(labelPosTyp pos);
0092     void setLabelPosition(labelPosTyp pos,CMapText *text);
0093     void textRemove(void);
0094 
0095     /** Used to load the properties of the element from a list of properties */
0096     void loadProperties(KConfigGroup properties) override;
0097     /** Used to save the properties of the element to a list of properties */
0098     void saveProperties(KConfigGroup properties) override;
0099     /** Used to save the element as an XML object 
0100       * @param properties The XML object to save the properties too
0101       * @param doc The XML Document */
0102     void saveQDomElement(QDomDocument *doc,QDomElement *properties) override;
0103     /** Used to load the properties from a XML object 
0104       * @param properties The XML object to load the properties too */
0105     void loadQDomElement(QDomElement *properties) override;
0106     
0107     /** Used to move the element relative to it's current position */
0108     void moveBy(QPoint offset) override;
0109     /** This is used to resize the element */
0110     void resize(QPoint offset,int resizeId) override;
0111     /** This is used to get a unique ID for the room */
0112     unsigned int getRoomID(void);
0113     /** This is used to set the ID of the room */
0114     void setRoomID(unsigned int id);
0115     /** Get the text element linked to this element */
0116     CMapText *getLinkedElement(void)                       { return textElement; }
0117     
0118 protected:
0119     /** Used to paint the element at a given location and size
0120       * @param p The painer to paint the element to
0121       * @param pos The position to paint the elmenet
0122       * @param size The size the element should be draw
0123       * @param zone The current zone being viewed */
0124     void paintElementResize(QPainter *p,QPoint pos,QSize size,CMapZone *zone) override;
0125     void geometryChanged(void);
0126     
0127     unsigned int m_ID;
0128 
0129 private:
0130     int time;
0131     /** Used to store details of all the paths from this room */
0132     QList<CMapPath *> pathList;
0133     QList<CMapPath *> connectingPaths;
0134 
0135     QStringList contentsList;
0136 
0137     labelPosTyp labelPosition;
0138 
0139     bool current,login,useDefaultCol;
0140 
0141     QColor color;
0142 
0143     CMapText *textElement;
0144 
0145     QString label;
0146     QString description;
0147 
0148     CMapRoom *copiedRoom;
0149 };
0150 
0151 #endif