예제 #1
0
        public void ListRooms(Dictionary <RoomId, List <object> > availableRooms)
        {
            mAvailableRooms = availableRooms;
            mMyRoomListScrollFrame.ClearChildWidgets();

            //we need to procedurally populate the scroll frame with the names of the available rooms from the server
            foreach (KeyValuePair <RoomId, List <object> > room in availableRooms)
            {
                IGuiFrame roomListing = (IGuiFrame)mMyRoomListingFramePrototype.Clone();

                RoomId newRoomId = new RoomId(room.Key);

                Button deleteRoomButton = roomListing.SelectSingleElement <Button>("DeleteRoomButton");
                deleteRoomButton.AddOnPressedAction(
                    delegate()
                {
                    DeleteRoom(newRoomId);
                }
                    );

                Button joinRoomButton = roomListing.SelectSingleElement <Button>("JoinRoomButton");
                joinRoomButton.AddOnPressedAction(
                    delegate()
                {
                    JoinRoom(newRoomId);
                }
                    );

                Label roomNameLabel = roomListing.SelectSingleElement <Label>("RoomName");
                roomNameLabel.Text = room.Value + " - id: " + room.Key.ToString();

                mMyRoomListScrollFrame.AddChildWidget(roomListing, new HorizontalAutoLayout());
            }
        }
예제 #2
0
        /// <summary>
        /// List<Pair<string, string>>, the first string is the facebook friend name, the second string is the facebook friend image url
        /// </summary>
        /// <param name="receivedFriends"></param>
        public void ListEntourage(List <Pair <string, string> > receivedFriends)
        {
            mEntourageListScrollFrame.ClearChildWidgets();
            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            // Show the bonus
            int percentBonus = (int)(Rewards.GetEntourageExperienceBonusPercent(receivedFriends.Count) * 100);

            mMemberCountLabel.Text = String.Format(Translation.ENTOURAGE_MEMBER_COUNT, percentBonus);

            //sort by facebook friend name
            Comparison <Pair <string, string> > sortAlphabetically = new Comparison <Pair <string, string> >(SortNamesAlphabetically);

            receivedFriends.Sort(sortAlphabetically);


            foreach (Pair <string, string> friendNameAndImageUrl in receivedFriends)
            {
                IGuiFrame friendListing = (IGuiFrame)mEntourageListingPrototypeFrame.Clone();

                string facebookFriendPictureUrl = friendNameAndImageUrl.Second;
                clientAssetRepository.LoadAssetFromPath <ImageAsset>(facebookFriendPictureUrl,
                                                                     delegate(ImageAsset friendImageTexture)
                {
                    Image friendImage   = friendListing.SelectSingleElement <Image>("FriendImage");
                    friendImage.Texture = friendImageTexture.Texture2D;
                });

                Label friendNameLabel = friendListing.SelectSingleElement <Label>("FriendName");
                friendNameLabel.Text = friendNameAndImageUrl.First;

                mEntourageListScrollFrame.AddChildWidget(friendListing, new HorizontalAutoLayout());
            }
        }
