예제 #1
0
        public EntourageGui(IGuiManager guiManager)
            : base(guiManager, mResourcePath)
        {
            foreach (IGuiElement element in this.AllElements)
            {
                if (element.Name == "EntourageGui" && element is Window)
                {
                    mMainWindow = (Window)element;

                    Button closeButton = mMainWindow.SelectSingleElement <Button>("MainFrame/EntourageListingsFrame/CancelButton");
                    closeButton.AddOnPressedAction(
                        delegate()
                    {
                        GameFacade.Instance.SendNotification(GameFacade.PLAY_SOUND_CLOSE);
                        mMainWindow.Showing = false;
                    }
                        );

                    mMemberCountLabel         = mMainWindow.SelectSingleElement <Label>("MainFrame/EntourageListingsFrame/MemberCountLabel");
                    mMemberCountLabel.Text    = String.Format(Translation.ENTOURAGE_MEMBER_COUNT, 0);
                    mInviteFriendsButton      = mMainWindow.SelectSingleElement <Button>("MainFrame/EntourageListingsFrame/InviteFriendsButton");
                    mInviteFriendsButton.Text = Translation.ENTOURAGE_INVITE_FRIENDS_BUTTON_TEXT;
                    mInviteFriendsButton.AddOnPressedAction(delegate()
                    {
                        InviteFriendsToEntourage();
                    });

                    mEntourageListScrollFrame       = mMainWindow.SelectSingleElement <ScrollFrame>("MainFrame/EntourageListingsFrame/EntourageListScrollFrame");
                    mEntourageListingPrototypeFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/EntourageListingsFrame/EntourageListScrollFrame/EntourageListingPrototypeFrame");
                    mEntourageListScrollFrame.RemoveChildWidget(mEntourageListingPrototypeFrame);
                }
            }
        }
예제 #2
0
        protected override Window BuildWindow(XmlNode windowNode)
        {
            string   name = BuildName(windowNode);
            IGuiSize size = BuildSize(windowNode);

            IGuiFrame    mainFrame         = null;
            IGuiPosition mainFramePosition = null;
            XmlNode      mainFrameNode     = windowNode.SelectSingleNode("MainFrame");

            if (mainFrameNode != null)
            {
                mainFramePosition = BuildPosition(mainFrameNode);
                mainFrame         = BuildFrame(mainFrameNode);
                if (mainFrame == null)
                {
                    throw new GuiConstructionException("Found MainFrame node in Window (" + name + "), but was unable to construct it.");
                }
            }

            IGuiStyle style = GetStyle(windowNode, typeof(Window));

            return(new DockableEditorTab
                   (
                       name,
                       size,
                       mManager,
                       new KeyValuePair <IGuiFrame, IGuiPosition>
                       (
                           mainFrame,
                           mainFramePosition
                       ),
                       style
                   ));
        }
예제 #3
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());
            }
        }
예제 #4
0
        public ProgressView(string name,
                            IGuiSize size,
                            IGuiFrame progressFrame,
                            IGuiPosition progressFramePosition,
                            IGuiStyle progressLabelsStyle,
                            IGuiFrame contextFrame,
                            IGuiPosition contextFramePosition)
            : base(name, size, null)
        {
            if (progressFrame == null)
            {
                throw new ArgumentNullException("progressFrame");
            }
            if (progressFramePosition == null)
            {
                throw new ArgumentNullException("progressFramePosition");
            }
            if (contextFrame == null)
            {
                throw new ArgumentNullException("contextFrame");
            }
            if (contextFramePosition == null)
            {
                throw new ArgumentNullException("contextFramePosition");
            }

            mProgressFrame      = new Pair <IGuiFrame, IGuiPosition>(progressFrame, progressFramePosition);
            mContextFrame       = new Pair <IGuiFrame, IGuiPosition>(contextFrame, contextFramePosition);
            mProgressLabelStyle = progressLabelsStyle;

            mProgressFrame.First.Parent = this;
            mContextFrame.First.Parent  = this;
        }
예제 #5
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());
            }
        }
