private static void Init() { using (var dbgFont = new Util.RandTempContentFile <SpriteFont>("Prism.Resources.FakeContent.DebugFont.xnb")) { DebugFont = dbgFont.Load(); } Node = new DebugMenuNode("Prism Debug Menu"); NavDirInit = new Dictionary <Ctrl, bool>(); NavDirTimer = new Dictionary <Ctrl, float>(); for (byte i = (byte)Ctrl.Up; i <= (byte)Ctrl.Right; i++) { NavDirInit[(Ctrl)i] = true; NavDirTimer[(Ctrl)i] = 0; } }
/// <summary> /// Call before the debug update hook so they can get the input from this /// </summary> internal static void Update(GameTime gt) { if (!Main.gameMenu && (GetKey(Keys.LeftShift) || GetKey(Keys.RightShift)) && (GetKey(Keys.LeftAlt) || GetKey(Keys.RightAlt)) && GetKey(Keys.H, KeyState.Down)) { if (!IsOpen) { IsOpen = true; Main.PlaySound(10); } else { IsOpen = false; Main.PlaySound(11); } } if (!HasBeenOpened) { if (IsOpen) { Init(); Main.NewText("Debug menu initialized.", 0, 255, 255, true); Main.NewText("Press I/K to move the selection up/down.", 0, 255, 255, true); Main.NewText("Press J/L to adjust the selected entry.", 0, 255, 255, true); Main.NewText("Press U/O to expand/collapse nodes.", 0, 255, 255, true); Main.NewText("Hold Shift/Alt while moving the selection or adjusting the selected entry to multiply the action by 10x/100x", 0, 255, 255, true); HasBeenOpened = true; } else { return; } } UpdateNav(gt); if (IsOpen) { if ((Nav & Ctrl.Up) == Ctrl.Up) { DebugSelection -= DbgModMult; Main.PlaySound(12); } if ((Nav & Ctrl.Down) == Ctrl.Down) { DebugSelection += DbgModMult; Main.PlaySound(12); } if ((Nav & Ctrl.Enter) == Ctrl.Enter && SelectedNode.Count > 0) { if (!SelectedNode.IsExpanded) { SelectedNode.Expand(); Main.PlaySound(10); } else { foreach (var c in SelectedNode) { DebugSelection = c.Value.VisibleIndex; Main.PlaySound(12); break; } } } if ((Nav & Ctrl.Back) == Ctrl.Back) { if (SelectedNode.Count > 0 && SelectedNode.IsExpanded) { SelectedNode.Collapse(); Main.PlaySound(11); } else if (SelectedNode.Parent != null) { SelectedNode = SelectedNode.Parent; DebugSelection = SelectedNode.VisibleIndex; Main.PlaySound(11); } } DebugSelection = (int)MathHelper.Clamp(DebugSelection, 0, Node.RecursiveChildVisibleCount); } prevKeyState = Main.keyState; }