private void DrawScriptItem(ScriptItem item, ref ScriptItem itemToDelete)
        {
            EditorGUILayout.BeginHorizontal();

#if USE_UNET
            if (item.resourceType == ScriptWizardResourceType.Quest || item.resourceType == ScriptWizardResourceType.QuestEntry || item.resourceType == ScriptWizardResourceType.Variable)
            {
                item.netSetMode = (NetSetMode)EditorGUILayout.EnumPopup(item.netSetMode, GUILayout.Width(36));
            }
            else
            {
                item.netSetMode = NetSetMode.Set;
                EditorGUILayout.LabelField("Set", GUILayout.Width(32));
            }
#else
            EditorGUILayout.LabelField("Set", GUILayout.Width(32));
#endif
            ScriptWizardResourceType newResourceType = (ScriptWizardResourceType)EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96));
            if (newResourceType != item.resourceType)
            {
                item.resourceType          = newResourceType;
                item.scriptQuestEntryNames = new string[0];

                s_lastWizardResourceType = LuaWizardBase.GetScriptResourceTypeToConditionResourceType(newResourceType);
            }

            if (item.resourceType == ScriptWizardResourceType.Quest)
            {
                // Quest:
                item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames);
                EditorGUILayout.LabelField("to", GUILayout.Width(22));
                item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96);

                s_lastQuestNamesIndex = item.questNamesIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.QuestEntry)
            {
                // Quest Entry:
                int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames);
                if (newQuestNamesIndex != item.questNamesIndex)
                {
                    item.questNamesIndex       = newQuestNamesIndex;
                    item.scriptQuestEntryNames = new string[0];
                }
                if ((item.scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length))
                {
                    item.scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]);
                }
                item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, item.scriptQuestEntryNames);
                EditorGUILayout.LabelField("to", GUILayout.Width(22));
                item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96);

                s_lastQuestNamesIndex = item.questNamesIndex;
                s_lastQuestEntryIndex = item.questEntryIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Variable)
            {
                // Variable:
                item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variablePopupNames);
                var variableType = GetWizardVariableType(item.variableNamesIndex);
                DrawValueSetMode(item, variableType);
                switch (variableType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastVariableNameIndex = item.variableNamesIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Actor)
            {
                // Actor:
                item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames);
                item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames);
                var actorFieldType = GetWizardActorFieldType(item.actorFieldIndex);
                DrawValueSetMode(item, actorFieldType);
                switch (actorFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastActorNamesIndex = item.actorNamesIndex;
                s_lastActorFieldIndex = item.actorFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Item)
            {
                // Item:
                item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames);
                item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames);
                var itemFieldType = GetWizardItemFieldType(item.itemFieldIndex);
                DrawValueSetMode(item, itemFieldType);
                switch (itemFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastItemNamesIndex = item.itemNamesIndex;
                s_lastItemFieldIndex = item.itemFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Location)
            {
                // Location:
                item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames);
                item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames);
                var locationFieldType = GetWizardLocationFieldType(item.locationFieldIndex);
                DrawValueSetMode(item, locationFieldType);
                switch (locationFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastLocationNameIndex  = item.locationNamesIndex;
                s_lastLocationFieldIndex = item.locationFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.SimStatus)
            {
                // SimStatus:
                item.simStatusID   = EditorGUILayout.IntField(item.simStatusID, GUILayout.Width(50));
                item.simStatusType = (SimStatusType)EditorGUILayout.EnumPopup(item.simStatusType);
            }
            else if (item.resourceType == ScriptWizardResourceType.Alert)
            {
                // Alert:
                item.stringValue = EditorGUILayout.TextField(item.stringValue);
            }
            else if (item.resourceType == ScriptWizardResourceType.Custom)
            {
                // Custom Lua Functions:
                if (customLuaFuncs == null)
                {
                    FindAllCustomLuaFuncs(false, out customLuaFuncs, out customLuaFuncNames);
                }

                int newCustomLuaFuncIndex = EditorGUILayout.Popup(item.customLuaFuncIndex, customLuaFuncNames);
                if (newCustomLuaFuncIndex != item.customLuaFuncIndex)
                {
                    item.customLuaFuncIndex = newCustomLuaFuncIndex;
                    item.customParamValues  = null;
                }
                if (0 <= item.customLuaFuncIndex && item.customLuaFuncIndex < customLuaFuncs.Length)
                {
                    var luaFuncRecord = customLuaFuncs[item.customLuaFuncIndex];
                    if (item.customParamValues == null)
                    {
                        InitCustomParamValues(luaFuncRecord, out item.customParamValues);
                    }
                    for (int i = 0; i < luaFuncRecord.parameters.Length; i++)
                    {
                        switch (luaFuncRecord.parameters[i])
                        {
                        case CustomLuaParameterType.Bool:
                            item.customParamValues[i] = (BooleanType)EditorGUILayout.EnumPopup((BooleanType)item.customParamValues[i]);
                            break;

                        case CustomLuaParameterType.Double:
                            item.customParamValues[i] = EditorGUILayout.FloatField((float)item.customParamValues[i]);
                            break;

                        case CustomLuaParameterType.String:
                            item.customParamValues[i] = EditorGUILayout.TextField((string)item.customParamValues[i]);
                            break;

                        case CustomLuaParameterType.Actor:
                            item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], actorNames);
                            break;

                        case CustomLuaParameterType.Quest:
                            item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], questNames);
                            item.questNamesIndex      = (int)item.customParamValues[i];
                            break;

                        case CustomLuaParameterType.QuestEntry:
                            if ((item.scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length))
                            {
                                item.scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]);
                            }
                            item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], item.scriptQuestEntryNames);
                            break;

                        case CustomLuaParameterType.Variable:
                            item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], variableNames);
                            break;

                        case CustomLuaParameterType.Item:
                            item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], itemNames);
                            break;
                        }
                    }
                }
            }
            else if (item.resourceType == ScriptWizardResourceType.ManualEnter)
            {
                // Custom:
                item.stringValue = EditorGUILayout.TextField(item.stringValue);
            }

            if (GUILayout.Button(new GUIContent("-", "Delete this script action."), EditorStyles.miniButton, GUILayout.Width(22)))
            {
                itemToDelete = item;
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
        private void DrawScriptItem(ScriptItem item, ref ScriptItem itemToDelete)
        {
            EditorGUILayout.BeginHorizontal();

#if USE_UNET
            if (item.resourceType == ScriptWizardResourceType.Quest || item.resourceType == ScriptWizardResourceType.QuestEntry || item.resourceType == ScriptWizardResourceType.Variable)
            {
                item.netSetMode = (NetSetMode)EditorGUILayout.EnumPopup(item.netSetMode, GUILayout.Width(36));
            }
            else
            {
                item.netSetMode = NetSetMode.Set;
                EditorGUILayout.LabelField("Set", GUILayout.Width(32));
            }
#else
            EditorGUILayout.LabelField("Set", GUILayout.Width(32));
#endif
            ScriptWizardResourceType newResourceType = (ScriptWizardResourceType)EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96));
            if (newResourceType != item.resourceType)
            {
                item.resourceType          = newResourceType;
                item.scriptQuestEntryNames = new string[0];

                s_lastWizardResourceType = LuaWizardBase.GetScriptResourceTypeToConditionResourceType(newResourceType);
            }

            if (item.resourceType == ScriptWizardResourceType.Quest)
            {
                // Quest:
                item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames);
                EditorGUILayout.LabelField("to", GUILayout.Width(22));
                //---Was: item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96));
                item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96);

                s_lastQuestNamesIndex = item.questNamesIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.QuestEntry)
            {
                // Quest Entry:
                int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames);
                if (newQuestNamesIndex != item.questNamesIndex)
                {
                    item.questNamesIndex       = newQuestNamesIndex;
                    item.scriptQuestEntryNames = new string[0];
                }
                if ((item.scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length))
                {
                    item.scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]);
                }
                item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, item.scriptQuestEntryNames);
                EditorGUILayout.LabelField("to", GUILayout.Width(22));
                //---Was: item.questState = (QuestState) EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96));
                item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96);

                s_lastQuestNamesIndex = item.questNamesIndex;
                s_lastQuestEntryIndex = item.questEntryIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Variable)
            {
                // Variable:
                item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames);
                var variableType = GetWizardVariableType(item.variableNamesIndex);
                DrawValueSetMode(item, variableType);
                switch (variableType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastVariableNameIndex = item.variableNamesIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Actor)
            {
                // Actor:
                item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames);
                item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames);
                var actorFieldType = GetWizardActorFieldType(item.actorFieldIndex);
                DrawValueSetMode(item, actorFieldType);
                switch (actorFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastActorNamesIndex = item.actorNamesIndex;
                s_lastActorFieldIndex = item.actorFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Item)
            {
                // Item:
                item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames);
                item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames);
                var itemFieldType = GetWizardItemFieldType(item.itemFieldIndex);
                DrawValueSetMode(item, itemFieldType);
                switch (itemFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastItemNamesIndex = item.itemNamesIndex;
                s_lastItemFieldIndex = item.itemFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.Location)
            {
                // Location:
                item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames);
                item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames);
                var locationFieldType = GetWizardLocationFieldType(item.locationFieldIndex);
                DrawValueSetMode(item, locationFieldType);
                switch (locationFieldType)
                {
                case FieldType.Boolean:
                    item.booleanValue = (BooleanType)EditorGUILayout.EnumPopup(item.booleanValue);
                    break;

                case FieldType.Number:
                    item.floatValue = EditorGUILayout.FloatField(item.floatValue);
                    break;

                default:
                    item.stringValue = EditorGUILayout.TextField(item.stringValue);
                    break;
                }

                s_lastLocationNameIndex  = item.locationNamesIndex;
                s_lastLocationFieldIndex = item.locationFieldIndex;
            }
            else if (item.resourceType == ScriptWizardResourceType.SimStatus)
            {
                // SimStatus:
                item.simStatusID   = EditorGUILayout.IntField(item.simStatusID, GUILayout.Width(50));
                item.simStatusType = (SimStatusType)EditorGUILayout.EnumPopup(item.simStatusType);
            }
            else if (item.resourceType == ScriptWizardResourceType.Alert)
            {
                // Alert:
                item.stringValue = EditorGUILayout.TextField(item.stringValue);
            }
            else if (item.resourceType == ScriptWizardResourceType.Custom)
            {
                // Custom:
                item.stringValue = EditorGUILayout.TextField(item.stringValue);
            }

            if (GUILayout.Button(new GUIContent("-", "Delete this script action."), EditorStyles.miniButton, GUILayout.Width(22)))
            {
                itemToDelete = item;
            }
            EditorGUILayout.EndHorizontal();
        }