ScummVM API documentation
dt-internal.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DIRECTOR_DEBUGER_DT_INTERNAL_H
23 #define DIRECTOR_DEBUGER_DT_INTERNAL_H
24 
25 #ifndef IMGUI_DEFINE_MATH_OPERATORS
26 #define IMGUI_DEFINE_MATH_OPERATORS
27 #endif
28 
29 #include "graphics/surface.h"
30 
31 #include "backends/imgui/imgui.h"
32 #include "backends/imgui/imgui_fonts.h"
33 #include "backends/imgui/components/imgui_logger.h"
34 
35 #include "director/debugger/imgui_memory_editor.h"
36 
37 #include "director/types.h"
38 #include "director/lingo/lingo.h"
39 #include "director/lingo/lingodec/ast.h"
40 #include "director/lingo/lingodec/handler.h"
41 
42 namespace Director {
43 namespace DT {
44 
45 #define kMaxColumnsInTable 512
46 
47 typedef struct ImGuiImage {
48  ImTextureID id;
49  int16 width;
50  int16 height;
51 } ImGuiImage;
52 
53 typedef struct ImGuiScriptCodeLine {
54  uint32 pc;
55  Common::String codeLine;
57 
58 typedef struct ImGuiScript {
59  bool score = false;
60  CastMemberID id;
61  ScriptType type;
62  Common::String handlerId;
63  Common::String handlerName;
64  Common::String moviePath;
65  Common::Array<uint32> byteOffsets;
66 
67  bool isMethod = false;
68  bool isGenericEvent = false;
69  Common::StringArray argumentNames;
70  Common::StringArray propertyNames;
71  Common::StringArray globalNames;
74  Common::Array<uint> startOffsets;
76 
77  bool operator==(const ImGuiScript &c) const {
78  return moviePath == c.moviePath && score == c.score && id == c.id && handlerId == c.handlerId;
79  }
80  bool operator!=(const ImGuiScript &c) const {
81  return !(*this == c);
82  }
83 } ImGuiScript;
84 
85 typedef struct ImGuiWindows {
86  bool controlPanel = true;
87  bool callStack = false;
88  bool vars = false;
89  bool channels = false;
90  bool cast = false;
91  bool funcList = false;
92  bool score = false;
93  bool bpList = false;
94  bool settings = false;
95  bool logger = false;
96  bool archive = false;
97  bool watchedVars = false;
98 } ImGuiWindows;
99 
100 typedef struct ImGuiState {
101  struct {
103  bool _listView = true;
104  int _thumbnailSize = 64;
105  ImGuiTextFilter _nameFilter;
106  int _typeFilter = 0x7FFF;
107  } _cast;
108  struct {
110  uint _current = 0;
111  ImGuiTextFilter _nameFilter;
112  bool _showByteCode = false;
113  bool _showScript = false;
114  } _functions;
115  struct {
116  uint _lastLinePC = 0;
117  uint _callstackSize = 0;
118  bool _isScriptDirty = false; // indicates whether or not we have to display the script corresponding to the current stackframe
119  } _dbg;
120 
121  struct {
122  ImVec4 _bp_color_disabled = ImVec4(0.9f, 0.08f, 0.0f, 0.0f);
123  ImVec4 _bp_color_enabled = ImVec4(0.9f, 0.08f, 0.0f, 1.0f);
124  ImVec4 _bp_color_hover = ImVec4(0.42f, 0.17f, 0.13f, 1.0f);
125 
126  ImVec4 _current_statement = ImColor(IM_COL32(0xFF, 0xFF, 0x00, 0xFF));
127  ImVec4 _line_color = ImVec4(0.44f, 0.44f, 0.44f, 1.0f);
128  ImVec4 _call_color = ImColor(IM_COL32(0xFF, 0xC5, 0x5C, 0xFF));
129  ImVec4 _builtin_color = ImColor(IM_COL32(0x60, 0x7C, 0xFF, 0xFF));
130  ImVec4 _var_color = ImColor(IM_COL32(0x4B, 0xCD, 0x5E, 0xFF));
131  ImVec4 _literal_color = ImColor(IM_COL32(0xFF, 0x9F, 0xDA, 0x9E));
132  ImVec4 _comment_color = ImColor(IM_COL32(0xFF, 0xA5, 0x9D, 0x95));
133  ImVec4 _type_color = ImColor(IM_COL32(0x13, 0xC5, 0xF9, 0xFF));
134  ImVec4 _keyword_color = ImColor(IM_COL32(0xC1, 0xC1, 0xC1, 0xFF));
135  ImVec4 _the_color = ImColor(IM_COL32(0xFF, 0x49, 0xEF, 0xFF));
136 
137  ImVec4 _script_ref = ImColor(IM_COL32(0x7f, 0x7f, 0xff, 0xfff));
138  ImVec4 _var_ref = ImColor(IM_COL32(0xe6, 0xe6, 0x00, 0xff));
139  ImVec4 _var_ref_changed = ImColor(IM_COL32(0xFF, 0x00, 0x00, 0xFF));
140  } _colors;
141 
142  struct {
143  DatumHash _locals;
144  DatumHash _globals;
145 
146  DatumHash _prevLocals;
147  DatumHash _prevGlobals;
148 
149  uint32 _lastTimeRefreshed = 0;
150  } _vars;
151 
152  ImGuiWindows _w;
153  ImGuiWindows _savedW;
154  bool _wasHidden = false;
155 
156  Common::List<CastMemberID> _scriptCasts;
158  int _prevFrame = -1;
159  struct {
160  int frame = -1;
161  int channel = -1;
162  } _selectedScoreCast;
163 
164  int _scoreMode = 0;
165  int _scoreFrameOffset = 1;
166 
167  ImFont *_tinyFont = nullptr;
168 
169  struct {
170  Common::Path path;
171  uint32 resType = 0;
172  uint32 resId = 0;
173 
174  byte *data = nullptr;
175  uint32 dataSize = 0;
176 
177  MemoryEditor memEdit;
178  } _archive;
179 
180  ImGuiEx::ImGuiLogger *_logger = nullptr;
181 } ImGuiState;
182 
183 // debugtools.cpp
184 ImGuiScript toImGuiScript(ScriptType scriptType, CastMemberID id, const Common::String &handlerId);
185 void setScriptToDisplay(const ImGuiScript &script);
186 Director::Breakpoint *getBreakpoint(const Common::String &handlerName, uint16 scriptId, uint pc);
187 void displayScriptRef(CastMemberID &scriptId);
188 ImGuiImage getImageID(CastMember *castMember);
189 Common::String getDisplayName(CastMember *castMember);
190 void showImage(const ImGuiImage &image, const char *name, float thumbnailSize);
191 ImVec4 convertColor(uint32 color);
192 void displayVariable(const Common::String &name, bool changed);
193 
194 void showCast(); // dt-cast.cpp
195 void showControlPanel(); // dt-controlpanel.cpp
196 
197 // dt-lists.cpp
198 void showCallStack();
199 void showVars();
200 void showWatchedVars();
201 void showBreakpointList();
202 void showArchive();
203 
204 // dt-score.cpp
205 void showScore();
206 void showChannels();
207 
208 void renderOldScriptAST(ImGuiScript &script, bool showByteCode); // dt-script-d2.cpp
209 void renderScriptAST(ImGuiScript &script, bool showByteCode); // dt-script-d4.cpp
210 
211 // dt-scripts.cpp
212 void showFuncList();
213 void showScriptCasts();
214 void showScripts();
215 
216 extern ImGuiState *_state;
217 
218 }
219 
220 }
221 
222 #endif
Definition: str.h:59
Definition: dt-internal.h:53
Definition: dt-internal.h:47
Definition: imgui.h:308
Definition: list.h:44
Definition: path.h:52
Definition: archive.h:35
Definition: imgui.h:3532
Definition: dt-internal.h:85
Definition: imgui_memory_editor.h:69
Definition: hashmap.h:85
Definition: imgui_logger.h:33
Definition: imgui.h:2866
Definition: imgui.h:2653
Definition: dt-internal.h:100
Definition: debugger.h:45
Definition: dt-internal.h:58
Definition: castmember.h:45
Definition: types.h:414