mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:17:01 +02:00
Add display of server script status to edit.js
This commit is contained in:
parent
d45f5ade97
commit
c015ac1bd5
3 changed files with 101 additions and 2 deletions
|
@ -1388,6 +1388,37 @@ function pushCommandForSelections(createdEntityData, deletedEntityData) {
|
||||||
|
|
||||||
var ENTITY_PROPERTIES_URL = Script.resolvePath('html/entityProperties.html');
|
var ENTITY_PROPERTIES_URL = Script.resolvePath('html/entityProperties.html');
|
||||||
|
|
||||||
|
var ServerScriptStatusMonitor = function(entityID, statusCallback) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
self.entityID = entityID;
|
||||||
|
self.active = true;
|
||||||
|
self.sendRequestTimerID = null;
|
||||||
|
|
||||||
|
var onStatusReceived = function(success, isRunning, status, errorInfo) {
|
||||||
|
print("Got script status:", success, isRunning, status, errorInfo);
|
||||||
|
if (self.active) {
|
||||||
|
print("Requesting status of script");
|
||||||
|
statusCallback({
|
||||||
|
statusRetrieved: success,
|
||||||
|
isRunning: isRunning,
|
||||||
|
status: status,
|
||||||
|
errorInfo: errorInfo
|
||||||
|
});
|
||||||
|
self.sendRequestTimerID = Script.setTimeout(function() {
|
||||||
|
if (self.active) {
|
||||||
|
Entities.getServerScriptStatus(entityID, onStatusReceived);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
self.stop = function() {
|
||||||
|
self.active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entities.getServerScriptStatus(entityID, onStatusReceived);
|
||||||
|
};
|
||||||
|
|
||||||
var PropertiesTool = function (opts) {
|
var PropertiesTool = function (opts) {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
@ -1399,6 +1430,11 @@ var PropertiesTool = function (opts) {
|
||||||
|
|
||||||
var visible = false;
|
var visible = false;
|
||||||
|
|
||||||
|
// This keeps track of the last entity ID that was selected. If multiple entities
|
||||||
|
// are selected or if no entity is selected this will be `null`.
|
||||||
|
var currentSelectedEntityID = null;
|
||||||
|
var statusMonitor = null;
|
||||||
|
|
||||||
webView.setVisible(visible);
|
webView.setVisible(visible);
|
||||||
|
|
||||||
that.setVisible = function (newVisible) {
|
that.setVisible = function (newVisible) {
|
||||||
|
@ -1406,10 +1442,43 @@ var PropertiesTool = function (opts) {
|
||||||
webView.setVisible(visible);
|
webView.setVisible(visible);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function updateScriptStatus(info) {
|
||||||
|
print("Got status: ", info);
|
||||||
|
info.type = "server_script_status";
|
||||||
|
webView.emitScriptEvent(JSON.stringify(info));
|
||||||
|
};
|
||||||
|
|
||||||
|
function resetScriptStatus() {
|
||||||
|
updateScriptStatus({
|
||||||
|
statusRetrieved: false,
|
||||||
|
isRunning: false,
|
||||||
|
status: "",
|
||||||
|
errorInfo: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
selectionManager.addEventListener(function () {
|
selectionManager.addEventListener(function () {
|
||||||
var data = {
|
var data = {
|
||||||
type: 'update'
|
type: 'update'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resetScriptStatus();
|
||||||
|
|
||||||
|
if (selectionManager.selections.length !== 1) {
|
||||||
|
if (statusMonitor !== null) {
|
||||||
|
statusMonitor.stop();
|
||||||
|
statusMonitor = null;
|
||||||
|
}
|
||||||
|
currentSelectedEntityID = null;
|
||||||
|
} else if (currentSelectedEntityID != selectionManager.selections[0]) {
|
||||||
|
if (statusMonitor !== null) {
|
||||||
|
statusMonitor.stop();
|
||||||
|
}
|
||||||
|
var entityID = selectionManager.selections[0];
|
||||||
|
currentSelectedEntityID = entityID;
|
||||||
|
statusMonitor = new ServerScriptStatusMonitor(entityID, updateScriptStatus);
|
||||||
|
}
|
||||||
|
|
||||||
var selections = [];
|
var selections = [];
|
||||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
var entity = {};
|
var entity = {};
|
||||||
|
|
|
@ -319,10 +319,17 @@
|
||||||
<input type="button" id="reload-script-button" class="glyph" value="F">
|
<input type="button" id="reload-script-button" class="glyph" value="F">
|
||||||
</div>
|
</div>
|
||||||
<div class="behavior-group property url refresh">
|
<div class="behavior-group property url refresh">
|
||||||
<label for="property-server-scripts">Server Script URLs</label>
|
<label for="property-server-scripts">Server Script URL</label>
|
||||||
<input type="text" id="property-server-scripts">
|
<input type="text" id="property-server-scripts">
|
||||||
<input type="button" id="reload-server-scripts-button" class="glyph" value="F">
|
<input type="button" id="reload-server-scripts-button" class="glyph" value="F">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="behavior-group property">
|
||||||
|
<label for="server-script-status">Server Script Status</label>
|
||||||
|
<span id="server-script-status"></span>
|
||||||
|
</div>
|
||||||
|
<div class="behavior-group property">
|
||||||
|
<textarea id="server-script-error"></textarea>
|
||||||
|
</div>
|
||||||
<div class="section-header model-group model-section zone-section">
|
<div class="section-header model-group model-section zone-section">
|
||||||
<label>Model</label><span>M</span>
|
<label>Model</label><span>M</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -593,6 +593,8 @@ function loaded() {
|
||||||
var elReloadScriptsButton = document.getElementById("reload-script-button");
|
var elReloadScriptsButton = document.getElementById("reload-script-button");
|
||||||
var elServerScripts = document.getElementById("property-server-scripts");
|
var elServerScripts = document.getElementById("property-server-scripts");
|
||||||
var elReloadServerScriptsButton = document.getElementById("reload-server-scripts-button");
|
var elReloadServerScriptsButton = document.getElementById("reload-server-scripts-button");
|
||||||
|
var elServerScriptStatus = document.getElementById("server-script-status");
|
||||||
|
var elServerScriptError = document.getElementById("server-script-error");
|
||||||
var elUserData = document.getElementById("property-user-data");
|
var elUserData = document.getElementById("property-user-data");
|
||||||
var elClearUserData = document.getElementById("userdata-clear");
|
var elClearUserData = document.getElementById("userdata-clear");
|
||||||
var elSaveUserData = document.getElementById("userdata-save");
|
var elSaveUserData = document.getElementById("userdata-save");
|
||||||
|
@ -710,7 +712,28 @@ function loaded() {
|
||||||
var properties;
|
var properties;
|
||||||
EventBridge.scriptEventReceived.connect(function(data) {
|
EventBridge.scriptEventReceived.connect(function(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (data.type == "update") {
|
if (data.type == "server_script_status") {
|
||||||
|
if (!data.statusRetrieved) {
|
||||||
|
elServerScriptStatus.innerHTML = "Failed to retrieve status";
|
||||||
|
elServerScriptError.style.display = "none";
|
||||||
|
} else if (data.isRunning) {
|
||||||
|
if (data.status == "running") {
|
||||||
|
elServerScriptStatus.innerHTML = "Running";
|
||||||
|
elServerScriptError.style.display = "none";
|
||||||
|
} else if (data.status == "error_loading_script") {
|
||||||
|
elServerScriptStatus.innerHTML = "Error loading script";
|
||||||
|
elServerScriptError.style.display = "block";
|
||||||
|
} else if (data.status == "error_running_script") {
|
||||||
|
elServerScriptStatus.innerHTML = "Error running script";
|
||||||
|
elServerScriptError.style.display = "block";
|
||||||
|
}
|
||||||
|
//elServerScriptError.innerHTML = JSON.stringify(data) + "\n" + data.errorInfo;;
|
||||||
|
elServerScriptError.innerHTML = data.errorInfo;;
|
||||||
|
} else {
|
||||||
|
elServerScriptStatus.innerHTML = "Not running";
|
||||||
|
elServerScriptError.style.display = "none";
|
||||||
|
}
|
||||||
|
} else if (data.type == "update") {
|
||||||
|
|
||||||
if (data.selections.length == 0) {
|
if (data.selections.length == 0) {
|
||||||
if (editor !== null && lastEntityID !== null) {
|
if (editor !== null && lastEntityID !== null) {
|
||||||
|
|
Loading…
Reference in a new issue