mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
add checkbox support in scripting interface
This commit is contained in:
parent
3f3e6ea581
commit
06da1bd566
4 changed files with 37 additions and 11 deletions
|
@ -38,15 +38,15 @@ EntityPropertyDialogBox = (function () {
|
||||||
|
|
||||||
array.push({ label: "Entity Type:" + properties.type, type: "header" });
|
array.push({ label: "Entity Type:" + properties.type, type: "header" });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Locked:", value: properties.locked });
|
array.push({ label: "Locked:", type: "checkbox", value: properties.locked });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (properties.type == "Model") {
|
if (properties.type == "Model") {
|
||||||
array.push({ label: "Model URL:", value: properties.modelURL });
|
array.push({ label: "Model URL:", value: properties.modelURL });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Animation URL:", value: properties.animationURL });
|
array.push({ label: "Animation URL:", value: properties.animationURL });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Animation is playing:", value: properties.animationIsPlaying });
|
array.push({ label: "Animation is playing:", type: "checkbox", value: properties.animationIsPlaying });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Animation FPS:", value: properties.animationFPS });
|
array.push({ label: "Animation FPS:", value: properties.animationFPS });
|
||||||
index++;
|
index++;
|
||||||
|
@ -130,20 +130,20 @@ EntityPropertyDialogBox = (function () {
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Mass:", value: properties.mass.toFixed(decimals) });
|
array.push({ label: "Mass:", value: properties.mass.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Ignore for Collisions:", value: properties.ignoreForCollisions });
|
array.push({ label: "Ignore for Collisions:", type: "checkbox", value: properties.ignoreForCollisions });
|
||||||
index++;
|
index++;
|
||||||
array.push({ label: "Collisions Will Move:", value: properties.collisionsWillMove });
|
array.push({ label: "Collisions Will Move:", type: "checkbox", value: properties.collisionsWillMove });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
array.push({ label: "Visible:", value: properties.visible });
|
array.push({ label: "Visible:", type: "checkbox", value: properties.visible });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
array.push({ label: "Script:", value: properties.script });
|
array.push({ label: "Script:", value: properties.script });
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (properties.type == "Box" || properties.type == "Sphere") {
|
if (properties.type == "Box" || properties.type == "Sphere") {
|
||||||
array.push({ label: "Color:", type: "header" });
|
array.push({ label: "Color:", type: "header" });
|
||||||
index++;
|
index++;
|
||||||
|
@ -215,7 +215,7 @@ EntityPropertyDialogBox = (function () {
|
||||||
var rescaledX = peekX * peekRescale / 100.0;
|
var rescaledX = peekX * peekRescale / 100.0;
|
||||||
var rescaledY = peekY * peekRescale / 100.0;
|
var rescaledY = peekY * peekRescale / 100.0;
|
||||||
var rescaledZ = peekZ * peekRescale / 100.0;
|
var rescaledZ = peekZ * peekRescale / 100.0;
|
||||||
|
|
||||||
Window.reloadNonBlockingForm([
|
Window.reloadNonBlockingForm([
|
||||||
{ value: rescaledX.toFixed(decimals), oldIndex: dimensionX },
|
{ value: rescaledX.toFixed(decimals), oldIndex: dimensionX },
|
||||||
{ value: rescaledY.toFixed(decimals), oldIndex: dimensionY },
|
{ value: rescaledY.toFixed(decimals), oldIndex: dimensionY },
|
||||||
|
@ -323,4 +323,3 @@ EntityPropertyDialogBox = (function () {
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|
|
@ -344,7 +344,7 @@ var toolBar = (function () {
|
||||||
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||||
|
|
||||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||||
Entities.addEntity({
|
Entities.addEntity({
|
||||||
type: "Light",
|
type: "Light",
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION },
|
dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION },
|
||||||
|
@ -699,7 +699,7 @@ function handeMenuEvent(menuItem) {
|
||||||
var selectedModel = form[0].value;
|
var selectedModel = form[0].value;
|
||||||
if (form[1].value == "Properties") {
|
if (form[1].value == "Properties") {
|
||||||
editModelID = selectedModel;
|
editModelID = selectedModel;
|
||||||
showPropertiesForm(editModelID);
|
entityPropertyDialogBox.openDialog(editModelID);
|
||||||
} else if (form[1].value == "Delete") {
|
} else if (form[1].value == "Delete") {
|
||||||
Entities.deleteEntity(selectedModel);
|
Entities.deleteEntity(selectedModel);
|
||||||
} else if (form[1].value == "Teleport") {
|
} else if (form[1].value == "Teleport") {
|
||||||
|
|
|
@ -248,6 +248,7 @@ QScriptValue WindowScriptingInterface::doPeekNonBlockingFormResult(QScriptValue
|
||||||
int e = -1;
|
int e = -1;
|
||||||
int d = -1;
|
int d = -1;
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
int h = -1;
|
||||||
for (int i = 0; i < _form.property("length").toInt32(); ++i) {
|
for (int i = 0; i < _form.property("length").toInt32(); ++i) {
|
||||||
QScriptValue item = _form.property(i);
|
QScriptValue item = _form.property(i);
|
||||||
QScriptValue value = item.property("value");
|
QScriptValue value = item.property("value");
|
||||||
|
@ -271,6 +272,11 @@ QScriptValue WindowScriptingInterface::doPeekNonBlockingFormResult(QScriptValue
|
||||||
array.engine()->undefinedValue()
|
array.engine()->undefinedValue()
|
||||||
);
|
);
|
||||||
_form.setProperty(i, item);
|
_form.setProperty(i, item);
|
||||||
|
} else if (item.property("type").toString() == "checkbox") {
|
||||||
|
h++;
|
||||||
|
value = _checks.at(h)->checkState() == Qt::Checked;
|
||||||
|
item.setProperty("value", value);
|
||||||
|
_form.setProperty(i, item);
|
||||||
} else {
|
} else {
|
||||||
e += 1;
|
e += 1;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -305,6 +311,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a
|
||||||
int e = -1;
|
int e = -1;
|
||||||
int d = -1;
|
int d = -1;
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
int h = -1;
|
||||||
for (int i = 0; i < _form.property("length").toInt32(); ++i) {
|
for (int i = 0; i < _form.property("length").toInt32(); ++i) {
|
||||||
QScriptValue item = _form.property(i);
|
QScriptValue item = _form.property(i);
|
||||||
QScriptValue value = item.property("value");
|
QScriptValue value = item.property("value");
|
||||||
|
@ -328,6 +335,11 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a
|
||||||
array.engine()->undefinedValue()
|
array.engine()->undefinedValue()
|
||||||
);
|
);
|
||||||
_form.setProperty(i, item);
|
_form.setProperty(i, item);
|
||||||
|
} else if (item.property("type").toString() == "checkbox") {
|
||||||
|
h++;
|
||||||
|
value = _checks.at(h)->checkState() == Qt::Checked;
|
||||||
|
item.setProperty("value", value);
|
||||||
|
_form.setProperty(i, item);
|
||||||
} else {
|
} else {
|
||||||
e += 1;
|
e += 1;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -358,6 +370,7 @@ QScriptValue WindowScriptingInterface::doGetNonBlockingFormResult(QScriptValue a
|
||||||
_edits.clear();
|
_edits.clear();
|
||||||
_directories.clear();
|
_directories.clear();
|
||||||
_combos.clear();
|
_combos.clear();
|
||||||
|
_checks.clear();
|
||||||
|
|
||||||
array = _form;
|
array = _form;
|
||||||
return (_formResult == QDialog::Accepted);
|
return (_formResult == QDialog::Accepted);
|
||||||
|
@ -383,6 +396,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal
|
||||||
int e = -1;
|
int e = -1;
|
||||||
int d = -1;
|
int d = -1;
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
int h = -1;
|
||||||
for (int i = 0; i < form.property("length").toInt32(); ++i) {
|
for (int i = 0; i < form.property("length").toInt32(); ++i) {
|
||||||
QScriptValue item = form.property(i);
|
QScriptValue item = form.property(i);
|
||||||
QScriptValue value = item.property("value");
|
QScriptValue value = item.property("value");
|
||||||
|
@ -406,6 +420,11 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal
|
||||||
form.engine()->undefinedValue()
|
form.engine()->undefinedValue()
|
||||||
);
|
);
|
||||||
form.setProperty(i, item);
|
form.setProperty(i, item);
|
||||||
|
} else if (item.property("type").toString() == "checkbox") {
|
||||||
|
h++;
|
||||||
|
value = _checks.at(h)->checkState() == Qt::Checked;
|
||||||
|
item.setProperty("value", value);
|
||||||
|
form.setProperty(i, item);
|
||||||
} else {
|
} else {
|
||||||
e += 1;
|
e += 1;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
@ -432,6 +451,7 @@ QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptVal
|
||||||
|
|
||||||
delete editDialog;
|
delete editDialog;
|
||||||
_combos.clear();
|
_combos.clear();
|
||||||
|
_checks.clear();
|
||||||
_edits.clear();
|
_edits.clear();
|
||||||
_directories.clear();
|
_directories.clear();
|
||||||
return (result == QDialog::Accepted);
|
return (result == QDialog::Accepted);
|
||||||
|
@ -518,6 +538,12 @@ QDialog* WindowScriptingInterface::createForm(const QString& title, QScriptValue
|
||||||
}
|
}
|
||||||
_combos.push_back(combo);
|
_combos.push_back(combo);
|
||||||
formLayout->addRow(new QLabel(item.property("label").toString()), combo);
|
formLayout->addRow(new QLabel(item.property("label").toString()), combo);
|
||||||
|
} else if (item.property("type").toString() == "checkbox") {
|
||||||
|
QCheckBox* check = new QCheckBox();
|
||||||
|
check->setTristate(false);
|
||||||
|
check->setCheckState(item.property("value").toString() == "true" ? Qt::Checked : Qt::Unchecked);
|
||||||
|
_checks.push_back(check);
|
||||||
|
formLayout->addRow(new QLabel(item.property("label").toString()), check);
|
||||||
} else {
|
} else {
|
||||||
QLineEdit* edit = new QLineEdit(item.property("value").toString());
|
QLineEdit* edit = new QLineEdit(item.property("value").toString());
|
||||||
edit->setMinimumWidth(200);
|
edit->setMinimumWidth(200);
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
bool _nonBlockingFormActive;
|
bool _nonBlockingFormActive;
|
||||||
int _formResult;
|
int _formResult;
|
||||||
QVector<QComboBox*> _combos;
|
QVector<QComboBox*> _combos;
|
||||||
|
QVector<QCheckBox*> _checks;
|
||||||
QVector<QLineEdit*> _edits;
|
QVector<QLineEdit*> _edits;
|
||||||
QVector<QPushButton*> _directories;
|
QVector<QPushButton*> _directories;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue