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 rect = new Rect(x, 0, 96, EditorGUIUtility.singleLineHeight); x += rect.width + 2; WizardResourceType newConditionType = (WizardResourceType)EditorGUI.EnumPopup(rect, GUIContent.none, item.conditionType); if (newConditionType != item.conditionType) { item.conditionType = newConditionType; conditionsQuestEntryNames = new string[0]; } if (item.conditionType == WizardResourceType.Quest) { // Quest: var questNameWidth = position.width - (typeWidth + equalityWidth + questStateWidth + deleteButtonWidth + 8); rect = new Rect(x, 0, questNameWidth, EditorGUIUtility.singleLineHeight); x += rect.width + 2; item.questNamesIndex = EditorGUI.Popup(rect, item.questNamesIndex, questNames); rect = new Rect(x, 0, equalityWidth, EditorGUIUtility.singleLineHeight); item.equalityType = (EqualityType)EditorGUI.EnumPopup(rect, item.equalityType); x += rect.width + 2; rect = new Rect(x, 0, questStateWidth, EditorGUIUtility.singleLineHeight); item.questState = (QuestState)EditorGUI.EnumPopup(rect, item.questState); x += rect.width + 2; } else if (item.conditionType == WizardResourceType.QuestEntry) { // Quest Entry: var freeWidth = position.width - (typeWidth + equalityWidth + questStateWidth + deleteButtonWidth + 10); rect = new Rect(x, 0, freeWidth / 2, EditorGUIUtility.singleLineHeight); int newQuestNamesIndex = EditorGUI.Popup(rect, item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; conditionsQuestEntryNames = new string[0]; } if ((conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } x += rect.width + 2; rect = new Rect(x, 0, freeWidth / 2, EditorGUIUtility.singleLineHeight); item.questEntryIndex = EditorGUI.Popup(rect, item.questEntryIndex, conditionsQuestEntryNames); x += rect.width + 2; rect = new Rect(x, 0, equalityWidth, EditorGUIUtility.singleLineHeight); item.equalityType = (EqualityType)EditorGUI.EnumPopup(rect, item.equalityType); x += rect.width + 2; rect = new Rect(x, 0, questStateWidth, EditorGUIUtility.singleLineHeight); item.questState = (QuestState)EditorGUI.EnumPopup(rect, item.questState); x += rect.width + 2; } else if (item.conditionType == WizardResourceType.Variable) { // Variable: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 8); rect = new Rect(x, 0, freeWidth / 2, EditorGUIUtility.singleLineHeight); item.variableNamesIndex = EditorGUI.Popup(rect, item.variableNamesIndex, variableNames); x += rect.width + 2; rect = new Rect(x, 0, equalityWidth + 2 + (freeWidth / 2), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardVariableType(item.variableNamesIndex)); x += rect.width + 2; } else if (item.conditionType == WizardResourceType.Actor) { // Actor: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.actorNamesIndex = EditorGUI.Popup(rect, item.actorNamesIndex, actorNames); x += rect.width + 2; rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.actorFieldIndex = EditorGUI.Popup(rect, item.actorFieldIndex, actorFieldNames); x += rect.width + 2; rect = new Rect(x, 0, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardActorFieldType(item.actorFieldIndex)); x += rect.width + 2; } else if (item.conditionType == WizardResourceType.Item) { // Item: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.itemNamesIndex = EditorGUI.Popup(rect, item.itemNamesIndex, itemNames); x += rect.width + 2; rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.itemFieldIndex = EditorGUI.Popup(rect, item.itemFieldIndex, itemFieldNames); x += rect.width + 2; rect = new Rect(x, 0, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardItemFieldType(item.itemFieldIndex)); x += rect.width + 2; } else if (item.conditionType == WizardResourceType.Location) { // Location: var freeWidth = position.width - (typeWidth + equalityWidth + deleteButtonWidth + 10); rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.locationNamesIndex = EditorGUI.Popup(rect, item.locationNamesIndex, locationNames); x += rect.width + 2; rect = new Rect(x, 0, freeWidth / 3, EditorGUIUtility.singleLineHeight); item.locationFieldIndex = EditorGUI.Popup(rect, item.locationFieldIndex, locationFieldNames); x += rect.width + 2; rect = new Rect(x, 0, equalityWidth + 2 + (freeWidth / 3), EditorGUIUtility.singleLineHeight); DrawRightHand(rect, item, GetWizardLocationFieldType(item.locationFieldIndex)); x += rect.width + 2; } // Delete button: rect = new Rect(position.width - deleteButtonWidth, 0, 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(); EditorGUILayout.LabelField("Set", GUILayout.Width(32)); WizardResourceType newResourceType = (WizardResourceType)EditorGUILayout.EnumPopup(item.resourceType, GUILayout.Width(96)); if (newResourceType != item.resourceType) { item.resourceType = newResourceType; scriptQuestEntryNames = new string[0]; } if (item.resourceType == WizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); item.questState = (QuestState)EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.resourceType == WizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; scriptQuestEntryNames = new string[0]; } if ((scriptQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { scriptQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, scriptQuestEntryNames); EditorGUILayout.LabelField("to", GUILayout.Width(22)); item.questState = (QuestState)EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.resourceType == WizardResourceType.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 == WizardResourceType.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 == WizardResourceType.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 == WizardResourceType.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; } } if (GUILayout.Button(new GUIContent("-", "Delete this script action."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }
private void DrawConditionItem(ConditionItem item, ref ConditionItem itemToDelete) { EditorGUILayout.BeginHorizontal(); WizardResourceType newConditionType = (WizardResourceType)EditorGUILayout.EnumPopup(item.conditionType, GUILayout.Width(96)); if (newConditionType != item.conditionType) { item.conditionType = newConditionType; conditionsQuestEntryNames = new string[0]; } if (item.conditionType == WizardResourceType.Quest) { // Quest: item.questNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, questNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = (QuestState)EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.conditionType == WizardResourceType.QuestEntry) { // Quest Entry: int newQuestNamesIndex = EditorGUILayout.Popup(item.questNamesIndex, complexQuestNames); if (newQuestNamesIndex != item.questNamesIndex) { item.questNamesIndex = newQuestNamesIndex; conditionsQuestEntryNames = new string[0]; } if ((conditionsQuestEntryNames.Length == 0) && (item.questNamesIndex < complexQuestNames.Length)) { conditionsQuestEntryNames = GetQuestEntryNames(complexQuestNames[item.questNamesIndex]); } item.questEntryIndex = EditorGUILayout.Popup(item.questEntryIndex, conditionsQuestEntryNames); item.equalityType = (EqualityType)EditorGUILayout.EnumPopup(item.equalityType, GUILayout.Width(60)); item.questState = (QuestState)EditorGUILayout.EnumPopup(item.questState, GUILayout.Width(96)); } else if (item.conditionType == WizardResourceType.Variable) { // Variable: item.variableNamesIndex = EditorGUILayout.Popup(item.variableNamesIndex, variableNames); DrawRightHand(item, GetWizardVariableType(item.variableNamesIndex)); } else if (item.conditionType == WizardResourceType.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 == WizardResourceType.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 == WizardResourceType.Location) { // Location: item.locationNamesIndex = EditorGUILayout.Popup(item.locationNamesIndex, locationNames); item.locationFieldIndex = EditorGUILayout.Popup(item.locationFieldIndex, locationFieldNames); DrawRightHand(item, GetWizardLocationFieldType(item.locationFieldIndex)); } if (GUILayout.Button(new GUIContent("-", "Delete this condition."), EditorStyles.miniButton, GUILayout.Width(22))) { itemToDelete = item; } EditorGUILayout.EndHorizontal(); }