public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        if (controller.InitialItems > controller.TotalItems)
        {
            controller.InitialItems = controller.TotalItems;
        }

        // Input Trap for dynamic population of min melt fee and est ENJ cost
        if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Tab)
        {
            if (controller.NewCryptoItem.reserve != "0")
            {
                if (controller.LastReserve != controller.NewCryptoItem.reserve)
                {
                    controller.MinWei      = System.Convert.ToInt64(GraphQLClient.GraphQuery.GetEndPointData(Enjin.MeltValueURL + controller.NewCryptoItem.reserve));
                    controller.LastReserve = controller.NewCryptoItem.reserve;
                }
            }
        }

        GUILayout.BeginArea(new Rect(5, 126, 912, 490), skin.GetStyle("TopBackground"));

        #region TITLE
        EditorGUILayout.LabelField(new GUIContent(controller.State + " CRYPTOITEM"), skin.GetStyle("MainTitle"));
        #endregion

        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();

        #region PANEL COLUMN 1
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM NAME"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        controller.NewCryptoItem.name = EditorGUILayout.TextField(controller.NewCryptoItem.name, skin.textField, GUILayout.Width(260), GUILayout.Height(30));

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TOTAL SUPPLY", "Max amount of CryptoItems that can be minted"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        controller.TotalItems = EditorGUILayout.IntField(controller.TotalItems, skin.textField, GUILayout.Width(260), GUILayout.Height(30));
        controller.TotalItems = (controller.TotalItems < 0) ? 0 : controller.TotalItems;
        controller.TotalItems = (controller.TotalItems > (int)Mathf.Pow(10, 9)) ? (int)Mathf.Pow(10, 9) : controller.TotalItems;
        controller.NewCryptoItem.totalSupply = controller.TotalItems.ToString();

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("INITIAL RESERVE", "Actual amount of CryptoItems minted less than total supply. Allows for reserve CryptoItems"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        controller.InitialItems          = EditorGUILayout.IntField(controller.InitialItems, skin.textField, GUILayout.Width(260), GUILayout.Height(30));
        controller.InitialItems          = (controller.InitialItems <= 0) ? 1 : controller.InitialItems;
        controller.InitialItems          = (controller.InitialItems > (int)Mathf.Pow(10, 9)) ? (int)Mathf.Pow(10, 9) : controller.InitialItems;
        controller.NewCryptoItem.reserve = controller.InitialItems.ToString();

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("MELT VALUE (MIN COST: " + (controller.MinWei / 1000000000000000000).ToString("N8") + " ENJ)", "Base value of item in Enjin Coin"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        //nTest = EditorGUILayout.TextField(Regex.Replace(nTest, @"[^.0-9 ]", ""), skin.textField, GUILayout.Width(260), GUILayout.Height(30));
        //nTest = nTest.Replace(".", "");
        //nTest = nTest.PadRight(18, '0');
        controller.EnjValue  = Mathf.Clamp(EditorGUILayout.FloatField(controller.EnjValue, skin.textField, GUILayout.Width(260), GUILayout.Height(30)), (float)(controller.MinWei / 1000000000000000000), Mathf.Pow(10, 9));
        controller.MeltValue = System.Convert.ToDecimal(controller.EnjValue);
        EditorGUILayout.EndVertical();
        #endregion

        #region PANEL COLUMN 2
        GUILayout.Space(20);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("SUPPLY TYPE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorStyles.popup.fixedHeight       = 30;
        EditorStyles.popup.fontSize          = 12;
        controller.ModelType                 = (SupplyModel2)EditorGUILayout.EnumPopup(controller.ModelType, GUILayout.Width(260), GUILayout.Height(30));
        controller.NewCryptoItem.supplyModel = (SupplyModel)System.Enum.Parse(typeof(SupplyModel), controller.ModelType.ToString());
        EditorStyles.popup.fixedHeight       = 15;
        EditorStyles.popup.fontSize          = 11;

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TRANSFERABLE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorStyles.popup.fixedHeight        = 30;
        EditorStyles.popup.fontSize           = 12;
        controller.NewCryptoItem.transferable = (Transferable)EditorGUILayout.EnumPopup(controller.NewCryptoItem.transferable, GUILayout.Width(260), GUILayout.Height(30));
        EditorStyles.popup.fixedHeight        = 15;
        EditorStyles.popup.fontSize           = 11;

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE SETTINGS"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorStyles.popup.fixedHeight = 30;
        EditorStyles.popup.fontSize    = 12;
        controller.NewCryptoItem.transferFeeSettings.type = (TransferType)EditorGUILayout.EnumPopup(controller.NewCryptoItem.transferFeeSettings.type, GUILayout.Width(260), GUILayout.Height(30));
        EditorStyles.popup.fixedHeight = 15;
        EditorStyles.popup.fontSize    = 11;

        /**
         * Re-enable token ID (for NFI) after v1 as part of the expanded NFI task set
         */
        //if (controller.NewCryptoItem.transferFeeSettings.type != TransferType.NONE)
        //{
        //    GUILayout.Space(20);
        //    EditorGUILayout.LabelField(new GUIContent("TOKEN ID"), skin.GetStyle("Subtitle"), GUILayout.Width(120));

        //    controller.NewCryptoItem.transferFeeSettings.token_id = "0";
        //    EditorGUILayout.LabelField(controller.NewCryptoItem.transferFeeSettings.token_id, skin.GetStyle("LargeTextDark"), GUILayout.Width(120), GUILayout.Height(30));
        //}

        EditorGUILayout.EndVertical();
        #endregion

        #region PANEL COLUMN 3
        GUILayout.Space(20);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("CREATOR MELT FEE %", "Sets the max melt fee. Max value is 50"), skin.GetStyle("Subtitle"), GUILayout.Width(260)); // was 120
        controller.MeltFee = Mathf.Clamp(EditorGUILayout.FloatField(controller.MeltFee, skin.textField, GUILayout.Width(260), GUILayout.Height(30)), 0.00f, 50.00f);
        controller.NewCryptoItem.meltFeeRatio = (int)(controller.MeltFee * Mathf.Pow(10, 2));

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM TYPE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorStyles.popup.fixedHeight       = 30;
        EditorStyles.popup.fontSize          = 12;
        controller.ItemType                  = (CryptoItemType)EditorGUILayout.EnumPopup(controller.ItemType, GUILayout.Width(260), GUILayout.Height(30));
        EditorStyles.popup.fixedHeight       = 15;
        EditorStyles.popup.fontSize          = 11;
        controller.NewCryptoItem.nonFungible = (controller.ItemType == CryptoItemType.NONFUNGIBLE) ? true : false;

        if (controller.NewCryptoItem.transferFeeSettings.type != TransferType.NONE)
        {
            GUILayout.Space(20);

            if (controller.NewCryptoItem.transferFeeSettings.type == TransferType.NONE)
            {
                EditorGUILayout.LabelField("0", skin.GetStyle("LargeTextDark"), GUILayout.Width(120), GUILayout.Height(30));
                controller.NewCryptoItem.transferFeeSettings.token_id = "0";
                controller.NewCryptoItem.transferFeeSettings.value    = ((decimal)0).ToString();
            }
            else if (controller.NewCryptoItem.transferFeeSettings.type == TransferType.RATIO_CUT || controller.NewCryptoItem.transferFeeSettings.type == TransferType.RATIO_EXTRA)
            {
                EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE % (MAX 50)"), skin.GetStyle("Subtitle"), GUILayout.Width(120));

                controller.TransferFeeEnj = Mathf.Clamp(EditorGUILayout.FloatField(controller.TransferFeeEnj, skin.textField, GUILayout.Width(120), GUILayout.Height(30)), 0f, 50f);
                // 50% is 5000 in Unit16 (for queries); Max value for transferFee is 50% or 5000.
                controller.NewCryptoItem.transferFeeSettings.value = ((decimal)(Mathf.Pow(10, 2) * controller.TransferFeeEnj)).ToString();
            }
            else if (controller.NewCryptoItem.transferFeeSettings.type == TransferType.PER_CRYPTO_ITEM || controller.NewCryptoItem.transferFeeSettings.type == TransferType.PER_TRANSFER)
            {
                EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE (ENJ)"), skin.GetStyle("Subtitle"), GUILayout.Width(120));

                controller.TransferFeeEnj = Mathf.Max(EditorGUILayout.FloatField(controller.TransferFeeEnj, skin.textField, GUILayout.Width(120), GUILayout.Height(30)), 0f);
                controller.NewCryptoItem.transferFeeSettings.value = ((decimal)(Mathf.Pow(10, 18) * controller.TransferFeeEnj)).ToString();
            }
        }

        EditorGUILayout.EndVertical();
        #endregion

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical();
        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("METADATA URI"), skin.GetStyle("Subtitle"), GUILayout.Width(120));
        controller.MetaDataURI = EditorGUILayout.TextField(controller.MetaDataURI, skin.textField, GUILayout.Height(30), GUILayout.Width(820));

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        #region BUTTON MENU
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button(new GUIContent("CREATE"), GUILayout.Width(100), GUILayout.Height(36)))
        {
            controller.Properties.Clear();
            bool process = true;

            if (controller.InitialItems == 0)
            {
                if (EditorUtility.DisplayDialog("WARNING", "Initial Reserve is set to 0. You do not have the permissions for this setting. Continue item creation with initial reserve set to 1?", "Pr1oceed", "Cancel"))
                {
                    controller.NewCryptoItem.reserve = "1";
                }
                else
                {
                    process = false;
                }
            }

            if ((decimal)controller.EnjValue < (controller.MinWei / 1000000000000000000))
            {
                if (EditorUtility.DisplayDialog("WARNING", "Your melt value is not greater than or equal to the minimum melt value. Would you like to set the melt value to the minimum (" + controller.MinWei / 1000000000000000000 + " ENJ) and continue?", "Proceed", "Cancel"))
                {
                    controller.EnjValue  = (float)(controller.MinWei / 1000000000000000000);
                    controller.MeltValue = System.Convert.ToDecimal(controller.EnjValue);

                    if (controller.Properties.ContainsKey("MeltValue"))
                    {
                        controller.Properties.Remove("MeltValue");
                    }

                    controller.Properties.Add("MeltValue", (float)controller.MeltValue);
                }
                else
                {
                    process = false;
                }
            }
            else
            {
                controller.MeltValue = System.Convert.ToDecimal(controller.EnjValue);

                if (controller.Properties.ContainsKey("MeltValue"))
                {
                    controller.Properties.Remove("MeltValue");
                }

                controller.Properties.Add("MeltValue", (float)controller.MeltValue);
            }

            if (controller.MeltValue == 0)
            {
                EditorUtility.DisplayDialog("INVALID MELT VALUE", "Melt value can't be 0", "Ok");
                process = false;
            }

            if (controller.NewCryptoItem.transferFeeSettings.type != TransferType.NONE)
            {
                if (controller.TransferFeeEnj == 0)
                {
                    EditorUtility.DisplayDialog("WARNING", "Transfer Fee must be greater than 0.", "OK");
                    process = false;
                }
            }

            if (controller.TotalItems == 0)
            {
                EditorUtility.DisplayDialog("INVALID SUPPLY TOTAL", "Supply total must be at least 1", "Ok");
                process = false;
            }

            if (controller.NewCryptoItem.name == null || controller.NewCryptoItem.name.Trim() == "" || controller.NewCryptoItem.name == string.Empty)
            {
                EditorUtility.DisplayDialog("INVALID TOKEN NAME", "Token must have a name", "Ok");
                process = false;
            }

            if (controller.IsValidURI(controller.MetaDataURI))
            {
                if (controller.MetaDataURI != "")
                {
                    controller.Properties.Add("MetaDataURI", controller.MetaDataURI);
                }
            }
            else if (!controller.IsValidURI(controller.MetaDataURI))
            {
                EditorUtility.DisplayDialog("INVALID METADATA URI", "Your metadata URI must be valid in a web browser", "Ok");
                process = false;
            }

            // Please note that this call is attached to button press logic
            if (process)
            {
                Request request = controller.ProcessCryptoItem(ProcessTasks.CREATE, controller.NewCryptoItem, controller.Properties);

                if (EnjinEditor.IsRequestSuccessfull(request.state))
                {
                    EditorUtility.DisplayDialog("SUCCESS", "The request has posted with a status of " + request.state + ". Please see your wallet to complete the transaction!", "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("FAILURE", "The request could not be processed due to a status of " + request.state + ".", "Ok");
                }

                controller.State = CryptoItemsController.CryptoItemState.MAIN;
            }
            // if process is false, we should already have shown a dialog so no false condition is required here.
        }

        if (GUILayout.Button(new GUIContent("BACK"), GUILayout.Width(100), GUILayout.Height(36)))
        {
            controller.Reset();
            controller.State = CryptoItemsController.CryptoItemState.MAIN;
        }

        GUILayout.Space(6);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        #endregion

        GUILayout.EndArea();
    }
    /// <summary>
    /// Build and Draw Mint CI Panel
    /// Embedded UI logic for field validation and initial request return status
    /// </summary>
    public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        controller.TotalReserveCost = System.Convert.ToInt64(controller.CurrentCryptoItem.reserve);
        controller.TotalReserveCost = controller.TotalReserveCost * (double)((float)System.Convert.ToDecimal(controller.CurrentCryptoItem.meltValue) / Mathf.Pow(10, 18));

        GUILayout.BeginArea(new Rect(5, 126, 912, 490), skin.GetStyle("TopBackground"));
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(new GUIContent("MINT CRYPTOITEM"), skin.GetStyle("MainTitle"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(30);
        // Begin Columns
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        #region Column 1
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM NAME"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.name), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TOTAL SUPPLY"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

        if (controller.CurrentCryptoItem.supplyModel != SupplyModel.INFINITE)
        {
            EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.totalSupply), skin.GetStyle("LargeTextDark"), GUILayout.Height(30), GUILayout.Width(260));
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent("INFINITE"), skin.GetStyle("LargeTextDark"), GUILayout.Height(30), GUILayout.Width(260));
        }

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TOTAL RESERVE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.reserve), skin.GetStyle("LargeTextDark"), GUILayout.Height(30), GUILayout.Width(260));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("MINT ALLOWANCE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent(controller.MintableCryptoItems.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("NUMBER TO MINT"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

        if (controller.CurrentCryptoItem.nonFungible)
        {
            controller.NumToMint = 1;
            EditorGUILayout.LabelField(new GUIContent(controller.NumToMint.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        }
        else
        {
            controller.NumToMint = (controller.NumToMint < 1) ? 1 : controller.NumToMint;
            controller.NumToMint = (controller.NumToMint > int.MaxValue) ? int.MaxValue : controller.NumToMint;
            controller.NumToMint = EditorGUILayout.IntField(controller.NumToMint, skin.textField, GUILayout.Width(260), GUILayout.Height(30));
        }

        EditorGUILayout.EndVertical();
        #endregion

        #region Column 2
        EditorGUILayout.BeginVertical(GUILayout.Width(600)); // double wide
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM ID"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.token_id, controller.CurrentCryptoItem.token_id), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("RESERVE BALANCE"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.TotalReserveCost.ToString("N4") + " ENJ"), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(20);

        if (controller.NumToMint <= controller.Reserve)
        {
            controller.TotalReserveCost = controller.NumToMint * controller.MeltValue2;
            controller.TotalEnjCost     = 0;
        }
        else if (controller.NumToMint > controller.Reserve && controller.Reserve == 0)
        {
            controller.TotalReserveCost = 0;
            controller.TotalEnjCost     = controller.NumToMint * controller.MeltValue2;
        }
        else if (controller.NumToMint > controller.Reserve && controller.Reserve > 0)
        {
            controller.TotalReserveCost = controller.Reserve * controller.MeltValue2;
            controller.TotalEnjCost     = (controller.NumToMint - controller.Reserve) * (double)((float)System.Convert.ToDecimal(controller.CurrentCryptoItem.meltValue) / Mathf.Pow(10, 18));
        }

        EditorGUILayout.LabelField(new GUIContent("RESERVE ENJ COST", "ENJ PER ITEM: " + controller.MeltValue2), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.TotalReserveCost.ToString("N4") + " ENJ"), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TOTAL ENJ COST", "ENJ PER ITEM: " + controller.MeltValue2), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.TotalEnjCost.ToString("N4") + " ENJ"), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TRANSFER TO ID"), skin.GetStyle("Subtitle"));
        controller.RecieverAddress[0] = EditorGUILayout.TextField(controller.RecieverAddress[0], skin.textField, GUILayout.Height(30));
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        #endregion
        // End Columns

        // Buttons
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("MINT", GUILayout.Width(100), GUILayout.Height(30)))
        {
            if (!Enjin.ValidateAddress(controller.RecieverAddress[0].Trim()))
            {
                EditorUtility.DisplayDialog("INVALID ADDRESS", "The address you entered is not valid. Please enter a valid address", "Ok");
            }
            else if (controller.CurrentCryptoItem.supplyModel != SupplyModel.INFINITE)
            {
                if (controller.NumToMint > System.Int32.Parse(controller.MintableCryptoItems))
                {
                    EditorUtility.DisplayDialog("INVALID MINT VALUE", "The number of items to mint can not exceed the mint allowance", "Ok");
                }
            }

            if (controller.NumToMint <= int.MaxValue)
            {
                controller.Properties.Clear();
                controller.Properties.Add("RecieverAddress", controller.RecieverAddress);

                if (!controller.CurrentCryptoItem.nonFungible)
                {
                    controller.Properties.Add("NumToMint", controller.NumToMint);
                }

                Request request = controller.ProcessCryptoItem(ProcessTasks.MINT, controller.CurrentCryptoItem, controller.Properties);

                if (EnjinEditor.IsRequestSuccessfull(request.state))
                {
                    EditorUtility.DisplayDialog("SUCCESS", "The request has posted with a status of " + request.state + ". Please see your wallet to complete the transaction!", "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("FAILURE", "The request could not be processed due to a status of " + request.state + ".", "Ok");
                }

                controller.State = CryptoItemsController.CryptoItemState.MAIN;
            }
            else
            {
                EditorUtility.DisplayDialog("Invalid Mintable CryptoItem Amount", "The token amount you selected is greater than the maximum limit. The maximum limit is " + int.MaxValue.ToString(), "Ok");
            }
        }

        if (GUILayout.Button("BACK", GUILayout.Width(100), GUILayout.Height(30)))
        {
            controller.State = CryptoItemsController.CryptoItemState.MAIN;
        }

        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        GUILayout.EndArea();
    }
