public UICallNeighborPanel(short callerNID, VM vm)
        {
            VM = vm;
            var nb    = Content.Get().Neighborhood;
            var neigh = nb.GetNeighborByID(callerNID);
            var rels  = neigh.Relationships.Keys;

            //var rels = nb.Neighbors.NeighbourByID.Keys;

            foreach (var to in rels)
            {
                var tn     = nb.GetNeighborByID((short)to);
                var family = tn.PersonData?.ElementAt((int)VMPersonDataVariable.TS1FamilyNumber) ?? 0;
                var gender = tn.PersonData?.ElementAt((int)VMPersonDataVariable.Gender) ?? 0; //can't call pets
                if (family != 0 && gender < 2)
                {
                    List <short> famList = null;
                    if (!NeighborsByFamilyID.TryGetValue(family, out famList))
                    {
                        famList = new List <short>();
                        NeighborsByFamilyID[family] = famList;
                    }

                    famList.Add((short)to);
                }
            }

            FamilyList             = new UITouchStringList();
            FamilyList.Size        = new Microsoft.Xna.Framework.Vector2(320, 350);
            FamilyList.BackingList = NeighborsByFamilyID.Select(x => nb.GetFamilyString((ushort)x.Key).GetString(0)).ToList();
            FamilyList.Refresh();
            FamilyList.OnSelectionChange += FamilyList_OnSelectionChange;
            Add(FamilyList);

            NeighbourList                    = new UITouchStringList();
            NeighbourList.Size               = new Microsoft.Xna.Framework.Vector2(320, 350);
            NeighbourList.Position           = new Microsoft.Xna.Framework.Vector2(370, 0);
            NeighbourList.OnSelectionChange += NeighbourList_OnSelectionChange;
            Add(NeighbourList);

            var cancelButton = new UIBigButton(false);

            cancelButton.Caption        = "Cancel";
            cancelButton.Position       = new Microsoft.Xna.Framework.Vector2(370 + 385, 135);
            cancelButton.OnButtonClick += (btn) => { OnResult?.Invoke(-1); };
            cancelButton.Width          = 275;
            Add(cancelButton);

            CallButton                = new UIBigButton(true);
            CallButton.Caption        = "Call";
            CallButton.Position       = new Microsoft.Xna.Framework.Vector2(370 + 385, 255);
            CallButton.OnButtonClick += (btn) => { OnResult?.Invoke(SelectedNeighbour); };
            CallButton.Width          = 275;
            Add(CallButton);

            NeighbourList_OnSelectionChange((NeighborsByFamilyID.Count == 0)?-2:-1);

            OnResult += (res) => { CallButton.Disabled = true; cancelButton.Disabled = true; };
        }
        public UISelectSkinPanel(VMAvatar target, string type, VM vm)
        {
            this.vm = vm;
            if (target != null)
            {
                BaseGUID       = target.Object.OBJ.GUID;
                CollectionType = type;
                var bodyStrings = target.Object.Resource.Get <FSO.Files.Formats.IFF.Chunks.STR>(target.Object.OBJ.BodyStringID);
                type = bodyStrings.GetString(1).Substring(4);
                type = type.Substring(0, type.IndexOf('_'));

                CurrentSkin = bodyStrings.GetString(14);
            }
            else
            {
                Pet = true;
                if (type == "cat")
                {
                    BaseGUID = 0x7BEA0977;
                }
                else if (type == "dog")
                {
                    BaseGUID = 0x4A70DF92;
                }
            }
            Camera           = new BasicCamera(GameFacade.GraphicsDevice, new Vector3(5, 1, 0), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            Camera.NearPlane = 0.001f;
            Scene            = new _3DTargetScene(GameFacade.GraphicsDevice, Camera, new Point(1030, 500), (GlobalSettings.Default.AntiAlias > 0)?8:0);
            Scene.Initialize(GameFacade.Scenes);

            InitializeLot();
            PopulateSimType(type);

            OKButton                = new UIBigButton(true);
            OKButton.Caption        = GameFacade.Strings.GetString("142", "0");
            OKButton.Position       = new Microsoft.Xna.Framework.Vector2((515 + 300) - 137, 370);
            OKButton.OnButtonClick += (btn) => { OnResult?.Invoke(ResultInd); };
            OKButton.Width          = 275;
            Add(OKButton);

            CancelButton                = new UIBigButton(true);
            CancelButton.Caption        = GameFacade.Strings.GetString("142", "1");
            CancelButton.Position       = new Microsoft.Xna.Framework.Vector2((515 - 300) - 137, 370);
            CancelButton.OnButtonClick += (btn) => { OnResult?.Invoke(-1); };
            CancelButton.Width          = 275;
            Add(CancelButton);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a button to this message box.
        /// </summary>
        /// <param name="label">Label of the button.</param>
        /// <param name="type">Type of the button to be added.</param>
        /// <param name="InternalHandler">Should the button's click be handled internally?</param>
        /// <returns></returns>
        private UIButton AddButton(string label, UIAlertButtonType type, bool InternalHandler)
        {
            var btn = new UIBigButton(type == UIAlertButtonType.OK || type == UIAlertButtonType.Yes);

            btn.Visible = false;
            btn.Caption = label;
            if (btn.Width < 275)
            {
                btn.Width = 275;
            }

            if (InternalHandler)
            {
                btn.OnButtonClick += new ButtonClickDelegate(x =>
                {
                    HandleClose();
                });
            }

            ButtonMap.Add(type, btn);

            this.Add(btn);
            return(btn);
        }
        public UIHouseSelectPanel(int houseID)
        {
            var screen = GameFacade.Screens.CurrentUIScreen;
            var extra  = Math.Max(0, (screen.ScreenHeight - 640) / 128) * 64;

            HouseID = houseID;

            Diag   = new UIDiagonalStripe(new Point(screen.ScreenWidth / 2, screen.ScreenHeight + 16), UIDiagonalStripeSide.RIGHT, UIStyle.Current.Bg);
            Diag.Y = -16;
            Diag.ListenForMouse(Diag.GetBounds(), (e, s) => { });
            Add(Diag);

            TitleStripe          = new UIDiagonalStripe(new Point(screen.ScreenWidth / 2, 92 + 8 + 32), UIDiagonalStripeSide.RIGHT, UIStyle.Current.Bg);
            TitleStripe.StartOff = 8 + 32;
            TitleStripe.Y        = -16 + extra;
            Add(TitleStripe);

            var neigh = Content.Get().Neighborhood;

            var house = neigh.GetHouse(houseID);

            var street     = neigh.StreetNames;
            var assignment = street.Get <STR>(2001).GetString(houseID - 1);

            int streetName;

            if (int.TryParse(assignment, out streetName))
            {
                StreetTitle          = new UILabel();
                StreetTitle.Position = new Vector2(30, 94 + extra - 64);
                InitLabel(StreetTitle);
                StreetTitle.CaptionStyle.Color = UIStyle.Current.BtnActive;
                StreetTitle.Caption            = street.Get <STR>(2000).GetString(streetName - 1).Replace("%s", houseID.ToString());
            }

            var nameDesc = neigh.GetHouseNameDesc(houseID);
            var name     = nameDesc.Item1;

            if (name == "")
            {
                name = StreetTitle.Caption;
            }

            LotTitle          = new UILabel();
            LotTitle.Position = new Vector2(30, 122 + extra - 64);
            InitLabel(LotTitle);
            LotTitle.CaptionStyle.Size = 37;
            LotTitle.Caption           = name;

            var family = neigh.GetFamilyForHouse((short)houseID);

            LotDescription          = new UILabel();
            LotDescription.Position = new Vector2(30, 206 + extra);
            InitLabel(LotDescription);
            //LotDescription.CaptionStyle.Size = 15;
            LotDescription.Size      = new Vector2(screen.ScreenWidth / 2 - 60, screen.ScreenHeight - 415);
            LotDescription.Wrapped   = true;
            LotDescription.Alignment = TextAlignment.Top | TextAlignment.Left;

            SecondaryText          = new UILabel();
            SecondaryText.Position = new Vector2(30, screen.ScreenHeight - (165 + extra));
            InitLabel(SecondaryText);
            SecondaryText.Size               = new Vector2(screen.ScreenWidth / 2 - 60, 29);
            SecondaryText.Wrapped            = true;
            SecondaryText.Alignment          = TextAlignment.Bottom | TextAlignment.Right;
            SecondaryText.CaptionStyle.Color = UIStyle.Current.SecondaryText;

            var moveInID    = (UIScreen.Current as Screens.TS1GameScreen).MoveInFamily;
            var moveIn      = (moveInID == null) ? null : Content.Get().Neighborhood.GetFamily((ushort)moveInID.Value);
            var buttonValid = true;

            if (family != null)
            {
                var famUI = new UIHouseFamilyList(family);

                var scale = Math.Max(2 / 3f, Math.Min(1, screen.ScreenWidth / 1704f));
                famUI.ScaleX = famUI.ScaleY = scale;
                var space = (96 * scale) - 56;
                LotDescription.Y += space;
                famUI.Position    = new Vector2(48 + space / 2, 152 + extra + space / 2);
                Add(famUI);
                FamilyDisplay = famUI;

                LotDescription.Caption = GameFacade.Strings.GetString("134", "0", new string[] {
                    Content.Get().Neighborhood.MainResource.Get <FAMs>(family.ChunkID)?.GetString(0) ?? "?",
                    "§" + (family.ValueInArch + family.Budget).ToString("##,#0"), //should include lot value eventually
                    family.FamilyFriends.ToString()
                });

                LotDescription.CaptionStyle.Color = UIStyle.Current.SecondaryText;

                if (moveIn != null)
                {
                    SecondaryText.Caption = GameFacade.Strings.GetString("132", "15"); //house occupied
                    buttonValid           = false;
                }
            }
            else
            {
                LotDescription.Y   -= 64;
                LotDescription.Size = new Vector2(LotDescription.Size.X, LotDescription.Size.Y + 65);
                //LotDescription.Caption = new string(Enumerable.Range(1, 255).Select(x => 'a').ToArray());
                LotDescription.Caption = nameDesc.Item2;

                //set up the secondary text
                var   zones  = neigh.ZoningDictionary;
                short result = 1;
                if (!zones.TryGetValue((short)houseID, out result))
                {
                    result = (short)((houseID >= 81 && houseID <= 89) ? 2 : 1);
                }

                if (result > 0)
                {
                    //zone
                    string str;
                    if (moveIn != null)
                    {
                        str         = GameFacade.Strings.GetString("134", "18").Substring(8); //is community, can't move in
                        buttonValid = false;
                    }
                    else
                    {
                        str = GameFacade.Strings.GetString("134", "17").Substring(8); //is community
                    }
                    SecondaryText.Caption = str;
                }
                else
                {
                    //show price
                    var    price = house.Get <SIMI>(1)?.PurchaseValue ?? 0;
                    string str;
                    if (houseID >= 90 && houseID <= 92)
                    {
                        //also requires magicoins
                        var magicoins  = neigh.GetMagicoinsForFamily(family);
                        var requiredMC = int.Parse(GameFacade.Strings.GetString("134", (32 + Math.Abs(91 - houseID)).ToString()));

                        if (moveIn != null)
                        {
                            if (magicoins >= requiredMC)
                            {
                                if (moveIn.Budget >= price)
                                {
                                    str = GameFacade.Strings.GetString("134", "31", new string[] { "", "",
                                                                                                   "§" + price.ToString("##,#0"),
                                                                                                   requiredMC.ToString() });
                                }
                                else
                                {
                                    //missing simoleons
                                    str = GameFacade.Strings.GetString("134", "38", new string[] { "", "",
                                                                                                   "§" + price.ToString("##,#0"),
                                                                                                   requiredMC.ToString(),
                                                                                                   moveIn.ChunkParent.Get <FAMs>(moveIn.ChunkID)?.GetString(0) ?? "",
                                                                                                   "§" + moveIn.Budget.ToString("##,#0") }).Substring(4);
                                    buttonValid = false;
                                }
                            }
                            else
                            {
                                if (moveIn.Budget >= price)
                                {
                                    //missing magicoins
                                    str = GameFacade.Strings.GetString("134", "36", new string[] { "", "",
                                                                                                   "§" + price.ToString("##,#0"),
                                                                                                   requiredMC.ToString(),
                                                                                                   moveIn.ChunkParent.Get <FAMs>(moveIn.ChunkID)?.GetString(0) ?? "",
                                                                                                   magicoins.ToString() }).Substring(4);
                                }
                                else
                                {
                                    //missing both
                                    str = GameFacade.Strings.GetString("134", "37", new string[] { "", "",
                                                                                                   "§" + price.ToString("##,#0"),
                                                                                                   requiredMC.ToString(),
                                                                                                   moveIn.ChunkParent.Get <FAMs>(moveIn.ChunkID)?.GetString(0) ?? "",
                                                                                                   magicoins.ToString() }).Substring(4);
                                    buttonValid = false;
                                }
                                buttonValid = false;
                            }
                        }
                        else
                        {
                            //suggest move in
                            str = GameFacade.Strings.GetString("134", "29", new string[] { "", "",
                                                                                           "§" + price.ToString("##,#0"),
                                                                                           requiredMC.ToString() }).Substring(4);
                        }
                    }
                    else
                    {
                        if (moveIn != null)
                        {
                            if (moveIn.Budget >= price)
                            {
                                str = GameFacade.Strings.GetString("134", "5", new string[] { "", "",
                                                                                              "§" + price.ToString("##,#0"),
                                                                                              "§" + (moveIn.Budget - price).ToString("##,#0") }).Substring(4);
                            }
                            else
                            {
                                str = GameFacade.Strings.GetString("134", "4", new string[] { "", "",
                                                                                              "§" + price.ToString("##,#0"),
                                                                                              moveIn.ChunkParent.Get <FAMs>(moveIn.ChunkID)?.GetString(0) ?? "",
                                                                                              "§" + moveIn.Budget.ToString("##,#0") }).Substring(4);
                                buttonValid = false;
                            }
                        }
                        else
                        {
                            //suggest move in
                            str = GameFacade.Strings.GetString("134", "1", new string[] { "", "", "§" + price.ToString("##,#0") }).Substring(4);
                        }
                    }

                    SecondaryText.Caption           = str;
                    SecondaryText.CaptionStyle.Size = 15;
                }
            }

            EnterLot                = new UIBigButton(false);
            EnterLot.Caption        = (moveIn == null)?"Enter Lot":"Move In";
            EnterLot.Width          = (moveIn == null)? (screen.ScreenWidth / 2 - 293) : (screen.ScreenWidth / 2 - 60);
            EnterLot.Disabled       = !buttonValid;
            EnterLot.Position       = new Vector2(30, screen.ScreenHeight - (extra + 125));
            EnterLot.OnButtonClick += (b) => { OnSelected?.Invoke(houseID); Kill(); };
            Add(EnterLot);

            More                = new UIBigButton(true);
            More.Caption        = "More";
            More.Width          = 208;
            More.Position       = new Vector2(screen.ScreenWidth / 2 - 238, screen.ScreenHeight - (extra + 125));
            More.OnButtonClick += (btn) => { ShowMore(true); };
            if (moveIn == null)
            {
                Add(More);
            }

            var optionFunctions = new ButtonClickDelegate[]
            {
                (family == null)?null:(ButtonClickDelegate)((btn) => Evict(family)),
                null,
                null,
                (btn) => ShowMore(false)
            };
            var optionNames = new string[]
            {
                (family == null)?"Bulldoze":"Evict",
                "Rezone",
                "Export",
                "Back"
            };

            var bY = extra + 140;

            for (int i = 0; i < optionFunctions.Length; i++)
            {
                var btn = new UIBigButton(i == optionFunctions.Length - 1);
                btn.Caption        = optionNames[i];
                btn.Position       = new Vector2(screen.ScreenWidth / 4 - btn.Width / 2, bY);
                btn.Disabled       = optionFunctions[i] == null;
                btn.OnButtonClick += optionFunctions[i];
                Add(btn);
                bY += 120;
                OptionButtons.Add(btn);
            }

            X = screen.ScreenWidth / -2;
            GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>()
            {
                { "X", 0f }
            }, TweenQuad.EaseOut);
            MoreTween = MoreTween;
        }
Esempio n. 5
0
        public UIHouseSelectPanel(int houseID)
        {
            HouseID = houseID;
            var screen = GameFacade.Screens.CurrentUIScreen;

            Diag   = new UIDiagonalStripe(new Point(screen.ScreenWidth / 2, screen.ScreenHeight + 16), UIDiagonalStripeSide.RIGHT, UIStyle.Current.Bg);
            Diag.Y = -16;
            Diag.ListenForMouse(Diag.GetBounds(), (e, s) => { });
            Add(Diag);

            TitleStripe          = new UIDiagonalStripe(new Point(screen.ScreenWidth / 2, 92 + 8 + 32), UIDiagonalStripeSide.RIGHT, UIStyle.Current.Bg);
            TitleStripe.StartOff = 8 + 32;
            TitleStripe.Y        = 82 - 34;
            Add(TitleStripe);

            var house = Content.Get().Neighborhood.GetHouse(houseID);

            var street     = Content.Get().Neighborhood.StreetNames;
            var assignment = street.Get <STR>(2001).GetString(houseID - 1);

            int streetName;

            if (int.TryParse(assignment, out streetName))
            {
                StreetTitle          = new UILabel();
                StreetTitle.Position = new Vector2(30, 94);
                InitLabel(StreetTitle);
                StreetTitle.CaptionStyle.Color = UIStyle.Current.BtnActive;
                StreetTitle.Caption            = street.Get <STR>(2000).GetString(streetName - 1).Replace("%s", houseID.ToString());
            }

            var nameDesc = Content.Get().Neighborhood.GetHouseNameDesc(houseID);
            var name     = nameDesc.Item1;

            if (name == "")
            {
                name = "Unnamed House";
            }

            LotTitle          = new UILabel();
            LotTitle.Position = new Vector2(30, 122);
            InitLabel(LotTitle);
            LotTitle.CaptionStyle.Size = 37;
            LotTitle.Caption           = name;

            LotDescription          = new UILabel();
            LotDescription.Position = new Vector2(30, 206);
            InitLabel(LotDescription);
            //LotDescription.CaptionStyle.Size = 15;
            LotDescription.Size      = new Vector2(502, screen.ScreenHeight - 415);
            LotDescription.Wrapped   = true;
            LotDescription.Alignment = TextAlignment.Top | TextAlignment.Left;
            LotDescription.Caption   = nameDesc.Item2;

            EnterLot                = new UIBigButton(false);
            EnterLot.Caption        = "Enter Lot";
            EnterLot.Width          = 275;
            EnterLot.Position       = new Vector2(30, screen.ScreenHeight - 160);
            EnterLot.OnButtonClick += (b) => { OnSelected?.Invoke(houseID); Kill(); };
            Add(EnterLot);

            More          = new UIBigButton(true);
            More.Caption  = "More";
            More.Width    = 192;
            More.Position = new Vector2(330, screen.ScreenHeight - 160);
            Add(More);

            X = screen.ScreenWidth / -2;
            GameFacade.Screens.Tween.To(this, 0.5f, new Dictionary <string, float>()
            {
                { "X", 0f }
            }, TweenQuad.EaseOut);
        }