/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { this.minimised = false; base.Initialize(); GUIButton btn = new GUIButton(Game, new Vector2(10, 10), "rewind", "<<"); btn.Initialize(); AddComponent(btn); btn = new GUIButton(Game, new Vector2(40, 10), "pause", "| |"); btn.Initialize(); AddComponent(btn); btn = new GUIButton(Game, new Vector2(65, 10), "play", " > "); btn.Initialize(); AddComponent(btn); GUICheckbox cb = new GUICheckbox(Game, new Vector2(10, 50), "debugdraw", "Debug Draw"); cb.Initialize(); AddComponent(cb); GUILabel lbl = new GUILabel(Game, new Vector2(10, 80), "status", "Status: Paused"); lbl.Initialize(); AddComponent(lbl); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { input = (InputHandler)Game.Services.GetService(typeof(IInputHandler)); console = (DeveloperConsole)Game.Services.GetService(typeof(IDeveloperConsole)); console.MessageHandler += new DeveloperConsole.DeveloperConsoleMessageHandler(ConsoleMessageHandler); camera = (Camera)Game.Services.GetService(typeof(ICamera)); guimanager = (GUIManager)Game.Services.GetService(typeof(IGUIManager)); // Define the World Simulator = new PhysicsSimulator(new Vector2(0, 8)); debugView = new PhysicsSimulatorView(Simulator); base.Initialize(); controlPanel = new GUIPhysicsControls(Game); controlPanel.Initialize(); guimanager.AddComponent(controlPanel); GUIButton btn = (GUIButton)controlPanel.getComponent("pause"); btn.OnMouseClick += new GUIButton.MouseClickHandler(PauseButtonMouseClick); btn = (GUIButton)controlPanel.getComponent("play"); btn.OnMouseClick += new GUIButton.MouseClickHandler(PlayButtonMouseClick); statusLabel = (GUILabel)controlPanel.getComponent("status"); //start off paused. Paused = true; GUICheckbox cb = (GUICheckbox)controlPanel.getComponent("debugdraw"); cb.CheckStateChange += new GUICheckbox.CheckChangeEventHandler(DebugDrawCheckStateChanged); cb.Checked = debugDraw; }
/// <summary> /// Adds a new checkbox to the GUI /// </summary> /// <param name="location">Screen location of the top left corner</param> /// <param name="name">Name of the component</param> /// <param name="caption">Caption to be displayed on the checkbox</param> internal GUICheckbox AddCheckbox(Vector2 location, string name, string caption) { GUICheckbox c = new GUICheckbox(Game, location, name, caption); c.Initialize(); components.Add(c); return(c); }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { base.Initialize(); GUILabel label = new GUILabel(Game, new Vector2(10, 10), "lblOpen", "Filename:"); label.Initialize(); AddComponent(label); //GUIEditBox edit = new GUIEditBox(Game, new Vector2(100, 10), "edtOpen", 300, ""); //edit.Initialize(); //AddComponent(edit); GUIButton ok = new GUIButton(Game, new Vector2(480, 50), "okbutton", "Ok"); ok.Initialize(); ok.OnMouseClick += new GUIButton.MouseClickHandler(OkMouseClick); AddComponent(ok); GUIButton cancel = new GUIButton(Game, new Vector2(520, 50), "cancelbutton", "Cancel"); cancel.Initialize(); cancel.OnMouseClick += new GUIButton.MouseClickHandler(CancelMouseClick); AddComponent(cancel); GUICheckbox isphys = new GUICheckbox(Game, new Vector2(100, 50), "isphys", "Generate Collision Mesh"); isphys.Initialize(); AddComponent(isphys); GUILabel bouncylbl = new GUILabel(Game, new Vector2(10, 90), "lblBounce", "Bounciness"); bouncylbl.Initialize(); AddComponent(bouncylbl); GUIEditBox bouncy = new GUIEditBox(Game, new Vector2(100, 90), "edtBouncy", 50, "500"); bouncy.Initialize(); AddComponent(bouncy); GUILabel frictionlbl = new GUILabel(Game, new Vector2(10, 120), "lblFriction", "Friction"); frictionlbl.Initialize(); AddComponent(frictionlbl); GUIEditBox friction = new GUIEditBox(Game, new Vector2(100, 120), "edtFriction", 50, "500"); friction.Initialize(); AddComponent(friction); // Add List Box List <GUIListBoxItem> guiListItems = new List <GUIListBoxItem>(); string[] filenames = Directory.GetFiles("Content\\LevelArt"); for (int i = 0; i < filenames.Length; i++) { string shortName = (string)filenames[i].Substring(17); guiListItems.Add(new GUIListBoxItem(Game, filenames[i], shortName)); } fileList = new GUIListBox(Game, new Vector2(100, 10), "list box", guiListItems); fileList.Initialize(); AddComponent(fileList); }