private void DrawScriptItem(Rect position, ScriptItem item, ref ScriptItem itemToDelete) { const float setLabelWidth = 32; const float deleteButtonWidth = 22; int originalIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var x = position.x; var y = position.y; var rect = new Rect(x, y, setLabelWidth, EditorGUIUtility.singleLineHeight); EditorGUI.LabelField(rect, "Set"); x += rect.width + 2; rect = new Rect(x, y, 96, EditorGUIUtility.singleLineHeight); ScriptWizardResourceType newResourceType = (ScriptWizardResourceType)EditorGUI.EnumPopup(rect, item.resourceType); x += rect.width + 2; if (newResourceType != item.resourceType) { item.resourceType = newResourceType; item.scriptQuestEntryNames = new string[0]; } if (item.resourceType == ScriptWizardResourceType.Quest) { // Quest: var questNameWidth = Mathf.Max(1, position.width - x - 98 - 22); rect = new Rect(x, y, questNameWidth, rect.height); x += rect.width + 2; item.questNamesIndex = EditorGUI.Popup(rect, item.questNamesIndex, questNames); rect = new Rect(x, y, 22, rect.height); x += rect.width + 2; EditorGUI.LabelField(rect, "to"); rect = new Rect(x, y, 96, EditorGUIUtility.singleLineHeight); item.questState = QuestStateDrawer.RectQuestStatePopup(rect, item.questState); } else if (item.resourceType == ScriptWizardResourceType.QuestEntry) { // Quest Entry: var questNameWidth = Mathf.Max(1, position.width - x - 98 - 98 - 22); rect = new Rect(x, y, questNameWidth, EditorGUIUtility.singleLineHeight); x += rect.width + 2; int newQuestNamesIndex = EditorGUI.Popup(rect, 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]); } rect = new Rect(x, y, 96, EditorGUIUtility.singleLineHeight); x += rect.width + 2; item.questEntryIndex = EditorGUI.Popup(rect, item.questEntryIndex, item.scriptQuestEntryNames); rect = new Rect(x, y, 22, rect.height); x += rect.width + 2; EditorGUI.LabelField(rect, "to"); rect = new Rect(x, y, 96, EditorGUIUtility.singleLineHeight); item.questState = QuestStateDrawer.RectQuestStatePopup(rect, item.questState); } else if (item.resourceType == ScriptWizardResourceType.Variable) { // Variable: var availableWidth = position.width - rect.x - deleteButtonWidth - 2; var fieldWidth = availableWidth / 3; rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.variableNamesIndex = EditorGUI.Popup(rect, item.variableNamesIndex, variableNames); var variableType = GetWizardVariableType(item.variableNamesIndex); rect = new Rect(x, y, 40, rect.height); x += rect.width + 2; DrawValueSetMode(rect, item, variableType); rect = new Rect(x, y, fieldWidth - 1, rect.height); switch (variableType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUI.EnumPopup(rect, item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUI.FloatField(rect, item.floatValue); break; default: item.stringValue = EditorGUI.TextField(rect, item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Actor) { // Actor: var availableWidth = position.width - rect.x - deleteButtonWidth - 2; var fieldWidth = availableWidth / 4; rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.actorNamesIndex = EditorGUI.Popup(rect, item.actorNamesIndex, actorNames); rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.actorFieldIndex = EditorGUI.Popup(rect, item.actorFieldIndex, actorFieldNames); var actorFieldType = GetWizardActorFieldType(item.actorFieldIndex); rect = new Rect(x, y, 40, rect.height); x += rect.width + 2; DrawValueSetMode(rect, item, actorFieldType); rect = new Rect(position.x + position.width - deleteButtonWidth - 2 - fieldWidth - 2, y, fieldWidth - 1, rect.height); switch (actorFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUI.EnumPopup(rect, item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUI.FloatField(rect, item.floatValue); break; default: item.stringValue = EditorGUI.TextField(rect, item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Item) { // Item: var availableWidth = position.width - rect.x - deleteButtonWidth - 2; var fieldWidth = availableWidth / 4; rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.itemNamesIndex = EditorGUI.Popup(rect, item.itemNamesIndex, itemNames); rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.itemFieldIndex = EditorGUI.Popup(rect, item.itemFieldIndex, itemFieldNames); var itemFieldType = GetWizardItemFieldType(item.itemFieldIndex); rect = new Rect(x, y, 40 - 1, rect.height); x += rect.width + 2; DrawValueSetMode(rect, item, itemFieldType); rect = new Rect(position.x + position.width - deleteButtonWidth - 2 - fieldWidth - 2, y, fieldWidth - 1, rect.height); switch (itemFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUI.EnumPopup(rect, item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUI.FloatField(rect, item.floatValue); break; default: item.stringValue = EditorGUI.TextField(rect, item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.Location) { // Location: var availableWidth = position.width - rect.x - deleteButtonWidth - 2; var fieldWidth = availableWidth / 4; rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.locationNamesIndex = EditorGUI.Popup(rect, item.locationNamesIndex, locationNames); rect = new Rect(x, y, fieldWidth - 1, rect.height); x += rect.width + 2; item.locationFieldIndex = EditorGUI.Popup(rect, item.locationFieldIndex, locationFieldNames); var locationFieldType = GetWizardLocationFieldType(item.locationFieldIndex); rect = new Rect(x, y, 40 - 1, rect.height); x += rect.width + 2; DrawValueSetMode(rect, item, locationFieldType); rect = new Rect(position.x + position.width - deleteButtonWidth - 2 - fieldWidth - 2, y, fieldWidth - 1, rect.height); switch (locationFieldType) { case FieldType.Boolean: item.booleanValue = (BooleanType)EditorGUI.EnumPopup(rect, item.booleanValue); break; case FieldType.Number: item.floatValue = EditorGUI.FloatField(rect, item.floatValue); break; default: item.stringValue = EditorGUI.TextField(rect, item.stringValue); break; } } else if (item.resourceType == ScriptWizardResourceType.SimStatus) { // SimStatus: rect = new Rect(x, y, 50, rect.height); x += rect.width + 2; item.simStatusID = EditorGUI.IntField(rect, item.simStatusID); rect = new Rect(x, y, position.width - x - 2, rect.height); item.simStatusType = (SimStatusType)EditorGUI.EnumPopup(rect, item.simStatusType); } else if (item.resourceType == ScriptWizardResourceType.ManualEnter) { // Custom: rect = new Rect(x, y, position.width - rect.width - 2, rect.height); item.stringValue = EditorGUI.TextField(rect, item.stringValue); } rect = new Rect(position.x + position.width - deleteButtonWidth, y, deleteButtonWidth, EditorGUIUtility.singleLineHeight); if (GUI.Button(rect, new GUIContent("-", "Delete this condition."), EditorStyles.miniButton)) { itemToDelete = item; } EditorGUI.indentLevel = originalIndentLevel; }
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(); }
private void DrawScriptItem(ScriptItem item, ref ScriptItem itemToDelete) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Set", GUILayout.Width(32)); ScriptWizardResourceType newResourceType = (ScriptWizardResourceType)EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96)); if (newResourceType != item.resourceType) { item.resourceType = newResourceType; item.scriptQuestEntryNames = new string[0]; } 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); } 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); } 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; } } 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; } } 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; } } 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; } } 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(); }
private void DrawConditionItem(Rect position, ConditionItem item, ref ConditionItem itemToDelete) { const float typeWidth = 96; const float equalityWidth = 64; const float questStateWidth = 96; const float deleteButtonWidth = 22; int originalIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var x = position.x; var y = position.y; var rect = new Rect(x, y, 96, EditorGUIUtility.singleLineHeight); x += rect.width + 2; ConditionWizardResourceType newConditionType = (ConditionWizardResourceType)EditorGUI.EnumPopup(rect, GUIContent.none, item.conditionType); if (newConditionType != item.conditionType) { item.conditionType = newConditionType; item.conditionsQuestEntryNames = new string[0]; } if (item.conditionType == ConditionWizardResourceType.Quest) { // Quest: var questNameWidth = position.width - (typeWidth + equalityWidth + questStateWidth + deleteButtonWidth + 8); rect = new Rect(x, y, questNameWidth, EditorGUIUtility.singleLineHeight); x += rect.width + 2; item.questNamesIndex = EditorGUI.Popup(rect, item.questNamesIndex, questNames); rect = new Rect(x, y, equalityWidth, EditorGUIUtility.singleLineHeight); item.equalityType = (EqualityType)EditorGUI.EnumPopup(rect, item.equalityType); x += rect.width + 2; rect = new Rect(x, y, questStateWidth, EditorGUIUtility.singleLineHeight); item.questState = QuestStateDrawer.RectQuestStatePopup(rect, item.questState); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.QuestEntry) { // Quest Entry: var freeWidth = position.width - (typeWidth + equalityWidth + questStateWidth + deleteButtonWidth + 10); rect = new Rect(x, y, freeWidth / 2, EditorGUIUtility.singleLineHeight); int newQuestNamesIndex = EditorGUI.Popup(rect, item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; item.conditionsQuestEntryNames = new string[0]; } if ((item.conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { item.conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } x += rect.width + 2; rect = new Rect(x, y, freeWidth / 2, EditorGUIUtility.singleLineHeight); item.questEntryIndex = EditorGUI.Popup(rect, item.questEntryIndex, item.conditionsQuestEntryNames); x += rect.width + 2; rect = new Rect(x, y, equalityWidth, EditorGUIUtility.singleLineHeight); item.equalityType = (EqualityType)EditorGUI.EnumPopup(rect, item.equalityType); x += rect.width + 2; rect = new Rect(x, y, questStateWidth, EditorGUIUtility.singleLineHeight); item.questState = QuestStateDrawer.RectQuestStatePopup(rect, item.questState); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.Variable) { // Variable: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 8); rect = new Rect(x, y, freeWidth / 2, EditorGUIUtility.singleLineHeight); item.variableNamesIndex = EditorGUI.Popup(rect, item.variableNamesIndex, variableNames); x += rect.width + 2; rect = new Rect(x, y, equalityWidth + 2 + (freeWidth / 2), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardVariableType(item.variableNamesIndex)); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.Actor) { // Actor: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.actorNamesIndex = EditorGUI.Popup(rect, item.actorNamesIndex, actorNames); x += rect.width + 2; rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.actorFieldIndex = EditorGUI.Popup(rect, item.actorFieldIndex, actorFieldNames); x += rect.width + 2; rect = new Rect(x, y, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardActorFieldType(item.actorFieldIndex)); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.Item) { // Item: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.itemNamesIndex = EditorGUI.Popup(rect, item.itemNamesIndex, itemNames); x += rect.width + 2; rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.itemFieldIndex = EditorGUI.Popup(rect, item.itemFieldIndex, itemFieldNames); x += rect.width + 2; rect = new Rect(x, y, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardItemFieldType(item.itemFieldIndex)); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.Location) { // Location: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.locationNamesIndex = EditorGUI.Popup(rect, item.locationNamesIndex, locationNames); x += rect.width + 2; rect = new Rect(x, y, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.locationFieldIndex = EditorGUI.Popup(rect, item.locationFieldIndex, locationFieldNames); x += rect.width + 2; rect = new Rect(x, y, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardLocationFieldType(item.locationFieldIndex)); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.SimStatus) { // SimStatus: var freeWidth = position.width - (88 + 56 + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, y, 14, EditorGUIUtility.singleLineHeight); item.simStatusThisID = EditorGUI.Toggle(rect, GUIContent.none, item.simStatusThisID); rect = new Rect(x + 14, y, 38, EditorGUIUtility.singleLineHeight); if (item.simStatusThisID) { EditorGUI.LabelField(rect, "thisID"); } else { item.simStatusID = EditorGUI.IntField(rect, item.simStatusID); } x += rect.width + 14; rect = new Rect(x, y, 56, EditorGUIUtility.singleLineHeight); item.equalityType = (EqualityType)EditorGUI.EnumPopup(rect, item.equalityType); x += rect.width + 2; rect = new Rect(x, y, freeWidth, EditorGUIUtility.singleLineHeight); item.simStatusType = (SimStatusType)EditorGUI.EnumPopup(rect, item.simStatusType); x += rect.width + 2; } else if (item.conditionType == ConditionWizardResourceType.ManualEnter) { // Custom: rect = new Rect(x, y, position.width - (88 + deleteButtonWidth + 20), EditorGUIUtility.singleLineHeight); item.stringValue = EditorGUI.TextField(rect, item.stringValue); } // Delete button: rect = new Rect(position.x + position.width - deleteButtonWidth, y, deleteButtonWidth, EditorGUIUtility.singleLineHeight); if (GUI.Button(rect, new GUIContent("-", "Delete this condition."), EditorStyles.miniButton)) { itemToDelete = item; } EditorGUI.indentLevel = originalIndentLevel; }
private void DrawConditionItem(ConditionItem item, ref ConditionItem itemToDelete) { EditorGUILayout.BeginHorizontal(); ConditionWizardResourceType newConditionType = (ConditionWizardResourceType)EditorGUILayout.EnumPopup(item.conditionType, GUILayout.Width(96)); if (newConditionType != item.conditionType) { item.conditionType = newConditionType; item.conditionsQuestEntryNames = new string[0]; s_lastWizardResourceType = newConditionType; } if (item.conditionType == ConditionWizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); s_lastQuestNamesIndex = item.questNamesIndex; } else if (item.conditionType == ConditionWizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; item.conditionsQuestEntryNames = new string[0]; } if ((item.conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { item.conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, item.conditionsQuestEntryNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); s_lastQuestNamesIndex = item.questNamesIndex; s_lastQuestEntryIndex = item.questEntryIndex; } else if (item.conditionType == ConditionWizardResourceType.Variable) { // Variable: item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames); DrawRightHand(item, GetWizardVariableType(item.variableNamesIndex)); s_lastVariableNameIndex = item.variableNamesIndex; } else if (item.conditionType == ConditionWizardResourceType.Actor) { // Actor: item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames); item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames); DrawRightHand(item, GetWizardActorFieldType(item.actorFieldIndex)); s_lastActorNamesIndex = item.actorNamesIndex; s_lastActorFieldIndex = item.actorFieldIndex; } else if (item.conditionType == ConditionWizardResourceType.Item) { // Item: item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames); item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames); DrawRightHand(item, GetWizardItemFieldType(item.itemFieldIndex)); s_lastItemNamesIndex = item.itemNamesIndex; s_lastItemFieldIndex = item.itemFieldIndex; } else if (item.conditionType == ConditionWizardResourceType.Location) { // Location: item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames); item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames); DrawRightHand(item, GetWizardLocationFieldType(item.locationFieldIndex)); s_lastLocationNameIndex = item.locationNamesIndex; s_lastLocationFieldIndex = item.locationFieldIndex; } else if (item.conditionType == ConditionWizardResourceType.SimStatus) { // SimStatus: item.simStatusThisID = EditorGUILayout.Toggle(GUIContent.none, item.simStatusThisID, GUILayout.Width(14)); if (item.simStatusThisID) { EditorGUILayout.LabelField("thisID", GUILayout.Width(38)); } else { item.simStatusID = EditorGUILayout.IntField(item.simStatusID, GUILayout.Width(38)); } item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(56)); item.simStatusType = (SimStatusType)EditorGUILayout.EnumPopup(item.simStatusType); } else if (item.conditionType == ConditionWizardResourceType.Custom) { // Custom Lua Functions: if (customLuaFuncs == null) { FindAllCustomLuaFuncs(true, 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.conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { item.conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], item.conditionsQuestEntryNames); break; case CustomLuaParameterType.Variable: item.customParamValues[i] = EditorGUILayout.Popup((int)item.customParamValues[i], variableNames); break; } } switch (luaFuncRecord.returnValue) { case CustomLuaReturnType.Bool: DrawRightHand(item, FieldType.Boolean); break; case CustomLuaReturnType.Double: DrawRightHand(item, FieldType.Number); break; case CustomLuaReturnType.String: DrawRightHand(item, FieldType.Text); break; } } } else if (item.conditionType == ConditionWizardResourceType.ManualEnter) { // Custom: item.stringValue = EditorGUILayout.TextField(item.stringValue); } if (GUILayout.Button(new GUIContent("-", "Delete this condition."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }
private void DrawConditionItem(ConditionItem item, ref ConditionItem itemToDelete) { EditorGUILayout.BeginHorizontal(); ConditionWizardResourceType newConditionType = (ConditionWizardResourceType)EditorGUILayout.EnumPopup(item.conditionType, GUILayout.Width(96)); if (newConditionType != item.conditionType) { item.conditionType = newConditionType; item.conditionsQuestEntryNames = new string[0]; } if (item.conditionType == ConditionWizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); } else if (item.conditionType == ConditionWizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; item.conditionsQuestEntryNames = new string[0]; } if ((item.conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { item.conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, item.conditionsQuestEntryNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = QuestStateDrawer.LayoutQuestStatePopup(item.questState, 96); } else if (item.conditionType == ConditionWizardResourceType.Variable) { // Variable: item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames); DrawRightHand(item, GetWizardVariableType(item.variableNamesIndex)); } else if (item.conditionType == ConditionWizardResourceType.Actor) { // Actor: item.actorNamesIndex = EditorGUILayout.Popup(item.actorNamesIndex, actorNames); item.actorFieldIndex = EditorGUILayout.Popup(item.actorFieldIndex, actorFieldNames); DrawRightHand(item, GetWizardActorFieldType(item.actorFieldIndex)); } else if (item.conditionType == ConditionWizardResourceType.Item) { // Item: item.itemNamesIndex = EditorGUILayout.Popup(item.itemNamesIndex, itemNames); item.itemFieldIndex = EditorGUILayout.Popup(item.itemFieldIndex, itemFieldNames); DrawRightHand(item, GetWizardItemFieldType(item.itemFieldIndex)); } else if (item.conditionType == ConditionWizardResourceType.Location) { // Location: item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames); item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames); DrawRightHand(item, GetWizardLocationFieldType(item.locationFieldIndex)); } else if (item.conditionType == ConditionWizardResourceType.SimStatus) { // SimStatus: item.simStatusThisID = EditorGUILayout.Toggle(GUIContent.none, item.simStatusThisID, GUILayout.Width(14)); if (item.simStatusThisID) { EditorGUILayout.LabelField("thisID", GUILayout.Width(38)); } else { item.simStatusID = EditorGUILayout.IntField(item.simStatusID, GUILayout.Width(38)); } item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(56)); item.simStatusType = (SimStatusType)EditorGUILayout.EnumPopup(item.simStatusType); } else if (item.conditionType == ConditionWizardResourceType.Custom) { // Custom: item.stringValue = EditorGUILayout.TextField(item.stringValue); } if (GUILayout.Button(new GUIContent("-", "Delete this condition."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }