00001 #ifndef HEADER_LEVELNODE_H 00002 #define HEADER_LEVELNODE_H 00003 00004 class Level; 00005 class NodeDrawer; 00006 00007 #include "V2.h" 00008 #include "Path.h" 00009 #include "NoCopy.h" 00010 00011 #include <string> 00012 #include <vector> 00013 00014 /** 00015 * Node on the map. 00016 */ 00017 class LevelNode : public NoCopy { 00018 public: 00019 enum eState { 00020 STATE_HIDDEN, 00021 STATE_FAR, 00022 STATE_OPEN, 00023 STATE_SOLVED 00024 }; 00025 private: 00026 static const int DOT_RADIUS = 13; 00027 std::string m_codename; 00028 std::string m_poster; 00029 Path m_datafile; 00030 V2 m_loc; 00031 eState m_state; 00032 int m_depth; 00033 typedef std::vector<class LevelNode*> t_children; 00034 t_children m_children; 00035 int m_bestMoves; 00036 std::string m_bestAuthor; 00037 private: 00038 bool isUnder(const V2 &cursor) const; 00039 public: 00040 LevelNode(const std::string &codename, const Path &datafile, 00041 const V2 &loc, const std::string &poster=""); 00042 virtual ~LevelNode(); 00043 void setState(eState state); 00044 eState getState() const { return m_state; } 00045 void setDepth(int depth) { m_depth = depth; } 00046 int getDepth() const { return m_depth; } 00047 00048 void bestSolution(int moves, const std::string &author); 00049 int getBestMoves() const { return m_bestMoves; } 00050 std::string getBestAuthor() const { return m_bestAuthor; } 00051 00052 std::string getCodename() const { return m_codename; } 00053 V2 getLoc() const { return m_loc; } 00054 std::string getPoster() const { return m_poster; } 00055 Level *createLevel() const; 00056 00057 void addChild(LevelNode *new_node); 00058 00059 LevelNode *findSelected(const V2 &cursor); 00060 LevelNode *findNamed(const std::string &codename); 00061 bool areAllSolved() const; 00062 bool isLeaf() const { return m_children.empty(); } 00063 00064 void drawPath(const NodeDrawer *drawer) const; 00065 }; 00066 00067 #endif