Example #1
0
        private void SetMode(Framework.UIElement button)
        {
            if (button == HouseInfoButton)
            {
                var controller = GameFacade.Screens.CurrentUIScreen.FindController <FSO.Client.Controllers.CoreGameScreenController>();
                if (controller != null)
                {
                    controller.ShowLotPage(controller.GetCurrentLotID());
                    return;
                }
            }

            var btn      = (UIButton)button;
            int newPanel = -1;

            BtnToMode.TryGetValue(btn, out newPanel);

            foreach (var ui in BtnToMode.Keys)
            {
                ui.Selected = false;
            }

            if (CurrentPanel != -1)
            {
                if (Panel is IDisposable)
                {
                    ((IDisposable)Panel)?.Dispose();
                }
                this.Remove(Panel);
            }
            if (newPanel != CurrentPanel)
            {
                btn.Selected = true;
                switch (newPanel)
                {
                case 1:
                    Panel = new UIStatsPanel(LotControl);
                    break;

                case 2:
                    Panel = new UIRoommatesPanel(LotControl);
                    break;

                case 3:
                    Panel = new UILogPanel(LotControl);
                    break;

                case 4:
                    Panel = new UIAdmitBanPanel(LotControl);
                    var ctr = Panel.BindController <LotAdmitController>();
                    break;

                case 5:
                    Panel   = new UIEnvPanel(LotControl);
                    Panel.X = 232;
                    Panel.Y = 0;
                    break;

                case 7:
                    Panel = new UIBuildableAreaPanel(LotControl);
                    break;

                default:
                    btn.Selected = false;
                    break;
                }
                if (Panel != null)
                {
                    if (newPanel != 5)
                    {
                        Panel.X = 225; //TODO: use uiscript positions
                        Panel.Y = 9;
                    }
                    this.Add(Panel);
                    CurrentPanel = newPanel;
                }
            }
            else
            {
                CurrentPanel = -1;
            }
        }