/// <summary>
    /// Main draw loop for team tab
    /// </summary>
    public void DrawTeamTab()
    {
        switch (_controller.State)
        {
        case TeamState.VIEWLIST:
            DrawTeamPanels();
            break;

        case TeamState.MANAGEROLES:
        case TeamState.EDITROLE:
        case TeamState.CREATEROLE:
            _rolesPanels.DrawTeamRolesPanel(_controller, _skin);
            break;

        case TeamState.CREATE:
        case TeamState.EDIT:
            _memberPanel.DrawTeamMemberPanel(_controller, _skin);
            break;

        case TeamState.INVITEUSER:
            _optionsPanel.DrawTeamOptionsPanel(_controller, _skin);
            _teamSearch.DrawTeamSearchPanel(_controller, _skin);
            _invitePanel.DrawInviteUserPanel(_controller, _skin);
            break;

        case TeamState.REFRESH:
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.REFRESHUSERROLES);
            _controller.SetTeamState(TeamState.VIEWLIST);
            DrawTeamTab();
            break;
        }
    }
    private void CheckAllowance()
    {
        AllowanceError = AllowanceErrors.NONE;

        if (EnjinEditor.CurrentUserIdentity.linking_code != null && EnjinEditor.CurrentUserIdentity.linking_code != string.Empty)
        {
            AllowanceError = AllowanceErrors.NOTLINKED;
            return;
        }

        EnjinEditor.Log("Checking Allowance");

        string allowance = "";

        allowance = EnjinEditor.GetAllowance(EnjinEditor.CurrentUserIdentity.ethereum_address);

        if (allowance.Contains("502"))
        {
            AllowanceError = AllowanceErrors.INVALIDADDRESS;
        }
        else if (allowance == "0")
        {
            IsAllowanceApproved = false;
        }
        else
        {
            IsAllowanceApproved = true;
        }
    }
 private void OnDestroy()
 {
     if (Enjin.IsLoggedIn)
     {
         EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.LOGOUT);
     }
 }
    /// <summary>
    /// Options Pane for main CI tab
    /// </summary>
    public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 10, 230, 100), skin.GetStyle("TopBackground"));
        EditorGUILayout.LabelField(new GUIContent("CREATE"), skin.GetStyle("MainTitle"));

        if (EnjinEditor.HasPermission(EnjinSDK.UserPermission.manageTokens))
        {
            if (EnjinEditor.CurrentUserIdentity.linking_code == string.Empty)
            {
                GUILayout.FlexibleSpace();
                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal(GUILayout.Width(100));
                GUILayout.Space(14);

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

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

        GUILayout.EndArea();
    }
    /// <summary>
    /// Main GUI Rendering Loop
    /// </summary>
    private void OnGUI()
    {
        if (EditorApplication.isCompiling && Enjin.IsLoggedIn)
        {
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.LOGOUT);
        }

        if (EditorApplication.isPlaying)
        {
            if (Enjin.IsLoggedIn)
            {
                EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.LOGOUT);
            }

            // Show blank window for now
        }
        else
        {
            EditorGUI.DrawRect(new Rect(0, 0, position.width, position.height), new Color(0.1f, 0.1f, 0.1f));
            _toolbarIndex = GUI.Toolbar(new Rect(15, 5, 910, 40), _toolbarIndex, _toolbarHeaders);
            GUILayout.BeginArea(new Rect(10, 50, position.width, position.height));
            _toolbarIndex = EnjinEditor.TabSelection(_toolbarIndex);
            GUILayout.EndArea();
        }
    }
Beispiel #6
0
    /// <summary>
    /// Creates a new team memeber
    /// </summary>
    public void CreateMember()
    {
        User result = null;

        if (UserObject.password == string.Empty)
        {
            result = new User();
            Enjin.InviteUser(UserObject.email, UserObject.name);
        }
        else
        {
            result = Enjin.CreateUser(UserObject.name, UserObject.email, UserObject.password, RolesList[RoleDropDownSelection].name);
        }

        if (result != null && Enjin.ServerResponse == ResponseCodes.SUCCESS)
        {
            if (UserObject.password == string.Empty)
            {
                EnjinEditor.DisplayDialog("SUCCESS", "User " + UserObject.name + " successfully created and invite sent.");
            }
            else
            {
                EnjinEditor.DisplayDialog("SUCCESS", "User " + UserObject.name + " successfully created.");
            }

            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADTEAM);
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADIDENTITIES);
            SetTeamState(TeamState.VIEWLIST);
        }
        else
        {
            EnjinEditor.DisplayDialog("FAILED", "Eamil address: " + UserObject.email + " has already been registered. Please enter a different email address");
        }
    }
    /// <summary>
    /// Checks if user has required permission to access feature
    /// </summary>
    /// <param name="perm">permission to check for</param>
    /// <returns>true/false based on results</returns>
    public bool HasPermission(UserPermission perm)
    {
        if (Enjin.AppID != -1)
        {
            return(EnjinEditor.HasPermission(perm));
        }

        return(false);
    }
