示例#1
0
    public void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning("You have multiple copies of the ADAGEMenu object running. Overriding...");
            DestroyImmediate(instance.gameObject);
        }
        DontDestroyOnLoad(this);
        instance = this;

        Messenger.AddListener(ADAGE.k_OnGameStart, OnGameStart);
        Messenger <int, string> .AddListener(ADAGE.k_OnError, ShowError);

        Messenger <string> .AddListener(ADAGE.k_OnConnectionTimeout, OnConnectionTimeout);

        Messenger <int, string> .AddListener(ADAGE.k_OnLoginComplete, OnLogin);

        //Messenger.AddListener(ADAGE.k_OnLoggingIn, ShowPanel<ADAGESplashPanel>);

        popup          = null;
        menuRect       = new Rect(112, 84, 800, 600);
        logoRect       = new Rect(312, 104, 400, 150);
        errorRect      = new Rect(212, 614, 600, 50);
        screenRect     = new Rect(0, 0, defaultResolution.x, defaultResolution.y);
        backgroundRect = overlayRect = screenRect;

        logo = Resources.Load("Images/GLS_Logo_Dark") as Texture2D;

        error     = "";
        errorTime = 0f;

        loading = true;
    }
示例#2
0
 private void OnADAGELoginFailed()
 {
     if (loginAttempts >= maxLoginAttempts)
     {
         ADAGEMenu.ShowPopup(new ADAGEConnectionFailurePopup(loginAttempts));
     }
 }
示例#3
0
    private bool IsValid()
    {
        if (username.Trim() == "" || username == kDefaultUsernameText)
        {
            ADAGEMenu.ShowError(-1, "Username cannot be blank");
            return(false);
        }

        if (password.Trim() == "" || password == kDefaultPasswordText)
        {
            ADAGEMenu.ShowError(-1, "Password cannot be blank");
            return(false);
        }

        if (email.Trim() == "" || email == kDefaultEmailText)
        {
            ADAGEMenu.ShowError(-1, "Email cannot be blank");
            return(false);
        }

        if (password != confirm || confirm == kDefaultConfirmText)
        {
            ADAGEMenu.ShowError(-1, "Passwords do not match");
            return(false);
        }

        return(true);
    }
