示例#1
0
        private void InvInteractionGUI()
        {
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Inventory interactions", EditorStyles.boldLabel);

            if (GUILayout.Button(addContent, EditorStyles.miniButtonRight, buttonWidth))
            {
                Undo.RecordObject(_target, "Create inventory interaction");
                _target.invButtons.Add(new Button());
                _target.provideInvInteraction = true;
            }
            EditorGUILayout.EndHorizontal();

            if (_target.provideInvInteraction)
            {
                if (inventoryManager)
                {
                    // Create a string List of the field's names (for the PopUp box)
                    List <string> labelList = new List <string>();
                    int           invNumber;

                    if (inventoryManager.items.Count > 0)
                    {
                        foreach (InvItem _item in inventoryManager.items)
                        {
                            labelList.Add(_item.label);
                        }

                        foreach (Button invButton in _target.invButtons)
                        {
                            invNumber = -1;

                            int    j       = 0;
                            string invName = "";
                            foreach (InvItem _item in inventoryManager.items)
                            {
                                // If an item has been removed, make sure selected variable is still valid
                                if (_item.id == invButton.invID)
                                {
                                    invNumber = j;
                                    invName   = _item.label;
                                    break;
                                }

                                j++;
                            }

                            if (invNumber == -1)
                            {
                                // Wasn't found (item was deleted?), so revert to zero
                                ACDebug.Log("Previously chosen item no longer exists!");
                                invNumber       = 0;
                                invButton.invID = 0;
                            }

                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();

                            invNumber = CustomGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray(), "", "The inventory item associated with the interaction");

                            // Re-assign variableID based on PopUp selection
                            invButton.invID = inventoryManager.items[invNumber].id;

                            if (settingsManager != null && settingsManager.CanGiveItems())
                            {
                                if (_target.GetComponent <Char>() != null || _target.GetComponentInParent <Char>() != null)
                                {
                                    invButton.selectItemMode = (SelectItemMode)EditorGUILayout.EnumPopup(invButton.selectItemMode, GUILayout.Width(70f));
                                }
                            }

                            if (GUILayout.Button("", CustomStyles.IconCog))
                            {
                                SideMenu("Inv", _target.invButtons.Count, _target.invButtons.IndexOf(invButton));
                            }


                            EditorGUILayout.EndHorizontal();
                            if (invName != "")
                            {
                                string label = invName;
                                if (_target.GetComponent <Char>() && settingsManager != null && settingsManager.CanGiveItems())
                                {
                                    label = invButton.selectItemMode.ToString() + " " + label;
                                }
                                ButtonGUI(invButton, label, _target.interactionSource, true);
                            }
                            else
                            {
                                ButtonGUI(invButton, "Inventory", _target.interactionSource, true);
                            }
                            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("No inventory items exist!");

                        for (int i = 0; i < _target.invButtons.Count; i++)
                        {
                            _target.invButtons[i].invID = -1;
                        }
                    }
                }
                else
                {
                    ACDebug.LogWarning("An InventoryManager is required to run the game properly - please open the Adventure Creator wizard and set one.");
                }
            }

            EditorGUILayout.EndVertical();
        }