예제 #6
0
 public Window(string name,
               IGuiSize size,
               IGuiManager manager,
               IGuiFrame mainFrame)
     : this(name, size, manager, new KeyValuePair <IGuiFrame, IGuiPosition>(mainFrame, null), new KeyValuePair <IGuiFrame, IGuiPosition>(null, null), null)
 {
 }
예제 #7
0
        public Button BuildTabButton(XmlNode buttonNode)
        {
            string    name             = BuildName(buttonNode);
            IGuiSize  size             = BuildSize(buttonNode);
            IGuiStyle activatedStyle   = GetNamedStyle(buttonNode, "activatedStyle", typeof(TabButton));
            IGuiStyle deactivatedStyle = GetNamedStyle(buttonNode, "deactivatedStyle", typeof(TabButton));

            Texture image = null;

            if (buttonNode.Attributes["image"] != null)
            {
                image = BuildTexture(buttonNode, "image");
            }

            IGuiFrame frame           = null;
            XmlNode   frameNode       = buttonNode.SelectSingleNode("Frame");
            XmlNode   scrollFrameNode = buttonNode.SelectSingleNode("ScrollFrame");

            if (frameNode != null)
            {
                frame = BuildFrame(frameNode);
            }
            if (scrollFrameNode != null)
            {
                frame = BuildScrollFrame(scrollFrameNode);
            }

            if (frame == null)
            {
                throw new GuiConstructionException("Cannot create TabButton (" + name + "), cannot find frame child node.");
            }
            return(new TabButton(name, size, activatedStyle, deactivatedStyle, image, frame));
        }
예제 #8
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);
    }
예제 #9
0
        private void SelectFrame(IGuiFrame friendListing)
        {
            GuiPath selectEverything = new GuiPath("**/*");

            foreach (Button button in selectEverything.SelectElements <Button>((IGuiContainer)friendListing.Parent))
            {
                button.Disable();
            }

            IGuiStyle buttonStyle = new GuiStyle(mGuiManager.GetDefaultStyle(typeof(Button)), "ButtonStyle");
            IGuiStyle frameStyle  = new GuiStyle(friendListing.Style, "FrameStyle");

            foreach (IGuiStyle style in mFirstTimeLevelGui.AllStyles)
            {
                if (style.Name == "SecondaryButtonStyle")
                {
                    buttonStyle = new GuiStyle(style, "ButtonStyle");
                }
                else if (style.Name == "SelectedFrameStyle")
                {
                    frameStyle = new GuiStyle(style, "FrameStyle");
                }
            }

            foreach (Button button in selectEverything.SelectElements <Button>(friendListing))
            {
                button.Style = buttonStyle;
                button.Enable();
            }
            friendListing.Style = frameStyle;
        }
예제 #10
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;
                }
            }
        }
예제 #11
0
 private void CleanupWindow()
 {
     if (mDesiredClothingWindow != null)
     {
         mDesiredClothingWindow.Close();
         mDesiredClothingWindow = null;
         mDesiredClothingFrame  = null;
     }
 }
예제 #12
0
 public Window(string name,
               IGuiSize size,
               IGuiManager manager,
               IGuiFrame mainFrame,
               IGuiFrame headerFrame,
               IGuiStyle style)
     : this(name, size, manager, new KeyValuePair <IGuiFrame, IGuiPosition>(mainFrame, null), new KeyValuePair <IGuiFrame, IGuiPosition>(headerFrame, null), style)
 {
 }
예제 #13
0
 public TabButton(string name,
                  IGuiSize size,
                  IGuiStyle activatedStyle,
                  IGuiStyle deactivatedStyle,
                  Texture image,
                  IGuiFrame frame)
     : base(name, size, activatedStyle, deactivatedStyle, image)
 {
     mFrame = frame;
 }
