public void UpdateCandidateList(NhoodCandidateList candidates)
        {
            IEnumerable <NhoodCandidate> sims = candidates.Candidates;
            var searchString = SearchBox.CurrentText.ToLowerInvariant();

            if (SearchBox.CurrentText != "")
            {
                sims = sims.Where(x => x.Name.ToLowerInvariant().Contains(searchString));
            }
            RoommateListBox.Items = sims.OrderBy(x => x.Name).Select(x =>
            {
                var personBtn = new UIPersonButton()
                {
                    AvatarId  = x.ID,
                    FrameSize = UIPersonButtonSize.SMALL
                };
                personBtn.LogicalParent = this;

                UIRatingDisplay rating = null;
                if (x.Rating != uint.MaxValue)
                {
                    rating = new UIRatingDisplay(true);
                    rating.LogicalParent = this;
                    rating.DisplayStars  = x.Rating / 100f;
                    rating.LinkAvatar    = x.ID;
                }
                return(new UIListBoxItem(
                           x,
                           personBtn,
                           x.Name,
                           "",
                           (object)rating ?? ""
                           ));
            }).ToList();
        }
Example #2
0
        public UIRatingSummaryPanel()
        {
            Body                = new UITextEdit();
            Body.TextStyle      = Body.TextStyle.Clone();
            Body.TextStyle.Size = 9;
            Body.TextStyle.LineHeightModifier = -4;
            Body.Position = new Vector2(5, 5);
            Body.SetSize(118, 81);
            Body.MaxLines      = 5;
            Body.Mode          = UITextEditMode.ReadOnly;
            Body.Position      = new Vector2(7, 3);
            Body.BBCodeEnabled = true;
            Body.RemoveMouseEvent();
            Add(Body);

            Body.Tooltip = GameFacade.Strings.GetString("f115", "94");

            NameLabel = new UILabel();
            NameLabel.CaptionStyle      = NameLabel.CaptionStyle.Clone();
            NameLabel.CaptionStyle.Size = 9;
            NameLabel.Position          = new Vector2(122, 77);
            NameLabel.Alignment         = TextAlignment.Right | TextAlignment.Top;
            NameLabel.Size = new Vector2(1, 1);
            NameLabel.CaptionStyle.Size = 9;
            Add(NameLabel);

            Rating          = new UIRatingDisplay(true);
            Rating.Position = new Vector2(7, 80);
            Add(Rating);

            CurrentRating = new Binding <MayorRating>()
                            .WithBinding(this, "Message", "MayorRating_Comment")
                            .WithBinding(this, "HalfStars", "MayorRating_HalfStars")
                            .WithBinding(this, "Name", "MayorRating_FromAvatar", (object id) =>
            {
                return(((uint)id == 0) ? "Anon" : "unknown");
            });

            Size = new Vector2(128, 96);

            ClickHandler =
                ListenForMouse(new Rectangle(0, 0, 128, 96), new UIMouseEvent(OnMouseEvent));
        }
