public override void Initialize(bool addToManagers) { base.Initialize(addToManagers); screenTitle = new Text(); screenTitle.DisplayText = "Options"; Vector2 titlePosition = PositionHelper.percentToCoordSprite(0.0f, 50.0f); screenTitle.Y = titlePosition.Y; screenTitle.HorizontalAlignment = HorizontalAlignment.Center; TextManager.AddText(screenTitle); GuiManager.IsUIEnabled = true; listBox = GuiManager.AddListBox(); listBox.ScaleX = 20; listBox.ScaleY = 12; // The first argument to AddItem is the text to show for the item // The second argument is the object that the Item will store. // The second argment is optional, but we'll use it to reference // the background color that we want to use. listBox.AddItem("Red", Color.Red); listBox.AddItem("Blue", Color.Blue); listBox.AddItem("Yellow", Color.Yellow); for (int i = 0; i < 200; i++) listBox.AddItem("BLAAA" + i); if(addToManagers) AddToManagers(); }
public void AddText(string text) { mLastTextAdded = text; // the text needs to be broken up into lines text = TextManager.InsertNewLines(text, GuiManager.TextSpacing, mListBox.TextScaleX * 2, TextManager.DefaultFont); string[] lines = text.Split('\n'); foreach (string s in lines) { mListBox.AddItem(s); } mListBox.HighlightItem(mListBox.Items[mListBox.mItems.Count - 1], false); mListBox.HighlightItem((CollapseItem)null, false); if (TextAdded != null) { TextAdded(this); } }
public override void Initialize(bool addToManagers) { base.Initialize(addToManagers); screenTitle = new Text(); screenTitle.DisplayText = "Song Selection"; Vector2 titlePosition = PositionHelper.percentToCoordSprite(0.0f, 80.0f); screenTitle.Y = titlePosition.Y; screenTitle.HorizontalAlignment = HorizontalAlignment.Center; TextManager.AddText(screenTitle); GuiManager.IsUIEnabled = true; listBox = GuiManager.AddListBox(); listBox.ScaleX = 10; listBox.ScaleY = 20; for (int i = 0; i < 200; i++) listBox.AddItem("Song " + i); if(addToManagers) AddToManagers(); }
void OnClick(Window callingWindow) { if (MenuItems.Count != 0) { #region Create the new ListBox and store it in mChildPerishableListBox mChildPerishableListBox = GuiManager.AddPerishableListBox(); mChildPerishableListBox.SortingStyle = ListBoxBase.Sorting.None; mChildPerishableListBox.ScaleX = 5; mChildPerishableListBox.ScaleY = 5; mChildPerishableListBox.ScrollBarVisible = false; #endregion #region Add the MenuItems to the new ListBox foreach (MenuItem menuItem in MenuItems) { CollapseItem item = mChildPerishableListBox.AddItem(menuItem.Text, menuItem); menuItem.mParentListBox = this.mChildPerishableListBox; item.Enabled = menuItem.Enabled; } #endregion #region Scale the new ListBox for the contents mChildPerishableListBox.SetScaleToContents(3); float maximumScale = GuiManager.YEdge - (MenuStrip.MenuStripHeight/2.0f); if (mChildPerishableListBox.ScaleY > maximumScale) { mChildPerishableListBox.ScrollBarVisible = true; mChildPerishableListBox.ScaleY = maximumScale; } #endregion if (this.mParentListBox != null) { GuiManager.PersistPerishableThroughNextClick(mChildPerishableListBox); } mChildPerishableListBox.Click += ListBoxClick; if (this.mParentListBox != null) { mChildPerishableListBox.X = mParentListBox.ScaleX + mParentListBox.WorldUnitX + GuiManager.UnmodifiedXEdge + mChildPerishableListBox.ScaleX; int indexofHighlighted = mParentListBox.GetFirstHighlightedIndex(); float extraDistanceDown = mParentListBox.DistanceBetweenLines * indexofHighlighted; mChildPerishableListBox.Y = -(mParentListBox.WorldUnitY - GuiManager.UnmodifiedYEdge) + mChildPerishableListBox.ScaleY - mParentListBox.ScaleY + mTextScale + extraDistanceDown - mChildPerishableListBox.FirstItemDistanceFromTop/2.0f ; } else { mChildPerishableListBox.X = X + mChildPerishableListBox.ScaleX; mChildPerishableListBox.Y = Y + mChildPerishableListBox.ScaleY + mTextScale; } mChildPerishableListBox.HighlightOnRollOver = true; } }
void OnClick(Window callingWindow) { if (MenuItems.Count != 0) { #region Create the new ListBox and store it in mChildPerishableListBox mChildPerishableListBox = GuiManager.AddPerishableListBox(); mChildPerishableListBox.SortingStyle = ListBoxBase.Sorting.None; mChildPerishableListBox.ScaleX = 5; mChildPerishableListBox.ScaleY = 5; mChildPerishableListBox.ScrollBarVisible = false; #endregion #region Add the MenuItems to the new ListBox foreach (MenuItem menuItem in MenuItems) { CollapseItem item = mChildPerishableListBox.AddItem(menuItem.Text, menuItem); menuItem.mParentListBox = this.mChildPerishableListBox; item.Enabled = menuItem.Enabled; } #endregion #region Scale the new ListBox for the contents mChildPerishableListBox.SetScaleToContents(3); float maximumScale = GuiManager.YEdge - (MenuStrip.MenuStripHeight / 2.0f); if (mChildPerishableListBox.ScaleY > maximumScale) { mChildPerishableListBox.ScrollBarVisible = true; mChildPerishableListBox.ScaleY = maximumScale; } #endregion if (this.mParentListBox != null) { GuiManager.PersistPerishableThroughNextClick(mChildPerishableListBox); } mChildPerishableListBox.Click += ListBoxClick; if (this.mParentListBox != null) { mChildPerishableListBox.X = mParentListBox.ScaleX + mParentListBox.WorldUnitX + GuiManager.UnmodifiedXEdge + mChildPerishableListBox.ScaleX; int indexofHighlighted = mParentListBox.GetFirstHighlightedIndex(); float extraDistanceDown = mParentListBox.DistanceBetweenLines * indexofHighlighted; mChildPerishableListBox.Y = -(mParentListBox.WorldUnitY - GuiManager.UnmodifiedYEdge) + mChildPerishableListBox.ScaleY - mParentListBox.ScaleY + mTextScale + extraDistanceDown - mChildPerishableListBox.FirstItemDistanceFromTop / 2.0f; } else { mChildPerishableListBox.X = X + mChildPerishableListBox.ScaleX; mChildPerishableListBox.Y = Y + mChildPerishableListBox.ScaleY + mTextScale; } mChildPerishableListBox.HighlightOnRollOver = true; } }
// public ComboBox(SpriteFrame baseSF, SpriteFrame textBoxSF, // string buttonTexture, // Cursor cursor, Camera camera, string contentManagerName) // : base(baseSF, cursor) // { //// baseSF.colorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Add; //// baseSF.tintBlue = 255; // mSelectionDisplay = base.AddTextBox(textBoxSF, "redball.bmp", camera, contentManagerName); // mSelectionDisplay.TakingInput = false; // mSelectionDisplay.fixedLength = false; // mSelectionDisplay.SpriteFrame.Z = baseSF.Z - .001f; // mSelectionDisplay.SpriteFrame.ScaleY = baseSF.ScaleY - .2f; // mStretchListBoxToContentWidth = false; // mDropDownButton = base.AddButton(buttonTexture, GuiManager.InternalGuiContentManagerName); // mDropDownButton.Click += new GuiMessage(OnDropDownButtonClick); // mDropDownButton.SpriteFrame.Z = baseSF.Z - .001f; // mDropDownButton.SpriteFrame.ScaleX = mDropDownButton.SpriteFrame.ScaleY = baseSF.ScaleY - .2f; // mName = baseSF.Name; // mListBox = this.AddListBox(baseSF.Clone(), null, null, null, null, null); // mListBox.SpriteFrame.Name = baseSF.Name + "ListBoxSpriteFrame"; // mListBox.SpriteFrame.UpdateInternalSpriteNames(); // SpriteManager.AddSpriteFrame(mListBox.SpriteFrame); // mListBox.SpriteFrame.Z = baseSF.Z - .1f; // this.RemoveWindow(mListBox); // just a quick way to have a list box initialized for us, but not keep it on this window // mListBox.SetPositionTL(ScaleX, ScaleY + 2); // mListBox.Visible = false; // mListBox.ScrollBarVisible = false; // mListBox.Click += new GuiMessage(OnListBoxClicked); // // I have no clue why this is in here. //// listBox.sf.xVelocity = 1; // SelectedObject = null; // this.ScaleX = SpriteFrame.ScaleX; // } // public ComboBox(SpriteFrame baseSF, SpriteFrame textBoxSF, SpriteFrame buttonSpriteFrame, // Cursor cursor, Camera camera) // : base(baseSF, cursor) // { // // baseSF.colorOperation = Microsoft.DirectX.Direct3D.TextureOperation.Add; // // baseSF.tintBlue = 255; // mSelectionDisplay = base.AddTextBox(textBoxSF, "redball.bmp", camera, GuiManager.InternalGuiContentManagerName); // mSelectionDisplay.TakingInput = false; // mSelectionDisplay.fixedLength = false; // mSelectionDisplay.SpriteFrame.Z = baseSF.Z - .001f; // mSelectionDisplay.SpriteFrame.ScaleY = baseSF.ScaleY - .2f; // mStretchListBoxToContentWidth = false; // mDropDownButton = base.AddButton(buttonSpriteFrame); // mDropDownButton.Click += new GuiMessage(OnDropDownButtonClick); // mDropDownButton.SpriteFrame.Z = baseSF.Z - .001f; //// dropDownButton.sf.ScaleX = dropDownButton.sf.ScaleY = baseSF.ScaleY - .2f; // mName = baseSF.Name; // mListBox = this.AddListBox(baseSF.Clone(), null, null, null, null, null); // mListBox.SpriteFrame.Name = baseSF.Name + "ListBoxSpriteFrame"; // mListBox.SpriteFrame.UpdateInternalSpriteNames(); // SpriteManager.AddSpriteFrame(mListBox.SpriteFrame); // mListBox.SpriteFrame.Z = baseSF.Z - .1f; // this.RemoveWindow(mListBox); // just a quick way to have a list box initialized for us, but not keep it on this window // mListBox.SetPositionTL(ScaleX, ScaleY + 2); // mListBox.Visible = false; // mListBox.ScrollBarVisible = false; // mListBox.Click += new GuiMessage(OnListBoxClicked); // // I have no clue why this was here //// listBox.sf.xVelocity = 1; // SelectedObject = null; // this.ScaleX = SpriteFrame.ScaleX; // } #endregion #region Public Methods public void AddItem(string stringToAdd) { mListBox.AddItem(stringToAdd); }
public CollapseListBox(Cursor cursor) : base(cursor) { mListBox = new ListBox(mCursor); mListBox.AddItem("Expand All"); mListBox.AddItem("Collapse All"); mListBox.SetScaleToContents(0); mListBox.HighlightOnRollOver = true; mListBox.ScrollBarVisible = false; mListBox.Click += PopupListBoxClick; SecondaryClick += OnRightClick; }