예제 #14
0
            public void ExecuteClosure()
            {
                if (!mThisRef.mFriendHired)
                {
                    mThisRef.mFriendHired = true;

                    // Cleanup the hire GUI to up framerate through the rest of this function
                    IGuiFrame hireParent = (IGuiFrame)mThisRef.mHireFrame.Parent;
                    ((IGuiFrame)hireParent.Parent).RemoveChildWidget(hireParent);
                    hireParent          = null;
                    mThisRef.mHireFrame = null;

                    mThisRef.mHireFeedbackLabel.Showing = true;
                    mThisRef.mHireFeedbackLabel.Text    = "Hiring " + mFriendInfo.FirstName + " " + mFriendInfo.LastName + ". Please wait...";

                    FashionNpcMediator npcFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>();
                    FashionGameCommands.HireFriend(mFriendInfo.FbAccountId, mJob, delegate(Message message)
                    {
                        npcFactory.HiredFriend(message, mThisRef.mLevel);
                    });

                    string feedType = "";
                    switch (mJob)
                    {
                    case Jobs.Model:
                        feedType = HIRED_FRIEND_MODEL_FEED_COPY;
                        break;

                    case Jobs.Hair:
                        feedType = HIRED_FRIEND_HAIR_FEED_COPY;
                        break;

                    case Jobs.Makeup:
                        feedType = HIRED_FRIEND_MAKEUP_FEED_COPY;
                        break;

                    case Jobs.Seamstress:
                        feedType = HIRED_FRIEND_SEAMSTRESS_FEED_COPY;
                        break;
                    }

                    GameFacade.Instance.RetrieveMediator <FacebookFeedMediator>().PostFeed
                    (
                        mFriendInfo.FbAccountId,
                        FashionMinigame.FACEBOOK_FEED_COPY_PATH,
                        feedType,
                        delegate(){},
                        mFriendInfo.FirstName + " " + mFriendInfo.LastName
                    );

                    // Add mixpanel funnel metrics
                    FunnelGlobals.Instance.LogFunnel(FunnelGlobals.FUNNEL_FRIEND_HIRE, FunnelGlobals.CLICKED_HIRE, "{\"level\":\"" + mThisRef.mLevel.Name + "\"}");
                }
            }
예제 #15
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()));
        }
예제 #16
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());
            }
        }
예제 #17
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();
    }
예제 #18
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);
        }
예제 #19
0
        public RoomAPIGui(IGuiManager guiManager)
            : base(guiManager, mResourcePath)
        {
            foreach (IGuiElement element in this.AllElements)
            {
                if (element.Name == "RoomAPIGui" && element is Window)
                {
                    mMainWindow = (Window)element;

                    Button closeButton = mMainWindow.SelectSingleElement <Button>("HeaderFrame/CloseButton");
                    closeButton.AddOnPressedAction(
                        delegate()
                    {
                        mMainWindow.Showing = false;
                    }
                        );

                    mMyRoomListScrollFrame       = mMainWindow.SelectSingleElement <ScrollFrame>("MainFrame/RoomListFrame");
                    mCreateRoomTextbox           = mMainWindow.SelectSingleElement <Textbox>("MainFrame/NewRoomName");
                    mCreateGreenScreenRoomButton = mMainWindow.SelectSingleElement <Button>("MainFrame/CreateGreenScreenRoom");
                    mCreateGreenScreenRoomButton.AddOnPressedAction(
                        delegate()
                    {
                        CreateRoom(mCreateRoomTextbox.Text, RoomType.GreenScreenRoom);
                    }
                        );
                    mCreateMiniGameRoomButton = mMainWindow.SelectSingleElement <Button>("MainFrame/CreateMiniGameRoom");
                    mCreateMiniGameRoomButton.AddOnPressedAction(
                        delegate()
                    {
                        CreateRoom(mCreateRoomTextbox.Text, RoomType.MiniGameRoom);
                    }
                        );
                    mMyRoomListingFramePrototype = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/RoomListFrame/RoomListingPrototype");

                    mMyRoomListScrollFrame.RemoveChildWidget(mMyRoomListingFramePrototype);

                    Button nextRoomButton = mMainWindow.SelectSingleElement <Button>("MainFrame/NextRoomButton");
                    nextRoomButton.AddOnPressedAction(GetNextRoom);
                    Button previousRoomButton = mMainWindow.SelectSingleElement <Button>("MainFrame/PreviousRoomButton");
                    previousRoomButton.AddOnPressedAction(GetPreviousRoom);
                }
            }
        }
예제 #20
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;
                }
            });
        }
