예제 #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
    private void SetupOpenWindowsList(ITopLevel topLevel)
    {
        mOpenWindowsList = topLevel;
        ((Window)mOpenWindowsList).InFront = true;
        mWindowListFrame = mOpenWindowsList.SelectSingleElement <IGuiFrame>("MainFrame/WindowList");
        Button hideShowButton = mOpenWindowsList.SelectSingleElement <Button>("MainFrame/HideShowButton");

        hideShowButton.AddOnPressedAction(delegate()
        {
            Vector2 currentPosition = mManager.GetTopLevelPosition(mOpenWindowsList).GetPosition(mOpenWindowsList);
            float shiftAmount       = mWindowListFrame.ExternalSize.x - (hideShowButton.ExternalSize.x * 0.5f);
            if (!mOpenWindowsListShowing)
            {
                shiftAmount *= -1.0f;
            }

            mManager.SetTopLevelPosition
            (
                mOpenWindowsList,
                new FixedPosition
                (
                    currentPosition - new Vector2(shiftAmount, 0.0f)
                )
            );

            mOpenWindowsListShowing = !mOpenWindowsListShowing;
        });

        mWindowListingPrototype = mWindowListFrame.SelectSingleElement <Button>("WindowListingPrototype");
        mWindowListFrame.RemoveChildWidget(mWindowListingPrototype);
    }
예제 #5
0
        public FashionGameGui()
            : base(GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>(), FASHION_GUI_PATH)
        {
            mInput = GameFacade.Instance.RetrieveMediator <FashionGameInput>();

            mScheduler           = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;
            this.MainGui.Showing = true;

            foreach (ITopLevel topLevel in AllGuis)
            {
                switch (topLevel.Name)
                {
                case "FashionGameGui":
                    mMainWindow         = (Window)topLevel;
                    mMainWindow.Showing = true;
                    break;

                case "FashionScoreGui":
                    mScoreWindow         = (Window)topLevel;
                    mScoreWindow.Showing = true;
                    break;
                }
            }

            mMainFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame");
            mClothingButtonPrototype = mMainFrame.SelectSingleElement <PushButton>("ButtonPrototype");

            // Initialize the clothing stack slots
            uint clothingStacks = (uint)(mMainFrame.InternalSize.x / mClothingButtonPrototype.ExternalSize.x);

            for (uint i = 0; i < clothingStacks; ++i)
            {
                mActiveClothes.Add(new List <Pair <ClothingItem, PushButton> >());
            }

            mMainFrame.RemoveChildWidget(mClothingButtonPrototype);

            mWaveLabel              = mScoreWindow.SelectSingleElement <Label>("**/WaveLabel");
            mWaveString             = mWaveLabel.Text;
            mNextWaveButton         = mScoreWindow.SelectSingleElement <Button>("**/NextWaveButton");
            mNextWaveButton.Enabled = false;
            mLevelLabel             = mScoreWindow.SelectSingleElement <Label>("**/LevelLabel");
            mExperienceMeter        = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/ExperienceMeter");
            mExperienceLabel        = mScoreWindow.SelectSingleElement <Label>("**/ExperienceLabel");
            mProgressStyle          = GetNamedStyle("Progress");
            mProgressCompleteStyle  = GetNamedStyle("ProgressComplete");
            mEnergyLabel            = mScoreWindow.SelectSingleElement <Label>("**/EnergyLabel");
            mEnergyTimerLabel       = mScoreWindow.SelectSingleElement <Label>("**/EnergyTimerLabel");
            mEnergyMeter            = mScoreWindow.SelectSingleElement <ProgressIndicator>("**/EnergyMeter");

            mTasks.Add(mScheduler.StartCoroutine(UpdateEnergyDisplay()));
        }
예제 #6
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());
                }
            }
        }
예제 #7
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());
            }
        }
예제 #8
0
    private void SetupLoadGuiDialog(ITopLevel topLevel)
    {
        mLoadGuiDialog = topLevel;
        ((Window)mLoadGuiDialog).InFront = true;
        mLoadGuiDialog.Showing           = false;
        mLoadGuiFilterText = mLoadGuiDialog.SelectSingleElement <Textbox>("MainFrame/FilterText");

        mGuiListFrame           = mLoadGuiDialog.SelectSingleElement <IGuiFrame>("MainFrame/GuiList");
        mLoadGuiButtonPrototype = mGuiListFrame.SelectSingleElement <Button>("OpenGuiPrototype");
        mGuiListFrame.RemoveChildWidget(mLoadGuiButtonPrototype);

        // Keep the load file button disabled until it points to a valid file
        mLoadGuiFilterText.AddTextChangedCallback(LayoutGuiListings);

        LayoutGuiListings();
    }
