Allow GUI scripts to do debug printing to the console

Example:
  onActivate {
    set "print" "this windowDefs rect:" "$rect";
  }
(added to the Desktop of a GUI) prints
"GUI debug: this windowDefs rect: 0 0 640 480"
to the ingame console
This commit is contained in:
Daniel Gibson 2025-02-20 02:05:31 +01:00
parent 4aef5c1dd4
commit 384fd0cca1

View file

@ -63,6 +63,18 @@ void Script_Set(idWindow *window, idList<idGSWinVar> *src) {
}
return;
}
// DG: allow debugprinting to the console with `set "print" "this windowDefs rect:" "$rect"`
if (idStr::Icmp(*dest, "print") == 0) {
idStr msg;
int parmCount = src->Num();
for (int i=1; i<parmCount; ++i) {
msg += (*src)[i].var->c_str();
msg += " ";
}
common->Printf("GUI debug: %s\n", msg.c_str());
return;
}
}
(*src)[0].var->Set((*src)[1].var->c_str());
(*src)[0].var->SetEval(false);