mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 01:50:12 +02:00
handle removal of an overlay for an avatar that is removed
This commit is contained in:
parent
7bd8c45098
commit
aeabae4faf
1 changed files with 26 additions and 17 deletions
|
@ -36,6 +36,20 @@ function removeOverlays() {
|
||||||
ignoreOverlays = {};
|
ignoreOverlays = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle clicks on the toolbar button
|
||||||
|
function buttonClicked(){
|
||||||
|
if (isShowingOverlays) {
|
||||||
|
removeOverlays();
|
||||||
|
isShowingOverlays = false;
|
||||||
|
} else {
|
||||||
|
isShowingOverlays = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.writeProperty('buttonState', isShowingOverlays ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.clicked.connect(buttonClicked);
|
||||||
|
|
||||||
var OVERLAY_SIZE = 0.25;
|
var OVERLAY_SIZE = 0.25;
|
||||||
|
|
||||||
function updateOverlays() {
|
function updateOverlays() {
|
||||||
|
@ -80,19 +94,19 @@ function updateOverlays() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle clicks on the toolbar button
|
Script.update.connect(updateOverlays);
|
||||||
function buttonClicked(){
|
|
||||||
|
AvatarList.avatarRemovedEvent.connect(function(avatarID){
|
||||||
if (isShowingOverlays) {
|
if (isShowingOverlays) {
|
||||||
removeOverlays();
|
// we are currently showing overlays and an avatar just went away
|
||||||
isShowingOverlays = false;
|
|
||||||
} else {
|
// first remove the rendered overlay
|
||||||
isShowingOverlays = true;
|
Overlays.deleteOverlay(ignoreOverlays[avatarID]);
|
||||||
|
|
||||||
|
// delete the saved ID of the overlay from our ignored overlays object
|
||||||
|
delete ignoreOverlays[avatarID];
|
||||||
}
|
}
|
||||||
|
})
|
||||||
button.writeProperty('buttonState', isShowingOverlays ? 0 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
button.clicked.connect(buttonClicked);
|
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(function(event){
|
Controller.mousePressEvent.connect(function(event){
|
||||||
// handle click events so we can detect when our overlays are clicked
|
// handle click events so we can detect when our overlays are clicked
|
||||||
|
@ -118,16 +132,11 @@ Controller.mousePressEvent.connect(function(event){
|
||||||
// matched to an overlay, ask for the matching avatar to be ignored
|
// matched to an overlay, ask for the matching avatar to be ignored
|
||||||
Users.ignore(avatarID);
|
Users.ignore(avatarID);
|
||||||
|
|
||||||
// remove the actual overlay so it is no longer rendered
|
// cleanup of the overlay is handled by the connection to avatarRemovedEvent
|
||||||
Overlays.deleteOverlay(ignoreOverlay);
|
|
||||||
|
|
||||||
// remove the overlay ID and avatar ID from our internal array
|
|
||||||
delete ignoreOverlays[avatarID];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Script.update.connect(updateOverlays);
|
|
||||||
|
|
||||||
// cleanup the toolbar button and overlays when script is stopped
|
// cleanup the toolbar button and overlays when script is stopped
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function() {
|
||||||
|
|
Loading…
Reference in a new issue