public void Disconnect(Action <bool> onDisconnected, bool forceLogin)
        {
            totalComplete       = 0;
            this.onDisconnected = onDisconnected;

            if (forceLogin)
            {
                targetComplete = 1;
                LoginRegulator.Logout();
            }

            CityConnectionRegulator.Disconnect();
            LotConnectionRegulator.Disconnect();

            if (!forceLogin)
            {
                LoginRegulator.AsyncTransition("AvatarData");
            }
        }
Example #2
0
        public LoginScreen(LoginRegulator regulator)
        {
            try
            {
                if (File.Exists("update2.exe"))
                {
                    File.Delete("update.exe");
                    File.Move("update2.exe", "update.exe");
                }
            } catch (Exception) {
                //maybe signal to user that the updater update failed
            }

            this.Regulator = regulator;
            regulator.Logout();

            HITVM.Get().PlaySoundEvent(UIMusic.None);
            GlobalSettings.Default.Save();

            if (Content.Content.Get().TS1)
            {
                //load the sandbox screen in neighbourhood view mode
                GameThread.NextUpdate(x =>
                {
                    FSOFacade.Controller.EnterSandboxMode("", false);
                });
            }

            Background = new UISetupBackground();

            /** Client version **/
            var lbl = new UILabel();

            lbl.Caption = "Version " + GlobalSettings.Default.ClientVersion;
            lbl.X       = 20;
            lbl.Y       = 558;
            Background.BackgroundCtnr.Add(lbl);
            this.Add(Background);

            /** Progress bar **/
            LoginProgress         = new UILoginProgress();
            LoginProgress.X       = (ScreenWidth - (LoginProgress.Width + 20));
            LoginProgress.Y       = (ScreenHeight - (LoginProgress.Height + 20));
            LoginProgress.Opacity = 0.9f;
            this.Add(LoginProgress);

            /** Login dialog **/
            LoginDialog         = new UILoginDialog(Login);
            LoginDialog.Opacity = 0.9f;
            //Center
            LoginDialog.X = (ScreenWidth - LoginDialog.Width) / 2;
            LoginDialog.Y = (ScreenHeight - LoginDialog.Height) / 2;
            this.Add(LoginDialog);

            bool usernamePopulated = false;

            var loginIniFile = GameFacade.GameFilePath("login.ini");

            if (File.Exists(loginIniFile))
            {
                var iniFile = IniFile.Read(loginIniFile);
                if (iniFile.ContainsKey("LastSession"))
                {
                    LoginDialog.Username = iniFile["LastSession"]["UserName"];
                    usernamePopulated    = true;
                }
            }

            if (!FSOEnvironment.SoftwareKeyboard)
            {
                if (usernamePopulated)
                {
                    LoginDialog.FocusPassword();
                }
                else
                {
                    LoginDialog.FocusUsername();
                }
            }

            var gameplayButton = new UIButton()
            {
                Caption = "Sandbox Mode",
                Y       = 10,
                Width   = 125,
                X       = 10
            };

            this.Add(gameplayButton);
            gameplayButton.OnButtonClick += new ButtonClickDelegate(gameplayButton_OnButtonClick);

            Regulator.OnError      += AuthRegulator_OnError;
            Regulator.OnTransition += AuthRegulator_OnTransition;

            var compat = GlobalSettings.Default.CompatState;

            if (compat != -1 && compat < GlobalSettings.TARGET_COMPAT_STATE)
            {
                GameThread.NextUpdate(x =>
                {
                    GlobalShowAlert(new UIAlertOptions()
                    {
                        Message = GameFacade.Strings.GetString("f105", "2")
                    }, true);
                    var settings                = GlobalSettings.Default;
                    settings.CompatState        = 0;
                    settings.LightingMode       = 0;
                    settings.SurroundingLotMode = 0;
                    settings.CityShadows        = false;
                    settings.AntiAlias          = 0;
                    settings.Save();

                    LotView.WorldConfig.Current = new LotView.WorldConfig()
                    {
                        LightingMode    = settings.LightingMode,
                        SmoothZoom      = settings.SmoothZoom,
                        SurroundingLots = settings.SurroundingLotMode,
                        AA                = settings.AntiAlias,
                        Weather           = settings.Weather,
                        Directional       = settings.DirectionalLight3D,
                        Complex           = settings.ComplexShaders,
                        EnableTransitions = settings.EnableTransitions
                    };
                });
            }
            GameThread.NextUpdate(x =>
            {
                FSOFacade.Hints.TriggerHint("screen:login");

                //UIScreen.GlobalShowDialog(new Panels.Neighborhoods.UIBulletinDialog(), false);
                //Content.Content.Get().UIGraphics.ExportAll(GameFacade.GraphicsDevice);
            });
        }