mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 15:59:49 +02:00
Merge pull request #8142 from ZappoMan/usersJSPatchToRC14
Users js patch to rc14
This commit is contained in:
commit
1bde849ed6
1 changed files with 124 additions and 119 deletions
|
@ -9,7 +9,7 @@
|
||||||
// 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
|
||||||
//
|
//
|
||||||
|
|
||||||
var PopUpMenu = function(properties) {
|
var PopUpMenu = function (properties) {
|
||||||
var value = properties.value,
|
var value = properties.value,
|
||||||
promptOverlay,
|
promptOverlay,
|
||||||
valueOverlay,
|
valueOverlay,
|
||||||
|
@ -217,7 +217,7 @@ var PopUpMenu = function(properties) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var usersWindow = (function() {
|
var usersWindow = (function () {
|
||||||
|
|
||||||
var baseURL = Script.resolvePath("assets/images/tools/"),
|
var baseURL = Script.resolvePath("assets/images/tools/"),
|
||||||
WINDOW_WIDTH = 260,
|
WINDOW_WIDTH = 260,
|
||||||
|
@ -253,11 +253,7 @@ var usersWindow = (function() {
|
||||||
WINDOW_BORDER_BOTTOM_MARGIN = WINDOW_BASE_MARGIN,
|
WINDOW_BORDER_BOTTOM_MARGIN = WINDOW_BASE_MARGIN,
|
||||||
WINDOW_BORDER_LEFT_MARGIN = WINDOW_BASE_MARGIN,
|
WINDOW_BORDER_LEFT_MARGIN = WINDOW_BASE_MARGIN,
|
||||||
WINDOW_BORDER_RADIUS = 4,
|
WINDOW_BORDER_RADIUS = 4,
|
||||||
WINDOW_BORDER_COLOR = {
|
WINDOW_BORDER_COLOR = { red: 255, green: 255, blue: 255 },
|
||||||
red: 255,
|
|
||||||
green: 255,
|
|
||||||
blue: 255
|
|
||||||
},
|
|
||||||
WINDOW_BORDER_ALPHA = 0.5,
|
WINDOW_BORDER_ALPHA = 0.5,
|
||||||
windowBorder,
|
windowBorder,
|
||||||
|
|
||||||
|
@ -363,30 +359,31 @@ var usersWindow = (function() {
|
||||||
usersTimer = null,
|
usersTimer = null,
|
||||||
USERS_UPDATE_TIMEOUT = 5000, // ms = 5s
|
USERS_UPDATE_TIMEOUT = 5000, // ms = 5s
|
||||||
|
|
||||||
|
showMe,
|
||||||
myVisibility,
|
myVisibility,
|
||||||
|
|
||||||
MENU_NAME = "Tools",
|
MENU_NAME = "View",
|
||||||
MENU_ITEM = "Users Online",
|
MENU_ITEM = "Users Online",
|
||||||
MENU_ITEM_AFTER = "Chat...",
|
MENU_ITEM_AFTER = "Overlays",
|
||||||
|
|
||||||
|
SETTING_USERS_SHOW_ME = "UsersWindow.ShowMe",
|
||||||
|
SETTING_USERS_VISIBLE_TO = "UsersWindow.VisibleTo",
|
||||||
SETTING_USERS_WINDOW_MINIMIZED = "UsersWindow.Minimized",
|
SETTING_USERS_WINDOW_MINIMIZED = "UsersWindow.Minimized",
|
||||||
SETINGS_USERS_WINDOW_OFFSET = "UsersWindow.Offset",
|
SETTING_USERS_WINDOW_OFFSET = "UsersWindow.Offset",
|
||||||
// +ve x, y values are offset from left, top of screen; -ve from right, bottom.
|
// +ve x, y values are offset from left, top of screen; -ve from right, bottom.
|
||||||
|
|
||||||
|
isLoggedIn = false,
|
||||||
isVisible = true,
|
isVisible = true,
|
||||||
isMinimized = false,
|
isMinimized = true,
|
||||||
isBorderVisible = false,
|
isBorderVisible = false,
|
||||||
|
|
||||||
viewport,
|
viewport,
|
||||||
isMirrorDisplay = false,
|
isMirrorDisplay = false,
|
||||||
isFullscreenMirror = false,
|
isFullscreenMirror = false,
|
||||||
|
|
||||||
windowPosition = {}, // Bottom left corner of window pane.
|
windowPosition = {}, // Bottom left corner of window pane.
|
||||||
isMovingWindow = false,
|
isMovingWindow = false,
|
||||||
movingClickOffset = {
|
movingClickOffset = { x: 0, y: 0 },
|
||||||
x: 0,
|
|
||||||
y: 0
|
|
||||||
},
|
|
||||||
|
|
||||||
isUsingScrollbars = false,
|
isUsingScrollbars = false,
|
||||||
isMovingScrollbar = false,
|
isMovingScrollbar = false,
|
||||||
|
@ -395,6 +392,12 @@ var usersWindow = (function() {
|
||||||
scrollbarBarClickedAt, // 0.0 .. 1.0
|
scrollbarBarClickedAt, // 0.0 .. 1.0
|
||||||
scrollbarValue = 0.0; // 0.0 .. 1.0
|
scrollbarValue = 0.0; // 0.0 .. 1.0
|
||||||
|
|
||||||
|
function isValueTrue(value) {
|
||||||
|
// Work around Boolean Settings values being read as string when Interface starts up but as Booleans when re-read after
|
||||||
|
// Being written if refresh script.
|
||||||
|
return value === true || value === "true";
|
||||||
|
}
|
||||||
|
|
||||||
function calculateWindowHeight() {
|
function calculateWindowHeight() {
|
||||||
var AUDIO_METER_HEIGHT = 52,
|
var AUDIO_METER_HEIGHT = 52,
|
||||||
MIRROR_HEIGHT = 220,
|
MIRROR_HEIGHT = 220,
|
||||||
|
@ -408,7 +411,9 @@ var usersWindow = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reserve space for title, friends button, and option controls
|
// Reserve space for title, friends button, and option controls
|
||||||
nonUsersHeight = WINDOW_MARGIN + windowLineHeight + FRIENDS_BUTTON_SPACER + FRIENDS_BUTTON_HEIGHT + DISPLAY_SPACER + windowLineHeight + VISIBILITY_SPACER + windowLineHeight + WINDOW_BASE_MARGIN;
|
nonUsersHeight = WINDOW_MARGIN + windowLineHeight + FRIENDS_BUTTON_SPACER + FRIENDS_BUTTON_HEIGHT + DISPLAY_SPACER
|
||||||
|
+ windowLineHeight + VISIBILITY_SPACER
|
||||||
|
+ windowLineHeight + WINDOW_BASE_MARGIN;
|
||||||
|
|
||||||
// Limit window to height of viewport above window position minus VU meter and mirror if displayed
|
// Limit window to height of viewport above window position minus VU meter and mirror if displayed
|
||||||
windowHeight = linesOfUsers.length * windowLineHeight - windowLineSpacing + nonUsersHeight;
|
windowHeight = linesOfUsers.length * windowLineHeight - windowLineSpacing + nonUsersHeight;
|
||||||
|
@ -461,14 +466,17 @@ var usersWindow = (function() {
|
||||||
x: scrollbarBackgroundPosition.x,
|
x: scrollbarBackgroundPosition.x,
|
||||||
y: scrollbarBackgroundPosition.y
|
y: scrollbarBackgroundPosition.y
|
||||||
});
|
});
|
||||||
scrollbarBarPosition.y = scrollbarBackgroundPosition.y + 1 + scrollbarValue * (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
|
scrollbarBarPosition.y = scrollbarBackgroundPosition.y + 1
|
||||||
|
+ scrollbarValue * (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
|
||||||
Overlays.editOverlay(scrollbarBar, {
|
Overlays.editOverlay(scrollbarBar, {
|
||||||
x: scrollbarBackgroundPosition.x + 1,
|
x: scrollbarBackgroundPosition.x + 1,
|
||||||
y: scrollbarBarPosition.y
|
y: scrollbarBarPosition.y
|
||||||
});
|
});
|
||||||
|
|
||||||
x = windowLeft + WINDOW_MARGIN;
|
x = windowLeft + WINDOW_MARGIN;
|
||||||
y = windowPosition.y - FRIENDS_BUTTON_HEIGHT - DISPLAY_SPACER - windowLineHeight - VISIBILITY_SPACER - windowLineHeight - WINDOW_BASE_MARGIN;
|
y = windowPosition.y - FRIENDS_BUTTON_HEIGHT - DISPLAY_SPACER
|
||||||
|
- windowLineHeight - VISIBILITY_SPACER
|
||||||
|
- windowLineHeight - WINDOW_BASE_MARGIN;
|
||||||
Overlays.editOverlay(friendsButton, {
|
Overlays.editOverlay(friendsButton, {
|
||||||
x: x,
|
x: x,
|
||||||
y: y
|
y: y
|
||||||
|
@ -519,13 +527,13 @@ var usersWindow = (function() {
|
||||||
scrollbarBackgroundHeight = numUsersToDisplay * windowLineHeight - windowLineSpacing / 2;
|
scrollbarBackgroundHeight = numUsersToDisplay * windowLineHeight - windowLineSpacing / 2;
|
||||||
Overlays.editOverlay(scrollbarBackground, {
|
Overlays.editOverlay(scrollbarBackground, {
|
||||||
height: scrollbarBackgroundHeight,
|
height: scrollbarBackgroundHeight,
|
||||||
visible: isUsingScrollbars
|
visible: isLoggedIn && isUsingScrollbars
|
||||||
});
|
});
|
||||||
scrollbarBarHeight = Math.max(numUsersToDisplay / linesOfUsers.length * scrollbarBackgroundHeight,
|
scrollbarBarHeight = Math.max(numUsersToDisplay / linesOfUsers.length * scrollbarBackgroundHeight,
|
||||||
SCROLLBAR_BAR_MIN_HEIGHT);
|
SCROLLBAR_BAR_MIN_HEIGHT);
|
||||||
Overlays.editOverlay(scrollbarBar, {
|
Overlays.editOverlay(scrollbarBar, {
|
||||||
height: scrollbarBarHeight,
|
height: scrollbarBarHeight,
|
||||||
visible: isUsingScrollbars
|
visible: isLoggedIn && isUsingScrollbars
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,10 +551,45 @@ var usersWindow = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateOverlayVisibility() {
|
||||||
|
Overlays.editOverlay(windowBorder, {
|
||||||
|
visible: isLoggedIn && isVisible && isBorderVisible
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(windowPane, {
|
||||||
|
visible: isLoggedIn && isVisible
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(windowHeading, {
|
||||||
|
visible: isLoggedIn && isVisible
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(minimizeButton, {
|
||||||
|
visible: isLoggedIn && isVisible
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(scrollbarBackground, {
|
||||||
|
visible: isLoggedIn && isVisible && isUsingScrollbars && !isMinimized
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(scrollbarBar, {
|
||||||
|
visible: isLoggedIn && isVisible && isUsingScrollbars && !isMinimized
|
||||||
|
});
|
||||||
|
Overlays.editOverlay(friendsButton, {
|
||||||
|
visible: isLoggedIn && isVisible && !isMinimized
|
||||||
|
});
|
||||||
|
displayControl.setVisible(isLoggedIn && isVisible && !isMinimized);
|
||||||
|
visibilityControl.setVisible(isLoggedIn && isVisible && !isMinimized);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkLoggedIn() {
|
||||||
|
var wasLoggedIn = isLoggedIn;
|
||||||
|
|
||||||
|
isLoggedIn = Account.isLoggedIn();
|
||||||
|
if (isLoggedIn !== wasLoggedIn) {
|
||||||
|
updateOverlayVisibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function pollUsers() {
|
function pollUsers() {
|
||||||
var url = API_URL;
|
var url = API_URL;
|
||||||
|
|
||||||
if (displayControl.getValue() === DISPLAY_FRIENDS) {
|
if (showMe === DISPLAY_FRIENDS) {
|
||||||
url += API_FRIENDS_FILTER;
|
url += API_FRIENDS_FILTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,36 +599,11 @@ var usersWindow = (function() {
|
||||||
usersRequest.ontimeout = pollUsersTimedOut;
|
usersRequest.ontimeout = pollUsersTimedOut;
|
||||||
usersRequest.onreadystatechange = processUsers;
|
usersRequest.onreadystatechange = processUsers;
|
||||||
usersRequest.send();
|
usersRequest.send();
|
||||||
|
|
||||||
checkLoggedIn();
|
checkLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
var loggedIn = false;
|
processUsers = function () {
|
||||||
|
|
||||||
function checkLoggedIn() {
|
|
||||||
loggedIn = Account.isLoggedIn();
|
|
||||||
if (loggedIn === false) {
|
|
||||||
Overlays.editOverlay(friendsButton, {
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
visibilityControl.setVisible(false);
|
|
||||||
displayControl.setVisible(false);
|
|
||||||
} else {
|
|
||||||
if (isMinimized === true) {
|
|
||||||
loggedIn = true;
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Overlays.editOverlay(friendsButton, {
|
|
||||||
visible: true
|
|
||||||
});
|
|
||||||
visibilityControl.setVisible(true);
|
|
||||||
displayControl.setVisible(true);
|
|
||||||
loggedIn = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
processUsers = function() {
|
|
||||||
var response,
|
var response,
|
||||||
myUsername,
|
myUsername,
|
||||||
user,
|
user,
|
||||||
|
@ -638,41 +656,11 @@ var usersWindow = (function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pollUsersTimedOut = function() {
|
pollUsersTimedOut = function () {
|
||||||
print("Error: Request for users status timed out");
|
print("Error: Request for users status timed out");
|
||||||
usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
|
usersTimer = Script.setTimeout(pollUsers, HTTP_GET_TIMEOUT); // Try again after a longer delay.
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateOverlayVisibility() {
|
|
||||||
Overlays.editOverlay(windowBorder, {
|
|
||||||
visible: isVisible && isBorderVisible
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(windowPane, {
|
|
||||||
visible: isVisible
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(windowHeading, {
|
|
||||||
visible: isVisible
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(minimizeButton, {
|
|
||||||
visible: isVisible
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(scrollbarBackground, {
|
|
||||||
visible: isVisible && isUsingScrollbars && !isMinimized
|
|
||||||
});
|
|
||||||
Overlays.editOverlay(scrollbarBar, {
|
|
||||||
visible: isVisible && isUsingScrollbars && !isMinimized
|
|
||||||
});
|
|
||||||
|
|
||||||
if (loggedIn === true) {
|
|
||||||
Overlays.editOverlay(friendsButton, {
|
|
||||||
visible: isVisible && !isMinimized
|
|
||||||
});
|
|
||||||
displayControl.setVisible(isVisible && !isMinimized);
|
|
||||||
visibilityControl.setVisible(isVisible && !isMinimized);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function setVisible(visible) {
|
function setVisible(visible) {
|
||||||
isVisible = visible;
|
isVisible = visible;
|
||||||
|
|
||||||
|
@ -686,7 +674,6 @@ var usersWindow = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOverlayVisibility();
|
updateOverlayVisibility();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMinimized(minimized) {
|
function setMinimized(minimized) {
|
||||||
|
@ -697,6 +684,7 @@ var usersWindow = (function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateOverlayVisibility();
|
updateOverlayVisibility();
|
||||||
|
Settings.setValue(SETTING_USERS_WINDOW_MINIMIZED, isMinimized);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMenuItemEvent(event) {
|
function onMenuItemEvent(event) {
|
||||||
|
@ -707,9 +695,11 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
function onFindableByChanged(event) {
|
function onFindableByChanged(event) {
|
||||||
if (VISIBILITY_VALUES.indexOf(event) !== -1) {
|
if (VISIBILITY_VALUES.indexOf(event) !== -1) {
|
||||||
|
myVisibility = event;
|
||||||
visibilityControl.setValue(event);
|
visibilityControl.setValue(event);
|
||||||
|
Settings.setValue(SETTING_USERS_VISIBLE_TO, myVisibility);
|
||||||
} else {
|
} else {
|
||||||
print("Error: Unrecognized onFindableByChanged value: " + myVisibility);
|
print("Error: Unrecognized onFindableByChanged value: " + event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,11 +729,15 @@ var usersWindow = (function() {
|
||||||
usersTimer = null;
|
usersTimer = null;
|
||||||
}
|
}
|
||||||
pollUsers();
|
pollUsers();
|
||||||
|
showMe = displayControl.getValue();
|
||||||
|
Settings.setValue(SETTING_USERS_SHOW_ME, showMe);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visibilityControl.handleClick(clickedOverlay)) {
|
if (visibilityControl.handleClick(clickedOverlay)) {
|
||||||
GlobalServices.findableBy = visibilityControl.getValue();
|
myVisibility = visibilityControl.getValue();
|
||||||
|
GlobalServices.findableBy = myVisibility;
|
||||||
|
Settings.setValue(SETTING_USERS_VISIBLE_TO, myVisibility);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,7 +757,9 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
userClicked = firstUserToDisplay + lineClicked;
|
userClicked = firstUserToDisplay + lineClicked;
|
||||||
|
|
||||||
if (0 <= userClicked && userClicked < linesOfUsers.length && 0 <= overlayX && overlayX <= usersOnline[linesOfUsers[userClicked]].textWidth) {
|
if (0 <= userClicked && userClicked < linesOfUsers.length && 0 <= overlayX
|
||||||
|
&& overlayX <= usersOnline[linesOfUsers[userClicked]].textWidth) {
|
||||||
|
//print("Go to " + usersOnline[linesOfUsers[userClicked]].username);
|
||||||
location.goToUser(usersOnline[linesOfUsers[userClicked]].username);
|
location.goToUser(usersOnline[linesOfUsers[userClicked]].username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,8 +827,12 @@ var usersWindow = (function() {
|
||||||
var isVisible;
|
var isVisible;
|
||||||
|
|
||||||
if (isMovingScrollbar) {
|
if (isMovingScrollbar) {
|
||||||
if (scrollbarBackgroundPosition.x - WINDOW_MARGIN <= event.x && event.x <= scrollbarBackgroundPosition.x + SCROLLBAR_BACKGROUND_WIDTH + WINDOW_MARGIN && scrollbarBackgroundPosition.y - WINDOW_MARGIN <= event.y && event.y <= scrollbarBackgroundPosition.y + scrollbarBackgroundHeight + WINDOW_MARGIN) {
|
if (scrollbarBackgroundPosition.x - WINDOW_MARGIN <= event.x
|
||||||
scrollbarValue = (event.y - scrollbarBarClickedAt * scrollbarBarHeight - scrollbarBackgroundPosition.y) / (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
|
&& event.x <= scrollbarBackgroundPosition.x + SCROLLBAR_BACKGROUND_WIDTH + WINDOW_MARGIN
|
||||||
|
&& scrollbarBackgroundPosition.y - WINDOW_MARGIN <= event.y
|
||||||
|
&& event.y <= scrollbarBackgroundPosition.y + scrollbarBackgroundHeight + WINDOW_MARGIN) {
|
||||||
|
scrollbarValue = (event.y - scrollbarBarClickedAt * scrollbarBarHeight - scrollbarBackgroundPosition.y)
|
||||||
|
/ (scrollbarBackgroundHeight - scrollbarBarHeight - 2);
|
||||||
scrollbarValue = Math.min(Math.max(scrollbarValue, 0.0), 1.0);
|
scrollbarValue = Math.min(Math.max(scrollbarValue, 0.0), 1.0);
|
||||||
firstUserToDisplay = Math.floor(scrollbarValue * (linesOfUsers.length - numUsersToDisplay));
|
firstUserToDisplay = Math.floor(scrollbarValue * (linesOfUsers.length - numUsersToDisplay));
|
||||||
updateOverlayPositions();
|
updateOverlayPositions();
|
||||||
|
@ -858,9 +858,13 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
isVisible = isBorderVisible;
|
isVisible = isBorderVisible;
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
isVisible = windowPosition.x - WINDOW_BORDER_LEFT_MARGIN <= event.x && event.x <= windowPosition.x - WINDOW_BORDER_LEFT_MARGIN + WINDOW_BORDER_WIDTH && windowPosition.y - windowHeight - WINDOW_BORDER_TOP_MARGIN <= event.y && event.y <= windowPosition.y + WINDOW_BORDER_BOTTOM_MARGIN;
|
isVisible = windowPosition.x - WINDOW_BORDER_LEFT_MARGIN <= event.x
|
||||||
|
&& event.x <= windowPosition.x - WINDOW_BORDER_LEFT_MARGIN + WINDOW_BORDER_WIDTH
|
||||||
|
&& windowPosition.y - windowHeight - WINDOW_BORDER_TOP_MARGIN <= event.y
|
||||||
|
&& event.y <= windowPosition.y + WINDOW_BORDER_BOTTOM_MARGIN;
|
||||||
} else {
|
} else {
|
||||||
isVisible = windowPosition.x <= event.x && event.x <= windowPosition.x + WINDOW_WIDTH && windowPosition.y - windowHeight <= event.y && event.y <= windowPosition.y;
|
isVisible = windowPosition.x <= event.x && event.x <= windowPosition.x + WINDOW_WIDTH
|
||||||
|
&& windowPosition.y - windowHeight <= event.y && event.y <= windowPosition.y;
|
||||||
}
|
}
|
||||||
if (isVisible !== isBorderVisible) {
|
if (isVisible !== isBorderVisible) {
|
||||||
isBorderVisible = isVisible;
|
isBorderVisible = isVisible;
|
||||||
|
@ -883,9 +887,11 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
if (isMovingWindow) {
|
if (isMovingWindow) {
|
||||||
// Save offset of bottom of window to nearest edge of the window.
|
// Save offset of bottom of window to nearest edge of the window.
|
||||||
offset.x = (windowPosition.x + WINDOW_WIDTH / 2 < viewport.x / 2) ? windowPosition.x : windowPosition.x - viewport.x;
|
offset.x = (windowPosition.x + WINDOW_WIDTH / 2 < viewport.x / 2)
|
||||||
offset.y = (windowPosition.y < viewport.y / 2) ? windowPosition.y : windowPosition.y - viewport.y;
|
? windowPosition.x : windowPosition.x - viewport.x;
|
||||||
Settings.setValue(SETINGS_USERS_WINDOW_OFFSET, JSON.stringify(offset));
|
offset.y = (windowPosition.y < viewport.y / 2)
|
||||||
|
? windowPosition.y : windowPosition.y - viewport.y;
|
||||||
|
Settings.setValue(SETTING_USERS_WINDOW_OFFSET, JSON.stringify(offset));
|
||||||
isMovingWindow = false;
|
isMovingWindow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -901,7 +907,8 @@ var usersWindow = (function() {
|
||||||
isMirrorDisplay = Menu.isOptionChecked(MIRROR_MENU_ITEM);
|
isMirrorDisplay = Menu.isOptionChecked(MIRROR_MENU_ITEM);
|
||||||
isFullscreenMirror = Menu.isOptionChecked(FULLSCREEN_MIRROR_MENU_ITEM);
|
isFullscreenMirror = Menu.isOptionChecked(FULLSCREEN_MIRROR_MENU_ITEM);
|
||||||
|
|
||||||
if (viewport.y !== oldViewport.y || isMirrorDisplay !== oldIsMirrorDisplay || isFullscreenMirror !== oldIsFullscreenMirror) {
|
if (viewport.y !== oldViewport.y || isMirrorDisplay !== oldIsMirrorDisplay
|
||||||
|
|| isFullscreenMirror !== oldIsFullscreenMirror) {
|
||||||
calculateWindowHeight();
|
calculateWindowHeight();
|
||||||
updateUsersDisplay();
|
updateUsersDisplay();
|
||||||
}
|
}
|
||||||
|
@ -940,9 +947,9 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
viewport = Controller.getViewportDimensions();
|
viewport = Controller.getViewportDimensions();
|
||||||
|
|
||||||
offsetSetting = Settings.getValue(SETINGS_USERS_WINDOW_OFFSET);
|
offsetSetting = Settings.getValue(SETTING_USERS_WINDOW_OFFSET);
|
||||||
if (offsetSetting !== "") {
|
if (offsetSetting !== "") {
|
||||||
offset = JSON.parse(Settings.getValue(SETINGS_USERS_WINDOW_OFFSET));
|
offset = JSON.parse(Settings.getValue(SETTING_USERS_WINDOW_OFFSET));
|
||||||
}
|
}
|
||||||
if (offset.hasOwnProperty("x") && offset.hasOwnProperty("y")) {
|
if (offset.hasOwnProperty("x") && offset.hasOwnProperty("y")) {
|
||||||
windowPosition.x = offset.x < 0 ? viewport.x + offset.x : offset.x;
|
windowPosition.x = offset.x < 0 ? viewport.x + offset.x : offset.x;
|
||||||
|
@ -951,8 +958,8 @@ var usersWindow = (function() {
|
||||||
} else {
|
} else {
|
||||||
hmdViewport = Controller.getRecommendedOverlayRect();
|
hmdViewport = Controller.getRecommendedOverlayRect();
|
||||||
windowPosition = {
|
windowPosition = {
|
||||||
x: (viewport.x - hmdViewport.width) / 2, // HMD viewport is narrower than screen.
|
x: (viewport.x - hmdViewport.width) / 2, // HMD viewport is narrower than screen.
|
||||||
y: hmdViewport.height // HMD viewport starts at top of screen but only extends down so far.
|
y: hmdViewport.height // HMD viewport starts at top of screen but only extends down so far.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,13 +967,13 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
windowBorder = Overlays.addOverlay("rectangle", {
|
windowBorder = Overlays.addOverlay("rectangle", {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: viewport.y, // Start up off-screen
|
y: viewport.y, // Start up off-screen
|
||||||
width: WINDOW_BORDER_WIDTH,
|
width: WINDOW_BORDER_WIDTH,
|
||||||
height: windowBorderHeight,
|
height: windowBorderHeight,
|
||||||
radius: WINDOW_BORDER_RADIUS,
|
radius: WINDOW_BORDER_RADIUS,
|
||||||
color: WINDOW_BORDER_COLOR,
|
color: WINDOW_BORDER_COLOR,
|
||||||
alpha: WINDOW_BORDER_ALPHA,
|
alpha: WINDOW_BORDER_ALPHA,
|
||||||
visible: isVisible && isBorderVisible
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
windowPane = Overlays.addOverlay("text", {
|
windowPane = Overlays.addOverlay("text", {
|
||||||
|
@ -982,7 +989,7 @@ var usersWindow = (function() {
|
||||||
backgroundAlpha: WINDOW_BACKGROUND_ALPHA,
|
backgroundAlpha: WINDOW_BACKGROUND_ALPHA,
|
||||||
text: "",
|
text: "",
|
||||||
font: WINDOW_FONT,
|
font: WINDOW_FONT,
|
||||||
visible: isVisible
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
windowHeading = Overlays.addOverlay("text", {
|
windowHeading = Overlays.addOverlay("text", {
|
||||||
|
@ -997,7 +1004,7 @@ var usersWindow = (function() {
|
||||||
backgroundAlpha: 0.0,
|
backgroundAlpha: 0.0,
|
||||||
text: "No users online",
|
text: "No users online",
|
||||||
font: WINDOW_FONT,
|
font: WINDOW_FONT,
|
||||||
visible: isVisible && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
minimizeButton = Overlays.addOverlay("image", {
|
minimizeButton = Overlays.addOverlay("image", {
|
||||||
|
@ -1014,7 +1021,7 @@ var usersWindow = (function() {
|
||||||
},
|
},
|
||||||
color: MIN_MAX_BUTTON_COLOR,
|
color: MIN_MAX_BUTTON_COLOR,
|
||||||
alpha: MIN_MAX_BUTTON_ALPHA,
|
alpha: MIN_MAX_BUTTON_ALPHA,
|
||||||
visible: isVisible && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
scrollbarBackgroundPosition = {
|
scrollbarBackgroundPosition = {
|
||||||
|
@ -1029,7 +1036,7 @@ var usersWindow = (function() {
|
||||||
backgroundColor: SCROLLBAR_BACKGROUND_COLOR,
|
backgroundColor: SCROLLBAR_BACKGROUND_COLOR,
|
||||||
backgroundAlpha: SCROLLBAR_BACKGROUND_ALPHA,
|
backgroundAlpha: SCROLLBAR_BACKGROUND_ALPHA,
|
||||||
text: "",
|
text: "",
|
||||||
visible: isVisible && isUsingScrollbars && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
scrollbarBarPosition = {
|
scrollbarBarPosition = {
|
||||||
|
@ -1044,7 +1051,7 @@ var usersWindow = (function() {
|
||||||
backgroundColor: SCROLLBAR_BAR_COLOR,
|
backgroundColor: SCROLLBAR_BAR_COLOR,
|
||||||
backgroundAlpha: SCROLLBAR_BAR_ALPHA,
|
backgroundAlpha: SCROLLBAR_BAR_ALPHA,
|
||||||
text: "",
|
text: "",
|
||||||
visible: isVisible && isUsingScrollbars && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
friendsButton = Overlays.addOverlay("image", {
|
friendsButton = Overlays.addOverlay("image", {
|
||||||
|
@ -1060,12 +1067,18 @@ var usersWindow = (function() {
|
||||||
height: FRIENDS_BUTTON_SVG_HEIGHT
|
height: FRIENDS_BUTTON_SVG_HEIGHT
|
||||||
},
|
},
|
||||||
color: FRIENDS_BUTTON_COLOR,
|
color: FRIENDS_BUTTON_COLOR,
|
||||||
alpha: FRIENDS_BUTTON_ALPHA
|
alpha: FRIENDS_BUTTON_ALPHA,
|
||||||
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
showMe = Settings.getValue(SETTING_USERS_SHOW_ME, "");
|
||||||
|
if (DISPLAY_VALUES.indexOf(showMe) === -1) {
|
||||||
|
showMe = DISPLAY_EVERYONE;
|
||||||
|
}
|
||||||
|
|
||||||
displayControl = new PopUpMenu({
|
displayControl = new PopUpMenu({
|
||||||
prompt: DISPLAY_PROMPT,
|
prompt: DISPLAY_PROMPT,
|
||||||
value: DISPLAY_VALUES[0],
|
value: showMe,
|
||||||
values: DISPLAY_VALUES,
|
values: DISPLAY_VALUES,
|
||||||
displayValues: DISPLAY_DISPLAY_VALUES,
|
displayValues: DISPLAY_DISPLAY_VALUES,
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -1087,13 +1100,12 @@ var usersWindow = (function() {
|
||||||
popupBackgroundAlpha: DISPLAY_OPTIONS_BACKGROUND_ALPHA,
|
popupBackgroundAlpha: DISPLAY_OPTIONS_BACKGROUND_ALPHA,
|
||||||
buttonColor: MIN_MAX_BUTTON_COLOR,
|
buttonColor: MIN_MAX_BUTTON_COLOR,
|
||||||
buttonAlpha: MIN_MAX_BUTTON_ALPHA,
|
buttonAlpha: MIN_MAX_BUTTON_ALPHA,
|
||||||
visible: isVisible && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
myVisibility = GlobalServices.findableBy;
|
myVisibility = Settings.getValue(SETTING_USERS_VISIBLE_TO, "");
|
||||||
if (VISIBILITY_VALUES.indexOf(myVisibility) === -1) {
|
if (VISIBILITY_VALUES.indexOf(myVisibility) === -1) {
|
||||||
print("Error: Unrecognized findableBy value: " + myVisibility);
|
myVisibility = VISIBILITY_FRIENDS;
|
||||||
myVisibility = VISIBILITY_ALL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visibilityControl = new PopUpMenu({
|
visibilityControl = new PopUpMenu({
|
||||||
|
@ -1120,14 +1132,9 @@ var usersWindow = (function() {
|
||||||
popupBackgroundAlpha: DISPLAY_OPTIONS_BACKGROUND_ALPHA,
|
popupBackgroundAlpha: DISPLAY_OPTIONS_BACKGROUND_ALPHA,
|
||||||
buttonColor: MIN_MAX_BUTTON_COLOR,
|
buttonColor: MIN_MAX_BUTTON_COLOR,
|
||||||
buttonAlpha: MIN_MAX_BUTTON_ALPHA,
|
buttonAlpha: MIN_MAX_BUTTON_ALPHA,
|
||||||
visible: isVisible && !isMinimized
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Script.setTimeout(function() {
|
|
||||||
checkLoggedIn()
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
Controller.mousePressEvent.connect(onMousePressEvent);
|
Controller.mousePressEvent.connect(onMousePressEvent);
|
||||||
Controller.mouseMoveEvent.connect(onMouseMoveEvent);
|
Controller.mouseMoveEvent.connect(onMouseMoveEvent);
|
||||||
Controller.mouseReleaseEvent.connect(onMouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(onMouseReleaseEvent);
|
||||||
|
@ -1148,12 +1155,10 @@ var usersWindow = (function() {
|
||||||
pollUsers();
|
pollUsers();
|
||||||
|
|
||||||
// Set minimized at end - setup code does not handle `minimized == false` correctly
|
// Set minimized at end - setup code does not handle `minimized == false` correctly
|
||||||
setMinimized(Settings.getValue(SETTING_USERS_WINDOW_MINIMIZED, false));
|
setMinimized(isValueTrue(Settings.getValue(SETTING_USERS_WINDOW_MINIMIZED, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
Settings.setValue(SETTING_USERS_WINDOW_MINIMIZED, isMinimized);
|
|
||||||
|
|
||||||
Menu.removeMenuItem(MENU_NAME, MENU_ITEM);
|
Menu.removeMenuItem(MENU_NAME, MENU_ITEM);
|
||||||
|
|
||||||
Script.clearTimeout(usersTimer);
|
Script.clearTimeout(usersTimer);
|
||||||
|
@ -1170,4 +1175,4 @@ var usersWindow = (function() {
|
||||||
|
|
||||||
setUp();
|
setUp();
|
||||||
Script.scriptEnding.connect(tearDown);
|
Script.scriptEnding.connect(tearDown);
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue