Skip to content

Commit

Permalink
DIRECTOR: Fix code viewer with D5
Browse files Browse the repository at this point in the history
  • Loading branch information
scemino committed May 28, 2024
1 parent 71a24ac commit f9aaf08
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions engines/director/debugtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,29 +429,36 @@ typedef struct ImGuiState {

ImGuiState *_state = nullptr;

const LingoDec::Handler *getHandler(CastMemberID id, const Common::String &handlerId) {
const Director::Movie *movie = g_director->getCurrentMovie();
const Cast *targets[2] = {movie->getCast(), movie->getSharedCast()};
for (int i = 0; i < 2; i++) {
const Cast *cast = targets[i];
if (!cast)
continue;
const ScriptContext *ctx = cast->_lingoArchive->findScriptContext(id.member);
if (!ctx || !ctx->_functionHandlers.contains(handlerId))
const LingoDec::Handler *getHandler(const Cast *cast, CastMemberID id, const Common::String &handlerId) {
if (!cast)
return nullptr;
const ScriptContext *ctx = cast->_lingoArchive->findScriptContext(id.member);
if (!ctx || !ctx->_functionHandlers.contains(handlerId))
return nullptr;
for (auto p : cast->_lingodec->scripts) {
if ((p.second->castID & 0xFFFF) != id.member)
continue;
for (auto p : cast->_lingodec->scripts) {
if (p.second->castID != id.member)
continue;
for (const LingoDec::Handler &handler : p.second->handlers) {
if (handler.name == handlerId) {
return &handler;
}
;
for (const LingoDec::Handler &handler : p.second->handlers) {
if (handler.name == handlerId) {
return &handler;
}
}
}
return nullptr;
}

const LingoDec::Handler *getHandler(CastMemberID id, const Common::String &handlerId) {
const Director::Movie *movie = g_director->getCurrentMovie();
for (const auto it : *movie->getCasts()) {
const Cast *cast = it._value;
const LingoDec::Handler *handler = getHandler(cast, id, handlerId);
if (handler)
return handler;
}
return getHandler(movie->getSharedCast(), id, handlerId);
}

ImGuiScript toImGuiScript(CastMemberID id, const Common::String &handlerId) {
ImGuiScript result;
result.id = id;
Expand Down

0 comments on commit f9aaf08

Please sign in to comment.