Beispiel #8
0
    /// <summary>
    /// Draws the logged in panel
    /// </summary>
    public void DrawPlatformLoggedInPanel(HomeController controller, GUISkin skin)
    {
        if (Enjin.AppID != -1 && controller.State == PlatformState.VIEW)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            EditorStyles.popup.fixedHeight = 30;
            EditorStyles.popup.fontSize    = 12;
            EnjinEditor.SelectedAppIndex   = EditorGUILayout.Popup(EnjinEditor.SelectedAppIndex, EnjinEditor.AppsNameList.ToArray(), GUILayout.Width(220), GUILayout.Height(30));
            EditorStyles.popup.fixedHeight = 15;
            EditorStyles.popup.fontSize    = 11;
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }

        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.CHECKAPPCHANGE);

        GUILayout.Space(30);

        if (controller.State == PlatformState.VIEW)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("ADD APP", GUILayout.Width(102), GUILayout.Height(30)))
            {
                controller.SetPlatformState(PlatformState.CREATE);
            }

            if (controller.HasPermission(UserPermission.manageApp))
            {
                GUILayout.Space(10);

                if (GUILayout.Button("EDIT APP", GUILayout.Width(102), GUILayout.Height(30)))
                {
                    controller.SetPlatformState(PlatformState.EDIT);
                }
            }

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

        switch (controller.State)
        {
        case PlatformState.CREATE:
        case PlatformState.EDIT:
            _appManagePanel.DrawManageAppsPanel(controller, skin);
            break;

        case PlatformState.VIEW:
            _viewPanel.DrawViewPanel(controller, skin);
            break;
        }
    }
    private void UnlinkedWallet()
    {
        GUILayout.BeginArea(new Rect(5, 10, 912, 606), _skin.GetStyle("TopBackground"));
        EditorGUILayout.LabelField(new GUIContent("LINK WALLET"), _skin.GetStyle("MainTitle"));
        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("Step 1:"), _skin.GetStyle("BoldTitle"), GUILayout.Width(50));
        EditorGUILayout.LabelField(new GUIContent("Download the Enjin Wallet"), _skin.GetStyle("ContentLight"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);

        //if (GUILayout.Button(new GUIContent("Enjin Wallet iOS"), GUILayout.Width(140), GUILayout.Height(30)))
        //    Application.OpenURL("https://itunes.apple.com/us/app/enjin-cryptocurrency-wallet/id1349078375?ls=1&mt=8");

        if (GUILayout.Button(new GUIContent("Enjin Wallet"), GUILayout.Width(140), GUILayout.Height(30)))
        {
            Application.OpenURL("https://enjinwallet.io/");
        }
        //Application.OpenURL("https://play.google.com/store/apps/details?id=com.enjin.mobile.wallet");

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("Step 2:"), _skin.GetStyle("BoldTitle"), GUILayout.Width(50));
        EditorGUILayout.LabelField(new GUIContent("Open the Enjin Wallet, select LINK in settings and enter this\nunique code:"), _skin.GetStyle("ContentLight"), GUILayout.Height(30));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(66);
        EditorGUILayout.LabelField(new GUIContent(EnjinEditor.CurrentUserIdentity.linking_code), _skin.GetStyle("LargeNumbersGreen"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("Step 3:"), _skin.GetStyle("BoldTitle"), GUILayout.Width(50));
        EditorGUILayout.LabelField(new GUIContent("After you entered the code, click refresh button below to\nconfirm that your wallet and address is linked."), _skin.GetStyle("ContentLight"), GUILayout.Height(30));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);

        if (GUILayout.Button(new GUIContent("Refresh"), GUILayout.Width(140), GUILayout.Height(30)))
        {
            EnjinEditor.CurrentUser = Enjin.GetUserRaw(EnjinEditor.CurrentUser.id);
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADALL);
        }

        EditorGUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.EndArea();
    }
    /// <summary>
    /// Main Method for the CI Tab. This method manages the state and is called repeatedly while the CI Tab is selected.
    /// </summary>
    public void DrawCryptoItemsTab()
    {
        // handle CI Tab state actions and panel display choices
        switch (_controller.State)
        {
        case CryptoItemsController.CryptoItemState.MAIN:
            _optionsPane.DrawPane(_controller, _skin);
            _searchPane.DrawPane(_controller, _skin);
            _mainPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.CREATE:
            _walletPane.DrawPane(_controller, _skin);
            _mintCostPane.DrawPane(_controller, _skin);
            _createPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.EDIT:
            _walletPane.DrawPane(_controller, _skin);
            _detailsPane.DrawPane(_controller, _skin);
            _editPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.VIEW:
            _walletPane.DrawPane(_controller, _skin);
            _detailsPane.DrawPane(_controller, _skin);
            _editPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.MINT:
            _walletPane.DrawPane(_controller, _skin);
            _detailsPane.DrawPane(_controller, _skin);
            _mintPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.MELT:
            _walletPane.DrawPane(_controller, _skin);
            _detailsPane.DrawPane(_controller, _skin);
            _meltPanel.DrawPane(_controller, _skin);
            break;

        case CryptoItemsController.CryptoItemState.CREATEBUNDLE:
            // NOTE: Will be implemented post v1 release
            break;

        case CryptoItemsController.CryptoItemState.REFRESH:
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
            _controller.Reset();
            break;
        }
    }
    /// <summary>
    /// Updates an exsiting App
    /// </summary>
    public void UpdateAp()
    {
        App newApp = new App
        {
            name        = AppInfo.name,
            image       = AppInfo.image,
            description = AppInfo.description
        };

        Enjin.UpdateApp(newApp);
        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.REFRESHAPPLIST);

        State = PlatformState.VIEW;
    }
Beispiel #12
0
    /// <summary>
    /// Updates an existing team member
    /// </summary>
    public void UpdateMember()
    {
        List <string> userRoles = new List <string>(UserRoles);
        string        roles     = "[";

        for (int i = 0; i < UpdateUserObject.roles.Length; i++)
        {
            if (userRoles.Contains(UpdateUserObject.roles[i].name))
            {
                roles += "\"" + UpdateUserObject.roles[i].name + "\"";

                if (i != UpdateUserObject.roles.Length)
                {
                    roles += ",";
                }
            }
        }

        if (RoleDropDownSelection != -1)
        {
            roles += "\"" + UserRoles[RoleDropDownSelection] + "\"]";
        }
        else
        {
            roles += "]";
        }

        if (UserObject.email == UpdateUserObject.email)
        {
            UpdateUserObject.email = string.Empty;
        }

        Enjin.UpdateUser(UserObject.id, UserObject.name, UpdateUserObject.email, roles);

        if (Enjin.ServerResponse == ResponseCodes.SUCCESS)
        {
            if (UnityEditor.EditorUtility.DisplayDialog("SUCCESS", "User updated successfully.", "OK"))
            {
                ResetTeamList();
            }
        }

        SelectedRoleIndex = 0;
        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADTEAM);
        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADIDENTITIES);
        SetTeamState(TeamState.VIEWLIST);
    }
Beispiel #13
0
    /// <summary>
    /// Deletes the user (soft delete)
    /// </summary>
    /// <returns>true if deleting the user was successful, otherwise false</returns>
    public bool DeleteUser()
    {
        if (UserList.Count == 1 && CurrentPage != 1)
        {
            CurrentPage--;
        }

        if (Enjin.DeleteUser(UserList[SelectedIndex].id))
        {
            SelectedIndex = 0;
            CurrentPage   = 1;
            ResetTeamList();
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADIDENTITIES);
            return(true);
        }

        return(false);
    }
Beispiel #14
0
    /// <summary>
    /// Checks the panel level and sets the state appropriately
    /// </summary>
    public void PanelLevelBack()
    {
        if (PanelLevelIndex == 0)
        {
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.REFRESHUSERROLES);
            SetTeamState(TeamState.VIEWLIST);
        }
        else
        {
            if (RolesList.Count != 0)
            {
                LastSelectedRoleIndex = -1;
                SelectedRoleIndex     = 0;
            }

            PanelLevelIndex--;
            SetTeamState(TeamState.MANAGEROLES);
        }
    }
