mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:43:49 +02:00
Moved isListOfStrings into shared/ScriptValueUtils
Also fixed some single line ifs.
This commit is contained in:
parent
253e4cbb73
commit
38418d0169
3 changed files with 56 additions and 18 deletions
|
@ -20,6 +20,7 @@
|
|||
#include <GeometryUtil.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <DebugDraw.h>
|
||||
#include <ScriptValueUtils.h>
|
||||
#include <shared/NsightHelpers.h>
|
||||
|
||||
#include "AnimationLogging.h"
|
||||
|
@ -783,24 +784,6 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
|||
_lastVelocity = workingVelocity;
|
||||
}
|
||||
|
||||
static bool isListOfStrings(const QScriptValue& arg) {
|
||||
if (!arg.isArray())
|
||||
return false;
|
||||
|
||||
auto lengthProperty = arg.property("length");
|
||||
if (!lengthProperty.isNumber())
|
||||
return false;
|
||||
|
||||
int length = lengthProperty.toInt32();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!arg.property(i).isString()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Allow script to add/remove handlers and report results, from within their thread.
|
||||
QScriptValue Rig::addAnimationStateHandler(QScriptValue handler, QScriptValue propertiesList) { // called in script thread
|
||||
|
||||
|
|
34
libraries/shared/src/ScriptValueUtils.cpp
Normal file
34
libraries/shared/src/ScriptValueUtils.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// ScriptValueUtils.cpp
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Anthony Thibault on 4/15/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Utilities for working with QtScriptValues
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "ScriptValueUtils.h"
|
||||
|
||||
bool isListOfStrings(const QScriptValue& arg) {
|
||||
if (!arg.isArray()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto lengthProperty = arg.property("length");
|
||||
if (!lengthProperty.isNumber()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int length = lengthProperty.toInt32();
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (!arg.property(i).isString()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
21
libraries/shared/src/ScriptValueUtils.h
Normal file
21
libraries/shared/src/ScriptValueUtils.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// ScriptValueUtils.h
|
||||
// libraries/shared/src
|
||||
//
|
||||
// Created by Anthony Thibault on 4/15/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Utilities for working with QtScriptValues
|
||||
//
|
||||
// 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_ScriptValueUtils_h
|
||||
#define hifi_ScriptValueUtils_h
|
||||
|
||||
#include <QScriptValue>
|
||||
|
||||
bool isListOfStrings(const QScriptValue& value);
|
||||
|
||||
#endif // #define hifi_ScriptValueUtils_h
|
Loading…
Reference in a new issue