Exemplo n.º 1
0
    private bool OnGuiBot(SerializablePropertys data, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect)
    {
        if (data == null)
        {
            return(false);
        }
        float yGui      = rect.y + 4;
        float widthLeft = 200;

        AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Edit property:");
        yGui += 32f;
        {
            comboBoxSlug.UpdateListContent(data.AllKey);
            comboBoxSlug.Empty             = "Not selected";
            comboBoxSlug.SelectedItemIndex = slugIndext;
            comboBoxSlug.Rect.x            = rect.x;
            comboBoxSlug.Rect.y            = yGui;
            comboBoxSlug.Rect.width        = widthLeft;
            comboBoxSlug.Rect.height       = 32f;
            comboBoxSlug.Show(rect.height - yGui, "defause", true, false, (int next) => {
                slugIndext = next;
            });
        }
        // if(comboBoxSlug.IsDropDownListVisible){
        //  return true;
        // }
        yGui   = rect.y + 4;
        rect.x = rect.x + widthLeft + 4;
        if (slugIndext < 0 || slugIndext >= data.AllKey.Count)
        {
            return(true);
        }

        AONGUI.Button(new Rect(rect.x, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Remove by slug", () => {
            data.Remove(slugIndext);
        });

        SerializablePropertys.Property property = data.PropertyByIndex(slugIndext);
        AONGUI.Button(new Rect(rect.x + 130, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Duplicate by slug", () => {
            var n = data.Copy(slugIndext);
            if (n >= 0)
            {
                slugIndext = n;
            }
        });
        yGui += 32f;
        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Name");
        AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Name, (string text) => {
            property.Name = text;
        });
        yGui += 32f;

        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Des");
        AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Des, (string text) => {
            property.Des = text;
        });
        yGui += 32f;

        string[] strType = SerializablePropertys.StrEType;
        AONGUI.SelectionGrid(new Rect(rect.x, yGui, rect.width, 24f), (int)property._Type, strType, strType.Length, tilesetAON.ListStyleGrid, (int next) => {
            var tNext = (SerializablePropertys.EType)next;
            if (tNext != property._Type)
            {
                property._Type = tNext;
            }
        });

        yGui += 32f;

        // if(property.IsItem){
        //  property.StackInBag = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.StackInBag, "Can Stack in bag");
        //  yGui += 32f;
        // }

        // property.CanEquip = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanEquip, " Can Equip");
        if (property.IsOutfit)
        {
            // float xGui = rect.x + widthLeft + 4;
            float xGui = rect.x;
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Item :");
            xGui += 60;
            string[] str         = AutoTileMap_Editor.Instance.ItemCharData.StrItemList;
            var      combobox    = ComboBoxHelper.Instance.StringN(str);
            var      hash        = "item";
            int      currentItem = ComboBoxHelper.Instance.IndextOfStringN(str, property.RefSlug);
            if (currentItem == -1)
            {
                if (property.RefSlug != null && property.RefSlug != "")
                {
                    combobox.Empty = property.RefSlug + " (not found)";
                }
                else
                {
                    combobox.Empty = "NULL";
                }
            }
            combobox.SelectedItemIndex = currentItem;
            combobox.Rect.x            = xGui;
            combobox.Rect.y            = yGui;
            combobox.Rect.width        = widthLeft;
            combobox.Rect.height       = 32f;
            float limitHeight = 32f * 6;
            combobox.Show(limitHeight, hash, (int nextItem) => {
                property.RefSlug = str[nextItem];
            });
            if (combobox.IsDropDownWithHash(hash))
            {
                yGui += limitHeight;
                return(false);
            }
            yGui += 32f;
        }

        // property.CanUsing = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanUsing, " Can Using");
        if (property.IsItem)
        {
            // float xGui = rect.x + widthLeft + 4;
            float xGui = rect.x;
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Action :");
            xGui += 60;
            var combobox          = ComboBoxHelper.Instance.FlagAction(listFlagAction);
            var hash              = "property";
            int currentFlagAction = FlagAction.IndextFlagAction(listFlagAction, property.ActionUsing);
            if (currentFlagAction == -1)
            {
                if (property.ActionUsing != null && property.ActionUsing != "")
                {
                    combobox.Empty = property.ActionUsing + " (not found)";
                }
                else
                {
                    combobox.Empty = "NULL";
                }
            }
            combobox.SelectedItemIndex = currentFlagAction;
            combobox.Rect.x            = xGui;
            combobox.Rect.y            = yGui;
            combobox.Rect.width        = widthLeft;
            combobox.Rect.height       = 32f;
            float limitHeight = 32f * 6;
            combobox.Show(limitHeight, hash, (int nextAction) => {
                property.ActionUsing = listFlagAction[nextAction].Name;
            });
            if (combobox.IsDropDownWithHash(hash))
            {
                yGui += limitHeight;
                return(false);
            }
            yGui += 32f;
        }

        // property.Consume = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.Consume, "Consumable");
        // yGui += 32f;

        if (property.IsPet)
        {
            AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Pet");
            AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefSlug, (string text) => {
                property.RefSlug = text;
            });

            AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => {
                InputFieldHelper.Instance.ShowPickModel((string topic, string pet) => {
                    Debug.Log(topic + "/" + pet);
                    property.RefSlug = topic + "/" + pet;
                    InputFieldHelper.Instance.HidePickModel();
                });
            });
            yGui += 32f;
        }

        if (property.IsItem || property.IsCertificates)
        {
            AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Icon");
            AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefIcon, (string text) => {
                property.RefIcon = text;
            });
            AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => {
                InputFieldHelper.Instance.ShowPickIcon((string topic, string icon) => {
                    // Debug.Log(topic + "/" + icon);
                    property.RefIcon = topic + "/" + icon;
                    InputFieldHelper.Instance.HidePickIcon();
                });
            });
            yGui += 32f;
        }
        return(false);
    }
Exemplo n.º 2
0
    public static bool OnGUIFlagActionList(ref float yGui, ref bool waitUI, Rect rect, List <FlagAction> flagAction, Flags flagsYaml, GUIStyle backgroundTop)
    {
        if (backgroundTop != null)
        {
            float height_top = 68;
            AONGUI.Box(new Rect(rect.x, rect.y, rect.width, height_top), "", backgroundTop);
        }
        AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, rect.width, DefineAON.GUI_Height_Label), "Action flag edit :");
        yGui += 32f;
        {
            //Add Key
            float xGui = rect.x + 4;
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 90, DefineAON.GUI_Height_Label), "Slug action");
            xGui += 94;
            AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, 200, DefineAON.GUI_Height_TextField), NameAdd, (string text) => {
                NameAdd = text;
            });
            xGui += 204;
            if (NameAdd.Length == 0)
            {
            }
            else
            {
                bool isUnique = (IndextFlagAction(flagAction, NameAdd) == -1);

                if (isUnique)
                {
                    AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, 40, DefineAON.GUI_Height_Button), "Add", () => {
                        flagAction.Add(new FlagAction()
                        {
                            Name = NameAdd
                        });
                        NameAdd = "";
                    });
                }
                else
                {
                    AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 200, DefineAON.GUI_Height_Label), "Slug should be unique");
                }
            }
            yGui += 32f;
        }
        float size_sub_remove = 70;
        float size_next       = 120;
        float size_o          = 80;
        float size_v          = 50;
        float size_text       = (rect.width - size_sub_remove - size_v - size_o - size_next - 8) / 2;

        for (int k = 0; k < flagAction.Count; k++)
        {
            if (k == 0)
            {
                yGui += 32f;
                continue;
            }
            float      xGui = rect.x + 4;
            FlagAction f    = flagAction[k];

            /*
             * if(k > 0){
             *      var name_next = GUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name, 25);
             *      if(name_next != f.Name){
             *              f.Name = name_next;
             *              return true;
             *      }
             * }else{
             *      GUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name);
             * }
             */
            if (k == 1)
            {
                AONGUI.Label(new Rect(xGui, yGui - 25, size_next, 24), "Slug:");
            }
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_text - 4, DefineAON.GUI_Height_TextField), f.Name);
            xGui += size_text;
            if (k == 1)
            {
                AONGUI.Label(new Rect(xGui, yGui - 25, size_next, 24), "Flag:");
            }
            {
                var comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.Key);
                int index_key     = FlagGui.Instance.IndexOfKey(f.Key);
                comboBoxFlags.SelectedItemIndex = index_key;
                comboBoxFlags.Rect.x            = xGui;
                comboBoxFlags.Rect.y            = yGui;
                comboBoxFlags.Rect.width        = size_text - 4;
                comboBoxFlags.Rect.height       = 32f;
                // float limitHeight = rect.height - yGui - 32;
                float limitHeight = 32 * 6f;
                comboBoxFlags.Show(limitHeight, k.ToString(), (int flagNext) => {
                    f.Key = FlagGui.Instance.KeyFromIndex(flagNext);
                });
                if (comboBoxFlags.IsDropDownWithHash(k.ToString()))
                {
                    yGui  += limitHeight;
                    waitUI = true;
                    return(false);
                }
            }
            xGui += size_text;
            {             //Operation
                int current           = f.Operation;
                var comboBoxOperation = ComboBoxHelper.Instance.Operation();
                comboBoxOperation.SelectedItemIndex = current;
                comboBoxOperation.Rect.x            = xGui;
                comboBoxOperation.Rect.y            = yGui;
                comboBoxOperation.Rect.width        = size_o - 4;
                comboBoxOperation.Rect.height       = 32f;
                float limitHeight = 32f * comboBoxOperation.ListContent.Length;
                comboBoxOperation.Show(limitHeight, k.ToString(), false, (int next) => {
                    f.Operation = next;
                });
                if (comboBoxOperation.IsDropDownWithHash(k.ToString()))
                {
                    yGui  += limitHeight;
                    waitUI = true;
                    return(false);
                }
            }
            float xGuiOperation = xGui;
            xGui += size_o;
            bool isHasInputValue = f.Operation < (int)AON.RpgMapEditor.ScriptGui.EOperation.Add_A_B;
            {
                if (isHasInputValue)
                {
                    AONGUI.TextField(new Rect(xGui, yGui + DefineAON.GUI_Y_TextField, size_v - 10, DefineAON.GUI_Height_TextField), f.Value.ToString(), 25, (string text) => {
                        f.Value = UtilsAON.StrToIntDef(text);
                    });
                }
                xGui += size_v;
                {
                    //Next ( add) Action
                    if (k == 1)
                    {
                        AONGUI.Label(new Rect(xGui + 10, yGui - 25, size_next, 24), "Add action:");
                    }
                    var combobox          = ComboBoxHelper.Instance.FlagAction(flagAction);
                    var hash              = k.ToString();
                    int currentFlagAction = FlagAction.IndextFlagAction(flagAction, f.Next);
                    if (currentFlagAction == -1)
                    {
                        if (f.Next != null && f.Next != "")
                        {
                            combobox.Empty = f.Next + " (not found)";
                        }
                        else
                        {
                            combobox.Empty = "NULL";
                        }
                    }
                    combobox.SelectedItemIndex = currentFlagAction;
                    combobox.Rect.x            = xGui + 10;
                    combobox.Rect.y            = yGui + 2;
                    combobox.Rect.width        = size_next - 20;
                    combobox.Rect.height       = 32f;
                    float limitHeight = 32f * 6;
                    combobox.Show(limitHeight, hash, (int nextAction) => {
                        f.Next = flagAction[nextAction].Name;
                    });
                    if (combobox.IsDropDownWithHash(hash))
                    {
                        yGui  += limitHeight;
                        waitUI = true;
                        return(false);
                    }
                    xGui += size_next;
                }
                AONGUI.Button(new Rect(xGui, yGui + DefineAON.GUI_Y_Button, size_sub_remove - 4, DefineAON.GUI_Height_Button), "Remove", () => {
                    flagAction.RemoveAt(k);
                });
            }

            /*
             * xGui += size_sub_e;
             * if(GUI.Button( new Rect(xGui, yGui + DefineAON.GUI_Y_Button, size_sub_e - 4, DefineAON.GUI_Height_Button), " + ")){
             *      FlagAction.Insert(k + 1, new FlagAction());
             *      return true;
             * }
             */

            if (!isHasInputValue)
            {
                yGui += 32f;
                // float size_ab = (rect.x + rect.width - xGuiOperation - size_sub_remove) / 2;
                float size_ab = size_o + size_v;
                xGui = xGuiOperation;
                AONGUI.Label(new Rect(xGui - size_text, yGui, size_text, DefineAON.GUI_Height_Label), "= " + AON.RpgMapEditor.ScriptGui.StrEOperation[f.Operation]);
                AONGUI.Label(new Rect(xGui - 25, yGui, 20, DefineAON.GUI_Height_Label), "a =");
                {
                    string hash          = "a" + k;
                    var    comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.KeyA);
                    int    index_a       = FlagGui.Instance.IndexOfKey(f.KeyA);
                    comboBoxFlags.SelectedItemIndex = index_a;
                    comboBoxFlags.Rect.x            = xGui;
                    comboBoxFlags.Rect.y            = yGui;
                    comboBoxFlags.Rect.width        = size_ab;
                    comboBoxFlags.Rect.height       = 32f;
                    // float limitHeight = rect.height - yGui - 32;
                    float limitHeight = 32 * 6f;
                    comboBoxFlags.Show(limitHeight, hash, (int flagNext) => {
                        f.KeyA = FlagGui.Instance.KeyFromIndex(flagNext);
                    });
                    if (comboBoxFlags.IsDropDownWithHash(hash))
                    {
                        yGui  += limitHeight;
                        waitUI = true;
                        return(false);
                    }
                }
                // xGui += size_ab;
                yGui += 32f;
                AONGUI.Label(new Rect(xGui - 25, yGui, 20, DefineAON.GUI_Height_Label), "b = ");
                {
                    string hash          = "b" + k;
                    var    comboBoxFlags = FlagGui.Instance.UpdateFlagsData(flagsYaml, f.KeyB);
                    int    index_b       = FlagGui.Instance.IndexOfKey(f.KeyB);
                    comboBoxFlags.SelectedItemIndex = index_b;
                    comboBoxFlags.Rect.x            = xGui;
                    comboBoxFlags.Rect.y            = yGui;
                    comboBoxFlags.Rect.width        = size_ab;
                    comboBoxFlags.Rect.height       = 32f;
                    // float limitHeight = rect.height - yGui - 32;
                    float limitHeight = 32 * 6f;
                    comboBoxFlags.Show(limitHeight, hash, (int flagNext) => {
                        f.KeyB = FlagGui.Instance.KeyFromIndex(flagNext);
                    });
                    if (comboBoxFlags.IsDropDownWithHash(hash))
                    {
                        yGui  += limitHeight;
                        waitUI = true;
                        return(false);
                    }
                    // var if_a_next = GUI.TextField(new Rect(rect.x + xGui, yGui + 32 - heighTextField, _w, heighTextField), if_a, 25);
                }
                yGui += 32f;
                yGui += 16f;
            }
            else
            {
                yGui += 32f;
            }
        }
        return(false);
    }