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

        AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Edit package:");
        yGui += 32f;
        {
            comboBoxSlug.UpdateListContent(packages.AllKey);
            comboBoxSlug.Empty             = "Not selected";
            comboBoxSlug.SelectedItemIndex = slugIndex;
            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) => {
                slugIndex = next;
            });
        }
        // if(comboBoxSlug.IsDropDownListVisible){
        //  return true;
        // }
        yGui   = rect.y + 4;
        rect.x = rect.x + widthLeft + 4;
        if (slugIndex < 0 || slugIndex >= packages.Count)
        {
            return(true);
        }

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

        SerializablePackages.Package package = packages.PackageByIndex(slugIndex);
        AONGUI.Button(new Rect(rect.x + 130, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Duplicate by slug", () => {
            var n = packages.Copy(slugIndex);
            if (n >= 0)
            {
                slugIndex = n;
            }
        });

        AONGUI.Button(new Rect(rect.x + 260, yGui + DefineAON.GUI_Y_Button, 100, DefineAON.GUI_Height_Label), "Add all Pets", () => {
            _addAllPets(package, propertys);
        });
        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), package.Name, (string text) => {
            package.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), package.Des, (string text) => {
            package.Des = text;
        });
        yGui += 32f;
        if (propertys == null || propertys.Count <= 0)
        {
            AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Propertys is empty");
            return(false);
        }
        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Propertys list:");
        yGui += 32f;
        {
            comboBoxItem.UpdateListContent(package.data.Keys);
            comboBoxItem.Empty             = "Not selected";
            comboBoxItem.SelectedItemIndex = itemIndex;
            comboBoxItem.Rect.x            = rect.x;
            comboBoxItem.Rect.y            = yGui;
            comboBoxItem.Rect.width        = widthLeft;
            comboBoxItem.Rect.height       = 32f;
            comboBoxItem.Show(rect.height - yGui, "defause", true, true, ( int next) => {
                itemIndex = next;
            });
        }
        AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_Button, 30, DefineAON.GUI_Height_Label), " + ", () => {
            if (itemIndex >= 0 && itemIndex < propertys.Count)
            {
                package.AddProperty(propertys.SlugByIndex(itemIndex));
            }
            else
            {
                package.AddProperty(propertys.SlugByIndex(0));
            }
        });
        if (itemIndex < 0)
        {
            return(false);
        }
        AONGUI.Button(new Rect(rect.x + widthLeft + 50, yGui + DefineAON.GUI_Y_Button, 30, DefineAON.GUI_Height_Label), " - ", () => {
            package.Remove(itemIndex);
        });
        if (package.data.Count == 0)
        {
            return(false);
        }
        if (itemIndex >= package.data.Count)
        {
            itemIndex = package.data.Count - 1;
            return(false);
        }
        rect.x = rect.x + widthLeft + 10;
        yGui  += 32f;
        string slugProperty = package.data[itemIndex].property;

        {
            // Pick Property
            bool isWaitUI = false;
            PropertysGUI.Instance.PickSlugItem(slugIndex.ToString(), propertys, slugProperty, rect.x, yGui, widthLeft, ref yGui, ref isWaitUI, (string slugPropertyPick) => {
                package.data[itemIndex].property = slugPropertyPick;
                package.data.ResetKeys();
            });
            yGui += 32f;
        }
        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Pay by:");
        yGui += 32f;

        SerializablePackages.PayBy payBy = package.data[itemIndex].payBy;
        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 100, DefineAON.GUI_Height_Label), "Coin");
        AONGUI.TextField(new Rect(rect.x + 100, yGui + DefineAON.GUI_Y_Label, widthLeft - 100, DefineAON.GUI_Height_Label), payBy.coin.ToString(), (string text) => {
            payBy.coin = UtilsAON.StrToIntDef(text);
        });
        yGui += 32f;
        return(false);
    }