[Scummvm-git-logs] scummvm master -> 96d7717c35e024fc9a5f7874c7ba235e9fd08d96
sev-
noreply at scummvm.org
Sat Jun 1 19:02:00 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
96d7717c35 DIRECTOR: DT: Moved out various list windows to dt-list.cpp
Commit: 96d7717c35e024fc9a5f7874c7ba235e9fd08d96
https://github.com/scummvm/scummvm/commit/96d7717c35e024fc9a5f7874c7ba235e9fd08d96
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-06-01T21:01:31+02:00
Commit Message:
DIRECTOR: DT: Moved out various list windows to dt-list.cpp
Changed paths:
A engines/director/debugger/dt-lists.cpp
engines/director/debugger/debugtools.cpp
engines/director/debugger/dt-internal.h
engines/director/module.mk
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index 233bbd42b6e..8d68368424a 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -131,19 +131,6 @@ Director::Breakpoint *getBreakpoint(const Common::String &handlerName, uint16 sc
return nullptr;
}
-static void showCallStack() {
- if (!_state->_w.callStack)
- return;
-
- Director::Lingo *lingo = g_director->getLingo();
- ImGui::SetNextWindowPos(ImVec2(20, 160), ImGuiCond_FirstUseEver);
- ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
- if (ImGui::Begin("CallStack", &_state->_w.callStack)) {
- ImGui::Text("%s", lingo->formatCallStack(lingo->_state->pc).c_str());
- }
- ImGui::End();
-}
-
static GLuint loadTextureFromSurface(Graphics::Surface *surface, const byte *palette, int palCount) {
// Create a OpenGL texture identifier
@@ -215,7 +202,7 @@ void showImage(const ImGuiImage &image, const char *name, float thumbnailSize) {
setToolTipImage(image, name);
}
-static void displayVariable(const Common::String &name) {
+void displayVariable(const Common::String &name) {
const ImU32 var_color = ImGui::GetColorU32(ImVec4(0.9f, 0.9f, 0.0f, 1.0f));
const ImU32 disp_color_disabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 0.0f));
@@ -252,80 +239,6 @@ static void displayVariable(const Common::String &name) {
dl->AddText(ImVec2(pos.x + eyeSize.x, pos.y), var_color, name.c_str());
}
-static void showVars() {
- if (!_state->_w.vars)
- return;
-
- // take a snapshot of the variables every 500 ms
- if ((g_director->getTotalPlayTime() - _state->_vars._lastTimeRefreshed) > 500) {
- if (g_lingo->_state->localVars) {
- _state->_vars._locals = *g_lingo->_state->localVars;
- } else {
- _state->_vars._locals.clear();
- }
-
- _state->_vars._globals = g_lingo->_globalvars;
- _state->_vars._lastTimeRefreshed = g_director->getTotalPlayTime();
- }
-
- Director::Lingo *lingo = g_director->getLingo();
- ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
- ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
- if (ImGui::Begin("Vars", &_state->_w.vars)) {
- Common::Array<Common::String> keyBuffer;
-
- if (ImGui::CollapsingHeader("Global vars:", ImGuiTreeNodeFlags_DefaultOpen)) {
- for (auto &it : _state->_vars._globals) {
- keyBuffer.push_back(it._key);
- }
- Common::sort(keyBuffer.begin(), keyBuffer.end());
- for (auto &i : keyBuffer) {
- Datum &val = _state->_vars._globals.getVal(i);
- displayVariable(i);
- ImGui::SameLine();
- ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
- }
- keyBuffer.clear();
- }
- if (ImGui::CollapsingHeader("Local vars:", ImGuiTreeNodeFlags_None)) {
- if (!_state->_vars._locals.empty()) {
- for (auto &it : _state->_vars._locals) {
- keyBuffer.push_back(it._key);
- }
- Common::sort(keyBuffer.begin(), keyBuffer.end());
- for (auto &i : keyBuffer) {
- Datum &val = _state->_vars._locals.getVal(i);
- displayVariable(i);
- ImGui::SameLine();
- ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
- }
- keyBuffer.clear();
- } else {
- ImGui::Text(" (no local vars)");
- }
- }
- if (ImGui::CollapsingHeader("Instance/property vars:", ImGuiTreeNodeFlags_None)) {
- if (lingo->_state->me.type == OBJECT && lingo->_state->me.u.obj->getObjType() & (kFactoryObj | kScriptObj)) {
- ScriptContext *script = static_cast<ScriptContext *>(lingo->_state->me.u.obj);
- for (uint32 i = 1; i <= script->getPropCount(); i++) {
- keyBuffer.push_back(script->getPropAt(i));
- }
- Common::sort(keyBuffer.begin(), keyBuffer.end());
- for (auto &i : keyBuffer) {
- Datum val = script->getProp(i);
- displayVariable(i);
- ImGui::SameLine();
- ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
- }
- keyBuffer.clear();
- } else {
- ImGui::Text(" (no instance or property)");
- }
- }
- }
- ImGui::End();
-}
-
ImVec4 convertColor(uint32 color) {
if (g_director->_colorDepth <= 8) {
float r = g_director->getPalette()[color * 3 + 0] * 1.0 / 255.0;
@@ -367,17 +280,6 @@ void displayScriptRef(CastMemberID &scriptId) {
}
}
-// Make the UI compact because there are so many fields
-static void PushStyleCompact() {
- ImGuiStyle &style = ImGui::GetStyle();
- ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.60f)));
- ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.60f)));
-}
-
-static void PopStyleCompact() {
- ImGui::PopStyleVar(2);
-}
-
static void showSettings() {
if (!_state->_w.settings)
return;
@@ -402,169 +304,6 @@ static void showSettings() {
ImGui::End();
}
-static void showBreakpointList() {
- if (!_state->_w.bpList)
- return;
-
- ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
- ImGui::SetNextWindowSize(ImVec2(480, 240), ImGuiCond_FirstUseEver);
- if (ImGui::Begin("Breakpoints", &_state->_w.bpList)) {
- auto &bps = g_lingo->getBreakpoints();
- if (ImGui::BeginTable("BreakpointsTable", 5, ImGuiTableFlags_SizingFixedFit)) {
- for (uint i = 0; i < 5; i++)
- ImGui::TableSetupColumn(NULL, i == 2 ? ImGuiTableColumnFlags_WidthStretch : ImGuiTableColumnFlags_NoHeaderWidth);
-
- for (uint i = 0; i < bps.size(); i++) {
- if (bps[i].type != kBreakpointFunction)
- continue;
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
-
- ImDrawList *dl = ImGui::GetWindowDrawList();
- ImVec2 pos = ImGui::GetCursorScreenPos();
- const ImVec2 mid(pos.x + 7, pos.y + 7);
-
- ImVec4 color = bps[i].enabled ? _state->_colors._bp_color_enabled : _state->_colors._bp_color_disabled;
- ImGui::InvisibleButton("Line", ImVec2(16, ImGui::GetFontSize()));
- if (ImGui::IsItemClicked(0)) {
- if (bps[i].enabled) {
- bps[i].enabled = false;
- color = _state->_colors._bp_color_disabled;
- } else {
- bps[i].enabled = true;
- color = _state->_colors._bp_color_enabled;
- }
- }
-
- if (!bps[i].enabled && ImGui::IsItemHovered()) {
- color = _state->_colors._bp_color_hover;
- }
-
- if (bps[i].enabled)
- dl->AddCircleFilled(mid, 4.0f, ImColor(color));
- else
- dl->AddCircle(mid, 4.0f, ImColor(_state->_colors._line_color));
-
- // enabled column
- ImGui::TableNextColumn();
- PushStyleCompact();
- ImGui::PushID(i);
- ImGui::Checkbox("", &bps[i].enabled);
- PopStyleCompact();
-
- // description
- ImGui::TableNextColumn();
- Common::String desc;
- if (bps[i].scriptId)
- desc = Common::String::format("%d: %s", bps[i].scriptId, bps[i].funcName.c_str());
- else
- desc = bps[i].funcName;
- ImGui::Text("%s", desc.c_str());
-
- // remove bp
- ImGui::TableNextColumn();
- pos = ImGui::GetCursorScreenPos();
- const bool del = ImGui::InvisibleButton("DelBp", ImVec2(16, ImGui::GetFontSize()));
- const bool hovered = ImGui::IsItemHovered();
- const float fontSize = ImGui::GetFontSize();
- const float cross_extent = ImGui::GetFontSize() * 0.5f * 0.7071f - 1.0f;
- const ImU32 cross_col = ImGui::GetColorU32(ImGuiCol_Text);
- const ImVec2 center = pos + ImVec2(0.5f + fontSize * 0.5f, 1.0f + fontSize * 0.5f);
- if (hovered)
- dl->AddCircleFilled(center, MAX(2.0f, fontSize * 0.5f + 1.0f), ImGui::GetColorU32(ImGuiCol_ButtonActive));
- dl->AddLine(center + ImVec2(+cross_extent, +cross_extent), center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f);
- dl->AddLine(center + ImVec2(+cross_extent, -cross_extent), center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f);
-
- // offset
- ImGui::TableNextColumn();
- ImGui::Text("%d", bps[i].funcOffset);
- ImGui::PopID();
-
- if (del) {
- g_lingo->delBreakpoint(bps[i].id);
- break;
- }
- }
- ImGui::EndTable();
- }
- }
- ImGui::End();
-}
-
-static void showArchive() {
- if (!_state->_w.archive)
- return;
-
- ImVec2 pos(40, 40);
- ImGui::SetNextWindowPos(pos, ImGuiCond_FirstUseEver);
-
- ImVec2 windowSize = ImGui::GetMainViewport()->Size * 0.8;
- ImGui::SetNextWindowSize(windowSize, ImGuiCond_FirstUseEver);
-
- if (ImGui::Begin("Archive", &_state->_w.archive)) {
- { // Left pane
- ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_None);
-
- for (auto &it : g_director->_allSeenResFiles) {
- Archive *archive = it._value;
-
- if (ImGui::TreeNode(archive->getPathName().toString().c_str())) {
- Common::Array<uint32> typeList = archive->getResourceTypeList();
- Common::sort(typeList.begin(), typeList.end());
-
- for (auto tag : typeList) {
- if (ImGui::TreeNode((void*)(intptr_t)tag, "%s", tag2str(tag))) {
- Common::Array<uint16> resList = archive->getResourceIDList(tag);
- Common::sort(resList.begin(), resList.end());
-
- for (auto id : resList) {
- if (ImGui::Selectable(Common::String::format("%d", id).c_str())) {
- _state->_archive.path = it._key;
- _state->_archive.resType = tag;
- _state->_archive.resId = id;
-
- free(_state->_archive.data);
-
- Common::SeekableReadStreamEndian *res = archive->getResource(tag, id);
- _state->_archive.data = (byte *)malloc(res->size());
- res->read(_state->_archive.data, res->size());
- _state->_archive.dataSize = res->size();
-
- delete res;
- }
- }
-
- ImGui::TreePop();
- }
- }
-
- ImGui::TreePop();
- }
- }
-
- ImGui::EndChild();
- }
-
- ImGui::SameLine();
-
- { // Right pane
- ImGui::BeginChild("ChildR", ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_Border);
-
- ImGui::Text("Resource %s %d (%d bytes)", tag2str(_state->_archive.resType), _state->_archive.resId, _state->_archive.dataSize);
-
- ImGui::Separator();
-
- if (!_state->_archive.path.empty())
- _state->_archive.memEdit.DrawContents(_state->_archive.data, _state->_archive.dataSize);
-
- ImGui::EndChild();
- }
-
- }
- ImGui::End();
-}
-
void onLog(LogMessageType::Type type, int level, uint32 debugChannels, const char *message) {
switch (type) {
case LogMessageType::kError:
@@ -582,40 +321,6 @@ void onLog(LogMessageType::Type type, int level, uint32 debugChannels, const cha
}
}
-static void showWatchedVars() {
- if (!_state->_w.watchedVars)
- return;
-
- if ((g_director->getTotalPlayTime() - _state->_vars._lastTimeRefreshed) > 500) {
- if (g_lingo->_state->localVars) {
- _state->_vars._locals = *g_lingo->_state->localVars;
- } else {
- _state->_vars._locals.clear();
- }
-
- _state->_vars._globals = g_lingo->_globalvars;
- _state->_vars._lastTimeRefreshed = g_director->getTotalPlayTime();
- }
-
- ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
- ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
- if (ImGui::Begin("Watched Vars", &_state->_w.watchedVars)) {
- for (auto &v : _state->_variables) {
- Datum name(v._key);
- name.type = VARREF;
- Datum val = g_lingo->varFetch(name, true);
-
- displayVariable(v._key);
- ImGui::SameLine();
- ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
- }
-
- if (_state->_variables.empty())
- ImGui::Text("(no watched variables)");
- }
- ImGui::End();
-}
-
void onImGuiInit() {
ImGuiIO &io = ImGui::GetIO();
io.Fonts->AddFontDefault();
diff --git a/engines/director/debugger/dt-internal.h b/engines/director/debugger/dt-internal.h
index 09c7b48a786..608a3c2af02 100644
--- a/engines/director/debugger/dt-internal.h
+++ b/engines/director/debugger/dt-internal.h
@@ -203,16 +203,29 @@ ImGuiImage getImageID(CastMember *castMember);
Common::String getDisplayName(CastMember *castMember);
void showImage(const ImGuiImage &image, const char *name, float thumbnailSize);
ImVec4 convertColor(uint32 color);
+void displayVariable(const Common::String &name);
void showCast(); // dt-cast.cpp
void showControlPanel(); // dt-controlpanel.cpp
-void showScore(); // dt-score.cpp
-void showChannels(); // dt-score.cpp
+
+// dt-lists.cpp
+void showCallStack();
+void showVars();
+void showWatchedVars();
+void showBreakpointList();
+void showArchive();
+
+// dt-score.cpp
+void showScore();
+void showChannels();
+
void renderOldScriptAST(ImGuiScript &script, bool showByteCode); // dt-script-d2.cpp
void renderScriptAST(ImGuiScript &script, bool showByteCode); // dt-script-d4.cpp
-void showFuncList(); // dt-scripts.cpp
-void showScriptCasts(); // dt-scripts.cpp
-void showScripts(); // dt-scripts.cpp
+
+// dt-scripts.cpp
+void showFuncList();
+void showScriptCasts();
+void showScripts();
extern ImGuiState *_state;
diff --git a/engines/director/debugger/dt-lists.cpp b/engines/director/debugger/dt-lists.cpp
new file mode 100644
index 00000000000..7d5e1a9ba5a
--- /dev/null
+++ b/engines/director/debugger/dt-lists.cpp
@@ -0,0 +1,329 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "director/director.h"
+#include "director/archive.h"
+#include "director/debugger.h"
+#include "director/debugger/dt-internal.h"
+
+#include "director/lingo/lingo-object.h"
+
+namespace Director {
+namespace DT {
+
+void showCallStack() {
+ if (!_state->_w.callStack)
+ return;
+
+ Director::Lingo *lingo = g_director->getLingo();
+ ImGui::SetNextWindowPos(ImVec2(20, 160), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("CallStack", &_state->_w.callStack)) {
+ ImGui::Text("%s", lingo->formatCallStack(lingo->_state->pc).c_str());
+ }
+ ImGui::End();
+}
+
+void showVars() {
+ if (!_state->_w.vars)
+ return;
+
+ // take a snapshot of the variables every 500 ms
+ if ((g_director->getTotalPlayTime() - _state->_vars._lastTimeRefreshed) > 500) {
+ if (g_lingo->_state->localVars) {
+ _state->_vars._locals = *g_lingo->_state->localVars;
+ } else {
+ _state->_vars._locals.clear();
+ }
+
+ _state->_vars._globals = g_lingo->_globalvars;
+ _state->_vars._lastTimeRefreshed = g_director->getTotalPlayTime();
+ }
+
+ Director::Lingo *lingo = g_director->getLingo();
+ ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Vars", &_state->_w.vars)) {
+ Common::Array<Common::String> keyBuffer;
+
+ if (ImGui::CollapsingHeader("Global vars:", ImGuiTreeNodeFlags_DefaultOpen)) {
+ for (auto &it : _state->_vars._globals) {
+ keyBuffer.push_back(it._key);
+ }
+ Common::sort(keyBuffer.begin(), keyBuffer.end());
+ for (auto &i : keyBuffer) {
+ Datum &val = _state->_vars._globals.getVal(i);
+ displayVariable(i);
+ ImGui::SameLine();
+ ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
+ }
+ keyBuffer.clear();
+ }
+ if (ImGui::CollapsingHeader("Local vars:", ImGuiTreeNodeFlags_None)) {
+ if (!_state->_vars._locals.empty()) {
+ for (auto &it : _state->_vars._locals) {
+ keyBuffer.push_back(it._key);
+ }
+ Common::sort(keyBuffer.begin(), keyBuffer.end());
+ for (auto &i : keyBuffer) {
+ Datum &val = _state->_vars._locals.getVal(i);
+ displayVariable(i);
+ ImGui::SameLine();
+ ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
+ }
+ keyBuffer.clear();
+ } else {
+ ImGui::Text(" (no local vars)");
+ }
+ }
+ if (ImGui::CollapsingHeader("Instance/property vars:", ImGuiTreeNodeFlags_None)) {
+ if (lingo->_state->me.type == OBJECT && lingo->_state->me.u.obj->getObjType() & (kFactoryObj | kScriptObj)) {
+ ScriptContext *script = static_cast<ScriptContext *>(lingo->_state->me.u.obj);
+ for (uint32 i = 1; i <= script->getPropCount(); i++) {
+ keyBuffer.push_back(script->getPropAt(i));
+ }
+ Common::sort(keyBuffer.begin(), keyBuffer.end());
+ for (auto &i : keyBuffer) {
+ Datum val = script->getProp(i);
+ displayVariable(i);
+ ImGui::SameLine();
+ ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
+ }
+ keyBuffer.clear();
+ } else {
+ ImGui::Text(" (no instance or property)");
+ }
+ }
+ }
+ ImGui::End();
+}
+
+void showWatchedVars() {
+ if (!_state->_w.watchedVars)
+ return;
+
+ if ((g_director->getTotalPlayTime() - _state->_vars._lastTimeRefreshed) > 500) {
+ if (g_lingo->_state->localVars) {
+ _state->_vars._locals = *g_lingo->_state->localVars;
+ } else {
+ _state->_vars._locals.clear();
+ }
+
+ _state->_vars._globals = g_lingo->_globalvars;
+ _state->_vars._lastTimeRefreshed = g_director->getTotalPlayTime();
+ }
+
+ ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Watched Vars", &_state->_w.watchedVars)) {
+ for (auto &v : _state->_variables) {
+ Datum name(v._key);
+ name.type = VARREF;
+ Datum val = g_lingo->varFetch(name, true);
+
+ displayVariable(v._key);
+ ImGui::SameLine();
+ ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
+ }
+
+ if (_state->_variables.empty())
+ ImGui::Text("(no watched variables)");
+ }
+ ImGui::End();
+}
+
+// Make the UI compact because there are so many fields
+static void PushStyleCompact() {
+ ImGuiStyle &style = ImGui::GetStyle();
+ ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.60f)));
+ ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.60f)));
+}
+
+static void PopStyleCompact() {
+ ImGui::PopStyleVar(2);
+}
+
+void showBreakpointList() {
+ if (!_state->_w.bpList)
+ return;
+
+ ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSize(ImVec2(480, 240), ImGuiCond_FirstUseEver);
+ if (ImGui::Begin("Breakpoints", &_state->_w.bpList)) {
+ auto &bps = g_lingo->getBreakpoints();
+ if (ImGui::BeginTable("BreakpointsTable", 5, ImGuiTableFlags_SizingFixedFit)) {
+ for (uint i = 0; i < 5; i++)
+ ImGui::TableSetupColumn(NULL, i == 2 ? ImGuiTableColumnFlags_WidthStretch : ImGuiTableColumnFlags_NoHeaderWidth);
+
+ for (uint i = 0; i < bps.size(); i++) {
+ if (bps[i].type != kBreakpointFunction)
+ continue;
+
+ ImGui::TableNextRow();
+ ImGui::TableNextColumn();
+
+ ImDrawList *dl = ImGui::GetWindowDrawList();
+ ImVec2 pos = ImGui::GetCursorScreenPos();
+ const ImVec2 mid(pos.x + 7, pos.y + 7);
+
+ ImVec4 color = bps[i].enabled ? _state->_colors._bp_color_enabled : _state->_colors._bp_color_disabled;
+ ImGui::InvisibleButton("Line", ImVec2(16, ImGui::GetFontSize()));
+ if (ImGui::IsItemClicked(0)) {
+ if (bps[i].enabled) {
+ bps[i].enabled = false;
+ color = _state->_colors._bp_color_disabled;
+ } else {
+ bps[i].enabled = true;
+ color = _state->_colors._bp_color_enabled;
+ }
+ }
+
+ if (!bps[i].enabled && ImGui::IsItemHovered()) {
+ color = _state->_colors._bp_color_hover;
+ }
+
+ if (bps[i].enabled)
+ dl->AddCircleFilled(mid, 4.0f, ImColor(color));
+ else
+ dl->AddCircle(mid, 4.0f, ImColor(_state->_colors._line_color));
+
+ // enabled column
+ ImGui::TableNextColumn();
+ PushStyleCompact();
+ ImGui::PushID(i);
+ ImGui::Checkbox("", &bps[i].enabled);
+ PopStyleCompact();
+
+ // description
+ ImGui::TableNextColumn();
+ Common::String desc;
+ if (bps[i].scriptId)
+ desc = Common::String::format("%d: %s", bps[i].scriptId, bps[i].funcName.c_str());
+ else
+ desc = bps[i].funcName;
+ ImGui::Text("%s", desc.c_str());
+
+ // remove bp
+ ImGui::TableNextColumn();
+ pos = ImGui::GetCursorScreenPos();
+ const bool del = ImGui::InvisibleButton("DelBp", ImVec2(16, ImGui::GetFontSize()));
+ const bool hovered = ImGui::IsItemHovered();
+ const float fontSize = ImGui::GetFontSize();
+ const float cross_extent = ImGui::GetFontSize() * 0.5f * 0.7071f - 1.0f;
+ const ImU32 cross_col = ImGui::GetColorU32(ImGuiCol_Text);
+ const ImVec2 center = pos + ImVec2(0.5f + fontSize * 0.5f, 1.0f + fontSize * 0.5f);
+ if (hovered)
+ dl->AddCircleFilled(center, MAX(2.0f, fontSize * 0.5f + 1.0f), ImGui::GetColorU32(ImGuiCol_ButtonActive));
+ dl->AddLine(center + ImVec2(+cross_extent, +cross_extent), center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f);
+ dl->AddLine(center + ImVec2(+cross_extent, -cross_extent), center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f);
+
+ // offset
+ ImGui::TableNextColumn();
+ ImGui::Text("%d", bps[i].funcOffset);
+ ImGui::PopID();
+
+ if (del) {
+ g_lingo->delBreakpoint(bps[i].id);
+ break;
+ }
+ }
+ ImGui::EndTable();
+ }
+ }
+ ImGui::End();
+}
+
+void showArchive() {
+ if (!_state->_w.archive)
+ return;
+
+ ImVec2 pos(40, 40);
+ ImGui::SetNextWindowPos(pos, ImGuiCond_FirstUseEver);
+
+ ImVec2 windowSize = ImGui::GetMainViewport()->Size * 0.8;
+ ImGui::SetNextWindowSize(windowSize, ImGuiCond_FirstUseEver);
+
+ if (ImGui::Begin("Archive", &_state->_w.archive)) {
+ { // Left pane
+ ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_None);
+
+ for (auto &it : g_director->_allSeenResFiles) {
+ Archive *archive = it._value;
+
+ if (ImGui::TreeNode(archive->getPathName().toString().c_str())) {
+ Common::Array<uint32> typeList = archive->getResourceTypeList();
+ Common::sort(typeList.begin(), typeList.end());
+
+ for (auto tag : typeList) {
+ if (ImGui::TreeNode((void*)(intptr_t)tag, "%s", tag2str(tag))) {
+ Common::Array<uint16> resList = archive->getResourceIDList(tag);
+ Common::sort(resList.begin(), resList.end());
+
+ for (auto id : resList) {
+ if (ImGui::Selectable(Common::String::format("%d", id).c_str())) {
+ _state->_archive.path = it._key;
+ _state->_archive.resType = tag;
+ _state->_archive.resId = id;
+
+ free(_state->_archive.data);
+
+ Common::SeekableReadStreamEndian *res = archive->getResource(tag, id);
+ _state->_archive.data = (byte *)malloc(res->size());
+ res->read(_state->_archive.data, res->size());
+ _state->_archive.dataSize = res->size();
+
+ delete res;
+ }
+ }
+
+ ImGui::TreePop();
+ }
+ }
+
+ ImGui::TreePop();
+ }
+ }
+
+ ImGui::EndChild();
+ }
+
+ ImGui::SameLine();
+
+ { // Right pane
+ ImGui::BeginChild("ChildR", ImVec2(ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y), ImGuiChildFlags_Border);
+
+ ImGui::Text("Resource %s %d (%d bytes)", tag2str(_state->_archive.resType), _state->_archive.resId, _state->_archive.dataSize);
+
+ ImGui::Separator();
+
+ if (!_state->_archive.path.empty())
+ _state->_archive.memEdit.DrawContents(_state->_archive.data, _state->_archive.dataSize);
+
+ ImGui::EndChild();
+ }
+
+ }
+ ImGui::End();
+}
+
+
+} // namespace DT
+} // namespace Director
diff --git a/engines/director/module.mk b/engines/director/module.mk
index dee347b0549..647ec854420 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -161,6 +161,7 @@ MODULE_OBJS += \
debugger/debugtools.o \
debugger/dt-cast.o \
debugger/dt-controlpanel.o \
+ debugger/dt-lists.o \
debugger/dt-logger.o \
debugger/dt-score.o \
debugger/dt-script-d2.o \
More information about the Scummvm-git-logs
mailing list