示例#1
0
 public override void Update(UpdateState state)
 {
     if (ThumbLock != null && CurrentLot?.Value != null && LastThumb != ThumbLock.LotTexture && ThumbLock.Loaded)
     {
         LotThumbnail.SetThumbnail(ThumbLock.LotTexture, CurrentLot.Value.Id);
         LastThumb = ThumbLock.LotTexture;
     }
     base.Update(state);
 }
示例#2
0
        public UILotPage()
        {
            var script = RenderScript("housepage.uis");

            BackgroundNumOccupantsImage = script.Create <UIImage>("BackgroundNumOccupantsImage");
            AddAt(0, BackgroundNumOccupantsImage);

            BackgroundHouseCategoryThumbImage = script.Create <UIImage>("BackgroundHouseCategoryThumbImage");
            AddAt(0, BackgroundHouseCategoryThumbImage);

            BackgroundHouseLeaderThumbImage = script.Create <UIImage>("BackgroundHouseLeaderThumbImage");
            AddAt(0, BackgroundHouseLeaderThumbImage);

            BackgroundDescriptionEditImage = script.Create <UIImage>("BackgroundDescriptionEditImage");
            AddAt(0, BackgroundDescriptionEditImage);

            BackgroundDescriptionImage = script.Create <UIImage>("BackgroundDescriptionImage");
            AddAt(0, BackgroundDescriptionImage);

            BackgroundContractedImage         = new UIImage();
            BackgroundContractedImage.Texture = ContractedBackgroundImage;
            this.AddAt(0, BackgroundContractedImage);
            BackgroundExpandedImage         = new UIImage();
            BackgroundExpandedImage.Texture = ExpandedBackgroundImage;
            this.AddAt(0, BackgroundExpandedImage);

            ContractButton.OnButtonClick += (x) => Open = false;
            ExpandButton.OnButtonClick   += (x) => Open = true;

            ExpandedCloseButton.OnButtonClick   += Close;
            ContractedCloseButton.OnButtonClick += Close;

            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);
            Add(LotThumbnail);

            RoommateList = script.Create <UIRoommateList>("RoommateList");
            Add(RoommateList);

            SkillGameplayLabel                   = new UIClickableLabel();
            SkillGameplayLabel.Position          = RoommateList.Position + new Vector2(-1, 24);
            SkillGameplayLabel.Size              = new Vector2(180, 18);
            SkillGameplayLabel.Alignment         = TextAlignment.Center;
            SkillGameplayLabel.OnButtonClick    += SkillGameplayLabel_OnButtonClick;
            SkillGameplayLabel.CaptionStyle      = SkillGameplayLabel.CaptionStyle.Clone();
            SkillGameplayLabel.CaptionStyle.Size = 9;
            Add(SkillGameplayLabel);

            OwnerButton           = script.Create <UIPersonButton>("HouseLeaderThumbSetup");
            OwnerButton.FrameSize = UIPersonButtonSize.LARGE;
            Add(OwnerButton);

            /** Drag **/
            UIUtils.MakeDraggable(BackgroundContractedImage, this, true);
            UIUtils.MakeDraggable(BackgroundExpandedImage, this, true);

            /** Description scroll **/
            HouseDescriptionSlider.AttachButtons(HouseDescriptionScrollUpButton, HouseDescriptionScrollDownButton, 1);
            HouseDescriptionTextEdit.AttachSlider(HouseDescriptionSlider);

            HouseLinkButton.OnButtonClick     += JoinLot;
            HouseCategoryButton.OnButtonClick += ChangeCategory;
            HouseNameButton.OnButtonClick     += ChangeName;
            LotThumbnail.OnLotClick           += JoinLot;

            NeighborhoodNameButton.OnButtonClick += (btn) =>
            {
                if (CurrentLot != null && CurrentLot.Value != null && CurrentLot.Value.Lot_NeighborhoodID != 0)
                {
                    FindController <CoreGameScreenController>().ShowNeighPage(CurrentLot.Value.Lot_NeighborhoodID);
                }
            };

            var ui = Content.Content.Get().CustomUI;

            HouseCategory_CommunityButtonImage = ui.Get("lotp_community_small.png").Get(GameFacade.GraphicsDevice);

            CurrentLot = new Binding <Lot>()
                         .WithBinding(HouseNameButton, "Caption", "Lot_Name")
                         .WithBinding(NeighborhoodNameButton, "Caption", "Lot_NeighborhoodName")
                         .WithBinding(HouseValueLabel, "Caption", "Lot_Price", x => MoneyFormatter.Format((uint)x))
                         .WithBinding(OccupantsNumberLabel, "Caption", "Lot_NumOccupants", x => x.ToString())
                         .WithBinding(OwnerButton, "AvatarId", "Lot_LeaderID")
                         .WithBinding(HouseCategoryButton, "Texture", "Lot_Category", x =>
            {
                var category = (LotCategory)Enum.Parse(typeof(LotCategory), x.ToString());
                switch (category)
                {
                case LotCategory.none:
                    return(HouseCategory_NoCategoryButtonImage);

                case LotCategory.welcome:
                    return(HouseCategory_WelcomeButtonImage);

                case LotCategory.money:
                    return(HouseCategory_MoneyButtonImage);

                case LotCategory.entertainment:
                    return(HouseCategory_EntertainmentButtonImage);

                case LotCategory.games:
                    return(HouseCategory_GamesButtonImage);

                case LotCategory.offbeat:
                    return(HouseCategory_OffbeatButtonImage);

                case LotCategory.residence:
                    return(HouseCategory_ResidenceButtonImage);

                case LotCategory.romance:
                    return(HouseCategory_RomanceButtonImage);

                case LotCategory.services:
                    return(HouseCategory_ServicesButtonImage);

                case LotCategory.shopping:
                    return(HouseCategory_ShoppingButtonImage);

                case LotCategory.skills:
                    return(HouseCategory_SkillsButtonImage);

                case LotCategory.community:
                    return(HouseCategory_CommunityButtonImage);

                default:
                    return(HouseCategory_CommunityButtonImage);
                }
            }).WithBinding(HouseCategoryButton, "Position", "Lot_Category", x =>
            {
                return(new Vector2(69 + 11 - HouseCategoryButton.Texture.Width / 8, 164 + 11 - HouseCategoryButton.Texture.Height / 2));
            })
                         .WithMultiBinding(x => RefreshUI(), "Lot_LeaderID", "Lot_IsOnline", "Lot_Thumbnail", "Lot_Description", "Lot_RoommateVec");

            RefreshUI();

            //NeighborhoodNameButton.Visible = false;

            Size = BackgroundExpandedImage.Size.ToVector2();

            SendToFront(ExpandButton, ContractButton);
        }
