Beispiel #1
0
        public void SetInfo(Texture2D thumb, string name, string description, int price, bool doDispose)
        {
            ActiveEntity  = null;
            Body.Caption  = description;
            Title.Caption = name;

            SetTitleSize();

            FullHeight = Body.CaptionStyle.LineHeight * Body.NumLines + 45 + 20;
            FullHeight = Math.Max(200, FullHeight);

            TitleAd.Caption = "";
            Ad.Caption      = "";

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

            if (Thumbnail != null && Disposable)
            {
                Thumbnail.Dispose();
            }
            if (Thumb3D != null)
            {
                Thumb3D.Dispose();
            }
            Thumbnail = null; Thumb3D = null;
            Thumbnail = thumb;
            //UpdateImagePosition();
            Disposable = doDispose;
        }
        public void SetInfo(VM vm, VMEntity entity)
        {
            var obj = entity.Object;
            var def = entity.MasterDefinition;

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

            CTSS catString = obj.Resource.Get <CTSS>(def.CatalogStringsID);

            if (catString != null)
            {
                TitleLabel.Caption = catString.GetString(0);
            }
            else
            {
                TitleLabel.Caption = entity.ToString();
            }
            var World    = vm.Context.World;
            var sellback = entity.MultitileGroup.Price;

            var canDelete = entity.IsUserMovable(vm.Context, true) == FSO.SimAntics.Model.VMPlacementError.Success;

            if (!canDelete)
            {
                SubtextLabel.Caption = GameFacade.Strings.GetString("136", "2").Replace("%", TitleLabel.Caption); //cannot be deleted
            }
            else
            {
                if (sellback > 0)
                {
                    SubtextLabel.Caption = GameFacade.Strings.GetString("136", "1").Replace("%", TitleLabel.Caption).Replace("$", "§" + sellback.ToString());
                }
                else
                {
                    SubtextLabel.Caption = GameFacade.Strings.GetString("136", "0").Replace("%", TitleLabel.Caption);
                }
            }

            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;
                }
                if (Thumbnail != null)
                {
                    Thumbnail.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumbnail = null; Thumb3D = null;
                if (FSOEnvironment.Enable3D)
                {
                    Thumb3D = new UI3DThumb(entity);
                }
                else
                {
                    var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice);
                    Thumbnail = thumb;
                }
            }
            else
            {
                if (Thumbnail != null)
                {
                    Thumbnail.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumbnail = null; Thumb3D = null;
                Thumbnail = null;
            }
        }
Beispiel #3
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.Get().WorldCatalog.GetItemByGUID(def.GUID);

            CTSS catString = obj.Resource.Get <CTSS>(def.CatalogStringsID);

            if (catString != null)
            {
                Body.Caption  = catString.GetString(1);
                Title.Caption = catString.GetString(0);
            }
            else
            {
                Body.Caption  = "No information available.";
                Title.Caption = entity.ToString();
            }

            StringBuilder motivesString = new StringBuilder();

            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]);
                }
            }

            var strings = motivesString.ToString().Replace("\r", "").Split('\n').TakeWhile(x => x != "");

            TitleAd.Caption = string.Join("\n", strings.Take(2));
            TitleAd.CaptionStyle.LineHeightModifier = -3;
            TitleAd.Y         = 22;
            TitleAd.Alignment = TextAlignment.Middle | TextAlignment.Right;
            TitleAd.Wrapped   = true;
            Ad.Caption        = string.Join(", ", strings);

            SetTitleSize();

            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;
                }
                if (Thumbnail != null && Disposable)
                {
                    Thumbnail.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumbnail = null; Thumb3D = null;
                if (FSOEnvironment.Enable3D)
                {
                    Thumb3D = new UI3DThumb(entity);
                }
                else
                {
                    var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice);
                    Thumbnail = thumb;
                }
            }
            else
            {
                if (Thumbnail != null && Disposable)
                {
                    Thumbnail.Dispose();
                }
                if (Thumb3D != null)
                {
                    Thumb3D.Dispose();
                }
                Thumbnail = null; Thumb3D = null;
                Thumbnail = null;
            }

            FullHeight = Body.CaptionStyle.LineHeight * Body.NumLines + 45 + 20;
            FullHeight = Math.Max(200, FullHeight);
            if (Ad.Caption != "")
            {
                Ad.Y        = FullHeight;
                FullHeight += 25;
            }
            Disposable = true;
        }