[Scummvm-git-logs] scummvm master -> 5e0112d7299fbabcd049727e4436cb4f5eaa437f
sev-
noreply at scummvm.org
Tue Jun 30 19:20:16 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
5e0112d729 DIRECTOR: DT: Fix script not rendering in script viewer (temporary fix)
Commit: 5e0112d7299fbabcd049727e4436cb4f5eaa437f
https://github.com/scummvm/scummvm/commit/5e0112d7299fbabcd049727e4436cb4f5eaa437f
Author: ramyak-sharma (ramyaksharma1 at gmail.com)
Date: 2026-06-30T21:20:12+02:00
Commit Message:
DIRECTOR: DT: Fix script not rendering in script viewer (temporary fix)
The script viewer fails to open for some cast members because
getScriptContext() returns null. As a workaround, when no compiled
AST is available, addToOpenHandlers() now falls back to displaying
the raw Lingo source text from CastMemberInfo::script.
Scripts using internal generic event handlers were also failing to
render because getHandler() matched handlers by name exactly, but
generic event handlers store an empty name and are identified only
by the isGenericEvent flag. Fix by also matching on
handler.isGenericEvent when handlerId is "scummvm_generic".
Changed paths:
engines/director/debugger/debugtools.cpp
engines/director/debugger/dt-castdetails.cpp
engines/director/debugger/dt-internal.h
engines/director/debugger/dt-score.cpp
engines/director/debugger/dt-scripts.cpp
diff --git a/engines/director/debugger/debugtools.cpp b/engines/director/debugger/debugtools.cpp
index f9c32539a1d..938b7f9a5a9 100644
--- a/engines/director/debugger/debugtools.cpp
+++ b/engines/director/debugger/debugtools.cpp
@@ -62,7 +62,7 @@ const LingoDec::Handler *getHandler(const Cast *cast, CastMemberID id, const Com
continue;
for (const LingoDec::Handler &handler : p.second->handlers) {
- if (handler.name == handlerId) {
+ if (handler.name == handlerId || (handler.isGenericEvent && handlerId == "scummvm_generic")) {
return &handler;
}
}
@@ -533,6 +533,21 @@ ImVec4 convertColor(uint32 color) {
}
void addToOpenHandlers(ImGuiScript handler) {
+ // If no decompiled AST is available, fall back to the source text from CastMemberInfo.
+ if (!handler.root && !handler.oldAst && handler.rawText.empty()) {
+ Movie *movie = g_director->getCurrentMovie();
+ if (movie) {
+ CastMember *member = movie->getCastMember(handler.id);
+ if (member) {
+ const CastMemberInfo *info = member->getInfo();
+ if (info && !info->script.empty()) {
+ handler.rawText = info->script;
+ handler.rawText.replace('\r', '\n');
+ }
+ }
+ }
+ }
+
ScriptData &data = _state->_openScripts;
_state->_w.scripts = true; // always (re)open the window
// Truncate forward history when navigating to a new script
diff --git a/engines/director/debugger/dt-castdetails.cpp b/engines/director/debugger/dt-castdetails.cpp
index 88ee550b014..9033b50e67a 100644
--- a/engines/director/debugger/dt-castdetails.cpp
+++ b/engines/director/debugger/dt-castdetails.cpp
@@ -581,6 +581,13 @@ void drawBaseCMprops(CastMember *member) {
script.handlerName = formatHandlerName(scriptCtx->_scriptId, scriptCastId.member, script.handlerId, scriptCtx->_scriptType, false);
addToOpenHandlers(script);
}
+ } else {
+ ImGuiScript script;
+ script.id = scriptCastId;
+ script.type = kCastScript;
+ script.moviePath = g_director->getCurrentMovie()->getArchive()->getPathName().toString();
+ script.handlerName = Common::String::format("Cast %d (source)", scriptCastId.member);
+ addToOpenHandlers(script);
}
}
} else {
diff --git a/engines/director/debugger/dt-internal.h b/engines/director/debugger/dt-internal.h
index 24d21b061d5..6f93bea0a8b 100644
--- a/engines/director/debugger/dt-internal.h
+++ b/engines/director/debugger/dt-internal.h
@@ -75,6 +75,7 @@ typedef struct ImGuiScript {
Common::Array<LingoDec::Bytecode> bytecodeArray;
Common::Array<uint> startOffsets;
Common::SharedPtr<Node> oldAst;
+ Common::String rawText;
bool operator==(const ImGuiScript &c) const {
return moviePath == c.moviePath && score == c.score && id == c.id && handlerId == c.handlerId;
diff --git a/engines/director/debugger/dt-score.cpp b/engines/director/debugger/dt-score.cpp
index 2f66701c6e6..c4422637a0f 100644
--- a/engines/director/debugger/dt-score.cpp
+++ b/engines/director/debugger/dt-score.cpp
@@ -974,13 +974,20 @@ static void drawMainChannelGrid(ImDrawList *dl, ImVec2 startPos, Score *score) {
case kChScript: // open script in script editor
if (mc.actionId.member) {
ScriptContext *ctx = getScriptContext(mc.actionId);
- if (!ctx)
- break;
- for (auto &handler : ctx->_functionHandlers) {
- ImGuiScript script = toImGuiScript(kScoreScript, mc.actionId, handler._key);
- script.byteOffsets = ctx->_functionByteOffsets[script.handlerId];
+ if (ctx) {
+ for (auto &handler : ctx->_functionHandlers) {
+ ImGuiScript script = toImGuiScript(kScoreScript, mc.actionId, handler._key);
+ script.byteOffsets = ctx->_functionByteOffsets[script.handlerId];
+ script.moviePath = g_director->getCurrentMovie()->getArchive()->getPathName().toString();
+ script.handlerName = formatHandlerName(ctx->_scriptId, mc.actionId.member, handler._key, kScoreScript, false);
+ addToOpenHandlers(script);
+ }
+ } else {
+ ImGuiScript script;
+ script.id = mc.actionId;
+ script.type = kScoreScript;
script.moviePath = g_director->getCurrentMovie()->getArchive()->getPathName().toString();
- script.handlerName = formatHandlerName(ctx->_scriptId, mc.actionId.member, handler._key, kScoreScript, false);
+ script.handlerName = Common::String::format("Cast %d (source)", mc.actionId.member);
addToOpenHandlers(script);
}
}
diff --git a/engines/director/debugger/dt-scripts.cpp b/engines/director/debugger/dt-scripts.cpp
index 562b24ddaaf..bb87930d09a 100644
--- a/engines/director/debugger/dt-scripts.cpp
+++ b/engines/director/debugger/dt-scripts.cpp
@@ -42,8 +42,11 @@ static void renderScript(ImGuiScript &script, bool showByteCode, bool scrollTo)
return;
}
- if (!script.root)
+ if (!script.root) {
+ if (!script.rawText.empty())
+ ImGui::TextUnformatted(script.rawText.c_str());
return;
+ }
renderScriptAST(script, showByteCode, scrollTo);
}
@@ -206,9 +209,11 @@ void showScriptsWindow() {
if (ImGui::Begin("Scripts", &_state->_w.scripts)) {
ScriptContext *ctx = getScriptContext(data._scripts[data._current].id);
+
if (ctx)
ImGui::Text("%s", ctx->asString().c_str());
+
if (renderScriptNavBar(data)) {
ImGui::Separator();
ImVec2 childSize = ImGui::GetContentRegionAvail();
More information about the Scummvm-git-logs
mailing list