public void Init(int candidates) { var ui = Content.Content.Get().CustomUI; var gd = GameFacade.GraphicsDevice; for (int i = 0; i < candidates; i++) { var elem = new UIVoteCandidate(i % 2 == 1, this); elem.Position = new Vector2(0, 98 * i); Add(elem); Elems.Add(elem); } VoteButton = new UIButton(ui.Get("vote_big_btn.png").Get(gd)); VoteButton.Width = 200; VoteButton.Caption = GameFacade.Strings.GetString("f118", "21"); VoteButton.CaptionStyle = VoteButton.CaptionStyle.Clone(); VoteButton.CaptionStyle.Color = Color.White; VoteButton.CaptionStyle.Shadow = true; VoteButton.CaptionStyle.Size = 22; VoteButton.Position = new Vector2((575 - 200) / 2, 98 * candidates + 8); Add(VoteButton); VoteButton.OnButtonClick += VoteButton_OnButtonClick; VoteImage = new UIImage(ui.Get("vote_icon.png").Get(gd)); VoteImage.Position = VoteButton.Position + new Vector2(float.Parse(GameFacade.Strings.GetString("f118", "22")), 12); VoteButton.Disabled = true; Add(VoteImage); }
public void SetSelected(UIVoteCandidate cand) { if (cand != null) SelectedID = cand.AvatarID; else SelectedID = 0; foreach (var cand2 in Elems) { cand2.SetChecked(cand == cand2); } VoteButton.Disabled = SelectedID == 0; }