Merge pull request #14563 from danteruiz/teleport-settings

Adding menu settings to disable teleporting
This commit is contained in:
Shannon Romano 2018-12-11 21:08:23 +00:00 committed by GitHub
commit efedc1f0b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 13 deletions

View file

@ -16,10 +16,11 @@ import controlsUit 1.0
Preference {
id: root
height: spacer.height + Math.max(hifi.dimensions.controlLineHeight, checkBox.implicitHeight)
property bool value: false
Component.onCompleted: {
checkBox.checked = preference.value;
preference.value = Qt.binding(function(){ return checkBox.checked; });
value = checkBox.checked;
}
function save() {
@ -47,6 +48,7 @@ Preference {
onClicked: {
Tablet.playSound(TabletEnums.ButtonClick);
value = checked;
}
anchors {

View file

@ -123,12 +123,12 @@ Item {
}
// Runtime customization of preferences.
var locomotionPreference = findPreference("VR Movement", "Teleporting only / Walking and teleporting");
var locomotionPreference = findPreference("VR Movement", "Walking");
var flyingPreference = findPreference("VR Movement", "Jumping and flying");
if (locomotionPreference && flyingPreference) {
flyingPreference.visible = (locomotionPreference.value === 1);
flyingPreference.visible = locomotionPreference.value;
locomotionPreference.valueChanged.connect(function () {
flyingPreference.visible = (locomotionPreference.value === 1);
flyingPreference.visible = locomotionPreference.value;
});
}
if (HMD.isHeadControllerAvailable("Oculus")) {

View file

@ -247,6 +247,7 @@ class MyAvatar : public Avatar {
Q_PROPERTY(bool isInSittingState READ getIsInSittingState WRITE setIsInSittingState);
Q_PROPERTY(MyAvatar::SitStandModelType userRecenterModel READ getUserRecenterModel WRITE setUserRecenterModel);
Q_PROPERTY(bool isSitStandStateLocked READ getIsSitStandStateLocked WRITE setIsSitStandStateLocked);
Q_PROPERTY(bool allowTeleporting READ getAllowTeleporting)
const QString DOMINANT_LEFT_HAND = "left";
const QString DOMINANT_RIGHT_HAND = "right";
@ -559,6 +560,9 @@ public:
void setUseAdvancedMovementControls(bool useAdvancedMovementControls)
{ _useAdvancedMovementControls.set(useAdvancedMovementControls); }
bool getAllowTeleporting() { return _allowTeleportingSetting.get(); }
void setAllowTeleporting(bool allowTeleporting) { _allowTeleportingSetting.set(allowTeleporting); }
bool getShowPlayArea() const { return _showPlayArea.get(); }
void setShowPlayArea(bool showPlayArea) { _showPlayArea.set(showPlayArea); }
@ -1889,6 +1893,7 @@ private:
Setting::Handle<float> _userHeightSetting;
Setting::Handle<bool> _flyingHMDSetting;
Setting::Handle<int> _avatarEntityCountSetting;
Setting::Handle<bool> _allowTeleportingSetting { "allowTeleporting", true };
std::vector<Setting::Handle<QUuid>> _avatarEntityIDSettings;
std::vector<Setting::Handle<QByteArray>> _avatarEntityDataSettings;
};

View file

@ -238,14 +238,15 @@ void setupPreferences() {
static const QString VR_MOVEMENT{ "VR Movement" };
{
auto getter = [myAvatar]()->int { return myAvatar->useAdvancedMovementControls() ? 1 : 0; };
auto setter = [myAvatar](int value) { myAvatar->setUseAdvancedMovementControls(value == 1); };
auto preference =
new RadioButtonsPreference(VR_MOVEMENT, "Teleporting only / Walking and teleporting", getter, setter);
QStringList items;
items << "Teleporting only" << "Walking and teleporting";
preference->setHeading("Movement mode");
preference->setItems(items);
auto getter = [myAvatar]()->bool { return myAvatar->getAllowTeleporting(); };
auto setter = [myAvatar](bool value) { myAvatar->setAllowTeleporting(value); };
auto preference = new CheckPreference(VR_MOVEMENT, "Teleporting", getter, setter);
preferences->addPreference(preference);
}
{
auto getter = [myAvatar]()->bool { return myAvatar->useAdvancedMovementControls(); };
auto setter = [myAvatar](bool value) { myAvatar->setUseAdvancedMovementControls(value); };
auto preference = new CheckPreference(VR_MOVEMENT, "Walking", getter, setter);
preferences->addPreference(preference);
}
{

View file

@ -701,7 +701,7 @@ Script.include("/~/system/libraries/controllers.js");
};
this.isReady = function(controllerData, deltaTime) {
if (Window.interstitialModeEnabled && !Window.isPhysicsEnabled()) {
if ((Window.interstitialModeEnabled && !Window.isPhysicsEnabled()) || !MyAvatar.allowTeleporting) {
return makeRunningValues(false, [], []);
}