Ejemplo n.º 1
0
    static SupportedDataType ConvertOldDataType(SupportedDataType supportedDataType)
    {
        int oldTypeIndex           = (int)supportedDataType;
        SupportedDataType dataType = (SupportedDataType)(oldTypeIndex + 1);

        return(dataType);
    }
        /// <summary>
        /// Add or remove a supported data type to keep to the application's settings
        /// </summary>
        /// <param name="keep">Defines whether the data must be added to the array or not</param>
        /// <param name="type">The <see cref="SupportedDataType"/> to add or remove</param>
        private void AddOrRemoveDataTypeToKeep(bool keep, SupportedDataType type)
        {
            var data = (int)type;

            if (keep && !Settings.Default.KeepDataTypes.Contains(data))
            {
                Settings.Default.KeepDataTypes.Add(data);
            }
            else if (Settings.Default.KeepDataTypes.Contains(data))
            {
                Settings.Default.KeepDataTypes.Remove(data);
            }
        }
Ejemplo n.º 3
0
        void CreateNewVariable()
        {
            if (selectedVariableType == VariableType.ChooseType || selectedDataType == SupportedDataType.ChooseType)
            {
                Debug.LogWarning($"{TuxLog.Prefix} Need to select variable type and data type before creating a variable");
                return;
            }

            factory.AddNew(selectedVariableType, selectedDataType);

            selectedDataType     = SupportedDataType.ChooseType;
            selectedVariableType = VariableType.ChooseType;
            serializedObject.Update();
        }
Ejemplo n.º 4
0
        void ShowVariableCreationInterface()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
            //GUILayout.Space((EditorGUI.indentLevel +1) * IndentSize);
            if (GUILayout.Button("Create Variable:"))
            {
                CreateNewVariable();
            }

            selectedVariableType = (VariableType)EditorGUILayout.EnumPopup(selectedVariableType);
            selectedDataType     = (SupportedDataType)EditorGUILayout.EnumPopup(selectedDataType);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
Ejemplo n.º 5
0
        void OnEnable()
        {
            variablePanelBackgroundColor = new Color(VariablePanelBackgroundLightness, VariablePanelBackgroundLightness, VariablePanelBackgroundLightness, 1);

            designFileTarget = target as ExperimentDesignFile2;
            if (designFileTarget == null)
            {
                Debug.LogError($"Null ExperimentDesignFile2 in editor {target.name}", this);
                throw new NullReferenceException("Null ExperimentDesignFile");
            }

            factoryProp = serializedObject.FindProperty(nameof(ExperimentDesignFile2.Factory));
            if (factoryProp == null)
            {
                throw new NullReferenceException("null factory prop");
            }
            factory = designFileTarget.Factory;
            if (factory == null)
            {
                throw new NullReferenceException("null factory");
            }


            trialTableGenerationMode  = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialTableGeneration));
            orderConfigs              = serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockOrderConfigurations));
            blockRandomizationMode    = serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockRandomization));
            trialRandomizationMode    = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialRandomization));
            trialRandomizationSubType =
                serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialPermutationType));
            blockPartialRandomizationSubType =
                serializedObject.FindProperty(nameof(ExperimentDesignFile2.BlockPartialRandomizationSubType));
            trialRepetitions      = serializedObject.FindProperty(nameof(ExperimentDesignFile2.TrialRepetitions));
            experimentRepetitions = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ExperimentRepetitions));
            columnNameSettings    = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ColumnNamesSettings));
            controlSettings       = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ControlSettings));
            guiSettings           = serializedObject.FindProperty(nameof(ExperimentDesignFile2.GuiSettings));
            fileLocationSettings  = serializedObject.FindProperty(nameof(ExperimentDesignFile2.FileLocationSettings));
            showAdvanced          = serializedObject.FindProperty(nameof(ExperimentDesignFile2.ShowAdvancedEditor));

            InitializeBlockOrderList();

            selectedDataType     = SupportedDataType.ChooseType;
            selectedVariableType = VariableType.ChooseType;
        }
Ejemplo n.º 6
0
        // ReSharper disable once CognitiveComplexity
        public Variable AddNew()
        {
            //TODO Probably a better way to do this
            Variable newVar;

            switch (VariableTypeToCreate)
            {
            case VariableType.Independent:
                Type ivType = supportedIndependentTypes[DataTypeToCreate];
                IndependentVariable newIv = Activator.CreateInstance(ivType) as IndependentVariable;
                UpdateSerializedListsWith(newIv);
                newVar = newIv;
                break;

            case VariableType.Dependent:
                Type dvType             = supportedDependentTypes[DataTypeToCreate];
                DependentVariable newDv = Activator.CreateInstance(dvType) as DependentVariable;
                UpdateSerializedListsWith(newDv);
                newVar = newDv;
                break;

            case VariableType.ChooseType:
                newVar = null;
                break;

            case VariableType.Participant:
                Type pvType = supportedParticipantTypes[DataTypeToCreate];
                ParticipantVariable newPv = Activator.CreateInstance(pvType) as ParticipantVariable;
                UpdateSerializedListsWith(newPv);
                newVar = newPv;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(VariableTypeToCreate), DataTypeToCreate, null);
            }

            DataTypeToCreate     = SupportedDataType.ChooseType;
            VariableTypeToCreate = VariableType.ChooseType;

            return(newVar);
        }
Ejemplo n.º 7
0
        void DrawVariableHeader(SerializedProperty expandViewerProp)
        {
            SerializedProperty variableName = VariableProperty.FindPropertyRelative(nameof(Variable.Name));
            SupportedDataType  dataType     = (SupportedDataType)VariableProperty.FindPropertyRelative(nameof(Variable.DataType)).intValue;

            EditorGUILayout.BeginHorizontal();

            if (expandViewerProp.boolValue)
            {
                EditorGUILayout.PropertyField(variableName, GUIContent.none, GUILayout.Width(NameWidth));
            }
            else
            {
                EditorGUILayout.LabelField(variableName.stringValue, GUILayout.Width(NameWidth));
            }

            VariableNameValidator.Validate(variableName.stringValue, VariableValidationResults);


            EditorGUILayout.LabelField($"{dataType}", GUILayout.Width(DataTypeWidth));
            GUILayout.FlexibleSpace();

            if (expandViewerProp.boolValue)
            {
                if (GUILayout.Button("Hide Settings", GUILayout.Width(DeleteButtonWidth)))
                {
                    expandViewerProp.boolValue = false;
                }
            }
            else
            {
                if (GUILayout.Button("Edit Settings", GUILayout.Width(DeleteButtonWidth)))
                {
                    expandViewerProp.boolValue = true;
                }
            }

            EditorGUILayout.EndHorizontal();
        }