Debian Codegraph @

src/menu/LevelNode.h

raw
1 #ifndef HEADER_LEVELNODE_H
2 #define HEADER_LEVELNODE_H
3
4 class Level;
5 class NodeDrawer;
6
7 #include "V2.h"
8 #include "Path.h"
9 #include "NoCopy.h"
10
11 #include <string>
12 #include <vector>
13
14 /**
15 * Node on the map.
16 */
17 class LevelNode : public NoCopy {
18 public:
19 enum eState {
20 STATE_HIDDEN,
21 STATE_FAR,
22 STATE_OPEN,
23 STATE_SOLVED
24 };
25 private:
26 static const int DOT_RADIUS = 13;
27 std::string m_codename;
28 std::string m_poster;
29 Path m_datafile;
30 V2 m_loc;
31 eState m_state;
32 int m_depth;
33 typedef std::vector<class LevelNode*> t_children;
34 t_children m_children;
35 int m_bestMoves;
36 std::string m_bestAuthor;
37 private:
38 bool isUnder(const V2 &cursor) const;
39 t_children findOpenNodes();
40 public:
41 LevelNode(const std::string &codename, const Path &datafile,
42 const V2 &loc, const std::string &poster="");
43 virtual ~LevelNode();
44 void setState(eState state);
45 eState getState() const { return m_state; }
46 void setDepth(int depth) { m_depth = depth; }
47 int getDepth() const { return m_depth; }
48
49 void bestSolution(int moves, const std::string &author);
50 int getBestMoves() const { return m_bestMoves; }
51 std::string getBestAuthor() const { return m_bestAuthor; }
52
53 std::string getCodename() const { return m_codename; }
54 V2 getLoc() const { return m_loc; }
55 std::string getPoster() const { return m_poster; }
56 Level *createLevel() const;
57
58 void addChild(LevelNode *new_node);
59
60 LevelNode *findSelected(const V2 &cursor);
61 LevelNode *findNextOpen(const LevelNode *current);
62 LevelNode *findNamed(const std::string &codename);
63 bool areAllSolved() const;
64 bool isLeaf() const { return m_children.empty(); }
65
66 void drawPath(const NodeDrawer *drawer) const;
67 };
68
69 #endif