예제 #9
0
        public ChatWindow(IInputManager inputManager, IGuiFrame chatFrame)
        {
            if (inputManager == null)
            {
                throw new ArgumentNullException("inputManager");
            }

            SetupSlashCommands();

            mChatFrame = chatFrame;

            mChatEntryBox = mChatFrame.SelectSingleElement <Textbox>("ChatEntryTextbox");

            //mChatLogFrame = (mChatFrame.SelectSingleElement<TabButton>("BottomLeftTabView/ButtonsFrame/ChatLogTab")).Frame;
            //mLocalChatPrototype = mChatLogFrame.SelectSingleElement<Textbox>("**/MyMessages");

            //mChatLogFrame.RemoveChildWidget(mLocalChatPrototype);

            Hangout.Shared.Action chatSend = delegate()
            {
                // Get chat from text entry box, and clear it
                String chatText = mChatEntryBox.Text;
                mChatEntryBox.Text = "";

                Hangout.Shared.Action slashCommand;
                if (mSlashCommands.TryGetValue(chatText, out slashCommand))
                {
                    slashCommand();
                }
                else
                {
                    // Filter out empty string
                    if (chatText != "")
                    {
                        // Dispatch chat event.  This will get picked up by SendChatCommand
                        object[] args = { chatText };
                        GameFacade.Instance.SendNotification(GameFacade.SEND_CHAT, args);
                    }
                }
            };

            mInputReceiptReturn = inputManager.RegisterForButtonDown(KeyCode.Return, chatSend);
            // If numlock is down, some laptops send this event instead
            mInputReceiptEnter = inputManager.RegisterForButtonDown(KeyCode.KeypadEnter, chatSend);
        }
예제 #10
0
        private void SetupHireFriendFrame(IGuiFrame hireFrame, Jobs job)
        {
            mStartLevelButton.Disable();

            mHireFrame         = hireFrame;
            mJobToHireFor      = job;
            mUserNameFilterBox = hireFrame.GetContainer <ITopLevel>().SelectSingleElement <Textbox>("**/FriendSearchBox");
            // Hide the feedback label until after the hiring is complete.
            mHireFeedbackLabel         = hireFrame.GetContainer <ITopLevel>().SelectSingleElement <Label>("**/HireFeedbackLabel");
            mHireFeedbackLabel.Showing = false;
            if (mUserNameFilterBox != null)
            {
                mUserNameFilterBox.AddTextChangedCallback(LayoutFriends);
            }

            mFriendHired = false;
            mHireFriendPrototypeFrame = hireFrame.SelectSingleElement <IGuiFrame>("HireFriendPrototypeFrame");
            if (mHireFriendPrototypeFrame == null)
            {
                throw new Exception("No HireFriendPrototypeFrame was found in the level GUI for this level");
            }
            mFriendListingStartPosition = hireFrame.GetChildPosition(mHireFriendPrototypeFrame);
            hireFrame.RemoveChildWidget(mHireFriendPrototypeFrame);

            GetFriendsToHire(job, delegate(IDictionary <long, FacebookFriendInfo> possibleHires)
            {
                // SortedList doesn't support multiple keys with the same value, so to support
                // friends that have the same name, we need to make the last name fields unique
                int uniqueifyingKeySuffix = 0;

                foreach (KeyValuePair <long, FacebookFriendInfo> possibleHire in possibleHires)
                {
                    mPossibleHires.Add(possibleHire.Value.FirstName + possibleHire.Value.LastName + uniqueifyingKeySuffix++, possibleHire.Value);
                }

                LayoutFriends();

                Scrollbar scrollbar = ((IGuiContainer)hireFrame.Parent).SelectSingleElement <Scrollbar>("ScrollBar");
                if (scrollbar != null)
                {
                    scrollbar.Percent = 0.0f;
                }
            });
        }