示例#3
0
        private void RefreshUI()
        {
            var isOpen       = _Open == true;
            var isClosed     = _Open == false;
            var isMyProperty = false;
            var isRoommate   = false;
            var isOnline     = false;

            if (CurrentLot != null && CurrentLot.Value != null)
            {
                isOnline     = CurrentLot.Value.Lot_IsOnline || (CurrentLot.Value.Lot_LotAdmitInfo?.LotAdmitInfo_AdmitMode >= 4);
                isMyProperty = FindController <CoreGameScreenController>().IsMe(CurrentLot.Value.Lot_LeaderID);

                var roomies = new List <uint>();
                if (CurrentLot.Value.Lot_RoommateVec != null)
                {
                    roomies.AddRange(CurrentLot.Value.Lot_RoommateVec);
                }
                roomies.Remove(CurrentLot.Value.Lot_LeaderID);
                foreach (var roomie in roomies)
                {
                    if (FindController <CoreGameScreenController>().IsMe(roomie))
                    {
                        isRoommate = true;
                    }
                }
                RoommateList.UpdateList(roomies);

                var thumb = CurrentLot.Value.Lot_Thumbnail.Data;
                if (((thumb?.Length) ?? 0) == 0)
                {
                    LotThumbnail.SetThumbnail(DefaultThumb, 0);
                }
                else
                {
                    LotThumbnail.SetThumbnail(ImageLoader.FromStream(GameFacade.GraphicsDevice, new MemoryStream(thumb)), CurrentLot.Value.Id);
                }

                if (OriginalDescription != CurrentLot.Value.Lot_Description)
                {
                    OriginalDescription = CurrentLot.Value.Lot_Description;
                    HouseDescriptionTextEdit.CurrentText = OriginalDescription;
                }
            }

            var canJoin = isMyProperty || isRoommate || isOnline || GameFacade.EnableMod;

            HouseNameButton.Disabled = !isMyProperty;

            BackgroundContractedImage.Visible = isClosed;
            BackgroundExpandedImage.Visible   = isOpen;
            RoommateList.Visible = isOpen;

            ExpandButton.Visible        = isClosed;
            ExpandedCloseButton.Visible = isOpen;

            ContractButton.Visible        = isOpen;
            ContractedCloseButton.Visible = isClosed;

            BackgroundDescriptionImage.Visible     = isOpen && !isMyProperty;
            BackgroundDescriptionEditImage.Visible = isOpen && isMyProperty;
            HouseDescriptionTextEdit.Mode          = (isMyProperty) ? UITextEditMode.Editor : UITextEditMode.ReadOnly;

            HouseDescriptionSlider.Visible                       =
                HouseDescriptionTextEdit.Visible                 =
                    HouseDescriptionScrollUpButton.Visible       =
                        HouseDescriptionScrollDownButton.Visible = isOpen;

            VisitorsLeftScrollButton.Visible = VisitorsRightScrollButton.Visible = isOpen;

            HouseCategoryButton.Disabled = !isMyProperty;
            if (isMyProperty)
            {
                LotThumbnail.Mode = UILotRelationship.OWNER;
            }
            else if (isRoommate)
            {
                LotThumbnail.Mode = UILotRelationship.ROOMMATE;
            }
            else
            {
                LotThumbnail.Mode = UILotRelationship.VISITOR;
            }

            if (canJoin)
            {
                HouseLinkButton.Disabled = false;
                LotThumbnail.Disabled    = false;
            }
            else
            {
                HouseLinkButton.Disabled = true;
                LotThumbnail.Disabled    = true;
            }
        }