Esempio n. 3
0
    /// <summary>
    /// Build and Draw View/Edit CI Panel
    /// Embedded UI logic for field validation and request return status (Edit Mode)
    /// </summary>
    public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 126, 912, 490), skin.GetStyle("TopBackground"));
        EditorGUILayout.LabelField(new GUIContent(controller.State + " CRYPTOITEM"), skin.GetStyle("MainTitle"));
        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));

        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM NAME"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

        if (controller.CurrentCryptoItem.isCreator && controller.State.Equals(CryptoItemsController.CryptoItemState.EDIT))
        {
            controller.EditItemName = EditorGUILayout.TextField(controller.EditItemName, skin.textField, GUILayout.Width(260), GUILayout.Height(30));
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.name), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        }

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TOTAL SUPPLY", "Total number of items in the supply"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

        if (controller.CurrentCryptoItem.supplyModel != SupplyModel.INFINITE)
        {
            EditorGUILayout.LabelField(new GUIContent(System.String.Format("{0:N0}", System.Double.Parse(controller.CurrentCryptoItem.totalSupply))), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent("INFINITE"), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        }

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("INITIAL RESERVE", "Number of items that are prepaid for"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(System.String.Format("{0:N0}", System.Double.Parse(controller.CurrentCryptoItem.reserve)), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("MELT VALUE", "Base value of item in Enjin Coin"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent((System.Convert.ToDouble(controller.CurrentCryptoItem.meltValue) / Mathf.Pow(10, 18)).ToString("N4") + " ENJ"), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        EditorGUILayout.EndVertical();
        GUILayout.Space(20);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("SUPPLY TYPE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.supplyModel.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TRANSFERABLE"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.transferable.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE SETTINGS"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.transferFeeSettings.type.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));

        EditorGUILayout.EndVertical();
        GUILayout.Space(20);
        EditorGUILayout.BeginVertical(GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent("CREATOR MELT FEE %", "Sets the max melt fee. Max value controller.Is 50"), skin.GetStyle("Subtitle"), GUILayout.Width(260)); // was 120

        EditorGUILayout.LabelField(new GUIContent((controller.CurrentCryptoItem.meltFeeRatio * 0.01f).ToString() + "%"), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("NONFUNGIBLE ITEM", "Flags the item as nonfungible"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.nonFungible.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260));

        if (controller.CurrentCryptoItem.nonFungible)
        {
            GUILayout.Space(20);
            EditorGUILayout.LabelField(new GUIContent("INDEX", "The particular index for thcontroller.Is non-fungible item"), skin.GetStyle("Subtitle"), GUILayout.Width(260));

            int tokenIndex;
            if (System.Int32.TryParse(controller.CurrentCryptoItem.index, out tokenIndex))
            {
                EditorGUILayout.LabelField(new GUIContent("" + tokenIndex), skin.GetStyle("LargeTextDark"), GUILayout.Width(260));
            }
            else if (controller.CurrentCryptoItem.index.Contains(",") && controller.CurrentCryptoItem.index.Split(',').Length > 0)
            {
                string   indexList = "";
                string[] indices   = controller.CurrentCryptoItem.index.Split(',');

                for (int indexIndex = 0; indexIndex < indices.Length; indexIndex++)
                {
                    int subItemIndex;
                    if (System.Int32.TryParse(indices[indexIndex], out subItemIndex))
                    {
                        if (indexIndex > 0 && indexIndex < indices.Length)
                        {
                            indexList += ", ";
                        }

                        indexList += subItemIndex;
                    }
                }

                skin.GetStyle("LargeTextDark").wordWrap = true;
                EditorGUILayout.LabelField(new GUIContent(indexList), skin.GetStyle("LargeTextDark"), GUILayout.Width(260));
                skin.GetStyle("LargeTextDark").wordWrap = false;
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("Invalid index"), skin.GetStyle("LargeTextDark"), GUILayout.Width(260));
            }
        }

        if (controller.CurrentCryptoItem.transferFeeSettings.type != TransferType.NONE)
        {
            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("TOKEN ID"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(controller.CurrentCryptoItem.token_id, skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);

            if (controller.CurrentCryptoItem.transferFeeSettings.type == TransferType.RATIO_CUT || controller.CurrentCryptoItem.transferFeeSettings.type == TransferType.RATIO_EXTRA)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE %"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField((float.Parse(controller.CurrentCryptoItem.transferFeeSettings.value) / Mathf.Pow(10, 2)) + "%", skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
                EditorGUILayout.EndHorizontal();
            }
            else if (controller.CurrentCryptoItem.transferFeeSettings.type == TransferType.PER_CRYPTO_ITEM || controller.CurrentCryptoItem.transferFeeSettings.type == TransferType.PER_TRANSFER)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("TRANSFER FEE (ENJ)"), skin.GetStyle("Subtitle"), GUILayout.Width(260));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField((float.Parse(controller.CurrentCryptoItem.transferFeeSettings.value) / Mathf.Pow(10, 18)).ToString(), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical();
        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("METADATA URI"), skin.GetStyle("Subtitle"), GUILayout.Width(120));
        if (controller.CurrentCryptoItem.isCreator && controller.State.Equals(CryptoItemsController.CryptoItemState.EDIT))
        {
            controller.MetaDataURI = EditorGUILayout.TextField(controller.MetaDataURI, skin.textField, GUILayout.Height(30), GUILayout.Width(820));
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.itemURI), skin.GetStyle("LargeTextDark"), GUILayout.Height(30), GUILayout.Width(260));
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (controller.CurrentCryptoItem.isCreator && controller.State.Equals(CryptoItemsController.CryptoItemState.EDIT))
        {
            if (GUILayout.Button(new GUIContent("UPDATE"), GUILayout.Width(100), GUILayout.Height(30)))
            {
                if (!controller.IsValidURI(controller.MetaDataURI))
                {
                    EditorUtility.DisplayDialog("INVALID METADATA URI", "Your metadata URI must be valid in a web browser", "Ok");
                }
                else
                {
                    controller.Properties.Clear();
                    controller.Properties.Add("ItemName", controller.EditItemName);
                    controller.Properties.Add("MetaDataURI", controller.MetaDataURI);
                    controller.Properties.Add("TranferFeeEnj", controller.TransferFeeEnj);
                    controller.Properties.Add("MeltFeeRatio", controller.MeltFee);
                    controller.ProcessCryptoItem(ProcessTasks.EDIT, controller.CurrentCryptoItem, controller.Properties);

                    if (Enjin.ServerResponse == ResponseCodes.SUCCESS)
                    {
                        EditorUtility.DisplayDialog("SUCCESS", "The request has posted successfully. Please see your wallet to complete the transaction!", "Ok");
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("FAILURE", "The request could not be processed.", "Ok");
                    }

                    controller.State = CryptoItemsController.CryptoItemState.MAIN;
                }
            }
        }

        if (GUILayout.Button(new GUIContent("BACK"), GUILayout.Width(100), GUILayout.Height(30)))
        {
            controller.Reset();
        }

        GUILayout.Space(6);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        GUILayout.EndArea();
    }
Esempio n. 4
0
    /// <summary>
    /// Build and Draw Melt CI Panel
    /// Embedded UI logic for field validation and initial request return status
    /// </summary>
    public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 126, 912, 490), skin.GetStyle("TopBackground"));
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(new GUIContent("MELT CRYPTOITEM"), skin.GetStyle("MainTitle"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical();
        EditorGUILayout.BeginHorizontal(GUILayout.Width(280));
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM ID"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.token_id.Substring(0, 8) + "..", controller.CurrentCryptoItem.token_id), skin.GetStyle("LargeTextDark"), GUILayout.Height(30), GUILayout.Width(30));
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        GUILayout.Label(controller.CurrentCryptoItem.iconTexture, GUILayout.Width(60), GUILayout.Height(60));
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.LabelField(new GUIContent("CRYPTOITEM NAME"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.CurrentCryptoItem.name), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("AVAILABLE COUNT"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.Balance.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(10);

        if (!controller.CurrentCryptoItem.nonFungible)
        {
            EditorGUILayout.LabelField(new GUIContent("NUMBER TO MELT"), skin.GetStyle("Subtitle"));
            controller.NumToMelt = EditorGUILayout.IntField(controller.NumToMelt, skin.textField, GUILayout.Width(260), GUILayout.Height(30));

            if (controller.NumToMelt > controller.Balance)
            {
                controller.NumToMelt = controller.Balance;
            }
        }
        else
        {
            controller.NumToMelt = 1;
            EditorGUILayout.LabelField(new GUIContent("NUMBER TO MELT"), skin.GetStyle("Subtitle"));
            EditorGUILayout.LabelField(new GUIContent(controller.NumToMelt.ToString()), skin.GetStyle("LargeTextDark"), GUILayout.Width(260), GUILayout.Height(30));
        }

        if (controller.NumToMelt == 0)
        {
            controller.NumToMelt = 1;
        }

        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("CREATOR MELT FEE"), skin.GetStyle("Subtitle"));
        EditorGUILayout.LabelField(new GUIContent(controller.EnjPerItem.ToString("N4") + " ENJ"), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(10);
        EditorGUILayout.LabelField(new GUIContent("ENJ RETURNED"), skin.GetStyle("Subtitle"));
        controller.EnjReturned = (controller.NumToMelt * controller.EnjPerItem);
        EditorGUILayout.LabelField(new GUIContent(controller.EnjReturned.ToString("N4")), skin.GetStyle("LargeTextDark"), GUILayout.Height(30));
        GUILayout.Space(10);

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("MELT", GUILayout.Width(100), GUILayout.Height(30)))
        {
            if (controller.NumToMelt == 0)
            {
                EditorUtility.DisplayDialog("INVALID MELT VALUE", "Melt value must be at least one.", "Ok");
            }
            else
            {
                controller.Properties.Clear();
                controller.Properties.Add("NumToMelt", controller.NumToMelt);

                Request request = controller.ProcessCryptoItem(ProcessTasks.MELT, controller.CurrentCryptoItem, controller.Properties);

                if (EnjinEditor.IsRequestSuccessfull(request.state))
                {
                    EditorUtility.DisplayDialog("SUCCESS", "The request has posted with a status of " + request.state + ". Please see your wallet to complete the transaction!", "Ok");
                }
                else
                {
                    EditorUtility.DisplayDialog("FAILURE", "The request could not be processed due to a status of " + request.state + ".", "Ok");
                }

                EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                controller.State = CryptoItemsController.CryptoItemState.MAIN;
            }
        }
        GUILayout.Space(16);

        if (GUILayout.Button("BACK", GUILayout.Width(100), GUILayout.Height(30)))
        {
            controller.State = CryptoItemsController.CryptoItemState.MAIN;
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
    }