public void OpenNewSection(GameObject dynamicMenu)
    {
        if (MenuType == RPGMenuType.TabMenu)
        {
            //We simply show the menu
            if (this.HostWindowTabControlContent != null)
            {
                this.HostWindowTabControlContent.SetActive(false);
            }
            this.HostWindowTabControlContent = dynamicMenu;
            this.HostWindowTabControlContent.SetActive(true);
            return;
        }

        //Else: we are a regular RPG menu, clear the current menu and add this new section
        removeMenuItems();

        //Add to current stack MenuSections
        if (MenuSections == null)
        {
            MenuSections = new Stack <RPGMenuData>();
        }

        //The dynamicMenu parameter is a GameObject with RPGMenuSection component residing in the scene, which we need to copy over into the current menu
        RPGMenuData menuData = new RPGMenuData(dynamicMenu.name); //Todo use RPGMenuSection data

        for (int i = 0; i < dynamicMenu.transform.childCount; i++)
        {
            GameObject  child = dynamicMenu.transform.GetChild(i).gameObject;
            RPGMenuItem item  = child.GetComponent <RPGMenuItem>();

            if (item)
            {
                menuData.MenuItems.Add(item.MenuItemData);
            }
        }

        MenuSections.Push(menuData);

        //Add new menu items to current window
        drawCurrentMenuSection();
    }
    /********* Other **********/

    //Fill in MenuItems and the first section from what's already on the UI in the editor
    private void pickupUIElements()
    {
        string menuTitle = "Nameless menu";

        if (MenuTitle != null)
        {
            menuTitle = MenuTitle.text;
        }

        RPGMenuData currentMenu = new RPGMenuData(menuTitle);

        foreach (Transform trans in HostWindowCommandMenuContent.transform)
        {
            RPGMenuItem item = trans.GetComponent <RPGMenuItem>();
            if (item != null)
            {
                item.ParentMenu = this;
                menuItemsGO.Add(item);
                currentMenu.AddItem(item.MenuItemData);
            }
        }

        if (currentMenu.MenuItems.Count > 0)
        {
            //Add to current stack MenuSections
            if (MenuSections == null)
            {
                MenuSections = new Stack <RPGMenuData>();
            }

            MenuSections.Push(currentMenu);
            Debug.Log("Picking up UI: " + this.gameObject.name + " and creating new section");
        }
        else
        {
            Debug.LogError("Failed to pick up any menu items already in the menu (HostWindowCommandMenuContent). The data inside this menu might not have any RPGMenuItemData component attached?");
        }
    }
Beispiel #3
0
    public UINode GenerateRPGMenuNode(string menuName)
    {
        var node = new UINode()
        {
            title = menuName, IsEntryPoint = false, NodeGUID = Guid.NewGuid().ToString()
        };

        node.SetPosition(new Rect(StartPositionX, StartPositionY, 480, 180));
        node.AddInputPort("Input");

        RPGMenuData thisNodeData = new RPGMenuData(menuName);

        node.MenuData = thisNodeData;

        EnumField interactTypeField = new EnumField(RPGMenuActionType.NewWindow);

        node.Type = (RPGMenuActionType)interactTypeField.value;
        interactTypeField.RegisterValueChangedCallback((ev) => { node.Type = (RPGMenuActionType)ev.newValue; });
        if (numberOfRPGMenus > 0)
        {
            //Allow user to select what kind of menu it is
            node.titleContainer.Add(interactTypeField);
        }

        //Create button
        Button CreateMenuInEditorButton = new Button(() => { CreateMenuInEditor(node); });

        CreateMenuInEditorButton.text = "Build RPG Menu";
        node.titleButtonContainer.Add(CreateMenuInEditorButton);

        //Content Container
        var entryName = new TextField("Menu iten name");
        var helpText  = new TextField("Help text");

        node.contentContainer.Add(entryName);
        node.contentContainer.Add(helpText);

        var mpCost = new IntegerField(120);

        mpCost.label = "MP cost";
        var apCost = new IntegerField(6);

        apCost.label = "AP cost";
        node.contentContainer.Add(apCost);
        node.contentContainer.Add(mpCost);

        var actionParam = new TextField("Action Parameter");

        node.contentContainer.Add(actionParam);

        //Add output connectors
        Button addButton = new Button(() => { AddRPGMenuItemToNode(node, entryName.text, helpText.text, mpCost.value, apCost.value, actionParam.text); });

        addButton.text = "Add menu item";
        node.contentContainer.Add(addButton);

        node.RefreshExpandedState();
        node.RefreshPorts();

        StartPositionX += 40;

        return(node);
    }
Beispiel #4
0
 public RPGMenuNode(string menuName) : base()
 {
     MenuData = new RPGMenuData(menuName);
 }