Beispiel #15
0
    /// <summary>
    /// Removes a give role from the current user
    /// </summary>
    public void RemoveRole(string role)
    {
        string roles = "[";

        for (int i = 0; i < UpdateUserObject.roles.Length; i++)
        {
            if (UpdateUserObject.roles[i].name == role)
            {
                continue;
            }

            roles += "\"" + UpdateUserObject.roles[i].name + "\"";

            if (i != UpdateUserObject.roles.Length)
            {
                roles += ",";
            }
        }

        roles += "]";

        if (UserObject.email == UpdateUserObject.email)
        {
            UpdateUserObject.email = string.Empty;
        }

        EnjinEditor.Log("Roles - " + roles);
        Enjin.UpdateUser(UserObject.id, UserObject.name, UpdateUserObject.email, roles);

        if (Enjin.ServerResponse == ResponseCodes.SUCCESS)
        {
            if (UnityEditor.EditorUtility.DisplayDialog("SUCCESS", "Removed role successfully.", "OK"))
            {
                ResetTeamList();
            }
        }

        SelectedRoleIndex = 0;
        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADTEAM);
        SetTeamState(TeamState.VIEWLIST);
    }
    /// <summary>
    /// Placeholder for logic changes in the next pass -- adds pop-up notifications for completed requests
    /// </summary>
    public void CheckForPopUps()
    {
        #region Popup Notification Handler
        // handle pending requests on the controller monitoring for result updates
        List <string> requestsCompleted = new List <string>();
        foreach (KeyValuePair <string, IdentitiesTabController.Result> entry in GetResults())
        {
            switch (entry.Value.Status)
            {
            case Status.SUCCESS:
                if (EditorUtility.DisplayDialog("SUCCESS", "A pending request has posted successfully. Refresh now?\n\nNote, refreshing will return you to the index and clear any active data entry.", "Refresh", "Cancel"))
                {
                    EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                    RefreshLists();
                }
                requestsCompleted.Add(entry.Key);
                break;

            case Status.FAILURE:
                if (EditorUtility.DisplayDialog("FAILURE", "A pending request could not be processed due to a status of " + entry.Value.Status + ". Refresh now?\n\nNote, refreshing will return you to the index and clear any active data entry.", "Refresh", "Cancel"))
                {
                    EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                    RefreshLists();
                }
                requestsCompleted.Add(entry.Key);
                break;

            case Status.NONE:
                if (EditorUtility.DisplayDialog("FAILURE", "Something went wrong and the status of this request was not set.\n The request returned a status of " + entry.Value.Status + ". Refresh now?\n\n note: refreshing will return you to the index and clear any data entry.", "Refresh", "Cancel"))
                {
                    EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                    RefreshLists();
                }
                requestsCompleted.Add(entry.Key);
                break;
            }
        }
        #endregion
    }
    /// <summary>
    /// Creates a new App
    /// </summary>
    public void CreateApp()
    {
        App newApp = new App
        {
            name        = AppInfo.name,
            image       = AppInfo.image,
            description = AppInfo.description
        };

        if (newApp.image == "" || newApp.image == null)
        {
            newApp.image = "None";
        }
        else
        {
            newApp.image = AppInfo.image;
        }

        if (newApp.description == "" || newApp.description == null)
        {
            newApp.description = "None";
        }
        else
        {
            newApp.description = AppInfo.description;
        }

        Enjin.CreateApp(newApp);
        //EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.REFRESHAPPLIST);
        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.LOGOUT);
        IsLoginSuccessful();
        ProcessStartUp();
        //Enjin.StartPlatform(Enjin.APIURL, LoginInfo.username, LoginInfo.password);
        //Enjin.Login(LoginInfo.username, LoginInfo.password);
        AppInfo = new AppData();

        State = PlatformState.VIEW;
    }
    /// <summary>
    /// Initialization when editor window is opened
    /// </summary>
    private void OnEnable()
    {
        _toolbarIndex   = 0;
        _toolbarHeaders = new GUIContent[] { new GUIContent("Home", "Entry point panel"), new GUIContent("Team", "Team management panel"), new GUIContent("Identities", "Identities management panel"),
                                             new GUIContent("CryptoItems", "Token management panel"), new GUIContent("Wallet", "Wallet management panel"), new GUIContent("Settings", "Account settings / options panel") };

        Texture2D bgText    = new Texture2D(2, 2);
        var       fillColor = bgText.GetPixels32();

        for (int i = 0; i < fillColor.Length; i++)
        {
            fillColor[i] = new Color32(128, 128, 128, 255);
        }

        bgText.SetPixels32(fillColor);
        bgText.Apply();

        _skin = (AssetDatabase.LoadAssetAtPath <GUISkin>("Assets/Enjin/Enjin SDK Editor/Themes/EnjinSDKEditorSkin.guiskin"));
        _skin.label.normal.background = bgText;

        EnjinEditor.SkinTheme = _skin;
        EnjinEditor.Init();
    }
Beispiel #19
0
 /// <summary>
 /// Checks if user has required permission to access feature
 /// </summary>
 /// <param name="perm">permission to check for</param>
 /// <returns>true/false based on results</returns>
 public bool HasPermission(UserPermission perm)
 {
     return(EnjinEditor.HasPermission(perm));
 }
