public NoticeDiaglogBox(string noticeMessage, string buttonText) { GuiFrame noticeFrame = new GuiFrame("NoticeDialogFrame", new FillParent()); Label noticeLabel = new Label("NoticeDialogLabel", new FixedSize(180, 50), null, noticeMessage); Button okButton = new Button("OkButton", new FixedSize(69, 30), null, buttonText); okButton.AddOnPressedAction(delegate(){ okButton.GetTopLevel().Close(); }); noticeFrame.AddChildWidget(noticeLabel, new FixedPosition(5, 5)); noticeFrame.AddChildWidget(okButton, new FixedPosition(62, 60)); mWindow = new Window("NoticeDiaglogBox", new FixedSize(200, 100), GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>(), noticeFrame); }
public override object Clone() { GuiFrame result = new GuiFrame ( this.Name, this.GuiSize, this.Style ); foreach (KeyValuePair <IWidget, IGuiPosition> widget in mWidgets) { result.AddChildWidget((IWidget)widget.Key.Clone(), widget.Value); } return(result); }
public InventoryGuiController(IGuiManager guiManager) : base(guiManager, mResourcePath) { mInventoryWindow = (Window)this.MainGui; mInventoryWindow.OnShowing(OnShowingCallback); mItemDisplayFrame = mInventoryWindow.SelectSingleElement <GuiFrame>("MainFrame/ItemDisplayFrame"); mStoreSelector = mInventoryWindow.SelectSingleElement <GuiFrame>("MainFrame/StoreSelector"); mPlayerInventoryFrame = mInventoryWindow.SelectSingleElement <GuiFrame>("MainFrame/PlayerInventoryFrame"); mCategorySideBar = mInventoryWindow.SelectSingleElement <GuiFrame>("MainFrame/CategorySideBarFrame"); foreach (ITopLevel topLevel in AllGuis) { if (topLevel.Name == "StoreOverlayWindow") { mStoreOverlayWindow = (Window)topLevel; } if (topLevel.Name == "InventoryOverlayWindow") { mInventoryOverlayWindow = (Window)topLevel; } if (topLevel.Name == "PurchaseModalWindow") { mPurchaseModalWindow = (Window)topLevel; Label modalLabel = mPurchaseModalWindow.SelectSingleElement <Label>("MainFrame/PurchaseModalFrame/PurchasingLabel"); modalLabel.Text = Translation.PURCHASE_COMPLETING_TRANSACTION; } } SetUpSideBar(); //Hide EEERRRRRRYTHANG mInventoryWindow.Showing = false; mItemDisplayFrame.Showing = false; mStoreSelector.Showing = false; mPlayerInventoryFrame.Showing = false; mCategorySideBar.Showing = false; mPurchaseModalWindow.Showing = false; ConstructStateMachine(); }
public TabView BuildTabView(XmlNode tabViewNode) { string name = BuildName(tabViewNode); XmlNode buttonsFrameNode = tabViewNode.SelectSingleNode("ButtonsFrame"); if (buttonsFrameNode == null) { throw new GuiConstructionException("Unable to find the ButtonsFrame node that should be a child of TabView (" + name + ")"); } GuiFrame buttonFrame = BuildFrame(buttonsFrameNode); IGuiPosition buttonFramePosition = BuildPosition(buttonsFrameNode); XmlNode contextFrameNode = tabViewNode.SelectSingleNode("ContextFrame"); if (contextFrameNode == null) { throw new GuiConstructionException("Unable to find the ContextFrame node that should be a child of TabView (" + name + ")"); } GuiFrame contextFrame = BuildFrame(contextFrameNode); IGuiPosition contextFramePosition = BuildPosition(contextFrameNode); IGuiSize size = BuildSize(tabViewNode); bool allowEmpty = GetBoolAttributeNothrow(tabViewNode, "allowEmpty", false); return(new TabView ( name, size, buttonFrame, buttonFramePosition, contextFrame, contextFramePosition, allowEmpty )); }
public TabView(string name, IGuiSize size, GuiFrame buttonFrame, IGuiPosition buttonFramePosition, GuiFrame contextFrame, IGuiPosition contextFramePosition, bool allowEmpty) : base(name, size, null) { mAllowEmpty = allowEmpty; if (buttonFrame == null) { throw new ArgumentNullException("buttonFrame"); } mButtonFrame = buttonFrame; mButtonFrame.Parent = this; if (buttonFramePosition == null) { throw new ArgumentNullException("buttonFramePosition"); } mButtonFramePosition = buttonFramePosition; if (contextFrame == null) { throw new ArgumentNullException("contextFrame"); } mContextFrame = contextFrame; mContextFrame.Parent = this; if (contextFramePosition == null) { throw new ArgumentNullException("contextFramePosition"); } mContextFramePosition = contextFramePosition; // Get all the elements of type TabButton in the buttonsFrame and store in mTabs mTabs = new List <TabButton>(); foreach (IGuiElement buttonFrameElement in buttonFrame.SelectElements <IGuiElement>("**/*")) { if (buttonFrameElement is TabButton) { TabButton tabButton = (TabButton)buttonFrameElement; mTabs.Add(tabButton); tabButton.RegisterWithTabView(this); } } if (mTabs.Count < 1) { throw new ArgumentException("Cannot create a TabView without any specified tabs.", "tabs"); } if (!mAllowEmpty) { ActivateTab(mTabs[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); }