예제 #21
0
        public ProgressIndicator(string name,
                                 IGuiSize size,
                                 IGuiStyle troughStyle,
                                 IGuiStyle progressStyle,
                                 Orientation orientation)
            : base(name, size, troughStyle)
        {
            if (progressStyle == null)
            {
                throw new ArgumentNullException("progressStyle");
            }
            mOrientation = orientation;

            mTroughFrame   = new GuiFrame("ProgressTrough", size, troughStyle);
            mProgressFrame = new GuiFrame("Progress", new FixedSize(Vector2.zero), progressStyle);

            mTroughFrame.AddChildWidget(mProgressFrame, new FixedPosition(Vector2.zero, GuiAnchor.BottomLeft));
            mTroughFrame.Parent = this;
        }
예제 #22
0
        private void HandleHireGui(Hangout.Shared.Action onStartLevel)
        {
            IGuiFrame hireFrame = mFirstTimeLevelGui.MainGui.SelectSingleElement <IGuiFrame>("**/HireList");

            mStartLevelButton = mFirstTimeLevelGui.MainGui.SelectSingleElement <Button>("**/StartLevelButton");

            if (hireFrame != null)
            {
                string  query      = "Level/FirstTimeLevelGui/@hires";
                XmlNode hireForJob = mLevelXml.SelectSingleNode(query);
                if (hireForJob == null)
                {
                    throw new Exception(mLevel.Name + " has a GUI that contains a hire friend dialog, but that level doesn't have any hire information at " + query);
                }

                // Add mixpanel funnel metrics
                FunnelGlobals.Instance.LogFunnel(FunnelGlobals.FUNNEL_FRIEND_HIRE, FunnelGlobals.HIRE_FRIEND_POPUP, "{\"level\":\"" + mLevel.Name + "\"}");

                SetupHireFriendFrame(hireFrame, (Jobs)Enum.Parse(typeof(Jobs), hireForJob.InnerText));

                mStartLevelButton.AddOnPressedAction(delegate()
                {
                    if (mFriendHired)
                    {
                        onStartLevel();
                        CleanupFirstTimeGui();

                        // Add mixpanel funnel metrics
                        FunnelGlobals.Instance.LogFunnel(FunnelGlobals.FUNNEL_FRIEND_HIRE, FunnelGlobals.CLICKED_PLAY, "{\"level\":\"" + mLevel.Name + "\"}");
                    }
                    else
                    {
                        throw new Exception("Need to Hire a friend first");
                    }
                });
            }
            else
            {
                mStartLevelButton.AddOnPressedAction(onStartLevel);
                mStartLevelButton.AddOnPressedAction(CleanupFirstTimeGui);
            }
        }
예제 #23
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());
                }
            }
        }
예제 #24
0
        public FriendsGui(IGuiManager guiManager)
            : base(guiManager, mResourcePath)
        {
            foreach (IGuiElement element in this.AllElements)
            {
                if (element.Name == "FriendsGui" && element is Window)
                {
                    mMainWindow = (Window)element;

                    Button closeButton = mMainWindow.SelectSingleElement <Button>("HeaderFrame/CloseButton");
                    closeButton.AddOnPressedAction(
                        delegate()
                    {
                        GameFacade.Instance.SendNotification(GameFacade.PLAY_SOUND_CLOSE);
                        mMainWindow.Showing = false;
                    }
                        );

                    mFriendListScrollFrame       = mMainWindow.SelectSingleElement <ScrollFrame>("MainFrame/FriendListScrollFrame");
                    mFriendListingPrototypeFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/FriendListScrollFrame/FriendListingPrototype");
                    mFriendListScrollFrame.RemoveChildWidget(mFriendListingPrototypeFrame);
                }
            }
        }
예제 #25
0
 public ProgressStep(string name, IGuiFrame contextFrame, IGuiFrame progressFrame)
 {
     mName          = name;
     mContextFrame  = contextFrame;
     mProgressFrame = progressFrame;
 }
예제 #26
0
        /// <summary>
        /// Starts a walk down the runway
        /// </summary>
        public void SetActive(FashionModelNeeds needs, FashionLevel level)
        {
            if (needs == null)
            {
                throw new ArgumentNullException("needs");
            }
            mNeeds = needs;

            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;

            mNametag.MainGui.Showing = true;

            mDesiredClothing.Clear();
            if (mDesiredClothingFrame != null)
            {
                mDesiredClothingFrame.ClearChildWidgets();
            }
            mDesiredStations.Clear();

            mStateMachine = new FashionModelStateMachine(this, mLevel);

            UnityGameObject.transform.position = mLevel.Start.First;

            mActiveWalkCycle      = mCatWalk;
            mActiveWalkCycleSpeed = mCatWalkSpeed;

            mCompletionBonusTime = 5.0f;
            mReady = false;

            mHandleBonusTask = mScheduler.StartCoroutine(HandleBonus());

            IGuiManager manager = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();

            mDesiredClothingFrame = new GuiFrame("MainFrame", new MainFrameSizePosition());

            IGuiStyle windowStyle = new GuiStyle(manager.GetDefaultStyle(typeof(Window)), "ModelNeedsWindow");

            windowStyle.Normal.Background = null;
            windowStyle.Hover.Background  = null;

            // TODO: Hard coded values
            float windowHeight = 192.0f;

            mDesiredClothingWindow = new Window
                                     (
                "ModelClothingPanel",
                new FixedSize(128.0f, windowHeight),
                manager,
                mDesiredClothingFrame,
                windowStyle
                                     );

            // TODO: Hard coded values
            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                GameFacade.Instance.RetrieveMediator <FashionCameraMediator>().Camera,
                this.DisplayObject.transform,
                GuiAnchor.CenterLeft,
                new Vector2(0.0f, windowHeight * 0.4f),
                new Vector3(0.125f, APPROX_AVATAR_HEIGHT * 1.3f, 0.25f)
                                      );

            manager.SetTopLevelPosition
            (
                mDesiredClothingWindow,
                mFollowWorldSpaceObject
            );

            ClothingMediator clothingMediator = GameFacade.Instance.RetrieveMediator <ClothingMediator>();

            // Setup Clothes GUI
            foreach (ItemId clothing in mNeeds.Clothing)
            {
                Image desiredClothingImage = new Image("DesiredClothingLabel", clothingMediator.GetThumbStyle(clothing), clothingMediator.GetThumbnail(clothing));
                mDesiredClothing.Add(clothing, desiredClothingImage);
                mDesiredClothingFrame.AddChildWidget(desiredClothingImage, new HorizontalAutoLayout());
            }

            // Setup Station GUI
            foreach (ModelStation station in mNeeds.Stations)
            {
                Image desiredStationImage = new Image("DesiredStationImage", station.Image);

                mDesiredStations.Add(station, desiredStationImage);
                mDesiredClothingFrame.AddChildWidget(desiredStationImage, new HorizontalAutoLayout());

                mCompletionBonusTime += station.WaitTime + mWalkToStationTimeBonus;
            }

            this.DisplayObject.SetActiveRecursively(true);

            Shader fashionModelShader = Shader.Find("Avatar/Fashion Model");

            if (fashionModelShader == null)
            {
                throw new Exception("Cannot find 'Avatar/Fashion Model' shader");
            }

            mModelMaterials.Clear();
            foreach (Component component in UnityGameObject.GetComponentsInChildren(typeof(Renderer)))
            {
                Renderer renderer = (Renderer)component;
                foreach (Material mat in renderer.materials)
                {
                    mat.shader = fashionModelShader;
                    mModelMaterials.Add(mat);
                }
            }

            mNeeds.AddOnCompleteAction(ModelComplete);
        }
예제 #27
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);
        }