Example #3
0
        public UIRatingContainer(bool rating)
        {
            Edit = new UITextEdit();
            Edit.SetSize(420, 75);
            Edit.Mode      = UITextEditMode.Editor;
            Edit.OnChange += Edit_OnChange;
            Edit.MaxLines  = 4;
            Edit.MaxChars  = 140;
            Edit.BackgroundTextureReference = UITextBox.StandardBackground;
            Edit.TextMargin = new Rectangle(8, 2, 8, 3);

            Add(Edit);

            Rating              = new UIRatingDisplay(true);
            Rating.Position     = new Vector2(5, 80);
            Rating.Settable     = true;
            Rating.DisplayStars = 0;
            Rating.Visible      = rating;
            Add(Rating);

            CurrentRatingLabel                     = new UILabel();
            CurrentRatingLabel.Position            = new Vector2(75, 77);
            CurrentRatingLabel.CaptionStyle        = TextStyle.DefaultTitle.Clone();
            CurrentRatingLabel.CaptionStyle.Shadow = true;
            CurrentRatingLabel.Caption             = "0 Stars";
            CurrentRatingLabel.Visible             = rating;
            Add(CurrentRatingLabel);

            CharacterLimitDisplay                     = new UILabel();
            CharacterLimitDisplay.Position            = new Vector2(414, 77);
            CharacterLimitDisplay.Alignment           = TextAlignment.Right | TextAlignment.Top;
            CharacterLimitDisplay.Size                = new Vector2(1, 1);
            CharacterLimitDisplay.CaptionStyle        = TextStyle.DefaultTitle.Clone();
            CharacterLimitDisplay.CaptionStyle.Shadow = true;
            CharacterLimitDisplay.Caption             = "0/140";
            Add(CharacterLimitDisplay);

            var emoji = new UIEmojiSuggestions(Edit);

            Add(emoji);
        }
        public UIFullRatingItem(uint ratingID)
        {
            RatingID = ratingID;

            Body                 = new UITextEdit();
            Body.TextStyle       = Body.TextStyle.Clone();
            Body.TextStyle.Size  = 8;
            Body.TextStyle.Color = Color.White;
            Body.SetSize(454, 42);
            Body.MaxLines      = 3;
            Body.Mode          = UITextEditMode.ReadOnly;
            Body.Position      = new Vector2(15, 20);
            Body.BBCodeEnabled = true;
            Body.RemoveMouseEvent();
            Add(Body);

            StarLabel           = new UILabel();
            StarLabel.Position  = new Vector2(75, 4);
            StarLabel.Alignment = TextAlignment.Left | TextAlignment.Top;
            StarLabel.Size      = new Vector2(1, 1);
            Add(StarLabel);

            NameLabel           = new UILabel();
            NameLabel.Position  = new Vector2(465, 4);
            NameLabel.Alignment = TextAlignment.Right | TextAlignment.Top;
            NameLabel.Size      = new Vector2(1, 1);
            Add(NameLabel);

            Rating          = new UIRatingDisplay(true);
            Rating.Position = new Vector2(9, 7);
            Add(Rating);

            CurrentRating = new Binding <MayorRating>()
                            .WithBinding(this, "Message", "MayorRating_Comment")
                            .WithBinding(this, "HalfStars", "MayorRating_HalfStars")
                            .WithBinding(this, "Name", "MayorRating_FromAvatar", (object id) =>
            {
                return(((uint)id == 0) ? "Anon" : "unknown");
            });

            var ui     = Content.Content.Get().CustomUI;
            var btnTex = ui.Get("chat_cat.png").Get(GameFacade.GraphicsDevice);

            var btnCaption = TextStyle.DefaultLabel.Clone();

            btnCaption.Size   = 8;
            btnCaption.Shadow = true;

            if (GameFacade.EnableMod)
            {
                DeleteButton                = new UIButton(btnTex);
                DeleteButton.Caption        = "Delete";
                DeleteButton.CaptionStyle   = btnCaption;
                DeleteButton.OnButtonClick += DeletePost;
                DeleteButton.Width          = 64;
                DeleteButton.X              = 135;
                DeleteButton.Y              = 4;
                Add(DeleteButton);
            }

            Size    = new Vector2(475, 70);
            PxWhite = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);
        }
