mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 01:04:06 +02:00
Make combo box go by index, add default values
This commit is contained in:
parent
6bd7034c1a
commit
06985f9278
2 changed files with 39 additions and 20 deletions
|
@ -34,6 +34,21 @@ ModalWindow {
|
|||
property var textInput;
|
||||
property var comboBox;
|
||||
property var checkBox;
|
||||
onTextInputChanged: {
|
||||
if (textInput) {
|
||||
textField.text = textInput.text;
|
||||
}
|
||||
}
|
||||
onComboBoxChanged: {
|
||||
if (comboBox) {
|
||||
comboBoxField.currentIndex = comboBox.index;
|
||||
}
|
||||
}
|
||||
onCheckBoxChanged: {
|
||||
if (checkBox) {
|
||||
checkBoxField.checked = checkBox.checked;
|
||||
}
|
||||
}
|
||||
|
||||
property var warning: "";
|
||||
property var result;
|
||||
|
@ -52,15 +67,15 @@ ModalWindow {
|
|||
|
||||
function updateCheckbox() {
|
||||
if (checkBox.disableForItems) {
|
||||
var currentTextInDisableList = false;
|
||||
var currentItemInDisableList = false;
|
||||
for (var i in checkBox.disableForItems) {
|
||||
if (comboBoxField.currentText === checkBox.disableForItems[i]) {
|
||||
currentTextInDisableList = true;
|
||||
if (comboBoxField.currentIndex === checkBox.disableForItems[i]) {
|
||||
currentItemInDisableList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTextInDisableList) {
|
||||
if (currentItemInDisableList) {
|
||||
checkBoxField.enabled = false;
|
||||
if (checkBox.checkStateOnDisable !== null && checkBox.checkStateOnDisable !== undefined) {
|
||||
root.implicitCheckState = checkBoxField.checked;
|
||||
|
@ -245,8 +260,8 @@ ModalWindow {
|
|||
result.textInput = textField.text;
|
||||
}
|
||||
if (comboBox) {
|
||||
result.comboBox = comboBoxField.currentText;
|
||||
result.comboBoxIndex = comboBoxField.currentIndex;
|
||||
result.comboBox = comboBoxField.currentIndex;
|
||||
result.comboBoxText = comboBoxField.currentText;
|
||||
}
|
||||
if (checkBox) {
|
||||
result.checkBox = checkBoxField.enabled ? checkBoxField.checked : null;
|
||||
|
|
|
@ -246,10 +246,18 @@ var toolBar = (function () {
|
|||
toolBar.writeProperty("shown", false);
|
||||
|
||||
addButton("newModelButton", "model-01.svg", function () {
|
||||
var SHAPE_TYPE_NONE_TEXT = "No Collision";
|
||||
var SHAPE_TYPE_SIMPLE_HULL_TEXT = "Basic - Whole model";
|
||||
var SHAPE_TYPE_SIMPLE_COMPOUND_TEXT = "Good - Sub-meshes";
|
||||
var SHAPE_TYPE_STATIC_MESH_TEXT = "Exact - All polygons";
|
||||
var SHAPE_TYPE_NONE = 0;
|
||||
var SHAPE_TYPE_SIMPLE_HULL = 1;
|
||||
var SHAPE_TYPE_SIMPLE_COMPOUND = 2;
|
||||
var SHAPE_TYPE_STATIC_MESH = 3;
|
||||
|
||||
var SHAPE_TYPES = [];
|
||||
SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision";
|
||||
SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model";
|
||||
SHAPE_TYPES[SHAPE_TYPE_SIMPLE_COMPOUND] = "Good - Sub-meshes";
|
||||
SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons";
|
||||
|
||||
var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH;
|
||||
var DYNAMIC_DEFAULT = false;
|
||||
var result = Window.customPrompt({
|
||||
textInput: {
|
||||
|
@ -257,18 +265,14 @@ var toolBar = (function () {
|
|||
},
|
||||
comboBox: {
|
||||
label: "Automatic Collisions",
|
||||
items: [
|
||||
SHAPE_TYPE_NONE_TEXT,
|
||||
SHAPE_TYPE_SIMPLE_HULL_TEXT,
|
||||
SHAPE_TYPE_SIMPLE_COMPOUND_TEXT,
|
||||
SHAPE_TYPE_STATIC_MESH_TEXT
|
||||
]
|
||||
index: SHAPE_TYPE_DEFAULT,
|
||||
items: SHAPE_TYPES
|
||||
},
|
||||
checkBox: {
|
||||
label: "Dynamic",
|
||||
checked: DYNAMIC_DEFAULT,
|
||||
disableForItems: [
|
||||
SHAPE_TYPE_STATIC_MESH_TEXT
|
||||
SHAPE_TYPE_STATIC_MESH
|
||||
],
|
||||
checkStateOnDisable: false,
|
||||
warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic"
|
||||
|
@ -279,13 +283,13 @@ var toolBar = (function () {
|
|||
var url = result.textInput;
|
||||
var shapeType;
|
||||
switch (result.comboBox) {
|
||||
case SHAPE_TYPE_SIMPLE_HULL_TEXT:
|
||||
case SHAPE_TYPE_SIMPLE_HULL:
|
||||
shapeType = "simple-hull";
|
||||
break;
|
||||
case SHAPE_TYPE_SIMPLE_COMPOUND_TEXT:
|
||||
case SHAPE_TYPE_SIMPLE_COMPOUND:
|
||||
shapeType = "simple-compound";
|
||||
break;
|
||||
case SHAPE_TYPE_STATIC_MESH_TEXT:
|
||||
case SHAPE_TYPE_STATIC_MESH:
|
||||
shapeType = "static-mesh";
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue