Esempio n. 1
0
        public void SetInfo(Texture2D thumb, string name, string description, int price)
        {
            ActiveEntity = null;
            Ghost        = false;
            DescriptionText.CurrentText = name + "\r\n" + description;
            ObjectNameText.Caption      = name;

            StringBuilder motivesString = new StringBuilder();

            motivesString.AppendFormat(GameFacade.Strings.GetString("206", "19") + "${0}\r\n", price);
            MotivesText.CurrentText = motivesString.ToString();

            SpecificTabButton.Disabled = true;
            SellBackButton.Disabled    = true;

            if (Thumbnail.Texture != null)
            {
                Thumbnail.Texture.Dispose();
            }
            if (Thumb3D != null)
            {
                Thumb3D.Dispose();
            }
            Thumb3D           = null;
            Thumbnail.Texture = thumb;
            UpdateImagePosition();
        }
Esempio n. 2
0
        public void SetInfo(VM vm, VMEntity entity, bool bought)
        {
            ActiveEntity = entity;
            var obj = entity.Object;
            var def = entity.MasterDefinition;

            if (def == null)
            {
                def = entity.Object.OBJ;
            }

            var item = Content.Content.Get().WorldCatalog.GetItemByGUID(def.GUID);

            var ndesc = GetObjName(entity);

            DescriptionText.CurrentText = ndesc.Item1 + "\r\n" + ndesc.Item2;
            ObjectNameText.Caption      = ndesc.Item1;

            IAmOwner      = ((entity.TSOState as VMTSOObjectState)?.OwnerID ?? 0) == vm.MyUID;
            Ghost         = entity.GhostImage;
            LastSalePrice = entity.MultitileGroup.SalePrice;
            CanSell       = (item?.DisableLevel ?? 0) < 2;

            int price      = def.Price;
            int finalPrice = price;
            int dcPercent  = 0;

            if (item != null)
            {
                price      = (int)item.Value.Price;
                dcPercent  = VMBuildableAreaInfo.GetDiscountFor(item.Value, vm);
                finalPrice = (price * (100 - dcPercent)) / 100;
            }

            StringBuilder motivesString = new StringBuilder();

            if (dcPercent > 0)
            {
                motivesString.Append(GameFacade.Strings.GetString("206", "36", new string[] { dcPercent.ToString() + "%" }) + "\r\n");
                motivesString.AppendFormat(GameFacade.Strings.GetString("206", "37") + "${0}\r\n", finalPrice);
                motivesString.AppendFormat(GameFacade.Strings.GetString("206", "38") + "${0}\r\n", price);
            }
            else
            {
                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.GetAvatarByPersist(ownerID);
                owner = (ownerEnt != null) ? owner = ownerEnt.Name : "(offline user)";
            }

            ObjectOwnerText.Caption = (!entity.GhostImage)?GameFacade.Strings.GetString("206", "24", new string[] { owner }):"";

            SpecificTabButton.Disabled = !bought;

            if (bought)
            {
                ObjectValueText.Caption   = GameFacade.Strings.GetString("206", "25", new string[] { " $" + entity.MultitileGroup.Price });
                ObjectValueText.Alignment = TextAlignment.Center;
                ObjectValueText.X         = ObjectNameText.X;
                ObjectValueText.Size      = new Vector2(260, 1);
            }

            if (LastSalePrice > -1)
            {
                ForSalePrice.CurrentText = "$" + entity.MultitileGroup.SalePrice;
                ForSalePrice.Alignment   = TextAlignment.Center;
                //ForSalePrice.SetSize(250, ForSalePrice.Height);
                SellBackButton.Disabled = (entity.PersistID == 0);
            }
            else
            {
                ForSalePrice.CurrentText = "";
            }

            if (entity is VMGameObject)
            {
                WearProgressBar.Value   = 100 - ((VMTSOObjectState)entity.TSOState).Wear / 4;
                WearProgressBar.Caption = ((VMTSOObjectState)entity.MultitileGroup.BaseObject.TSOState).Broken? GameFacade.Strings.GetString("206", "34") : null;
                WearValueText.Caption   = ((VMTSOObjectState)entity.TSOState).Wear / 4 + "%";
                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;
                }

                if (Thumbnail.Texture != null)
                {
                    Thumbnail.Texture.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumb3D = null; Thumbnail.Texture = null;
                if (FSOEnvironment.Enable3D)
                {
                    Thumb3D = new UI3DThumb(entity);
                }
                else
                {
                    var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice);
                    Thumbnail.Texture = thumb;
                }
                UpdateImagePosition();
            }
            else
            {
                WearProgressBar.Value = 0;
                WearValueText.Caption = "0%";
                if (Thumbnail.Texture != null)
                {
                    Thumbnail.Texture.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumb3D           = null;
                Thumbnail.Texture = null;
            }

            if (bought)
            {
                FSOFacade.Hints.TriggerHint("ui:querypanel");
            }
        }
