public override void InitUi(Canvas canvas) { var window = new WindowControl(canvas, "Menu principal"); window.DisableResizing(); window.IsClosable = false; window.SetSize(200, 125); window.SetPosition(Game.GetWindowSize().X / 2 - window.Width / 2, Game.GetWindowSize().Y / 2 - window.Height / 2); var playButton = new Button(window); playButton.SetText("Jouer !"); playButton.Clicked += (sender, arguments) => ShowSelectLevelUi(canvas); var settingsButton = new Button(window); settingsButton.SetText("Options"); Align.PlaceDownLeft(settingsButton, playButton, 10); var exitButton = new Button(window); exitButton.SetText("Quitter"); exitButton.Clicked += (sender, arguments) => { Game.Close(); }; Align.PlaceDownLeft(exitButton, settingsButton, 10); Align.CenterHorizontally(playButton); Align.CenterHorizontally(settingsButton); Align.CenterHorizontally(exitButton); }
Base ConstructFindGame() { Base FindGame = new Base(MainCanvas.GetCanvas()); FindGame.SetSize(300, 300); Label EnterIP = new Label(FindGame); EnterIP.AutoSizeToContents = true; EnterIP.SetText("Enter an IP:"); EnterIP.SetPosition(10, 10); TextBox IPAddress = new TextBox(FindGame); IPAddress.SetText("127.0.0.1"); IPAddress.SetPosition(10, 40); IPAddress.SetSize(260, 20); TextBox Port = new TextBox(FindGame); Port.SetText("54987"); Port.SetPosition(10, 70); Port.SetSize(260, 20); Button Connect = new Button(FindGame); Connect.SetText("Connect"); Connect.SetPosition(10, 200); Connect.SetSize(200, 20); Connect.Clicked += delegate(Base sender, ClickedEventArgs args) { Program.Connect(IPAddress.Text, Int32.Parse(Port.Text)); MainMenu.Hide(); FindGame.Hide(); Connecting.Show(); }; Button Back = new Button(FindGame); Back.SetText("Back"); Back.SetPosition(10, 225); Back.SetSize(200, 20); Back.Clicked += delegate(Base sender, ClickedEventArgs args) { Mode = MenuMode.MainMenu; MainMenu.Show(); FindGame.Hide(); }; return FindGame; }
public void Initialize() { Status = new Label(MainCanvas.Instance); Status.SetPosition(10, 10); Status.SetText("Waiting for opponent..."); Status.MakeColorBright(); Button cancel = new Button(MainCanvas.Instance); cancel.SetText("Cancel"); cancel.SetPosition(10, 40); cancel.Clicked += delegate(Base sender, ClickedEventArgs args) { Program.SwitchState(new MainMenu()); }; NetPeerConfiguration Configuration = new NetPeerConfiguration("Xanatos"); Configuration.Port = 54987; Configuration.MaximumConnections = 1; Program.Connection = new NetServer(Configuration); Program.Connection.Start(); Message.RegisterServer(Program.Connection); }
private void CreateEscapeWindow() { EscapeWindow = new WindowControl(MainCanvas.GetCanvas()); EscapeWindow.SetPosition(10, 10); EscapeWindow.SetSize(200, 200); Button Close = new Button(EscapeWindow); Close.SetPosition(10, 10); Close.SetText("Continue"); Close.Clicked += delegate(Base sender, ClickedEventArgs args) { EscapeWindow.Hide(); Game.LockMouse = true; }; Button Quit = new Button(EscapeWindow); Quit.SetPosition(10, 40); Quit.SetText("Quit"); Quit.Clicked += delegate(Base sender, ClickedEventArgs args) { MainCanvas.Dispose(); Environment.Exit(0); }; }
private void setupUi() { renderer = new Gwen.Renderer.OpenTK(); Gwen.Skin.Base skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png"); canvas = new Canvas(skin); canvas.SetSize(Width, Height); gwenInput = new Gwen.Input.OpenTK(this); gwenInput.Initialize(canvas); Mouse.ButtonDown += Mouse_ButtonDown; Mouse.ButtonUp += Mouse_ButtonUp; Mouse.Move += Mouse_Move; Mouse.WheelChanged += Mouse_Wheel; canvas.ShouldDrawBackground = true; canvas.BackgroundColor = System.Drawing.Color.FromArgb(122, 150, 170, 170); // controls radioCamera = new RadioButtonGroup(canvas); radioCamera.AutoSizeToContents = true; radioCamera.SetText("Тип камеры"); radioCamera.AddOption("Свободная", "free"); radioCamera.AddOption("Привязанная", "bound"); radioCamera.SetSelection(0); radioCamera.SelectionChanged += radioCamera_SelectionChanged; // coord GroupBox posGroup = new GroupBox(canvas); posGroup.SetText("Позиция камеры"); posGroup.SizeToChildren(); posGroup.SetSize(150, 120); Gwen.Align.PlaceDownLeft(posGroup, radioCamera, 45); labelPosX = new Label(posGroup); labelPosY = new Label(posGroup); labelPosZ = new Label(posGroup); labelPosX.SetText("X: 0.0"); labelPosY.SetText("Y: 1.0"); labelPosZ.SetText("Z: 2.0"); Gwen.Align.PlaceDownLeft(labelPosY, labelPosX, 5); Gwen.Align.PlaceDownLeft(labelPosZ, labelPosY, 5); // reset button Button resetCameraButton = new Gwen.Control.Button(posGroup); resetCameraButton.SetText("Сбросить позицию\nкамеры"); resetCameraButton.Clicked += cameraReset_Clicked; resetCameraButton.SizeToContents(); Gwen.Align.PlaceDownLeft(resetCameraButton, labelPosZ, 5); labelSpeed = new Label(canvas); Gwen.Align.PlaceDownLeft(labelSpeed, posGroup, 5); labelTips = new Label(canvas); labelTips.SetText(freeCameraTip + "\n\n" + nodeTransformTip); labelTips.SizeToContents(); Gwen.Align.PlaceDownLeft(labelTips, labelSpeed, 15); statusBar = new Gwen.Control.StatusBar(canvas); statusBar.Dock = Gwen.Pos.Bottom; }
private void ShowSelectLevelUi(Canvas canvas) { var window = new WindowControl(canvas, "Choisir un niveau", true); window.DisableResizing(); window.SetSize(300, 400); window.SetPosition(Game.GetWindowSize().X /2 - window.Width / 2, Game.GetWindowSize().Y / 2 - window.Height / 2); var listLevel = new ListBox(window); listLevel.SetSize(window.Width / 2, window.Height - 40); if (Directory.Exists(_levelsPath)) { foreach (var file in Directory.EnumerateFiles(_levelsPath)) { var fileInfo = new FileInfo(file); if (fileInfo.Extension.Equals(".mtrlvl")) { listLevel.AddRow(fileInfo.Name.Remove(fileInfo.Name.LastIndexOf('.')), fileInfo.Name, file); } } } var widthButton = window.Width - listLevel.Width - 30; var playButton = new Button(window); playButton.SetText("Jouer"); playButton.SetPosition(listLevel.Width + 10, 0); playButton.SetSize(widthButton, playButton.Height); playButton.Clicked += (sender, arguments) => { LoadLevel(listLevel, canvas, false); }; var deleteLevelButton = new Button(window); deleteLevelButton.SetText("Supprimer"); deleteLevelButton.SetSize(widthButton, deleteLevelButton.Height); deleteLevelButton.Clicked += (sender, arguments) => { if (listLevel.SelectedRowIndex == -1) new MessageBox(canvas, "Aucun niveau n'a été sélectionné !", "Erreur !").Show(); else { var path = listLevel.SelectedRow.UserData.ToString(); try { File.Delete(path); listLevel.RemoveRow(listLevel.SelectedRowIndex); listLevel.SelectedRow = null; Log.WriteInfo("Le niveau : " + path + " a été supprimé !"); } catch (IOException e) { new MessageBox(canvas, "Impossible de supprimer le niveau sélectionné ! Erreur : " + e.Message, "Erreur !").Show(); } } }; Align.PlaceDownLeft(deleteLevelButton, playButton, 10); var editLevelButton = new Button(window); editLevelButton.SetText("Editer le niveau"); editLevelButton.SetSize(widthButton, editLevelButton.Height); editLevelButton.Clicked += (sender, arguments) => { LoadLevel(listLevel, canvas, true); }; Align.PlaceDownLeft(editLevelButton, deleteLevelButton, 10); var newLevelButton = new Button(window); newLevelButton.SetText("Nouveau niveau"); newLevelButton.SetSize(widthButton, newLevelButton.Height); Align.PlaceDownLeft(newLevelButton, editLevelButton, 10); }
public override void InitUi(Canvas canvas) { _canvas = canvas; Game.BackgroundColor = Color.Black; var windowAction = new WindowControl(canvas, "Options", false); windowAction.DisableResizing(); windowAction.IsClosable = false; windowAction.SetSize(200, 150); windowAction.SetPosition(0, 0); var addScriptButton = new Button(windowAction); addScriptButton.SetText("Ajouter un script"); addScriptButton.Clicked += (sender, arguments) => ShowAddScriptWindow(canvas); Align.CenterHorizontally(addScriptButton); // Fenêtre sur les informations du script sélectionné _windowInfoScript = new WindowControl(canvas, "Paramètres du script"); _windowInfoScript.DisableResizing(); _windowInfoScript.IsClosable = false; _windowInfoScript.SetSize(200, 300); _windowInfoScript.SetPosition(Game.GetWindowSize().X - _windowInfoScript.Width, 0); var labelX = new Label(_windowInfoScript); labelX.SetPosition(0, 10); labelX.SetText("X :"); _uiInfoTextBoxPosX = new TextBoxNumeric(_windowInfoScript); _uiInfoTextBoxPosX.SetSize(100, _uiInfoTextBoxPosX.Height); _uiInfoTextBoxPosX.TextChanged += (sender, arguments) => { if (_selectScript != null) { _selectScript.RectShape.Position = new Vector2f((int) _uiInfoTextBoxPosX.Value, _selectScript.RectShape.Position.Y); } }; Align.PlaceRightBottom(_uiInfoTextBoxPosX, labelX, 10); var labelY = new Label(_windowInfoScript); labelY.SetText("Y :"); Align.PlaceDownLeft(labelY, labelX, 10); _uiInfoTextBoxPosY = new TextBoxNumeric(_windowInfoScript); _uiInfoTextBoxPosY.SetSize(100, _uiInfoTextBoxPosY.Height); _uiInfoTextBoxPosY.TextChanged += (sender, arguments) => { if (_selectScript != null) { _selectScript.RectShape.Position = new Vector2f(_selectScript.RectShape.Position.X, (int) _uiInfoTextBoxPosY.Value); } }; Align.PlaceRightBottom(_uiInfoTextBoxPosY, labelY, 10); var labelSizeX = new Label(_windowInfoScript); labelSizeX.SetText("Largeur :"); Align.PlaceDownLeft(labelSizeX, labelY, 10); _uiInfoTextBoxSizeX = new TextBoxNumeric(_windowInfoScript); _uiInfoTextBoxSizeX.SetSize(100, _uiInfoTextBoxPosY.Height); _uiInfoTextBoxSizeX.TextChanged += (sender, arguments) => { if (_selectScript != null) { _selectScript.RectShape.Size = new Vector2f((int)_uiInfoTextBoxSizeX.Value, _selectScript.RectShape.Size.Y); _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2); } }; Align.PlaceRightBottom(_uiInfoTextBoxSizeX, labelSizeX, 10); var labelSizeY = new Label(_windowInfoScript); labelSizeY.SetText("Hauteur :"); Align.PlaceDownLeft(labelSizeY, labelSizeX, 10); _uiInfoTextBoxSizeY = new TextBoxNumeric(_windowInfoScript); _uiInfoTextBoxSizeY.SetSize(100, _uiInfoTextBoxSizeY.Height); _uiInfoTextBoxSizeY.TextChanged += (sender, arguments) => { if (_selectScript != null) { _selectScript.RectShape.Size = new Vector2f(_selectScript.RectShape.Size.X, (int)_uiInfoTextBoxSizeY.Value); _selectScript.RectShape.Origin = new Vector2f(_selectScript.RectShape.Size.X / 2, _selectScript.RectShape.Size.Y / 2); } }; Align.PlaceRightBottom(_uiInfoTextBoxSizeY, labelSizeY, 10); _uiInfoScriptImage = new ImagePanel(_windowInfoScript); _uiInfoScriptImage.SetSize(75, 75); _uiInfoScriptImage.Hide(); Align.PlaceDownLeft(_uiInfoScriptImage, _uiInfoTextBoxSizeY, 10); Align.CenterHorizontally(_uiInfoScriptImage); UnSelect_SelectScript(); }
Base ConstructMainMenu() { Base MainMenu = new Base(MainCanvas.GetCanvas()); MainMenu.SetSize(300, 300); MainMenu.Dock = Gwen.Pos.Center; Button SinglePlayer = new Button(MainMenu); SinglePlayer.SetText("Single Player"); SinglePlayer.SetPosition(10, 10); SinglePlayer.SetSize(220, 20); //SinglePlayer.Clicked += delegate(Base caller) { // Mode = SINGLEPLAYER; // MainMenu.Hide(); //}; SinglePlayer.Disable(); Button JoinGame = new Button(MainMenu); JoinGame.SetText("Join Game"); JoinGame.SetPosition(10, 70); JoinGame.SetSize(220, 20); JoinGame.Clicked += delegate(Base sender, ClickedEventArgs args) { MainMenu.Hide(); FindGame.Show(); Mode = MenuMode.JoiningGame; }; Button Quit = new Button(MainMenu); Quit.SetText("Quit"); Quit.SetPosition(10, 100); Quit.SetSize(220, 20); Quit.Clicked += delegate(Base sender, ClickedEventArgs args) { MainCanvas.Dispose(); Environment.Exit(0); }; return MainMenu; }