Пример #1
0
 private void RateSwitch(UIElement button)
 {
     if (MayorIsMe || GameFacade.EnableMod)
     {
         CurrentMayorTab = UINeighMayorTabMode.Actions;
         Redraw();
     }
     else
     {
         FindController <CoreGameScreenController>()?.NeighborhoodProtocol?.BeginRating
             (CurrentNeigh.Value?.Id ?? 0,
             CurrentNeigh.Value?.Neighborhood_MayorID ?? 0,
             (success) =>
         {
             if (success == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS)
             {
                 UIAlert.Alert("", GameFacade.Strings.GetString("f115", "97"), true);
             }
             GameThread.SetTimeout(() =>
             {
                 RefreshMayor();
             }, 500);
         });
     }
 }
Пример #2
0
        private void Redraw()
        {
            var isDesc   = CurrentTab == UINeighPageTab.Description;
            var isLot    = CurrentTab == UINeighPageTab.Lots;
            var isPeople = CurrentTab == UINeighPageTab.People;
            var isTop    = isLot || isPeople;
            var isMayor  = CurrentTab == UINeighPageTab.Mayor;

            InfoButton.Selected   = isDesc;
            HouseButton.Selected  = isLot;
            PersonButton.Selected = isPeople;
            MayorButton.Selected  = isMayor;

            InfoTabBackgroundImage.Visible = isDesc;
            InfoTabImage.Visible           = isDesc;

            LotThumbnail.Visible                = isDesc;
            DescriptionText.Visible             = isDesc;
            DescriptionSlider.Visible           = isDesc;
            DescriptionScrollDownButton.Visible = isDesc;
            DescriptionScrollUpButton.Visible   = isDesc;

            StatusLabel.Visible         = isDesc;
            ActivityRatingLabel.Visible = isDesc;
            TownNameBanner.Visible      = isDesc;
            //TownHallNameLabel.Visible = isDesc;
            ResidentCountLabel.Visible = isDesc;
            PropertyCountLabel.Visible = isDesc;

            TabTypeLabel.Visible            = isTop;
            TopSTab2BackgroundImage.Visible = isLot;
            TopSTab3BackgroundImage.Visible = isPeople;
            TopSTabImage.Visible            = isTop;

            var topData = GetData();

            for (int i = 0; i < Pedestals.Count; i++)
            {
                var ped   = Pedestals[i];
                var label = Top10Labels[i];
                label.Visible = isTop;
                ped.Visible   = isTop;
                if (!isTop)
                {
                    ped.Height = 0;
                }
                else
                {
                    if (isLot && CurrentLotTab == UINeighLotsTab.TopCategory)
                    {
                        ped.SetPlace(0);
                    }
                    else
                    {
                        ped.SetPlace(i + 1);
                    }

                    //set the top items
                    if (i >= topData.Count)
                    {
                        ped.AvatarId = 0;
                        ped.LotId    = 0;
                    }
                    else
                    {
                        if (isLot)
                        {
                            ped.LotId    = topData[i];
                            ped.AvatarId = 0;
                        }
                        else
                        {
                            ped.LotId    = 0;
                            ped.AvatarId = topData[i];
                        }
                    }
                }
            }


            if (isTop)
            {
                SetPedestalPosition(isLot && CurrentLotTab == UINeighLotsTab.TopCategory, false);
                SetTopLabelState(isPeople, isLot && CurrentLotTab == UINeighLotsTab.TopCategory);
                if (isLot)
                {
                    TabTypeLabel.Caption = GameFacade.Strings.GetString("f115", (17 + (int)CurrentLotTab).ToString());

                    TopTab1Button.Tooltip = GameFacade.Strings.GetString("f115", "17");
                    TopTab2Button.Tooltip = GameFacade.Strings.GetString("f115", "18");
                }
                else
                {
                    TabTypeLabel.Caption = GameFacade.Strings.GetString("f115", (19 + (int)CurrentPersonTab).ToString());

                    TopTab1Button.Tooltip = GameFacade.Strings.GetString("f115", "19");
                    TopTab2Button.Tooltip = GameFacade.Strings.GetString("f115", "20");
                    TopTab3Button.Tooltip = GameFacade.Strings.GetString("f115", "21");
                }
            }

            TopSTabTab1BackgroundImage.Visible = (isLot && CurrentLotTab == UINeighLotsTab.TopOverall) || (isPeople && CurrentPersonTab == UINeighPersonTab.TopActivity);
            TopSTabTab2BackgroundImage.Visible = (isLot && CurrentLotTab == UINeighLotsTab.TopCategory) || (isPeople && CurrentPersonTab == UINeighPersonTab.TopFamous);
            TopSTabTab3BackgroundImage.Visible = isPeople && CurrentPersonTab == UINeighPersonTab.TopInfamous;
            TopSTabTab4BackgroundImage.Visible = false;

            TopSTabTab1SeatImage.Visible = (isTop && !TopSTabTab1BackgroundImage.Visible);
            TopSTabTab2SeatImage.Visible = (isTop && !TopSTabTab2BackgroundImage.Visible);
            TopSTabTab3SeatImage.Visible = (isPeople && !TopSTabTab3BackgroundImage.Visible);
            TopSTabTab4SeatImage.Visible = false;

            TopTab1Button.Visible = isTop;
            TopTab2Button.Visible = isTop && !isPeople; //top famous and infamous disabled til relationship rework
            TopTab3Button.Visible = false;              // isPeople;
            TopTab4Button.Visible = false;

            TopTab1Button.Selected = TopSTabTab1BackgroundImage.Visible;
            TopTab2Button.Selected = TopSTabTab2BackgroundImage.Visible;
            TopTab3Button.Selected = TopSTabTab3BackgroundImage.Visible;
            TopTab4Button.Selected = TopSTabTab4BackgroundImage.Visible;

            MayorTabBackgroundImage.Visible = isMayor;
            MayorTabImage.Visible           = isMayor;

            MayorPersonButton.Visible = isMayor;

            MayorElectionLabel.Visible   = isMayor;
            MayorNominationLabel.Visible = isMayor;

            var  now      = ClientEpoch.Now;
            bool hasMayor = false;
            bool iAmMayor = false;

            if (CurrentNeigh.Value != null)
            {
                iAmMayor  = FindController <CoreGameScreenController>().IsMe(CurrentNeigh.Value.Neighborhood_MayorID);
                MayorIsMe = iAmMayor;
                if (CurrentTab == UINeighPageTab.Description && !DescriptionChanged)
                {
                    DescriptionText.CurrentText = CurrentNeigh.Value.Neighborhood_Description;
                }
                if (!HasShownFilters &&
                    CurrentNeigh.Value.Neighborhood_TopLotCategory != null && CurrentNeigh.Value.Neighborhood_TopLotCategory.Count > 0 &&
                    CurrentNeigh.Value.Neighborhood_TopLotOverall != null && CurrentNeigh.Value.Neighborhood_TopLotOverall.Count > 0)
                {
                    ForcePropertyFilters();
                }
                AsyncAPIThumb(CurrentNeigh.Value.Neighborhood_TownHallXY);
                if (MayorPersonButton.AvatarId != CurrentNeigh.Value.Neighborhood_MayorID)
                {
                    MayorPersonButton.AvatarId = CurrentNeigh.Value.Neighborhood_MayorID;
                }
                var hasElect = (CurrentNeigh.Value.Neighborhood_Flag & 2) == 0;
                hasMayor = CurrentNeigh.Value.Neighborhood_MayorID != 0;
                if (isMayor)
                {
                    //render election data
                    MayorElectionLabel.Visible   = hasElect;
                    MayorNominationLabel.Visible = hasElect;

                    if (hasElect && CurrentNeigh.Value.Neighborhood_ElectionCycle != null)
                    {
                        var electionOver     = ClientEpoch.Now > CurrentNeigh.Value.Neighborhood_ElectionCycle.ElectionCycle_EndDate;
                        var currentMayorDate = ClientEpoch.ToDate(CurrentNeigh.Value.Neighborhood_ElectedDate).ToLocalTime();
                        var awaitingResult   = electionOver && CurrentNeigh.Value.Neighborhood_ElectedDate < CurrentNeigh.Value.Neighborhood_ElectionCycle.ElectionCycle_EndDate;
                        MayorStatusLabel.Caption = GameFacade.Strings.GetString("f115", awaitingResult ? "29" : "30", new string[] { currentMayorDate.ToShortDateString() });

                        var electionDay = CurrentNeigh.Value.Neighborhood_ElectionCycle.ElectionCycle_EndDate;

                        MayorElectionLabel.Caption = GameFacade.Strings.GetString("f115", "31", new string[] { TimeLeftToString((int)(electionDay - now)) });

                        MayorNominationLabel.Caption = GameFacade.Strings.GetString("f115", "32", new string[] { TimeLeftToString((int)((electionDay - 60 * 60 * 24 * 3) - now)) });
                    }
                    else
                    {
                        MayorStatusLabel.Caption = GameFacade.Strings.GetString("f115", "28");
                    }
                }
                var hallLoc = CurrentNeigh.Value.Neighborhood_TownHallXY;
                HasTownHall = hallLoc != 0;
            }

            if (isMayor)
            {
                var canUseExtraTools = iAmMayor || GameFacade.EnableMod;
                MayorRatingFlairLabel.Caption = GameFacade.Strings.GetString("f115", (37 + (int)CurrentMayorTab).ToString());
                RateButton.Caption            = GameFacade.Strings.GetString("f115", (canUseExtraTools) ? "89" : "33");
                if (!canUseExtraTools)
                {
                    CurrentMayorTab = UINeighMayorTabMode.Rate;
                }
            }

            MayorStatusLabel.Visible = isMayor && hasMayor;

            bool isRating = isMayor && CurrentMayorTab == UINeighMayorTabMode.Rate && hasMayor;

            MayorTabRateImage.Visible = isRating;
            RateButton.Visible        = isRating || GameFacade.EnableMod && isMayor;
            MayorRatingBox1.Visible   = isRating;
            MayorRatingBox2.Visible   = isRating;

            bool isMayorAction = isMayor && CurrentMayorTab == UINeighMayorTabMode.Actions;

            MayorActionMod.Visible        = isMayorAction && GameFacade.EnableMod;
            MayorActionMoveTH.Visible     = isMayorAction;
            MayorActionMoveTH.Disabled    = !HasTownHall;
            MayorActionNewTH.Visible      = isMayorAction;
            MayorActionNewTH.Disabled     = HasTownHall;
            MayorActionOrdinances.Visible = false; //isMayorAction;
            MayorActionReturn.Visible     = isMayorAction;

            bool isModAction = isMayor && CurrentMayorTab == UINeighMayorTabMode.ModActions;

            MayorRatingFlairLabel.Visible = isRating || isMayorAction || isModAction;

            ModActionManageRatings.Visible = isModAction;
            ModActionReserved.Visible      = isModAction;
            ModActionReturn.Visible        = isModAction;
            ModActionSetMayor.Visible      = isModAction;
            ModActionTestCycle.Visible     = isModAction;

            MayorBanner.Visible = isMayor;
            RatingStars.Visible = isMayor && hasMayor;
            TermBanner.Visible  = isMayor && hasMayor;
        }
