mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
added snapshot notification in desktop mode
This commit is contained in:
parent
218b26b521
commit
04184ee1fb
3 changed files with 53 additions and 35 deletions
|
@ -4988,7 +4988,9 @@ void Application::takeSnapshot() {
|
||||||
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
||||||
player->play();
|
player->play();
|
||||||
|
|
||||||
Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot());
|
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot());
|
||||||
|
|
||||||
|
emit DependencyManager::get<WindowScriptingInterface>()->snapshotTaken(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Application::getRenderResolutionScale() const {
|
float Application::getRenderResolutionScale() const {
|
||||||
|
|
|
@ -46,6 +46,7 @@ signals:
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(const QString& domainHostname);
|
||||||
void svoImportRequested(const QString& url);
|
void svoImportRequested(const QString& url);
|
||||||
void domainConnectionRefused(const QString& reasonMessage, int reasonCode);
|
void domainConnectionRefused(const QString& reasonMessage, int reasonCode);
|
||||||
|
void snapshotTaken(const QString& path);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height);
|
WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height);
|
||||||
|
|
|
@ -49,10 +49,10 @@
|
||||||
// 2. Declare a text string.
|
// 2. Declare a text string.
|
||||||
// 3. Call createNotifications(text, NotificationType) parsing the text.
|
// 3. Call createNotifications(text, NotificationType) parsing the text.
|
||||||
// example:
|
// example:
|
||||||
// if (key.text === "s") {
|
// if (key.text === "o") {
|
||||||
// if (ctrlIsPressed === true) {
|
// if (ctrlIsPressed === true) {
|
||||||
// noteString = "Snapshot taken.";
|
// noteString = "Open script";
|
||||||
// createNotification(noteString, NotificationType.SNAPSHOT);
|
// createNotification(noteString, NotificationType.OPEN_SCRIPT);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -233,8 +233,9 @@ function calculate3DOverlayPositions(noticeWidth, noticeHeight, y) {
|
||||||
// Pushes data to each array and sets up data for 2nd dimension array
|
// Pushes data to each array and sets up data for 2nd dimension array
|
||||||
// to handle auxiliary data not carried by the overlay class
|
// to handle auxiliary data not carried by the overlay class
|
||||||
// specifically notification "heights", "times" of creation, and .
|
// specifically notification "heights", "times" of creation, and .
|
||||||
function notify(notice, button, height) {
|
function notify(notice, button, height, imageProperties, image) {
|
||||||
var noticeWidth,
|
var notificationText,
|
||||||
|
noticeWidth,
|
||||||
noticeHeight,
|
noticeHeight,
|
||||||
positions,
|
positions,
|
||||||
last;
|
last;
|
||||||
|
@ -269,9 +270,13 @@ function notify(notice, button, height) {
|
||||||
height: noticeHeight
|
height: noticeHeight
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var notificationText = Overlays.addOverlay("text", notice);
|
if (!image) {
|
||||||
notifications.push((notificationText));
|
notificationText = Overlays.addOverlay("text", notice);
|
||||||
buttons.push((Overlays.addOverlay("image", button)));
|
notifications.push((notificationText));
|
||||||
|
} else {
|
||||||
|
notifications.push(Overlays.addOverlay("image", notice));
|
||||||
|
}
|
||||||
|
buttons.push(Overlays.addOverlay("image", button));
|
||||||
}
|
}
|
||||||
|
|
||||||
height = height + 1.0;
|
height = height + 1.0;
|
||||||
|
@ -281,11 +286,24 @@ function notify(notice, button, height) {
|
||||||
last = notifications.length - 1;
|
last = notifications.length - 1;
|
||||||
createArrays(notifications[last], buttons[last], times[last], heights[last], myAlpha[last]);
|
createArrays(notifications[last], buttons[last], times[last], heights[last], myAlpha[last]);
|
||||||
fadeIn(notifications[last], buttons[last]);
|
fadeIn(notifications[last], buttons[last]);
|
||||||
|
|
||||||
|
if (imageProperties && !image) {
|
||||||
|
var imageHeight = notice.width / imageProperties.aspectRatio;
|
||||||
|
notice = {
|
||||||
|
x: notice.x,
|
||||||
|
y: notice.y + height,
|
||||||
|
width: notice.width,
|
||||||
|
height: imageHeight,
|
||||||
|
imageURL: imageProperties.path
|
||||||
|
};
|
||||||
|
notify(notice, button, imageHeight, imageProperties, true);
|
||||||
|
}
|
||||||
|
|
||||||
return notificationText;
|
return notificationText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function creates and sizes the overlays
|
// This function creates and sizes the overlays
|
||||||
function createNotification(text, notificationType) {
|
function createNotification(text, notificationType, imageProperties) {
|
||||||
var count = (text.match(/\n/g) || []).length,
|
var count = (text.match(/\n/g) || []).length,
|
||||||
breakPoint = 43.0, // length when new line is added
|
breakPoint = 43.0, // length when new line is added
|
||||||
extraLine = 0,
|
extraLine = 0,
|
||||||
|
@ -308,6 +326,11 @@ function createNotification(text, notificationType) {
|
||||||
|
|
||||||
level = (stack + 20.0);
|
level = (stack + 20.0);
|
||||||
height = height + extraLine;
|
height = height + extraLine;
|
||||||
|
|
||||||
|
if (imageProperties && imageProperties.path) {
|
||||||
|
imageProperties.path = Script.resolvePath(imageProperties.path);
|
||||||
|
}
|
||||||
|
|
||||||
noticeProperties = {
|
noticeProperties = {
|
||||||
x: overlayLocationX,
|
x: overlayLocationX,
|
||||||
y: level,
|
y: level,
|
||||||
|
@ -336,12 +359,11 @@ function createNotification(text, notificationType) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Menu.isOptionChecked(PLAY_NOTIFICATION_SOUNDS_MENU_ITEM) &&
|
if (Menu.isOptionChecked(PLAY_NOTIFICATION_SOUNDS_MENU_ITEM) &&
|
||||||
Menu.isOptionChecked(NotificationType.getMenuString(notificationType)))
|
Menu.isOptionChecked(NotificationType.getMenuString(notificationType))) {
|
||||||
{
|
|
||||||
randomSounds.playRandom();
|
randomSounds.playRandom();
|
||||||
}
|
}
|
||||||
|
|
||||||
return notify(noticeProperties, buttonProperties, height);
|
return notify(noticeProperties, buttonProperties, height, imageProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteNotification(index) {
|
function deleteNotification(index) {
|
||||||
|
@ -362,21 +384,12 @@ function deleteNotification(index) {
|
||||||
|
|
||||||
// wraps whole word to newline
|
// wraps whole word to newline
|
||||||
function stringDivider(str, slotWidth, spaceReplacer) {
|
function stringDivider(str, slotWidth, spaceReplacer) {
|
||||||
var p,
|
var left, right;
|
||||||
left,
|
|
||||||
right;
|
|
||||||
|
|
||||||
if (str.length > slotWidth) {
|
if (str.length > slotWidth && slotWidth > 0) {
|
||||||
p = slotWidth;
|
left = str.substring(0, slotWidth);
|
||||||
while (p > 0 && str[p] !== ' ') {
|
right = str.substring(slotWidth + 1);
|
||||||
p -= 1;
|
return left + spaceReplacer + stringDivider(right, slotWidth, spaceReplacer);
|
||||||
}
|
|
||||||
|
|
||||||
if (p > 0) {
|
|
||||||
left = str.substring(0, p);
|
|
||||||
right = str.substring(p + 1);
|
|
||||||
return left + spaceReplacer + stringDivider(right, slotWidth, spaceReplacer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +517,15 @@ function onMuteStateChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDomainConnectionRefused(reason) {
|
function onDomainConnectionRefused(reason) {
|
||||||
createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED );
|
createNotification("Connection refused: " + reason, NotificationType.CONNECTION_REFUSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSnapshotTaken(path) {
|
||||||
|
var imageProperties = {
|
||||||
|
path: path,
|
||||||
|
aspectRatio: Window.innerWidth / Window.innerHeight
|
||||||
|
}
|
||||||
|
createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handles mouse clicks on buttons
|
// handles mouse clicks on buttons
|
||||||
|
@ -541,13 +562,6 @@ function keyPressEvent(key) {
|
||||||
if (key.key === 16777249) {
|
if (key.key === 16777249) {
|
||||||
ctrlIsPressed = true;
|
ctrlIsPressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.text === "s") {
|
|
||||||
if (ctrlIsPressed === true) {
|
|
||||||
noteString = "Snapshot taken.";
|
|
||||||
createNotification(noteString, NotificationType.SNAPSHOT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
|
@ -615,5 +629,6 @@ Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
Menu.menuItemEvent.connect(menuItemEvent);
|
Menu.menuItemEvent.connect(menuItemEvent);
|
||||||
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
Window.domainConnectionRefused.connect(onDomainConnectionRefused);
|
||||||
|
Window.snapshotTaken.connect(onSnapshotTaken);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
Loading…
Reference in a new issue