public UICitySelector() : base(UIDialogStyle.Standard, true) { this.Opacity = 0.9f; CityListBoxBackground = new UIImage(UITextBox.StandardBackground); this.Add(CityListBoxBackground); CityDescriptionBackground = new UIImage(UITextBox.StandardBackground); this.Add(CityDescriptionBackground); var script = this.RenderScript("cityselector.uis"); this.DialogSize = (Point)script.GetControlProperty("DialogSize"); var cityThumbBG = new UIImage(thumbnailBackgroundImage); cityThumbBG.Position = (Vector2)script.GetControlProperty("CityThumbnailBackgroundPosition"); this.Add(cityThumbBG); CityThumb = new UIImage(); CityThumb.Position = (Vector2)script.GetControlProperty("CityThumbnailPosition"); this.Add(CityThumb); CityDescriptionSlider.AttachButtons(CityDescriptionScrollUpButton, CityDescriptionDownButton, 1); DescriptionText.AttachSlider(CityDescriptionSlider); OkButton.Disabled = true; OkButton.OnButtonClick += new ButtonClickDelegate(OkButton_OnButtonClick); CancelButton.OnButtonClick += new ButtonClickDelegate(CancelButton_OnButtonClick); this.Caption = (string)script["TitleString"]; /** Parse the list styles **/ listStyleNormal = script.Create <UIListBoxTextStyle>("CityListBoxColors", CityListBox.FontStyle); listStyleBusy = script.Create <UIListBoxTextStyle>("CityListBoxColorsBusy", CityListBox.FontStyle); listStyleFull = script.Create <UIListBoxTextStyle>("CityListBoxColorsFull", CityListBox.FontStyle); listStyleReserved = script.Create <UIListBoxTextStyle>("CityListBoxColorsReserved", CityListBox.FontStyle); UpdateItems(); CityListBox.OnChange += new ChangeDelegate(CityListBox_OnChange); NetworkFacade.Controller.OnNewCityServer += new OnNewCityServerDelegate(Controller_OnNewCityServer); NetworkFacade.Controller.OnCityServerOffline += new OnCityServerOfflineDelegate(Controller_OnCityServerOffline); }
public UICitySelector() : base(UIDialogStyle.Standard, true) { this.Opacity = 0.9f; CityListBoxBackground = new UIImage(UITextBox.StandardBackground); this.Add(CityListBoxBackground); CityDescriptionBackground = new UIImage(UITextBox.StandardBackground); this.Add(CityDescriptionBackground); var script = this.RenderScript("cityselector.uis"); this.DialogSize = (Point)script.GetControlProperty("DialogSize"); var cityThumbBG = new UIImage(thumbnailBackgroundImage); cityThumbBG.Position = (Vector2)script.GetControlProperty("CityThumbnailBackgroundPosition"); this.Add(cityThumbBG); CityThumb = new UIImage(); CityThumb.Position = (Vector2)script.GetControlProperty("CityThumbnailPosition"); this.Add(CityThumb); CityDescriptionSlider.AttachButtons(CityDescriptionScrollUpButton, CityDescriptionDownButton, 1); DescriptionText.AttachSlider(CityDescriptionSlider); OkButton.Disabled = true; OkButton.OnButtonClick += new ButtonClickDelegate(OkButton_OnButtonClick); CancelButton.OnButtonClick += new ButtonClickDelegate(CancelButton_OnButtonClick); this.Caption = (string)script["TitleString"]; /** Parse the list styles **/ var listStyleNormal = script.Create <UIListBoxTextStyle>("CityListBoxColors", CityListBox.FontStyle); var listStyleBusy = script.Create <UIListBoxTextStyle>("CityListBoxColorsBusy", CityListBox.FontStyle); var listStyleFull = script.Create <UIListBoxTextStyle>("CityListBoxColorsFull", CityListBox.FontStyle); var listStyleReserved = script.Create <UIListBoxTextStyle>("CityListBoxColorsReserved", CityListBox.FontStyle); var statusToStyle = new Dictionary <CityInfoStatus, UIListBoxTextStyle>(); statusToStyle.Add(CityInfoStatus.Ok, listStyleNormal); statusToStyle.Add(CityInfoStatus.Busy, listStyleBusy); statusToStyle.Add(CityInfoStatus.Full, listStyleFull); statusToStyle.Add(CityInfoStatus.Reserved, listStyleReserved); var statusToLabel = new Dictionary <CityInfoStatus, string>(); statusToLabel.Add(CityInfoStatus.Ok, StatusOk); statusToLabel.Add(CityInfoStatus.Busy, StatusBusy); statusToLabel.Add(CityInfoStatus.Full, StatusFull); statusToLabel.Add(CityInfoStatus.Reserved, StatusOk); CityListBox.TextStyle = listStyleNormal; CityListBox.Items = NetworkFacade.Cities.Select( x => new UIListBoxItem(x, CityIconImage, x.Name, x.Online ? OnlineStatusUp : OnlineStatusDown, statusToLabel[x.Status]) { //Disabled = x.Status != TSOServiceClient.Model.CityInfoStatus.Ok, CustomStyle = statusToStyle[x.Status] } ).ToList(); CityListBox.OnChange += new ChangeDelegate(CityListBox_OnChange); //CityListBox.SelectedIndex = 0; }
public UICitySelector(List <ShardStatusItem> shards) : base(UIDialogStyle.Standard, true) { Opacity = 0.9f; CityListBoxBackground = new UIImage(UITextBox.StandardBackground); Add(CityListBoxBackground); CityDescriptionBackground = new UIImage(UITextBox.StandardBackground); Add(CityDescriptionBackground); var script = RenderScript("cityselector.uis"); DialogSize = (Point)script.GetControlProperty("DialogSize"); var cityThumbBG = new UIImage(thumbnailBackgroundImage) { Position = (Vector2)script.GetControlProperty("CityThumbnailBackgroundPosition") }; Add(cityThumbBG); CityThumb = new UIImage { Position = (Vector2)script.GetControlProperty("CityThumbnailPosition") }; Add(CityThumb); CityDescriptionSlider.AttachButtons(CityDescriptionScrollUpButton, CityDescriptionDownButton, 1); DescriptionText.AttachSlider(CityDescriptionSlider); OkButton.Disabled = true; OkButton.OnButtonClick += new ButtonClickDelegate(OkButton_OnButtonClick); CancelButton.OnButtonClick += new ButtonClickDelegate(CancelButton_OnButtonClick); Caption = (string)script["TitleString"]; /** Parse the list styles **/ var listStyleNormal = script.Create <UIListBoxTextStyle>("CityListBoxColors", CityListBox.FontStyle); var listStyleBusy = script.Create <UIListBoxTextStyle>("CityListBoxColorsBusy", CityListBox.FontStyle); var listStyleFull = script.Create <UIListBoxTextStyle>("CityListBoxColorsFull", CityListBox.FontStyle); var listStyleReserved = script.Create <UIListBoxTextStyle>("CityListBoxColorsReserved", CityListBox.FontStyle); var statusToStyle = new Dictionary <ShardStatus, UIListBoxTextStyle>(); statusToStyle.Add(ShardStatus.Up, listStyleNormal); statusToStyle.Add(ShardStatus.Busy, listStyleBusy); statusToStyle.Add(ShardStatus.Full, listStyleFull); statusToStyle.Add(ShardStatus.Down, listStyleFull); statusToStyle.Add(ShardStatus.Closed, listStyleFull); statusToStyle.Add(ShardStatus.Frontier, listStyleReserved); var statusToLabel = new Dictionary <ShardStatus, string>(); statusToLabel.Add(ShardStatus.Up, StatusOk); statusToLabel.Add(ShardStatus.Busy, StatusBusy); statusToLabel.Add(ShardStatus.Full, StatusFull); statusToLabel.Add(ShardStatus.Down, StatusFull); statusToLabel.Add(ShardStatus.Closed, StatusFull); statusToLabel.Add(ShardStatus.Frontier, StatusOk); CityListSlider.AttachButtons(CityListScrollUpButton, CityScrollDownButton, 1); CityListBox.TextStyle = listStyleNormal; CityListBox.AttachSlider(CityListSlider); CityListBox.OnChange += new ChangeDelegate(CityListBox_OnChange); CityListBox.Items = shards.Select(x => new UIListBoxItem(x, CityIconImage, x.Name, x.Status == ShardStatus.Up ? OnlineStatusUp : OnlineStatusDown, statusToLabel[x.Status]) { CustomStyle = statusToStyle[x.Status] }).ToList(); if (shards.Count > 0) { CityListBox.SelectedIndex = 0; } GameThread.NextUpdate(x => { FSOFacade.Hints.TriggerHint("screen:sascity"); }); }