Esempio n. 1
0
        public void SaveLoginSettings()
        {
            Manager manager = SingletonUtil.GetMain();
            Access  access  = AccessUtil.GetAccessData();
            LoginSettingsPanelComponent loginSettingsPanelComponent = (LoginSettingsPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN_SETTINGS);

#if UNITY_EDITOR
            access.DevJsonPath = loginSettingsPanelComponent.InputField_DevJsonPath.text;
#endif
            access.JsonPath = loginSettingsPanelComponent.InputField_JsonPath.text;

#if UNITY_EDITOR
            PlayerPrefs.SetString("DevJsonPath", access.DevJsonPath);
#endif
            PlayerPrefs.SetString("JsonPath", access.JsonPath);
#if UNITY_EDITOR
            if (loginSettingsPanelComponent.InputField_DevJsonPath.text != string.Empty)
            {
                ClientUtil.SetClient();
            }
#else
            if (loginSettingsPanelComponent.InputField_JsonPath.text != string.Empty)
            {
                ClientUtil.SetClient();
            }
#endif
        }
Esempio n. 2
0
        public static void UpdatePanel()
        {
            LoginPanelComponent loginPanelComponent = (LoginPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN);
            Access access = AccessUtil.GetAccessData();

            bool displayLogin = true;

#if UNITY_EDITOR
            displayLogin = access.DevJsonPath != string.Empty;
#else
            displayLogin = access.JsonPath != string.Empty;
#endif

            loginPanelComponent.InputField_Username.enabled = displayLogin;
            loginPanelComponent.InputField_Token.enabled    = displayLogin;
            loginPanelComponent.Button_Submit.enabled       = displayLogin && loginPanelComponent.InputField_Token.text != string.Empty && loginPanelComponent.InputField_Username.text != string.Empty;

            if (!loginPanelComponent.Button_Submit.enabled)
            {
                loginPanelComponent.Button_Submit.image.color = loginPanelComponent.Button_Submit.colors.disabledColor;
            }
            else
            {
                loginPanelComponent.Button_Submit.image.color = Color.white;
            }
        }
Esempio n. 3
0
        public static void SetupPanel()
        {
            Manager manager = SingletonUtil.GetMain();
            Access  access  = manager.Access;
            LoginSettingsPanelComponent panel = (LoginSettingsPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN_SETTINGS);

#if UNITY_EDITOR
            panel.InputField_DevJsonPath.text = AccessUtil.GetCredentialsJsonPath();
#endif

            panel.InputField_JsonPath.text = AccessUtil.GetCredentialsJsonPath();
        }
Esempio n. 4
0
        public static void SetClient()
        {
            Client client     = GetClient();
            string clientJson = JsonUtility.ToJson(client);

            string jsonPath;

#if UNITY_EDITOR
            jsonPath = AccessUtil.GetCredentialsJsonPath() + "/DevClient.json";
#else
            jsonPath = AccessUtil.GetCredentialsJsonPath() + "/client.json";
#endif

            File.WriteAllText(jsonPath, clientJson);
        }
Esempio n. 5
0
        public static void SetupPanel()
        {
            LoginPanelComponent loginPanelComponent = (LoginPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN);

            string credentialsPath = string.Empty;

#if UNITY_EDITOR
            credentialsPath = AccessUtil.GetCredentialsJsonPath() + "/DevClient.json";
#else
            credentialsPath = AccessUtil.GetCredentialsJsonPath() + "/client.json";
#endif
            if (System.IO.File.Exists(credentialsPath))
            {
                Manager manager = SingletonUtil.GetMain();
                manager.Client = ClientUtil.LoadClient();

                loginPanelComponent.InputField_Username.text = manager.Client.UserName;
                loginPanelComponent.InputField_Token.text    = manager.Client.AccessToken;
            }
        }
Esempio n. 6
0
        public void Login()
        {
            LoginPanelComponent loginPanelComponent = (LoginPanelComponent)UIPanelUtil.GetUIPanel(PanelType.LOGIN);

            Client client = ClientUtil.GetClient();

            client.UserName     = loginPanelComponent.InputField_Username.text;
            client.AccessToken  = loginPanelComponent.InputField_Token.text;
            client.ReadMessages = false;
            client.Followers    = new List <Follower>();

            ClientUtil.SetClient();

            Simulation       simulation = SimulationUtil.GetSimulation();
            ProcessStartInfo backEnd    = new ProcessStartInfo();

            backEnd.FileName         = "TwitchChat_bckEnd.exe";
            backEnd.WorkingDirectory = AccessUtil.GetBackEndProcessPath();
            simulation.Backend       = Process.Start(backEnd);
        }
Esempio n. 7
0
        public static Client LoadClient()
        {
            string jsonPath = AccessUtil.GetCredentialsJsonPath();
            string filePath = string.Empty;

#if UNITY_EDITOR
            filePath = jsonPath + "/DevClient.json";
#else
            filePath = jsonPath + "/client.json";
#endif
            try
            {
                string clientJson = File.ReadAllText(filePath);
                Client client     = JsonUtility.FromJson <Client>(clientJson);

                return(client);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 8
0
        void Update()
        {
            SimulationUtil.ManageStateChanging();

            State currentState = SimulationUtil.GetCurrentState();

            SimulationUtil.UpdateTick();

            switch (currentState)
            {
            case State.INTIALIZE:
                AccessUtil.LoadAccess();
                SimulationUtil.InitializeSimulation();
                CameraUtil.InitializeMainCameraComponent();
                UIUtil.InitializeUI();
                SimulationUtil.SetState(State.LOGIN);
                break;

            case State.LOGIN:
            {
                if (Simulation.Backend != null)
                {
                    SimulationUtil.SetState(State.CONNECTING);
                }
            }
            break;

            case State.IN_CHAT:
            {
                if (!ClientUtil.IsConnected())
                {
                    UnityEngine.Debug.Log("Disconnected");

                    if (Simulation.Backend != null && Simulation.Backend.HasExited)
                    {
                        Simulation.Backend = null;
                    }

                    SimulationUtil.SetState(State.LOGIN);
                    break;
                }

                if (SimulationUtil.Tick())
                {
                    FollowerUtil.UpdateFollowers();
                }

                ChatUtil.UpdateChat();
            }
            break;

            case State.LOGIN_SETTINGS:
                break;

            case State.CONNECTING:
            {
                if (!SimulationUtil.Tick())
                {
                    break;
                }

                UnityEngine.Debug.Log("Connecting");

                if (ClientUtil.IsConnected())
                {
                    SimulationUtil.SetState(State.HUB);
                    UnityEngine.Debug.Log("Connection complete !");
                }
            }
            break;

            case State.HUB:
            {
                Client.ReadMessages = true;

                if (SimulationUtil.Tick())
                {
                    FollowerUtil.UpdateFollowers();
                }
            }
            break;
            }

            UIUtil.UpdateUI();
        }