Beispiel #20
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();
    }
    public void DrawCreateEditPane(IdentitiesTabController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 10, 912, 606), skin.GetStyle("TopBackground"));
        EditorGUILayout.BeginHorizontal();

        if (controller.State == IdentitiesTabController.IdentityState.EDIT)
        {
            EditorGUILayout.LabelField(new GUIContent("VIEW IDENTITY"), skin.GetStyle("MainTitle"));
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent(controller.State.ToString() + " IDENTITY"), skin.GetStyle("MainTitle"));
        }

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("CURRENT APPLICATION"), skin.GetStyle("Subtitle"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("ID: " + Enjin.AppID.ToString() + " -> " + EnjinEditor.AppsNameList[EnjinEditor.SelectedAppIndex]), skin.GetStyle("LargeTextDark"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("USER ID"), skin.GetStyle("Subtitle"));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);

        if (controller.State == IdentitiesTabController.IdentityState.CREATE)
        {
            EditorStyles.popup.fixedHeight     = 30;
            EditorStyles.popup.fontSize        = 12;
            controller.CurrentIdentity.user.id = System.Convert.ToInt32(EditorGUILayout.Popup(controller.CurrentIdentity.user.id, controller.UserIDs.ToArray(), GUILayout.Width(220), GUILayout.Height(30)));
            EditorStyles.popup.fixedHeight     = 15;
            EditorStyles.popup.fontSize        = 11;
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.user.id.ToString()), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30));
        }

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);

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

        if (controller.State == IdentitiesTabController.IdentityState.CREATE)
        {
            EditorGUILayout.LabelField(new GUIContent("ETHEREUM ADDRESS"), skin.GetStyle("Subtitle"));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(14);

            controller.CurrentIdentity.ethereum_address = EditorGUILayout.TextField(controller.CurrentIdentity.ethereum_address, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }
        else
        {
            if (controller.CurrentIdentity.linking_code == "")
            {
                EditorGUILayout.LabelField(new GUIContent("ETHEREUM ADDRESS"), skin.GetStyle("Subtitle"));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(14);

                EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.ethereum_address), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30));
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("LINKING CODE"), skin.GetStyle("Subtitle"));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(14);

                EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.linking_code), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30));
            }
        }

        EditorGUILayout.EndHorizontal();


        if (controller.State != IdentitiesTabController.IdentityState.CREATE && controller.CurrentIdentity.linking_code == "")
        {
            GUILayout.Space(20);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(14);
            EditorGUILayout.LabelField(new GUIContent("To change your wallet addres you will need to unlink this wallet."), skin.GetStyle("ContentDark"));
            EditorGUILayout.EndHorizontal();

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

            if (GUILayout.Button(new GUIContent("Unlink Wallet"), GUILayout.Width(120), GUILayout.Height(30)))
            {
                if (EditorUtility.DisplayDialog("Unlink Wallet", "This will unlink this editor from your developer wallet. Do you want to proceed?", "Accept", "Cancel"))
                {
                    Enjin.UnLinkIdentity(controller.CurrentIdentity.id);
                    EnjinEditor.CurrentUser = Enjin.GetUserRaw(controller.CurrentIdentity.id);
                    EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADALL);
                }
            }

            EditorGUILayout.EndHorizontal();
        }

        /***
         * Disabled for V1
         */
        //GUILayout.Space(20);
        //EditorGUILayout.BeginHorizontal();
        //EditorGUILayout.LabelField(new GUIContent("FIELDS"), skin.GetStyle("MainTitle"));
        //EditorGUILayout.EndHorizontal();
        //GUILayout.Space(20);
        //EditorGUILayout.BeginHorizontal();
        //GUILayout.Space(14);

        ///* TODO POST V1
        // *      - Make fields additive so user can add fields as nessisary
        // */

        //if (controller.CurrentIdentity.fields == null || controller.CurrentIdentity.fields.Length == 0)
        //{
        //    controller.CurrentIdentity.fields = new Fields[2];
        //    controller.CurrentIdentity.fields = Enjin.DefaultFields;
        //}

        //_scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(320), GUILayout.Height(140));

        //for (int i = 0; i < controller.CurrentIdentity.fields.Length; i++)
        //{
        //    EditorGUILayout.BeginVertical("helpBox");
        //    EditorGUILayout.BeginHorizontal();
        //    GUILayout.Space(14);
        //    EditorGUILayout.LabelField(new GUIContent("KEY"), skin.GetStyle("Subtitle"), GUILayout.Width(140));
        //    EditorGUILayout.LabelField(new GUIContent("VALUE"), skin.GetStyle("Subtitle"), GUILayout.Width(140));
        //    EditorGUILayout.EndHorizontal();
        //    EditorGUILayout.BeginHorizontal();
        //    GUILayout.Space(14);
        //    EditorGUILayout.LabelField(new GUIContent(controller.CurrentIdentity.fields[i].key), GUILayout.Width(140), GUILayout.Height(30));
        //    controller.CurrentIdentity.fields[i].value = EditorGUILayout.TextField(controller.CurrentIdentity.fields[i].value, skin.textField, GUILayout.Width(140), GUILayout.Height(30));
        //    EditorGUILayout.EndHorizontal();
        //    GUILayout.Space(8);
        //    EditorGUILayout.EndVertical();
        //}

        //EditorGUILayout.EndScrollView();
        //EditorGUILayout.EndHorizontal();

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

        if (controller.State == IdentitiesTabController.IdentityState.CREATE)
        {
            if (GUILayout.Button(new GUIContent("CREATE"), GUILayout.Width(100), GUILayout.Height(30)))
            {
                controller.ProcessRequest(ProcessTasks.CREATE, controller.CurrentIdentity, _properties);

                //if (!Enjin.ValidateAddress(controller.CurrentIdentity.ethereum_address))
                //    EditorUtility.DisplayDialog("INVALID ADDRESS", "The address you entered is not valid. Please enter a valid address", "Ok");
                //else
                //{
                //    controller.ProcessRequest(ProcessTasks.CREATE, controller.CurrentIdentity, _properties);
                //}
            }
        }

        if (GUILayout.Button(new GUIContent("BACK"), GUILayout.Width(100), GUILayout.Height(30)))
        {
            controller.CurrentIdentity.fields = new Fields[0];
            controller.State = IdentitiesTabController.IdentityState.VIEW;
        }

        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        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();
    }
