예제 #1
0
        public void SetActiveObject(GameObject obj)
        {
            ActiveObj = obj;

            // Workaround to guarantee a monospaced font
            XMLEntryTextBox.Font = new Font(FontFamily.GenericMonospace, XMLEntryTextBox.Font.Size);

            IFFFilenameTextBox.Text = ActiveObj.Resource.Iff.Filename;
            CommentCheckbox.Checked = false;

            GUIDTextBox.Text = ActiveObj.OBJ.GUID.ToString("X8");

            CategoryComboBox.DisplayMember = "Key";
            CategoryComboBox.ValueMember   = "Value";
            CategoryComboBox.DataSource    = new BindingSource(CategoryIds, null);
            CategoryComboBox.SelectedValue = 29;

            SalePriceUpDown.Value = ActiveObj.OBJ.SalePrice;
            CTSS ctss = ActiveObj.Resource.Get <CTSS>(ActiveObj.OBJ.CatalogStringsID);

            NameTextBox.Text = ctss == null ? ActiveObj.OBJ.ChunkLabel : ctss.GetString(0);

            CopiedLabel.Text = "";

            XMLEntryTextBox.Text = GenerateXML();
        }
예제 #2
0
        public Tuple <string, string> GetObjName(VMEntity entity)
        {
            string name = null;

            if (entity.Object.GUID == 0x3278BD34 || entity.Object.GUID == 0x5157DDF2)
            {
                //pet carrier name calculation
                int skinIndex = 0;
                if (entity.GetAttribute(24) == 0)
                {
                    //skin is not random - it has already been assigned
                    skinIndex = entity.GetAttribute(2) + 1;
                }
                name = entity.Object.Resource.Get <STR>(330).GetString(skinIndex);
            }
            else
            {
                if (entity.MultitileGroup.Name != null && entity.MultitileGroup.Name != "")
                {
                    name = entity.Name;
                }
            }

            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)
            {
                if (name == null)
                {
                    name = catString.GetString(0);
                }
                return(new Tuple <string, string>(name, catString.GetString(1)));
            }
            else
            {
                if (name == null)
                {
                    name = entity.ToString();
                }
                return(new Tuple <string, string>(name, ""));
            }
        }
예제 #3
0
        //process of creating a family
        // - other function provides persondata and bodystrings
        // - create FAMI with a new ID
        //   - generate GUID for each sim, and populate FamilyGUIDs
        // - set family in generated persondatas
        // - make the sims
        //   - AddNeighbour to NBRS as below (get back ID. do not set neighborID in personData, as the original doesn't)
        //   - gets a free user_#### id and makes that the name
        //   - replace relevant body strings in TemplatePerson
        //   - add/replace CTSS in TemplatePerson
        //   - change OBJD name to "user_#### - name". maybe change ctss id?
        //   - save sim to userdata

        public static void PrepareTemplatePerson(uint guid, SimTemplateCreateInfo info)
        {
            var neigh = Content.Content.Get().Neighborhood;
            //userid
            var userid = neigh.NextSim;

            var tempObj = Content.Content.Get().WorldObjects.Get(info.CustomGUID ?? TEMPLATE_GUID);

            tempObj.OBJ.ChunkParent.RetainChunkData = true;
            tempObj.OBJ.GUID       = guid;
            tempObj.OBJ.ChunkLabel = "user" + userid.ToString().PadLeft(5, '0') + " - " + info.Name;

            var ctss = tempObj.Resource.Get <CTSS>(2000);

            if (ctss == null)
            {
                ctss = new CTSS()
                {
                    ChunkLabel     = "",
                    ChunkID        = 2000,
                    ChunkProcessed = true,
                    ChunkType      = "CTSS",
                    ChunkParent    = tempObj.Resource.MainIff,
                    AddedByPatch   = true,
                };
                tempObj.Resource.MainIff.AddChunk(ctss);
                ctss.InsertString(0, new STRItem()
                {
                    Value = "", Comment = ""
                });
                ctss.InsertString(0, new STRItem()
                {
                    Value = "", Comment = ""
                });
            }
            ctss.SetString(0, info.Name);
            ctss.SetString(1, info.Bio);
            tempObj.OBJ.CatalogStringsID = 2000;

            var bodyStrings = tempObj.Resource.Get <STR>(200);

            foreach (var item in info.BodyStringReplace)
            {
                bodyStrings.SetString(item.Key, item.Value);
            }

            neigh.SaveNewNeighbour(tempObj);
            bodyStrings.SetString(1, "");
            bodyStrings.SetString(2, "");
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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;
            }
        }
예제 #6
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);

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

            IAmOwner      = ((entity.TSOState as VMTSOObjectState)?.OwnerID ?? 0) == vm.MyUID;
            LastSalePrice = entity.MultitileGroup.SalePrice;

            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 = 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)
            {
                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;
            }
        }
예제 #7
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;
        }
예제 #8
0
        public Tuple <string, string> GetObjName(VM vm, VMEntity entity)
        {
            string name = null;

            if (entity.Object.GUID == 0x3278BD34 || entity.Object.GUID == 0x5157DDF2)
            {
                //pet carrier name calculation
                int skinIndex = 0;
                if (entity.GetAttribute(24) == 0)
                {
                    //skin is not random - it has already been assigned
                    skinIndex = entity.GetAttribute(2) + 1;
                }
                name = entity.Object.Resource.Get <STR>(330).GetString(skinIndex);
            }
            else
            {
                if (entity.MultitileGroup.Name != null && entity.MultitileGroup.Name != "")
                {
                    name = entity.Name;
                }
            }

            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);
            var  desc      = "";

            if (catString != null)
            {
                if (name == null)
                {
                    name = catString.GetString(0);
                }
                desc = catString.GetString(1);
            }
            else
            {
                if (name == null)
                {
                    name = entity.ToString();
                }
            }
            var tsoState = entity.PlatformState as VMTSOObjectState;

            if (tsoState != null && tsoState.UpgradeLevel > 0)
            {
                name += ' ';
                for (int i = 0; i < tsoState.UpgradeLevel; i++)
                {
                    name += '★';
                }
            }
            desc = DescProcess(vm, entity, desc, catString);
            return(new Tuple <string, string>(name, desc));
        }
예제 #9
0
        public void SetInfo(VMEntity entity, bool bought)
        {
            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)
            {
                DescriptionText.CurrentText = catString.GetString(0) + "\r\n" + catString.GetString(1);
                ObjectNameText.Caption      = catString.GetString(0);
            }
            else
            {
                DescriptionText.CurrentText = entity.ToString();
                ObjectNameText.Caption      = entity.ToString();
            }
            StringBuilder motivesString = new StringBuilder();

            motivesString.AppendFormat(GameFacade.Strings.GetString("206", "19") + "${0}\r\n", def.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();
            ObjectOwnerText.Caption = GameFacade.Strings.GetString("206", "24", new string[] { "You" });

            SpecificTabButton.Disabled = !bought;

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