Пример #3
0
        public UINeighPage()
        {
            Add(BackgroundImage = new UIImage());

            Add(InfoTabBackgroundImage = new UIImage());
            Add(InfoTabImage           = new UIImage());

            Add(TopSTab2BackgroundImage = new UIImage());
            Add(TopSTab3BackgroundImage = new UIImage());
            Add(TopSTabImage            = new UIImage());

            Add(TopSTabTab1BackgroundImage = new UIImage());
            Add(TopSTabTab2BackgroundImage = new UIImage());
            Add(TopSTabTab3BackgroundImage = new UIImage());
            Add(TopSTabTab4BackgroundImage = new UIImage());

            Add(TopSTabTab1SeatImage = new UIImage());
            Add(TopSTabTab2SeatImage = new UIImage());
            Add(TopSTabTab3SeatImage = new UIImage());
            Add(TopSTabTab4SeatImage = new UIImage());

            Add(MayorTabBackgroundImage = new UIImage());
            Add(MayorTabImage           = new UIImage());
            Add(MayorTabRateImage       = new UIImage());

            MayorBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f, ScaleY = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "72")
            };
            TermBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f, ScaleY = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "83", new string[] { GetOrdinal(1) })
            };
            TownNameBanner = new UINeighBanner()
            {
                ScaleX  = 0.3333f,
                ScaleY  = 0.3333f,
                Caption = GameFacade.Strings.GetString("f115", "14")
            };

            MayorRatingBox1 = new UIRatingSummaryPanel();
            MayorRatingBox2 = new UIRatingSummaryPanel();

            RatingStars           = new UIRatingDisplay(false);
            RatingStars.HalfStars = 7;

            var script = RenderScript("fsoneighpage.uis");

            DescriptionText.OnChange      += DescriptionText_OnChange;
            HouseNameButton.OnButtonClick += RenameAdmin;
            InfoButton.OnButtonClick      += (btn) => SetTab(UINeighPageTab.Description);
            HouseButton.OnButtonClick     += (btn) => SetTab(UINeighPageTab.Lots);
            PersonButton.OnButtonClick    += (btn) => SetTab(UINeighPageTab.People);
            MayorButton.OnButtonClick     += (btn) => SetTab(UINeighPageTab.Mayor);

            TopTab1Button.OnButtonClick += (btn) => SetSubTab(0);
            TopTab2Button.OnButtonClick += (btn) => SetSubTab(1);
            TopTab3Button.OnButtonClick += (btn) => SetSubTab(2);
            TopTab4Button.OnButtonClick += (btn) => SetSubTab(3);

            RateButton.OnButtonClick += RateSwitch;

            UIUtils.MakeDraggable(BackgroundImage, this, true);

            DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1);
            DescriptionText.AttachSlider(DescriptionSlider);

            RateButton.Width = 60;
            LotThumbnail     = script.Create <UILotThumbButton>("HouseThumbSetup");
            LotThumbnail.Init(RoommateThumbButtonImage, VisitorThumbButtonImage);
            DefaultThumb = TextureUtils.TextureFromFile(GameFacade.GraphicsDevice, GameFacade.GameFilePath("userdata/houses/defaulthouse.bmp"));
            TextureUtils.ManualTextureMask(ref DefaultThumb, new uint[] { 0xFF000000 });
            LotThumbnail.SetThumbnail(DefaultThumb, 0);
            LotThumbnail.OnLotClick += (btn) => {
                FindController <CoreGameScreenController>()?.ShowLotPage(CurrentNeigh.Value?.Neighborhood_TownHallXY ?? 0);
            };
            Add(LotThumbnail);

            MayorPersonButton = script.Create <UIBigPersonButton>("MayorPersonButton");
            Add(MayorPersonButton);

            Add(RatingStars);
            Add(MayorBanner);
            Add(TermBanner);
            TermBanner.Flip = true;
            Add(TownNameBanner);
            Add(MayorRatingBox1);
            Add(MayorRatingBox2);

            CurrentNeigh = new Binding <Neighborhood>()
                           .WithBinding(HouseNameButton, "Caption", "Neighborhood_Name")
                           .WithBinding(ResidentCountLabel, "Caption", "Neighborhood_AvatarCount", (object ava) =>
            {
                return(GameFacade.Strings.GetString("f115", "15", new string[] { ava.ToString() }));
            })
                           .WithBinding(PropertyCountLabel, "Caption", "Neighborhood_LotCount", (object lot) =>
            {
                return(GameFacade.Strings.GetString("f115", "16", new string[] { lot.ToString() }));
            })
                           .WithBinding(ActivityRatingLabel, "Caption", "Neighborhood_ActivityRating", (object rate) =>
            {
                return(GameFacade.Strings.GetString("f115", "13", new string[] { rate.ToString() }));
            })
                           .WithBinding(TermBanner, "Caption", "Neighborhood_ElectedDate", (object rate) =>
            {
                return(GameFacade.Strings.GetString("f115", "83", new string[] { GetOrdinal(GetTermsSince((uint)rate)) }));
            })
                           .WithBinding(this, "MayorID", "Neighborhood_MayorID")
                           .WithBinding(this, "TownHallID", "Neighborhood_TownHallXY")
                           .WithBinding(StatusLabel, "Caption", "Neighborhood_Flag", (object flago) =>
            {
                var flag          = (uint)flago;
                var availableText = "11";
                if ((flag & 1) > 0)
                {
                    availableText = "12";
                }
                return(GameFacade.Strings.GetString("f115", availableText));
            })
                           .WithMultiBinding((changes) => Redraw(), "Neighborhood_Description", "Neighborhood_TownHallXY", "Neighborhood_MayorID",
                                             "Neighborhood_TopLotCategory", "Neighborhood_TopLotOverall", "Neighborhood_TopAvatarActivity", "Neighborhood_TopAvatarFamous",
                                             "Neighborhood_TopAvatarInfamous");

            CurrentMayor = new Binding <Avatar>()
                           .WithBinding(RatingStars, "DisplayStars", "Avatar_MayorRatingHundredth", (object hundredths) =>
            {
                return(((uint)hundredths) / 100f);
            })
                           .WithBinding(this, "Ratings", "Avatar_ReviewIDs");

            CurrentTownHall = new Binding <Lot>()
                              .WithBinding(TownNameBanner, "Caption", "Lot_Name", (object name) =>
            {
                if ((string)name == "Retrieving...")
                {
                    return(GameFacade.Strings.GetString("f115", "14"));
                }
                else
                {
                    return((string)name);
                }
            });

            CenterButton.OnButtonClick += (btn) =>
            {
                (UIScreen.Current as CoreGameScreen).CityRenderer.NeighGeom.CenterNHood((int)(CurrentNeigh.Value?.Id ?? 0));
            };

            BulletinButton.OnButtonClick += (btn) =>
            {
                var id = CurrentNeigh?.Value?.Id ?? 0;
                if (id != 0 && !UIBulletinDialog.Present)
                {
                    var dialog = new UIBulletinDialog(id);
                    dialog.CloseButton.OnButtonClick += (btn2) =>
                    {
                        UIScreen.RemoveDialog(dialog);
                    };
                    UIScreen.GlobalShowDialog(dialog, false);
                }
            };

            CloseButton.OnButtonClick += (btn) =>
            {
                FindController <NeighPageController>().Close();
            };

            //mayor action buttons:
            MayorActionMod.OnButtonClick    += (btn) => { CurrentMayorTab = UINeighMayorTabMode.ModActions; Redraw(); };
            MayorActionReturn.OnButtonClick += (btn) => { CurrentMayorTab = UINeighMayorTabMode.Rate; Redraw(); };
            MayorActionMoveTH.OnButtonClick += (btn) => { MoveTownHall(true); };
            MayorActionNewTH.OnButtonClick  += (btn) => { MoveTownHall(false); };
            ModActionSetMayor.OnButtonClick += ModSetMayor;

            ModActionReturn.OnButtonClick        += (btn) => { CurrentMayorTab = UINeighMayorTabMode.Actions; Redraw(); };
            ModActionManageRatings.OnButtonClick += (btn) => {
                var ratingList = new UIRatingList(CurrentMayor.Value?.Avatar_Id ?? 0);
                UIScreen.GlobalShowAlert(new UIAlertOptions()
                {
                    Title           = GameFacade.Strings.GetString("f118", "23", new string[] { "Retrieving..." }),
                    Message         = GameFacade.Strings.GetString("f118", "24", new string[] { "Retrieving..." }),
                    GenericAddition = ratingList,
                    Width           = 530
                }, true);
            };

            foreach (var elem in Children)
            {
                var label = elem as UILabel;
                if (label != null)
                {
                    label.CaptionStyle        = label.CaptionStyle.Clone();
                    label.CaptionStyle.Shadow = true;
                }
            }

            Pedestals   = new List <UITop10Pedestal>();
            Top10Labels = new List <UILabel>();
            var top10style = TextStyle.DefaultLabel.Clone();

            top10style.Shadow = true;
            top10style.Size   = 8;
            for (int i = 0; i < 10; i++)
            {
                var alt = i % 2 == 1;
                var ped = new UITop10Pedestal()
                {
                    AltColor = alt
                };
                Pedestals.Add(ped);

                var label = new UILabel()
                {
                    CaptionStyle = top10style,
                    Alignment    = TextAlignment.Center | TextAlignment.Middle,
                    Size         = new Vector2(1, 1)
                };
                Top10Labels.Add(label);
                Add(label);
            }
            for (int i = 0; i < 10; i += 2)
            {
                Add(Pedestals[i]);                             //backmost
            }
            for (int i = 1; i < 10; i += 2)
            {
                Add(Pedestals[i]);                             //frontmost
            }
            SetPedestalPosition(false, true);

            Redraw();
        }