public static string CSTReplaceString(string data, bool hasExpire)
        {
            var split = data.Substring(1).Split(';');

            if (split.Length < (hasExpire ? 3 : 2))
            {
                return(data);
            }

            var args = split.Skip((hasExpire)?3:2).Select(x => BBCodeParser.SanitizeBB(x)).ToArray();

            if (hasExpire)
            {
                uint expire;
                if (uint.TryParse(split[0], out expire) && expire > 0)
                {
                    var date = ClientEpoch.ToDate(expire);
                    date = date.ToLocalTime();
                    var dateString = date.ToShortTimeString() + " " + date.ToShortDateString();
                    for (int i = 0; i < args.Length; i++)
                    {
                        if (args[i] == split[0])
                        {
                            args[i] = dateString;
                        }
                    }
                }
            }
            int off = hasExpire ? 1 : 0;

            return(GameFacade.Strings.GetString(split[off], split[1 + off], args));
        }
Exemple #2
0
 public virtual void SetItem(BulletinItem item)
 {
     Item = item;
     if (item == null)
     {
         Visible = false;
     }
     else
     {
         Visible            = true;
         TitleLabel.Caption = item.Subject;
         Body.Caption       = item.Body;
         if (item.SenderID == 0)
         {
             PersonButton.Visible = false;
         }
         else
         {
             PersonButton.Visible  = true;
             PersonButton.AvatarId = item.SenderID;
         }
         if (item.Time == 0)
         {
             DateLabel.Caption = GameFacade.Strings.GetString("f120", "38");
         }
         else
         {
             DateLabel.Caption = ClientEpoch.ToDate((uint)item.Time).ToLocalTime().ToShortDateString();
         }
         PromotedStar.Visible = (item.Flags & BulletinFlags.PromotedByMayor) > 0;
     }
 }
        private void Regulator_OnError(object data)
        {
            var errorTitle = GameFacade.Strings.GetString("211", "45");
            var errorBody  = GameFacade.Strings.GetString("211", "45");

            if (data is NhoodResponse)
            {
                var response = data as NhoodResponse;
                if (response.Code == NhoodResponseCode.NHOOD_GAMEPLAY_BAN)
                {
                    //print message and end date
                    errorTitle = GameFacade.Strings.GetString("f117", "1");
                    errorBody  = GameFacade.Strings.GetString("f117", ((int)response.Code + 1).ToString(),
                                                              new string[] {
                        ClientEpoch.DHMRemaining(response.BanEndDate),
                        response.Message
                    });
                }
                else if (response.Code == NhoodResponseCode.UNKNOWN_ERROR)
                {
                    errorTitle = GameFacade.Strings.GetString("f117", "1");
                    errorBody  = GameFacade.Strings.GetString("f117", "23");
                    if (response.Message != "")
                    {
                        errorBody += "\n\n" + response.Message;
                    }
                }
                else
                {
                    errorTitle = GameFacade.Strings.GetString("f117", "1");
                    errorBody  = GameFacade.Strings.GetString("f117", ((int)response.Code + 1).ToString());
                }
                LastMessage = response.Message;
                ResolveCallbacks(response.Code);
            }
            else
            {
                ResolveCallbacks(NhoodResponseCode.UNKNOWN_ERROR);
            }

            UIAlert alert = null;

            alert = UIScreen.GlobalShowAlert(new UIAlertOptions()
            {
                Title   = errorTitle,
                Message = errorBody,
                Buttons = UIAlertButton.Ok(x => {
                    UIScreen.RemoveDialog(BlockingDialog);
                    UIScreen.RemoveDialog(alert);
                }),
                AllowEmojis = true
            }, true);
        }
        private void Regulator_OnError(object data)
        {
            var errorTitle = GameFacade.Strings.GetString("211", "45");
            var errorBody  = GameFacade.Strings.GetString("211", "45");

            if (data is BulletinResponse)
            {
                var response = data as BulletinResponse;
                if (response.Type == BulletinResponseType.SEND_FAIL_GAMEPLAY_BAN)
                {
                    //print message and end date
                    errorTitle = GameFacade.Strings.GetString("f117", "1");
                    errorBody  = GameFacade.Strings.GetString("f117", "18",
                                                              new string[] {
                        ClientEpoch.DHMRemaining(response.BanEndDate),
                        response.Message
                    });
                }
                else if (response.Type == BulletinResponseType.FAIL_UNKNOWN)
                {
                    errorTitle = GameFacade.Strings.GetString("f121", "1");
                    errorBody  = GameFacade.Strings.GetString("f121", "2");
                    if (response.Message != "")
                    {
                        errorBody += "\n\n" + response.Message;
                    }
                }
                else
                {
                    errorTitle = GameFacade.Strings.GetString("f121", "1");
                    errorBody  = GameFacade.Strings.GetString("f121", ((int)response.Type + 1).ToString(), new string[] { "3", "1" });
                }
                ResolveCallbacks(response.Type);
            }
            else
            {
                ResolveCallbacks(BulletinResponseType.FAIL_UNKNOWN);
            }

            UIAlert alert = null;

            alert = UIScreen.GlobalShowAlert(new UIAlertOptions()
            {
                Title   = errorTitle,
                Message = errorBody,
                Buttons = UIAlertButton.Ok(x => {
                    UIScreen.RemoveDialog(BlockingDialog);
                    UIScreen.RemoveDialog(alert);
                }),
                AllowEmojis = true
            }, true);
        }
Exemple #5
0
        private int GetTermsSince(uint time)
        {
            var startDate = ClientEpoch.ToDate(time);
            var now       = DateTime.UtcNow;

            var months = 0;

            if (now.Year != startDate.Year)
            {
                months += (((now.Year - startDate.Year) - 1) * 12 + 13 - startDate.Month);
                months += now.Month - 1;
            }
            else
            {
                months = (now.Month - startDate.Month) + 1;
            }
            return(months + 1);
        }
        public void SetPost(BulletinItem item)
        {
            ActiveItem = item;
            if (item == null)
            {
                EditorMode             = true;
                TitleEdit.CurrentText  = "";
                TitleEdit.Mode         = UITextEditMode.Editor;
                BodyText.BBCodeEnabled = false;
                BodyText.CurrentText   = "";
                BodyText.Mode          = UITextEditMode.Editor;
                TimeLabel.Caption      = "0/1000";
                TypeLabel.Caption      = "";
                RightButton.Caption    = GameFacade.Strings.GetString("f120", "12");
                RightButton.Visible    = true;

                LotThumbButton.Visible     = true;
                LotThumbButton.LotId       = 0;
                PropertyButtonName.Visible = true;
                PropertyButtonName.Caption = GameFacade.Strings.GetString("f120", "28");
                LotThumbButton.LotTooltip  = GameFacade.Strings.GetString("f120", "29");
                PropertyButtonBG.Visible   = true;

                PersonButton.Visible     = true;
                PersonButton.AvatarId    = FindController <CoreGameScreenController>()?.MyID() ?? 0;
                PersonButtonName.Visible = true;
                PersonButtonBG.Visible   = true;

                MiddleButton.Visible = false;
            }
            else
            {
                EditorMode             = false;
                TitleEdit.CurrentText  = item.Subject;
                TitleEdit.Mode         = UITextEditMode.ReadOnly;
                BodyText.BBCodeEnabled = true;
                BodyText.CurrentText   = GameFacade.Emojis.EmojiToBB(BBCodeParser.SanitizeBB(item.Body));
                BodyText.Mode          = UITextEditMode.ReadOnly;
                var time = ClientEpoch.ToDate((uint)item.Time).ToLocalTime();
                TimeLabel.Caption = time.ToShortTimeString() + " " + time.ToShortDateString();

                switch (item.Type)
                {
                case BulletinType.Community:
                    TypeLabel.Caption = GameFacade.Strings.GetString("f120", "24");
                    break;

                case BulletinType.System:
                    TypeLabel.Caption = GameFacade.Strings.GetString("f120", "25");
                    break;

                case BulletinType.Mayor:
                    if ((item.Flags & BulletinFlags.PromotedByMayor) > 0)
                    {
                        TypeLabel.Caption = GameFacade.Strings.GetString("f120", "27");
                    }
                    else
                    {
                        TypeLabel.Caption = GameFacade.Strings.GetString("f120", "26");
                    }
                    break;
                }

                var hasLot    = item.LotID != 0;
                var hasPerson = item.SenderID != 0 && item.SenderID != 0xFFFFFFFF;

                PropertyButtonBG.Visible   = hasLot;
                PropertyButtonName.Visible = hasLot;
                LotThumbButton.Visible     = hasLot;

                PersonButton.Visible     = hasPerson;
                PersonButtonBG.Visible   = hasPerson;
                PersonButtonName.Visible = hasPerson;

                LotThumbButton.LotId  = item.LotID;
                PersonButton.AvatarId = item.SenderID;

                var canPromote = IsMayor && item.Type == BulletinType.Community;
                var myPost     = FindController <CoreGameScreenController>()?.IsMe(item.SenderID) ?? false;
                var admin      = GameFacade.EnableMod;

                RightButton.Visible = true;
                if (canPromote)
                {
                    RightButton.Caption = GameFacade.Strings.GetString("f120", "14");
                }
                else
                {
                    if (myPost)
                    {
                        RightButton.Caption = GameFacade.Strings.GetString("f120", "35");
                    }
                    else
                    {
                        RightButton.Visible = false;
                    }
                }

                MiddleButton.Caption = GameFacade.Strings.GetString("f120", "35");
                MiddleButton.Visible = !myPost && GameFacade.EnableMod;
            }
        }
Exemple #7
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;
        }