public ScriptItem() { resourceType = LuaWizardBase.GetConditionResourceTypeToScriptResourceType(s_lastWizardResourceType); questNamesIndex = s_lastQuestNamesIndex; questEntryIndex = s_lastQuestEntryIndex; actorNamesIndex = s_lastActorNamesIndex; actorFieldIndex = s_lastActorFieldIndex; itemNamesIndex = s_lastItemNamesIndex; itemFieldIndex = s_lastItemFieldIndex; locationNamesIndex = s_lastLocationNameIndex; locationFieldIndex = s_lastLocationFieldIndex; variableNamesIndex = s_lastVariableNameIndex; }
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(); 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 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(); }
public static ConditionWizardResourceType GetScriptResourceTypeToConditionResourceType(ScriptWizardResourceType scriptResourceType) { switch (scriptResourceType) { default: case ScriptWizardResourceType.Quest: return(ConditionWizardResourceType.Quest); case ScriptWizardResourceType.QuestEntry: return(ConditionWizardResourceType.QuestEntry); case ScriptWizardResourceType.Actor: return(ConditionWizardResourceType.Actor); case ScriptWizardResourceType.Item: return(ConditionWizardResourceType.Item); case ScriptWizardResourceType.Variable: return(ConditionWizardResourceType.Variable); case ScriptWizardResourceType.Location: return(ConditionWizardResourceType.Location); case ScriptWizardResourceType.SimStatus: return(ConditionWizardResourceType.SimStatus); case ScriptWizardResourceType.Custom: return(ConditionWizardResourceType.Custom); } }