예제 #3
0
        private void LayoutFriends()
        {
            string filter = "";

            if (mUserNameFilterBox != null)
            {
                filter = mUserNameFilterBox.Text;
            }

            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();
            Vector2 nextGuiPosition = mFriendListingStartPosition;

            mHireFrame.ClearChildWidgets();

            List <Regex> searchFilters = new List <Regex>();

            foreach (string filterSplit in filter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                searchFilters.Add(new Regex(filterSplit, RegexOptions.IgnoreCase | RegexOptions.Compiled));
            }

            foreach (FacebookFriendInfo facebookFriend in mPossibleHires.Values)
            {
                bool matches = true;
                foreach (Regex rx in searchFilters)
                {
                    if (!rx.IsMatch(facebookFriend.FirstName) && !rx.IsMatch(facebookFriend.LastName))
                    {
                        matches = false;
                        break;
                    }
                }

                if (matches)
                {
                    IGuiFrame friendListing = (IGuiFrame)mHireFriendPrototypeFrame.Clone();
                    (friendListing.SelectSingleElement <ITextGuiElement>("FriendNameLabel")).Text = facebookFriend.FirstName + " " + facebookFriend.LastName;

                    Button hireFriendButton   = friendListing.SelectSingleElement <Button>("HireFriendButton");
                    Image  friendListingImage = friendListing.SelectSingleElement <Image>("FriendImage");
                    if (facebookFriend.ImageUrl != "")
                    {
                        clientAssetRepository.LoadAssetFromPath <ImageAsset>
                        (
                            facebookFriend.ImageUrl,
                            delegate(ImageAsset image)
                        {
                            friendListingImage.Texture = image.Texture2D;
                        }
                        );
                    }
                    hireFriendButton.AddOnPressedAction(new HireFriendClosure(this, friendListing, mJobToHireFor, facebookFriend).ExecuteClosure);

                    mHireFrame.AddChildWidget(friendListing, new FixedPosition(nextGuiPosition));
                    nextGuiPosition.y += friendListing.ExternalSize.y + mFriendListingStartPosition.y;
                }
            }
        }
예제 #4
0
        public void ListFriends(List <string> receivedFriends)
        {
            foreach (string friendName in receivedFriends)
            {
                IGuiFrame friendListing = (IGuiFrame)mFriendListingPrototypeFrame.Clone();
                //Image friendImage = friendListing.SelectSingleElement<Image>("FriendImage");
                Label friendNameLabel = friendListing.SelectSingleElement <Label>("FriendName");
                friendNameLabel.Text = friendName;

                //Button chatButton = friendListing.SelectSingleElement<Button>("ChatButton");
                //Button gotoButton = friendListing.SelectSingleElement<Button>("GotoButton");

                mFriendListScrollFrame.AddChildWidget(friendListing, new HorizontalAutoLayout());
            }
        }
예제 #5
0
        /// <summary>
        /// the list of objects should just be the room's data in the same order as the create message
        /// </summary>
        /// <param name="availableRooms"></param>
        public void ListRooms(Dictionary <RoomId, List <object> > availableRooms, RoomId currentRoomId)
        {
            //we need to procedurally populate the scroll frame with the names of the available rooms from the server
            foreach (KeyValuePair <RoomId, List <object> > room in availableRooms)
            {
                RoomType roomtype = CheckType.TryAssignType <RoomType>(room.Value[2]);
                if (roomtype == RoomType.GreenScreenRoom)
                {
                    IGuiFrame roomListing = (IGuiFrame)mRoomListingPrototypeFrame.Clone();

                    Label roomNameLabel = roomListing.SelectSingleElement <Label>("RoomNameLabel");
                    roomNameLabel.Text = CheckType.TryAssignType <string>(room.Value[5]);

                    Label privacyLevelLabel = roomListing.SelectSingleElement <Label>("PrivacyLevelLabel");
                    privacyLevelLabel.Text = CheckType.TryAssignType <PrivacyLevel>(room.Value[4]).ToString();

                    Label populationLevelLabel = roomListing.SelectSingleElement <Label>("PopulationLabel");
                    populationLevelLabel.Text = CheckType.TryAssignType <uint>(room.Value[6]).ToString();

                    RoomId newRoomId      = new RoomId(room.Key);
                    Button joinRoomButton = roomListing.SelectSingleElement <Button>("JoinRoomButton");
                    joinRoomButton.Text = Translation.JOIN_ROOM;

                    joinRoomButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        mSendSwitchingToRoomTypeNotification(roomtype);
                        RoomAPICommands.SwitchRoom(newRoomId, mCurrentRoomRequestType);
                        mMainWindow.Showing = false;
                    }
                    );

                    mRoomListScrollFrame.AddChildWidget(roomListing, new HorizontalAutoLayout());
                }
            }
        }