示例#4
0
    public override void Draw(MonoBehaviour owner = null)
    {
        if (loading)
        {
            InitStyles();
            loading = false;
        }

        GUILayout.BeginArea(buttonAreaRect);
        {
            GUILayout.BeginHorizontal();
            {
                if (ADAGEMenu.AllowPasswordLogin)
                {
                    if (GUILayout.Button("Password", buttonStyle, GUILayout.Width(buttonWidth), GUILayout.ExpandHeight(true)))
                    {
                        OnPassword();
                    }

                    if (ADAGE.AllowGuestLogin || ADAGEMenu.AllowQRLogin)
                    {
                        GUILayout.Space(buttonSpacing);
                    }
                }

                if (ADAGEMenu.AllowQRLogin)
                {
                    if (GUILayout.Button("QR", buttonStyle, GUILayout.Width(buttonWidth), GUILayout.ExpandHeight(true)))
                    {
                        OnQR();
                    }
                    if (ADAGE.AllowGuestLogin)
                    {
                        GUILayout.Space(buttonSpacing);
                    }
                }

                if (ADAGE.AllowGuestLogin)
                {
                    if (GUILayout.Button("Guest", buttonStyle, GUILayout.Width(buttonWidth), GUILayout.ExpandHeight(true)))
                    {
                        OnGuest();
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        if (!isLocked)
        {
            if (GUI.Button(backButtonRect, "Back", buttonStyle))
            {
                ADAGEMenu.ShowPanel <ADAGEHomePanel>();
            }
        }

        GUI.enabled = true;
    }
示例#5
0
    public override void Draw(MonoBehaviour owner = null)
    {
        if (loading)
        {
            InitStyles();
            loading = false;
        }

        usernameFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        username        = GUI.TextField(usernameFieldRect, username, usernameStyle);

        passwordFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        if (keyboardFieldID == passwordFieldID || password != kDefaultPasswordText)
        {
            password = GUI.PasswordField(passwordFieldRect, password, '*', passwordStyle);
        }
        else
        {
            password = GUI.TextField(passwordFieldRect, password, passwordStyle);
        }

        confirmFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        if (keyboardFieldID == confirmFieldID || confirm != kDefaultConfirmText)
        {
            confirm = GUI.PasswordField(confirmFieldRect, confirm, '*', confirmStyle);
        }
        else
        {
            confirm = GUI.TextField(confirmFieldRect, confirm, confirmStyle);
        }

        emailFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        email        = GUI.TextField(emailFieldRect, email, emailStyle);

        if (GUI.Button(submitButtonRect, "Submit", buttonStyle))
        {
            ClearFocus();
            ADAGEMenu.ShowPanel <ADAGESplashPanel>();
            if (IsValid())
            {
                ADAGE.RegisterPlayer(username, email, password, confirm);
            }
        }

        if (GUI.Button(backButtonRect, "Back", buttonStyle))
        {
            ClearFocus();
            ADAGEMenu.ShowLast();
        }

        CheckFields();
    }
示例#6
0
    public override void Draw(MonoBehaviour owner = null)
    {
        if (loading)
        {
            InitStyles();
            CheckFields();
            loading = false;
        }

        usernameFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        username        = GUI.TextField(usernameFieldRect, username, usernameStyle);

        passwordFieldID = GUIUtility.GetControlID(FocusType.Keyboard) + 1;
        if (keyboardFieldID == passwordFieldID || password != kDefaultPasswordText)
        {
            password = GUI.PasswordField(passwordFieldRect, password, '*', passwordStyle);
        }
        else
        {
            password = GUI.TextField(passwordFieldRect, password, passwordStyle);
        }

        GUI.enabled = (password != kDefaultPasswordText && username != kDefaultUsernameText && password.Trim().Length != 0 && username.Trim().Length != 0);
        if (GUI.Button(loginButtonRect, "Login", buttonStyle))
        {
            ClearFocus();
            loginAttempts++;
            ADAGEMenu.ShowPanel <ADAGESplashPanel>();
            ADAGE.LoginPlayer(username.Trim(), password.Trim());
        }
        GUI.enabled = true;

        if (!isLocked)
        {
            if (GUI.Button(backButtonRect, "Back", buttonStyle))
            {
                ClearFocus();
                ADAGEMenu.ShowLast();
            }
        }

        if (ADAGE.AllowFacebook)
        {
            if (GUI.Button(facebookButtonRect, "", imageButtonStyle))
            {
                ClearFocus();
            }
        }

        CheckFields();
    }
示例#7
0
    public override void OnInspectorGUI()
    {
        base.DrawDefaultInspector();
        ADAGEMenu curTarget = (target as ADAGEMenu);

        //GUI.enabled = ADAGEEditor.enableGuestLogin;
        //ADAGE.AllowGuestLogin = EditorGUILayout.Toggle("Enable Guest Login", ADAGE.AllowGuestLogin);

        //curTarget.qrPanel.isLocked = EditorGUILayout.Toggle("Lock QR Panel", curTarget.qrPanel.isLocked);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(curTarget);
        }
    }
示例#8
0
    public override void Draw()
    {
        GUI.BeginGroup(drawRect, "", "box");
        {
            GUI.Label(labelRect, string.Format("The system has made {0} failed attempts to connect to ADAGE. Continue in Offline Mode?", numAttempts));

            if (GUI.Button(yesRect, "Yes"))
            {
                Messenger.Broadcast(ADAGE.k_OnGameStart);
            }

            if (GUI.Button(noRect, "No"))
            {
                ADAGEMenu.ShowPanel <ADAGELoginPanel>();
            }
        }
        GUI.EndGroup();
    }
    public override void Draw(MonoBehaviour owner = null)
    {
        if (loading)
        {
            InitStyles();
            loading = false;
        }

        if (cameraTexture != null)
        {
            GUI.DrawTexture(imagePanelRect, cameraTexture, ScaleMode.StretchToFill);
        }

        GUI.Label(labelRect, "Point your camera at the QR code");

        if (!isLocked)
        {
            if (GUI.Button(backButtonRect, "Back", buttonStyle))
            {
                ADAGEMenu.ShowLast();
            }
        }
    }
示例#10
0
    void Draw(int windowID)
    {
        if (backgroundImage != null)
        {
            GUI.DrawTexture(backgroundRect, backgroundImage);
        }

        if (overlay != null)
        {
            GUI.DrawTexture(overlayRect, overlay);
        }

        GUI.Box(menuRect, "");

        GUI.DrawTexture(logoRect, logo);

        if (GUI.Button(logoRect, "", invisibleButtonStyle))
        {
            ADAGEMenu.ShowPanel <ADAGEHomePanel>();
        }

        GUI.enabled = (popup == null);
        currentPanel.Draw();
        GUI.enabled = true;

        GUI.Label(errorRect, instance.error, errorStyle);

        if (popup != null)
        {
            if (overlay != null)
            {
                GUI.DrawTexture(overlayRect, overlay);
            }

            popup.Draw();
        }
    }
示例#11
0
 private void OnLogin(bool locked = false)
 {
     ClearFocus();
     ADAGEMenu.ShowPanel <ADAGELoginOptionsPanel>(locked);
 }
示例#12
0
 private void OnLogin()
 {
     ClearFocus();
     ADAGEMenu.ShowPanel <ADAGELoginPanel>();
 }
示例#13
0
 private void OnRegistration()
 {
     ClearFocus();
     ADAGEMenu.ShowPanel <ADAGERegisterPanel>();
 }
示例#14
0
 private void OnQR(bool locked = false)
 {
     ADAGEMenu.ShowPanel <ADAGEQRPanel>(locked);
 }
示例#15
0
 private void OnPassword(bool locked = false)
 {
     ADAGEMenu.ShowPanel <ADAGELoginPanel>(locked);
 }
    public override IEnumerator Update()
    {
        if (cameraTexture == null)
        {
                        #if UNITY_WEBPLAYER
            yield return(Application.RequestUserAuthorization(UserAuthorization.WebCam));

            if (Application.HasUserAuthorization(UserAuthorization.WebCam))
            {
                InitCamera();
                yield return(null);
            }
            else
            {
                ADAGEMenu.ShowPanel <ADAGELoginPanel>();
            }
                        #else
            InitCamera();
                        #endif
        }
        else
        {
            if (!cameraTexture.isPlaying)
            {
                cameraTexture.Play();
            }
            else
            {
                if (W != cameraTexture.width)
                {
                    W = cameraTexture.width;
                }
                if (H != cameraTexture.height)
                {
                    H = cameraTexture.height;
                }
            }
        }

        if (c == null)
        {
            c = cameraTexture.GetPixels32();
        }

        if (qrResult != "" && !decoding)
        {
            lastQrResult = qrResult;

            try
            {
                ADAGEQRGroup qrData = LitJson.JsonMapper.ToObject <ADAGEQRGroup>(qrResult);
                ADAGEMenu.ShowPanel <ADAGESplashPanel>();
                ADAGE.ConnectWithQR(qrData.group);
            }
            catch
            {
                if (ADAGEMenu.instance != null)
                {
                    ADAGEMenu.ShowError(-1, "Invalid QR Code");
                    StartThread();
                }
            }
            qrResult = "";
        }
        yield return(null);
    }
示例#17
0
 private void OnRegistration(bool locked = false)
 {
     ClearFocus();
     ADAGEMenu.ShowPanel <ADAGERegisterPanel>(locked);
 }