private void SetupLoadedGuiWindowList() { mWindowListFrame.ClearChildWidgets(); float nextButtonPosition = 0.0f; foreach (ITopLevel topLevel in mLoadedGuis) { Button windowListing = (Button)mWindowListingPrototype.Clone(); windowListing.Text = topLevel.Name; mWindowListFrame.AddChildWidget(windowListing, new FixedPosition(4.0f, nextButtonPosition)); nextButtonPosition += windowListing.ExternalSize.y + 2.0f; ITopLevel closureTopLevel = topLevel; windowListing.AddOnPressedAction(delegate() { closureTopLevel.Showing = !closureTopLevel.Showing; if (!closureTopLevel.Showing && !mHiddenWindows.Contains(closureTopLevel.Name)) { mHiddenWindows.Add(closureTopLevel.Name); } else if (closureTopLevel.Showing && mHiddenWindows.Contains(closureTopLevel.Name)) { mHiddenWindows.Remove(closureTopLevel.Name); } }); } }
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; } } }
/// <summary> /// Call this anytime the clothing in mActiveClothes changes to update the GUI /// </summary> private void LayoutStacks() { mMainFrame.ClearChildWidgets(); int tallestStack = 0; foreach (List <Pair <ClothingItem, PushButton> > stack in mActiveClothes) { if (stack.Count > tallestStack) { tallestStack = stack.Count; } } if (tallestStack >= MAX_STACK_DISPLAY) { tallestStack = MAX_STACK_DISPLAY; } float buttonWidth = mClothingButtonPrototype.ExternalSize.x; // This ordering is a little awkward because the items need to be added // to the frame in a particular order to keep from having z ordering issues for (int i = tallestStack - 1; i >= 0; --i) { Vector2 basePosition = new Vector2(0.0f, 0.0f); foreach (List <Pair <ClothingItem, PushButton> > stack in mActiveClothes) { if (stack.Count > i) { Vector2 buttonPosition = STACK_OFFSET * (float)i; buttonPosition += basePosition; IWidget clothingWidget = stack[i].Second; if (i == 0) { clothingWidget = new Image(clothingWidget.Name + "(Inactive)", clothingWidget.Style, stack[i].Second.Image); } mMainFrame.AddChildWidget(stack[i].Second, new FixedPosition(buttonPosition)); } basePosition.x += buttonWidth; } } }
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; }
private void LayoutGuiListings() { float currentPosition = 0.0f; List <Regex> filters = new List <Regex>(); foreach (string filterWord in mLoadGuiFilterText.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) { filters.Add(new Regex(filterWord, RegexOptions.IgnoreCase | RegexOptions.Compiled)); } mGuiListFrame.ClearChildWidgets(); foreach (FileInfo guiFileInfo in mAllGuisOnDisk) { bool match = true; foreach (Regex filter in filters) { if (!filter.IsMatch(guiFileInfo.Name)) { match = false; break; } } if (match) { Button guiListingButton = (Button)mLoadGuiButtonPrototype.Clone(); guiListingButton.Text = guiFileInfo.Name; mGuiListFrame.AddChildWidget(guiListingButton, new FixedPosition(4.0f, currentPosition)); currentPosition += guiListingButton.ExternalSize.y; string path = guiFileInfo.FullName; guiListingButton.AddOnPressedAction(delegate() { ClearUserGuis(); LoadUserGui(path); SetLastLoadedGui(path); mHiddenWindows.Clear(); mLoadGuiDialog.Showing = false; }); } } }
public void Report(ILogMessage message) { IGuiStyle logStyle = mLogLevelStyles[message.Level]; Textbox newLog = new Textbox ( "LoggedMessage", new ExpandText(mMainFrameWidth), logStyle, message.Message, false, false ); mLogFrame.AddChildWidget(newLog, new FixedPosition(0.0f, mNextLogPosition)); mNextLogPosition += newLog.Size.y + logStyle.ExternalMargins.GetSizeDifference().y; /*if( message.Level == LogLevel.Error ) * { * mConsoleWindow.Showing = true; * ((Window)mConsoleWindow).InFront = true; * }*/ }
/// <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()); } } }
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); }
/// <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); }