示例#2
0
        private void ItemsGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            EditorGUILayout.LabelField("Unhandled events", CustomStyles.subHeader);
            EditorGUILayout.Space();

            unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine, "AC.KickStarter.runtimeInventory.unhandledCombine");
            unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot, "AC.KickStarter.runtimeInventory.unhandledHotspot");
            if (settingsManager != null && settingsManager.CanGiveItems())
            {
                unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive, "AC.KickStarter.runtimeInventory.unhandledGive");
            }

            passUnhandledHotspotAsParameter = CustomGUILayout.ToggleLeft("Pass Hotspot as GameObject parameter?", passUnhandledHotspotAsParameter, "AC.KickStarter.inventoryManager.passUnhandledHotspotAsParameter");
            if (passUnhandledHotspotAsParameter && unhandledHotspot != null)
            {
                EditorGUILayout.HelpBox("The Hotspot will be set as " + unhandledHotspot.name + "'s first parameter, which must be set to type 'GameObject'.", MessageType.Info);
            }

            List <string> binList = new List <string>();

            foreach (InvBin bin in bins)
            {
                binList.Add(bin.label);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
            CreateItemsGUI(binList.ToArray());
            EditorGUILayout.Space();

            if (selectedItem != null && items.Contains(selectedItem))
            {
                string apiPrefix = "AC.KickStarter.runtimeInventory.GetItem (" + selectedItem.id + ")";

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' settings", CustomStyles.subHeader);
                EditorGUILayout.Space();

                selectedItem.label    = CustomGUILayout.TextField("Name:", selectedItem.label, apiPrefix + ".label");
                selectedItem.altLabel = CustomGUILayout.TextField("Label (if not name):", selectedItem.altLabel, apiPrefix + ".altLabel");

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Category:", GUILayout.Width(146f));
                if (bins.Count > 0)
                {
                    binNumber          = GetBinSlot(selectedItem.binID);
                    binNumber          = CustomGUILayout.Popup(binNumber, binList.ToArray(), apiPrefix + ".binID");
                    selectedItem.binID = bins[binNumber].id;
                }
                else
                {
                    selectedItem.binID = -1;
                    EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f));
                }
                EditorGUILayout.EndHorizontal();

                selectedItem.carryOnStart = CustomGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart, apiPrefix + ".carryOnStart");
                if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory)
                {
                    selectedItem.carryOnStartNotDefault = CustomGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault, apiPrefix + ".carryOnStartNotDefault");
                    if (selectedItem.carryOnStartNotDefault)
                    {
                        selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID, apiPrefix + ".carryOnStartID");
                    }
                }

                selectedItem.canCarryMultiple = CustomGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple, apiPrefix + ".canCarryMultiple");
                if (selectedItem.canCarryMultiple)
                {
                    selectedItem.useSeparateSlots = CustomGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots, apiPrefix + ".useSeparateSlots");
                }
                if (selectedItem.carryOnStart && selectedItem.canCarryMultiple)
                {
                    selectedItem.count = CustomGUILayout.IntField("Quantity on start:", selectedItem.count, apiPrefix + ".count");
                }
                else
                {
                    selectedItem.count = 1;
                }

                selectedItem.overrideUseSyntax = CustomGUILayout.Toggle("Override 'Use' syntax?", selectedItem.overrideUseSyntax, apiPrefix + ".overrideUseSyntax");
                if (selectedItem.overrideUseSyntax)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f));
                    selectedItem.hotspotPrefix1.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix1.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                    selectedItem.hotspotPrefix2.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix2.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                    EditorGUILayout.EndHorizontal();
                }

                selectedItem.linkedPrefab = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Linked prefab:", selectedItem.linkedPrefab, false, apiPrefix + ".linkedPrefab");
                if (selectedItem.linkedPrefab != null)
                {
                    EditorGUILayout.HelpBox("This reference is only accessibly through scripting.", MessageType.Info);
                }

                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Main graphic:", GUILayout.Width(145));
                selectedItem.tex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (selectedItem.tex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".tex");
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Active graphic:", GUILayout.Width(145));
                selectedItem.activeTex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (selectedItem.activeTex, false, GUILayout.Width(70), GUILayout.Height(70), apiPrefix + ".activeTex");
                EditorGUILayout.EndHorizontal();


                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.selectInventoryDisplay == SelectInventoryDisplay.ShowSelectedGraphic)
                {
                    selectedItem.selectedTex = (Texture2D)CustomGUILayout.ObjectField <Texture2D> ("Selected graphic:", selectedItem.selectedTex, false, apiPrefix + ".selectedTex");
                }
                if (AdvGame.GetReferences().cursorManager != null)
                {
                    CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                    if (cursorManager.inventoryHandling == InventoryHandling.ChangeCursor || cursorManager.inventoryHandling == InventoryHandling.ChangeCursorAndHotspotLabel)
                    {
                        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        selectedItem.cursorIcon.ShowGUI(true, "Cursor (optional):", cursorManager.cursorRendering, apiPrefix + ".cursorIcon");
                        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                    }
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Standard interactions", CustomStyles.subHeader);
                if (settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences().cursorManager)
                {
                    CursorManager cursorManager = AdvGame.GetReferences().cursorManager;

                    List <string> iconList = new List <string>();
                    foreach (CursorIcon icon in cursorManager.cursorIcons)
                    {
                        iconList.Add(icon.label);
                    }

                    if (cursorManager.cursorIcons.Count > 0)
                    {
                        foreach (InvInteraction interaction in selectedItem.interactions)
                        {
                            EditorGUILayout.BeginHorizontal();
                            invNumber        = GetIconSlot(interaction.icon.id);
                            invNumber        = EditorGUILayout.Popup(invNumber, iconList.ToArray());
                            interaction.icon = cursorManager.cursorIcons[invNumber];

                            int    i        = selectedItem.interactions.IndexOf(interaction);
                            string autoName = selectedItem.label + "_" + interaction.icon.label;
                            interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList, apiPrefix + ".interactions[" + i + "].actionList", autoName);

                            if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                            {
                                Undo.RecordObject(this, "Delete interaction");
                                selectedItem.interactions.Remove(interaction);
                                break;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No interaction icons defined - please use the Cursor Manager", MessageType.Warning);
                    }
                    if (GUILayout.Button("Add interaction"))
                    {
                        Undo.RecordObject(this, "Add new interaction");
                        selectedItem.interactions.Add(new InvInteraction(cursorManager.cursorIcons[0]));
                    }
                }
                else
                {
                    string autoName = selectedItem.label + "_Use";
                    selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList, apiPrefix + ".useActionList", autoName);
                    if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0)
                    {
                        int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID) + 1;
                        if (selectedItem.useIconID == -1)
                        {
                            useCursor_int = 0;
                        }
                        useCursor_int = CustomGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray(true), apiPrefix + ".useIconID");

                        if (useCursor_int == 0)
                        {
                            selectedItem.useIconID = -1;
                        }
                        else if (cursorManager.cursorIcons.Count > (useCursor_int - 1))
                        {
                            selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int - 1].id;
                        }
                    }
                    else
                    {
                        selectedItem.useIconID = 0;
                    }
                    autoName = selectedItem.label + "_Examine";
                    selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList, apiPrefix + ".lookActionList", autoName);
                }

                if (settingsManager.CanSelectItems(false))
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Unhandled interactions", CustomStyles.subHeader);
                    string autoName = selectedItem.label + "_Unhandled_Hotspot";
                    selectedItem.unhandledActionList = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList, apiPrefix + ".unhandledActionList", autoName);
                    autoName = selectedItem.label + "_Unhandled_Combine";
                    selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList, apiPrefix + ".unhandledCombineActionList", autoName);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Combine interactions", CustomStyles.subHeader);
                for (int i = 0; i < selectedItem.combineActionList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    invNumber = GetArraySlot(selectedItem.combineID[i]);
                    invNumber = EditorGUILayout.Popup(invNumber, GetLabelList());
                    selectedItem.combineID[i] = items[invNumber].id;

                    string autoName = selectedItem.label + "_Combine_" + GetLabelList() [invNumber];
                    selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i], apiPrefix + ".combineActionList[" + i + "]", autoName);

                    if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                    {
                        Undo.RecordObject(this, "Delete combine event");
                        selectedItem.combineActionList.RemoveAt(i);
                        selectedItem.combineID.RemoveAt(i);
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (GUILayout.Button("Add combine event"))
                {
                    Undo.RecordObject(this, "Add new combine event");
                    selectedItem.combineActionList.Add(null);
                    selectedItem.combineID.Add(0);
                }

                // List all "reverse" inventory combinations
                string reverseCombinations = "";
                foreach (InvItem otherItem in items)
                {
                    if (otherItem != selectedItem)
                    {
                        if (otherItem.combineID.Contains(selectedItem.id))
                        {
                            reverseCombinations += "- " + otherItem.label + "\n";
                            continue;
                        }
                    }
                }
                if (reverseCombinations.Length > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.HelpBox("The following inventory items have combine interactions that reference this item:\n" + reverseCombinations, MessageType.Info);
                }

                if (invVars.Count > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Properties", CustomStyles.subHeader);

                    RebuildProperties(selectedItem);

                    // UI for setting property values
                    if (selectedItem.vars.Count > 0)
                    {
                        foreach (InvVar invVar in selectedItem.vars)
                        {
                            string label = invVar.label + ":";
                            if (invVar.label.Length == 0)
                            {
                                label = "Property " + invVar.id.ToString() + ":";
                            }

                            if (invVar.type == VariableType.Boolean)
                            {
                                if (invVar.val != 1)
                                {
                                    invVar.val = 0;
                                }
                                invVar.val = CustomGUILayout.Popup(label, invVar.val, boolType, apiPrefix + ".GetProperty (" + invVar.id + ").val");
                            }
                            else if (invVar.type == VariableType.Integer)
                            {
                                invVar.val = CustomGUILayout.IntField(label, invVar.val, apiPrefix + ".GetProperty (" + invVar.id + ").val");
                            }
                            else if (invVar.type == VariableType.PopUp)
                            {
                                invVar.val = CustomGUILayout.Popup(label, invVar.val, invVar.popUps, apiPrefix + ".GetProperty (" + invVar.id + ").val");
                            }
                            else if (invVar.type == VariableType.String)
                            {
                                invVar.textVal = CustomGUILayout.TextField(label, invVar.textVal, apiPrefix + ".GetProperty (" + invVar.id + ").textVal");
                            }
                            else if (invVar.type == VariableType.Float)
                            {
                                invVar.floatVal = CustomGUILayout.FloatField(label, invVar.floatVal, apiPrefix + ".GetProperty (" + invVar.id + ").floatVal");
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No properties have been defined that this inventory item can use.", MessageType.Info);
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }
示例#3
0
        private void ItemsGUI()
        {
            EditorGUILayout.LabelField("Unhandled events", EditorStyles.boldLabel);
            unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine);
            unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot);
            if (settingsManager != null && settingsManager.CanGiveItems())
            {
                unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive);
            }

            List <string> binList = new List <string>();

            foreach (InvBin bin in bins)
            {
                binList.Add(bin.label);
            }

            EditorGUILayout.Space();
            CreateItemsGUI(binList.ToArray());
            EditorGUILayout.Space();

            if (selectedItem != null && items.Contains(selectedItem))
            {
                EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' properties", EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical("Button");
                selectedItem.label    = EditorGUILayout.TextField("Name:", selectedItem.label);
                selectedItem.altLabel = EditorGUILayout.TextField("Label (if not name):", selectedItem.altLabel);

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Category:", GUILayout.Width(146f));
                if (bins.Count > 0)
                {
                    binNumber          = GetBinSlot(selectedItem.binID);
                    binNumber          = EditorGUILayout.Popup(binNumber, binList.ToArray());
                    selectedItem.binID = bins[binNumber].id;
                }
                else
                {
                    selectedItem.binID = -1;
                    EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f));
                }
                EditorGUILayout.EndHorizontal();

                selectedItem.tex = (Texture2D)EditorGUILayout.ObjectField("Texture:", selectedItem.tex, typeof(Texture2D), false);

                if (settingsManager && (settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive || settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot || (settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && settingsManager.inventoryInteractions == InventoryInteractions.Single)))
                {
                    selectedItem.activeTex = (Texture2D)EditorGUILayout.ObjectField("Active texture:", selectedItem.activeTex, typeof(Texture2D), false);
                }

                selectedItem.carryOnStart = EditorGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart);
                if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory)
                {
                    selectedItem.carryOnStartNotDefault = EditorGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault);
                    if (selectedItem.carryOnStartNotDefault)
                    {
                        selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID);
                    }
                }

                selectedItem.canCarryMultiple = EditorGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple);
                if (selectedItem.canCarryMultiple)
                {
                    selectedItem.useSeparateSlots = EditorGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots);
                }
                if (selectedItem.carryOnStart && selectedItem.canCarryMultiple)
                {
                    selectedItem.count = EditorGUILayout.IntField("Quantity on start:", selectedItem.count);
                }
                else
                {
                    selectedItem.count = 1;
                }

                selectedItem.overrideUseSyntax = EditorGUILayout.Toggle("Override 'Use' syntax?", selectedItem.overrideUseSyntax);
                if (selectedItem.overrideUseSyntax)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f));
                    selectedItem.hotspotPrefix1.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix1.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                    selectedItem.hotspotPrefix2.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix2.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Standard interactions", EditorStyles.boldLabel);
                if (settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences().cursorManager)
                {
                    CursorManager cursorManager = AdvGame.GetReferences().cursorManager;

                    List <string> iconList = new List <string>();
                    foreach (CursorIcon icon in cursorManager.cursorIcons)
                    {
                        iconList.Add(icon.label);
                    }

                    if (cursorManager.cursorIcons.Count > 0)
                    {
                        foreach (InvInteraction interaction in selectedItem.interactions)
                        {
                            EditorGUILayout.BeginHorizontal();
                            invNumber        = GetIconSlot(interaction.icon.id);
                            invNumber        = EditorGUILayout.Popup(invNumber, iconList.ToArray());
                            interaction.icon = cursorManager.cursorIcons[invNumber];

                            interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList);

                            if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                            {
                                Undo.RecordObject(this, "Delete interaction");
                                selectedItem.interactions.Remove(interaction);
                                break;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No interaction icons defined - please use the Cursor Manager", MessageType.Warning);
                    }
                    if (GUILayout.Button("Add interaction"))
                    {
                        Undo.RecordObject(this, "Add new interaction");
                        selectedItem.interactions.Add(new InvInteraction(cursorManager.cursorIcons[0]));
                    }
                }
                else
                {
                    selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList);
                    if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0)
                    {
                        int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID);
                        useCursor_int          = EditorGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray(useCursor_int));
                        selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int].id;
                    }
                    else
                    {
                        selectedItem.useIconID = 0;
                    }
                    selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList);
                }

                if (settingsManager.CanSelectItems(false))
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Unhandled interactions", EditorStyles.boldLabel);
                    selectedItem.unhandledActionList        = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList);
                    selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Combine interactions", EditorStyles.boldLabel);
                for (int i = 0; i < selectedItem.combineActionList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    invNumber = GetArraySlot(selectedItem.combineID[i]);
                    invNumber = EditorGUILayout.Popup(invNumber, GetLabelList());
                    selectedItem.combineID[i] = items[invNumber].id;

                    selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i]);

                    if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                    {
                        Undo.RecordObject(this, "Delete combine event");
                        selectedItem.combineActionList.RemoveAt(i);
                        selectedItem.combineID.RemoveAt(i);
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (GUILayout.Button("Add combine event"))
                {
                    Undo.RecordObject(this, "Add new combine event");
                    selectedItem.combineActionList.Add(null);
                    selectedItem.combineID.Add(0);
                }

                EditorGUILayout.EndVertical();
            }
        }