Esempio n. 3
0
        public void SetInfo(VM vm, VMEntity entity, bool bought)
        {
            var sameEntity = entity == ActiveEntity;

            ActiveEntity = entity;
            var obj = entity.Object;
            var def = entity.MasterDefinition;

            if (def == null)
            {
                def = entity.Object.OBJ;
            }

            var item = Content.Content.Get().WorldCatalog.GetItemByGUID(def.GUID);

            var ndesc = GetObjName(vm, entity);

            DescriptionText.CurrentText = ndesc.Item1 + "\r\n" + ndesc.Item2;
            ObjectNameText.Caption      = ndesc.Item1;

            IAmOwner      = ((entity.TSOState as VMTSOObjectState)?.OwnerID ?? 0) == vm.MyUID;
            Ghost         = entity.GhostImage;
            LastSalePrice = entity.MultitileGroup.SalePrice;
            CanSell       =
                vm.PlatformState.Validator.CanManageAsyncSale((VMAvatar)LotParent.ActiveEntity, ActiveEntity as VMGameObject) &&
                (item?.DisableLevel ?? 0) < 2;

            var upgrades = Content.Content.Get().Upgrades.GetFile(entity.Object.Resource.MainIff.Filename);

            if (!sameEntity)
            {
                SetHasUpgrades(upgrades != null, bought);
            }

            var upgradeLevel = (entity.PlatformState as VMTSOObjectState)?.UpgradeLevel ?? 0;
            int price        = def.Price;
            int finalPrice   = price;
            int dcPercent    = 0;

            if (item != null)
            {
                price = (int)item.Value.Price;
                if (upgradeLevel > 0)
                {
                    price = entity.MultitileGroup.InitialPrice;
                }
                dcPercent  = VMBuildableAreaInfo.GetDiscountFor(item.Value, vm);
                finalPrice = (price * (100 - dcPercent)) / 100;
                if (LotParent.ObjectHolder.DonateMode)
                {
                    finalPrice -= (finalPrice * 2) / 3;
                    dcPercent   = 66;
                }
            }

            StringBuilder motivesString = new StringBuilder();

            if (dcPercent > 0)
            {
                motivesString.Append(GameFacade.Strings.GetString("206", "36", new string[] { dcPercent.ToString() + "%" }) + "\r\n");
                motivesString.AppendFormat(GameFacade.Strings.GetString("206", "37") + "${0}\r\n", finalPrice);
                motivesString.AppendFormat(GameFacade.Strings.GetString("206", "38") + "${0}\r\n", price);
            }
            else
            {
                motivesString.AppendFormat(GameFacade.Strings.GetString("206", "19") + "${0}\r\n", price);
            }

            var catFlags = def.LotCategories;

            for (int i = 1; i < 12; i++)
            {
                if ((catFlags & (1 << i)) > 0)
                {
                    motivesString.AppendLine(CategoryStrings[i - 1]);
                }
            }

            if (def.RatingHunger != 0)
            {
                motivesString.AppendFormat(AdStrings[0], (short)def.RatingHunger);
            }
            if (def.RatingComfort != 0)
            {
                motivesString.AppendFormat(AdStrings[1], (short)def.RatingComfort);
            }
            if (def.RatingHygiene != 0)
            {
                motivesString.AppendFormat(AdStrings[2], (short)def.RatingHygiene);
            }
            if (def.RatingBladder != 0)
            {
                motivesString.AppendFormat(AdStrings[3], (short)def.RatingBladder);
            }
            if (def.RatingEnergy != 0)
            {
                motivesString.AppendFormat(AdStrings[4], (short)def.RatingEnergy);
            }
            if (def.RatingFun != 0)
            {
                motivesString.AppendFormat(AdStrings[5], (short)def.RatingFun);
            }
            if (def.RatingRoom != 0)
            {
                motivesString.AppendFormat(AdStrings[6], (short)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";
            var    ownerTable = "206";
            var    ownerEntry = "24";

            if (entity is VMGameObject && ((VMTSOObjectState)entity.TSOState).OwnerID > 0)
            {
                var ownerID = ((VMTSOObjectState)entity.TSOState).OwnerID;
                owner = (vm.TSOState.Names.GetNameForID(vm, ownerID));
                if (((VMTSOObjectState)entity.TSOState).ObjectFlags.HasFlag(VMTSOObjectFlags.FSODonated))
                {
                    ownerTable = "f114";
                    ownerEntry = "1";
                }
            }

            ObjectOwnerText.Caption = (!entity.GhostImage)?GameFacade.Strings.GetString(ownerTable, ownerEntry, new string[] { owner }):"";

            SpecificTabButton.Disabled = !bought;

            if (bought)
            {
                ObjectValueText.Caption   = GameFacade.Strings.GetString("206", "25", new string[] { " $" + entity.MultitileGroup.Price });
                ObjectValueText.Alignment = TextAlignment.Center;
                ObjectValueText.X         = ObjectNameText.X;
                ObjectValueText.Size      = new Vector2(260, 1);
            }

            if (LastSalePrice > -1)
            {
                ForSalePrice.CurrentText = "$" + entity.MultitileGroup.SalePrice;
                ForSalePrice.Alignment   = TextAlignment.Center;
                //ForSalePrice.SetSize(250, ForSalePrice.Height);
                SellBackButton.Disabled = (entity.PersistID == 0);
            }
            else
            {
                ForSalePrice.CurrentText = "";
            }

            if (entity is VMGameObject)
            {
                WearProgressBar.Value   = 100 - ((VMTSOObjectState)entity.TSOState).Wear / 4;
                WearProgressBar.Caption = ((VMTSOObjectState)entity.MultitileGroup.BaseObject.TSOState).Broken? GameFacade.Strings.GetString("206", "34") : null;
                WearValueText.Caption   = ((VMTSOObjectState)entity.TSOState).Wear / 4 + "%";
                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;
                }

                if (Thumbnail.Texture != null)
                {
                    Thumbnail.Texture.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumb3D = null; Thumbnail.Texture = null;
                if (World.State.CameraMode == LotView.Model.CameraRenderMode._3D)
                {
                    Thumb3D = new UI3DThumb(entity);
                }
                else
                {
                    var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice);
                    Thumbnail.Texture = thumb;
                }
                UpdateImagePosition();
            }
            else
            {
                WearProgressBar.Value = 0;
                WearValueText.Caption = "0%";
                if (Thumbnail.Texture != null)
                {
                    Thumbnail.Texture.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumb3D           = null;
                Thumbnail.Texture = null;
            }

            if (bought)
            {
                FSOFacade.Hints.TriggerHint("ui:querypanel");
            }
        }