public void SetInfo(VM vm, VMEntity entity, bool bought) { var obj = entity.Object; var def = entity.MasterDefinition; if (def == null) { def = entity.Object.OBJ; } var item = Content.Content.Get().WorldCatalog.GetItemByGUID(def.GUID); CTSS catString = obj.Resource.Get <CTSS>(def.CatalogStringsID); if (catString != null) { DescriptionText.CurrentText = catString.GetString(0) + "\r\n" + catString.GetString(1); ObjectNameText.Caption = catString.GetString(0); } else { DescriptionText.CurrentText = entity.ToString(); ObjectNameText.Caption = entity.ToString(); } int price = def.Price; if (item != null) { price = (int)item.Price; } StringBuilder motivesString = new StringBuilder(); motivesString.AppendFormat(GameFacade.Strings.GetString("206", "19") + "${0}\r\n", price); if (def.RatingHunger != 0) { motivesString.AppendFormat(AdStrings[0], def.RatingHunger); } if (def.RatingComfort != 0) { motivesString.AppendFormat(AdStrings[1], def.RatingComfort); } if (def.RatingHygiene != 0) { motivesString.AppendFormat(AdStrings[2], def.RatingHygiene); } if (def.RatingBladder != 0) { motivesString.AppendFormat(AdStrings[3], def.RatingBladder); } if (def.RatingEnergy != 0) { motivesString.AppendFormat(AdStrings[4], def.RatingEnergy); } if (def.RatingFun != 0) { motivesString.AppendFormat(AdStrings[5], def.RatingFun); } if (def.RatingRoom != 0) { motivesString.AppendFormat(AdStrings[6], def.RatingRoom); } var sFlags = def.RatingSkillFlags; for (int i = 0; i < 7; i++) { if ((sFlags & (1 << i)) > 0) { motivesString.Append(AdStrings[i + 7]); } } MotivesText.CurrentText = motivesString.ToString(); string owner = "Nobody"; if (entity is VMGameObject && ((VMTSOObjectState)entity.TSOState).OwnerID > 0) { var ownerID = ((VMTSOObjectState)entity.TSOState).OwnerID; var ownerEnt = vm.GetObjectByPersist(ownerID); owner = (ownerEnt != null) ? owner = ownerEnt.Name : "(offline user)"; } ObjectOwnerText.Caption = GameFacade.Strings.GetString("206", "24", new string[] { owner }); SpecificTabButton.Disabled = !bought; if (bought) { ForSalePrice.CurrentText = GameFacade.Strings.GetString("206", "25", new string[] { " $" + entity.MultitileGroup.Price }); ForSalePrice.SetSize(250, ForSalePrice.Height); } if (entity is VMGameObject) { var objects = entity.MultitileGroup.Objects; ObjectComponent[] objComps = new ObjectComponent[objects.Count]; for (int i = 0; i < objects.Count; i++) { objComps[i] = (ObjectComponent)objects[i].WorldUI; } var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice); if (Thumbnail.Texture != null) { Thumbnail.Texture.Dispose(); } Thumbnail.Texture = thumb; UpdateImagePosition(); } else { if (Thumbnail.Texture != null) { Thumbnail.Texture.Dispose(); } Thumbnail.Texture = null; } }
public UIQueryPanel(LotView.World world) { World = world; Active = false; Opacity = 0; Visible = false; AdStrings = new string[14]; for (int i = 0; i < 14; i++) { string str = GameFacade.Strings.GetString("206", (i + 4).ToString()); AdStrings[i] = ((i < 7)?str.Substring(0, str.Length - 2) + "{0}":str) + "\r\n"; } var useSmall = (GlobalSettings.Default.GraphicsWidth < 1024) || FSOEnvironment.UIZoomFactor > 1f; var script = this.RenderScript("querypanel" + (useSmall?"":"1024") + ".uis"); //NOTE: the background and position of this element changes with the context it is used in. //other elements that are only used for certain modes will be flagged as such with comments. QuerybackPanel = new UIImage(BackgroundImagePanel); QuerybackPanel.Y = 0; this.AddAt(0, QuerybackPanel); ListenForMouse(new Rectangle(0, 0, QuerybackPanel.Texture.Width, QuerybackPanel.Texture.Height), (t, s) => { }); Size = QuerybackPanel.Size.ToVector2() + new Vector2(22, 42); BackOffset = new Point(40, 0); QuerybackCatalog = new UIImage(BackgroundImageCatalog); QuerybackCatalog.Position = new Vector2(-22, 0); this.AddAt(1, QuerybackCatalog); QuerybackTrade = new UIImage(BackgroundImageTrade); QuerybackTrade.X = -40; QuerybackTrade.Y = 0; this.AddAt(2, QuerybackTrade); //init general tab specific backgrounds DescriptionBackgroundImage = new UIImage(ImageDescriptionBackground); DescriptionBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(119, 7); this.AddAt(3, DescriptionBackgroundImage); MotivesBackgroundImage = new UIImage(ImageMotivesBackground); MotivesBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 395:619, 7); this.AddAt(3, MotivesBackgroundImage); GeneralTabImage = new UIImage(ImageGeneralTab); GeneralTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0); this.AddAt(3, GeneralTabImage); SpecificTabImage = new UIImage(ImageSpecificTab); SpecificTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0); this.AddAt(3, SpecificTabImage); OwnerPriceBack = script.Create <UIImage>("OwnerPriceBack"); this.AddAt(3, OwnerPriceBack); BuyerPriceBack = script.Create <UIImage>("BuyerPriceBack"); this.AddAt(3, BuyerPriceBack); OwnerPriceBack.X = ForSalePrice.X; BuyerPriceBack.X = ForSalePrice.X; ForSalePrice.Y += 2; ForSalePrice.SetSize(OwnerPriceBack.Width, ForSalePrice.Height); Thumbnail = new UIImage(); Thumbnail.Position = new Vector2(24, 11); Thumbnail.SetSize(90, 90); this.Add(Thumbnail); DescriptionText.CurrentText = "No Object Selected"; //user should not see this. DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1); DescriptionText.AttachSlider(DescriptionSlider); MotivesText.CurrentText = ""; MotivesSlider.AttachButtons(MotivesScrollUpButton, MotivesScrollDownButton, 1); MotivesText.AttachSlider(MotivesSlider); GeneralTabButton.OnButtonClick += new ButtonClickDelegate(GeneralTabButton_OnButtonClick); SpecificTabButton.OnButtonClick += new ButtonClickDelegate(SpecificTabButton_OnButtonClick); SellBackButton.OnButtonClick += new ButtonClickDelegate(SellBackButton_OnButtonClick); AsyncBuyButton.OnButtonClick += (btn) => { OnAsyncBuyClicked?.Invoke(btn); }; AsyncSaleButton.OnButtonClick += (btn) => { OnAsyncSaleClicked?.Invoke(btn); }; AsyncEditPriceButton.OnButtonClick += (btn) => { OnAsyncPriceClicked?.Invoke(btn); }; AsyncCancelSaleButton.OnButtonClick += (btn) => { OnAsyncSaleCancelClicked?.Invoke(btn); }; InventoryButton.OnButtonClick += InventoryButton_OnButtonClick; WearProgressBar.CaptionStyle = TextStyle.DefaultLabel.Clone(); WearProgressBar.CaptionStyle.Shadow = true; var btnBg = GetTexture(0x8A700000001); //buybuild_query_generalbuy_sellasyncback = 0x8A700000001 SpecificBtnBGs = new List <UIImage>(); SpecificBtnBGs.Add(AddButtonBackground(SellBackButton, btnBg)); SpecificBtnBGs.Add(AddButtonBackground(InventoryButton, btnBg)); SpecificBtnBGs.Add(AddButtonBackground(AsyncSaleButton, btnBg)); AsyncCancelSaleButtonBG = AddButtonBackground(AsyncCancelSaleButton, btnBg); var progressBG = new UIImage(ImageWearBack); progressBG.Position = WearProgressBar.Position - new Vector2(3, 2); AddAt(3, progressBG); SpecificBtnBGs.Add(progressBG); Mode = 1; Tab = 0; }