示例#4
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            selectType = (InventorySelectType)EditorGUILayout.EnumPopup("Select type:", selectType);
            if (selectType == InventorySelectType.DeselectActive)
            {
                AfterRunningOption();
                return;
            }

            if (!inventoryManager)
            {
                inventoryManager = AdvGame.GetReferences().inventoryManager;
            }
            if (!settingsManager)
            {
                settingsManager = AdvGame.GetReferences().settingsManager;
            }

            if (inventoryManager)
            {
                // Create a string List of the field's names (for the PopUp box)
                List <string> labelList = new List <string>();

                int i = 0;
                if (parameterID == -1)
                {
                    invNumber = -1;
                }

                if (inventoryManager.items.Count > 0)
                {
                    foreach (InvItem _item in inventoryManager.items)
                    {
                        labelList.Add(_item.label);

                        // If an item has been removed, make sure selected variable is still valid
                        if (_item.id == invID)
                        {
                            invNumber = i;
                        }

                        i++;
                    }

                    if (invNumber == -1)
                    {
                        ACDebug.LogWarning("Previously chosen item no longer exists!");
                        invNumber = 0;
                        invID     = 0;
                    }

                    parameterID = Action.ChooseParameterGUI("Inventory item:", parameters, parameterID, ParameterType.InventoryItem);
                    if (parameterID >= 0)
                    {
                        invNumber = Mathf.Min(invNumber, inventoryManager.items.Count - 1);
                        invID     = -1;
                    }
                    else
                    {
                        invNumber = EditorGUILayout.Popup("Inventory item:", invNumber, labelList.ToArray());
                        invID     = inventoryManager.items[invNumber].id;
                    }

                    giveToPlayer = EditorGUILayout.Toggle("Add if not held?", giveToPlayer);

                    if (settingsManager && settingsManager.CanGiveItems())
                    {
                        selectItemMode = (SelectItemMode)EditorGUILayout.EnumPopup("Select item mode:", selectItemMode);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("No inventory items exist!", MessageType.Info);
                    invID     = -1;
                    invNumber = -1;
                }
            }
            AfterRunningOption();
        }
