mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 08:56:36 +02:00
resolve conflicts on merge with upstream/master
This commit is contained in:
commit
11f3161029
68 changed files with 1082 additions and 597 deletions
|
@ -648,6 +648,7 @@ void AudioMixer::run() {
|
|||
|
||||
// setup a QThread with us as parent that will house the AudioMixerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Datagram Processor Thread");
|
||||
|
||||
// create an AudioMixerDatagramProcessor and move it to that thread
|
||||
AudioMixerDatagramProcessor* datagramProcessor = new AudioMixerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
|
@ -879,6 +879,7 @@ void OctreeServer::setupDatagramProcessingThread() {
|
|||
|
||||
// setup a QThread with us as parent that will house the OctreeServerDatagramProcessor
|
||||
_datagramProcessingThread = new QThread(this);
|
||||
_datagramProcessingThread->setObjectName("Octree Datagram Processor");
|
||||
|
||||
// create an OctreeServerDatagramProcessor and move it to that thread
|
||||
OctreeServerDatagramProcessor* datagramProcessor = new OctreeServerDatagramProcessor(nodeList->getNodeSocket(), thread());
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <HTTPConnection.h>
|
||||
#include <LogUtils.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <ShutdownEventListener.h>
|
||||
#include <UUID.h>
|
||||
|
@ -1925,7 +1925,7 @@ Headers DomainServer::setupCookieHeadersFromProfileReply(QNetworkReply* profileR
|
|||
|
||||
// persist the cookie to settings file so we can get it back on DS relaunch
|
||||
QStringList path = QStringList() << DS_SETTINGS_SESSIONS_GROUP << cookieUUID.toString();
|
||||
SettingHandles::SettingHandle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
Setting::Handle<QVariant>(path).set(QVariant::fromValue(sessionData));
|
||||
|
||||
// setup expiry for cookie to 1 month from today
|
||||
QDateTime cookieExpiry = QDateTime::currentDateTimeUtc().addMonths(1);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
Script.load("progress.js");
|
||||
Script.load("lookWithTouch.js");
|
||||
Script.load("editEntities.js");
|
||||
Script.load("selectAudioDevice.js");
|
||||
|
|
109
examples/dice.js
Normal file
109
examples/dice.js
Normal file
|
@ -0,0 +1,109 @@
|
|||
//
|
||||
// dice.js
|
||||
// examples
|
||||
//
|
||||
// Created by Philip Rosedale on February 2, 2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Press the dice button to throw some dice from the center of the screen.
|
||||
// Change NUMBER_OF_DICE to change the number thrown (Yahtzee, anyone?)
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var isDice = false;
|
||||
var NUMBER_OF_DICE = 2;
|
||||
var dice = [];
|
||||
var DIE_SIZE = 0.20;
|
||||
|
||||
var madeSound = true; // Set false at start of throw to look for collision
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
var rollSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/dice/diceRoll.wav");
|
||||
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
var offButton = Overlays.addOverlay("image", {
|
||||
x: screenSize.x - 48,
|
||||
y: 96,
|
||||
width: 32,
|
||||
height: 32,
|
||||
imageURL: HIFI_PUBLIC_BUCKET + "images/close.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
var diceButton = Overlays.addOverlay("image", {
|
||||
x: screenSize.x - 48,
|
||||
y: 130,
|
||||
width: 32,
|
||||
height: 32,
|
||||
imageURL: HIFI_PUBLIC_BUCKET + "images/die.png",
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
alpha: 1
|
||||
});
|
||||
|
||||
var GRAVITY = -3.5;
|
||||
var LIFETIME = 300;
|
||||
function shootDice(position, velocity) {
|
||||
for (var i = 0; i < NUMBER_OF_DICE; i++) {
|
||||
dice.push(Entities.addEntity(
|
||||
{ type: "Model",
|
||||
modelURL: HIFI_PUBLIC_BUCKET + "models/props/Dice/goldDie.fbx",
|
||||
position: position,
|
||||
velocity: velocity,
|
||||
rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360),
|
||||
lifetime: LIFETIME,
|
||||
gravity: { x: 0, y: GRAVITY, z: 0 },
|
||||
collisionsWillMove: true
|
||||
}));
|
||||
position = Vec3.sum(position, Vec3.multiply(DIE_SIZE, Vec3.normalize(Quat.getRight(Camera.getOrientation()))));
|
||||
}
|
||||
}
|
||||
|
||||
function deleteDice() {
|
||||
while(dice.length > 0) {
|
||||
Entities.deleteEntity(dice.pop());
|
||||
}
|
||||
}
|
||||
|
||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||
if (!madeSound) {
|
||||
// Is it one of our dice?
|
||||
for (var i = 0; i < dice.length; i++) {
|
||||
if (!dice[i].isKnownID) {
|
||||
dice[i] = Entities.identifyEntity(dice[i]);
|
||||
}
|
||||
if ((entity1.id == dice[i].id) || (entity2.id == dice[i].id)) {
|
||||
madeSound = true;
|
||||
Audio.playSound(rollSound, { position: collision.contactPoint });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function mousePressEvent(event) {
|
||||
var clickedText = false;
|
||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
if (clickedOverlay == offButton) {
|
||||
deleteDice();
|
||||
} else if (clickedOverlay == diceButton) {
|
||||
var HOW_HARD = 2.0;
|
||||
var position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
var velocity = Vec3.multiply(HOW_HARD, Quat.getFront(Camera.getOrientation()));
|
||||
shootDice(position, velocity);
|
||||
madeSound = false;
|
||||
}
|
||||
}
|
||||
|
||||
function scriptEnding() {
|
||||
deleteDice();
|
||||
Overlays.deleteOverlay(offButton);
|
||||
Overlays.deleteOverlay(diceButton);
|
||||
|
||||
}
|
||||
|
||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
||||
Controller.mousePressEvent.connect(mousePressEvent);
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -60,6 +60,7 @@ selectionManager.addEventListener(function() {
|
|||
propertiesTool.setVisible(true);
|
||||
entityListTool.setVisible(true);
|
||||
gridTool.setVisible(true);
|
||||
Window.setFocus();
|
||||
hasShownPropertiesTool = true;
|
||||
}
|
||||
if (!selectionManager.hasSelection()) {
|
||||
|
@ -534,7 +535,7 @@ function mousePressEvent(event) {
|
|||
if (result !== null) {
|
||||
var currentProperties = Entities.getEntityProperties(result.entityID);
|
||||
cameraManager.enable();
|
||||
cameraManager.focus(currentProperties.position, null, Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||
cameraManager.focus(currentProperties.position, null, true);
|
||||
cameraManager.mousePressEvent(event);
|
||||
}
|
||||
} else {
|
||||
|
@ -670,19 +671,19 @@ function mouseClickEvent(event) {
|
|||
orientation = MyAvatar.orientation;
|
||||
intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation));
|
||||
|
||||
if (!event.isShifted) {
|
||||
selectionManager.clearSelections();
|
||||
}
|
||||
|
||||
var toggle = event.isShifted;
|
||||
selectionManager.addEntity(foundEntity, toggle);
|
||||
if (!event.isShifted) {
|
||||
selectionManager.setSelections([foundEntity]);
|
||||
} else {
|
||||
selectionManager.addEntity(foundEntity, true);
|
||||
}
|
||||
|
||||
print("Model selected: " + foundEntity.id);
|
||||
selectionDisplay.select(selectedEntityID, event);
|
||||
|
||||
cameraManager.focus(selectionManager.worldPosition,
|
||||
selectionManager.worldDimensions,
|
||||
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -820,9 +821,7 @@ function handeMenuEvent(menuItem) {
|
|||
} else if (menuItem == "Import Models") {
|
||||
modelImporter.doImport();
|
||||
} else if (menuItem == "Entity List...") {
|
||||
if (isActive) {
|
||||
entityListTool.toggleVisible();
|
||||
}
|
||||
entityListTool.toggleVisible();
|
||||
}
|
||||
tooltip.show(false);
|
||||
}
|
||||
|
|
|
@ -559,13 +559,6 @@
|
|||
</div>
|
||||
|
||||
<div class="property">
|
||||
<div class="label">Mass</div>
|
||||
<div class="value">
|
||||
<input type='number' id="property-mass"></input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="label">Density</div>
|
||||
<div>
|
||||
<input type='number' id="property-density"></input>
|
||||
|
|
265
examples/progress.js
Normal file
265
examples/progress.js
Normal file
|
@ -0,0 +1,265 @@
|
|||
//
|
||||
// progress.js
|
||||
// examples
|
||||
//
|
||||
// Created by David Rowe on 29 Jan 2015.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This script displays a progress download indicator when downloads are in progress.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function () {
|
||||
|
||||
var progress = 100, // %
|
||||
alpha = 0.0,
|
||||
alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/
|
||||
ALPHA_DELTA_IN = 0.15,
|
||||
ALPHA_DELTA_OUT = -0.02,
|
||||
fadeTimer = null,
|
||||
FADE_INTERVAL = 30, // ms between changes in alpha.
|
||||
fadeWaitTimer = null,
|
||||
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
|
||||
visible = false,
|
||||
BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar.
|
||||
BAR_HEIGHT = 20,
|
||||
BAR_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar.svg",
|
||||
BACKGROUND_WIDTH = 360,
|
||||
BACKGROUND_HEIGHT = 60,
|
||||
BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg",
|
||||
isOnHMD = false,
|
||||
windowWidth = 0,
|
||||
windowHeight = 0,
|
||||
background2D = {},
|
||||
bar2D = {},
|
||||
SCALE_2D = 0.55, // Scale the SVGs for 2D display.
|
||||
background3D = {},
|
||||
bar3D = {},
|
||||
ENABLE_VR_MODE_MENU_ITEM = "Enable VR Mode",
|
||||
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
|
||||
PROGRESS_3D_DISTANCE = 0.602, // Horizontal distance from avatar position.
|
||||
PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes.
|
||||
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
|
||||
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical.
|
||||
SCALE_3D = 0.0017, // Scale the bar SVG for 3D display.
|
||||
BACKGROUND_3D_SIZE = { x: 0.76, y: 0.08 }, // Match up with the 3D background with those of notifications.js notices.
|
||||
BACKGROUND_3D_COLOR = { red: 2, green: 2, blue: 2 },
|
||||
BACKGROUND_3D_ALPHA = 0.7;
|
||||
|
||||
function fade() {
|
||||
|
||||
alpha = alpha + alphaDelta;
|
||||
|
||||
if (alpha < 0) {
|
||||
alpha = 0;
|
||||
}
|
||||
|
||||
if (alpha > 1) {
|
||||
alpha = 1;
|
||||
}
|
||||
|
||||
if (alpha === 0 || alpha === 1) { // Finished fading in or out
|
||||
alphaDelta = 0;
|
||||
Script.clearInterval(fadeTimer);
|
||||
}
|
||||
|
||||
if (alpha === 0) { // Finished fading out
|
||||
visible = false;
|
||||
}
|
||||
|
||||
if (isOnHMD) {
|
||||
Overlays.editOverlay(background3D.overlay, {
|
||||
backgroundAlpha: alpha * BACKGROUND_3D_ALPHA,
|
||||
visible: visible
|
||||
});
|
||||
} else {
|
||||
Overlays.editOverlay(background2D.overlay, {
|
||||
alpha: alpha,
|
||||
visible: visible
|
||||
});
|
||||
}
|
||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
||||
alpha: alpha,
|
||||
visible: visible
|
||||
});
|
||||
}
|
||||
|
||||
function onDownloadInfoChanged(info) {
|
||||
var i;
|
||||
|
||||
// Calculate progress
|
||||
if (info.downloading.length + info.pending === 0) {
|
||||
progress = 100;
|
||||
} else {
|
||||
progress = 0;
|
||||
for (i = 0; i < info.downloading.length; i += 1) {
|
||||
progress += info.downloading[i];
|
||||
}
|
||||
progress = progress / (info.downloading.length + info.pending);
|
||||
}
|
||||
|
||||
// Update state
|
||||
if (!visible) { // Not visible because no recent downloads
|
||||
if (progress < 100) { // Have started downloading so fade in
|
||||
visible = true;
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
}
|
||||
} else if (alphaDelta !== 0.0) { // Fading in or out
|
||||
if (alphaDelta > 0) {
|
||||
if (progress === 100) { // Was donloading but now have finished so fade out
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
}
|
||||
} else {
|
||||
if (progress < 100) { // Was finished downloading but have resumed so fade in
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
}
|
||||
}
|
||||
} else { // Fully visible because downloading or recently so
|
||||
if (fadeWaitTimer === null) {
|
||||
if (progress === 100) { // Was downloading but have finished so fade out soon
|
||||
fadeWaitTimer = Script.setTimeout(function () {
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
fadeWaitTimer = null;
|
||||
}, FADE_OUT_WAIT);
|
||||
}
|
||||
} else {
|
||||
if (progress < 100) { // Was finished and waiting to fade out but have resumed downloading so don't fade out
|
||||
Script.clearInterval(fadeWaitTimer);
|
||||
fadeWaitTimer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update progress bar
|
||||
if (visible) {
|
||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
||||
subImage: { x: BAR_WIDTH * (1 - progress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createOverlays() {
|
||||
if (isOnHMD) {
|
||||
|
||||
background3D.overlay = Overlays.addOverlay("rectangle3d", {
|
||||
size: BACKGROUND_3D_SIZE,
|
||||
color: BACKGROUND_3D_COLOR,
|
||||
alpha: BACKGROUND_3D_ALPHA,
|
||||
solid: true,
|
||||
isFacingAvatar: false,
|
||||
visible: false,
|
||||
ignoreRayIntersection: true
|
||||
});
|
||||
bar3D.overlay = Overlays.addOverlay("billboard", {
|
||||
url: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
scale: SCALE_3D * BAR_WIDTH,
|
||||
isFacingAvatar: false,
|
||||
visible: false,
|
||||
alpha: 0.0,
|
||||
ignoreRayIntersection: true
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
background2D.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: BACKGROUND_URL,
|
||||
width: background2D.width,
|
||||
height: background2D.height,
|
||||
visible: false,
|
||||
alpha: 0.0
|
||||
});
|
||||
bar2D.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
width: bar2D.width,
|
||||
height: bar2D.height,
|
||||
visible: false,
|
||||
alpha: 0.0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteOverlays() {
|
||||
Overlays.deleteOverlay(isOnHMD ? background3D.overlay : background2D.overlay);
|
||||
Overlays.deleteOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay);
|
||||
}
|
||||
|
||||
function update() {
|
||||
var viewport,
|
||||
eyePosition,
|
||||
avatarOrientation;
|
||||
|
||||
if (isOnHMD !== Menu.isOptionChecked(ENABLE_VR_MODE_MENU_ITEM)) {
|
||||
deleteOverlays();
|
||||
isOnHMD = !isOnHMD;
|
||||
createOverlays();
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
if (isOnHMD) {
|
||||
// Update 3D overlays to maintain positions relative to avatar
|
||||
eyePosition = MyAvatar.getDefaultEyePosition();
|
||||
avatarOrientation = MyAvatar.orientation;
|
||||
|
||||
Overlays.editOverlay(background3D.overlay, {
|
||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, background3D.offset)),
|
||||
rotation: Quat.multiply(avatarOrientation, background3D.orientation)
|
||||
});
|
||||
Overlays.editOverlay(bar3D.overlay, {
|
||||
position: Vec3.sum(eyePosition, Vec3.multiplyQbyV(avatarOrientation, bar3D.offset)),
|
||||
rotation: Quat.multiply(avatarOrientation, bar3D.orientation)
|
||||
});
|
||||
|
||||
} else {
|
||||
// Update 2D overlays to maintain positions at bottom middle of window
|
||||
viewport = Controller.getViewportDimensions();
|
||||
|
||||
if (viewport.x !== windowWidth || viewport.y !== windowHeight) {
|
||||
windowWidth = viewport.x;
|
||||
windowHeight = viewport.y;
|
||||
|
||||
Overlays.editOverlay(background2D.overlay, {
|
||||
x: windowWidth / 2 - background2D.width / 2,
|
||||
y: windowHeight - background2D.height - bar2D.height
|
||||
});
|
||||
|
||||
Overlays.editOverlay(bar2D.overlay, {
|
||||
x: windowWidth / 2 - bar2D.width / 2,
|
||||
y: windowHeight - background2D.height - bar2D.height + (background2D.height - bar2D.height) / 2
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
background2D.width = SCALE_2D * BACKGROUND_WIDTH;
|
||||
background2D.height = SCALE_2D * BACKGROUND_HEIGHT;
|
||||
bar2D.width = SCALE_2D * BAR_WIDTH;
|
||||
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
||||
|
||||
background3D.offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, PROGRESS_3D_DIRECTION, 0),
|
||||
{ x: 0, y: 0, z: -PROGRESS_3D_DISTANCE });
|
||||
background3D.offset.y += PROGRESS_3D_ELEVATION;
|
||||
background3D.orientation = Quat.fromPitchYawRollDegrees(PROGRESS_3D_PITCH, PROGRESS_3D_DIRECTION + PROGRESS_3D_YAW, 0);
|
||||
bar3D.offset = Vec3.sum(background3D.offset, { x: 0, y: 0, z: 0.001 }); // Just in front of background
|
||||
bar3D.orientation = background3D.orientation;
|
||||
|
||||
createOverlays();
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
deleteOverlays();
|
||||
}
|
||||
|
||||
setUp();
|
||||
GlobalServices.downloadInfoChanged.connect(onDownloadInfoChanged);
|
||||
GlobalServices.updateDownloadInfo();
|
||||
Script.update.connect(update);
|
||||
Script.scriptEnding.connect(tearDown);
|
||||
}());
|
|
@ -73,7 +73,7 @@
|
|||
#include <PhysicsEngine.h>
|
||||
#include <ProgramObject.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SoundCache.h>
|
||||
#include <TextRenderer.h>
|
||||
#include <UserActivityLogger.h>
|
||||
|
@ -143,12 +143,6 @@ const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::D
|
|||
|
||||
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> firstRun("firstRun", true);
|
||||
const SettingHandle<QString> lastScriptLocation("LastScriptLocation");
|
||||
const SettingHandle<QString> scriptsLocation("scriptsLocation");
|
||||
}
|
||||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
|
||||
|
||||
|
@ -164,16 +158,8 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
if (portStr) {
|
||||
listenPort = atoi(portStr);
|
||||
}
|
||||
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
QApplication::setApplicationName(applicationInfo.value("name").toString());
|
||||
QApplication::setApplicationVersion(BUILD_VERSION);
|
||||
QApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
QApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
// Set build version
|
||||
QCoreApplication::setApplicationVersion(BUILD_VERSION);
|
||||
|
||||
DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
|
||||
DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
|
||||
|
@ -208,7 +194,6 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
||||
|
@ -229,6 +214,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_lastQueriedViewFrustum(),
|
||||
_lastQueriedTime(usecTimestampNow()),
|
||||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||
_firstRun("firstRun", true),
|
||||
_previousScriptLocation("LastScriptLocation"),
|
||||
_scriptsLocationHandle("scriptsLocation"),
|
||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_viewTransform(),
|
||||
_scaleMirror(1.0f),
|
||||
_rotateMirror(0.0f),
|
||||
|
@ -242,7 +231,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_enableProcessOctreeThread(true),
|
||||
_octreeProcessor(),
|
||||
_nodeBoundsDisplay(this),
|
||||
_previousScriptLocation(),
|
||||
_applicationOverlay(),
|
||||
_runningScriptsWidget(NULL),
|
||||
_runningScriptsWidgetWasVisible(false),
|
||||
|
@ -250,7 +238,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_lastNackTime(usecTimestampNow()),
|
||||
_lastSendDownstreamAudioStats(usecTimestampNow()),
|
||||
_isVSyncOn(true),
|
||||
_aboutToQuit(false)
|
||||
_aboutToQuit(false),
|
||||
_notifiedPacketVersionMismatchThisDomain(false)
|
||||
{
|
||||
_logger = new FileLogger(this); // After setting organization name in order to get correct directory
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
@ -277,6 +266,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
||||
|
||||
// start the nodeThread so its event loop is running
|
||||
_nodeThread->setObjectName("Datagram Processor Thread");
|
||||
_nodeThread->start();
|
||||
|
||||
// make sure the node thread is given highest priority
|
||||
|
@ -291,6 +281,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
// put the audio processing on a separate thread
|
||||
QThread* audioThread = new QThread(this);
|
||||
audioThread->setObjectName("Audio Thread");
|
||||
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
|
||||
|
@ -326,6 +317,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
connect(nodeList.data(), SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer)));
|
||||
connect(nodeList.data(), &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID);
|
||||
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
|
||||
connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
||||
|
||||
// connect to appropriate slots on AccountManager
|
||||
AccountManager& accountManager = AccountManager::getInstance();
|
||||
|
@ -438,26 +430,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
bandwidthRecorder.data(), SLOT(updateInboundData(const quint8, const int)));
|
||||
|
||||
// check first run...
|
||||
bool firstRun = SettingHandles::firstRun.get();
|
||||
if (firstRun) {
|
||||
if (_firstRun.get()) {
|
||||
qDebug() << "This is a first run...";
|
||||
// clear the scripts, and set out script to our default scripts
|
||||
clearScriptsBeforeRunning();
|
||||
loadScript(DEFAULT_SCRIPTS_JS_URL);
|
||||
|
||||
SettingHandles::firstRun.set(false);
|
||||
_firstRun.set(false);
|
||||
} else {
|
||||
// do this as late as possible so that all required subsystems are initialized
|
||||
loadScripts();
|
||||
|
||||
_previousScriptLocation = SettingHandles::lastScriptLocation.get();
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
int SAVE_SETTINGS_INTERVAL = 10 * MSECS_PER_SECOND; // Let's save every seconds for now
|
||||
connect(&_settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||
connect(&_settingsThread, SIGNAL(started), &_settingsTimer, SLOT(start));
|
||||
connect(&_settingsThread, &QThread::finished, &_settingsTimer, &QTimer::deleteLater);
|
||||
connect(&_settingsThread, SIGNAL(started()), &_settingsTimer, SLOT(start()));
|
||||
connect(&_settingsThread, SIGNAL(finished()), &_settingsTimer, SLOT(stop()));
|
||||
_settingsTimer.moveToThread(&_settingsThread);
|
||||
_settingsTimer.setSingleShot(false);
|
||||
_settingsTimer.setInterval(SAVE_SETTINGS_INTERVAL);
|
||||
|
@ -483,6 +472,8 @@ void Application::aboutToQuit() {
|
|||
}
|
||||
|
||||
Application::~Application() {
|
||||
QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
|
||||
_settingsThread.quit();
|
||||
saveSettings();
|
||||
|
||||
_entities.getTree()->setSimulation(NULL);
|
||||
|
@ -568,6 +559,7 @@ void Application::initializeGL() {
|
|||
|
||||
// create thread for parsing of octee data independent of the main network and rendering threads
|
||||
_octreeProcessor.initialize(_enableProcessOctreeThread);
|
||||
connect(&_octreeProcessor, &OctreePacketProcessor::packetVersionMismatch, this, &Application::notifyPacketVersionMismatch);
|
||||
_entityEditSender.initialize(_enableProcessOctreeThread);
|
||||
|
||||
// call our timer function every second
|
||||
|
@ -727,7 +719,7 @@ void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height)
|
|||
TV3DManager::configureCamera(camera, width, height);
|
||||
} else {
|
||||
camera.setAspectRatio((float)width / height);
|
||||
camera.setFieldOfView(_viewFrustum.getFieldOfView());
|
||||
camera.setFieldOfView(_fieldOfView.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1567,15 +1559,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
}
|
||||
|
||||
void Application::loadSettings() {
|
||||
|
||||
DependencyManager::get<AudioClient>()->loadSettings();
|
||||
DependencyManager::get<LODManager>()->loadSettings();
|
||||
|
||||
Menu::getInstance()->loadSettings();
|
||||
_myAvatar->loadData();
|
||||
}
|
||||
|
||||
void Application::saveSettings() {
|
||||
DependencyManager::get<AudioClient>()->saveSettings();
|
||||
DependencyManager::get<LODManager>()->saveSettings();
|
||||
|
||||
Menu::getInstance()->saveSettings();
|
||||
_myAvatar->saveData();
|
||||
}
|
||||
|
@ -2936,7 +2929,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
|||
_mirrorCamera.setPosition(_myAvatar->getPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * BILLBOARD_DISTANCE * _myAvatar->getScale());
|
||||
|
||||
} else if (SettingHandles::rearViewZoomLevel.get() == BODY) {
|
||||
} else if (RearMirrorTools::rearViewZoomLevel.get() == BODY) {
|
||||
_mirrorCamera.setFieldOfView(MIRROR_FIELD_OF_VIEW); // degrees
|
||||
_mirrorCamera.setPosition(_myAvatar->getChestPosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_REARVIEW_BODY_DISTANCE * _myAvatar->getScale());
|
||||
|
@ -3174,11 +3167,11 @@ void Application::connectedToDomain(const QString& hostname) {
|
|||
|
||||
if (accountManager.isLoggedIn() && !domainID.isNull()) {
|
||||
// update our data-server with the domain-server we're logged in with
|
||||
|
||||
QString domainPutJsonString = "{\"location\":{\"domain_id\":\"" + uuidStringWithoutCurlyBraces(domainID) + "\"}}";
|
||||
|
||||
accountManager.authenticatedRequest("/api/v1/user/location", QNetworkAccessManager::PutOperation,
|
||||
JSONCallbackParameters(), domainPutJsonString.toUtf8());
|
||||
|
||||
_notifiedPacketVersionMismatchThisDomain = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3445,6 +3438,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
#endif
|
||||
|
||||
QThread* workerThread = new QThread(this);
|
||||
workerThread->setObjectName("Script Engine Thread");
|
||||
|
||||
// when the worker thread is started, call our engine's run..
|
||||
connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);
|
||||
|
@ -3663,21 +3657,20 @@ void Application::domainSettingsReceived(const QJsonObject& domainSettingsObject
|
|||
|
||||
QString Application::getPreviousScriptLocation() {
|
||||
QString suggestedName;
|
||||
if (_previousScriptLocation.isEmpty()) {
|
||||
if (_previousScriptLocation.get().isEmpty()) {
|
||||
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
// Temporary fix to Qt bug: http://stackoverflow.com/questions/16194475
|
||||
#ifdef __APPLE__
|
||||
suggestedName = desktopLocation.append("/script.js");
|
||||
#endif
|
||||
} else {
|
||||
suggestedName = _previousScriptLocation;
|
||||
suggestedName = _previousScriptLocation.get();
|
||||
}
|
||||
return suggestedName;
|
||||
}
|
||||
|
||||
void Application::setPreviousScriptLocation(const QString& previousScriptLocation) {
|
||||
_previousScriptLocation = previousScriptLocation;
|
||||
SettingHandles::lastScriptLocation.set(_previousScriptLocation);
|
||||
_previousScriptLocation.set(previousScriptLocation);
|
||||
}
|
||||
|
||||
void Application::loadDialog() {
|
||||
|
@ -3712,12 +3705,12 @@ void Application::loadScriptURLDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
QString Application::getScriptsLocation() const {
|
||||
return SettingHandles::scriptsLocation.get();
|
||||
QString Application::getScriptsLocation() {
|
||||
return _scriptsLocationHandle.get();
|
||||
}
|
||||
|
||||
void Application::setScriptsLocation(const QString& scriptsLocation) {
|
||||
SettingHandles::scriptsLocation.set(scriptsLocation);
|
||||
_scriptsLocationHandle.set(scriptsLocation);
|
||||
emit scriptLocationChanged(scriptsLocation);
|
||||
}
|
||||
|
||||
|
@ -3940,3 +3933,18 @@ int Application::getRenderAmbientLight() const {
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::notifyPacketVersionMismatch() {
|
||||
if (!_notifiedPacketVersionMismatchThisDomain) {
|
||||
_notifiedPacketVersionMismatchThisDomain = true;
|
||||
|
||||
QString message = "The location you are visiting is running an incompatible server version.\n";
|
||||
message += "Content may not display properly.";
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,6 +208,9 @@ public:
|
|||
|
||||
virtual const Transform& getViewTransform() const { return _viewTransform; }
|
||||
void setViewTransform(const Transform& view);
|
||||
|
||||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
void setFieldOfView(float fov) { _fieldOfView.set(fov); }
|
||||
|
||||
NodeToOctreeSceneStats* getOcteeSceneStats() { return &_octreeServerSceneStats; }
|
||||
void lockOctreeSceneStats() { _octreeSceneStatsLock.lockForRead(); }
|
||||
|
@ -290,7 +293,7 @@ public:
|
|||
|
||||
Bookmarks* getBookmarks() const { return _bookmarks; }
|
||||
|
||||
QString getScriptsLocation() const;
|
||||
QString getScriptsLocation();
|
||||
void setScriptsLocation(const QString& scriptsLocation);
|
||||
|
||||
signals:
|
||||
|
@ -355,6 +358,8 @@ public slots:
|
|||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
void notifyPacketVersionMismatch();
|
||||
|
||||
private slots:
|
||||
void clearDomainOctreeDetails();
|
||||
void timer();
|
||||
|
@ -479,6 +484,11 @@ private:
|
|||
Camera _mirrorCamera; // Cammera for mirror view
|
||||
QRect _mirrorViewRect;
|
||||
RearMirrorTools* _rearMirrorTools;
|
||||
|
||||
Setting::Handle<bool> _firstRun;
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<QString> _scriptsLocationHandle;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
|
||||
Transform _viewTransform;
|
||||
glm::mat4 _untranslatedViewMatrix;
|
||||
|
@ -536,8 +546,6 @@ private:
|
|||
QPointer<LogDialog> _logDialog;
|
||||
QPointer<SnapshotShareDialog> _snapshotShareDialog;
|
||||
|
||||
QString _previousScriptLocation;
|
||||
|
||||
FileLogger* _logger;
|
||||
|
||||
void checkVersion();
|
||||
|
@ -565,6 +573,8 @@ private:
|
|||
bool _aboutToQuit;
|
||||
|
||||
Bookmarks* _bookmarks;
|
||||
|
||||
bool _notifiedPacketVersionMismatchThisDomain;
|
||||
|
||||
QThread _settingsThread;
|
||||
QTimer _settingsTimer;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <Util.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
@ -16,15 +17,14 @@
|
|||
|
||||
#include "LODManager.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
const SettingHandle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
const SettingHandle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
const SettingHandle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
Setting::Handle<bool> automaticAvatarLOD("automaticAvatarLOD", true);
|
||||
Setting::Handle<float> avatarLODDecreaseFPS("avatarLODDecreaseFPS", DEFAULT_ADJUST_AVATAR_LOD_DOWN_FPS);
|
||||
Setting::Handle<float> avatarLODIncreaseFPS("avatarLODIncreaseFPS", ADJUST_LOD_UP_FPS);
|
||||
Setting::Handle<float> avatarLODDistanceMultiplier("avatarLODDistanceMultiplier",
|
||||
DEFAULT_AVATAR_LOD_DISTANCE_MULTIPLIER);
|
||||
const SettingHandle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
const SettingHandle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
}
|
||||
Setting::Handle<int> boundaryLevelAdjust("boundaryLevelAdjust", 0);
|
||||
Setting::Handle<float> octreeSizeScale("octreeSizeScale", DEFAULT_OCTREE_SIZE_SCALE);
|
||||
|
||||
|
||||
void LODManager::autoAdjustLOD(float currentFPS) {
|
||||
// NOTE: our first ~100 samples at app startup are completely all over the place, and we don't
|
||||
|
@ -190,21 +190,21 @@ void LODManager::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
|||
|
||||
|
||||
void LODManager::loadSettings() {
|
||||
setAutomaticAvatarLOD(SettingHandles::automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(SettingHandles::avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(SettingHandles::avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(SettingHandles::avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(SettingHandles::boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(SettingHandles::octreeSizeScale.get());
|
||||
setAutomaticAvatarLOD(automaticAvatarLOD.get());
|
||||
setAvatarLODDecreaseFPS(avatarLODDecreaseFPS.get());
|
||||
setAvatarLODIncreaseFPS(avatarLODIncreaseFPS.get());
|
||||
setAvatarLODDistanceMultiplier(avatarLODDistanceMultiplier.get());
|
||||
setBoundaryLevelAdjust(boundaryLevelAdjust.get());
|
||||
setOctreeSizeScale(octreeSizeScale.get());
|
||||
}
|
||||
|
||||
void LODManager::saveSettings() {
|
||||
SettingHandles::automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
SettingHandles::avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
SettingHandles::avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
SettingHandles::avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
SettingHandles::boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
SettingHandles::octreeSizeScale.set(getOctreeSizeScale());
|
||||
automaticAvatarLOD.set(getAutomaticAvatarLOD());
|
||||
avatarLODDecreaseFPS.set(getAvatarLODDecreaseFPS());
|
||||
avatarLODIncreaseFPS.set(getAvatarLODIncreaseFPS());
|
||||
avatarLODDistanceMultiplier.set(getAvatarLODDistanceMultiplier());
|
||||
boundaryLevelAdjust.set(getBoundaryLevelAdjust());
|
||||
octreeSizeScale.set(getOctreeSizeScale());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <OctreeConstants.h>
|
||||
#include <Settings.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
||||
|
|
|
@ -18,24 +18,20 @@
|
|||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QRect> windowGeometry("WindowGeometry");
|
||||
}
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent),
|
||||
_windowGeometry("WindowGeometry")
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
// Did not use setGeometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry = SettingHandles::windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
QRect geometry = _windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
move(geometry.topLeft());
|
||||
resize(geometry.size());
|
||||
}
|
||||
|
@ -44,7 +40,7 @@ void MainWindow::saveGeometry() {
|
|||
// Did not use geometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
QRect geometry(pos(), size());
|
||||
SettingHandles::windowGeometry.set(geometry);
|
||||
_windowGeometry.set(geometry);
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -33,6 +35,9 @@ protected:
|
|||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void changeEvent(QEvent* event);
|
||||
|
||||
private:
|
||||
Setting::Handle<QRect> _windowGeometry;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MainWindow__) */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <GlowEffect.h>
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <XmppClient.h>
|
||||
|
||||
|
|
|
@ -239,8 +239,6 @@ namespace MenuOption {
|
|||
const QString RunTimingTests = "Run Timing Tests";
|
||||
const QString ScriptEditor = "Script Editor...";
|
||||
const QString ScriptedMotorControl = "Enable Scripted Motor Control";
|
||||
const QString SettingsExport = "Export Settings";
|
||||
const QString SettingsImport = "Import Settings";
|
||||
const QString ShowBordersEntityNodes = "Show Entity Nodes";
|
||||
const QString ShowBordersVoxelNodes = "Show Voxel Nodes";
|
||||
const QString ShowIKConstraints = "Show IK Constraints";
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <GeometryCache.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <Settings.h>
|
||||
#include <TextureCache.h>
|
||||
|
||||
#include "ModelUploader.h"
|
||||
|
@ -68,14 +67,13 @@ static const int MAX_CHECK = 30;
|
|||
static const int QCOMPRESS_HEADER_POSITION = 0;
|
||||
static const int QCOMPRESS_HEADER_SIZE = 4;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> lastModelUploadLocation("LastModelUploadLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
}
|
||||
Setting::Handle<QString> ModelUploader::_lastModelUploadLocation("LastModelUploadLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
|
||||
|
||||
void ModelUploader::uploadModel(ModelType modelType) {
|
||||
ModelUploader* uploader = new ModelUploader(modelType);
|
||||
QThread* thread = new QThread();
|
||||
thread->setObjectName("Model Uploader");
|
||||
thread->connect(uploader, SIGNAL(destroyed()), SLOT(quit()));
|
||||
thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
|
||||
uploader->connect(thread, SIGNAL(started()), SLOT(send()));
|
||||
|
@ -117,7 +115,7 @@ ModelUploader::~ModelUploader() {
|
|||
|
||||
bool ModelUploader::zip() {
|
||||
// File Dialog
|
||||
QString lastLocation = SettingHandles::lastModelUploadLocation.get();
|
||||
QString lastLocation = _lastModelUploadLocation.get();
|
||||
|
||||
if (lastLocation.isEmpty()) {
|
||||
lastLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
|
@ -134,7 +132,7 @@ bool ModelUploader::zip() {
|
|||
// If the user canceled we return.
|
||||
return false;
|
||||
}
|
||||
SettingHandles::lastModelUploadLocation.set(filename);
|
||||
_lastModelUploadLocation.set(filename);
|
||||
|
||||
// First we check the FST file (if any)
|
||||
QFile* fst;
|
||||
|
@ -265,7 +263,7 @@ bool ModelUploader::zip() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void ModelUploader::populateBasicMapping(QVariantHash& mapping, QString filename, FBXGeometry geometry) {
|
||||
void ModelUploader::populateBasicMapping(QVariantHash& mapping, QString filename, const FBXGeometry& geometry) {
|
||||
if (!mapping.contains(NAME_FIELD)) {
|
||||
mapping.insert(NAME_FIELD, QFileInfo(filename).baseName());
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <FBXReader.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "ui/ModelsBrowser.h"
|
||||
|
||||
|
@ -53,7 +54,7 @@ private:
|
|||
ModelUploader(ModelType type);
|
||||
~ModelUploader();
|
||||
|
||||
void populateBasicMapping(QVariantHash& mapping, QString filename, FBXGeometry geometry);
|
||||
void populateBasicMapping(QVariantHash& mapping, QString filename, const FBXGeometry& geometry);
|
||||
bool zip();
|
||||
bool addTextures(const QString& texdir, const FBXGeometry& geometry);
|
||||
bool addPart(const QString& path, const QString& name, bool isTexture = false);
|
||||
|
@ -68,13 +69,15 @@ private:
|
|||
ModelType _modelType;
|
||||
bool _readyToSend;
|
||||
|
||||
QHttpMultiPart* _dataMultiPart;
|
||||
QHttpMultiPart* _dataMultiPart = nullptr;
|
||||
|
||||
int _numberOfChecks;
|
||||
QTimer _timer;
|
||||
|
||||
QDialog* _progressDialog;
|
||||
QProgressBar* _progressBar;
|
||||
QDialog* _progressDialog = nullptr;
|
||||
QProgressBar* _progressBar = nullptr;
|
||||
|
||||
static Setting::Handle<QString> _lastModelUploadLocation;
|
||||
};
|
||||
|
||||
/// A dialog that allows customization of various model properties.
|
||||
|
@ -101,23 +104,23 @@ private:
|
|||
QVariantHash _originalMapping;
|
||||
QString _basePath;
|
||||
FBXGeometry _geometry;
|
||||
QLineEdit* _name;
|
||||
QPushButton* _textureDirectory;
|
||||
QDoubleSpinBox* _scale;
|
||||
QDoubleSpinBox* _translationX;
|
||||
QDoubleSpinBox* _translationY;
|
||||
QDoubleSpinBox* _translationZ;
|
||||
QCheckBox* _pivotAboutCenter;
|
||||
QComboBox* _pivotJoint;
|
||||
QComboBox* _leftEyeJoint;
|
||||
QComboBox* _rightEyeJoint;
|
||||
QComboBox* _neckJoint;
|
||||
QComboBox* _rootJoint;
|
||||
QComboBox* _leanJoint;
|
||||
QComboBox* _headJoint;
|
||||
QComboBox* _leftHandJoint;
|
||||
QComboBox* _rightHandJoint;
|
||||
QVBoxLayout* _freeJoints;
|
||||
QLineEdit* _name = nullptr;
|
||||
QPushButton* _textureDirectory = nullptr;
|
||||
QDoubleSpinBox* _scale = nullptr;
|
||||
QDoubleSpinBox* _translationX = nullptr;
|
||||
QDoubleSpinBox* _translationY = nullptr;
|
||||
QDoubleSpinBox* _translationZ = nullptr;
|
||||
QCheckBox* _pivotAboutCenter = nullptr;
|
||||
QComboBox* _pivotJoint = nullptr;
|
||||
QComboBox* _leftEyeJoint = nullptr;
|
||||
QComboBox* _rightEyeJoint = nullptr;
|
||||
QComboBox* _neckJoint = nullptr;
|
||||
QComboBox* _rootJoint = nullptr;
|
||||
QComboBox* _leanJoint = nullptr;
|
||||
QComboBox* _headJoint = nullptr;
|
||||
QComboBox* _leftHandJoint = nullptr;
|
||||
QComboBox* _rightHandJoint = nullptr;
|
||||
QVBoxLayout* _freeJoints = nullptr;
|
||||
};
|
||||
|
||||
#endif // hifi_ModelUploader_h
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
#include <Settings.h>
|
||||
#include <ShapeCollider.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer.h>
|
||||
|
@ -53,6 +52,7 @@ const float YAW_SPEED = 500.0f; // degrees/sec
|
|||
const float PITCH_SPEED = 100.0f; // degrees/sec
|
||||
const float COLLISION_RADIUS_SCALAR = 1.2f; // pertains to avatar-to-avatar collisions
|
||||
const float COLLISION_RADIUS_SCALE = 0.125f;
|
||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||
|
||||
const float MAX_WALKING_SPEED = 2.5f; // human walking speed
|
||||
const float MAX_BOOST_SPEED = 0.5f * MAX_WALKING_SPEED; // keyboard motor gets additive boost below this speed
|
||||
|
@ -91,7 +91,9 @@ MyAvatar::MyAvatar() :
|
|||
_billboardValid(false),
|
||||
_physicsSimulation(),
|
||||
_feetTouchFloor(true),
|
||||
_isLookingAtLeftEye(true)
|
||||
_isLookingAtLeftEye(true),
|
||||
_realWorldFieldOfView("realWorldFieldOfView",
|
||||
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES)
|
||||
{
|
||||
ShapeCollider::initDispatchTable();
|
||||
for (int i = 0; i < MAX_DRIVE_KEYS; i++) {
|
||||
|
@ -340,8 +342,8 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
|||
head->setDeltaPitch(estimatedRotation.x);
|
||||
head->setDeltaYaw(estimatedRotation.y);
|
||||
} else {
|
||||
float magnifyFieldOfView = qApp->getViewFrustum()->getFieldOfView() /
|
||||
qApp->getViewFrustum()->getRealWorldFieldOfView();
|
||||
float magnifyFieldOfView = qApp->getFieldOfView() /
|
||||
_realWorldFieldOfView.get();
|
||||
head->setDeltaPitch(estimatedRotation.x * magnifyFieldOfView);
|
||||
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,8 @@
|
|||
#ifndef hifi_MyAvatar_h
|
||||
#define hifi_MyAvatar_h
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <PhysicsSimulation.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
|
||||
|
@ -47,12 +46,14 @@ public:
|
|||
void setLeanScale(float scale) { _leanScale = scale; }
|
||||
void setLocalGravity(glm::vec3 gravity);
|
||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; }
|
||||
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
||||
|
||||
// getters
|
||||
float getLeanScale() const { return _leanScale; }
|
||||
glm::vec3 getGravity() const { return _gravity; }
|
||||
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
||||
|
||||
const QList<AnimationHandlePointer>& getAnimationHandles() const { return _animationHandles; }
|
||||
AnimationHandlePointer addAnimationHandle();
|
||||
|
@ -225,6 +226,8 @@ private:
|
|||
|
||||
glm::vec3 _trackedHeadPosition;
|
||||
|
||||
Setting::Handle<float> _realWorldFieldOfView;
|
||||
|
||||
// private methods
|
||||
void updateOrientation(float deltaTime);
|
||||
glm::vec3 applyKeyboardMotor(float deltaTime, const glm::vec3& velocity, bool walkingOnFloor);
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PerfStat.h>
|
||||
#include <Settings.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "Faceshift.h"
|
||||
|
@ -29,11 +28,6 @@ using namespace std;
|
|||
const quint16 FACESHIFT_PORT = 33433;
|
||||
float STARTING_FACESHIFT_FRAME_TIME = 0.033f;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<float> faceshiftEyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION);
|
||||
const SettingHandle<QString> faceshiftHostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME);
|
||||
}
|
||||
|
||||
Faceshift::Faceshift() :
|
||||
_tcpEnabled(true),
|
||||
_tcpRetryCount(0),
|
||||
|
@ -61,7 +55,9 @@ Faceshift::Faceshift() :
|
|||
_jawOpenIndex(21),
|
||||
_longTermAverageEyePitch(0.0f),
|
||||
_longTermAverageEyeYaw(0.0f),
|
||||
_longTermAverageInitialized(false)
|
||||
_longTermAverageInitialized(false),
|
||||
_eyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION),
|
||||
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME)
|
||||
{
|
||||
#ifdef HAVE_FACESHIFT
|
||||
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
|
||||
|
@ -73,9 +69,6 @@ Faceshift::Faceshift() :
|
|||
|
||||
_udpSocket.bind(FACESHIFT_PORT);
|
||||
#endif
|
||||
|
||||
_eyeDeflection = SettingHandles::faceshiftEyeDeflection.get();
|
||||
_hostname = SettingHandles::faceshiftHostname.get();
|
||||
}
|
||||
|
||||
void Faceshift::init() {
|
||||
|
@ -169,7 +162,7 @@ void Faceshift::connectSocket() {
|
|||
qDebug("Faceshift: Connecting...");
|
||||
}
|
||||
|
||||
_tcpSocket.connectToHost(_hostname, FACESHIFT_PORT);
|
||||
_tcpSocket.connectToHost(_hostname.get(), FACESHIFT_PORT);
|
||||
_tracking = false;
|
||||
}
|
||||
}
|
||||
|
@ -321,11 +314,9 @@ void Faceshift::receive(const QByteArray& buffer) {
|
|||
}
|
||||
|
||||
void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
|
||||
_eyeDeflection = faceshiftEyeDeflection;
|
||||
SettingHandles::faceshiftEyeDeflection.set(_eyeDeflection);
|
||||
_eyeDeflection.set(faceshiftEyeDeflection);
|
||||
}
|
||||
|
||||
void Faceshift::setHostname(const QString& hostname) {
|
||||
_hostname = hostname;
|
||||
SettingHandles::faceshiftHostname.set(_hostname);
|
||||
_hostname.set(hostname);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#endif
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "FaceTracker.h"
|
||||
|
||||
|
@ -62,10 +63,10 @@ public:
|
|||
float getMouthSmileLeft() const { return getBlendshapeCoefficient(_mouthSmileLeftIndex); }
|
||||
float getMouthSmileRight() const { return getBlendshapeCoefficient(_mouthSmileRightIndex); }
|
||||
|
||||
float getEyeDeflection() const { return _eyeDeflection; }
|
||||
float getEyeDeflection() { return _eyeDeflection.get(); }
|
||||
void setEyeDeflection(float faceshiftEyeDeflection);
|
||||
|
||||
const QString& getHostname() const { return _hostname; }
|
||||
QString getHostname() { return _hostname.get(); }
|
||||
void setHostname(const QString& hostname);
|
||||
|
||||
void update();
|
||||
|
@ -151,8 +152,8 @@ private:
|
|||
float _longTermAverageEyeYaw;
|
||||
bool _longTermAverageInitialized;
|
||||
|
||||
float _eyeDeflection = DEFAULT_FACESHIFT_EYE_DEFLECTION;
|
||||
QString _hostname = DEFAULT_FACESHIFT_HOSTNAME;
|
||||
Setting::Handle<float> _eyeDeflection;
|
||||
Setting::Handle<QString> _hostname;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -68,11 +68,12 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode,
|
|||
<< senderUUID << "sent" << (int)packetVersion << "but"
|
||||
<< (int)expectedVersion << "expected.";
|
||||
|
||||
emit packetVersionMismatch();
|
||||
|
||||
versionDebugSuppressMap.insert(senderUUID, voxelPacketType);
|
||||
}
|
||||
return; // bail since piggyback version doesn't match
|
||||
}
|
||||
|
||||
|
||||
app->trackIncomingOctreePacket(mutablePacket, sendingNode, wasStatsPacket);
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
/// the user is responsible for reading inbound packets and adding them to the processing queue by calling queueReceivedPacket()
|
||||
class OctreePacketProcessor : public ReceivedPacketProcessor {
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void packetVersionMismatch();
|
||||
|
||||
protected:
|
||||
virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet);
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "SettingsScriptingInterface.h"
|
||||
|
||||
|
@ -20,7 +20,7 @@ SettingsScriptingInterface* SettingsScriptingInterface::getInstance() {
|
|||
}
|
||||
|
||||
QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
||||
QVariant value = SettingHandles::SettingHandle<QVariant>(setting).get();
|
||||
QVariant value = Setting::Handle<QVariant>(setting).get();
|
||||
if (!value.isValid()) {
|
||||
value = "";
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting) {
|
|||
}
|
||||
|
||||
QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVariant& defaultValue) {
|
||||
QVariant value = SettingHandles::SettingHandle<QVariant>(setting, defaultValue).get();
|
||||
QVariant value = Setting::Handle<QVariant>(setting, defaultValue).get();
|
||||
if (!value.isValid()) {
|
||||
value = "";
|
||||
}
|
||||
|
@ -36,5 +36,5 @@ QVariant SettingsScriptingInterface::getValue(const QString& setting, const QVar
|
|||
}
|
||||
|
||||
void SettingsScriptingInterface::setValue(const QString& setting, const QVariant& value) {
|
||||
SettingHandles::SettingHandle<QVariant>(setting).set(value);
|
||||
Setting::Handle<QVariant>(setting).set(value);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,11 @@ QScriptValue WindowScriptingInterface::hasFocus() {
|
|||
return DependencyManager::get<GLCanvas>()->hasFocus();
|
||||
}
|
||||
|
||||
void WindowScriptingInterface::setFocus() {
|
||||
Application::getInstance()->getWindow()->activateWindow();
|
||||
Application::getInstance()->getWindow()->setFocus();
|
||||
}
|
||||
|
||||
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
||||
Application::getInstance()->setCursorVisible(visible);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public slots:
|
|||
void setCursorPosition(int x, int y);
|
||||
void setCursorVisible(bool visible);
|
||||
QScriptValue hasFocus();
|
||||
void setFocus();
|
||||
QScriptValue alert(const QString& message = "");
|
||||
QScriptValue confirm(const QString& message = "");
|
||||
QScriptValue form(const QString& title, QScriptValue array);
|
||||
|
|
|
@ -21,16 +21,8 @@
|
|||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <avatar/AvatarManager.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <Settings.h>
|
||||
|
||||
#include "AnimationsDialog.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> animationDirectory("animation_directory", QString());
|
||||
}
|
||||
|
||||
AnimationsDialog::AnimationsDialog(QWidget* parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
|
@ -80,6 +72,8 @@ void AnimationsDialog::addAnimation() {
|
|||
DependencyManager::get<AvatarManager>()->getMyAvatar()->addAnimationHandle()));
|
||||
}
|
||||
|
||||
Setting::Handle<QString> AnimationPanel::_animationDirectory("animation_directory", QString());
|
||||
|
||||
AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePointer& handle) :
|
||||
_dialog(dialog),
|
||||
_handle(handle),
|
||||
|
@ -165,12 +159,12 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
|
|||
}
|
||||
|
||||
void AnimationPanel::chooseURL() {
|
||||
QString directory = SettingHandles::animationDirectory.get();
|
||||
QString filename = QFileDialog::getOpenFileName(this, "Choose Animation", directory, "Animation files (*.fbx)");
|
||||
QString filename = QFileDialog::getOpenFileName(this, "Choose Animation",
|
||||
_animationDirectory.get(), "Animation files (*.fbx)");
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::animationDirectory.set(QFileInfo(filename).path());
|
||||
_animationDirectory.set(QFileInfo(filename).path());
|
||||
_url->setText(QUrl::fromLocalFile(filename).toString());
|
||||
emit _url->returnPressed();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <QDoubleSpinBox>
|
||||
#include <QFrame>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "avatar/MyAvatar.h"
|
||||
|
||||
class QCheckBox;
|
||||
|
@ -41,8 +43,8 @@ private slots:
|
|||
|
||||
private:
|
||||
|
||||
QVBoxLayout* _animations;
|
||||
QPushButton* _ok;
|
||||
QVBoxLayout* _animations = nullptr;
|
||||
QPushButton* _ok = nullptr;
|
||||
};
|
||||
|
||||
/// A panel controlling a single animation.
|
||||
|
@ -62,22 +64,24 @@ private slots:
|
|||
|
||||
private:
|
||||
|
||||
AnimationsDialog* _dialog;
|
||||
AnimationsDialog* _dialog = nullptr;
|
||||
AnimationHandlePointer _handle;
|
||||
QComboBox* _role;
|
||||
QLineEdit* _url;
|
||||
QDoubleSpinBox* _fps;
|
||||
QDoubleSpinBox* _priority;
|
||||
QCheckBox* _loop;
|
||||
QCheckBox* _hold;
|
||||
QCheckBox* _startAutomatically;
|
||||
QDoubleSpinBox* _firstFrame;
|
||||
QDoubleSpinBox* _lastFrame;
|
||||
QLineEdit* _maskedJoints;
|
||||
QPushButton* _chooseMaskedJoints;
|
||||
QPushButton* _start;
|
||||
QPushButton* _stop;
|
||||
QComboBox* _role = nullptr;
|
||||
QLineEdit* _url = nullptr;
|
||||
QDoubleSpinBox* _fps = nullptr;
|
||||
QDoubleSpinBox* _priority = nullptr;
|
||||
QCheckBox* _loop = nullptr;
|
||||
QCheckBox* _hold = nullptr;
|
||||
QCheckBox* _startAutomatically = nullptr;
|
||||
QDoubleSpinBox* _firstFrame = nullptr;
|
||||
QDoubleSpinBox* _lastFrame = nullptr;
|
||||
QLineEdit* _maskedJoints = nullptr;
|
||||
QPushButton* _chooseMaskedJoints = nullptr;
|
||||
QPushButton* _start = nullptr;
|
||||
QPushButton* _stop = nullptr;
|
||||
bool _applying;
|
||||
|
||||
static Setting::Handle<QString> _animationDirectory;
|
||||
};
|
||||
|
||||
#endif // hifi_AnimationsDialog_h
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <AddressManager.h>
|
||||
#include <AccountManager.h>
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ChatMessageArea.h"
|
||||
|
@ -42,10 +41,6 @@ const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
|||
const QString mentionSoundsPath("/mention-sounds/");
|
||||
const QString mentionRegex("@(\\b%1\\b)");
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QDateTime> usernameMentionTimestamp("MentionTimestamp", QDateTime());
|
||||
}
|
||||
|
||||
ChatWindow::ChatWindow(QWidget* parent) :
|
||||
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||
Qt::WindowCloseButtonHint),
|
||||
|
@ -54,7 +49,8 @@ ChatWindow::ChatWindow(QWidget* parent) :
|
|||
_mousePressed(false),
|
||||
_mouseStartPosition(),
|
||||
_trayIcon(parent),
|
||||
_effectPlayer()
|
||||
_effectPlayer(),
|
||||
_usernameMentionTimestamp("MentionTimestamp", QDateTime())
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
||||
|
@ -382,9 +378,9 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
|
|||
if (message.body().contains(usernameMention)) {
|
||||
|
||||
// Don't show messages already seen in icon tray at start-up.
|
||||
bool showMessage = SettingHandles::usernameMentionTimestamp.get() < _lastMessageStamp;
|
||||
bool showMessage = _usernameMentionTimestamp.get() < _lastMessageStamp;
|
||||
if (showMessage) {
|
||||
SettingHandles::usernameMentionTimestamp.set(_lastMessageStamp);
|
||||
_usernameMentionTimestamp.set(_lastMessageStamp);
|
||||
}
|
||||
|
||||
if (isHidden() && showMessage) {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <Application.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "FramelessDialog.h"
|
||||
|
||||
#ifdef HAVE_QXMPP
|
||||
|
@ -69,6 +71,8 @@ private:
|
|||
QSystemTrayIcon _trayIcon;
|
||||
QStringList _mentionSounds;
|
||||
QMediaPlayer _effectPlayer;
|
||||
|
||||
Setting::Handle<QDateTime> _usernameMentionTimestamp;
|
||||
|
||||
private slots:
|
||||
void connected();
|
||||
|
|
|
@ -16,15 +16,13 @@
|
|||
#include <QtWebKit/QWebElement>
|
||||
|
||||
#include <PathUtils.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "InfoView.h"
|
||||
|
||||
static const float MAX_DIALOG_HEIGHT_RATIO = 0.9f;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> infoVersion("info-version", QString());
|
||||
}
|
||||
Setting::Handle<QString> infoVersion("info-version", QString());
|
||||
|
||||
InfoView::InfoView(bool forced, QString path) :
|
||||
_forced(forced)
|
||||
|
@ -52,13 +50,13 @@ bool InfoView::shouldShow() {
|
|||
return true;
|
||||
}
|
||||
|
||||
QString lastVersion = SettingHandles::infoVersion.get();
|
||||
QString lastVersion = infoVersion.get();
|
||||
|
||||
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
|
||||
QString version = versionTag.attribute("value");
|
||||
|
||||
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
|
||||
SettingHandles::infoVersion.set(version);
|
||||
infoVersion.set(version);
|
||||
shouldShow = true;
|
||||
} else {
|
||||
shouldShow = false;
|
||||
|
|
|
@ -85,6 +85,7 @@ ModelsBrowser::ModelsBrowser(ModelType modelsType, QWidget* parent) :
|
|||
|
||||
// Setup and launch update thread
|
||||
QThread* thread = new QThread();
|
||||
thread->setObjectName("Models Browser");
|
||||
thread->connect(_handler, SIGNAL(destroyed()), SLOT(quit()));
|
||||
thread->connect(thread, SIGNAL(finished()), SLOT(deleteLater()));
|
||||
_handler->moveToThread(thread);
|
||||
|
|
|
@ -122,7 +122,7 @@ void PreferencesDialog::loadPreferences() {
|
|||
|
||||
ui.sendDataCheckBox->setChecked(!menuInstance->isOptionChecked(MenuOption::DisableActivityLogger));
|
||||
|
||||
ui.snapshotLocationEdit->setText(SettingHandles::snapshotsLocation.get());
|
||||
ui.snapshotLocationEdit->setText(Snapshot::snapshotsLocation.get());
|
||||
|
||||
ui.scriptsLocationEdit->setText(qApp->getScriptsLocation());
|
||||
|
||||
|
@ -154,9 +154,9 @@ void PreferencesDialog::loadPreferences() {
|
|||
ui.outputStarveDetectionThresholdSpinner->setValue(audio->getOutputStarveDetectionThreshold());
|
||||
ui.outputStarveDetectionPeriodSpinner->setValue(audio->getOutputStarveDetectionPeriod());
|
||||
|
||||
ui.realWorldFieldOfViewSpin->setValue(qApp->getViewFrustum()->getRealWorldFieldOfView());
|
||||
ui.realWorldFieldOfViewSpin->setValue(qApp->getAvatar()->getRealWorldFieldOfView());
|
||||
|
||||
ui.fieldOfViewSpin->setValue(qApp->getViewFrustum()->getFieldOfView());
|
||||
ui.fieldOfViewSpin->setValue(qApp->getFieldOfView());
|
||||
|
||||
ui.leanScaleSpin->setValue(myAvatar->getLeanScale());
|
||||
|
||||
|
@ -220,7 +220,7 @@ void PreferencesDialog::savePreferences() {
|
|||
}
|
||||
|
||||
if (!ui.snapshotLocationEdit->text().isEmpty() && QDir(ui.snapshotLocationEdit->text()).exists()) {
|
||||
SettingHandles::snapshotsLocation.set(ui.snapshotLocationEdit->text());
|
||||
Snapshot::snapshotsLocation.set(ui.snapshotLocationEdit->text());
|
||||
}
|
||||
|
||||
if (!ui.scriptsLocationEdit->text().isEmpty() && QDir(ui.scriptsLocationEdit->text()).exists()) {
|
||||
|
@ -234,9 +234,9 @@ void PreferencesDialog::savePreferences() {
|
|||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||
|
||||
qApp->getViewFrustum()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||
qApp->getAvatar()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||
|
||||
qApp->getViewFrustum()->setFieldOfView(ui.fieldOfViewSpin->value());
|
||||
qApp->setFieldOfView(ui.fieldOfViewSpin->value());
|
||||
|
||||
auto faceshift = DependencyManager::get<Faceshift>();
|
||||
faceshift->setEyeDeflection(ui.faceshiftEyeDeflectionSider->value() /
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
const int ICON_SIZE = 24;
|
||||
const int ICON_PADDING = 5;
|
||||
|
||||
const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
|
||||
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
||||
Setting::Handle<int> RearMirrorTools::rearViewZoomLevel(QStringList() << SETTINGS_GROUP_NAME << ZOOM_LEVEL_SETTINGS,
|
||||
ZoomLevel::HEAD);
|
||||
|
||||
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) :
|
||||
_parent(parent),
|
||||
_bounds(bounds),
|
||||
|
@ -52,7 +57,7 @@ void RearMirrorTools::render(bool fullScreen) {
|
|||
if (_windowed) {
|
||||
displayIcon(_bounds, _closeIconRect, _closeTextureId);
|
||||
|
||||
ZoomLevel zoomLevel = (ZoomLevel)SettingHandles::rearViewZoomLevel.get();
|
||||
ZoomLevel zoomLevel = (ZoomLevel)rearViewZoomLevel.get();
|
||||
displayIcon(_bounds, _headZoomIconRect, _zoomHeadTextureId, zoomLevel == HEAD);
|
||||
displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, zoomLevel == BODY);
|
||||
}
|
||||
|
@ -68,12 +73,12 @@ bool RearMirrorTools::mousePressEvent(int x, int y) {
|
|||
}
|
||||
|
||||
if (_headZoomIconRect.contains(x, y)) {
|
||||
SettingHandles::rearViewZoomLevel.set(HEAD);
|
||||
rearViewZoomLevel.set(HEAD);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_bodyZoomIconRect.contains(x, y)) {
|
||||
SettingHandles::rearViewZoomLevel.set(BODY);
|
||||
rearViewZoomLevel.set(BODY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,26 +16,21 @@
|
|||
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
enum ZoomLevel {
|
||||
HEAD = 0,
|
||||
BODY = 1
|
||||
};
|
||||
|
||||
namespace SettingHandles {
|
||||
const char SETTINGS_GROUP_NAME[] = "Rear View Tools";
|
||||
const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
||||
const SettingHandle<int> rearViewZoomLevel(QStringList() << SETTINGS_GROUP_NAME << ZOOM_LEVEL_SETTINGS,
|
||||
ZoomLevel::HEAD);
|
||||
}
|
||||
|
||||
class RearMirrorTools : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RearMirrorTools(QGLWidget* parent, QRect& bounds);
|
||||
void render(bool fullScreen);
|
||||
bool mousePressEvent(int x, int y);
|
||||
|
||||
static Setting::Handle<int> rearViewZoomLevel;
|
||||
|
||||
signals:
|
||||
void closeView();
|
||||
|
|
|
@ -43,6 +43,9 @@ const QString ORIENTATION_W = "orientation-w";
|
|||
|
||||
const QString DOMAIN_KEY = "domain";
|
||||
|
||||
Setting::Handle<QString> Snapshot::snapshotsLocation("snapshotsLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||
|
||||
SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) {
|
||||
|
||||
if (!QFile(snapshotPath).exists()) {
|
||||
|
@ -125,7 +128,7 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
|||
const int IMAGE_QUALITY = 100;
|
||||
|
||||
if (!isTemporary) {
|
||||
QString snapshotFullPath = SettingHandles::snapshotsLocation.get();
|
||||
QString snapshotFullPath = snapshotsLocation.get();
|
||||
|
||||
if (!snapshotFullPath.endsWith(QDir::separator())) {
|
||||
snapshotFullPath.append(QDir::separator());
|
||||
|
|
|
@ -17,16 +17,11 @@
|
|||
#include <QString>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
class QFile;
|
||||
class QTemporaryFile;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> snapshotsLocation("snapshotsLocation",
|
||||
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||
}
|
||||
|
||||
class SnapshotMetaData {
|
||||
public:
|
||||
|
||||
|
@ -51,6 +46,7 @@ public:
|
|||
static QTemporaryFile* saveTempSnapshot();
|
||||
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
||||
|
||||
static Setting::Handle<QString> snapshotsLocation;
|
||||
private:
|
||||
static QFile* savedFileForSnapshot(bool isTemporary);
|
||||
};
|
||||
|
|
|
@ -316,6 +316,11 @@ void Stats::display(
|
|||
verticalOffset = 0;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + 1;
|
||||
|
||||
if (columnOneWidth == _generalStatsWidth) {
|
||||
drawBackground(backgroundColor, horizontalOffset, 0, _bandwidthStatsWidth, lines * STATS_PELS_PER_LINE + 10);
|
||||
}
|
||||
horizontalOffset += 5;
|
||||
|
||||
char packetsPerSecondString[30];
|
||||
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
|
||||
char averageMegabitsPerSecond[30];
|
||||
|
|
|
@ -70,16 +70,16 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
// for our overlay, is solid means we draw a solid "filled" rectangle otherwise we just draw a border line...
|
||||
if (getIsSolid()) {
|
||||
glm::vec3 topLeft(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glm::vec3 bottomRight(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
glm::vec3 topLeft(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
glm::vec3 bottomRight(halfDimensions.x, halfDimensions.y, 0.0f);
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, rectangleColor);
|
||||
} else {
|
||||
if (getIsDashedLine()) {
|
||||
|
||||
glm::vec3 point1(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glm::vec3 point2(halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
glm::vec3 point3(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
glm::vec3 point4(-halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
glm::vec3 point1(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
glm::vec3 point2(halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
glm::vec3 point3(halfDimensions.x, halfDimensions.y, 0.0f);
|
||||
glm::vec3 point4(-halfDimensions.x, halfDimensions.y, 0.0f);
|
||||
|
||||
geometryCache->renderDashedLine(point1, point2, rectangleColor);
|
||||
geometryCache->renderDashedLine(point2, point3, rectangleColor);
|
||||
|
@ -90,11 +90,11 @@ void Rectangle3DOverlay::render(RenderArgs* args) {
|
|||
|
||||
if (halfDimensions != _previousHalfDimensions) {
|
||||
QVector<glm::vec3> border;
|
||||
border << glm::vec3(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
border << glm::vec3(halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
border << glm::vec3(halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
border << glm::vec3(-halfDimensions.x, 0.0f, halfDimensions.y);
|
||||
border << glm::vec3(-halfDimensions.x, 0.0f, -halfDimensions.y);
|
||||
border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
border << glm::vec3(halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
border << glm::vec3(halfDimensions.x, halfDimensions.y, 0.0f);
|
||||
border << glm::vec3(-halfDimensions.x, halfDimensions.y, 0.0f);
|
||||
border << glm::vec3(-halfDimensions.x, -halfDimensions.y, 0.0f);
|
||||
geometryCache->updateVertices(_geometryCacheID, border, rectangleColor);
|
||||
|
||||
_previousHalfDimensions = halfDimensions;
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <PositionalAudioStream.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
|
||||
|
@ -49,16 +50,17 @@
|
|||
|
||||
static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> audioOutputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED);
|
||||
const SettingHandle<int> audioOutputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD);
|
||||
const SettingHandle<int> audioOutputStarveDetectionPeriod("audioOutputStarveDetectionPeriod",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD);
|
||||
const SettingHandle<int> audioOutputBufferSize("audioOutputBufferSize",
|
||||
DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
}
|
||||
Setting::Handle<bool> dynamicJitterBuffers("dynamicJitterBuffers", DEFAULT_DYNAMIC_JITTER_BUFFERS);
|
||||
Setting::Handle<int> maxFramesOverDesired("maxFramesOverDesired", DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
Setting::Handle<int> staticDesiredJitterBufferFrames("staticDesiredJitterBufferFrames",
|
||||
DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES);
|
||||
Setting::Handle<bool> useStDevForJitterCalc("useStDevForJitterCalc", DEFAULT_USE_STDEV_FOR_JITTER_CALC);
|
||||
Setting::Handle<int> windowStarveThreshold("windowStarveThreshold", DEFAULT_WINDOW_STARVE_THRESHOLD);
|
||||
Setting::Handle<int> windowSecondsForDesiredCalcOnTooManyStarves("windowSecondsForDesiredCalcOnTooManyStarves",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES);
|
||||
Setting::Handle<int> windowSecondsForDesiredReduction("windowSecondsForDesiredReduction",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION);
|
||||
Setting::Handle<bool> repetitionWithFade("repetitionWithFade", DEFAULT_REPETITION_WITH_FADE);
|
||||
|
||||
AudioClient::AudioClient() :
|
||||
AbstractAudioInterface(),
|
||||
|
@ -76,16 +78,22 @@ AudioClient::AudioClient() :
|
|||
_inputRingBuffer(0),
|
||||
_receivedAudioStream(0, RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES, InboundAudioStream::Settings()),
|
||||
_isStereoInput(false),
|
||||
_outputBufferSizeFrames(DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES),
|
||||
#ifdef Q_OS_ANDROID
|
||||
_outputStarveDetectionEnabled(false),
|
||||
#else
|
||||
_outputStarveDetectionEnabled(true),
|
||||
#endif
|
||||
_outputStarveDetectionStartTimeMsec(0),
|
||||
_outputStarveDetectionCount(0),
|
||||
_outputStarveDetectionPeriodMsec(DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
||||
_outputStarveDetectionThreshold(DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD),
|
||||
_outputBufferSizeFrames("audioOutputBufferSize",
|
||||
DEFAULT_MAX_FRAMES_OVER_DESIRED),
|
||||
#ifdef Q_OS_ANDROID
|
||||
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||
false),
|
||||
#else
|
||||
_outputStarveDetectionEnabled("audioOutputStarveDetectionEnabled",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_ENABLED),
|
||||
#endif
|
||||
|
||||
_outputStarveDetectionPeriodMsec("audioOutputStarveDetectionPeriod",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_PERIOD),
|
||||
_outputStarveDetectionThreshold("audioOutputStarveDetectionThreshold",
|
||||
DEFAULT_AUDIO_OUTPUT_STARVE_DETECTION_THRESHOLD),
|
||||
_averagedLatency(0.0f),
|
||||
_lastInputLoudness(0.0f),
|
||||
_timeSinceLastClip(-1.0f),
|
||||
|
@ -1056,16 +1064,16 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn
|
|||
void AudioClient::outputNotify() {
|
||||
int recentUnfulfilled = _audioOutputIODevice.getRecentUnfulfilledReads();
|
||||
if (recentUnfulfilled > 0) {
|
||||
if (_outputStarveDetectionEnabled) {
|
||||
if (_outputStarveDetectionEnabled.get()) {
|
||||
quint64 now = usecTimestampNow() / 1000;
|
||||
quint64 dt = now - _outputStarveDetectionStartTimeMsec;
|
||||
if (dt > _outputStarveDetectionPeriodMsec) {
|
||||
if (dt > _outputStarveDetectionPeriodMsec.get()) {
|
||||
_outputStarveDetectionStartTimeMsec = now;
|
||||
_outputStarveDetectionCount = 0;
|
||||
} else {
|
||||
_outputStarveDetectionCount += recentUnfulfilled;
|
||||
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold) {
|
||||
int newOutputBufferSizeFrames = _outputBufferSizeFrames + 1;
|
||||
if (_outputStarveDetectionCount > _outputStarveDetectionThreshold.get()) {
|
||||
int newOutputBufferSizeFrames = _outputBufferSizeFrames.get() + 1;
|
||||
qDebug() << "Starve detection threshold met, increasing buffer size to " << newOutputBufferSizeFrames;
|
||||
setOutputBufferSize(newOutputBufferSizeFrames);
|
||||
|
||||
|
@ -1129,7 +1137,7 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice
|
|||
|
||||
// setup our general output device for audio-mixer audio
|
||||
_audioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
_audioOutput->setBufferSize(_outputBufferSizeFrames * _outputFrameSize * sizeof(int16_t));
|
||||
_audioOutput->setBufferSize(_outputBufferSizeFrames.get() * _outputFrameSize * sizeof(int16_t));
|
||||
|
||||
connect(_audioOutput, &QAudioOutput::notify, this, &AudioClient::outputNotify);
|
||||
|
||||
|
@ -1153,9 +1161,9 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice
|
|||
|
||||
void AudioClient::setOutputBufferSize(int numFrames) {
|
||||
numFrames = std::min(std::max(numFrames, MIN_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES), MAX_AUDIO_OUTPUT_BUFFER_SIZE_FRAMES);
|
||||
if (numFrames != _outputBufferSizeFrames) {
|
||||
if (numFrames != _outputBufferSizeFrames.get()) {
|
||||
qDebug() << "Audio output buffer size (frames): " << numFrames;
|
||||
_outputBufferSizeFrames = numFrames;
|
||||
_outputBufferSizeFrames.set(numFrames);
|
||||
|
||||
if (_audioOutput) {
|
||||
// The buffer size can't be adjusted after QAudioOutput::start() has been called, so
|
||||
|
@ -1254,26 +1262,24 @@ void AudioClient::checkDevices() {
|
|||
}
|
||||
|
||||
void AudioClient::loadSettings() {
|
||||
_receivedAudioStream.loadSettings();
|
||||
|
||||
setOutputStarveDetectionEnabled(SettingHandles::audioOutputStarveDetectionEnabled.get());
|
||||
setOutputStarveDetectionThreshold(SettingHandles::audioOutputStarveDetectionThreshold.get());
|
||||
setOutputStarveDetectionPeriod(SettingHandles::audioOutputStarveDetectionPeriod.get());
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setOutputBufferSize",
|
||||
Q_ARG(int, SettingHandles::audioOutputBufferSize.get()));
|
||||
} else {
|
||||
setOutputBufferSize(SettingHandles::audioOutputBufferSize.get());
|
||||
}
|
||||
_receivedAudioStream.setDynamicJitterBuffers(dynamicJitterBuffers.get());
|
||||
_receivedAudioStream.setMaxFramesOverDesired(maxFramesOverDesired.get());
|
||||
_receivedAudioStream.setStaticDesiredJitterBufferFrames(staticDesiredJitterBufferFrames.get());
|
||||
_receivedAudioStream.setUseStDevForJitterCalc(useStDevForJitterCalc.get());
|
||||
_receivedAudioStream.setWindowStarveThreshold(windowStarveThreshold.get());
|
||||
_receivedAudioStream.setWindowSecondsForDesiredCalcOnTooManyStarves(
|
||||
windowSecondsForDesiredCalcOnTooManyStarves.get());
|
||||
_receivedAudioStream.setWindowSecondsForDesiredReduction(windowSecondsForDesiredReduction.get());
|
||||
_receivedAudioStream.setRepetitionWithFade(repetitionWithFade.get());
|
||||
}
|
||||
|
||||
void AudioClient::saveSettings() {
|
||||
_receivedAudioStream.saveSettings();
|
||||
|
||||
SettingHandles::audioOutputStarveDetectionEnabled.set(getOutputStarveDetectionEnabled());
|
||||
SettingHandles::audioOutputStarveDetectionThreshold.set(getOutputStarveDetectionThreshold());
|
||||
SettingHandles::audioOutputStarveDetectionPeriod.set(getOutputStarveDetectionPeriod());
|
||||
SettingHandles::audioOutputBufferSize.set(getOutputBufferSize());
|
||||
dynamicJitterBuffers.set(_receivedAudioStream.getDynamicJitterBuffers());
|
||||
maxFramesOverDesired.set(_receivedAudioStream.getMaxFramesOverDesired());
|
||||
staticDesiredJitterBufferFrames.set(_receivedAudioStream.getDesiredJitterBufferFrames());
|
||||
windowStarveThreshold.set(_receivedAudioStream.getWindowStarveThreshold());
|
||||
windowSecondsForDesiredCalcOnTooManyStarves.set(_receivedAudioStream.
|
||||
getWindowSecondsForDesiredCalcOnTooManyStarves());
|
||||
windowSecondsForDesiredReduction.set(_receivedAudioStream.getWindowSecondsForDesiredReduction());
|
||||
repetitionWithFade.set(_receivedAudioStream.getRepetitionWithFade());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,10 @@
|
|||
#include <AudioSourceNoise.h>
|
||||
#include <AudioStreamStats.h>
|
||||
#include <DependencyManager.h>
|
||||
|
||||
#include <MixedProcessedAudioStream.h>
|
||||
#include <RingBufferHistory.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <StDev.h>
|
||||
|
||||
#include "AudioIOStats.h"
|
||||
|
@ -111,16 +113,13 @@ public:
|
|||
float getInputRingBufferMsecsAvailable() const;
|
||||
float getAudioOutputMsecsUnplayed() const;
|
||||
|
||||
int getOutputBufferSize() { return _outputBufferSizeFrames; }
|
||||
int getOutputBufferSize() { return _outputBufferSizeFrames.get(); }
|
||||
|
||||
bool getOutputStarveDetectionEnabled() { return _outputStarveDetectionEnabled; }
|
||||
void setOutputStarveDetectionEnabled(bool enabled) { _outputStarveDetectionEnabled = enabled; }
|
||||
|
||||
int getOutputStarveDetectionPeriod() { return _outputStarveDetectionPeriodMsec; }
|
||||
void setOutputStarveDetectionPeriod(quint64 msecs) { _outputStarveDetectionPeriodMsec = msecs; }
|
||||
|
||||
int getOutputStarveDetectionThreshold() { return _outputStarveDetectionThreshold; }
|
||||
void setOutputStarveDetectionThreshold(int threshold) { _outputStarveDetectionThreshold = threshold; }
|
||||
int getOutputStarveDetectionPeriod() { return _outputStarveDetectionPeriodMsec.get(); }
|
||||
void setOutputStarveDetectionPeriod(int msecs) { _outputStarveDetectionPeriodMsec.set(msecs); }
|
||||
|
||||
int getOutputStarveDetectionThreshold() { return _outputStarveDetectionThreshold.get(); }
|
||||
void setOutputStarveDetectionThreshold(int threshold) { _outputStarveDetectionThreshold.set(threshold); }
|
||||
|
||||
void setPositionGetter(AudioPositionGetter positionGetter) { _positionGetter = positionGetter; }
|
||||
void setOrientationGetter(AudioOrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
||||
|
@ -209,13 +208,15 @@ private:
|
|||
|
||||
QString _inputAudioDeviceName;
|
||||
QString _outputAudioDeviceName;
|
||||
|
||||
int _outputBufferSizeFrames;
|
||||
bool _outputStarveDetectionEnabled;
|
||||
|
||||
quint64 _outputStarveDetectionStartTimeMsec;
|
||||
int _outputStarveDetectionCount;
|
||||
quint64 _outputStarveDetectionPeriodMsec;
|
||||
int _outputStarveDetectionThreshold; // Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size
|
||||
|
||||
Setting::Handle<int> _outputBufferSizeFrames;
|
||||
Setting::Handle<bool> _outputStarveDetectionEnabled;
|
||||
Setting::Handle<int> _outputStarveDetectionPeriodMsec;
|
||||
// Maximum number of starves per _outputStarveDetectionPeriod before increasing buffer size
|
||||
Setting::Handle<int> _outputStarveDetectionThreshold;
|
||||
|
||||
StDev _stdev;
|
||||
QElapsedTimer _timeSinceLastReceived;
|
||||
|
|
|
@ -53,6 +53,7 @@ AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjec
|
|||
injector->setLocalAudioInterface(_localAudioInterface);
|
||||
|
||||
QThread* injectorThread = new QThread();
|
||||
injectorThread->setObjectName("Audio Injector Thread");
|
||||
|
||||
injector->moveToThread(injectorThread);
|
||||
|
||||
|
|
|
@ -11,27 +11,11 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
const int STARVE_HISTORY_CAPACITY = 50;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<bool> dynamicJitterBuffers("dynamicJitterBuffers", DEFAULT_DYNAMIC_JITTER_BUFFERS);
|
||||
const SettingHandle<int> maxFramesOverDesired("maxFramesOverDesired", DEFAULT_MAX_FRAMES_OVER_DESIRED);
|
||||
const SettingHandle<int> staticDesiredJitterBufferFrames("staticDesiredJitterBufferFrames",
|
||||
DEFAULT_STATIC_DESIRED_JITTER_BUFFER_FRAMES);
|
||||
const SettingHandle<bool> useStDevForJitterCalc("useStDevForJitterCalc", DEFAULT_USE_STDEV_FOR_JITTER_CALC);
|
||||
const SettingHandle<int> windowStarveThreshold("windowStarveThreshold", DEFAULT_WINDOW_STARVE_THRESHOLD);
|
||||
const SettingHandle<int> windowSecondsForDesiredCalcOnTooManyStarves("windowSecondsForDesiredCalcOnTooManyStarves",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_CALC_ON_TOO_MANY_STARVES);
|
||||
const SettingHandle<int> windowSecondsForDesiredReduction("windowSecondsForDesiredReduction",
|
||||
DEFAULT_WINDOW_SECONDS_FOR_DESIRED_REDUCTION);
|
||||
const SettingHandle<bool> repetitionWithFade("repetitionWithFade", DEFAULT_REPETITION_WITH_FADE);
|
||||
}
|
||||
|
||||
InboundAudioStream::InboundAudioStream(int numFrameSamples, int numFramesCapacity, const Settings& settings) :
|
||||
_ringBuffer(numFrameSamples, false, numFramesCapacity),
|
||||
_lastPopSucceeded(false),
|
||||
|
@ -517,27 +501,3 @@ float calculateRepeatedFrameFadeFactor(int indexOfRepeat) {
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
void InboundAudioStream::loadSettings() {
|
||||
setDynamicJitterBuffers(SettingHandles::dynamicJitterBuffers.get());
|
||||
setMaxFramesOverDesired(SettingHandles::maxFramesOverDesired.get());
|
||||
setStaticDesiredJitterBufferFrames(SettingHandles::staticDesiredJitterBufferFrames.get());
|
||||
setUseStDevForJitterCalc(SettingHandles::useStDevForJitterCalc.get());
|
||||
setWindowStarveThreshold(SettingHandles::windowStarveThreshold.get());
|
||||
setWindowSecondsForDesiredCalcOnTooManyStarves(SettingHandles::windowSecondsForDesiredCalcOnTooManyStarves.get());
|
||||
setWindowSecondsForDesiredReduction(SettingHandles::windowSecondsForDesiredReduction.get());
|
||||
setRepetitionWithFade(SettingHandles::repetitionWithFade.get());
|
||||
}
|
||||
|
||||
void InboundAudioStream::saveSettings() {
|
||||
SettingHandles::dynamicJitterBuffers.set(getDynamicJitterBuffers());
|
||||
SettingHandles::maxFramesOverDesired.set(getMaxFramesOverDesired());
|
||||
SettingHandles::staticDesiredJitterBufferFrames.set(getDesiredJitterBufferFrames());
|
||||
SettingHandles::useStDevForJitterCalc.set(getUseStDevForJitterCalc());
|
||||
SettingHandles::windowStarveThreshold.set(getWindowStarveThreshold());
|
||||
SettingHandles::windowSecondsForDesiredCalcOnTooManyStarves.set(getWindowSecondsForDesiredCalcOnTooManyStarves());
|
||||
SettingHandles::windowSecondsForDesiredReduction.set(getWindowSecondsForDesiredReduction());
|
||||
SettingHandles::repetitionWithFade.set(getRepetitionWithFade());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -126,9 +126,6 @@ public:
|
|||
void setWindowSecondsForDesiredReduction(int windowSecondsForDesiredReduction);
|
||||
void setRepetitionWithFade(bool repetitionWithFade) { _repetitionWithFade = repetitionWithFade; }
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
virtual AudioStreamStats getAudioStreamStats() const;
|
||||
|
||||
/// returns the desired number of jitter buffer frames under the dyanmic jitter buffers scheme
|
||||
|
|
|
@ -166,6 +166,7 @@ void Player::pausePlayer() {
|
|||
|
||||
void Player::setupAudioThread() {
|
||||
_audioThread = new QThread();
|
||||
_audioThread->setObjectName("Player Audio Thread");
|
||||
_options.position = _avatar->getPosition();
|
||||
_options.orientation = _avatar->getOrientation();
|
||||
_injector.reset(new AudioInjector(_recording->getAudioData(), _options), &QObject::deleteLater);
|
||||
|
|
|
@ -628,17 +628,6 @@ void EntityItem::setMass(float mass) {
|
|||
|
||||
const float ENTITY_ITEM_EPSILON_VELOCITY_LENGTH = 0.001f / (float)TREE_SCALE;
|
||||
|
||||
// TODO: we probably want to change this to make "down" be the direction of the entity's gravity vector
|
||||
// for now, this is always true DOWN even if entity has non-down gravity.
|
||||
// TODO: the old code had "&& _velocity.y >= -EPSILON && _velocity.y <= EPSILON" --- what was I thinking?
|
||||
bool EntityItem::isRestingOnSurface() const {
|
||||
glm::vec3 downwardVelocity = glm::vec3(0.0f, _velocity.y, 0.0f);
|
||||
|
||||
return _position.y <= getDistanceToBottomOfEntity()
|
||||
&& (glm::length(downwardVelocity) <= ENTITY_ITEM_EPSILON_VELOCITY_LENGTH)
|
||||
&& _gravity.y < 0.0f;
|
||||
}
|
||||
|
||||
void EntityItem::simulate(const quint64& now) {
|
||||
if (_lastSimulated == 0) {
|
||||
_lastSimulated = now;
|
||||
|
@ -654,7 +643,6 @@ void EntityItem::simulate(const quint64& now) {
|
|||
qDebug() << " timeElapsed=" << timeElapsed;
|
||||
qDebug() << " hasVelocity=" << hasVelocity();
|
||||
qDebug() << " hasGravity=" << hasGravity();
|
||||
qDebug() << " isRestingOnSurface=" << isRestingOnSurface();
|
||||
qDebug() << " hasAngularVelocity=" << hasAngularVelocity();
|
||||
qDebug() << " getAngularVelocity=" << getAngularVelocity();
|
||||
qDebug() << " isMortal=" << isMortal();
|
||||
|
@ -662,11 +650,10 @@ void EntityItem::simulate(const quint64& now) {
|
|||
qDebug() << " getLifetime()=" << getLifetime();
|
||||
|
||||
|
||||
if (hasVelocity() || (hasGravity() && !isRestingOnSurface())) {
|
||||
if (hasVelocity() || hasGravity()) {
|
||||
qDebug() << " MOVING...=";
|
||||
qDebug() << " hasVelocity=" << hasVelocity();
|
||||
qDebug() << " hasGravity=" << hasGravity();
|
||||
qDebug() << " isRestingOnSurface=" << isRestingOnSurface();
|
||||
qDebug() << " hasAngularVelocity=" << hasAngularVelocity();
|
||||
qDebug() << " getAngularVelocity=" << getAngularVelocity();
|
||||
}
|
||||
|
@ -756,7 +743,6 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) {
|
|||
qDebug() << " old position:" << position;
|
||||
qDebug() << " old velocity:" << velocity;
|
||||
qDebug() << " old getAABox:" << getAABox();
|
||||
qDebug() << " getDistanceToBottomOfEntity():" << getDistanceToBottomOfEntity() * (float)TREE_SCALE << " in meters";
|
||||
qDebug() << " newPosition:" << newPosition;
|
||||
qDebug() << " glm::distance(newPosition, position):" << glm::distance(newPosition, position);
|
||||
#endif
|
||||
|
@ -911,11 +897,6 @@ float EntityItem::getSize() const {
|
|||
return glm::length(_dimensions);
|
||||
}
|
||||
|
||||
float EntityItem::getDistanceToBottomOfEntity() const {
|
||||
glm::vec3 minimumPoint = getAABox().getMinimumPoint();
|
||||
return getPosition().y - minimumPoint.y;
|
||||
}
|
||||
|
||||
// TODO: doesn't this need to handle rotation?
|
||||
glm::vec3 EntityItem::getCenter() const {
|
||||
return _position + (_dimensions * (glm::vec3(0.5f,0.5f,0.5f) - _registrationPoint));
|
||||
|
|
|
@ -159,7 +159,6 @@ public:
|
|||
|
||||
const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in domain scale units (0.0 - 1.0)
|
||||
glm::vec3 getDimensionsInMeters() const { return _dimensions * (float) TREE_SCALE; } /// get dimensions in meters
|
||||
float getDistanceToBottomOfEntity() const; /// get the distance from the position of the entity to its "bottom" in y axis
|
||||
float getLargestDimension() const { return glm::length(_dimensions); } /// get the largest possible dimension
|
||||
|
||||
/// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately
|
||||
|
@ -195,9 +194,6 @@ public:
|
|||
void setGravityInMeters(const glm::vec3& value) { _gravity = value / (float) TREE_SCALE; } /// gravity in meters
|
||||
bool hasGravity() const { return _gravity != ENTITY_ITEM_ZERO_VEC3; }
|
||||
|
||||
// TODO: this should eventually be updated to support resting on collisions with other surfaces
|
||||
bool isRestingOnSurface() const;
|
||||
|
||||
float getDamping() const { return _damping; }
|
||||
void setDamping(float value) { _damping = value; }
|
||||
|
||||
|
|
|
@ -1250,6 +1250,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
QString jointRightHandID;
|
||||
QString jointLeftToeID;
|
||||
QString jointRightToeID;
|
||||
|
||||
float lightmapOffset = 0.0f;
|
||||
|
||||
QVector<QString> humanIKJointNames;
|
||||
for (int i = 0;; i++) {
|
||||
|
@ -2070,6 +2072,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
|||
|
||||
FBXTexture emissiveTexture;
|
||||
glm::vec2 emissiveParams(0.f, 1.f);
|
||||
emissiveParams.x = lightmapOffset;
|
||||
emissiveParams.y = lightmapLevel;
|
||||
QString emissiveTextureID = emissiveTextures.value(childID);
|
||||
QString ambientTextureID = ambientTextures.value(childID);
|
||||
|
|
|
@ -49,7 +49,7 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= {
|
|||
GL_UNSIGNED_BYTE
|
||||
};
|
||||
|
||||
#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError()
|
||||
//#define CHECK_GL_ERROR()
|
||||
//#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError()
|
||||
#define CHECK_GL_ERROR()
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <QtDebug>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "MetavoxelUtil.h"
|
||||
#include "ScriptCache.h"
|
||||
|
@ -485,9 +485,7 @@ void QColorEditor::selectColor() {
|
|||
}
|
||||
}
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QStringList> editorURLs("editorURLs");
|
||||
}
|
||||
Setting::Handle<QStringList> editorURLs("editorURLs");
|
||||
|
||||
QUrlEditor::QUrlEditor(QWidget* parent) :
|
||||
QComboBox(parent) {
|
||||
|
@ -496,7 +494,7 @@ QUrlEditor::QUrlEditor(QWidget* parent) :
|
|||
setInsertPolicy(InsertAtTop);
|
||||
|
||||
// populate initial URL list from settings
|
||||
addItems(SettingHandles::editorURLs.get());
|
||||
addItems(editorURLs.get());
|
||||
|
||||
connect(this, SIGNAL(activated(const QString&)), SLOT(updateURL(const QString&)));
|
||||
connect(model(), SIGNAL(rowsInserted(const QModelIndex&,int,int)), SLOT(updateSettings()));
|
||||
|
@ -516,7 +514,7 @@ void QUrlEditor::updateSettings() {
|
|||
for (int i = 0, size = qMin(MAX_STORED_URLS, count()); i < size; i++) {
|
||||
urls.append(itemText(i));
|
||||
}
|
||||
SettingHandles::editorURLs.set(urls);
|
||||
editorURLs.set(urls);
|
||||
}
|
||||
|
||||
BaseVec3Editor::BaseVec3Editor(QWidget* parent) : QWidget(parent) {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <glm/gtx/transform.hpp>
|
||||
|
||||
#include <GeometryUtil.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "MetavoxelData.h"
|
||||
#include "Spanner.h"
|
||||
|
@ -58,9 +58,7 @@ static QItemEditorCreatorBase* heightfieldColorEditorCreator = createHeightfield
|
|||
const float DEFAULT_PLACEMENT_GRANULARITY = 0.01f;
|
||||
const float DEFAULT_VOXELIZATION_GRANULARITY = powf(2.0f, -3.0f);
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QString> heightfieldDir("heightDir", QString());
|
||||
}
|
||||
Setting::Handle<QString> heightfieldDir("heightDir");
|
||||
|
||||
Spanner::Spanner() :
|
||||
_renderer(NULL),
|
||||
|
@ -615,12 +613,12 @@ static int getHeightfieldSize(int size) {
|
|||
|
||||
void HeightfieldHeightEditor::select() {
|
||||
QString result = QFileDialog::getOpenFileName(this, "Select Height Image",
|
||||
SettingHandles::heightfieldDir.get(),
|
||||
heightfieldDir.get(),
|
||||
"Images (*.png *.jpg *.bmp *.raw *.mdr)");
|
||||
if (result.isNull()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::heightfieldDir.set(QFileInfo(result).path());
|
||||
heightfieldDir.set(QFileInfo(result).path());
|
||||
const quint16 CONVERSION_OFFSET = 1;
|
||||
QString lowerResult = result.toLower();
|
||||
bool isMDR = lowerResult.endsWith(".mdr");
|
||||
|
@ -885,12 +883,12 @@ void HeightfieldColorEditor::setColor(const HeightfieldColorPointer& color) {
|
|||
|
||||
void HeightfieldColorEditor::select() {
|
||||
QString result = QFileDialog::getOpenFileName(this, "Select Color Image",
|
||||
SettingHandles::heightfieldDir.get(),
|
||||
heightfieldDir.get(),
|
||||
"Images (*.png *.jpg *.bmp)");
|
||||
if (result.isNull()) {
|
||||
return;
|
||||
}
|
||||
SettingHandles::heightfieldDir.get(QFileInfo(result).path());
|
||||
heightfieldDir.get(QFileInfo(result).path());
|
||||
QImage image;
|
||||
if (!image.load(result)) {
|
||||
QMessageBox::warning(this, "Invalid Image", "The selected image could not be read.");
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <qthread.h>
|
||||
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
@ -96,7 +96,7 @@ void AccountManager::logout() {
|
|||
if (_shouldPersistToSettingsFile) {
|
||||
QString keyURLString(_authURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE));
|
||||
QStringList path = QStringList() << ACCOUNTS_GROUP << keyURLString;
|
||||
SettingHandles::SettingHandle<DataServerAccountInfo>(path).remove();
|
||||
Setting::Handle<DataServerAccountInfo>(path).remove();
|
||||
|
||||
qDebug() << "Removed account info for" << _authURL << "from in-memory accounts and .ini file";
|
||||
} else {
|
||||
|
@ -344,7 +344,7 @@ void AccountManager::persistAccountToSettings() {
|
|||
// store this access token into the local settings
|
||||
QString keyURLString(_authURL.toString().replace("//", DOUBLE_SLASH_SUBSTITUTE));
|
||||
QStringList path = QStringList() << ACCOUNTS_GROUP << keyURLString;
|
||||
SettingHandles::SettingHandle<QVariant>(path).set(QVariant::fromValue(_accountInfo));
|
||||
Setting::Handle<QVariant>(path).set(QVariant::fromValue(_accountInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,6 +500,7 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) {
|
|||
void AccountManager::generateNewKeypair() {
|
||||
// setup a new QThread to generate the keypair on, in case it takes a while
|
||||
QThread* generateThread = new QThread(this);
|
||||
generateThread->setObjectName("Account Manager Generator Thread");
|
||||
|
||||
// setup a keypair generator
|
||||
RSAKeypairGenerator* keypairGenerator = new RSAKeypairGenerator();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <QStringList>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
|
@ -26,11 +26,9 @@
|
|||
|
||||
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
|
||||
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<QUrl> currentAddress(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP
|
||||
<< "address",
|
||||
QUrl());
|
||||
}
|
||||
|
||||
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address");
|
||||
|
||||
|
||||
AddressManager::AddressManager() :
|
||||
_rootPlaceName(),
|
||||
|
@ -57,18 +55,14 @@ const QUrl AddressManager::currentAddress() const {
|
|||
|
||||
void AddressManager::loadSettings(const QString& lookupString) {
|
||||
if (lookupString.isEmpty()) {
|
||||
const QString& lastAddress = SettingHandles::currentAddress.get().toString();
|
||||
|
||||
if (lastAddress.isEmpty()) {
|
||||
handleLookupString(lastAddress);
|
||||
}
|
||||
handleLookupString(currentAddressHandle.get().toString());
|
||||
} else {
|
||||
handleLookupString(lookupString);
|
||||
}
|
||||
}
|
||||
|
||||
void AddressManager::storeCurrentAddress() {
|
||||
SettingHandles::currentAddress.set(currentAddress());
|
||||
currentAddressHandle.set(currentAddress());
|
||||
}
|
||||
|
||||
const QString AddressManager::currentPath(bool withOrientation) const {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include "BandwidthRecorder.h"
|
||||
|
||||
|
@ -53,17 +52,18 @@ void BandwidthRecorder::Channel::updateOutputAverage(const float sample) {
|
|||
}
|
||||
|
||||
BandwidthRecorder::BandwidthRecorder() {
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++)
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
_channels[ i ] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BandwidthRecorder::~BandwidthRecorder() {
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++)
|
||||
for (uint i=0; i<CHANNEL_COUNT; i++) {
|
||||
delete _channels[ i ];
|
||||
}
|
||||
}
|
||||
|
||||
void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sample) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
_channels[channelType] = new Channel();
|
||||
}
|
||||
|
@ -71,7 +71,6 @@ void BandwidthRecorder::updateInboundData(const quint8 channelType, const int sa
|
|||
}
|
||||
|
||||
void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int sample) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
_channels[channelType] = new Channel();
|
||||
}
|
||||
|
@ -79,7 +78,6 @@ void BandwidthRecorder::updateOutboundData(const quint8 channelType, const int s
|
|||
}
|
||||
|
||||
float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
@ -87,7 +85,6 @@ float BandwidthRecorder::getAverageInputPacketsPerSecond(const quint8 channelTyp
|
|||
}
|
||||
|
||||
float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
@ -95,7 +92,6 @@ float BandwidthRecorder::getAverageOutputPacketsPerSecond(const quint8 channelTy
|
|||
}
|
||||
|
||||
float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
@ -103,7 +99,6 @@ float BandwidthRecorder::getAverageInputKilobitsPerSecond(const quint8 channelTy
|
|||
}
|
||||
|
||||
float BandwidthRecorder::getAverageOutputKilobitsPerSecond(const quint8 channelType) {
|
||||
Q_ASSERT(channelType < CHANNEL_COUNT);
|
||||
if (! _channels[channelType]) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
|
@ -153,6 +153,8 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
|||
qDebug() << "Packet version mismatch on" << packetTypeForPacket(packet) << "- Sender"
|
||||
<< uuidFromPacketHeader(packet) << "sent" << qPrintable(QString::number(packet[numPacketTypeBytes])) << "but"
|
||||
<< qPrintable(QString::number(versionForPacketType(mismatchType))) << "expected.";
|
||||
|
||||
emit packetVersionMismatch();
|
||||
|
||||
versionDebugSuppressMap.insert(senderUUID, checkType);
|
||||
}
|
||||
|
|
|
@ -185,6 +185,8 @@ signals:
|
|||
|
||||
void dataSent(const quint8 channel_type, const int bytes);
|
||||
void dataReceived(const quint8 channel_type, const int bytes);
|
||||
|
||||
void packetVersionMismatch();
|
||||
|
||||
protected:
|
||||
LimitedNodeList(unsigned short socketListenPort = 0, unsigned short dtlsListenPort = 0);
|
||||
|
|
|
@ -11,23 +11,21 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <Settings.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
}
|
||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
|
||||
OctreeQuery::OctreeQuery() {
|
||||
_maxOctreePPS = SettingHandles::maxOctreePacketsPerSecond.get();
|
||||
_maxOctreePPS = maxOctreePacketsPerSecond.get();
|
||||
}
|
||||
|
||||
void OctreeQuery::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||
if (maxOctreePPS != _maxOctreePPS) {
|
||||
_maxOctreePPS = maxOctreePPS;
|
||||
SettingHandles::maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <Settings.h>
|
||||
|
||||
#include "GeometryUtil.h"
|
||||
#include "GLMHelpers.h"
|
||||
#include "SharedUtil.h"
|
||||
|
@ -27,14 +25,7 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace SettingHandles {
|
||||
const SettingHandle<float> fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
|
||||
const SettingHandle<float> realWorldFieldOfView("realWorldFieldOfView", DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES);
|
||||
}
|
||||
|
||||
ViewFrustum::ViewFrustum() {
|
||||
_fieldOfView = SettingHandles::fieldOfView.get();
|
||||
_realWorldFieldOfView = SettingHandles::realWorldFieldOfView.get();
|
||||
}
|
||||
|
||||
void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
||||
|
@ -44,19 +35,6 @@ void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
|||
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f));
|
||||
}
|
||||
|
||||
void ViewFrustum::setFieldOfView(float f) {
|
||||
if (f != _fieldOfView) {
|
||||
_fieldOfView = f;
|
||||
SettingHandles::fieldOfView.set(f);
|
||||
}
|
||||
}
|
||||
void ViewFrustum::setRealWorldFieldOfView(float realWorldFieldOfView) {
|
||||
if (realWorldFieldOfView != _realWorldFieldOfView) {
|
||||
_realWorldFieldOfView = realWorldFieldOfView;
|
||||
SettingHandles::realWorldFieldOfView.set(realWorldFieldOfView);
|
||||
}
|
||||
}
|
||||
|
||||
// ViewFrustum::calculateViewFrustum()
|
||||
//
|
||||
// Description: this will calculate the view frustum bounds for a given position and direction
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
const float DEFAULT_KEYHOLE_RADIUS = 3.0f;
|
||||
const float DEFAULT_FIELD_OF_VIEW_DEGREES = 45.0f;
|
||||
const float DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES = 30.0f;
|
||||
const float DEFAULT_ASPECT_RATIO = 16.0f/9.0f;
|
||||
const float DEFAULT_NEAR_CLIP = 0.08f;
|
||||
const float DEFAULT_FAR_CLIP = TREE_SCALE;
|
||||
|
@ -53,8 +52,7 @@ public:
|
|||
void setOrthographic(bool orthographic) { _orthographic = orthographic; }
|
||||
void setWidth(float width) { _width = width; }
|
||||
void setHeight(float height) { _height = height; }
|
||||
void setFieldOfView(float f);
|
||||
void setRealWorldFieldOfView(float realWorldFieldOfView);
|
||||
void setFieldOfView(float f) { _fieldOfView = f; }
|
||||
void setAspectRatio(float a) { _aspectRatio = a; }
|
||||
void setNearClip(float n) { _nearClip = n; }
|
||||
void setFarClip(float f) { _farClip = f; }
|
||||
|
@ -67,7 +65,6 @@ public:
|
|||
float getWidth() const { return _width; }
|
||||
float getHeight() const { return _height; }
|
||||
float getFieldOfView() const { return _fieldOfView; }
|
||||
float getRealWorldFieldOfView() const { return _realWorldFieldOfView; }
|
||||
float getAspectRatio() const { return _aspectRatio; }
|
||||
float getNearClip() const { return _nearClip; }
|
||||
float getFarClip() const { return _farClip; }
|
||||
|
@ -159,9 +156,6 @@ private:
|
|||
|
||||
// in Degrees, doesn't apply to HMD like Oculus
|
||||
float _fieldOfView = DEFAULT_FIELD_OF_VIEW_DEGREES;
|
||||
// The actual FOV set by the user's monitor size and view distance
|
||||
float _realWorldFieldOfView = DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES;
|
||||
|
||||
|
||||
// keyhole attributes
|
||||
float _keyholeRadius = DEFAULT_KEYHOLE_RADIUS;
|
||||
|
|
|
@ -2120,6 +2120,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
|||
NetworkMesh networkMesh;
|
||||
|
||||
int totalIndices = 0;
|
||||
bool checkForTexcoordLightmap = false;
|
||||
foreach (const FBXMeshPart& part, mesh.parts) {
|
||||
NetworkMeshPart networkPart;
|
||||
if (!part.diffuseTexture.filename.isEmpty()) {
|
||||
|
@ -2149,6 +2150,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
|||
false, part.emissiveTexture.content);
|
||||
networkPart.emissiveTextureName = part.emissiveTexture.name;
|
||||
networkPart.emissiveTexture->setLoadPriorities(_loadPriorities);
|
||||
checkForTexcoordLightmap = true;
|
||||
}
|
||||
networkMesh.parts.append(networkPart);
|
||||
|
||||
|
@ -2215,7 +2217,12 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) {
|
|||
if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ));
|
||||
if (mesh.colors.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::COLOR, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RGB));
|
||||
if (mesh.texCoords.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
||||
if (mesh.texCoords1.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
||||
if (mesh.texCoords1.size()) {
|
||||
networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum++, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
||||
} else if (checkForTexcoordLightmap && mesh.texCoords.size()) {
|
||||
// need lightmap texcoord UV but doesn't have uv#1 so just reuse the same channel
|
||||
networkMesh._vertexFormat->setAttribute(gpu::Stream::TEXCOORD1, channelNum - 1, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::UV));
|
||||
}
|
||||
if (mesh.clusterIndices.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW));
|
||||
if (mesh.clusterWeights.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT, channelNum++, gpu::Element(gpu::VEC4, gpu::NFLOAT, gpu::XYZW));
|
||||
}
|
||||
|
|
68
libraries/shared/src/SettingHandle.h
Normal file
68
libraries/shared/src/SettingHandle.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// SettingHandle.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SettingHandle_h
|
||||
#define hifi_SettingHandle_h
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
#include "SettingInterface.h"
|
||||
|
||||
// TODO: remove
|
||||
class Settings : public QSettings {
|
||||
|
||||
};
|
||||
|
||||
namespace Setting {
|
||||
template <typename T>
|
||||
class Handle : public Interface {
|
||||
public:
|
||||
Handle(const QString& key) : Interface(key) {}
|
||||
Handle(const QStringList& path) : Interface(path.join("/")) {}
|
||||
|
||||
Handle(const QString& key, const T& defaultValue) : Interface(key), _defaultValue(defaultValue) {}
|
||||
Handle(const QStringList& path, const T& defaultValue) : Handle(path.join("/"), defaultValue) {}
|
||||
|
||||
virtual ~Handle() { save(); }
|
||||
|
||||
// Returns setting value, returns its default value if not found
|
||||
T get() { return get(_defaultValue); }
|
||||
// Returns setting value, returns other if not found
|
||||
T get(const T& other) { maybeInit(); return (_isSet) ? _value : other; }
|
||||
T getDefault() const { return _defaultValue; }
|
||||
|
||||
void set(const T& value) { maybeInit(); _value = value; _isSet = true; }
|
||||
void reset() { set(_defaultValue); }
|
||||
|
||||
void remove() { maybeInit(); _isSet = false; }
|
||||
|
||||
protected:
|
||||
virtual void setVariant(const QVariant& variant);
|
||||
virtual QVariant getVariant() { return QVariant::fromValue(get()); }
|
||||
|
||||
private:
|
||||
T _value;
|
||||
const T _defaultValue;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void Handle<T>::setVariant(const QVariant& variant) {
|
||||
if (variant.canConvert<T>() || std::is_same<T, QVariant>::value) {
|
||||
set(variant.value<T>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // hifi_SettingHandle_h
|
100
libraries/shared/src/SettingInterface.cpp
Normal file
100
libraries/shared/src/SettingInterface.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// SettingInterface.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
|
||||
#include "PathUtils.h"
|
||||
#include "SettingInterface.h"
|
||||
#include "SettingManager.h"
|
||||
|
||||
namespace Setting {
|
||||
static Manager* privateInstance = nullptr;
|
||||
|
||||
// cleans up the settings private instance. Should only be run once at closing down.
|
||||
void cleanupPrivateInstance() {
|
||||
delete privateInstance;
|
||||
privateInstance = nullptr;
|
||||
}
|
||||
|
||||
// Sets up the settings private instance. Should only be run once at startup
|
||||
void setupPrivateInstance() {
|
||||
// read the ApplicationInfo.ini file for Name/Version/Domain information
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings applicationInfo(PathUtils::resourcesPath() + "info/ApplicationInfo.ini", QSettings::IniFormat);
|
||||
// set the associated application properties
|
||||
applicationInfo.beginGroup("INFO");
|
||||
QCoreApplication::setApplicationName(applicationInfo.value("name").toString());
|
||||
QCoreApplication::setOrganizationName(applicationInfo.value("organizationName").toString());
|
||||
QCoreApplication::setOrganizationDomain(applicationInfo.value("organizationDomain").toString());
|
||||
|
||||
// Let's set up the settings Private instance on it's own thread
|
||||
QThread* thread = new QThread();
|
||||
Q_CHECK_PTR(thread);
|
||||
thread->setObjectName("Settings Thread");
|
||||
|
||||
privateInstance = new Manager();
|
||||
Q_CHECK_PTR(privateInstance);
|
||||
|
||||
QObject::connect(privateInstance, SIGNAL(destroyed()), thread, SLOT(quit()));
|
||||
QObject::connect(thread, SIGNAL(started()), privateInstance, SLOT(startTimer()));
|
||||
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
privateInstance->moveToThread(thread);
|
||||
thread->start();
|
||||
qDebug() << "Settings thread started.";
|
||||
|
||||
// Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
|
||||
qAddPostRoutine(cleanupPrivateInstance);
|
||||
}
|
||||
// Register setupPrivateInstance to run after QCoreApplication's constructor.
|
||||
Q_COREAPP_STARTUP_FUNCTION(setupPrivateInstance)
|
||||
|
||||
|
||||
Interface::~Interface() {
|
||||
if (privateInstance) {
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::init() {
|
||||
if (!privateInstance) {
|
||||
qWarning() << "Setting::Interface::init(): Manager not yet created, bailing";
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Handle
|
||||
privateInstance->registerHandle(this);
|
||||
_isInitialized = true;
|
||||
|
||||
// Load value from disk
|
||||
load();
|
||||
}
|
||||
|
||||
void Interface::maybeInit() {
|
||||
if (!_isInitialized) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::save() {
|
||||
if (privateInstance) {
|
||||
privateInstance->saveSetting(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::load() {
|
||||
if (privateInstance) {
|
||||
privateInstance->loadSetting(this);
|
||||
}
|
||||
}
|
||||
}
|
45
libraries/shared/src/SettingInterface.h
Normal file
45
libraries/shared/src/SettingInterface.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// SettingInterface.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SettingInterface_h
|
||||
#define hifi_SettingInterface_h
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
namespace Setting {
|
||||
class Interface {
|
||||
public:
|
||||
QString getKey() const { return _key; }
|
||||
bool isSet() const { return _isSet; }
|
||||
|
||||
virtual void setVariant(const QVariant& variant) = 0;
|
||||
virtual QVariant getVariant() = 0;
|
||||
|
||||
protected:
|
||||
Interface(const QString& key) : _key(key) {}
|
||||
virtual ~Interface();
|
||||
|
||||
void init();
|
||||
void maybeInit();
|
||||
|
||||
void save();
|
||||
void load();
|
||||
|
||||
bool _isInitialized = false;
|
||||
bool _isSet = false;
|
||||
const QString _key;
|
||||
|
||||
friend class Manager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_SettingInterface_h
|
80
libraries/shared/src/SettingManager.cpp
Normal file
80
libraries/shared/src/SettingManager.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
//
|
||||
// SettingManager.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "SettingInterface.h"
|
||||
#include "SettingManager.h"
|
||||
|
||||
namespace Setting {
|
||||
Manager::~Manager() {
|
||||
// Cleanup timer
|
||||
stopTimer();
|
||||
disconnect(_saveTimer, 0, 0, 0);
|
||||
|
||||
// Save all settings before exit
|
||||
saveAll();
|
||||
sync();
|
||||
}
|
||||
|
||||
void Manager::registerHandle(Setting::Interface* handle) {
|
||||
QString key = handle->getKey();
|
||||
if (_handles.contains(key)) {
|
||||
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
||||
}
|
||||
_handles.insert(key, handle);
|
||||
}
|
||||
|
||||
void Manager::removeHandle(const QString& key) {
|
||||
_handles.remove(key);
|
||||
}
|
||||
|
||||
void Manager::loadSetting(Interface* handle) {
|
||||
handle->setVariant(value(handle->getKey()));
|
||||
}
|
||||
|
||||
void Manager::saveSetting(Interface* handle) {
|
||||
if (handle->isSet()) {
|
||||
setValue(handle->getKey(), handle->getVariant());
|
||||
} else {
|
||||
remove(handle->getKey());
|
||||
}
|
||||
}
|
||||
|
||||
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
|
||||
void Manager::startTimer() {
|
||||
if (!_saveTimer) {
|
||||
_saveTimer = new QTimer(this);
|
||||
Q_CHECK_PTR(_saveTimer);
|
||||
_saveTimer->setSingleShot(true); // We will restart it once settings are saved.
|
||||
_saveTimer->setInterval(SAVE_INTERVAL_MSEC);
|
||||
connect(_saveTimer, SIGNAL(timeout()), this, SLOT(saveAll()));
|
||||
}
|
||||
_saveTimer->start();
|
||||
}
|
||||
|
||||
void Manager::stopTimer() {
|
||||
if (_saveTimer) {
|
||||
_saveTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::saveAll() {
|
||||
for (auto handle : _handles) {
|
||||
saveSetting(handle);
|
||||
}
|
||||
|
||||
// Restart timer
|
||||
if (_saveTimer) {
|
||||
_saveTimer->start();
|
||||
}
|
||||
}
|
||||
}
|
48
libraries/shared/src/SettingManager.h
Normal file
48
libraries/shared/src/SettingManager.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// SettingManager.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 2/2/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_SettingManager_h
|
||||
#define hifi_SettingManager_h
|
||||
|
||||
#include <QPointer>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Setting {
|
||||
class Interface;
|
||||
|
||||
class Manager : public QSettings {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
~Manager();
|
||||
void registerHandle(Interface* handle);
|
||||
void removeHandle(const QString& key);
|
||||
|
||||
void loadSetting(Interface* handle);
|
||||
void saveSetting(Interface* handle);
|
||||
|
||||
private slots:
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
|
||||
void saveAll();
|
||||
|
||||
private:
|
||||
QHash<QString, Interface*> _handles;
|
||||
QPointer<QTimer> _saveTimer = nullptr;
|
||||
|
||||
friend class Interface;
|
||||
friend void cleanupPrivateInstance();
|
||||
friend void setupPrivateInstance();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // hifi_SettingManager_h
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// Settings.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QSettings>
|
||||
#include <QThread>
|
||||
#include <QThreadStorage>
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
namespace SettingHandles {
|
||||
|
||||
static QThreadStorage<QSettings*> storage;
|
||||
|
||||
QSettings* getSettings() {
|
||||
if (!storage.hasLocalData()) {
|
||||
storage.setLocalData(new QSettings());
|
||||
QObject::connect(QThread::currentThread(), &QThread::destroyed,
|
||||
storage.localData(), &QSettings::deleteLater);
|
||||
}
|
||||
return storage.localData();
|
||||
}
|
||||
|
||||
QVariant SettingsBridge::getFromSettings(const QString& key, const QVariant& defaultValue) {
|
||||
return getSettings()->value(key, defaultValue);
|
||||
}
|
||||
|
||||
void SettingsBridge::setInSettings(const QString& key, const QVariant& value) {
|
||||
getSettings()->setValue(key, value);
|
||||
}
|
||||
|
||||
void SettingsBridge::removeFromSettings(const QString& key) {
|
||||
getSettings()->remove(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
//
|
||||
// Settings.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 1/18/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_Settings_h
|
||||
#define hifi_Settings_h
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
// TODO: remove
|
||||
class Settings : public QSettings {
|
||||
|
||||
};
|
||||
|
||||
namespace SettingHandles {
|
||||
|
||||
template <typename T>
|
||||
class SettingHandle {
|
||||
public:
|
||||
SettingHandle(const QString& key);
|
||||
SettingHandle(const QStringList& path);
|
||||
SettingHandle(const QString& key, const T& defaultValue);
|
||||
SettingHandle(const QStringList& path, const T& defaultValue);
|
||||
|
||||
T get() const; // Returns setting value, returns its default value if not found
|
||||
T get(const T& other) const; // Returns setting value, returns other if not found
|
||||
T getDefault() const;
|
||||
|
||||
void set(const T& value) const;
|
||||
void reset() const;
|
||||
|
||||
void remove() const;
|
||||
|
||||
private:
|
||||
const QString _key;
|
||||
const QVariant _defaultValue;
|
||||
};
|
||||
|
||||
class SettingsBridge {
|
||||
private:
|
||||
static QVariant getFromSettings(const QString& key, const QVariant& defaultValue);
|
||||
static void setInSettings(const QString& key, const QVariant& value);
|
||||
static void removeFromSettings(const QString& key);
|
||||
|
||||
template<typename T>
|
||||
friend class SettingHandle;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QString& key) : _key(key) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QStringList& path) : _key(path.join("/")) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QString& key, const T& defaultValue) :
|
||||
_key(key),
|
||||
_defaultValue(defaultValue) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
SettingHandle<T>::SettingHandle(const QStringList& path, const T& defaultValue) :
|
||||
_key(path.join("/")),
|
||||
_defaultValue(defaultValue) {
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SettingHandle<T>::get() const {
|
||||
QVariant variant = SettingsBridge::getFromSettings(_key, _defaultValue);
|
||||
if (variant.canConvert<T>()) {
|
||||
return variant.value<T>();
|
||||
}
|
||||
return _defaultValue.value<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T SettingHandle<T>::get(const T& other) const {
|
||||
QVariant variant = SettingsBridge::getFromSettings(_key, QVariant(other));
|
||||
if (variant.canConvert<T>()) {
|
||||
return variant.value<T>();
|
||||
}
|
||||
return other;
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
T SettingHandle<T>::getDefault() const {
|
||||
return _defaultValue.value<T>();
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::set(const T& value) const {
|
||||
if (value != get()) {
|
||||
SettingsBridge::setInSettings(_key, QVariant(value));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::reset() const {
|
||||
SettingsBridge::setInSettings(_key, _defaultValue);
|
||||
}
|
||||
|
||||
template <typename T> inline
|
||||
void SettingHandle<T>::remove() const {
|
||||
SettingsBridge::removeFromSettings(_key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // hifi_Settings_h
|
Loading…
Reference in a new issue