示例#1
0
 /// <summary>
 /// destroys all children from this group
 /// </summary>
 /// <param name="andTheirChildren">includes the children of the children</param>
 /// <param name="hardDestroy">destroy the children but with more force</param>
 public void RemoveAllChildren(bool andTheirChildren = false, bool hardDestroy = false)
 {
     for (int i = Elements.Count - 1; i >= 0; i--)
     {
         UIElement elem = Elements[i];
         if (andTheirChildren)
         {
             try
             {
                 GroupElement group = (GroupElement)elem;
                 group.RemoveAllChildren(true, hardDestroy);
             }
             catch (InvalidCastException)
             {
                 //
             }
         }
         elem.Destroy(hardDestroy);
         Elements.RemoveAt(i);
     }
 }
示例#2
0
 /// <summary>
 /// creates a new ui manager
 /// </summary>
 /// <param name="game">the parent game to reference to</param>
 /// <param name="assetManager">the asset manager for the ui elements to reference to</param>
 public UIManager(Game game, AssetManager assetManager)
 {
     Game                = game;
     SortMode            = SpriteSortMode.FrontToBack;
     Assets              = assetManager;
     Elements            = new Dictionary <string, UIElement>();
     CurrentInput        = null;
     ScrollMultiplier    = -16;
     lastPressedKeys     = new Keys[0];
     lastScrollAmount    = 0;
     KeyToCharMap        = new Dictionary <Keys, char>();
     KeyToShiftedCharMap = new Dictionary <Keys, char>();
     InputShifted        = false;
     TopUINode           = new GroupElement(this, new Vector2(0, 0), new Vector2(Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), 0f, "top");
     AddKeyToChar(Keys.D0, '0', ')'); //lmk if there is a better way to go about adding these characters
     AddKeyToChar(Keys.D1, '1', '!');
     AddKeyToChar(Keys.D2, '2', '@');
     AddKeyToChar(Keys.D3, '3', '#');
     AddKeyToChar(Keys.D4, '4', '$');
     AddKeyToChar(Keys.D5, '5', '%');
     AddKeyToChar(Keys.D6, '6', '^');
     AddKeyToChar(Keys.D7, '7', '&');
     AddKeyToChar(Keys.D8, '8', '*');
     AddKeyToChar(Keys.D9, '9', '(');
     AddKeyToChar(Keys.OemPipe, '\\', '|');
     AddKeyToChar(Keys.OemQuestion, '/', '?');
     AddKeyToChar(Keys.OemMinus, '-', '_');
     AddKeyToChar(Keys.OemPlus, '=', '+');
     AddKeyToChar(Keys.OemComma, ',', '<');
     AddKeyToChar(Keys.OemPeriod, '.', '>');
     AddKeyToChar(Keys.OemQuotes, '\'', '"');
     AddKeyToChar(Keys.OemSemicolon, ';', ':');
     AddKeyToChar(Keys.OemOpenBrackets, '[', '{');
     AddKeyToChar(Keys.OemCloseBrackets, ']', '}');
     AddKeyToChar(Keys.OemTilde, '`', '~');
     AddKeyToChar(Keys.A, 'a', 'A');
     AddKeyToChar(Keys.B, 'b', 'B');
     AddKeyToChar(Keys.C, 'c', 'C');
     AddKeyToChar(Keys.D, 'd', 'D');
     AddKeyToChar(Keys.E, 'e', 'E');
     AddKeyToChar(Keys.F, 'f', 'F');
     AddKeyToChar(Keys.G, 'g', 'G');
     AddKeyToChar(Keys.H, 'h', 'H');
     AddKeyToChar(Keys.I, 'i', 'I');
     AddKeyToChar(Keys.J, 'j', 'J');
     AddKeyToChar(Keys.K, 'k', 'K');
     AddKeyToChar(Keys.L, 'l', 'L');
     AddKeyToChar(Keys.M, 'm', 'M');
     AddKeyToChar(Keys.N, 'n', 'N');
     AddKeyToChar(Keys.O, 'o', 'O');
     AddKeyToChar(Keys.P, 'p', 'P');
     AddKeyToChar(Keys.Q, 'q', 'Q');
     AddKeyToChar(Keys.R, 'r', 'R');
     AddKeyToChar(Keys.S, 's', 'S');
     AddKeyToChar(Keys.T, 't', 'T');
     AddKeyToChar(Keys.U, 'u', 'U');
     AddKeyToChar(Keys.V, 'v', 'V');
     AddKeyToChar(Keys.W, 'w', 'W');
     AddKeyToChar(Keys.X, 'x', 'X');
     AddKeyToChar(Keys.Y, 'y', 'Y');
     AddKeyToChar(Keys.Z, 'z', 'Z');
 }