예제 #11
0
        private ProgressView BuildProgressView(IEnumerable <Pair <IGuiFrame> > progressSteps, IGuiStyle progressLabelStyle)
        {
            IGuiFrame mainFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame");

            if (mainFrame == null)
            {
                throw new Exception("Cannot find the navigation frame at 'NewRoomDialog/MainFrame'");
            }

            IGuiFrame navigationFrame = mainFrame.SelectSingleElement <IGuiFrame>("NavigationFrame");

            if (navigationFrame == null)
            {
                throw new Exception("Cannot find the navigation frame at 'NewRoomDialog/MainFrame/NavigationFrame'");
            }

            IGuiFrame viewFrame = mainFrame.SelectSingleElement <IGuiFrame>("ViewFrame");

            if (viewFrame == null)
            {
                throw new Exception("Cannot find the view frame at 'NewRoomDialog/MainFrame/ViewFrame'");
            }

            IGuiFrame toolFrame = viewFrame.SelectSingleElement <IGuiFrame>("ToolFrame");

            if (toolFrame == null)
            {
                throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/ToolFrame'");
            }

            IGuiFrame topLetterbox = viewFrame.SelectSingleElement <IGuiFrame>("LetterboxTop");

            if (topLetterbox == null)
            {
                throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/LetterboxTop'");
            }

            IGuiFrame bottomLetterbox = viewFrame.SelectSingleElement <IGuiFrame>("LetterboxBottom");

            if (topLetterbox == null)
            {
                throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/LetterboxBottom'");
            }

            if (viewFrame.GuiSize is ProceduralSize)
            {
                // The view frame's size covers the screen except for the NavigationFrame's area
                ((ProceduralSize)viewFrame.GuiSize).SizeFunc = delegate(IGuiElement element)
                {
                    Vector2 size = element.Parent.Size;
                    size.x -= navigationFrame.Size.x;
                    return(size);
                };
            }

            if (toolFrame.GuiSize is ProceduralSize)
            {
                // The tool frame's size is the largest frame that will fit in the ViewFrame while
                // still being the same aspect ratio as the screen.
                ((ProceduralSize)toolFrame.GuiSize).SizeFunc = delegate(IGuiElement element)
                {
                    float   aspectRatio = (float)Screen.width / (float)Screen.height;
                    Vector2 size        = viewFrame.Size;
                    size.y = size.x / aspectRatio;
                    return(size);
                };
            }

            foreach (IGuiElement child in viewFrame.Children)
            {
                if ((child is IGuiFrame))
                {
                    IGuiFrame frame = (IGuiFrame)child;

                    if (frame.GuiSize is ProceduralSize)
                    {
                        if (frame.Name == "LetterboxTop" || frame.Name == "LetterboxBottom")
                        {
                            // The letterbox sizes are 1/2 of the size difference between the
                            // tool frame and the view frame
                            ((ProceduralSize)frame.GuiSize).SizeFunc = delegate(IGuiElement element)
                            {
                                Vector2 size = viewFrame.Size;
                                size.y = (size.y - toolFrame.Size.y) * 0.5f;
                                return(size);
                            };
                        }
                    }
                }
            }

            IGuiPosition toolFramePosition = viewFrame.GetChildGuiPosition(toolFrame);

            if (toolFramePosition is ProceduralPosition)
            {
                ((ProceduralPosition)toolFramePosition).PositionFunc = delegate(IGuiElement element)
                {
                    return(new Vector2(0.0f, topLetterbox.Size.y));
                };
            }

            ProgressView result = new ProgressView
                                  (
                "NewRoomDialogProgressView",
                new FillParent(),
                navigationFrame,
                mainFrame.GetChildGuiPosition(navigationFrame),
                progressLabelStyle,
                viewFrame,
                mainFrame.GetChildGuiPosition(viewFrame)
                                  );

            mainFrame.ClearChildWidgets();
            mainFrame.AddChildWidget(result, new FillParent());

            IGuiPosition topLetterboxPosition    = viewFrame.GetChildGuiPosition(topLetterbox);
            IGuiPosition bottomLetterboxPosition = viewFrame.GetChildGuiPosition(bottomLetterbox);

            foreach (Pair <IGuiFrame> progressStep in progressSteps)
            {
                IGuiFrame newContextFrame = new GuiFrame(progressStep.First.Name.Replace("Main", ""), new FillParent());

                newContextFrame.AddChildWidget(topLetterbox, topLetterboxPosition);
                newContextFrame.AddChildWidget(progressStep.First, toolFramePosition);
                newContextFrame.AddChildWidget(bottomLetterbox, bottomLetterboxPosition);

                result.AddStep(newContextFrame.Name, newContextFrame, progressStep.Second);
            }
            return(result);
        }