Beispiel #23
0
    public void ProcessRequests()
    {
        if (Processing)
        {
            return;
        }

        // Start processing result queue
        Processing = true;
        // handle pending requests on the controller monitoring for result updates
        RequestsCompleted.Clear();

        foreach (KeyValuePair <string, Result> entry in ResultsQueue)
        {
            if (entry.Value.Type == Result.Types.CRYPTOITEMS && CIController != null)
            {
                switch (entry.Value.Status)
                {
                case Status.SUCCESS:
                    if (entry.Value.compoundQueries.Count > 0)
                    {
                        foreach (CompoundQuery query in entry.Value.compoundQueries)
                        {
                            Request request = CIController.ProcessCryptoItem(query.Task, query.CryptoItem, query.Properties);

                            if (EnjinEditor.IsRequestSuccessfull(request.state))
                            {
                                EditorUtility.DisplayDialog("SUCCESS", "Your previous request contained an additional request which has now 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");
                            }

                            CIController.State = CryptoItemsController.CryptoItemState.MAIN;
                        }
                        RequestsCompleted.Add(entry.Key);
                    }
                    else
                    {
                        if (EditorUtility.DisplayDialog("SUCCESS", "A pending request has posted successfully. Refresh now?\n\nNote, refreshing will return you to the index and clear any active data entry.", "Refresh", "Cancel"))
                        {
                            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                            CIController.Reset();
                        }
                        RequestsCompleted.Add(entry.Key);
                    }
                    break;

                case Status.FAILURE:
                    if (EditorUtility.DisplayDialog("FAILURE", "A pending request could not be processed due to a status of " + entry.Value.Status + ". Refresh now?\n\nNote, refreshing will return you to the index and clear any active data entry.", "Refresh", "Cancel"))
                    {
                        EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
                        CIController.Reset();
                    }
                    RequestsCompleted.Add(entry.Key);
                    break;
                }
            }
            else if (entry.Value.Type == Result.Types.IDENTITIES)
            {
                // noop -- stub example for future notifications
            }
            else
            {
                // noop
            }
        }

        if (RequestsCompleted.Count > 0)
        {
            RequestsCompleted.ForEach(e => ResultsQueue.Remove(e));
        }

        // Done processing result queue.
        Processing = false;
    }
    /// <summary>
    /// Method for creating and editing team members
    /// </summary>
    public void DrawTeamMemberPanel(TeamController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 10, 912, 606), skin.GetStyle("TopBackground"));
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(new GUIContent(controller.State.ToString() + " TEAM MEMBER"), skin.GetStyle("MainTitle"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField(new GUIContent("USERNAME", "Username for user account"), skin.GetStyle("Subtitle"));

        if (controller.State == TeamState.EDIT)
        {
            controller.UpdateUserObject.name = EditorGUILayout.TextField(controller.UpdateUserObject.name, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }
        else
        {
            controller.UserObject.name = EditorGUILayout.TextField(controller.UserObject.name, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent("EMAIL ADDRESS", "Email address of user you wish to create"), skin.GetStyle("Subtitle"));

        if (controller.State == TeamState.EDIT)
        {
            controller.UpdateUserObject.email = EditorGUILayout.TextField(controller.UpdateUserObject.email, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }
        else
        {
            controller.UserObject.email = EditorGUILayout.TextField(controller.UserObject.email, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }

        GUILayout.Space(20);

        if (controller.State == TeamState.CREATE)
        {
            EditorGUILayout.LabelField(new GUIContent("PASSWORD (Optional)", "Not setting a passwrod will result in a random one being generated. An invite with password will be sent to provided email address."), skin.GetStyle("Subtitle"));
            controller.UserObject.password = EditorGUILayout.TextField(controller.UserObject.password, skin.textField, GUILayout.Width(320), GUILayout.Height(30));
        }

        if (EnjinEditor.HasRole(EnjinSDK.UserRoles.PLATFORM_OWNER) || EnjinEditor.HasRole(EnjinSDK.UserRoles.ADMIN))
        {
            List <string> availableRoles = new List <string>();
            availableRoles = controller.GetAvailableRoles();

            GUILayout.Space(20);
            EditorGUILayout.LabelField(new GUIContent("SELECT ROLE TO ADD", "Initial role to be assigned to user. If none is selected, Player role will be assigned by default"), skin.GetStyle("Subtitle"));

            if (availableRoles.Count > 0)
            {
                EditorStyles.popup.fixedHeight = 30;
                EditorStyles.popup.fontSize    = 12;
                string[] rolesArray = availableRoles.ToArray();
                controller.SelectedRoleIndex = EditorGUILayout.Popup(controller.SelectedRoleIndex, rolesArray, GUILayout.Width(120), GUILayout.Height(30));
                controller.SetLocalRoleIndex(rolesArray);
                EditorStyles.popup.fixedHeight = 15;
                EditorStyles.popup.fontSize    = 11;
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("All Available Roles Assigned"), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30));
            }

            GUILayout.Space(30);
        }

        EditorGUILayout.EndVertical();

        // BEGIN COLUMN 2
        if (controller.State != TeamState.CREATE)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(new GUIContent("ASSIGNED ROLES"), skin.GetStyle("Subtitle"));
            GUILayout.Space(10);
            _roleScrollPos = EditorGUILayout.BeginScrollView(_roleScrollPos, GUILayout.Height(450));

            foreach (string role in controller.UserCurrentRolesList)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent(role), skin.GetStyle("LargeText"), GUILayout.Width(320), GUILayout.Height(30));

                if (role != "Player" && role != "Platform Owner")
                {
                    if (GUILayout.Button("REMOVE", GUILayout.Width(100), GUILayout.Height(30)))
                    {
                        if (controller.IsEmailValid(controller.UpdateUserObject.email))
                        {
                            controller.RemoveRole(role);
                        }

                        GUI.FocusControl(null);
                    }
                }

                EditorGUILayout.EndHorizontal();
                GUILayout.Space(10);
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            GUILayout.Space(30);
        }

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

        if (controller.State == TeamState.CREATE)
        {
            if (GUILayout.Button("CREATE", GUILayout.Width(100), GUILayout.Height(30)))
            {
                if (controller.IsEmailValid(controller.UserObject.email))
                {
                    if (controller.RoleDropDownSelection == -1)
                    {
                        controller.RoleDropDownSelection = 0;
                    }

                    controller.CreateMember();
                }

                GUI.FocusControl(null);
            }
        }
        else
        {
            if (GUILayout.Button("UPDATE", GUILayout.Width(100), GUILayout.Height(30)))
            {
                if (controller.IsEmailValid(controller.UpdateUserObject.email))
                {
                    controller.UpdateMember();
                }

                GUI.FocusControl(null);
            }
        }

        if (GUILayout.Button("BACK", GUILayout.Width(100), GUILayout.Height(30)))
        {
            controller.SetTeamState(TeamState.VIEWLIST);
        }

        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        GUILayout.EndArea();
    }
 /// <summary>
 /// Handles executing logout process
 /// </summary>
 public void Logout()
 {
     _loginState = LoginState.NONE;
     LoginInfo   = new LoginCredentials();
     EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.LOGOUT);
 }
    public void DrawGeneralSettingsPanel(GUISkin skin, SettingsController controller)
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.Width(880));
        controller.GeneralFoldout = EditorGUILayout.Foldout(controller.GeneralFoldout, new GUIContent("GENERAL SETTINGS"));

        if (controller.GeneralFoldout)
        {
            #region General Settings Body
            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(150));

            #region General Settings Column 1
            EditorGUILayout.BeginVertical(GUILayout.Width(150));
            EditorGUILayout.LabelField(new GUIContent("RESET USER CACHE"), GUILayout.Width(140));

            if (GUILayout.Button(new GUIContent("Reset"), GUILayout.Width(120), GUILayout.Height(20)))
            {
                PlayerPrefs.DeleteKey("UserData");
            }

            EditorGUILayout.EndVertical();
            #endregion

            #region General Settings Column 2
            //EditorGUILayout.BeginVertical(GUILayout.Width(150));
            //EditorGUILayout.LabelField(new GUIContent("ITEMS PER PAGE"), GUILayout.Width(140));
            //controller.UserSettings.ItemsPerPage = EditorGUILayout.IntField(controller.UserSettings.ItemsPerPage, skin.textField, GUILayout.Width(120), GUILayout.Height(30));

            //if (GUILayout.Button(new GUIContent("Update", "Updates the items per page and saves as default setting"), GUILayout.Width(120), GUILayout.Height(20)))
            //{
            //    controller.UserSettings.Update();
            //    EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.UPDATEITEMSPERPAGE);
            //}

            //EditorGUILayout.EndVertical();
            #endregion

            #region General Settings Column 3
            EditorGUILayout.BeginVertical(GUILayout.Width(150));
            EditorGUILayout.LabelField(new GUIContent("APPROVE ALLOWANCE"), GUILayout.Width(140));

            if (GUILayout.Button(new GUIContent("Approve", "Sets approval allowance to max"), GUILayout.Width(120), GUILayout.Height(20)))
            {
                if (controller.IsAllowanceApproved)
                {
                    EnjinEditor.DisplayDialog("ERROR", "Approval has already been set");
                }
                else
                {
                    if (controller.AllowanceError == SettingsController.AllowanceErrors.NOTLINKED)
                    {
                        EnjinEditor.DisplayDialog("ERROR", "Wallet must be linked prior to approving the allowance");
                    }
                    else if (controller.AllowanceError == SettingsController.AllowanceErrors.INVALIDADDRESS)
                    {
                        EnjinEditor.DisplayDialog("ERROR", "The eth address you're trying to approve doesn't exists");
                    }
                    else
                    {
                        EnjinSDK.Enjin.SetAllowance(EnjinEditor.CurrentUserIdentity.id);
                        EnjinEditor.DisplayDialog("INFO", "The approval request has been sent. Approve this in the wallet then press ok.");
                        controller.UpdateAllowance();
                    }
                }

                EditorGUILayout.EndVertical();
            }
            #endregion

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

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
    private void LinkedWallet()
    {
        GUILayout.BeginArea(new Rect(5, 10, 912, 606), _skin.GetStyle("TopBackground"));
        EditorGUILayout.LabelField(new GUIContent("WALLET DETAILS"), _skin.GetStyle("MainTitle"));
        GUILayout.Space(30);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.LabelField(new GUIContent("ENJ BALANCE"), _skin.GetStyle("Subtitle"), GUILayout.Width(140));
        EditorGUILayout.LabelField(new GUIContent("ETH BALANCE"), _skin.GetStyle("Subtitle"), GUILayout.Width(140));
        EditorGUILayout.LabelField(new GUIContent("ACTIVE TOKENS"), _skin.GetStyle("Subtitle"), GUILayout.Width(140));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.LabelField(new GUIContent(Enjin.GetEnjBalance.ToString("#,##0.###")), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140));
        EditorGUILayout.LabelField(new GUIContent(Enjin.GetEthBalance.ToString("#,##0.########")), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140));
        EditorGUILayout.LabelField(new GUIContent(_activeTokenBalance), _skin.GetStyle("LargeNumbers"), GUILayout.Width(140));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.LabelField(new GUIContent("LINKED ADDRESS"), _skin.GetStyle("Subtitle"), GUILayout.Width(120));
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent(EnjinEditor.CurrentUserIdentity.ethereum_address), _skin.GetStyle("ContentDark"));
        GUILayout.Space(14);

        if (GUILayout.Button(new GUIContent(ClipBoardIcon, "Copy Wallet Address to Clipboard"), GUILayout.Width(32), GUILayout.Height(32)))
        {
            EditorGUIUtility.systemCopyBuffer = EnjinEditor.CurrentUserIdentity.ethereum_address;
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        //EditorGUILayout.BeginHorizontal();
        //GUILayout.Space(14);

        //if (GUILayout.Button(new GUIContent("Download Wallet"), GUILayout.Width(120), GUILayout.Height(30)))
        //    Application.OpenURL("https://enjinwallet.io/");

        //EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);
        EditorGUILayout.LabelField(new GUIContent("To change your wallet addres you will need to unlink this wallet."), _skin.GetStyle("ContentLight"));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(14);

        if (GUILayout.Button(new GUIContent("Unlink Wallet"), GUILayout.Width(120), GUILayout.Height(30)))
        {
            if (EditorUtility.DisplayDialog("Unlink Wallet", "This will unlink this editor from your developer wallet. Do you want to proceed?", "Accept", "Cancel"))
            {
                Enjin.UnLinkIdentity(EnjinEditor.CurrentUserIdentity.id);
                EnjinEditor.CurrentUser = Enjin.GetUserRaw(EnjinEditor.CurrentUser.id);
                EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADALL);
            }
        }

        EditorGUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
 /// <summary>
 /// Starts up the platform
 /// </summary>
 public void ProcessStartUp()
 {
     Enjin.IsLoggedIn = true;
     EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.INITILAIZEPLATFORM);
     _loginState = LoginState.VALID;
 }
    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();
    }
