mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
checkpoint
This commit is contained in:
parent
6fc27ac8d6
commit
86010af828
2 changed files with 59 additions and 29 deletions
|
@ -40,7 +40,7 @@ Rectangle {
|
||||||
property int actionWidth: nameWidth / (table.columnCount - 1);
|
property int actionWidth: nameWidth / (table.columnCount - 1);
|
||||||
property int rowHeight: 50;
|
property int rowHeight: 50;
|
||||||
property var userData: [];
|
property var userData: [];
|
||||||
property var myData: null;
|
property var myData: ({displayName: "", userName: ""}); // valid dummy until set
|
||||||
function fromScript(data) {
|
function fromScript(data) {
|
||||||
var myIndex = 0;
|
var myIndex = 0;
|
||||||
while ((myIndex < data.length) && data[myIndex].sessionId) myIndex++; // no findIndex in .qml
|
while ((myIndex < data.length) && data[myIndex].sessionId) myIndex++; // no findIndex in .qml
|
||||||
|
@ -61,8 +61,8 @@ Rectangle {
|
||||||
userData.sort(function (a, b) {
|
userData.sort(function (a, b) {
|
||||||
var aValue = a[sortProperty].toString().toLowerCase(), bValue = b[sortProperty].toString().toLowerCase();
|
var aValue = a[sortProperty].toString().toLowerCase(), bValue = b[sortProperty].toString().toLowerCase();
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case (aValue < bValue): console.log(aValue, bValue, before); return before;
|
case (aValue < bValue): console.log('fixme', aValue, bValue, before); return before;
|
||||||
case (aValue > bValue): console.log(aValue, bValue, after); return after;
|
case (aValue > bValue): console.log('fixme', aValue, bValue, after); return after;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,6 +79,22 @@ Rectangle {
|
||||||
userModel.append(datum);
|
userModel.append(datum);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
signal sendToScript(var message);
|
||||||
|
function noticeSelection() {
|
||||||
|
console.log('selection changed');
|
||||||
|
var userIds = [];
|
||||||
|
table.selection.forEach(function (userIndex) {
|
||||||
|
userIds.push(userData[userIndex].sessionId);
|
||||||
|
});
|
||||||
|
console.log('fixme selected ' + JSON.stringify(userIds));
|
||||||
|
pal.sendToScript(userIds);
|
||||||
|
//pal.parent.sendToScript(userIds);
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: table.selection
|
||||||
|
onSelectionChanged: pal.noticeSelection()
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
NameCard {
|
NameCard {
|
||||||
id: myCard;
|
id: myCard;
|
||||||
|
|
|
@ -11,33 +11,33 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
// FIXME: (function() { // BEGIN LOCAL_SCOPE
|
// FIXME when we make this a defaultScript: (function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
var overlays = {}; // Keeps track of all our extended overlay data objects, keyed by target identifier.
|
var overlays = {}; // Keeps track of all our extended overlay data objects, keyed by target identifier.
|
||||||
function ExtendedOverlay(key, type, properties) { // A wrapper around overlays to store the key it is associated with.
|
function ExtendedOverlay(key, type, properties) { // A wrapper around overlays to store the key it is associated with.
|
||||||
overlays[key] = this;
|
overlays[key] = this;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.unselectedOverlay = Overlays.addOverlay(type, properties);
|
this.selected = false; // not undefined
|
||||||
|
this.activeOverlay = Overlays.addOverlay(type, properties); // We could use different overlays for (un)selected...
|
||||||
}
|
}
|
||||||
// Instance methods:
|
// Instance methods:
|
||||||
ExtendedOverlay.prototype.deleteOverlay = function () { // remove display and data of this overlay
|
ExtendedOverlay.prototype.deleteOverlay = function () { // remove display and data of this overlay
|
||||||
Overlays.deleteOverlay(this.unselectedOverlay);
|
Overlays.deleteOverlay(this.activeOverlay);
|
||||||
if (this.selected) {
|
|
||||||
Overlays.deleteOverlay(this.selectedOverlay);
|
|
||||||
}
|
|
||||||
delete overlays[this.key];
|
delete overlays[this.key];
|
||||||
};
|
};
|
||||||
|
|
||||||
ExtendedOverlay.prototype.editOverlay = function (properties) { // change display of this overlay
|
ExtendedOverlay.prototype.editOverlay = function (properties) { // change display of this overlay
|
||||||
Overlays.editOverlay(this.selected ? this.selectedOverlay : this.unselectedOverlay, properties);
|
Overlays.editOverlay(this.activeOverlay, properties);
|
||||||
};
|
};
|
||||||
ExtendedOverlay.prototype.select = function (selected, type, initialProperties) {
|
var UNSELECTED_COLOR = {red: 20, green: 250, blue: 20};
|
||||||
if (selected && !this.selectedOverlay) {
|
var SELECTED_COLOR = {red: 250, green: 20, blue: 20};
|
||||||
this.selectedOverlay = Overlays.addOverlay(type, initialProperties);
|
ExtendedOverlay.prototype.select = function (selected) {
|
||||||
|
if (this.selected === selected) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.editOverlay({color: selected ? SELECTED_COLOR : UNSELECTED_COLOR});
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
Overlays.editOverlay(this.unselectedOverlay, {visible: !selected});
|
|
||||||
Overlays.editOverlay(this.selectedOverlay, {visible: selected});
|
|
||||||
};
|
};
|
||||||
// Class methods:
|
// Class methods:
|
||||||
ExtendedOverlay.get = function (key) { // answer the extended overlay data object associated with the given avatar identifier
|
ExtendedOverlay.get = function (key) { // answer the extended overlay data object associated with the given avatar identifier
|
||||||
|
@ -57,7 +57,7 @@ ExtendedOverlay.applyPickRay = function (pickRay, cb) { // cb(overlay) on the on
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ExtendedOverlay.some(function (overlay) { // See if pickedOverlay is one of ours.
|
ExtendedOverlay.some(function (overlay) { // See if pickedOverlay is one of ours.
|
||||||
if ((overlay.selected ? overlay.selectedOverlay : overlay.unselectedOverlay) === pickedOverlay.overlayID) {
|
if ((overlay.activeOverlay) === pickedOverlay.overlayID) {
|
||||||
cb(overlay);
|
cb(overlay);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -67,20 +67,20 @@ ExtendedOverlay.applyPickRay = function (pickRay, cb) { // cb(overlay) on the on
|
||||||
|
|
||||||
var pal = new OverlayWindow({
|
var pal = new OverlayWindow({
|
||||||
title: 'People Action List',
|
title: 'People Action List',
|
||||||
source: Script.resolvePath('../../qml/hifi/Pal.qml'),
|
source: 'hifi/Pal.qml',
|
||||||
width: 480,
|
width: 480,
|
||||||
height: 640,
|
height: 640,
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
pal.fromQml.connect(function (message) {
|
||||||
|
ExtendedOverlay.some(function (overlay) {
|
||||||
|
overlay.select(-1 !== message.indexOf(overlay.key));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var AVATAR_OVERLAY = Script.resolvePath("assets/images/grabsprite-3.png");
|
var AVATAR_OVERLAY = Script.resolvePath("assets/images/grabsprite-3.png");
|
||||||
function populateUserList() {
|
function populateUserList() {
|
||||||
var data = [];
|
var data = [];
|
||||||
/*data.push({ // Create an extra user for debugging.
|
|
||||||
displayName: "Dummy Debugging User",
|
|
||||||
userName: "foo.bar",
|
|
||||||
sessionId: 'XXX'
|
|
||||||
})*/
|
|
||||||
var counter = 1;
|
var counter = 1;
|
||||||
AvatarList.getAvatarIdentifiers().forEach(function (id) {
|
AvatarList.getAvatarIdentifiers().forEach(function (id) {
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatar(id);
|
||||||
|
@ -90,27 +90,40 @@ function populateUserList() {
|
||||||
sessionId: id
|
sessionId: id
|
||||||
});
|
});
|
||||||
if (id) { // No overlay for us
|
if (id) { // No overlay for us
|
||||||
new ExtendedOverlay(id, "image3d", { // 3d so we don't go cross-eyed looking at it, but on top of everything
|
new ExtendedOverlay(id, "sphere", { // 3d so we don't go cross-eyed looking at it, but on top of everything
|
||||||
imageURL: AVATAR_OVERLAY,
|
solid: true,
|
||||||
|
alpha: 0.8,
|
||||||
|
color: UNSELECTED_COLOR,
|
||||||
|
dimensions: 0.4,
|
||||||
drawInFront: true
|
drawInFront: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
pal.sendToQml(data);
|
pal.sendToQml(data);
|
||||||
}
|
}
|
||||||
|
var pingPong = true;
|
||||||
function updateOverlays() {
|
function updateOverlays() {
|
||||||
//var eye = Camera.position;
|
var eye = Camera.position;
|
||||||
AvatarList.getAvatarIdentifiers().forEach(function (id) {
|
AvatarList.getAvatarIdentifiers().forEach(function (id) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return; // don't update ourself
|
return; // don't update ourself
|
||||||
}
|
}
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatar(id);
|
||||||
var target = avatar.position;
|
var target = avatar.position;
|
||||||
//var distance = Vec3.distance(target, eye);
|
var distance = Vec3.distance(target, eye);
|
||||||
ExtendedOverlay.get(id).editOverlay({
|
var overlay = ExtendedOverlay.get(id);
|
||||||
position: target
|
overlay.ping = pingPong;
|
||||||
|
overlay.editOverlay({
|
||||||
|
position: target,
|
||||||
|
dimensions: 0.05 * distance // constant apparent size
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
pingPong = !pingPong;
|
||||||
|
ExtendedOverlay.some(function (overlay) { // Remove any that weren't updated. (User is gone.)
|
||||||
|
if (overlay.ping === pingPong) {
|
||||||
|
overlay.deleteOverlay();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function removeOverlays() {
|
function removeOverlays() {
|
||||||
ExtendedOverlay.some(function (overlay) { overlay.deleteOverlay(); });
|
ExtendedOverlay.some(function (overlay) { overlay.deleteOverlay(); });
|
||||||
|
@ -121,7 +134,7 @@ var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
|
||||||
var buttonName = "pal";
|
var buttonName = "pal";
|
||||||
var button = toolBar.addButton({
|
var button = toolBar.addButton({
|
||||||
objectName: buttonName,
|
objectName: buttonName,
|
||||||
imageURL: Script.resolvePath("assets/images/tools/ignore.svg"),
|
imageURL: Script.resolvePath("assets/images/tools/people.svg"),
|
||||||
visible: true,
|
visible: true,
|
||||||
hoverState: 2,
|
hoverState: 2,
|
||||||
defaultState: 1,
|
defaultState: 1,
|
||||||
|
@ -151,6 +164,7 @@ Script.scriptEnding.connect(function () {
|
||||||
toolBar.removeButton(buttonName);
|
toolBar.removeButton(buttonName);
|
||||||
pal.visibleChanged.disconnect(onVisibileChanged);
|
pal.visibleChanged.disconnect(onVisibileChanged);
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
|
removeOverlays();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue