[Scummvm-git-logs] scummvm master -> a0d6cfbf56fa1b357ac8eb67dec697a0f0cae660

sev- noreply at scummvm.org
Thu May 9 21:12:00 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
7b6ce1866a iDIRECTOR: DEBUGGER: Unwind variable list code
a0d6cfbf56 DIRECTOR: DEBUGGER: Made variables clickable and selectable


Commit: 7b6ce1866ab1dbc5e72ba07dddf375e8bb55cbaa
    https://github.com/scummvm/scummvm/commit/7b6ce1866ab1dbc5e72ba07dddf375e8bb55cbaa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-05-09T21:19:15+02:00

Commit Message:
iDIRECTOR: DEBUGGER: Unwind variable list code

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index 98dd015cfde..df353963530 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -615,9 +615,52 @@ static void showVars() {
 
 	Director::Lingo *lingo = g_director->getLingo();
 	ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
-	ImGui::SetNextWindowSize(ImVec2(120, 120), ImGuiCond_FirstUseEver);
+	ImGui::SetNextWindowSize(ImVec2(300, 250), ImGuiCond_FirstUseEver);
 	if (ImGui::Begin("Vars", &_state->_showVars)) {
-		ImGui::Text("%s", lingo->formatAllVars().c_str());
+		Common::Array<Common::String> keyBuffer;
+		const ImVec4 head_color = ImVec4(0.9f, 0.08f, 0.0f, 1.0f);
+
+
+		ImGui::TextColored(head_color, "Local vars:");
+		if (lingo->_state->localVars) {
+			for (auto &it : *lingo->_state->localVars) {
+				keyBuffer.push_back(it._key);
+			}
+			Common::sort(keyBuffer.begin(), keyBuffer.end());
+			for (auto &i : keyBuffer) {
+				Datum &val = lingo->_state->localVars->getVal(i);
+				ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+			}
+			keyBuffer.clear();
+		} else {
+			ImGui::Text("  (no local vars)");
+		}
+
+		if (lingo->_state->me.type == OBJECT && lingo->_state->me.u.obj->getObjType() & (kFactoryObj | kScriptObj)) {
+			ScriptContext *script = static_cast<ScriptContext *>(lingo->_state->me.u.obj);
+			ImGui::TextColored(head_color, "Instance/property vars:");
+			for (auto &it : script->_properties) {
+				keyBuffer.push_back(it._key);
+			}
+			Common::sort(keyBuffer.begin(), keyBuffer.end());
+			for (auto &i : keyBuffer) {
+				Datum &val = script->_properties.getVal(i);
+				ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+			}
+			keyBuffer.clear();
+		}
+
+		ImGui::TextColored(head_color, "Global vars:");
+		for (auto &it : lingo->_globalvars) {
+			keyBuffer.push_back(it._key);
+		}
+		Common::sort(keyBuffer.begin(), keyBuffer.end());
+		for (auto &i : keyBuffer) {
+			Datum &val = lingo->_globalvars.getVal(i);
+			ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+		}
+		keyBuffer.clear();
+
 		ImGui::Separator();
 		ImGuiIO &io = ImGui::GetIO();
 		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
@@ -792,10 +835,10 @@ static void renderCastScript(Symbol &sym) {
 
 	ImDrawList *dl = ImGui::GetWindowDrawList();
 
-	ImU32 bp_color_disabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 0.0f));
-	ImU32 bp_color_enabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 1.0f));
-	ImU32 bp_color_hover = ImGui::GetColorU32(ImVec4(0.42f, 0.17f, 0.13f, 1.0f));
-	ImU32 line_color = ImGui::GetColorU32(ImVec4(0.44f, 0.44f, 0.44f, 1.0f));
+	const ImU32 bp_color_disabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 0.0f));
+	const ImU32 bp_color_enabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 1.0f));
+	const ImU32 bp_color_hover = ImGui::GetColorU32(ImVec4(0.42f, 0.17f, 0.13f, 1.0f));
+	const ImU32 line_color = ImGui::GetColorU32(ImVec4(0.44f, 0.44f, 0.44f, 1.0f));
 	ImU32 color;
 
 	uint pc = 0;