示例#5
0
        private void ItemsGUI()
        {
            EditorGUILayout.LabelField("Unhandled events", EditorStyles.boldLabel);
            unhandledCombine = ActionListAssetMenu.AssetGUI("Combine:", unhandledCombine);
            unhandledHotspot = ActionListAssetMenu.AssetGUI("Use on hotspot:", unhandledHotspot);
            if (settingsManager != null && settingsManager.CanGiveItems())
            {
                unhandledGive = ActionListAssetMenu.AssetGUI("Give to NPC:", unhandledGive);
            }

            List <string> binList = new List <string>();

            foreach (InvBin bin in bins)
            {
                binList.Add(bin.label);
            }

            EditorGUILayout.Space();
            CreateItemsGUI(binList.ToArray());
            EditorGUILayout.Space();

            if (selectedItem != null && items.Contains(selectedItem))
            {
                EditorGUILayout.LabelField("Inventory item '" + selectedItem.label + "' settings", EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical("Button");
                selectedItem.label    = EditorGUILayout.TextField("Name:", selectedItem.label);
                selectedItem.altLabel = EditorGUILayout.TextField("Label (if not name):", selectedItem.altLabel);

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Category:", GUILayout.Width(146f));
                if (bins.Count > 0)
                {
                    binNumber          = GetBinSlot(selectedItem.binID);
                    binNumber          = EditorGUILayout.Popup(binNumber, binList.ToArray());
                    selectedItem.binID = bins[binNumber].id;
                }
                else
                {
                    selectedItem.binID = -1;
                    EditorGUILayout.LabelField("No categories defined!", EditorStyles.miniLabel, GUILayout.Width(146f));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Main graphic:", GUILayout.Width(145));
                selectedItem.tex = (Texture2D)EditorGUILayout.ObjectField(selectedItem.tex, typeof(Texture2D), false, GUILayout.Width(70), GUILayout.Height(70));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Active graphic:", GUILayout.Width(145));
                selectedItem.activeTex = (Texture2D)EditorGUILayout.ObjectField(selectedItem.activeTex, typeof(Texture2D), false, GUILayout.Width(70), GUILayout.Height(70));
                EditorGUILayout.EndHorizontal();

                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.selectInventoryDisplay == SelectInventoryDisplay.ShowSelectedGraphic)
                {
                    selectedItem.selectedTex = (Texture2D)EditorGUILayout.ObjectField("Selected graphic:", selectedItem.selectedTex, typeof(Texture2D), false);
                }
                if (AdvGame.GetReferences().cursorManager != null)
                {
                    CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                    if (cursorManager.inventoryHandling == InventoryHandling.ChangeCursor || cursorManager.inventoryHandling == InventoryHandling.ChangeCursorAndHotspotLabel)
                    {
                        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        selectedItem.cursorIcon.ShowGUI(true, cursorManager.cursorRendering, "Cursor (optional):");
                        GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                    }
                }

                selectedItem.carryOnStart = EditorGUILayout.Toggle("Carry on start?", selectedItem.carryOnStart);
                if (selectedItem.carryOnStart && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.playerSwitching == PlayerSwitching.Allow && !AdvGame.GetReferences().settingsManager.shareInventory)
                {
                    selectedItem.carryOnStartNotDefault = EditorGUILayout.Toggle("Give to non-default player?", selectedItem.carryOnStartNotDefault);
                    if (selectedItem.carryOnStartNotDefault)
                    {
                        selectedItem.carryOnStartID = ChoosePlayerGUI(selectedItem.carryOnStartID);
                    }
                }

                selectedItem.canCarryMultiple = EditorGUILayout.Toggle("Can carry multiple?", selectedItem.canCarryMultiple);
                if (selectedItem.canCarryMultiple)
                {
                    selectedItem.useSeparateSlots = EditorGUILayout.Toggle("Place in separate slots?", selectedItem.useSeparateSlots);
                }
                if (selectedItem.carryOnStart && selectedItem.canCarryMultiple)
                {
                    selectedItem.count = EditorGUILayout.IntField("Quantity on start:", selectedItem.count);
                }
                else
                {
                    selectedItem.count = 1;
                }

                selectedItem.overrideUseSyntax = EditorGUILayout.Toggle("Override 'Use' syntax?", selectedItem.overrideUseSyntax);
                if (selectedItem.overrideUseSyntax)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Use syntax:", GUILayout.Width(100f));
                    selectedItem.hotspotPrefix1.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix1.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(item)", GUILayout.MaxWidth(40f));
                    selectedItem.hotspotPrefix2.label = EditorGUILayout.TextField(selectedItem.hotspotPrefix2.label, GUILayout.MaxWidth(80f));
                    EditorGUILayout.LabelField("(hotspot)", GUILayout.MaxWidth(55f));
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Standard interactions", EditorStyles.boldLabel);
                if (settingsManager && settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && settingsManager.inventoryInteractions == InventoryInteractions.Multiple && AdvGame.GetReferences().cursorManager)
                {
                    CursorManager cursorManager = AdvGame.GetReferences().cursorManager;

                    List <string> iconList = new List <string>();
                    foreach (CursorIcon icon in cursorManager.cursorIcons)
                    {
                        iconList.Add(icon.label);
                    }

                    if (cursorManager.cursorIcons.Count > 0)
                    {
                        foreach (InvInteraction interaction in selectedItem.interactions)
                        {
                            EditorGUILayout.BeginHorizontal();
                            invNumber        = GetIconSlot(interaction.icon.id);
                            invNumber        = EditorGUILayout.Popup(invNumber, iconList.ToArray());
                            interaction.icon = cursorManager.cursorIcons[invNumber];

                            interaction.actionList = ActionListAssetMenu.AssetGUI("", interaction.actionList);

                            if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                            {
                                Undo.RecordObject(this, "Delete interaction");
                                selectedItem.interactions.Remove(interaction);
                                break;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No interaction icons defined - please use the Cursor Manager", MessageType.Warning);
                    }
                    if (GUILayout.Button("Add interaction"))
                    {
                        Undo.RecordObject(this, "Add new interaction");
                        selectedItem.interactions.Add(new InvInteraction(cursorManager.cursorIcons[0]));
                    }
                }
                else
                {
                    selectedItem.useActionList = ActionListAssetMenu.AssetGUI("Use:", selectedItem.useActionList);
                    if (cursorManager && cursorManager.allowInteractionCursorForInventory && cursorManager.cursorIcons.Count > 0)
                    {
                        int useCursor_int = cursorManager.GetIntFromID(selectedItem.useIconID);
                        useCursor_int          = EditorGUILayout.Popup("Use cursor icon:", useCursor_int, cursorManager.GetLabelsArray());
                        selectedItem.useIconID = cursorManager.cursorIcons[useCursor_int].id;
                    }
                    else
                    {
                        selectedItem.useIconID = 0;
                    }
                    selectedItem.lookActionList = ActionListAssetMenu.AssetGUI("Examine:", selectedItem.lookActionList);
                }

                if (settingsManager.CanSelectItems(false))
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Unhandled interactions", EditorStyles.boldLabel);
                    selectedItem.unhandledActionList        = ActionListAssetMenu.AssetGUI("Unhandled use on Hotspot:", selectedItem.unhandledActionList);
                    selectedItem.unhandledCombineActionList = ActionListAssetMenu.AssetGUI("Unhandled combine:", selectedItem.unhandledCombineActionList);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Combine interactions", EditorStyles.boldLabel);
                for (int i = 0; i < selectedItem.combineActionList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    invNumber = GetArraySlot(selectedItem.combineID[i]);
                    invNumber = EditorGUILayout.Popup(invNumber, GetLabelList());
                    selectedItem.combineID[i] = items[invNumber].id;

                    selectedItem.combineActionList[i] = ActionListAssetMenu.AssetGUI("", selectedItem.combineActionList[i]);

                    if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                    {
                        Undo.RecordObject(this, "Delete combine event");
                        selectedItem.combineActionList.RemoveAt(i);
                        selectedItem.combineID.RemoveAt(i);
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (GUILayout.Button("Add combine event"))
                {
                    Undo.RecordObject(this, "Add new combine event");
                    selectedItem.combineActionList.Add(null);
                    selectedItem.combineID.Add(0);
                }

                // List all "reverse" inventory combinations
                string reverseCombinations = "";
                foreach (InvItem otherItem in items)
                {
                    if (otherItem != selectedItem)
                    {
                        if (otherItem.combineID.Contains(selectedItem.id))
                        {
                            reverseCombinations += "- " + otherItem.label + "\n";
                            continue;
                        }
                    }
                }
                if (reverseCombinations.Length > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.HelpBox("The following inventory items have combine interactions that reference this item:\n" + reverseCombinations, MessageType.Info);
                }

                if (invVars.Count > 0)
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Properties", EditorStyles.boldLabel);

                    RebuildProperties(selectedItem);

                    // UI for setting property values
                    if (selectedItem.vars.Count > 0)
                    {
                        foreach (InvVar invVar in selectedItem.vars)
                        {
                            string label = invVar.label + ":";
                            if (invVar.label.Length == 0)
                            {
                                label = "Property " + invVar.id.ToString() + ":";
                            }

                            if (invVar.type == VariableType.Boolean)
                            {
                                if (invVar.val != 1)
                                {
                                    invVar.val = 0;
                                }
                                invVar.val = EditorGUILayout.Popup(label, invVar.val, boolType);
                            }
                            else if (invVar.type == VariableType.Integer)
                            {
                                invVar.val = EditorGUILayout.IntField(label, invVar.val);
                            }
                            else if (invVar.type == VariableType.PopUp)
                            {
                                invVar.val = EditorGUILayout.Popup(label, invVar.val, invVar.popUps);
                            }
                            else if (invVar.type == VariableType.String)
                            {
                                invVar.textVal = EditorGUILayout.TextField(label, invVar.textVal);
                            }
                            else if (invVar.type == VariableType.Float)
                            {
                                invVar.floatVal = EditorGUILayout.FloatField(label, invVar.floatVal);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("No properties have been defined that this inventory item can use.", MessageType.Info);
                    }
                }

                EditorGUILayout.EndVertical();
            }
        }