Debian Codegraph @

src/tools/dlgedit/dlg_circle.h

raw
1 /*
2 Copyright (C) 2002/2003 Kai Sterker <[email protected]>
3 Part of the Adonthell Project <http://adonthell.nongnu.org>
4
5 Dlgedit is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 Dlgedit is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Dlgedit. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /**
20 * @file dlg_circle.h
21 *
22 * @author Kai Sterker
23 * @brief The node containing the actual dialogue text.
24 */
25
26 #ifndef DLG_CIRCLE_H
27 #define DLG_CIRCLE_H
28
29 #include "dlg_node.h"
30 #include "dlg_circle_entry.h"
31
32 /**
33 * This is the node that contains the actual dialogue text and associated
34 * attributes, such as conditions or arbitrary (Python) code.
35 *
36 * There are three types of circles: Player, NPC and Narrator nodes.
37 * - Player nodes contain text assigned to the person in front of the screen.
38 * - NPC nodes are assigned to a certain, computer controlled entity.
39 * - Narrator nodes are assigned to an (imaginary) voice from the off.
40 */
41 class DlgCircle : public DlgNode
42 {
43 public:
44 /**
45 * Create an empty circle. Used when loading a circle.
46 * @param mid The id of the module the circle belongs to.
47 * @param nid The id of the circle.
48 */
49 DlgCircle (int mid = 0, int nid = 0)
50 { mode_ = IDLE; entry_ = NULL; mid_ = mid; nid_ = nid; }
51
52 /**
53 * Create a circle with basic information. Used to create a new circle.
54 * @param p The point where the circle needs to be created.
55 * @param t The type of the circle (PLAYER, NPC or NARRATOR).
56 * @param nid The unique id of the newly created circle.
57 * @param mid The id of the module the circle belongs to.
58 * @param e The actual contents of the circle.
59 */
60 DlgCircle (DlgPoint &p, node_type t, int nid, int mid, DlgCircleEntry *e = NULL);
61 /**
62 * Standard destructor.
63 */
64 ~DlgCircle ();
65
66 /**
67 * @name Methods for graph traversal
68 */
69 //@{
70 /**
71 * This method retrieves a %DlgCircle preceeding this node, i.e.
72 * (one of) it's parent(s).
73 * @param pos Defines from what position to start retrieving the parent.
74 * @param offset Get the parent found at the specified offset from the
75 * position given above.
76 * @return The %DlgCircle found at the specified offset from the
77 * given position.
78 * @see query_type
79 */
80 DlgCircle* parent (query_type pos, int offset = 1);
81 /**
82 * This method retrieves a %DlgCircle following this node, i.e.
83 * (one of) it's child(ren).
84 * @param pos Defines from what position to start retrieving the child.
85 * @param offset Get the child found at the specified offset from the
86 * position given above.
87 * @return The %DlgCircle found at the specified offset from the
88 * given position.
89 * @see query_type
90 */
91 DlgCircle* child (query_type pos, int offset = 1);
92 //@}
93
94 /**
95 * load circle from a file. The file to load from is a global variable,
96 * as loading is handled by a scanner generated with flex.
97 * @return <b>true</b> on success, <b>false</b> otherwise.
98 */
99 bool load ();
100
101 /**
102 * save a circle to a file
103 * @param file Stream to an open file
104 */
105 void save (std::ofstream &file);
106
107 /**
108 * Draw this node to the given surface with the specified offset.
109 * The node's current mode determines the color thw node is drawn with.
110 * @param surface the cairo_surface_t to draw to
111 * @param offset the DlgPoint to use as offset
112 * @param widget the GtkWidget to update after drawing
113 */
114 void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget);
115
116 /**
117 * Get the contents of this node.
118 * @return a DlgCircleEntry with the circle's text, code, conditions, etc.
119 */
120 DlgCircleEntry *entry () { return entry_; }
121
122 /**
123 * Get the text of this circle
124 * @return a string of the form "<NPC>: <Text>" if a certain NPC is
125 * attached to the node, otherwise returns only the text.
126 */
127 std::string text ();
128
129 /**
130 * Get the text of this circle for use with the GuiTooltip
131 * @return a string of the form "<condition>\n<Text>\n<code>".
132 */
133 std::string tooltip ();
134
135 /**
136 * Check whether any arbitrary Python code is assigned to this circle.
137 * @return <b>true</b> if this is the case, <b>false</b> otherwise.
138 */
139 bool hasCode () { return entry_->hasCode (); }
140
141 /**
142 * Check whether the given node is a child of this circle
143 * @return <b>true</b> if this is the case, <b>false</b> otherwise.
144 */
145 bool hasChild (DlgNode *child);
146
147 private:
148 DlgCircleEntry *entry_;
149 };
150
151 #endif // DLG_CIRCLE_H