mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 11:52:04 +02:00
debug window enhancements
This commit is contained in:
parent
08cfd8a40e
commit
e6a20102d4
2 changed files with 29 additions and 4 deletions
|
@ -704,6 +704,15 @@ Menu::Menu() {
|
|||
addActionToQMenuAndActionHash(developerMenu, MenuOption::Log, Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
||||
qApp, SLOT(toggleLogDialog()));
|
||||
|
||||
action = addActionToQMenuAndActionHash(developerMenu, "Script Log (HMD friendly)...");
|
||||
connect(action, &QAction::triggered, [] {
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
QUrl defaultScriptsLoc = defaultScriptsLocation();
|
||||
defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
|
||||
scriptEngines->loadScript(defaultScriptsLoc.toString());
|
||||
});
|
||||
|
||||
|
||||
// Developer > Stats
|
||||
addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::Stats);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('debugWindow.qml');
|
||||
|
@ -19,18 +20,33 @@ var window = new OverlayWindow({
|
|||
window.setPosition(25, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
|
||||
var getFormattedDate = function() {
|
||||
var date = new Date();
|
||||
return date.getMonth() + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
};
|
||||
|
||||
var sendToLogWindow = function(type, message, scriptFileName) {
|
||||
var typeFormatted = "";
|
||||
if (type) {
|
||||
typeFormatted = type + " - ";
|
||||
}
|
||||
window.sendToQml("[" + getFormattedDate() + "] " + "[" + scriptFileName + "] " + typeFormatted + message);
|
||||
};
|
||||
|
||||
ScriptDiscoveryService.printedMessage.connect(function(message, scriptFileName) {
|
||||
window.sendToQml("[" + scriptFileName + "] " + message);
|
||||
sendToLogWindow("", message, scriptFileName);
|
||||
});
|
||||
|
||||
ScriptDiscoveryService.warningMessage.connect(function(message, scriptFileName) {
|
||||
window.sendToQml("[" + scriptFileName + "] WARNING - " + message);
|
||||
sendToLogWindow("WARNING", message, scriptFileName);
|
||||
});
|
||||
|
||||
ScriptDiscoveryService.errorMessage.connect(function(message, scriptFileName) {
|
||||
window.sendToQml("[" + scriptFileName + "] ERROR - " + message);
|
||||
sendToLogWindow("ERROR", message, scriptFileName);
|
||||
});
|
||||
|
||||
ScriptDiscoveryService.infoMessage.connect(function(message, scriptFileName) {
|
||||
window.sendToQml("[" + scriptFileName + "] INFO - " + message);
|
||||
sendToLogWindow("INFO", message, scriptFileName);
|
||||
});
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue