public void SearchCat(NavigatorCategory currentCat)
 {
     foreach (ALFA.Shared.IListBoxItem item in currentCat.ContainedItems)
     {
         string[] rowDataEntries = item.TextFields.ToLower().Split(';');
         foreach(string rowData in rowDataEntries)
         {
             string[] rowBit = rowData.Split('=');
             if(rowBit.Length > 1)
             {
                 if(rowBit[1].Contains(currentUser.LastSearchString.ToLower()) &&
                     !responseObject.ContainedItems.Contains(item))
                 {
                     responseObject.ContainedItems.Add(item);
                 }
             }
         }
         if (this.CancellationPending)
         {
             return;
         }
     }
     foreach (NavigatorCategory childCat in currentCat.ContainedCategories)
     {
         SearchCat(childCat);
     }
 }
예제 #2
0
 public static void DrawNavigatorCategory(CLRScriptBase script, NavigatorCategory nav)
 {
     if (nav != null)
     {
         script.ClearListBox(script.OBJECT_SELF, "SCREEN_DMC_CREATOR", "LISTBOX_ACR_CREATOR");
         if (nav.ParentCategory != null)
         {
             string textFields = "LISTBOX_ITEM_TEXT=  ..";
             string variables = "5=Category:..";
             script.AddListBoxRow(script.OBJECT_SELF, "SCREEN_DMC_CREATOR", "LISTBOX_ACR_CREATOR", "Category:..", textFields, "LISTBOX_ITEM_ICON=folder.tga", variables, "unhide");
         }
         foreach (NavigatorCategory navCat in nav.ContainedCategories)
         {
             string textFields = String.Format("LISTBOX_ITEM_TEXT=  {0}", navCat.DisplayName);
             string variables = String.Format("5={0}", "Category:" + navCat.Name);
             script.AddListBoxRow(script.OBJECT_SELF, "SCREEN_DMC_CREATOR", "LISTBOX_ACR_CREATOR", "Category:" + navCat.Name, textFields, "LISTBOX_ITEM_ICON=folder.tga", variables, "unhide");
         }
         foreach (IListBoxItem navItem in nav.ContainedItems)
         {
             script.AddListBoxRow(script.OBJECT_SELF, "SCREEN_DMC_CREATOR", "LISTBOX_ACR_CREATOR", navItem.RowName, navItem.TextFields, navItem.Icon, navItem.Variables, "unhide");
         }
     }
     else
     {
         script.SendMessageToPC(script.OBJECT_SELF, "Error: Navigator category is null. Cannot draw a list.");
     }
 }
예제 #3
0
 public NavigatorItem(uint uint_3, uint ParentId, uint SpaceId, string Name, bool IsCategory, NavigatorCategory Category)
 {
     this.uint_0              = uint_3;
     this.uint_1              = ParentId;
     this.uint_2              = SpaceId;
     this.string_0            = Name;
     this.bool_0              = IsCategory;
     this.navigatorCategory_0 = Category;
 }
 public void SearchCreator(object Sender, EventArgs e)
 {
     responseObject = new NavigatorCategory();
     responseObject.ParentCategory = baseCat;
     SearchCat(baseCat);
     if (this.CancellationPending)
     {
         return;
     }
     currentUser.CreatorSearchResponse = responseObject;
 }
예제 #5
0
        public override void HandleMessage(Yupi.Model.Domain.Habbo session, Yupi.Protocol.Buffers.ClientMessage request,
                                           Yupi.Protocol.IRouter router)
        {
            string name         = request.GetString();
            string description  = request.GetString();
            string roomModel    = request.GetString();
            int    categoryId   = request.GetInteger();
            int    maxVisitors  = request.GetInteger();
            int    tradeStateId = request.GetInteger();

            RoomModel    model;
            TradingState tradeState;

            if (!RoomModel.TryParse(roomModel, out model) ||
                !TradingState.TryFromInt32(tradeStateId, out tradeState))
            {
                return;
            }

            NavigatorCategory category = NavigatorRepository.Find(categoryId);

            if (category.MinRank > session.Info.Rank)
            {
                return;
            }

            // TODO Filter Name, Description, max visitors
            RoomData data = new RoomData()
            {
                Name        = name,
                Description = description,
                Model       = model,
                Category    = category,
                UsersMax    = maxVisitors,
                TradeState  = tradeState,
                Owner       = session.Info
            };

            RoomRepository.Save(data);

            router.GetComposer <OnCreateRoomInfoMessageComposer>().Compose(session, data);
        }