예제 #28
0
        public NewRoomDialog(IGuiManager guiManager)
            : base(guiManager, mGuiPath)
        {
            Pair <IGuiFrame>[] progressSteps = new Pair <IGuiFrame> [mProgressFrameNames.Length];
            for (int i = 0; i < progressSteps.Length; ++i)
            {
                progressSteps[i] = new Pair <IGuiFrame>();
            }

            // Grab the references to the required elements
            foreach (IGuiElement element in this.AllElements)
            {
                if (element is Window && element.Name == "NewRoomDialog")
                {
                    mMainWindow = (Window)element;
                }
                else if (element is IGuiFrame)
                {
                    IGuiFrame frame = (IGuiFrame)element;
                    for (int i = 0; i < mProgressFrameNames.Length; ++i)
                    {
                        if (frame.Name == mProgressFrameNames[i].First)
                        {
                            progressSteps[i].First = frame;
                        }
                        else if (frame.Name == mProgressFrameNames[i].Second)
                        {
                            progressSteps[i].Second = frame;
                        }
                    }
                }
                else
                {
                    throw new Exception("Unexpected " + element.GetType().Name + "(" + element.Name + ") found in the root of GUI XML(" + mGuiPath + ")");
                }
            }

            // Check to make sure all the frames are in the XML
            for (int i = 0; i < progressSteps.Length; ++i)
            {
                string failName = null;
                if (progressSteps[i].First == null)
                {
                    failName = mProgressFrameNames[i].First;
                }
                else if (progressSteps[i].Second == null)
                {
                    failName = mProgressFrameNames[i].Second;
                }
                if (failName != null)
                {
                    throw new Exception("Unable to find frame(" + failName + ") in the root of " + mGuiPath);
                }
            }

            if (mMainWindow == null)
            {
                throw new Exception("Unable to find Window(NewRoomDialog) in the root of " + mGuiPath);
            }
            mMainWindow.Showing = false;

            mProgressView = BuildProgressView(progressSteps, this.GetNamedStyle("NavbarButton"));
            SetupProgressButtons(progressSteps);
            mProgressView.GoToStep(0);
        }
예제 #29
0
        public RoomPickerGui(IGuiManager guiManager, System.Action <RoomType> sendSwitchingToRoomTypeNotification)
            : base(guiManager, mResourcePath)
        {
            mSendSwitchingToRoomTypeNotification = sendSwitchingToRoomTypeNotification;
            foreach (IGuiElement element in this.AllElements)
            {
                if (element.Name == "RoomPickerGui" && element is Window)
                {
                    mMainWindow = (Window)element;
                    mMainWindow.OnShowing(OnShowingCallback);

                    mTitleLabel = mMainWindow.SelectSingleElement <Label>("MainFrame/RoomListingsFrame/TitleBarLabel");
                    //we're going to initially display the client's rooms so the "My Rooms" title should be displayed first
                    mTitleLabel.Text = Translation.ROOM_PICKER_MY_ROOMS;

                    Button closeButton = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingsFrame/CancelButton");
                    closeButton.AddOnPressedAction(
                        delegate()
                    {
                        mMainWindow.Showing = false;
                    }
                        );

                    //setup the buttons for displaying the various types of rooms
                    Button clientOwnedRoomsButton   = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/ClientOwnedRoomsButton");
                    Button friendsRoomsButton       = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/FriendsRoomsButton");
                    Button hangoutPublicRoomsButton = mMainWindow.SelectSingleElement <Button>("MainFrame/RoomListingButtons/HangoutPublicRoomsButton");

                    clientOwnedRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.ClientOwnedRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.ClientOwnedRooms);
                        mCurrentRoomRequestType = MessageSubType.ClientOwnedRooms;
                    }
                    );
                    friendsRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.FriendsRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.FriendsRooms);
                        mCurrentRoomRequestType = MessageSubType.FriendsRooms;
                    }
                    );
                    hangoutPublicRoomsButton.AddOnPressedAction
                    (
                        delegate()
                    {
                        ClearRoomsWindow();
                        UpdateWindowTitleLabel(MessageSubType.PublicRooms);
                        RoomAPICommands.RequestRoomsFromServer(MessageSubType.PublicRooms);
                        mCurrentRoomRequestType = MessageSubType.PublicRooms;
                    }
                    );

                    //set up the grid view / scroll area where the rooms are listed
                    mRoomListScrollFrame       = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/RoomListingsFrame/RoomListScrollFrame");
                    mRoomListingPrototypeFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame/RoomListingsFrame/RoomListScrollFrame/RoomListingPrototypeFrame");
                    mRoomListScrollFrame.RemoveChildWidget(mRoomListingPrototypeFrame);
                }
            }
        }
예제 #30
0
 public ProgressStep(ProgressStep copy)
 {
     mName          = copy.Name;
     mContextFrame  = (IGuiFrame)copy.ContextFrame.Clone();
     mProgressFrame = (IGuiFrame)copy.ProgressFrame.Clone();
 }