[Scummvm-git-logs] scummvm master -> d0fd1de710a3dc987cc0497d2fa0330b097e4b07
sev-
noreply at scummvm.org
Sun Jun 2 00:05:16 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:
d0fd1de710 DIRECTOR: DT: Highlight variables that got changed
Commit: d0fd1de710a3dc987cc0497d2fa0330b097e4b07
https://github.com/scummvm/scummvm/commit/d0fd1de710a3dc987cc0497d2fa0330b097e4b07
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-06-02T02:05:02+02:00
Commit Message:
DIRECTOR: DT: Highlight variables that got changed
Changed paths:
engines/director/debugger/debugtools.cpp
engines/director/debugger/dt-internal.h
engines/director/debugger/dt-lists.cpp
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index 8d68368424a..72ed100946d 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -202,8 +202,8 @@ void showImage(const ImGuiImage &image, const char *name, float thumbnailSize) {
setToolTipImage(image, name);
}
-void displayVariable(const Common::String &name) {
- const ImU32 var_color = ImGui::GetColorU32(ImVec4(0.9f, 0.9f, 0.0f, 1.0f));
+void displayVariable(const Common::String &name, bool changed) {
+ 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));
const ImU32 disp_color_enabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 1.0f));
@@ -231,6 +231,9 @@ void displayVariable(const Common::String &name) {
}
}
+ if (changed)
+ var_color = ImGui::GetColorU32(_state->_colors._changed_var_color);
+
if (color == disp_color_disabled && ImGui::IsItemHovered()) {
color = disp_color_hover;
}
diff --git a/engines/director/debugger/dt-internal.h b/engines/director/debugger/dt-internal.h
index 608a3c2af02..92a9df0f1b7 100644
--- a/engines/director/debugger/dt-internal.h
+++ b/engines/director/debugger/dt-internal.h
@@ -122,6 +122,7 @@ typedef struct ImGuiState {
ImVec4 _bp_color_disabled = ImVec4(0.9f, 0.08f, 0.0f, 0.0f);
ImVec4 _bp_color_enabled = ImVec4(0.9f, 0.08f, 0.0f, 1.0f);
ImVec4 _bp_color_hover = ImVec4(0.42f, 0.17f, 0.13f, 1.0f);
+
ImVec4 _current_statement = ImColor(IM_COL32(0xFF, 0xFF, 0x00, 0xFF));
ImVec4 _line_color = ImVec4(0.44f, 0.44f, 0.44f, 1.0f);
ImVec4 _call_color = ImColor(IM_COL32(0xFF, 0xC5, 0x5C, 0xFF));
@@ -132,11 +133,17 @@ typedef struct ImGuiState {
ImVec4 _type_color = ImColor(IM_COL32(0x13, 0xC5, 0xF9, 0xFF));
ImVec4 _keyword_color = ImColor(IM_COL32(0xC1, 0xC1, 0xC1, 0xFF));
ImVec4 _the_color = ImColor(IM_COL32(0xFF, 0x49, 0xEF, 0xFF));
+
+ ImVec4 _changed_var_color = ImColor(IM_COL32(0xFF, 0x00, 0x00, 0xFF));
} _colors;
struct {
DatumHash _locals;
DatumHash _globals;
+
+ DatumHash _prevLocals;
+ DatumHash _prevGlobals;
+
uint32 _lastTimeRefreshed = 0;
} _vars;
@@ -203,7 +210,7 @@ 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 displayVariable(const Common::String &name, bool changed);
void showCast(); // dt-cast.cpp
void showControlPanel(); // dt-controlpanel.cpp
diff --git a/engines/director/debugger/dt-lists.cpp b/engines/director/debugger/dt-lists.cpp
index 7d5e1a9ba5a..924075c0a4f 100644
--- a/engines/director/debugger/dt-lists.cpp
+++ b/engines/director/debugger/dt-lists.cpp
@@ -42,21 +42,27 @@ void showCallStack() {
ImGui::End();
}
-void showVars() {
- if (!_state->_w.vars)
- return;
-
+static void cacheVars() {
// take a snapshot of the variables every 500 ms
if ((g_director->getTotalPlayTime() - _state->_vars._lastTimeRefreshed) > 500) {
+ _state->_vars._prevLocals = _state->_vars._locals;
if (g_lingo->_state->localVars) {
_state->_vars._locals = *g_lingo->_state->localVars;
} else {
_state->_vars._locals.clear();
}
+ _state->_vars._prevGlobals = _state->_vars._globals;
_state->_vars._globals = g_lingo->_globalvars;
_state->_vars._lastTimeRefreshed = g_director->getTotalPlayTime();
}
+}
+
+void showVars() {
+ if (!_state->_w.vars)
+ return;
+
+ cacheVars();
Director::Lingo *lingo = g_director->getLingo();
ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
@@ -71,7 +77,8 @@ void showVars() {
Common::sort(keyBuffer.begin(), keyBuffer.end());
for (auto &i : keyBuffer) {
Datum &val = _state->_vars._globals.getVal(i);
- displayVariable(i);
+ bool changed = !_state->_vars._prevGlobals.contains(i) || !(_state->_vars._globals.getVal(i) == _state->_vars._prevGlobals.getVal(i));
+ displayVariable(i, changed);
ImGui::SameLine();
ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
}
@@ -85,7 +92,8 @@ void showVars() {
Common::sort(keyBuffer.begin(), keyBuffer.end());
for (auto &i : keyBuffer) {
Datum &val = _state->_vars._locals.getVal(i);
- displayVariable(i);
+ bool changed = !_state->_vars._prevLocals.contains(i) || !(_state->_vars._locals.getVal(i) == _state->_vars._prevLocals.getVal(i));
+ displayVariable(i, changed);
ImGui::SameLine();
ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
}
@@ -103,7 +111,7 @@ void showVars() {
Common::sort(keyBuffer.begin(), keyBuffer.end());
for (auto &i : keyBuffer) {
Datum val = script->getProp(i);
- displayVariable(i);
+ displayVariable(i, false);
ImGui::SameLine();
ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
}
@@ -120,16 +128,7 @@ 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();
- }
+ cacheVars();
ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
@@ -139,7 +138,7 @@ void showWatchedVars() {
name.type = VARREF;
Datum val = g_lingo->varFetch(name, true);
- displayVariable(v._key);
+ displayVariable(v._key, false);
ImGui::SameLine();
ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
}
More information about the Scummvm-git-logs
mailing list