Example #5
0
        public UINeighPage()
        {
            Add(BackgroundImage = new UIImage());

            Add(InfoTabBackgroundImage = new UIImage());
            Add(InfoTabImage           = new UIImage());

            Add(TopSTab2BackgroundImage = new UIImage());
            Add(TopSTab3BackgroundImage = new UIImage());
            Add(TopSTabImage            = new UIImage());

            Add(TopSTabTab1BackgroundImage = new UIImage());
            Add(TopSTabTab2BackgroundImage = new UIImage());
            Add(TopSTabTab3BackgroundImage = new UIImage());
            Add(TopSTabTab4BackgroundImage = new UIImage());

            Add(TopSTabTab1SeatImage = new UIImage());
            Add(TopSTabTab2SeatImage = new UIImage());
            Add(TopSTabTab3SeatImage = new UIImage());
            Add(TopSTabTab4SeatImage = new UIImage());

            Add(MayorTabBackgroundImage = new UIImage());
            Add(MayorTabImage           = new UIImage());
            Add(MayorTabRateImage       = new UIImage());

            MayorBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f, ScaleY = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "72")
            };
            TermBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f, ScaleY = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "83", new string[] { GetOrdinal(1) })
            };
            TownNameBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f,
                ScaleY  = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "14")
            };

            MayorRatingBox1 = new UIRatingSummaryPanel();
            MayorRatingBox2 = new UIRatingSummaryPanel();

            RatingStars           = new UIRatingDisplay(false);
            RatingStars.HalfStars = 7;

            var script = RenderScript("fsoneighpage.uis");

            DescriptionText.OnChange      += DescriptionText_OnChange;
            HouseNameButton.OnButtonClick += RenameAdmin;
            InfoButton.OnButtonClick      += (btn) => SetTab(UINeighPageTab.Description);
            HouseButton.OnButtonClick     += (btn) => SetTab(UINeighPageTab.Lots);
            PersonButton.OnButtonClick    += (btn) => SetTab(UINeighPageTab.People);
            MayorButton.OnButtonClick     += (btn) => SetTab(UINeighPageTab.Mayor);

            TopTab1Button.OnButtonClick += (btn) => SetSubTab(0);
            TopTab2Button.OnButtonClick += (btn) => SetSubTab(1);
            TopTab3Button.OnButtonClick += (btn) => SetSubTab(2);
            TopTab4Button.OnButtonClick += (btn) => SetSubTab(3);

            RateButton.OnButtonClick += RateSwitch;

            UIUtils.MakeDraggable(BackgroundImage, this, true);

            DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1);
            DescriptionText.AttachSlider(DescriptionSlider);

            RateButton.Width = 60;
            LotThumbnail     = script.Create <UILotThumbButton>("HouseThumbSetup");
            LotThumbnail.Init(RoommateThumbButtonImage, VisitorThumbButtonImage);
            DefaultThumb = TextureUtils.TextureFromFile(GameFacade.GraphicsDevice, GameFacade.GameFilePath("userdata/houses/defaulthouse.bmp"));
            TextureUtils.ManualTextureMask(ref DefaultThumb, new uint[] { 0xFF000000 });
            LotThumbnail.SetThumbnail(DefaultThumb, 0);
            LotThumbnail.OnLotClick += (btn) => {
                FindController <CoreGameScreenController>()?.ShowLotPage(CurrentNeigh.Value?.Neighborhood_TownHallXY ?? 0);
            };
            Add(LotThumbnail);

            MayorPersonButton = script.Create <UIBigPersonButton>("MayorPersonButton");
            Add(MayorPersonButton);

            Add(RatingStars);
            Add(MayorBanner);
            Add(TermBanner);
            TermBanner.Flip = true;
            Add(TownNameBanner);
            Add(MayorRatingBox1);
            Add(MayorRatingBox2);

            CurrentNeigh = new Binding <Neighborhood>()
                           .WithBinding(HouseNameButton, "Caption", "Neighborhood_Name")
                           .WithBinding(ResidentCountLabel, "Caption", "Neighborhood_AvatarCount", (object ava) =>
            {
                return(GameFacade.Strings.GetString("f115", "15", new string[] { ava.ToString() }));
            })
                           .WithBinding(PropertyCountLabel, "Caption", "Neighborhood_LotCount", (object lot) =>
            {
                return(GameFacade.Strings.GetString("f115", "16", new string[] { lot.ToString() }));
            })
                           .WithBinding(ActivityRatingLabel, "Caption", "Neighborhood_ActivityRating", (object rate) =>
            {
                return(GameFacade.Strings.GetString("f115", "13", new string[] { rate.ToString() }));
            })
                           .WithBinding(TermBanner, "Caption", "Neighborhood_ElectedDate", (object rate) =>
            {
                return(GameFacade.Strings.GetString("f115", "83", new string[] { GetOrdinal(GetTermsSince((uint)rate)) }));
            })
                           .WithBinding(this, "MayorID", "Neighborhood_MayorID")
                           .WithBinding(this, "TownHallID", "Neighborhood_TownHallXY")
                           .WithBinding(StatusLabel, "Caption", "Neighborhood_Flag", (object flago) =>
            {
                var flag          = (uint)flago;
                var availableText = "11";
                if ((flag & 1) > 0)
                {
                    availableText = "12";
                }
                return(GameFacade.Strings.GetString("f115", availableText));
            })
                           .WithMultiBinding((changes) => Redraw(), "Neighborhood_Description", "Neighborhood_TownHallXY", "Neighborhood_MayorID",
                                             "Neighborhood_TopLotCategory", "Neighborhood_TopLotOverall", "Neighborhood_TopAvatarActivity", "Neighborhood_TopAvatarFamous",
                                             "Neighborhood_TopAvatarInfamous");

            CurrentMayor = new Binding <Avatar>()
                           .WithBinding(RatingStars, "DisplayStars", "Avatar_MayorRatingHundredth", (object hundredths) =>
            {
                return(((uint)hundredths) / 100f);
            })
                           .WithBinding(this, "Ratings", "Avatar_ReviewIDs");

            CurrentTownHall = new Binding <Lot>()
                              .WithBinding(TownNameBanner, "Caption", "Lot_Name", (object name) =>
            {
                if ((string)name == "Retrieving...")
                {
                    return(GameFacade.Strings.GetString("f115", "14"));
                }
                else
                {
                    return((string)name);
                }
            });

            CenterButton.OnButtonClick += (btn) =>
            {
                (UIScreen.Current as CoreGameScreen).CityRenderer.NeighGeom.CenterNHood((int)(CurrentNeigh.Value?.Id ?? 0));
            };

            BulletinButton.OnButtonClick += (btn) =>
            {
                var id = CurrentNeigh?.Value?.Id ?? 0;
                if (id != 0 && !UIBulletinDialog.Present)
                {
                    var dialog = new UIBulletinDialog(id);
                    dialog.CloseButton.OnButtonClick += (btn2) =>
                    {
                        UIScreen.RemoveDialog(dialog);
                    };
                    UIScreen.GlobalShowDialog(dialog, false);
                }
            };

            CloseButton.OnButtonClick += (btn) =>
            {
                FindController <NeighPageController>().Close();
            };

            //mayor action buttons:
            MayorActionMod.OnButtonClick    += (btn) => { CurrentMayorTab = UINeighMayorTabMode.ModActions; Redraw(); };
            MayorActionReturn.OnButtonClick += (btn) => { CurrentMayorTab = UINeighMayorTabMode.Rate; Redraw(); };
            MayorActionMoveTH.OnButtonClick += (btn) => { MoveTownHall(true); };
            MayorActionNewTH.OnButtonClick  += (btn) => { MoveTownHall(false); };
            ModActionSetMayor.OnButtonClick += ModSetMayor;

            ModActionReturn.OnButtonClick        += (btn) => { CurrentMayorTab = UINeighMayorTabMode.Actions; Redraw(); };
            ModActionManageRatings.OnButtonClick += (btn) => {
                var ratingList = new UIRatingList(CurrentMayor.Value?.Avatar_Id ?? 0);
                UIScreen.GlobalShowAlert(new UIAlertOptions()
                {
                    Title           = GameFacade.Strings.GetString("f118", "23", new string[] { "Retrieving..." }),
                    Message         = GameFacade.Strings.GetString("f118", "24", new string[] { "Retrieving..." }),
                    GenericAddition = ratingList,
                    Width           = 530
                }, true);
            };

            foreach (var elem in Children)
            {
                var label = elem as UILabel;
                if (label != null)
                {
                    label.CaptionStyle        = label.CaptionStyle.Clone();
                    label.CaptionStyle.Shadow = true;
                }
            }

            Pedestals   = new List <UITop10Pedestal>();
            Top10Labels = new List <UILabel>();
            var top10style = TextStyle.DefaultLabel.Clone();

            top10style.Shadow = true;
            top10style.Size   = 8;
            for (int i = 0; i < 10; i++)
            {
                var alt = i % 2 == 1;
                var ped = new UITop10Pedestal()
                {
                    AltColor = alt
                };
                Pedestals.Add(ped);

                var label = new UILabel()
                {
                    CaptionStyle = top10style,
                    Alignment    = TextAlignment.Center | TextAlignment.Middle,
                    Size         = new Vector2(1, 1)
                };
                Top10Labels.Add(label);
                Add(label);
            }
            for (int i = 0; i < 10; i += 2)
            {
                Add(Pedestals[i]);                             //backmost
            }
            for (int i = 1; i < 10; i += 2)
            {
                Add(Pedestals[i]);                             //frontmost
            }
            SetPedestalPosition(false, true);

            Redraw();
        }
        public UIVoteCandidate(bool alignment, UIVoteContainer container)
        {
            var ui = Content.Content.Get().CustomUI;
            var gd = GameFacade.GraphicsDevice;

            Background          = new UIImage(ui.Get("vote_bg_9slice.png").Get(gd)).With9Slice(15, 15, 15, 15);
            Background.Position = new Vector2(alignment ? 5 : 32, 16);
            Background.SetSize(539, 77);
            Add(Background);

            AvaBackground          = new UIImage(ui.Get("vote_ava_bg.png").Get(gd));
            AvaBackground.Position = new Vector2(alignment ? 499 : 0, 0);
            Add(AvaBackground);

            CheckButton                = new UIButton(ui.Get("vote_check.png").Get(gd));
            CheckButton.Position       = new Vector2(alignment ? 15 : 518, 34);
            CheckButton.OnButtonClick += (btn) =>
            {
                container.SetSelected(this);
            };
            Add(CheckButton);

            Avatar        = new UIBigPersonButton();
            Avatar.ScaleX = Avatar.ScaleY = 108f / 170;
            Add(Avatar);
            Avatar.Position = new Vector2(alignment ? 502 : 2, 2);

            //range: [75, 501]

            NameLabel                     = new UILabel();
            NameLabel.Position            = new Vector2(75 + 2, 16);
            NameLabel.Size                = new Vector2(426 - 4, 1);
            NameLabel.CaptionStyle        = NameLabel.CaptionStyle.Clone();
            NameLabel.CaptionStyle.Shadow = true;
            NameLabel.CaptionStyle.Color  = Color.White;
            NameLabel.CaptionStyle.Size   = 16;
            NameLabel.Alignment           = alignment ? TextAlignment.Right : TextAlignment.Left;
            Add(NameLabel);

            SubtitleLabel           = new UILabel();
            SubtitleLabel.Position  = new Vector2(75 + 6, 39);
            SubtitleLabel.Size      = new Vector2(426 - 12, 1);
            SubtitleLabel.Alignment = alignment ? TextAlignment.Right : TextAlignment.Left;
            Add(SubtitleLabel);

            MessageLabel                = new UITextEdit();
            MessageLabel.Position       = new Vector2(75 + 4, 56);
            MessageLabel.Size           = new Vector2(426 - 8, 35);
            MessageLabel.Mode           = UITextEditMode.ReadOnly;
            MessageLabel.Alignment      = TextAlignment.Top | (alignment ? TextAlignment.Right : TextAlignment.Left);
            MessageLabel.TextStyle      = MessageLabel.TextStyle.Clone();
            MessageLabel.TextStyle.Size = 8;
            MessageLabel.BBCodeEnabled  = true;
            MessageLabel.TextStyle.LineHeightModifier = -3;
            MessageLabel.TextStyle.Color = Color.White;
            Add(MessageLabel);

            Rating         = new UIRatingDisplay(true);
            Rating.Visible = false;
            Rating.Y       = 28 + 14;
            Add(Rating);

            /*
             * NameLabel.Caption = "VERY LONG NAMEMEMEMEMMEE";
             * SubtitleLabel.Caption = "Running for 2nd Term";
             * MessageLabel.CurrentText = "If you vote for me, I personally vow to avoid polluting the water supply. It will be hard, but I believe that with your votes I might find any restraint whatsoever.";
             * Avatar.AvatarId = 887;
             */

            Alignment = alignment;
        }