Commit: a0d6cfbf56fa1b357ac8eb67dec697a0f0cae660
    https://github.com/scummvm/scummvm/commit/a0d6cfbf56fa1b357ac8eb67dec697a0f0cae660
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-05-09T23:11:19+02:00

Commit Message:
DIRECTOR: DEBUGGER: Made variables clickable and selectable

Changed paths:
    engines/director/debugtools.cpp


diff --git a/engines/director/debugtools.cpp b/engines/director/debugtools.cpp
index df353963530..4395d3b233c 100644
--- a/engines/director/debugtools.cpp
+++ b/engines/director/debugtools.cpp
@@ -96,6 +96,7 @@ typedef struct ImGuiState {
 	bool _showFuncList = false;
 	Common::List<CastMemberID> _scriptCasts;
 	Common::HashMap<Common::String, bool, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _breakpoints;
+	Common::HashMap<Common::String, bool, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _variables;
 	int _prevFrame = -1;
 } ImGuiState;
 
@@ -609,6 +610,43 @@ static void showCast() {
 	ImGui::End();
 }
 
+static void displayVariable(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));
+	const ImU32 disp_color_enabled = ImGui::GetColorU32(ImVec4(0.9f, 0.08f, 0.0f, 1.0f));
+	const ImU32 disp_color_hover = ImGui::GetColorU32(ImVec4(0.42f, 0.17f, 0.13f, 1.0f));
+	ImU32 color;
+
+	color = disp_color_disabled;
+
+	if (_state->_variables.contains(name))
+		color = disp_color_enabled;
+
+	ImDrawList *dl = ImGui::GetWindowDrawList();
+	ImVec2 pos = ImGui::GetCursorScreenPos();
+	ImVec2 eyeSize = ImGui::CalcTextSize("\ue05b ");
+	ImVec2 textSize = ImGui::CalcTextSize(name.c_str());
+
+	ImGui::InvisibleButton("Line", ImVec2(textSize.x + eyeSize.x, textSize.y));
+	if (ImGui::IsItemClicked(0)) {
+		if (color == disp_color_enabled) {
+			_state->_variables.erase(name);
+			color = disp_color_disabled;
+		} else {
+			_state->_variables[name] = true;
+			color = disp_color_enabled;
+		}
+	}
+
+	if (color == disp_color_disabled && ImGui::IsItemHovered()) {
+		color = disp_color_hover;
+	}
+
+	dl->AddText(pos, color, "\ue05b ");
+	dl->AddText(ImVec2(pos.x + eyeSize.x, pos.y), var_color, name.c_str());
+}
+
 static void showVars() {
 	if (!_state->_showVars)
 		return;
@@ -629,7 +667,9 @@ static void showVars() {
 			Common::sort(keyBuffer.begin(), keyBuffer.end());
 			for (auto &i : keyBuffer) {
 				Datum &val = lingo->_state->localVars->getVal(i);
-				ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+				displayVariable(i);
+				ImGui::SameLine();
+				ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
 			}
 			keyBuffer.clear();
 		} else {
@@ -645,7 +685,9 @@ static void showVars() {
 			Common::sort(keyBuffer.begin(), keyBuffer.end());
 			for (auto &i : keyBuffer) {
 				Datum &val = script->_properties.getVal(i);
-				ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+				displayVariable(i);
+				ImGui::SameLine();
+				ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
 			}
 			keyBuffer.clear();
 		}
@@ -657,13 +699,11 @@ static void showVars() {
 		Common::sort(keyBuffer.begin(), keyBuffer.end());
 		for (auto &i : keyBuffer) {
 			Datum &val = lingo->_globalvars.getVal(i);
-			ImGui::Text("  %s - [%s] %s", i.c_str(), val.type2str(), formatStringForDump(val.asString(true)).c_str());
+			displayVariable(i);
+			ImGui::SameLine();
+			ImGui::Text(" - [%s] %s", val.type2str(), formatStringForDump(val.asString(true)).c_str());
 		}
 		keyBuffer.clear();
-
-		ImGui::Separator();
-		ImGuiIO &io = ImGui::GetIO();
-		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
 	}
 	ImGui::End();
 }




More information about the Scummvm-git-logs mailing list