private void InitializeComponent() { EnableDragging = false; _dialogText = new LabelControl(); _dialogText.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 15.0f), new UniScalar(1.0f, -30.0f), new UniScalar(1.0f, -85.0f) ); Children.Add(_dialogText); _optionsList = new ListControl(); _optionsList.Bounds = new UniRectangle(10, 10, new UniScalar(1, -20), 150); _optionsList.SelectionMode = ListSelectionMode.Single; _nextButton = new ButtonControl(); _nextButton.Text = "Continue"; _nextButton.Bounds = new UniRectangle( new UniScalar(1.0f, -110), new UniScalar(1.0f, -55f), new UniScalar(100), new UniScalar(45) ); Children.Add(_nextButton); Bounds = new UniRectangle( new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, -225.0f), new UniScalar(1.0f, 0.0f), new UniScalar(0.0f, 225.0f) ); }
private void InitializeComponent() { EnableDragging = false; _return = new ButtonControl(); _mainMenu = new ButtonControl(); _exit = new ButtonControl(); // new game _return.Text = "Return"; _return.Bounds = new UniRectangle(15, 15, 150, 45); // continue _mainMenu.Text = "Main Menu"; _mainMenu.Bounds = new UniRectangle(15, 65, 150, 45); // load game _exit.Text = "Exit"; _exit.Bounds = new UniRectangle(15, 115, 150, 45); Children.Add(_return); Children.Add(_mainMenu); Children.Add(_exit); Bounds = new UniRectangle(10, 10, 180, 175); }
public LoadGameScene(Game game) : base(game) { // list of games var saveGameList = Data.SaveGame.FetchAll((SRPGGame)game); for(var i = 0; i < saveGameList.Count; i++) { var saveGame = saveGameList[i]; var dlg = new SavedGameDialog(saveGame); dlg.Bounds = new UniRectangle( new UniScalar(0), new UniScalar(110 * i), new UniScalar(1.0f, -160), new UniScalar(100) ); var fileNumber = i; dlg.OnSelect += () => ((SRPGGame) Game).LoadGame(fileNumber); Gui.Screen.Desktop.Children.Add(dlg); } // cancel button var button = new ButtonControl(); button.Bounds = new UniRectangle( new UniScalar(1.0f, -150), new UniScalar(0), new UniScalar(150), new UniScalar(45) ); button.Text = "Cancel"; button.Pressed += (s, a) => Game.PopScene(); Gui.Screen.Desktop.Children.Add(button); Gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml"); }
private void InitializeComponent() { // file number _number = new LabelControl(); _number.Bounds = new UniRectangle(10, 10, 50, 35); Children.Add(_number); // name _name = new LabelControl(); _name.Bounds = new UniRectangle(60, 10, 300, 35); Children.Add(_name); // elapsed game time _gameTime = new LabelControl(); _gameTime.Bounds = new UniRectangle(10, 55, 300, 35); Children.Add(_gameTime); // load button _loadButton = new ButtonControl(); _loadButton.Text = "Overwrite"; _loadButton.Bounds = new UniRectangle( new UniScalar(1.0f, -160), new UniScalar(10), new UniScalar(150), new UniScalar(35) ); Children.Add(_loadButton); }
private void InitializeComponent() { EnableDragging = false; Bounds = new UniRectangle( new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f), new UniScalar(1.0f, 0.0f), new UniScalar(0.0f, 95.0f) ); _statusButton = new ButtonControl(); _statusButton.Text = "Status"; _statusButton.Bounds = new UniRectangle( new UniScalar(0.025f, 0.0f), new UniScalar(0.0f, 15.0f), new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f) ); Children.Add(_statusButton); _inventoryButton = new ButtonControl(); _inventoryButton.Text = "Inventory"; _inventoryButton.Bounds = new UniRectangle( new UniScalar(0.35f, 0.0f), new UniScalar(0.0f, 15.0f), new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f) ); Children.Add(_inventoryButton); _settingsButton = new ButtonControl(); _settingsButton.Text = "Settings"; _settingsButton.Bounds = new UniRectangle( new UniScalar(0.675f, 0.0f), new UniScalar(0.0f, 15.0f), new UniScalar(0.30f, 0.0f), new UniScalar(0.0f, 65.0f) ); Children.Add(_settingsButton); }
/// <summary> /// Required method for user interface initialization - /// do modify the contents of this method with the code editor. /// </summary> private void InitializeComponent() { _helloWorldLabel = new LabelControl(); _okButton = new ButtonControl(); _cancelButton = new ButtonControl(); // // helloWorldLabel // _helloWorldLabel.Text = "Hello World! This is a label."; _helloWorldLabel.Bounds = new UniRectangle(10.0f, 15.0f, 110.0f, 30.0f); // // okButton // _okButton.Bounds = new UniRectangle( new UniScalar(1.0f, -180.0f), new UniScalar(1.0f, -40.0f), 80, 24 ); // // cancelButton // _cancelButton.Bounds = new UniRectangle( new UniScalar(1.0f, -90.0f), new UniScalar(1.0f, -40.0f), 80, 24 ); // // DemoDialog // Bounds = new UniRectangle(0.0f, 0.0f, 250.0f, 125.0f); Children.Add(_helloWorldLabel); Children.Add(_okButton); Children.Add(_cancelButton); }
public DialogBox(String title, String texto) { this.nameEntryLabel = new LabelControl(); this.okButton = new ButtonControl(); // // nameEntryLabel // this.nameEntryLabel.Text = texto; this.nameEntryLabel.Bounds = new UniRectangle(10.0f, 30.0f, 110.0f, 24.0f); // // okButton // this.okButton.Bounds = new UniRectangle(10.0f, 50.0f, 50.0f, 24.0f); this.okButton.Text = "OK"; this.okButton.Pressed += new EventHandler(okClicked); // // DialogBox // this.Bounds = new UniRectangle(200.0f, 200.0f, .0f, 384.0f); this.Title = title; Children.Add(this.nameEntryLabel); Children.Add(this.okButton); }
private void InitializeComponent() { _label = new LabelControl(); _yesButton = new ButtonControl(); _noButton = new ButtonControl(); Children.Add(_label); Children.Add(_yesButton); Children.Add(_noButton); // // label // _label.Bounds = new UniRectangle(25, 15, 500, 45); _label.Text = ""; // // yesButton // _yesButton.Bounds = new UniRectangle(new UniScalar(1.0F, -85), new UniScalar(1.0F, -45), 70, 30); _yesButton.Text = "Yes"; // // noButton // _noButton.Bounds = new UniRectangle(new UniScalar(1.0F, -160), new UniScalar(1.0F, -45), 70, 30); _noButton.Text = "No"; Bounds = new UniRectangle(0, 0, 550, 120); }
public void SetItems(IEnumerable<Item> items) { _itemList.Children.Clear(); for (var i = 0; i < items.Count(); i++) { var item = items.ElementAt(i); var button = new ButtonControl(); button.Bounds = new UniRectangle(10, 5 + 50*i, new UniScalar(1.0f, -20.0f), 40); button.Pressed += (s, a) => ItemSelected.Invoke(item); button.Text = item.Name; _itemList.Children.Add(button); } }
public SaveGameScene(Game game, string zone, string door) : base(game) { // GUI elements: // cancel button var cancelButton = new ButtonControl(); cancelButton.Text = "Cancel"; cancelButton.Pressed += (s, a) => Game.PopScene(); cancelButton.Bounds = new UniRectangle( new UniScalar(1.0f, -150), new UniScalar(0), new UniScalar(150), new UniScalar(45) ); Gui.Screen.Desktop.Children.Add(cancelButton); // new save var newSaveButton = new ButtonControl(); newSaveButton.Text = "New Save"; newSaveButton.Pressed += (s, a) => { ((SRPGGame) Game).NewSaveGame(zone, door); Game.PopScene(); }; newSaveButton.Bounds = new UniRectangle( new UniScalar(1.0f, -150), new UniScalar(55), new UniScalar(150), new UniScalar(45) ); Gui.Screen.Desktop.Children.Add(newSaveButton); // list of saves // list of games var saveGameList = Data.SaveGame.FetchAll((SRPGGame)game); for (var i = 0; i < saveGameList.Count; i++) { var saveGame = saveGameList[i]; var dlg = new SavedGameDialog(saveGame); dlg.Bounds = new UniRectangle( new UniScalar(0), new UniScalar(110 * i), new UniScalar(1.0f, -160), new UniScalar(100) ); var fileNumber = i; dlg.OnSelect += () => { ((SRPGGame) Game).SaveGame(fileNumber, zone, door); Game.PopScene(); }; Gui.Screen.Desktop.Children.Add(dlg); } Gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml"); }
public void TestButtonPressByMouse() { ButtonControl button = new ButtonControl(); button.Bounds = new UniRectangle(10, 10, 100, 100); IButtonSubscriber mockedSubscriber = mockSubscriber(button); Expect.Once.On(mockedSubscriber).Method("Pressed").WithAnyArguments(); // Move the mouse over the button and do a left-click button.ProcessMouseMove(0, 0, 50, 50); button.ProcessMousePress(MouseButtons.Left); button.ProcessMouseRelease(MouseButtons.Left); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
public void AddItem(string item) { var button = new ButtonControl { Bounds = new UniRectangle( new UniScalar(0), new UniScalar(_items*30), new UniScalar(1, 0), new UniScalar(30) ), Text = item }; button.Pressed += (s, a) => ItemSelected.Invoke(item); Children.Add(button); _items++; }
private void createDesktopControls(Screen mainScreen) { startButton = new ButtonControl(); creditButton = new ButtonControl(); instructionButton = new ButtonControl(); exitButton = new ButtonControl(); startButton.Text = "New Game"; // configure the start button startButton.Bounds = new UniRectangle( new UniScalar(-0.1f, 0.0f), new UniScalar(0.0f, 445.0f), 100, 32 ); startButton.Pressed += new EventHandler( delegate(object sender, EventArgs arguments){ _cont.start(); gui.Visible = false; }); mainScreen.Desktop.Children.Add(startButton); creditButton.Text = "Credits"; // configure the credit button creditButton.Bounds = new UniRectangle( new UniScalar(0.1f, 0.0f), new UniScalar(0.0f, 445.0f), 100, 32 ); creditButton.Pressed += new EventHandler( delegate(object sender, EventArgs arguments){ _cont.credits(); }); mainScreen.Desktop.Children.Add(creditButton); instructionButton.Text = "Instructions"; // configure the instruction button instructionButton.Bounds = new UniRectangle( new UniScalar(0.3f, 0.0f), new UniScalar(0.0f, 445.0f), 100, 32 ); instructionButton.Pressed += new EventHandler( delegate(object sender, EventArgs arguments){ _cont.instructions(); }); mainScreen.Desktop.Children.Add(instructionButton); exitButton.Text = "Exit"; // configure the exit button exitButton.Bounds = new UniRectangle( new UniScalar(0.5f, 0.0f), new UniScalar(0.0f, 445.0f), 100, 32 ); exitButton.Pressed += new EventHandler( delegate(object sender, EventArgs arguments) { Exit(); }); mainScreen.Desktop.Children.Add(exitButton); }
public void TestLastSecondAbortByMouse() { ButtonControl button = new ButtonControl(); button.Bounds = new UniRectangle(10, 10, 100, 100); Mock <IButtonSubscriber> mockedSubscriber = mockSubscriber(button); mockedSubscriber.Expects.No.Method(m => m.Pressed(null, null)).WithAnyArguments(); // Move the mouse over the button and do a left-click button.ProcessMouseMove(0, 0, 50, 50); button.ProcessMousePress(MouseButtons.Left); button.ProcessMouseMove(0, 0, 5, 5); // outside of the button button.ProcessMouseRelease(MouseButtons.Left); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
private void InitializeComponent() { // full screen label var label = new LabelControl(); label.Text = "Full Screen"; label.Bounds = new UniRectangle(10, 12, 100, 20); Children.Add(label); // full screen checkbox _fullScreenButton = new ButtonControl(); _fullScreenButton.Bounds = new UniRectangle(150, 10, 150, 30); _fullScreenButton.Text = "No"; Children.Add(_fullScreenButton); // resolution label label = new LabelControl(); label.Text = "Resolution"; label.Bounds = new UniRectangle(10, 52, 100, 20); Children.Add(label); // resolution selection _resolutionButton = new ButtonControl(); _resolutionButton.Bounds = new UniRectangle(150, 50, 150, 30); _resolutionButton.Text = "1024x768"; Children.Add(_resolutionButton); // save button _saveButton = new ButtonControl(); _saveButton.Bounds = new UniRectangle( new UniScalar(0.5f, 10), new UniScalar(1, -40), new UniScalar(0.5f, -20), new UniScalar(30) ); _saveButton.Text = "Save"; Children.Add(_saveButton); // cancel button _cancelButton = new ButtonControl(); _cancelButton.Bounds = new UniRectangle( new UniScalar(0, 10), new UniScalar(1, -40), new UniScalar(0.5f, -20), new UniScalar(30) ); _cancelButton.Text = "Cancel"; Children.Add(_cancelButton); }
public void TestFocusSwitchingWithUnfocusableControl() { Screen screen = new Screen(100.0f, 100.0f); Controls.Desktop.ButtonControl one = new Controls.Desktop.ButtonControl(); one.Bounds = new UniRectangle(40, 10, 20, 20); Controls.Control two = new Controls.Control(); two.Bounds = new UniRectangle(40, 40, 20, 20); Controls.Desktop.ButtonControl three = new Controls.Desktop.ButtonControl(); three.Bounds = new UniRectangle(40, 70, 20, 20); screen.Desktop.Children.Add(one); screen.Desktop.Children.Add(two); screen.Desktop.Children.Add(three); screen.FocusedControl = one; screen.InjectKeyPress(Keys.Down); screen.InjectKeyRelease(Keys.Down); Assert.AreSame(three, screen.FocusedControl); }
private void InitializeComponent() { Bounds = new Nuclex.UserInterface.UniRectangle(200, 200, 200, 400); _itemList = new ListControl(); _itemList.Bounds = new UniRectangle( new UniScalar(0, 10), new UniScalar(0, 10), new UniScalar(1, -20), new UniScalar(1, -65) ); Children.Add(_itemList); var cancelButton = new ButtonControl(); cancelButton.Text = "Cancel"; cancelButton.Pressed += (s, a) => { ItemCancelled.Invoke(); }; cancelButton.Bounds = new UniRectangle( new UniScalar(0, 10), new UniScalar(1, -45), new UniScalar(1, -20), new UniScalar(35) ); Children.Add(cancelButton); }
private void InitializeComponent() { EnableDragging = false; Bounds = new UniRectangle( new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 170.0f), new UniScalar(0.0f, 125.0f) ); _roundLabel = new LabelControl(); _roundNumber = new LabelControl(); _faction = new LabelControl(); _endTurn = new ButtonControl(); Children.Add(_roundLabel); Children.Add(_roundNumber); Children.Add(_faction); Children.Add(_endTurn); _faction.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 10.0f), new UniScalar(1.0f, -20.0f), new UniScalar(0.0f, 30.0f) ); _roundLabel.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 40.0f), new UniScalar(0.5f, -10.0f), new UniScalar(0.0f, 30.0f) ); _roundLabel.Text = "Round: "; _roundNumber.Bounds = new UniRectangle( new UniScalar(0.5f, 10.0f), new UniScalar(0.0f, 40.0f), new UniScalar(0.5f, -10.0f), new UniScalar(0.0f, 30.0f) ); _endTurn.Bounds = new UniRectangle( new UniScalar(0.0f, 10.0f), new UniScalar(0.0f, 70.0f), new UniScalar(1.0f, -20.0f), new UniScalar(0.0f, 45.0f) ); _endTurn.Text = "End Turn"; }
private void InitializeComponent() { Bounds = new UniRectangle( new UniScalar(0.0f, 0.0f), new UniScalar(0.0f, 105.0f), new UniScalar(0.2f, 0.0f), new UniScalar(1.0f, -105.0f) ); EnableDragging = false; for (var i = 0; i < _party.Count; i++) { var combatant = _party[i]; var partyButton = new ButtonControl(); partyButton.Text = combatant.Name; partyButton.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, (75.0f * i) + 15.0f), new UniScalar(1.0f, -30.0f), new UniScalar(0.0f, 65.0f) ); partyButton.Pressed += (s, a) => ChangeCharacter(combatant); Children.Add(partyButton); } }
public void TestNoFocusChangeOnHandledDirectionalCommand() { Screen screen = new Screen(100.0f, 100.0f); Mock <IInputReceiver> mockedReceiver = mockReceiver(screen); DelegatingControl one = new DelegatingControl(mockedReceiver.MockObject); one.Bounds = new UniRectangle(40, 10, 20, 20); Controls.Desktop.ButtonControl two = new Controls.Desktop.ButtonControl(); two.Bounds = new UniRectangle(40, 40, 20, 20); screen.Desktop.Children.Add(one); screen.Desktop.Children.Add(two); mockedReceiver.Expects.One.MethodWith(m => m.InjectCommand(Command.Down)); screen.FocusedControl = one; screen.InjectCommand(Command.Down); Assert.AreSame(one, screen.FocusedControl); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
private void InitializeComponent() { _startButton = new ButtonControl(); _helpButton = new ButtonControl(); _highscoresButton = new ButtonControl(); _exitButton = new ButtonControl(); Children.Add(_startButton); Children.Add(_helpButton); Children.Add(_highscoresButton); Children.Add(_exitButton); // // _startButton // _startButton.Bounds = new UniRectangle(25, 25, 150, 40); _startButton.Text = "Start"; // // _helpButton // _helpButton.Bounds = new UniRectangle(25, 70, 150, 40); _helpButton.Text = "Help"; // // _highscoresButton // _highscoresButton.Bounds = new UniRectangle(25, 115, 150, 40); _highscoresButton.Text = "High Scores"; // // _exitButton // _exitButton.Bounds = new UniRectangle(25, 335, 150, 40); _exitButton.Text = "Exit"; Bounds = new UniRectangle(0, 0, 200, 400); EnableDragging = false; }
public void TestFocusSwitching() { Screen screen = new Screen(100.0f, 100.0f); Controls.Desktop.ButtonControl center = new Controls.Desktop.ButtonControl(); center.Bounds = new UniRectangle(40, 40, 20, 20); Controls.Desktop.ButtonControl left = new Controls.Desktop.ButtonControl(); left.Bounds = new UniRectangle(10, 51, 20, 20); Controls.Desktop.ButtonControl right = new Controls.Desktop.ButtonControl(); right.Bounds = new UniRectangle(70, 29, 20, 20); Controls.Desktop.ButtonControl up = new Controls.Desktop.ButtonControl(); up.Bounds = new UniRectangle(29, 10, 20, 20); Controls.Desktop.ButtonControl down = new Controls.Desktop.ButtonControl(); down.Bounds = new UniRectangle(51, 70, 20, 20); screen.Desktop.Children.Add(center); screen.Desktop.Children.Add(left); screen.Desktop.Children.Add(right); screen.Desktop.Children.Add(up); screen.Desktop.Children.Add(down); screen.FocusedControl = center; screen.InjectKeyPress(Keys.Down); Assert.AreSame(down, screen.FocusedControl); screen.FocusedControl = center; screen.InjectKeyPress(Keys.Up); Assert.AreSame(up, screen.FocusedControl); screen.FocusedControl = center; screen.InjectKeyPress(Keys.Left); Assert.AreSame(left, screen.FocusedControl); screen.FocusedControl = center; screen.InjectKeyPress(Keys.Right); Assert.AreSame(right, screen.FocusedControl); }
private void InitializeComponent() { EnableDragging = false; _newGame = new ButtonControl(); _continue = new ButtonControl(); _loadGame = new ButtonControl(); _options = new ButtonControl(); _exit = new ButtonControl(); // new game _newGame.Text = "New Game"; _newGame.Bounds = new UniRectangle(15, 15, 150, 45); // continue _continue.Text = "Continue"; _continue.Bounds = new UniRectangle(15, 65, 150, 45); // load game _loadGame.Text = "Load Game"; _loadGame.Bounds = new UniRectangle(15, 115, 150, 45); // options _options.Text = "Options"; _options.Bounds = new UniRectangle(15, 165, 150, 45); // exit _exit.Text = "Exit"; _exit.Bounds = new UniRectangle(15, 215, 150, 45); Children.Add(_newGame); Children.Add(_continue); Children.Add(_loadGame); Children.Add(_options); Children.Add(_exit); }
public void UpdateControls() { foreach(var control in _controls) { // should always contain it, but just to be safe... if (Children.Contains(control)) Children.Remove(control); } _controls.Clear(); ButtonControl executeControl = new ButtonControl(); executeControl.Text = "Execute!"; executeControl.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(1.0f, -60.0f), new UniScalar(1.0f, -30.0f), new UniScalar(0.0f, 45.0f) ); executeControl.Pressed += (s, a) => ExecuteClicked.Invoke(); Children.Add(executeControl); for (var i = 0; i < Commands.Count; i++) { var command = Commands.ElementAt(i); QueuedCommandControl control = new QueuedCommandControl(); control.Command = command; control.Bounds = new UniRectangle( new UniScalar(0.0f, 15.0f), new UniScalar(0.0f, 15.0f + (49.0f * i)), new UniScalar(1.0f, -30.0f), new UniScalar(0.0f, 50.0f) ); _controls.Add(control); Children.Add(control); } Bounds.Size.Y.Offset = 95 + 49 * (Commands.Count); Bounds.Location.Y.Offset = 0 - Bounds.Size.Y.Offset; }
/// <summary> /// Required method for user interface initialization - /// do modify the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.btnClose = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.btnCheckUpdates = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.lblUpdateInfo = new Nuclex.UserInterface.Controls.LabelControl(); this.lblCopyright = new Nuclex.UserInterface.Controls.LabelControl(); this.lblWebsite = new Nuclex.UserInterface.Controls.LabelControl(); this.lblVersion = new Nuclex.UserInterface.Controls.LabelControl(); // // lblCopyright // this.lblCopyright.Bounds = new UniRectangle( new UniScalar(0.0f, 20.0f), new UniScalar(0.0f, 40.0f), new UniScalar(0.6f, -30.0f), 25 ); this.lblCopyright.Text = "Baby Bash XNA - Copyright Murray Grant 2011"; // // lblWebsite // this.lblWebsite.Bounds = new UniRectangle( new UniScalar(0.0f, 20.0f), new UniScalar(0.0f, 65.0f), new UniScalar(0.6f, -30.0f), 25 ); this.lblWebsite.Text = "http://babybashxna.codeplex.com"; // // lblVersion // this.lblVersion.Bounds = new UniRectangle( new UniScalar(0.0f, 40.0f), new UniScalar(0.0f, 90.0f), new UniScalar(0.6f, -30.0f), 25 ); this.lblVersion.Text = "Version: " + Helper.GetApplicationVesion().ToString(); // // lblUpdateInfo // this.lblUpdateInfo.Bounds = new UniRectangle( new UniScalar(0.0f, 20.0f), new UniScalar(1.0f, -80.0f), new UniScalar(0.8f, -30.0f), 25 ); this.lblUpdateInfo.Text = String.Empty; // // btnCheckUpdates // this.btnCheckUpdates.Bounds = new UniRectangle( new UniScalar(0.0f, 20.0f), new UniScalar(1.0f, -40.0f), 130, 24 ); this.btnCheckUpdates.Text = "Check for Updates"; this.btnCheckUpdates.Pressed += new EventHandler(this.btnCheckUpdates_Pressed); // // btnClose // this.btnClose.Bounds = new UniRectangle( new UniScalar(1.0f, -100.0f), new UniScalar(1.0f, -40.0f), 80, 24 ); this.btnClose.Text = "Close"; this.btnClose.Pressed += new EventHandler(this.btnClose_Pressed); // // DemoDialog // this.Bounds = new UniRectangle(new UniScalar(0, -20.0f), new UniScalar(0, -20.0f), 430, 200); this.Title = "About"; this.Children.Add(this.btnClose); this.Children.Add(this.btnCheckUpdates); this.Children.Add(this.lblUpdateInfo); this.Children.Add(this.lblCopyright); this.Children.Add(this.lblWebsite); this.Children.Add(this.lblVersion); }
/// <summary> /// Create gui controls /// </summary> /// <param name="mainScreen"> /// Screen to whose desktop the controls will be added /// </param> private void createDesktopControls(Screen mainScreen) { WindowControl options = new WindowControl(); options.Title = "Options"; options.EnableDragging = true; options.Bounds = new UniRectangle( new UniScalar(1.0f, -210.0f), 10, 200, 275); mainScreen.Desktop.Children.Add(options); OptionControl wireFrameToggle = new OptionControl(); wireFrameToggle.Text = "Wireframe"; wireFrameToggle.Bounds = new UniRectangle(10, 30, 100, 32); wireFrameToggle.Selected = Wireframe; wireFrameToggle.Changed += delegate(object sender, EventArgs arguments) { Wireframe = wireFrameToggle.Selected; }; options.Children.Add(wireFrameToggle); /* OptionControl fogToggle = new OptionControl(); fogToggle.Text = "Fog"; fogToggle.Bounds = new UniRectangle(10, 65, 100, 32); fogToggle.Selected = terrainDrawContext.BasicEffect.FogEnabled; fogToggle.Changed += delegate(object sender, EventArgs arguments) { terrainDrawContext.BasicEffect.FogEnabled = fogToggle.Selected; }; options.Children.Add(fogToggle); LabelControl fogNearLabel = new LabelControl("Near"); fogNearLabel.Bounds = new UniRectangle(10, 100, 20, 24); options.Children.Add(fogNearLabel); const float fogRange = 1000f; HorizontalSliderControl fogNear = new HorizontalSliderControl(); fogNear.Bounds = new UniRectangle(50, 100, 140, 24); fogNear.ThumbSize = 0.1f; fogNear.ThumbPosition = terrainDrawContext.BasicEffect.FogStart / fogRange; fogNear.Moved += delegate(object sender, EventArgs arguments) { terrainDrawContext.BasicEffect.FogStart = fogNear.ThumbPosition * fogRange; }; options.Children.Add(fogNear); LabelControl fogFarLabel = new LabelControl("Far"); fogFarLabel.Bounds = new UniRectangle(10, 125, 20, 24); options.Children.Add(fogFarLabel); HorizontalSliderControl fogFar = new HorizontalSliderControl(); fogFar.Bounds = new UniRectangle(50, 125, 140, 24); fogFar.ThumbSize = 0.1f; fogFar.ThumbPosition = terrainDrawContext.BasicEffect.FogEnd / fogRange; fogFar.Moved += delegate(object sender, EventArgs arguments) { terrainDrawContext.BasicEffect.FogEnd = fogFar.ThumbPosition * fogRange; }; options.Children.Add(fogFar); */ LabelControl cellGapLabel = new LabelControl("Gap"); cellGapLabel.Bounds = new UniRectangle(10, 65, 20, 24); options.Children.Add(cellGapLabel); HorizontalSliderControl cellGapControl = new HorizontalSliderControl(); cellGapControl.Bounds = new UniRectangle(50, 65, 140, 24); cellGapControl.ThumbSize = 0.1f; const float cellGapRange = 5.0f; cellGapControl.ThumbPosition = cellGap / cellGapRange; cellGapControl.Moved += delegate(object sender, EventArgs arguments) { cellGap = cellGapControl.ThumbPosition * cellGapRange; }; options.Children.Add(cellGapControl); LabelControl densityLabel = new LabelControl("Density"); densityLabel.Bounds = new UniRectangle(10, 90, 20, 24); options.Children.Add(densityLabel); const float densityRange = 100.0f; HorizontalSliderControl densityControl = new HorizontalSliderControl(); densityControl.Bounds = new UniRectangle(60, 90, 130, 24); densityControl.ThumbSize = 0.1f; densityControl.ThumbPosition = terrainNoiseDensity / densityRange; densityControl.Moved += delegate(object sender, EventArgs arguments) { terrainNoiseDensity = densityControl.ThumbPosition * densityRange; }; options.Children.Add(densityControl); LabelControl cellResLabel = new LabelControl("CellRes"); cellResLabel.Bounds = new UniRectangle(10, 115, 20, 24); options.Children.Add(cellResLabel); const float cellResRange = 5.0f; HorizontalSliderControl cellResControl = new HorizontalSliderControl(); cellResControl.Bounds = new UniRectangle(60, 115, 130, 24); cellResControl.ThumbSize = 0.1f; cellResControl.ThumbPosition = cellRes / (float)Math.Pow(2, cellResRange); cellResControl.Moved += delegate(object sender, EventArgs arguments) { cellRes = (float)Math.Pow(2, (int)(cellResControl.ThumbPosition * cellResRange)); }; options.Children.Add(cellResControl); LabelControl terrainResLabel = new LabelControl("TerRes"); terrainResLabel.Bounds = new UniRectangle(10, 140, 20, 24); options.Children.Add(terrainResLabel); const float terrainResRange = 5.0f; HorizontalSliderControl terrainResControl = new HorizontalSliderControl(); terrainResControl.Bounds = new UniRectangle(60, 140, 130, 24); terrainResControl.ThumbSize = 0.1f; terrainResControl.ThumbPosition = terrainRes / (float)Math.Pow(2, terrainResRange); terrainResControl.Moved += delegate(object sender, EventArgs arguments) { terrainRes = (float)Math.Pow(2, (int)(terrainResControl.ThumbPosition * terrainResRange)); }; options.Children.Add(terrainResControl); OptionControl cubicToggle = new OptionControl(); cubicToggle.Text = "Cubic (requires regen)"; cubicToggle.Bounds = new UniRectangle(10, 165, 100, 32); cubicToggle.Selected = cubicTerrain; cubicToggle.Changed += delegate(object sender, EventArgs arguments) { cubicTerrain = cubicToggle.Selected; }; options.Children.Add(cubicToggle); ButtonControl regenerateButton = new ButtonControl(); regenerateButton.Text = "Regenerate"; regenerateButton.Bounds = new UniRectangle( new UniScalar(1.0f, -190.0f), new UniScalar(1.0f, -75.0f), 110, 32); regenerateButton.Pressed += delegate(object sender, EventArgs arguments) { GenerateTerrain(random.Next(255)); }; options.Children.Add(regenerateButton); ButtonControl resetButton = new ButtonControl(); resetButton.Text = "Reset Camera"; resetButton.Bounds = new UniRectangle( new UniScalar(1.0f, -190.0f), new UniScalar(1.0f, -40.0f), 110, 32); resetButton.Pressed += delegate(object sender, EventArgs arguments) { ResetCamera(); }; options.Children.Add(resetButton); // Button through which the user can quit the application ButtonControl quitButton = new ButtonControl(); quitButton.Text = "Quit"; quitButton.Bounds = new UniRectangle( new UniScalar(1.0f, -70.0f), new UniScalar(1.0f, -40.0f), 60, 32); quitButton.Pressed += delegate(object sender, EventArgs arguments) { Exit(); }; options.Children.Add(quitButton); }
public ShopScene(Game game, List<Item> shopInventory) : base(game) { _shopInventory = shopInventory; var keyboard = new KeyboardInputLayer(this, null); keyboard.AddKeyDownBinding(Keys.Escape, () => Game.PopScene()); Components.Add(keyboard); Game.IsMouseVisible = true; Gui.DrawOrder = 1000; Gui.Visualizer = FlatGuiVisualizer.FromFile(Game.Services, "Content/Gui/main_gui.xml"); // GUI elements: _shopInventoryDialog = new InventoryDialog(); _shopInventoryDialog.Bounds = new UniRectangle( new UniScalar(0), new UniScalar(0), new UniScalar(225), new UniScalar(0.6F, -45) ); _shopInventoryDialog.SetInventory(_shopInventory); _shopInventoryDialog.HoverChanged += UpdateItemFocus; _shopInventoryDialog.HoverCleared += ClearItemFocus; Gui.Screen.Desktop.Children.Add(_shopInventoryDialog); _playerInventoryDialog = new InventoryDialog(); _playerInventoryDialog.Bounds = new UniRectangle( new UniScalar(235), new UniScalar(0), new UniScalar(225), new UniScalar(0.6F, -45) ); _playerInventoryDialog.HoverChanged += UpdateItemFocus; _playerInventoryDialog.HoverCleared += ClearItemFocus; Gui.Screen.Desktop.Children.Add(_playerInventoryDialog); _itemPreviewDialog = new ItemPreviewDialog(); _itemPreviewDialog.Bounds = new UniRectangle( new UniScalar(470), new UniScalar(0), new UniScalar(1.0f, -630), new UniScalar(0.6F, 0) ); Gui.Screen.Desktop.Children.Add(_itemPreviewDialog); // money / information _infoDialog = new InfoDialog(); _infoDialog.Bounds = new UniRectangle( new UniScalar(1.0F, -150), new UniScalar(0.0F, 45), new UniScalar(150), new UniScalar(0.6F, -45) ); Gui.Screen.Desktop.Children.Add(_infoDialog); // party _partyDialog = new PartyDialog(((SRPGGame)Game).Party); _partyDialog.Bounds = new UniRectangle( new UniScalar(0), new UniScalar(0.6F, 10), new UniScalar(1.0F, 0), new UniScalar(0.4F, -10) ); Gui.Screen.Desktop.Children.Add(_partyDialog); // exit button _exitButton = new ButtonControl(); _exitButton.Text = "Exit"; _exitButton.Bounds = new UniRectangle( new UniScalar(1.0F, -150), new UniScalar(0), new UniScalar(150), new UniScalar(35) ); _exitButton.Pressed += (s, a) => Game.PopScene(); Gui.Screen.Desktop.Children.Add(_exitButton); // buy selected _buyButton = new ButtonControl(); _buyButton.Text = "Buy"; _buyButton.Bounds = new UniRectangle( new UniScalar(0), new UniScalar(0.6F, -35), new UniScalar(225), new UniScalar(35) ); _buyButton.Pressed += BuySelectedItems; Gui.Screen.Desktop.Children.Add(_buyButton); // sell selected _sellButton = new ButtonControl(); _sellButton.Text = "Sell"; _sellButton.Bounds = new UniRectangle( new UniScalar(235), new UniScalar(0.6F, -35), new UniScalar(225), new UniScalar(35) ); _sellButton.Pressed += SellSelectedItems; Gui.Screen.Desktop.Children.Add(_sellButton); ClearItemFocus(); RefreshShop(); }
private void IngresoNuevoUsuario(Screen mainScreen) { LabelControl nameEntryLabel = new Nuclex.UserInterface.Controls.LabelControl(); InputControl nameEntryBox = new Nuclex.UserInterface.Controls.Desktop.InputControl(); ButtonControl okButton = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); WindowControl w = new WindowControl(); // // nameEntryLabel // nameEntryLabel.Text = "Por favor elija su nombre"; nameEntryLabel.Bounds = new UniRectangle( graphics.PreferredBackBufferWidth / 2 - 75, 200, 150, 50 ); mainScreen.Desktop.Children.Add(nameEntryLabel); // // nameEntryBox // nameEntryBox.Bounds = new UniRectangle( graphics.PreferredBackBufferWidth / 2 - 150, 280, 300, 30 ); mainScreen.Desktop.Children.Add(nameEntryBox); // //okButton // okButton.Text = "Guardar"; okButton.Bounds = new UniRectangle( graphics.PreferredBackBufferWidth / 2 - 100, 360, 200, 30 ); mainScreen.Desktop.Children.Add(okButton); okButton.Pressed += delegate(object sender, EventArgs arguments) { if ((JugadorExistenteEnArchivo(nameEntryBox.Text)) || (nameEntryBox.Text.Trim() == "")) { okButton.Enabled = false; WindowControl window = new WindowControl(); window.Title = "Error"; LabelControl labelExiste = new LabelControl("El jugador ingresado ya existe o es invalido"); labelExiste.Bounds = new UniRectangle(10.0f, 30.0f, 120.0f, 15.0f); ButtonControl aceptarButton = new ButtonControl(); aceptarButton.Text = "Aceptar"; aceptarButton.Bounds = new UniRectangle(110, 60, 80, 30); window.Bounds = new UniRectangle(graphics.PreferredBackBufferWidth / 2 - 150, 450, 300, 100); window.Children.Add(labelExiste); window.Children.Add(aceptarButton); mainScreen.Desktop.Children.Add(window); aceptarButton.Pressed += delegate(object senderWindow, EventArgs argumentsWindow) { okButton.Enabled = true; window.Close(); }; } else { nombre = nameEntryBox.Text; StreamWriter sw = new StreamWriter("Jugadores.txt", true); sw.WriteLine(nameEntryBox.Text.Trim()); sw.Close(); mainScreen.Desktop.Children.Clear(); menuUsuarioNuevo = false; menuGeneral = true; } }; }
/// <summary> /// Required method for user interface initialization - /// do modify the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.lblBabyPackage = new Nuclex.UserInterface.Controls.LabelControl(); this.lblBabyPackagePath = new Nuclex.UserInterface.Controls.LabelControl(); this.btnBabyPackageBrowse = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.lblKeyBashingThreshold = new Nuclex.UserInterface.Controls.LabelControl(); this.txtKeyBashingThreshold = new Nuclex.UserInterface.Controls.Desktop.InputControl(); this.lblRunOnAllMonitors = new Nuclex.UserInterface.Controls.LabelControl(); this.chkRunOnAllMonitors = new Nuclex.UserInterface.Controls.Desktop.OptionControl(); this.lblMouseRequired = new Nuclex.UserInterface.Controls.LabelControl(); this.chkMouseRequired = new Nuclex.UserInterface.Controls.Desktop.OptionControl(); this.lblAutoPublishErrors = new Nuclex.UserInterface.Controls.LabelControl(); this.chkAutoPublishErrors = new Nuclex.UserInterface.Controls.Desktop.OptionControl(); this.lblDeveloperMode = new Nuclex.UserInterface.Controls.LabelControl(); this.chkDeveloperMode = new Nuclex.UserInterface.Controls.Desktop.OptionControl(); this.lblDisabledKeys = new Nuclex.UserInterface.Controls.LabelControl(); this.lblDisabledKeyCount = new Nuclex.UserInterface.Controls.LabelControl(); this.btnDisableKeys = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.lblErrorMessage = new Nuclex.UserInterface.Controls.LabelControl(); this.btnUndo = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.btnClose = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); this.btnAbout = new Nuclex.UserInterface.Controls.Desktop.ButtonControl(); // // lblBabyPackage // this.lblBabyPackage.Text = "Baby Package of sounds and shapes:"; this.lblBabyPackage.Bounds = new UniRectangle(20.0f, 30.0f, 300.0f, 30.0f); // // lblBabyPackagePath // this.lblBabyPackagePath.Bounds = new UniRectangle(30.0f, 50.0f, 300.0f, 30.0f); // // btnBabyPackageBrowse // this.btnBabyPackageBrowse.Bounds = new UniRectangle(350.0f, 30.0f, 80.0f, 24.0f); this.btnBabyPackageBrowse.Pressed += new EventHandler(this.btnBabyPackageBrowse_Pressed); this.btnBabyPackageBrowse.Text = "Select"; // // lblKeyBashingThreshold // this.lblKeyBashingThreshold.Text = "Key Bashing Threshold (0 to turn off):"; this.lblKeyBashingThreshold.Bounds = new UniRectangle(20.0f, 90.0f, 300.0f, 30.0f); // // txtKeyBashingThreshold // this.txtKeyBashingThreshold.Bounds = new UniRectangle(350.0f, 90.0f, 60.0f, 30.0f); // // lblMouseRequired // this.lblMouseRequired.Text = "Must Press Mouse Button When Moving:"; this.lblMouseRequired.Bounds = new UniRectangle(20.0f, 120.0f, 300.0f, 30.0f); // // chkMouseRequired // this.chkMouseRequired.Bounds = new UniRectangle(350.0f, 120.0f, 60.0f, 30.0f); // // lblAutoPublishErrors // this.lblAutoPublishErrors.Text = "Automatically Publish Errors to Murray:"; this.lblAutoPublishErrors.Bounds = new UniRectangle(20.0f, 150.0f, 300.0f, 30.0f); // // chkAutoPublishErrors // this.chkAutoPublishErrors.Bounds = new UniRectangle(350.0f, 150.0f, 60.0f, 30.0f); // // lblDeveloperMode // this.lblDeveloperMode.Text = "Developer Mode:"; this.lblDeveloperMode.Bounds = new UniRectangle(20.0f, 180.0f, 300.0f, 30.0f); // // chkDeveloperMode // this.chkDeveloperMode.Bounds = new UniRectangle(350.0f, 180.0f, 60.0f, 30.0f); // // lblRunOnAllMonitors // this.lblRunOnAllMonitors.Text = "Run on all Monitors (Must Restart BabyBash):"; this.lblRunOnAllMonitors.Bounds = new UniRectangle(20.0f, 150.0f, 300.0f, 30.0f); // // chkRunOnAllMonitors // this.chkRunOnAllMonitors.Bounds = new UniRectangle(350.0f, 150.0f, 60.0f, 30.0f); // // lblDisabledKeys // this.lblDisabledKeys.Text = "Deactivated Keys:"; this.lblDisabledKeys.Bounds = new UniRectangle(20.0f, 180.0f, 300.0f, 30.0f); // // lblDisabledKeyCount // this.lblDisabledKeyCount.Text = "{0} Deactivated"; this.lblDisabledKeyCount.Bounds = new UniRectangle(450.0f, 180.0f, 300.0f, 30.0f); // // btnDisableKeys // this.btnDisableKeys.Bounds = new UniRectangle(350.0f, 180.0f, 80f, 24f); this.btnDisableKeys.Pressed += new EventHandler(this.btnDisableKeys_Pressed); this.btnDisableKeys.Text = "Choose"; // // lblErrorMessage // this.lblErrorMessage.Text = ""; this.lblErrorMessage.Bounds = new UniRectangle(20.0f, 230.0f, 300.0f, 30.0f); // // btnUndo // this.btnUndo.Bounds = new UniRectangle( new UniScalar(1.0f, -250.0f), new UniScalar(1.0f, -40.0f), 80, 24 ); this.btnUndo.Pressed += new EventHandler(this.undoButton_Pressed); this.btnUndo.Text = "Undo"; // // btnClose // this.btnClose.Bounds = new UniRectangle( new UniScalar(1.0f, -160.0f), new UniScalar(1.0f, -40.0f), 140, 24 ); this.btnClose.Pressed += new EventHandler(this.closeButton_Pressed); this.btnClose.Text = "Save and Close"; // // btnAbout // this.btnAbout.Bounds = new UniRectangle( new UniScalar(0.0f, 40.0f), new UniScalar(1.0f, -40.0f), 80, 24 ); this.btnAbout.Pressed += new EventHandler(this.creditsButton_Pressed); this.btnAbout.Text = "About"; // // DemoDialog // this.Bounds = new UniRectangle(new UniScalar(0, 0), new UniScalar(0, 0), 600f, 300f); this.Title = "Options"; this.Children.Add(this.lblBabyPackage); this.Children.Add(this.lblBabyPackagePath); this.Children.Add(this.btnBabyPackageBrowse); this.Children.Add(this.lblKeyBashingThreshold); this.Children.Add(this.txtKeyBashingThreshold); this.Children.Add(this.lblMouseRequired); this.Children.Add(this.chkMouseRequired); this.Children.Add(this.lblAutoPublishErrors); this.Children.Add(this.chkAutoPublishErrors); this.Children.Add(this.lblDeveloperMode); this.Children.Add(this.chkDeveloperMode); // Disable these until they're implemented. //this.Children.Add(this.lblRunOnAllMonitors); //this.Children.Add(this.chkRunOnAllMonitors); //this.Children.Add(this.lblDisabledKeys); //this.Children.Add(this.lblDisabledKeyCount); //this.Children.Add(this.btnDisableKeys); this.Children.Add(this.lblErrorMessage); this.Children.Add(this.btnUndo); this.Children.Add(this.btnClose); this.Children.Add(this.btnAbout); }
protected void InitializeComponents() { this.callsignLabel = new LabelControl(); this.tagLabel = new LabelControl(); this.hostLabel = new LabelControl(); this.teamLabel = new LabelControl(); this.callsignInput = new InputControl(); this.tagInput = new InputControl(); this.hostInput = new InputControl(); this.joinButton = new ButtonControl(); this.backButton = new ButtonControl(); this.teamChoice = new Control(); this.redTeam = new ChoiceControl(); this.blueTeam = new ChoiceControl(); this.greenTeam = new ChoiceControl(); this.callsignLabel.Text = "Callsign: "; this.callsignLabel.Bounds = new UniRectangle(new UniScalar(.7f, 0f), new UniScalar(.2f, 0f), 50, 24); this.callsignInput.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.2f, 0f), 150, 24); this.callsignInput.Enabled = true; this.tagLabel.Text = "Tag: "; this.tagLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.3f, 0f), 50, 24); this.tagInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.3f, 0f), 150, 24); this.tagInput.Enabled = true; this.hostLabel.Text = "Host: "; this.hostLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.4f, 0f), 50, 24); this.hostInput.Bounds = new UniRectangle(new UniScalar(0.7f, 80f), new UniScalar(0.4f, 0f), 150, 24); this.hostInput.Enabled = true; this.teamLabel.Text = "Team: "; this.teamLabel.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 50, 24); this.teamChoice.Bounds = new UniRectangle(new UniScalar(0.7f, 0f), new UniScalar(0.5f, 0f), 150, 94); this.redTeam.Text = "Red Team"; this.redTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 10f), 10, 10); this.redTeam.Enabled = true; this.blueTeam.Text = "Blue Team"; this.blueTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 30f), 10, 10); this.blueTeam.Enabled = true; this.greenTeam.Text = "Green Team"; this.greenTeam.Bounds = new UniRectangle(new UniScalar(0.0f, 80f), new UniScalar(0.0f, 50f), 10, 10); this.greenTeam.Enabled = true; this.joinButton.Text = "Join!"; this.joinButton.Bounds = new UniRectangle(new UniScalar(.7f, 80f), new UniScalar(0.7f, 0f), 150, 72); // 80, 24 for regular button this.backButton.Text = "Back"; this.backButton.Bounds = new UniRectangle(new UniScalar(0.1f, 0.0f), new UniScalar(0.9f, 0f), 80, 24); joinScreen.Desktop.Children.Add(callsignLabel); joinScreen.Desktop.Children.Add(callsignInput); joinScreen.Desktop.Children.Add(tagLabel); joinScreen.Desktop.Children.Add(tagInput); joinScreen.Desktop.Children.Add(hostLabel); joinScreen.Desktop.Children.Add(hostInput); joinScreen.Desktop.Children.Add(teamLabel); joinScreen.Desktop.Children.Add(teamChoice); joinScreen.Desktop.Children.Add(joinButton); joinScreen.Desktop.Children.Add(backButton); teamChoice.Children.Add(redTeam); teamChoice.Children.Add(blueTeam); teamChoice.Children.Add(greenTeam); }
public void TestNoFocusChangeOnHandledDirectionalCommand() { Screen screen = new Screen(100.0f, 100.0f); IInputReceiver mockedReceiver = mockReceiver(screen); DelegatingControl one = new DelegatingControl(mockedReceiver); one.Bounds = new UniRectangle(40, 10, 20, 20); Controls.Desktop.ButtonControl two = new Controls.Desktop.ButtonControl(); two.Bounds = new UniRectangle(40, 40, 20, 20); screen.Desktop.Children.Add(one); screen.Desktop.Children.Add(two); Expect.Once.On(mockedReceiver).Method("InjectCommand").WithAnyArguments(); screen.FocusedControl = one; screen.InjectCommand(Command.Down); Assert.AreSame(one, screen.FocusedControl); this.mockery.VerifyAllExpectationsHaveBeenMet(); }
private void InitializeComponent() { EnableDragging = false; // // weaponLabel // _weaponLabel = new LabelControl(); _weaponLabel.Bounds = new UniRectangle(15, 13, 150, 25); _weaponLabel.Text = "Weapon"; Children.Add(_weaponLabel); // // weaponText // _weaponText = new LabelControl(); _weaponText.Bounds = new UniRectangle(130, 13, 170, 25); Children.Add(_weaponText); // // weaponButton // _weaponButton = new ButtonControl(); _weaponButton.Bounds = new UniRectangle(new UniScalar(1.0f, -110), 10, 100, 40); _weaponButton.Text = "Change"; _weaponButton.Pressed += (s, a) => WeaponChange.Invoke(); Children.Add(_weaponButton); // // armorLabel // _armorLabel = new LabelControl(); _armorLabel.Bounds = new UniRectangle(15, 58, 150, 25); _armorLabel.Text = "Armor"; Children.Add(_armorLabel); // // armorText // _armorText = new LabelControl(); _armorText.Bounds = new UniRectangle(130, 58, 170, 25); Children.Add(_armorText); // // armorButton // _armorButton = new ButtonControl(); _armorButton.Bounds = new UniRectangle(new UniScalar(1.0f, -110), 55, 100, 40); _armorButton.Text = "Change"; _armorButton.Pressed += (s, a) => ArmorChange.Invoke(); Children.Add(_armorButton); // // accLabel // _accLabel = new LabelControl(); _accLabel.Bounds = new UniRectangle(15, 103, 150, 25); _accLabel.Text = "Accessory"; Children.Add(_accLabel); // // accText // _accText = new LabelControl(); _accText.Bounds = new UniRectangle(130, 103, 170, 25); Children.Add(_accText); // // accButton // _accButton = new ButtonControl(); _accButton.Bounds = new UniRectangle(new UniScalar(1.0f, -110), 100, 100, 40); _accButton.Text = "Change"; _accButton.Pressed += (s, a) => AccessoryChange.Invoke(); Children.Add(_accButton); }
protected void InitializeComponents() { joinButton = new ButtonControl(); helpButton = new ButtonControl(); quitButton = new ButtonControl(); joinButton.Text = "Join"; joinButton.Bounds = new UniRectangle(new UniScalar(0.5f, 0.0f), new UniScalar(0.3f, 0.0f), 240, 48); helpButton.Text = "Help/Credits"; helpButton.Bounds = new UniRectangle(new UniScalar(0.5f, 0.0f), new UniScalar(0.5f, 0.0f), 240, 48); quitButton.Text = "Quit"; quitButton.Bounds = new UniRectangle(new UniScalar(0.5f, 0.0f), new UniScalar(0.7f, 0.0f), 240, 48); mainMenuScreen.Desktop.Children.Add(joinButton); mainMenuScreen.Desktop.Children.Add(helpButton); mainMenuScreen.Desktop.Children.Add(quitButton); }
private void LoadContent(Screen mainScreen, ContentManager content) { background = content.Load<Texture2D>("Images\\Room\\background2"); headerTeam = content.Load<SpriteFont>("Images\\Room\\headerTeam"); int width = 315; int height = 591; Color[] data = new Color[width * height]; for (int i = 0; i < width; ++i) { data[i] = Color.Black; } for (int i = width; i < (width * (height - 1)); ++i) { if (((i % width) == 0) || ((i % width) == (width - 1))) { data[i] = Color.Black; } else { data[i] = Color.White; } } for (int i = (width * (height - 1)); i < (width * height); ++i) { data[i] = Color.Black; } teamPanel = new Texture2D(graphics.GraphicsDevice, width, height); teamPanel.SetData(data); width = 308; height = 123; data = new Color[width * height]; for (int i = 0; i < width; ++i) { data[i] = Color.Black; } for (int i = width; i < (width * (height - 1)); ++i) { if (((i % width) == 0) || ((i % width) == (width - 1))) { data[i] = Color.Black; } else { data[i] = Color.Aquamarine; } } for (int i = (width * (height - 1)); i < (width * height); ++i) { data[i] = Color.Black; } playerPanel = new Texture2D(graphics.GraphicsDevice, width, height); playerPanel.SetData(data); int j = 0; for (int i = 0; i < 8; i += 2) { LabelControl playerIDLeftLabel = new LabelControl("0.0.0.0"); playerIDLeftLabel.Bounds = new UniRectangle(21, 72 + 129 * j, 115, 18); playerIDLeftLabel.Name = "Label Player ID " + (i + 1); LabelControl playerIDRightLabel = new LabelControl("0.0.0.1"); playerIDRightLabel.Bounds = new UniRectangle(451, 72 + 129 * j, 115, 18); playerIDRightLabel.Name = "Label Player ID " + (i + 2); playerIDLabels.Add(playerIDLeftLabel); panelVisibility.Add(false); playerIDLabels.Add(playerIDRightLabel); panelVisibility.Add(false); /*mainScreen.Desktop.Children.Add(playerIDLeftLabel); mainScreen.Desktop.Children.Add(playerIDRightLabel);*/ j++; } ButtonControl leftTeamButton = new ButtonControl(); leftTeamButton.Bounds = new UniRectangle(335, 13, 40, 40); leftTeamButton.Name = "Left Team Button"; leftTeamButton.imageTexture = content.Load<Texture2D>("Images\\Room\\LeftTeam"); leftTeamButton.Pressed += new EventHandler(leftTeamPressed); ButtonControl rightTeamButton = new ButtonControl(); rightTeamButton.Bounds = new UniRectangle(397, 13, 40, 40); rightTeamButton.Name = "Right Team Button"; rightTeamButton.imageTexture = content.Load<Texture2D>("Images\\Room\\RightTeam"); rightTeamButton.Pressed += new EventHandler(rightTeamPressed); ButtonControl chooseVehicleButton = new ButtonControl(); chooseVehicleButton.Bounds = new UniRectangle(14, 612, 150, 60); chooseVehicleButton.Name = "Choose Vehicle Button"; chooseVehicleButton.imageTexture = content.Load<Texture2D>("Images\\Room\\ChooseVehicle"); chooseVehicleButton.imageHover = content.Load<Texture2D>("Images\\Room\\ChooseVehicleHover"); chooseVehicleButton.Pressed += new EventHandler(chooseVehiclePressed); ButtonControl readyButton = new ButtonControl(); readyButton.Bounds = new UniRectangle(443, 612, 150, 60); readyButton.Name = "Ready Button"; readyButton.imageTexture = content.Load<Texture2D>("Images\\Room\\ReadyButton"); readyButton.imageHover = content.Load<Texture2D>("Images\\Room\\ReadyButtonHover"); readyButton.Pressed += new EventHandler(readyPressed); ButtonControl startGameButton = new ButtonControl(); startGameButton.Bounds = new UniRectangle(608, 612, 150, 60); startGameButton.Name = "Start Game Button"; startGameButton.imageTexture = content.Load<Texture2D>("Images\\Room\\PlayButton"); startGameButton.imageHover = content.Load<Texture2D>("Images\\Room\\PlayButtonHover"); startGameButton.Pressed += new EventHandler(startGamePressed); ButtonControl backButton = new ButtonControl(); backButton.Bounds = new UniRectangle(1022, 612, 150, 60); backButton.Name = "Back Button"; backButton.imageTexture = content.Load<Texture2D>("Images\\Room\\BackButton"); backButton.imageHover = content.Load<Texture2D>("Images\\Room\\BackButtonHover"); backButton.Pressed += new EventHandler(backPressed); mainScreen.Desktop.Children.Add(leftTeamButton); mainScreen.Desktop.Children.Add(rightTeamButton); mainScreen.Desktop.Children.Add(chooseVehicleButton); mainScreen.Desktop.Children.Add(readyButton); mainScreen.Desktop.Children.Add(startGameButton); mainScreen.Desktop.Children.Add(backButton); }
private void LoadContent(Screen mainScreen, ContentManager content) { background = content.Load<Texture2D>("Images\\CreateRoom\\background2"); header = content.Load<SpriteFont>("Images\\CreateRoom\\header"); LabelControl roomNameLabel = new LabelControl("Room Name"); roomNameLabel.Bounds = new UniRectangle(44, 91, 98, 20); roomNameLabel.Name = "Label Room Name"; roomNameInput = new InputControl(); roomNameInput.Bounds = new UniRectangle(217, 88, 213, 26); roomNameInput.Name = "Input Room Name"; LabelControl maxPlayerLabel = new LabelControl("Maimum Player"); maxPlayerLabel.Bounds = new UniRectangle(44, 155, 123, 20); maxPlayerLabel.Name = "Label Maximum Player"; twoChoice = new ChoiceControl(); twoChoice.Name = "Choice Two Player"; twoChoice.Text = "2"; twoChoice.Bounds = new UniRectangle(217, 155, 35, 20); twoChoice.Selected = true; fourChoice = new ChoiceControl(); fourChoice.Name = "Choice Four Player"; fourChoice.Text = "4"; fourChoice.Bounds = new UniRectangle(258, 155, 35, 20); sixChoice = new ChoiceControl(); sixChoice.Name = "Choice Six Player"; sixChoice.Text = "6"; sixChoice.Bounds = new UniRectangle(299, 155, 35, 20); eightChoice = new ChoiceControl(); eightChoice.Name = "Choice Eight Player"; eightChoice.Text = "8"; eightChoice.Bounds = new UniRectangle(340, 155, 35, 20); ButtonControl createRoomButton = new ButtonControl(); createRoomButton.Bounds = new UniRectangle(48, 208, 104, 46); createRoomButton.Name = "Create Room Button"; createRoomButton.Pressed += new EventHandler(createRoomPressed); createRoomButton.Text = "Create"; ButtonControl cancelButton = new ButtonControl(); cancelButton.Bounds = new UniRectangle(326, 208, 104, 46); cancelButton.Name = "Cancel Button"; cancelButton.Pressed += new EventHandler(cancelPressed); cancelButton.Text = "Cancel"; mainScreen.Desktop.Children.Add(roomNameLabel); mainScreen.Desktop.Children.Add(roomNameInput); mainScreen.Desktop.Children.Add(maxPlayerLabel); mainScreen.Desktop.Children.Add(twoChoice); mainScreen.Desktop.Children.Add(fourChoice); mainScreen.Desktop.Children.Add(sixChoice); mainScreen.Desktop.Children.Add(eightChoice); mainScreen.Desktop.Children.Add(createRoomButton); mainScreen.Desktop.Children.Add(cancelButton); }
private void LoadContent(Screen mainScreen, ContentManager content) { background = content.Load<Texture2D>("Images\\Lobby\\background1"); backgroundMusic = content.Load<Song>("Music\\03 Gunbound- Now Loading"); avatar = content.Load<Texture2D>("Images\\Lobby\\Gunbound_dragon"); int width = 869; int height = 519; Color[] data = new Color[width * height]; for (int i = 0; i < width; ++i) { data[i] = Color.Black; } for (int i = width; i < (width * (height - 1)); ++i) { if (((i % width) == 0) || ((i % width) == (width - 1))) { data[i] = Color.Black; } else { data[i] = Color.White; } } for (int i = (width * (height-1)); i < (width * height); ++i) { data[i] = Color.Black; } mainPanel = new Texture2D(graphics.GraphicsDevice, width, height); mainPanel.SetData(data); width = 282; height = 519; data = new Color[width * height]; for (int i = 0; i < width; ++i) { data[i] = Color.Black; } for (int i = width; i < (width * (height - 1)); ++i) { if (((i % width) == 0) || ((i % width) == (width - 1))) { data[i] = Color.Black; } else { data[i] = Color.White; } } for (int i = (width * (height - 1)); i < (width * height); ++i) { data[i] = Color.Black; } userPanel = new Texture2D(graphics.GraphicsDevice, width, height); userPanel.SetData(data); roomPanel = content.Load<Texture2D>("Images\\Lobby\\roombox"); width = roomPanel.Width; height = roomPanel.Height; data = new Color[width * height]; roomPanel.GetData(data); for (int i = 0; i < width; ++i) { data[i] = Color.Black; } for (int i = width; i < (width * (height - 1)); i += width) { data[i] = Color.Black; data[i + (width - 1)] = Color.Gray; } for (int i = (width * (height - 1)); i < (width * height); ++i) { data[i] = Color.Gray; } roomPanel.SetData(data); Texture2D buttonBackGround = content.Load<Texture2D>("Images\\Lobby\\buttes2"); int j = 0; for (int i = 0; i < 10; i+=2) { LabelControl roomIDLeftLabel = new LabelControl("Test dulu"); roomIDLeftLabel.Bounds = new UniRectangle(25, 32 + 102 * j, 55, 16); roomIDLeftLabel.Name = "Label Room ID " + (i + 1); LabelControl roomCapLeftLabel = new LabelControl("Sekian / sekian"); roomCapLeftLabel.Bounds = new UniRectangle(25, 50 + 102 * j, 55, 16); roomCapLeftLabel.Name = "Label Room Cap " + (i + 1); ButtonControl joinLeftButton = new ButtonControl(); joinLeftButton.Text = "JOIN"; joinLeftButton.Bounds = new UniRectangle(334, 67 + 102 * j, 101, 28); joinLeftButton.Name = "Join Button " + (i + 1); joinLeftButton.imageTexture = buttonBackGround; LabelControl roomIDRightLabel = new LabelControl("Test dulu"); roomIDRightLabel.Bounds = new UniRectangle(451, 32 + 102 * j, 55, 16); roomIDRightLabel.Name = "Label Room ID " + (i + 2); LabelControl roomCapRightLabel = new LabelControl("Sekian / sekian"); roomCapRightLabel.Bounds = new UniRectangle(451, 50 + 102 * j, 55, 16); roomCapRightLabel.Name = "Label Room Cap " + (i + 2); ButtonControl joinRightButton = new ButtonControl(); joinRightButton.Text = "JOIN"; joinRightButton.Bounds = new UniRectangle(760, 67 + 102 * j, 101, 28); joinRightButton.Name = "Join Button " + (i + 2); joinRightButton.imageTexture = buttonBackGround; roomIDLabels.Add(roomIDLeftLabel); roomCapLabels.Add(roomCapLeftLabel); joinButtons.Add(joinLeftButton); panelVisibility.Add(false); joinEventHandlers.Add(new EventHandler(joinRoomPressed)); roomIDLabels.Add(roomIDRightLabel); roomCapLabels.Add(roomCapRightLabel); joinButtons.Add(joinRightButton); panelVisibility.Add(false); joinEventHandlers.Add(new EventHandler(joinRoomPressed)); /*mainScreen.Desktop.Children.Add(roomIDLeftLabel); mainScreen.Desktop.Children.Add(roomCapLeftLabel); mainScreen.Desktop.Children.Add(joinLeftButton); mainScreen.Desktop.Children.Add(roomIDRightLabel); mainScreen.Desktop.Children.Add(roomCapRightLabel); mainScreen.Desktop.Children.Add(joinRightButton);*/ j++; } LabelControl usernameLabel = new LabelControl(username); usernameLabel.Bounds = new UniRectangle(938, 20, 157, 32); usernameLabel.Name = "Label Username"; ButtonControl createRoomButton = new ButtonControl(); createRoomButton.Bounds = new UniRectangle(15, 537, 151, 151); createRoomButton.Name = "Create Room Button"; createRoomButton.imageTexture = content.Load<Texture2D>("Images\\Lobby\\CreateRoom"); createRoomButton.imageHover = content.Load<Texture2D>("Images\\Lobby\\CreateRoomHover"); createRoomButton.Pressed += new EventHandler(createRoomPressed); ButtonControl refreshButton = new ButtonControl(); refreshButton.Bounds = new UniRectangle(200, 537, 151, 151); refreshButton.Name = "Refresh Button"; refreshButton.imageTexture = content.Load<Texture2D>("Images\\Lobby\\Refresh"); refreshButton.imageHover = content.Load<Texture2D>("Images\\Lobby\\RefreshHover"); refreshButton.Pressed += new EventHandler(refreshPressed); ButtonControl leftPageButton = new ButtonControl(); leftPageButton.Bounds = new UniRectangle(622, 537, 151, 151); leftPageButton.Name = "Left Page Button"; leftPageButton.imageTexture = content.Load<Texture2D>("Images\\Lobby\\LeftPage"); leftPageButton.imageHover = content.Load<Texture2D>("Images\\Lobby\\LeftPageHover"); leftPageButton.Pressed += new EventHandler(leftPagePressed); ButtonControl rightPageButton = new ButtonControl(); rightPageButton.Bounds = new UniRectangle(781, 537, 151, 151); rightPageButton.Name = "Right Page Button"; rightPageButton.imageTexture = content.Load<Texture2D>("Images\\Lobby\\RightPage"); rightPageButton.imageHover = content.Load<Texture2D>("Images\\Lobby\\RightPageHover"); rightPageButton.Pressed += new EventHandler(rightPagePressed); ButtonControl exitGameButton = new ButtonControl(); exitGameButton.Bounds = new UniRectangle(1026, 537, 151, 151); exitGameButton.Name = "Exit Button"; exitGameButton.imageTexture = content.Load<Texture2D>("Images\\Lobby\\Exit"); exitGameButton.imageHover = content.Load<Texture2D>("Images\\Lobby\\ExitHover"); exitGameButton.Pressed += new EventHandler(exitPressed); mainScreen.Desktop.Children.Add(usernameLabel); mainScreen.Desktop.Children.Add(createRoomButton); mainScreen.Desktop.Children.Add(refreshButton); mainScreen.Desktop.Children.Add(leftPageButton); mainScreen.Desktop.Children.Add(rightPageButton); mainScreen.Desktop.Children.Add(exitGameButton); }