Beispiel #30
0
    /// <summary>
    /// Build and Draw Main Panel
    /// </summary>
    public void DrawPane(CryptoItemsController controller, GUISkin skin)
    {
        GUILayout.BeginArea(new Rect(5, 126, 912, 490), skin.GetStyle("TopBackground"));
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();

        if (controller.HasListRefreshed)
        {
            EditorGUILayout.LabelField(new GUIContent(EnjinEditor.CurrentAppName.ToUpper()), skin.GetStyle("MainTitle"));
            GUILayout.FlexibleSpace();
            //GUILayout.Space(16);
            //EditorStyles.popup.fixedHeight = 30;
            //EditorStyles.popup.fontSize = 12;
            //controller.ItemFilter = (CryptoItemsController.ItemFilterType)EditorGUILayout.EnumPopup(controller.ItemFilter, GUILayout.Width(180), GUILayout.Height(30));
            //EditorStyles.popup.fixedHeight = 15;
            //EditorStyles.popup.fontSize = 11;
        }
        else
        {
            EditorGUILayout.LabelField(new GUIContent("SEARCH RESULTS"), skin.GetStyle("MainTitle"));
        }

        if (GUILayout.Button("REFRESH", GUILayout.Height(30), GUILayout.Width(80)))
        {
            EnjinEditor.ExecuteMethod(EnjinEditor.CallMethod.RELOADITEMS);
        }

        GUILayout.Space(10);
        EditorGUILayout.EndHorizontal();

        if (controller.LastFilterSelected != controller.FilterSelection)
        {
            controller.LastFilterSelected = controller.FilterSelection;
        }

        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);
        EditorGUILayout.LabelField(new GUIContent("Type"), skin.GetStyle("Subtitle"), GUILayout.Width(76));
        EditorGUILayout.LabelField(new GUIContent("Name"), skin.GetStyle("Subtitle"), GUILayout.Width(100));
        EditorGUILayout.LabelField(new GUIContent("Index"), skin.GetStyle("Subtitle"), GUILayout.Width(74));
        EditorGUILayout.LabelField(new GUIContent("Balance"), skin.GetStyle("Subtitle"), GUILayout.Width(108));
        EditorGUILayout.LabelField(new GUIContent("Total Supply"), skin.GetStyle("Subtitle"), GUILayout.Width(102));
        EditorGUILayout.LabelField(new GUIContent("Total Reserve"), skin.GetStyle("Subtitle"), GUILayout.Width(98));
        EditorGUILayout.LabelField(new GUIContent("Circulating"), skin.GetStyle("Subtitle"), GUILayout.Width(86));
        EditorGUILayout.LabelField(new GUIContent("Transferable"), skin.GetStyle("Subtitle"), GUILayout.Width(114));
        EditorGUILayout.LabelField(new GUIContent("Supply Type"), skin.GetStyle("Subtitle"));
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(16);

        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Width(890), GUILayout.Height(342));

        if (EnjinEditor.CurrentUserIdentity.linking_code != string.Empty)
        {
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("WARNING: You don't have a wallet linked. Select the wallet tab to link your wallet"), skin.GetStyle("MainTitle"));
            EditorGUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
        }
        else if (controller.CryptoItemList != null && controller.CryptoItemList.Count != 0)
        {
            for (int i = 0; i < controller.CryptoItemList.Count; i++)
            {
                if (controller.SelectedIndex == i)
                {
                    EditorGUILayout.BeginHorizontal(skin.box);
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                }

                if (controller.CryptoItemList[i].nonFungible)
                {
                    EditorGUILayout.LabelField(new GUIContent("Non-fungible"), skin.GetStyle("ContentDark"), GUILayout.Width(75));
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent("Fungible"), skin.GetStyle("ContentDark"), GUILayout.Width(75));
                }

                Rect lastRect = GUILayoutUtility.GetLastRect();

                if (GUI.Button(new Rect(lastRect.x, lastRect.y, 890.0f, lastRect.height), GUIContent.none, skin.button))
                {
                    if (controller.SelectedIndex == i)
                    {
                        controller.State                     = CryptoItemsController.CryptoItemState.VIEW;
                        controller.CurrentCryptoItem         = controller.CryptoItemList[controller.SelectedIndex];
                        controller.CurrentCryptoItem.itemURI = Enjin.GetCryptoItemURI(controller.CurrentCryptoItem.token_id, controller.CurrentCryptoItem.index, false);
                    }

                    controller.SelectedIndex = i;
                }

                GUILayout.Space(10);

                if (controller.CryptoItemList[i].name.Length > 40)
                {
                    EditorGUILayout.LabelField(new GUIContent(controller.CryptoItemList[i].name.Substring(0, 38) + ".."), skin.GetStyle("ContentDark"), GUILayout.Width(160));
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent(controller.CryptoItemList[i].name), skin.GetStyle("ContentDark"), GUILayout.Width(100));
                }

                GUILayout.Space(10);

                try
                {
                    if (controller.CryptoItemList[i].index != null)
                    {
                        string   indexList = "";
                        string[] indices   = controller.CryptoItemList[i].index.Split(',');

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

                                indexList += subItemIndex;
                            }
                        }

                        EditorGUILayout.LabelField(new GUIContent(indexList), skin.GetStyle("ContentDark"), GUILayout.Width(50));
                    }
                    else
                    {
                        EditorGUILayout.LabelField(new GUIContent(""), skin.GetStyle("ContentDark"), GUILayout.Width(50));
                    }
                }
                catch (System.Exception)
                {
                    EditorGUILayout.LabelField(new GUIContent(""), skin.GetStyle("ContentDark"), GUILayout.Width(50));
                }

                GUILayout.Space(10);
                EditorGUILayout.LabelField(new GUIContent(controller.CryptoItemList[i].balance.ToString()), skin.GetStyle("ContentDark"), GUILayout.Width(90));
                GUILayout.Space(10);

                if (controller.CryptoItemList[i].supplyModel != SupplyModel.INFINITE)
                {
                    if (controller.CryptoItemList[i].totalSupply.Length > 12)
                    {
                        EditorGUILayout.LabelField(new GUIContent(System.String.Format("{0:N0}..", System.Int32.Parse(controller.CryptoItemList[i].totalSupply.Substring(0, 9)))), skin.GetStyle("ContentDark"), GUILayout.Width(90));
                    }
                    else
                    {
                        EditorGUILayout.LabelField(new GUIContent(System.String.Format("{0:N0}", System.Int32.Parse(controller.CryptoItemList[i].totalSupply))), skin.GetStyle("ContentDark"), GUILayout.Width(90));
                    }
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent("INFINITE"), skin.GetStyle("ContentDark"), GUILayout.Width(90));
                }

                GUILayout.Space(10);
                EditorGUILayout.LabelField(new GUIContent(System.String.Format("{0:N0}", System.Int32.Parse(controller.CryptoItemList[i].reserve))), skin.GetStyle("ContentDark"), GUILayout.Width(80));
                GUILayout.Space(10);
                EditorGUILayout.LabelField(new GUIContent(System.String.Format("{0:N0}", System.Int32.Parse(controller.CryptoItemList[i].circulatingSupply))), skin.GetStyle("ContentDark"), GUILayout.Width(70));
                GUILayout.Space(10);
                EditorGUILayout.LabelField(new GUIContent(controller.CryptoItemList[i].transferable.ToString()), skin.GetStyle("ContentDark"), GUILayout.Width(100));
                GUILayout.Space(10);

                if (controller.CryptoItemList[i].supplyModel == SupplyModel.COLLAPSING)
                {
                    EditorGUILayout.LabelField(new GUIContent("COLLAPSE"), skin.GetStyle("ContentDark"), GUILayout.Width(66));
                }
                else if (controller.CryptoItemList[i].supplyModel == SupplyModel.ANNUAL_PERCENTAGE)
                {
                    EditorGUILayout.LabelField(new GUIContent("ANNUAL %"), skin.GetStyle("ContentDark"), GUILayout.Width(66));
                }
                else if (controller.CryptoItemList[i].supplyModel == SupplyModel.ANNUAL_VALUE)
                {
                    EditorGUILayout.LabelField(new GUIContent("ANNUAL #"), skin.GetStyle("ContentDark"), GUILayout.Width(66));
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent(controller.CryptoItemList[i].supplyModel.ToString()), skin.GetStyle("ContentDark"), GUILayout.Width(66));
                }

                if (controller.CryptoItemList[i].markedForDelete)
                {
                    EditorGUILayout.LabelField(new GUIContent(skin.GetStyle("Images").normal.scaledBackgrounds[2] as Texture2D, "Marked for Deletion"), GUILayout.Width(16), GUILayout.Height(16));
                }
                else
                {
                    EditorGUILayout.LabelField(new GUIContent(""), GUILayout.Width(16), GUILayout.Height(16));
                }

                EditorGUILayout.EndHorizontal();
                GUI.backgroundColor = _bgDefault;
                GUILayout.Space(8);
            }
        }

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

        if (!controller.IsSearchMode && controller.CryptoItemList.Count != 0)
        {
            if (controller.CurrentPage != 1)
            {
                GUILayout.Space(10);

                if (GUILayout.Button(new GUIContent("<<"), GUILayout.Height(20)))
                {
                    if (controller.CurrentPage != 1)
                    {
                        controller.CurrentPage--;
                        controller.PageCheck();
                    }
                }
            }

            GUILayout.Space(5);

            for (int i = controller.FirstPage; i < controller.TotalPages + 1; i++)
            {
                if (i != controller.CurrentPage)
                {
                    _numStyle = skin.GetStyle("PageNumberDark");
                }
                else
                {
                    _numStyle = skin.GetStyle("PageNumberLight");
                }


                if (GUILayout.Button(new GUIContent(i.ToString()), _numStyle, GUILayout.Width(30)))
                {
                    controller.CurrentPage = i;
                    controller.PageCheck();
                }

                if (i - controller.FirstPage == 9)
                {
                    break;
                }
            }

            if (controller.CurrentPage != controller.TotalPages)
            {
                if (GUILayout.Button(new GUIContent(">>"), GUILayout.Height(20)))
                {
                    if (controller.CurrentPage != controller.TotalPages)
                    {
                        controller.CurrentPage++;
                        controller.PageCheck();
                    }
                }
            }
        }

        GUILayout.FlexibleSpace();

        if (controller.CryptoItemList.Count > 0)
        {
            // =================== ADVANCED SEND TEST BUTTON ========================
            //if (GUILayout.Button("A SEND", GUILayout.Width(100), GUILayout.Height(30)))
            //{
            //CryptoItemBatch testItems = new CryptoItemBatch(EnjinEditor.CurrentUserIdentity.id);

            //for (int i = 0; i < controller.CryptoItemList.Count; i++)
            //    testItems.Add(EnjinEditor.CurrentUserIdentity.ethereum_address, "0xeD7aA45fd86c4D58261B3B2Cce9f68009c76C7d1", controller.CryptoItemList[i], controller.CryptoItemList[i].balance);

            //testItems.Send();
            //}
            // ======================================================================

            if (GUILayout.Button("VIEW", GUILayout.Width(100), GUILayout.Height(30)))
            {
                controller.CurrentCryptoItem = controller.CryptoItemList[controller.SelectedIndex];

                // On-demand loading of item URI to avoid performance issues-- this is a demanding call.
                if (controller.CurrentCryptoItem.itemURI == null)
                {
                    controller.CurrentCryptoItem.itemURI = Enjin.GetCryptoItemURI(controller.CurrentCryptoItem.token_id, controller.CurrentCryptoItem.index, false);
                }

                controller.State = CryptoItemsController.CryptoItemState.VIEW;
            }

            if (controller.IsCreator(controller.CryptoItemList[controller.SelectedIndex].creator) && !controller.CryptoItemList[controller.SelectedIndex].markedForDelete)
            {
                if (GUILayout.Button("EDIT", GUILayout.Width(100), GUILayout.Height(30)))
                {
                    controller.CurrentCryptoItem = controller.CryptoItemList[controller.SelectedIndex];

                    if (controller.CurrentCryptoItem.itemURI == null)
                    {
                        if (controller.CurrentCryptoItem.nonFungible)
                        {
                            controller.CurrentCryptoItem.itemURI = Enjin.GetCryptoItemURI(controller.CurrentCryptoItem.token_id, controller.CurrentCryptoItem.index, false);
                        }
                        else
                        {
                            controller.CurrentCryptoItem.itemURI = Enjin.GetCryptoItemURI(controller.CurrentCryptoItem.token_id, "0", false);
                        }
                    }

                    controller.TransferFeeEnj = float.Parse((decimal.Parse(controller.CurrentCryptoItem.transferFeeSettings.value) / ((decimal)Mathf.Pow(10, 18))).ToString());
                    controller.NewCryptoItem.transferFeeSettings = controller.CurrentCryptoItem.transferFeeSettings;
                    controller.EditItemName                = controller.CurrentCryptoItem.name;
                    controller.MetaDataURI                 = controller.CurrentCryptoItem.itemURI;
                    controller.EditMetaDataURI             = controller.MetaDataURI;
                    controller.CurrentCryptoItem.isCreator = controller.IsCreator(controller.CurrentCryptoItem.creator);
                    controller.MeltFee = controller.CurrentCryptoItem.meltFeeRatio * 0.01f;
                    controller.State   = CryptoItemsController.CryptoItemState.EDIT;
                }

                if (GUILayout.Button(new GUIContent("MINT"), GUILayout.Width(100), GUILayout.Height(30)))
                {
                    controller.MintableCryptoItems = Enjin.GetMintableItems(controller.CryptoItemList[controller.SelectedIndex].token_id);
                    controller.NumToMint           = 1;
                    controller.RecieverAddress     = new string[1];
                    controller.RecieverAddress[0]  = EnjinEditor.CurrentUserIdentity.ethereum_address;
                    controller.Reserve             = System.Convert.ToInt32(controller.CurrentCryptoItem.reserve);
                    controller.MeltValue2          = (double)((float)System.Convert.ToDecimal(controller.CurrentCryptoItem.meltValue) / Mathf.Pow(10, 18));
                    controller.CurrentCryptoItem   = controller.CryptoItemList[controller.SelectedIndex];
                    controller.State = CryptoItemsController.CryptoItemState.MINT;
                }
            }

            if (controller.CryptoItemList[controller.SelectedIndex].nonFungible == false) //  || System.Int32.Parse(controller.CryptoItemList[controller.SelectedIndex].index) != 0
            {
                if (controller.CryptoItemList[controller.SelectedIndex].balance != 0)
                {
                    if (GUILayout.Button(new GUIContent("MELT"), GUILayout.Width(100), GUILayout.Height(30)))
                    {
                        controller.CurrentCryptoItem = controller.CryptoItemList[controller.SelectedIndex];
                        controller.Balance           = controller.CurrentCryptoItem.balance;
                        controller.State             = CryptoItemsController.CryptoItemState.MELT;
                    }
                }
            }
        }
        GUILayout.Space(8);
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(10);
        GUILayout.EndArea();
    }