예제 #6
0
        /// <summary>
        ///     Serializes the search result list statics.
        /// </summary>
        /// <param name="staticId">The static identifier.</param>
        /// <param name="direct">if set to <c>true</c> [direct].</param>
        /// <param name="message">The message.</param>
        /// <param name="session">The session.</param>
        /// <param name="opened"></param>
        /// <param name="showImage"></param>
        internal static void SerializeSearchResultListStatics(string staticId, bool direct, ServerMessage message, GameClient session, bool opened = false, bool showImage = false)
        {
            if (string.IsNullOrEmpty(staticId) || staticId == "official")
            {
                staticId = "official_view";
            }

            if (staticId != "hotel_view" && staticId != "roomads_view" && staticId != "myworld_view" && !staticId.StartsWith("category__") && staticId != "official_view")
            {
                message.AppendString(staticId);
                message.AppendString(string.Empty);
                message.AppendInteger(1);
                message.AppendBool(!opened); // staticId != "my" && staticId != "popular" && staticId != "official-root"
                message.AppendInteger(showImage ? 1 : 0);
            }

            KeyValuePair <RoomData, uint>[] rooms;

            switch (staticId)
            {
            case "hotel_view":
            {
                NavigatorCategory navCategory = Yupi.GetGame().GetNavigator().GetNavigatorCategory(staticId);

                foreach (NavigatorSubCategory subCategory in navCategory.SubCategories)
                {
                    SerializeSearchResultListStatics(subCategory.Caption, false, message, session, subCategory.IsOpened, subCategory.IsImage);
                }

                foreach (PublicCategory flat in Yupi.GetGame().GetNavigator().PrivateCategories.Values)
                {
                    SerializeSearchResultListFlatcats(flat.Id, false, message);
                }

                break;
            }

            case "official_view":
            {
                NavigatorCategory navCategory = Yupi.GetGame().GetNavigator().GetNavigatorCategory(staticId);

                foreach (NavigatorSubCategory subCategory in navCategory.SubCategories)
                {
                    SerializeSearchResultListStatics(subCategory.Caption, false, message, session, subCategory.IsOpened, subCategory.IsImage);
                }
            }
            break;

            case "myworld_view":
            {
                NavigatorCategory navCategory = Yupi.GetGame().GetNavigator().GetNavigatorCategory(staticId);

                foreach (NavigatorSubCategory subCategory in navCategory.SubCategories)
                {
                    SerializeSearchResultListStatics(subCategory.Caption, false, message, session, subCategory.IsOpened, subCategory.IsImage);
                }
            }
            break;

            case "roomads_view":
            {
                foreach (PublicCategory flat in Yupi.GetGame().GetNavigator().PrivateCategories.Values)
                {
                    SerializePromotionsResultListFlatcats(flat.Id, false, message);
                }

                NavigatorCategory navCategory = Yupi.GetGame().GetNavigator().GetNavigatorCategory(staticId);

                foreach (NavigatorSubCategory subCategory in navCategory.SubCategories)
                {
                    SerializeSearchResultListStatics(subCategory.Caption, false, message, session, subCategory.IsOpened, subCategory.IsImage);
                }

                break;
            }

            case "official-root":
            {
                message.AppendServerMessage(Yupi.GetGame().GetNavigator().NewPublicRooms);

                break;
            }

            case "staffpicks":
            {
                message.AppendServerMessage(Yupi.GetGame().GetNavigator().NewStaffPicks);

                break;
            }

            case "my":
            {
                int i = 0;

                message.StartArray();

                foreach (RoomData data in session.GetHabbo().UsersRooms)
                {
                    if (data != null)
                    {
                        data.Serialize(message);

                        message.SaveArray();

                        if (i++ == (direct ? 100 : 8))
                        {
                            break;
                        }
                    }
                }

                message.EndArray();

                break;
            }

            case "favorites":
            {
                if (session.GetHabbo().FavoriteRooms == null)
                {
                    message.AppendInteger(0);

                    return;
                }

                int i = 0;

                message.AppendInteger(session.GetHabbo().FavoriteRooms.Count > (direct ? 40 : 8)
                            ? (direct ? 40 : 8)
                            : session.GetHabbo().FavoriteRooms.Count);

                foreach (
                    RoomData data in
                    session.GetHabbo()
                    .FavoriteRooms.Select(dataId => Yupi.GetGame().GetRoomManager().GenerateRoomData(dataId))
                    .Where(data => data != null))
                {
                    data.Serialize(message);

                    i++;

                    if (i == (direct ? 40 : 8))
                    {
                        break;
                    }
                }

                break;
            }

            case "friends_rooms":
            {
                int i = 0;

                if (session?.GetHabbo() == null || session.GetHabbo().GetMessenger() == null ||
                    session.GetHabbo().GetMessenger().GetActiveFriendsRooms() == null)
                {
                    message.AppendInteger(0);

                    return;
                }

                List <RoomData> roomsFriends =
                    session.GetHabbo()
                    .GetMessenger()
                    .GetActiveFriendsRooms()
                    .OrderByDescending(p => p.UsersNow)
                    .Take(direct ? 40 : 8)
                    .ToList();

                message.AppendInteger(roomsFriends.Count);

                foreach (RoomData data in roomsFriends.Where(data => data != null))
                {
                    data.Serialize(message);

                    i++;

                    if (i == (direct ? 40 : 8))
                    {
                        break;
                    }
                }

                break;
            }

            case "recommended":
            {
                break;
            }

            case "popular":
            {
                rooms = Yupi.GetGame().GetRoomManager().GetActiveRooms();

                if (rooms == null)
                {
                    message.AppendInteger(0);

                    break;
                }

                message.AppendInteger(rooms.Length);

                foreach (KeyValuePair <RoomData, uint> room in rooms)
                {
                    room.Key.Serialize(message);
                }

                break;
            }

            case "top_promotions":
            {
                rooms = Yupi.GetGame().GetRoomManager().GetEventRooms();

                message.AppendInteger(rooms.Length);

                foreach (KeyValuePair <RoomData, uint> room in rooms)
                {
                    room.Key.Serialize(message);
                }

                break;
            }

            case "my_groups":
            {
                int i = 0;

                message.StartArray();

                foreach (uint xGroupId in session.GetHabbo().MyGroups)
                {
                    Group xGroup = Yupi.GetGame().GetGroupManager().GetGroup(xGroupId);

                    if (xGroup != null)
                    {
                        RoomData data = Yupi.GetGame().GetRoomManager().GenerateRoomData(xGroup.RoomId);

                        if (data != null)
                        {
                            data.Serialize(message);
                            message.SaveArray();

                            if (i++ == (direct ? 40 : 8))
                            {
                                break;
                            }
                        }
                    }
                }

                message.EndArray();

                break;
            }

            case "history":
            {
                int i = 0;

                message.StartArray();

                foreach (
                    RoomData roomData in
                    session.GetHabbo()
                    .RecentlyVisitedRooms.Select(
                        roomId => Yupi.GetGame().GetRoomManager().GenerateRoomData(roomId))
                    .Where(roomData => roomData != null))
                {
                    roomData.Serialize(message);
                    message.SaveArray();

                    if (i++ == (direct ? 40 : 8))
                    {
                        break;
                    }
                }

                message.EndArray();

                break;
            }

            default:
            {
                if (staticId.StartsWith("category__"))
                {
                    SerializeSearchResultListFlatcats(
                        Yupi.GetGame()
                        .GetNavigator()
                        .GetFlatCatIdByName(staticId.Replace("category__", string.Empty)), true, message);
                }
                else
                {
                    message.AppendInteger(0);
                }

                break;
            }
            }
        }
 public static void DefaultSortNavigators(NavigatorCategory cat)
 {
     try
     {
         foreach (NavigatorCategory containedCat in cat.ContainedCategories)
         {
             DefaultSortNavigators(containedCat);
         }
         cat.ContainedCategories.Sort();
         cat.ContainedItems.Sort();
     }
     catch(Exception ex)
     {
         loaderError += "\nSorting Error: " + ex.Message;
     }
 }
 public static NavigatorCategory GetCategoryByName(NavigatorCategory ContainingCat, string SeekingName)
 {
     foreach (NavigatorCategory containedCat in ContainingCat.ContainedCategories)
     {
         if (containedCat.Name == SeekingName)
             return containedCat;
     }
     NavigatorCategory newCat = new NavigatorCategory();
     newCat.Name = SeekingName;
     newCat.ParentCategory = ContainingCat;
     newCat.DisplayName = ALFA.Shared.DisplayString.ShortenStringToWidth(newCat.Name, 214);
     ContainingCat.ContainedCategories.Add(newCat);
     return newCat;
 }