public override void Initialize() { Viewport viewport = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]).GetViewport(); originalWidth = (int)((float)viewport.Width * 0.5f); //Notification Bar notificationWindow = new Window(manager); notificationWindow.Init(); notificationWindow.Text = "Notification Bar"; notificationWindow.Height = 110; notificationWindow.Width = originalWidth; notificationWindow.Visible = true; notificationWindow.Top = viewport.Height - notificationWindow.Height; notificationWindow.Left = viewport.Width/2 - originalWidth/2; notificationWindow.CloseButtonVisible = false; notificationWindow.AutoScroll = true; notificationWindow.Resizable = true; notificationWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); notificationWindow.IconVisible = false; manager.Add(notificationWindow); NotificationBar data = new NotificationBar(m_device, m_content, originalWidth-32, 25); notificationBar = new NotificationBarContainer(manager, notificationWindow, data); notificationBar.Init(); notificationBar.Width = originalWidth-32;// tilemap.tilemapImage.Width; notificationBar.Height = 160;// tilemap.tilemapImage.Height; notificationBar.Parent = notificationWindow; notificationBar.CanFocus = false; notificationBar.MouseOver += new TomShane.Neoforce.Controls.MouseEventHandler(OnGainFocus); notificationBar.MouseOut += new TomShane.Neoforce.Controls.MouseEventHandler(OnLoseFocus); }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Methods /////////// //////////////////////////////////////////////////////////////////////////// protected override void Initialize() { base.Initialize(); // Create and setup Window control. window = new Window(Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. button = new Button(Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; // Add the window control to the manager processing queue. Manager.Add(window); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// protected virtual void InitMainWindow() { if (mainWindow != null) { if (!mainWindow.Initialized) { mainWindow.Init(); } mainWindow.Alpha = 255; mainWindow.Width = manager.TargetWidth; mainWindow.Height = manager.TargetHeight; mainWindow.Shadow = false; mainWindow.Left = 0; mainWindow.Top = 0; mainWindow.CloseButtonVisible = true; mainWindow.Resizable = false; mainWindow.Movable = false; mainWindow.Text = this.Window.Title; mainWindow.Closing += new WindowClosingEventHandler(MainWindow_Closing); mainWindow.ClientArea.Draw += new DrawEventHandler(MainWindow_Draw); mainWindow.BorderVisible = mainWindow.CaptionVisible = (!systemBorder && !Graphics.IsFullScreen) || (Graphics.IsFullScreen && fullScreenBorder); mainWindow.StayOnBack = true; manager.Add(mainWindow); mainWindow.SendToBack(); } }
public override void Initialize() { creditWindow = new Window(manager); creditWindow.Init(); creditWindow.Width = 300; creditWindow.Height = 200; creditWindow.Center(); creditWindow.Text = "Credits"; creditWindow.Visible = false; creditWindow.IconVisible = false; manager.Add(creditWindow); textBox = new TextBox(manager); textBox.Init(); textBox.Parent = creditWindow; textBox.Left = 8; textBox.Top = 8; textBox.Width = creditWindow.ClientArea.Width - 16; textBox.Height = creditWindow.Height - 48; textBox.Anchor = Anchors.All; textBox.Mode = TextBoxMode.Multiline; textBox.ReadOnly = true; string text = "Makers of The Little Cheese Boy Editor:\n"+ GetCreators(); text += "\n\nSpecial Thanks to Alexander Brodén and \nMattias Liljeson for their great work \non The Little Cheese Boy!"; textBox.Text = text; textBox.ScrollBars = ScrollBars.None; textBox.CanFocus = false; textBox.TextColor = Color.White; }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ngui = Gui as NeoforceGui; manager = ngui.Manager; Window window = new Window(manager); window.Init(); window.Text = "Options"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; Button button = new Button(manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click); manager.Add(window); }
public override void Initialize() { ContentSystem contentSystem = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]); Viewport viewport = contentSystem.GetViewport(); tilemapWindow = new Window(manager); tilemapWindow.Init(); tilemapWindow.Text = "Tilemap"; if (enableWindowAutoSize) { tilemapWindow.Resizable = false; tilemapWindow.Movable = false; tilemapWindow.Height = viewport.Height; tilemapWindow.MouseOver += new TomShane.Neoforce.Controls.MouseEventHandler(OnMouseOverBehavior); tilemapWindow.MouseOut += new TomShane.Neoforce.Controls.MouseEventHandler(OnMouseOutBehavior); } else { // tilemapWindow.Height = 196; tilemapWindow.Height = viewport.Height; } tilemapWindow.Width = 210; tilemapWindow.Visible = true; tilemapWindow.Top = viewport.Height - tilemapWindow.Height; tilemapWindow.Left = 0; // (int)((float)viewport.Width -tilemapWindow.Width); tilemapWindow.CloseButtonVisible = false; tilemapWindow.MaximumHeight = 960 + 54; tilemapWindow.MaximumWidth = 960 + 32; tilemapWindow.IconVisible = false; tilemapWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); manager.Add(tilemapWindow); tilemap = new TilemapContainer(manager, m_content); tilemap.gridImage = contentSystem.LoadTexture("TileSheets/grid"); tilemap.tileSelectorImage = contentSystem.LoadTexture("TileSheets/tileSelector"); tilemap.Parent = tilemapWindow; tilemap.windowParent = tilemapWindow; tilemap.Width = 960; tilemap.Height = 960; tilemap.Parent = tilemapWindow; tilemap.gridColor = Color.Black; tilemap.CanFocus = false; tilemap.Click += new TomShane.Neoforce.Controls.EventHandler(OnClick); tilemap.DoubleClicks = false; tilemap.MouseDown += new TomShane.Neoforce.Controls.MouseEventHandler(OnMouseDown); tilemap.MouseDown += new MouseEventHandler(PanningMouseDownBehavior); tilemap.MouseMove += new MouseEventHandler(PanningMouseMoveBehavior); tilemap.MouseUp += new MouseEventHandler(PanningMouseUpBehavior); tilemap.MouseOut += new TomShane.Neoforce.Controls.MouseEventHandler(lostFocusBehavior); if (enableWindowAutoSize) { tilemap.MouseOver += new TomShane.Neoforce.Controls.MouseEventHandler(OnMouseOverBehavior); tilemap.MouseOut += new TomShane.Neoforce.Controls.MouseEventHandler(OnMouseOutBehavior); } tilemap.Init(contentSystem.GetViewportSize()); }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Methods /////////// //////////////////////////////////////////////////////////////////////////// protected override void Initialize() { base.Initialize(); // Load image image = Content.Load<Texture2D>("Content\\Image"); // Creates and initializes window window = new Window(manager); window.Init(); window.Text = "ScrollBars"; window.Width = 360; window.Height = 360; window.Center(); window.Visible = true; // Setup of the vertical scrollbar vert = new ScrollBar(manager, Orientation.Vertical); vert.Init(); vert.Parent = window; vert.Top = 0; vert.Left = window.ClientWidth - vert.Width ; vert.Height = window.ClientHeight - vert.Width; vert.Value = 0; vert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom; // Setup of the horizontal scrollbar horz = new ScrollBar(manager, Orientation.Horizontal); horz.Init(); horz.Parent = window; horz.Left = 0; horz.Top = window.ClientHeight - horz.Height; horz.Width = window.ClientWidth - vert.Width; horz.Value = 0; horz.Anchor = Anchors.Left | Anchors.Right | Anchors.Bottom; // Creates imagebox in the client area box = new ImageBox(manager); box.Init(); box.Parent = window; box.Left = 0; box.Top = 0; box.Width = window.ClientWidth - vert.Width; box.Height = window.ClientHeight - horz.Height; box.Image = image; box.Anchor = Anchors.All; // Add window to manager processing manager.Add(window); // Bind events window.Resize += new ResizeEventHandler(Recalc); vert.ValueChanged += new EventHandler(ValueChanged); horz.ValueChanged += new EventHandler(ValueChanged); Recalc(this, null); // Calculates initial properties of the scrollbars }
public override void LoadContent(ContentManager contentloader) { _guiman = new Manager(_gamemanager.Game, _gamemanager.Graphics, "Default"); _guiman.Initialize(); _settingsmenu = new Window(_guiman); _settingsmenu.Init(); _settingsmenu.Resizable = false; _settingsmenu.Movable = false; _settingsmenu.CloseButtonVisible = false; _settingsmenu.Text = "Settings Menu"; _settingsmenu.Width = 300; _settingsmenu.Height = 400; _settingsmenu.Center(); _settingsmenu.Visible = true; _settingsmenu.BorderVisible = true; _settingsmenu.Cursor = _guiman.Skin.Cursors["Default"].Resource; _back = new Button(_guiman); _back.Init(); _back.Text = "Go Back"; _back.Width = 200; _back.Height = 50; _back.Left = 50; _back.Top = 300; _back.Anchor = Anchors.Bottom; _back.Parent = _settingsmenu; _playername = new TextBox(_guiman); _playername.Init(); _playername.Text = _gamemanager.Pbag.Player.Name; _playername.Width = 200; _playername.Height = 50; _playername.Left = 50; _playername.Top = 0; _playername.Anchor = Anchors.Bottom; _playername.Parent = _settingsmenu; _volume = new ScrollBar(_guiman, Orientation.Horizontal); _volume.Init(); //Todo check why volume.value is reseting it to 50 :S _volume.Value = _gamemanager.Audiomanager.GetVolume(); _volume.Range = 100; _volume.PageSize = 10; _volume.StepSize = 1; _volume.Width = 200; _volume.Height = 50; _volume.Left = 50; _volume.Top = 50; _volume.Anchor = Anchors.Bottom; _volume.Parent = _settingsmenu; _guiman.Add(_settingsmenu); _gamemanager.Game.IsMouseVisible = true; }
private IGameState[] CardSelected(Manager manager, GameInfo gameInfo, Story story) { var storyGraphic = gameInfo.Content.Load<Texture2D>(story.StoryGraphic); const int spacing = 20; const int width = 400; var yPos = spacing; var window = new Window(manager) { Text = String.Format("Your fate has been decided! You spun a {0} story", story.StoryType), AutoScroll = false }; window.Init(); var storybox = new GroupBox(manager) { Width = 400, Height = 100, Left = 30, Top = yPos, Parent = window, Color = story.StoryType == StoryType.Red ? Color.Red : Color.Black, Text = ""+story.StoryType, TextColor = Color.White }; storybox.Init(); var storylabel = new Label(manager) { Width = storybox.Width, Height = storybox.Height, Parent = storybox, Text = story.DisplayedMessage, Left = spacing, StayOnTop = true }; storylabel.Init(); var imageBox = new ImageBox(manager) { Left = window.Width/2-100, Top = 140, Image = storyGraphic, Color = Color.White, Width = storyGraphic.Width, Height = storyGraphic.Height }; imageBox.Init(); window.Add(imageBox); var close = new Button(manager) { Text = "OK", Top = window.Height-50-spacing, Left = window.Width / 2 - 50, Parent = window }; close.Init(); close.Click += (sender, args) => window.Close(); window.Closed += (sender, args) => WindowClosed(gameInfo); manager.Add(window); if (story.Positive) gameInfo.Content.Load<SoundEffect>("Sounds/applause").Play(); else gameInfo.Content.Load<SoundEffect>("Sounds/sadtrombone").Play(); return new[] { story.PureLogic, waitState }; }
private void CreateMessage(Manager manager, GameInfo gameInfo, IGameState waitState) { var currentPlayer = gameInfo.CurrentPlayer; var messageWindow = new Window(manager) { Text = "Pay Day!", AutoScroll = false, CloseButtonVisible = false}; messageWindow.Init(); messageWindow.SetSize(400, 230); var message = new Label(manager) { Text = "Well Done! you have received your Pay Day! \nBelow are the details.", Width = 400, Height = 40, Left = 5, Top = 10 }; message.Init(); message.Parent = messageWindow; var careerImage = gameInfo.Content.Load<Texture2D>("Images/career_icons/" + gameInfo.CurrentPlayer.CurrentCareer); var career = new ImageBox(manager) { Image = careerImage, Width = careerImage.Width, Height = careerImage.Height, Top = 50, Left = 16, StayOnBack = true }; career.Init(); career.Parent = messageWindow; var icon = new ImageBox(manager) { Image = gameInfo.Content.Load<Texture2D>("Images/payday"), Top = 60, Left = career.Left + career.Width + 70 }; icon.Init(); icon.Parent = messageWindow; var job = new Label(manager) { Text = "Current Career:\n" + currentPlayer.CurrentCareer.Title, Top = 110, Left = 10, Width = 150, Height = 50 }; job.Init(); job.Parent = messageWindow; var salary = new Label(manager) { Text = String.Format("Level {1} Promotion\nReceived: ${0:N0}", currentPlayer.CurrentCareer.Salary[currentPlayer.PromotionLevel], currentPlayer.PromotionLevel + 1), Top = 110, Left = 140, Width = 140, Height = 50 }; salary.Init(); salary.Parent = messageWindow; var close = new Button(manager) { Text = "OK", Top = 160, Left = messageWindow.Width / 2 - 50 }; close.Init(); close.Parent = messageWindow; close.Click += (sender, args) => { messageWindow.Close(); WindowClosed(gameInfo, waitState); }; messageWindow.Closed += (sender, args) => WindowClosed(gameInfo, waitState); gameInfo.Manager.Add(messageWindow); messageWindow.Init(); gameInfo.Content.Load<SoundEffect>("Sounds/coins").Play(); }
public override void Initialize() { #region Initialize Window //Create Window m_Window = new Window(Global.GUIManager); m_Window.Init(); m_Window.CloseButtonVisible = false; m_Window.Movable = false; m_Window.StayOnBack = true; m_Window.Resizable = false; m_Window.Text = "Pause Game"; m_Window.Top = 150; m_Window.Left = 170; m_Window.Width = 450; m_Window.Height = 330; m_Panel.Add(m_Window); Global.GUIManager.Add(m_Window); #endregion #region Initialize Buttons m_PauseButtons = new Button[(m_Editor) ? 4 : 3]; for (int i = 0; i < m_PauseButtons.Length; i++) { //Create buttons m_PauseButtons[i] = new Button(Global.GUIManager); m_PauseButtons[i].Text = Global.PAUSE_MENU[i]; m_PauseButtons[i].Top = Global.PAUSEBUTTON_TOP + (i * Global.PAUSEBUTTON_SPACE); m_PauseButtons[i].Left = Global.PAUSEBUTTON_LEFT; m_PauseButtons[i].Width = Global.PAUSEBUTTON_WIDTH; m_PauseButtons[i].Init(); //Add the buttons m_Panel.Add(m_PauseButtons[i]); Global.GUIManager.Add(m_PauseButtons[i]); //Set event handler m_PauseButtons[i].Click += PauseChoose; } #endregion //Create Help label m_Help = new Label(Global.GUIManager); m_Help.Init(); m_Help.Text = Global.PAUSE_HELP; m_Help.Top = 190; m_Help.Left = 200; m_Help.Width = 300; m_Help.Height = 280; //Add it to the m_Panel.Add(m_Help); Global.GUIManager.Add(m_Help); //TODO: Fix layout. }
public void Init() { window = new Window(manager) ; window.Init(); window.Text = "Server List"; window.Width = 700; window.Height = 500; window.Center(); window.Visible = true; window.CloseButtonVisible = false; play = new Button(manager); play.Init(); play.Text = "Play"; play.Width = 100; play.Height = 24; play.Left = window.Width - play.Width - 40; play.Top = window.Height - 80; play.Anchor = Anchors.Right; play.Parent = window; refresh = new Button(manager); refresh.Init(); refresh.Text = "Refresh Server List"; refresh.Width = 150; refresh.Height = 24; refresh.Left = 30; refresh.Top = window.Height - 130; refresh.Anchor = Anchors.Left; refresh.Parent = window; back = new Button(manager); back.Init(); back.Text = "Back"; back.Width = 75; back.Height = 24; back.Left = 30; back.Top = window.Height - 80; back.Anchor = Anchors.Left; back.Parent = window; listview = new ListView(manager, headers); listview.Init(); listview.Width = 630; listview.Height = 300; listview.Left = 30; listview.Top = 40; listview.Anchor = Anchors.All; listview.HideSelection = false; listview.Parent = window; listview.Items = data; listview.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(listview_ItemIndexChanged); }
/// <summary> /// Shows the simple input dialog. /// </summary> public void ShowSimpleInputDialog(Manager manager, string caption, string text, string initialValue, TomShane.Neoforce.Controls.EventHandler okBtnEventHandler) { window = new Window(manager); window.Init(); window.Width = 450; window.Height = 150; window.Text = caption; window.Closing += OnSimpleInputDialogClosing; window.Visible = true; Label label = new Label(manager); label.Init(); label.Text = text; label.Width = 400; label.Height = 20; label.Left = 5; label.Top = 5; label.Parent = window; TextBox textBox = new TextBox(manager); textBox.Init(); textBox.Width = 400; textBox.Height = 20; textBox.Left = 5; textBox.Top = 40; textBox.Text = initialValue; textBox.Parent = window; Button btnSimpleInputDialogOk = new Button(manager); btnSimpleInputDialogOk.Init(); btnSimpleInputDialogOk.Text = "Ok"; btnSimpleInputDialogOk.Width = 100; btnSimpleInputDialogOk.Height = 30; btnSimpleInputDialogOk.Left = 5; btnSimpleInputDialogOk.Top = 75; btnSimpleInputDialogOk.Click += okBtnEventHandler; btnSimpleInputDialogOk.Click += OnClickBtnSimpleInputDialogOk; btnSimpleInputDialogOk.Tag = textBox; // Textbox as Tag, to access the value btnSimpleInputDialogOk.Parent = window; Button btnSimpleInputDialogCancel = new Button(manager); btnSimpleInputDialogCancel.Init(); btnSimpleInputDialogCancel.Text = "Cancel"; btnSimpleInputDialogCancel.Width = 100; btnSimpleInputDialogCancel.Height = 30; btnSimpleInputDialogCancel.Left = 110; btnSimpleInputDialogCancel.Top = 75; btnSimpleInputDialogCancel.Click += OnClickBtnSimpleInputDialogCancel; btnSimpleInputDialogCancel.Parent = window; manager.Add(window); }
public override void LoadContent(ContentManager contentloader) { _guiman = new Manager(_gamemanager.Game, _gamemanager.Graphics, "Default"); _guiman.Initialize(); _mainmenu = new Window(_guiman); _mainmenu.Init(); _mainmenu.Resizable = false; _mainmenu.Movable = false; _mainmenu.CloseButtonVisible = false; _mainmenu.Text = "Main Menu"; _mainmenu.Width = 300; _mainmenu.Height = 400; _mainmenu.Center(); _mainmenu.Visible = true; _mainmenu.BorderVisible = true; //mainmenu.Cursor = guiman.Skin.Cursors["Default"].Resource; _play = new Button(_guiman); _play.Init(); _play.Text = "Play"; _play.Width = 200; _play.Height = 50; _play.Left = 50; _play.Top = 0; _play.Anchor = Anchors.Bottom; _play.Parent = _mainmenu; _settings = new Button(_guiman); _settings.Init(); _settings.Text = "Settings"; _settings.Width = 200; _settings.Height = 50; _settings.Left = 50; _settings.Top = 50; _settings.Anchor = Anchors.Bottom; _settings.Parent = _mainmenu; _exit = new Button(_guiman); _exit.Init(); _exit.Text = "Exit"; _exit.Width = 200; _exit.Height = 50; _exit.Left = 50; _exit.Top = 100; _exit.Anchor = Anchors.Bottom; _exit.Parent = _mainmenu; _guiman.Cursor = _guiman.Skin.Cursors["Default"].Resource; _guiman.Add(_mainmenu); _gamemanager.Game.IsMouseVisible = true; }
public GamemodeWindow(Sidebar sidebar) { this.manager = sidebar.manager; this.sidebar = sidebar; window = new Window(manager); window.Init(); window.Left = sidebar.master.Left; window.Width = sidebar.master.Width; window.Top = 0; window.Height = 600; window.Text = "Game Mode"; manager.Add(window); TitlePanel titlePanel = new TitlePanel(sidebar, window, "Game Mode", true); titlePanel.btnBack.Click += (s, e) => window.Close(); HeightCounter += titlePanel.topPanel.Height + LeftPadding * 2; lblMode = new Label(manager); lblMode.Init(); lblMode.Parent = window; lblMode.Top = HeightCounter; lblMode.Left = LeftPadding; lblMode.Text = "Game Mode Options"; lblMode.Width = 120; lblMode.TextColor = Color.Black; //cbMode = new ComboBox(manager); //cbMode.Init(); //cbMode.Parent = window; //cbMode.Left = lblMode.Left + lblMode.Width; //cbMode.Top = HeightCounter; //cbMode.Width = 100; // //foreach (GameModes m in Enum.GetValues(typeof(GameModes))) //{ // cbMode.Items.Add(m); //} HeightCounter += lblMode.Height + LeftPadding * 3; insViewModes = new InspectorView(sidebar, window, LeftPadding, HeightCounter); insViewModes.Width -= 20; insViewModes.Height -= 100; HeightCounter += insViewModes.Height + LeftPadding * 3; insViewModes.SetRootObject(OrbIt.globalGameMode); //insViewGlobal = new InspectorView(sidebar, window, LeftPadding, HeightCounter); //insViewGlobal.Width -= 20; //insViewGlobal.Height -= 100; window.Refresh(); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } NeoforceGui guiManager = this.Gui as NeoforceGui; System.Diagnostics.Debug.Assert(guiManager != null); // Create and setup Window control. Window window = new Window(guiManager.Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. Button button = new Button(guiManager.Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; button.Click += new TomShane.Neoforce.Controls.EventHandler(button_Click); // Add the window control to the manager processing queue. guiManager.Manager.Add(window); this.World.CameraManager.AddCamera(new CameraFirstPerson(false,GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
public ConsoleControl(StackEngine engine, ConsoleMessageEventHandler messageSent, KeyEventHandler keyUp) { Manager = engine.Renderer.GUIManager; WindowUIControl = new TomShane.Neoforce.Controls.Window(Manager); WindowUIControl.Init(); WindowUIControl.Text = "STACK Engine Console"; WindowUIControl.Width = 480; WindowUIControl.Resizable = true; WindowUIControl.MinimumHeight = 240; WindowUIControl.MinimumWidth = 320; WindowUIControl.Height = 200; WindowUIControl.IconVisible = false; WindowUIControl.Alpha = 215; WindowUIControl.CloseButtonVisible = false; WindowUIControl.Closing += (object sender, WindowClosingEventArgs e) => e.Cancel = true; WindowUIControl.Visible = false; WindowUIControl.Color = Color.Black; WindowUIControl.Center(engine.Game.VirtualResolution); ConsoleUIControl = new TomShane.Neoforce.Controls.Console(Manager); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.System, "System", Color.White)); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Debug, "Debug", Color.LightGray)); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Error, "Error", Color.IndianRed)); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Notice, "Notice", Color.DimGray)); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.Warning, "Warning", Color.DeepPink)); ConsoleUIControl.Channels.Add(new ConsoleChannel((byte)Console.Channel.User, "User", Color.Gray)); ConsoleUIControl.SelectedChannel = (byte)Console.Channel.User; ConsoleUIControl.ChannelsVisible = false; ConsoleUIControl.ClientArea.Left = 10; ConsoleUIControl.Color = Color.Black; ConsoleUIControl.MessageFormat = ConsoleMessageFormats.TimeStamp; ConsoleUIControl.TextBox.Color = Color.Black; ConsoleUIControl.Sender = "User"; ConsoleUIControl.TextBox.KeyUp += keyUp; ConsoleUIControl.TextBox.AutoSelection = false; ConsoleUIControl.Width = WindowUIControl.ClientWidth - ConsoleUIControl.Left; ConsoleUIControl.Height = WindowUIControl.ClientHeight; ConsoleUIControl.Parent = WindowUIControl; ConsoleUIControl.MessageSent += messageSent; WindowUIControl.Resize += new ResizeEventHandler(OnWindowResize); Manager.Add(WindowUIControl); }
/// <summary> /// Shows the chose enum dialog. /// </summary> public void ShowChooseEnumDialog(Manager manager, string caption, Type type, EnumChooseEventHandler btnEventHandler) { _type = type; _handler = btnEventHandler; window = new Window(manager); window.Init(); window.Width = 175; window.Text = caption; window.Icon = IconProvider.ApplicationIcon; window.CaptionVisible = true; window.Closing += OnChooseEnumDialogClosing; window.Visible = true; if (!type.IsEnum) { CloseDialog(); } else { int offsetY = 5; foreach (object value in Enum.GetValues(type)) { string name = value.ToString(); Button btnEnumName = new Button(manager); btnEnumName.Init(); btnEnumName.Text = name; btnEnumName.Width = 150; btnEnumName.Height = 30; btnEnumName.Left = 5; btnEnumName.Top = offsetY; btnEnumName.Tag = value; btnEnumName.Click += OnClickBtnEnumName; btnEnumName.Parent = window; offsetY += 35; } window.Height = offsetY + 35; manager.Add(window); } }
public override void Initialize() { Viewport viewport = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]).GetViewport(); //Notification Bar currentToolWindow = new Window(manager); currentToolWindow.Init(); currentToolWindow.Text = "Current Tool"; currentToolWindow.Height = 100; currentToolWindow.Width = 100; currentToolWindow.Visible = true; currentToolWindow.Top = 10; currentToolWindow.Left = viewport.Width-currentToolWindow.Width; currentToolWindow.CloseButtonVisible = false; currentToolWindow.AutoScroll = false; currentToolWindow.Resizable = false; currentToolWindow.BorderVisible = false; currentToolWindow.Movable = false; currentToolWindow.Visible = false; manager.Add(currentToolWindow); m_container = new CurrentToolContainer(manager, currentToolWindow, m_content); m_container.Init(); m_container.Width = currentToolWindow.Width;// tilemap.tilemapImage.Width; m_container.Height = currentToolWindow.Height;// tilemap.tilemapImage.Height; m_container.Parent = currentToolWindow; m_container.CanFocus = false; m_container.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); //Initialize some hotkeys EventSystem ev = (EventSystem)world.SystemManager.GetSystem<EventSystem>()[0]; EventData ev1 = new EventData(SetCurrentToolCB, Tool.ROAD_TOOL); EventData ev2 = new EventData(SetCurrentToolCB, Tool.PAINT_TOOL); EventData ev3 = new EventData(SetCurrentToolCB, Tool.ERASE_TOOL); ev.addEvent(ev1); ev.addEvent(ev2); ev.addEvent(ev3); ev.setHotKey(ev1, Microsoft.Xna.Framework.Input.Keys.D1); ev.setHotKey(ev2, Microsoft.Xna.Framework.Input.Keys.D2); ev.setHotKey(ev3, Microsoft.Xna.Framework.Input.Keys.D3); }
//////////////////////////////////////////////////////////////////////////// public void Init() { // Create and setup Window control. window = new Window(manager); window.Init(); window.Text = "Please Wait"; window.Width = 300; window.Height = 175; window.Center(); window.Visible = true; window.CloseButtonVisible = false; text = new Label(manager); text.Init(); text.Text = ""; text.Width = 250; text.Height = 24; text.Left = 20; text.Top = 20; text.Anchor = Anchors.Left; text.Parent = window; bar = new ProgressBar(manager); bar.Init(); bar.Width = 260; bar.Height = 15; bar.Left = 20; bar.Top = 60; bar.Anchor = Anchors.Left; bar.Parent = window; bar.Value = 0; bar.Mode = ProgressBarMode.Default; cancel = new Button(manager); cancel.Init(); cancel.Left = window.Width - cancel.Width - 20; cancel.Top = 110; cancel.Text = "Cancel"; cancel.Anchor = Anchors.Right; cancel.Parent = window; }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Methods /////////// //////////////////////////////////////////////////////////////////////////// protected override void Initialize() { base.Initialize(); // Controls setup. window = new Window(manager); window.Init(); window.Text = "Addon Controls"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; button = new Button(manager); button.Init(); button.Text = "DEFAULT"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - 4 - button.Width; button.Top = window.ClientHeight - button.Height - 32; button.Anchor = Anchors.Bottom; button.Parent = window; button.Focused = true; // Here we construct our custom button. custom = new CustomButton(manager); custom.Init(); custom.Text = "CUSTOM"; custom.Width = 72; custom.Height = 24; custom.Left = (window.ClientWidth / 2) + 4; custom.Top = window.ClientHeight - button.Height - 32; custom.Anchor = Anchors.Bottom; custom.Parent = window; custom.Cursor = manager.Skin.Cursors["Custom.Cursor"].Resource; manager.Add(window); }
/// <summary> /// Initialize the components that make up the window, including the window itself. /// </summary> private void Initialize() { Window = new Window(manager); Window.Init(); Window.Text = "Console"; Window.Left = windowFrame.X; Window.Top = windowFrame.Y; Window.Width = windowFrame.Width; Window.Height = windowFrame.Height; Window.Alpha = 200; Window.BorderVisible = true; Window.CaptionVisible = false; Window.BackColor = Color.Black; Window.Center(); TextArea = new ConsoleArea(manager); TextArea.Init(); TextArea.Text = ""; TextArea.Width = windowFrame.Width - 15; TextArea.Height = windowFrame.Height - 40; TextArea.Enabled = true; TextArea.CanFocus = false; TextArea.BackgroundColor = Color.Black; TextArea.TextColor = Color.Green; TextArea.TextPosition = ConsoleArea.TextOrigin.BOTTOM; TextArea.Parent = Window; Input = new TextBox(manager); Input.Init(); Input.Text = ""; Input.Color = Color.Black; Input.TextColor = Color.Green; Input.Top = TextArea.Top + TextArea.Height + 2; Input.Width = windowFrame.Width - 15; Input.Height = 20; Input.Enabled = true; Input.Parent = Window; }
public Window CreateGameResult() { var resultWindow = new Window(_gameInfo.Manager) { Text = "Game Results", Height = 400, AutoScroll = true, Resizable = false }; resultWindow.Closed += (sender, args) => { MenuButton.Enabled = true; }; resultWindow.BringToFront(); resultWindow.Init(); var tabbedControl = new EndGameResults().GetTabbedControl(_gameInfo.Manager, _gameInfo.PlayerList); tabbedControl.Init(); tabbedControl.MinimumHeight = resultWindow.Height - 40; tabbedControl.MinimumWidth = resultWindow.Width - 40; tabbedControl.Parent = resultWindow; ControlManager.Add(resultWindow); tabbedControl.SelectedIndex = 0; return resultWindow; }
public override void Initialize() { Point screenSize = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]).GetViewportSize(); confirmWindow = new Window(manager); confirmWindow.Init(); confirmWindow.Text = "Would you like to exit?"; confirmWindow.Width = 248; confirmWindow.Height = 48; confirmWindow.Center(); confirmWindow.Visible = false; confirmWindow.Resizable = false; confirmWindow.IconVisible = false; confirmWindow.CloseButtonVisible = false; confirmWindow.Closing += new WindowClosingEventHandler(WindowCloseBehavior); manager.Add(confirmWindow); acceptButton = new Button(manager); acceptButton.Init(); acceptButton.Parent = confirmWindow; acceptButton.Width = 100; acceptButton.Height = 24; acceptButton.Click +=new TomShane.Neoforce.Controls.EventHandler(ConfirmedExit); acceptButton.Left = 12; acceptButton.Top = 8; acceptButton.Text = "Yes"; cancelButton = new Button(manager); cancelButton.Init(); cancelButton.Parent = confirmWindow; cancelButton.Width = 100; cancelButton.Height = 24; cancelButton.Click += new TomShane.Neoforce.Controls.EventHandler(CancelExit); cancelButton.Left = 124; cancelButton.Top = 8; cancelButton.Text = "No thanks"; }
private void CreateWelcomeMessage() { var padding = 15; var window = new Window(_gameInfo.Manager) { Width = 400, Height = 300, Text = "Welcome to Game of Life!", AutoScroll = false, Resizable = false }; var label = new Label(_gameInfo.Manager) { Width = window.Width, Parent = window, Height = 180, Top = padding, Left = padding, Text = "You are about to begin the game. \nThe camera can be controlled using the following keys: \n\n -W A S D \n -Up Down Left Right \n\nAny active game objects visible on screen will glow. \n\nObjects outside of the visible area will have \nclickable arrows pointing to them. \n\nClicking the arrow will adjust the camera automatically. \n\nClose this window to begin." }; label.Init(); var close = new Button(_gameInfo.Manager) { Text = "Close", Parent = window, Top = window.Height - 75, Left = window.Width / 2 - 50 }; close.Click += (sender, args) => window.Close(); window.Closed += (sender, args) => BeginGame(); close.Init(); window.Init(); _gameInfo.Manager.Add(window); }
public override void Initialize() { ContentSystem contentSystem = ((ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]); m_actionsystem = ((ActionSystem)world.SystemManager.GetSystem<ActionSystem>()[0]); Viewport viewport = contentSystem.GetViewport(); int toolbarwindowh = 360; undoTreeWindow = new Window(manager); undoTreeWindow.Init(); undoTreeWindow.Text = "History"; undoTreeWindow.Width = 160; undoTreeWindow.Height = (int)((float)viewport.Height - toolbarwindowh); undoTreeWindow.Top = toolbarwindowh; // height of toolbarwindow undoTreeWindow.Left = viewport.Width - undoTreeWindow.Width; undoTreeWindow.Visible = true; undoTreeWindow.CloseButtonVisible = false; undoTreeWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); undoTreeWindow.IconVisible = false; undoTreeWindow.AutoScroll = false; //toolbarWindow.BorderVisible = false; //toolbar.Movable = false; manager.Add(undoTreeWindow); undoTreeContainer = new UndoTreeContainer(manager, undoTreeWindow, m_gd, m_content); undoTreeContainer.Init(); undoTreeContainer.Width = viewport.Width-16; undoTreeContainer.Height = viewport.Height-16; undoTreeContainer.Parent = undoTreeWindow; undoTreeContainer.CanFocus = false; undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnContainerClickBehavior); undoTreeContainer.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerScrollBehaviour); //undoTreeContainer.MousePress += new TomShane.Neoforce.Controls.MouseEventHandler(OnContainerPanBehaviour); undoTreeContainer.MouseMove += new MouseEventHandler(OnContainerPanBehaviour); undoTreeContainer.DoubleClicks = false; /* viewMode = new RadioButton(manager); viewMode.Init(); viewMode.Parent = undoTreeWindow; viewMode.Width = undoTreeWindow.Width / 2; viewMode.Height = 24; viewMode.Left = 0; viewMode.Top = 24; viewMode.Checked = true; viewMode.Text = "Tree view"; viewMode.Click += new TomShane.Neoforce.Controls.EventHandler(ViewModeBehaviour); * */ sbVert = new ScrollBar(manager, Orientation.Vertical); sbVert.Init(); sbVert.Detached = false; sbVert.Parent = undoTreeWindow; sbVert.Height = undoTreeWindow.ClientHeight-16; sbVert.SetPosition(undoTreeWindow.ClientWidth - sbVert.Width, 0); sbVert.Anchor = Anchors.Top | Anchors.Right | Anchors.Bottom; sbVert.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedY); // sbVert.MouseScroll += new TomShane.Neoforce.Controls.MouseEventHandler(ScrollBarMouseScroll); sbVert.Range = scrollMax; sbVert.PageSize = 0; sbVert.Value = 0; sbVert.Visible = true; undoTreeWindow.Add(sbVert); sbHorz = new ScrollBar(manager, Orientation.Horizontal); sbHorz.Init(); sbHorz.Detached = false; sbHorz.Parent = undoTreeWindow; sbHorz.Width = undoTreeWindow.ClientWidth-16; sbHorz.SetPosition(0, undoTreeWindow.ClientHeight - sbHorz.Height); sbHorz.Anchor = Anchors.Left | Anchors.Right | Anchors.Bottom; sbHorz.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(ScrollBarValueChangedX); sbHorz.Range = scrollMax; sbHorz.PageSize = 0; sbHorz.Value = 0; sbHorz.Visible = true; undoTreeWindow.Add(sbHorz); // undoTreeContainer.Click += new TomShane.Neoforce.Controls.EventHandler(OnClick); }
public override void Initialize() { ContentSystem sys = (ContentSystem)world.SystemManager.GetSystem<ContentSystem>()[0]; Viewport viewport = sys.GetViewport(); toolbarWindow = new Window(manager); toolbarWindow.Init(); toolbarWindow.Text = "Toolbar"; toolbarWindow.Width = 160; toolbarWindow.Height = 360; toolbarWindow.Top = 0; toolbarWindow.IconVisible = false; toolbarWindow.Left = viewport.Width - toolbarWindow.Width; toolbarWindow.Resizable = false; toolbarWindow.AutoScroll = false; toolbarWindow.CloseButtonVisible = false; toolbarWindow.BorderVisible = true; toolbarWindow.Click += new TomShane.Neoforce.Controls.EventHandler(OnWindowClickBehavior); toolbarWindow.Movable = true; manager.Add(toolbarWindow); int toolHeight = 50; int clientW = toolbarWindow.ClientWidth; int toolWidth = toolHeight; int toolMargin = 5; roadTool = new ImageBasedButton(manager); roadTool.Init(); roadTool.Parent = toolbarWindow; roadTool.Width = toolWidth; roadTool.Height = toolHeight; roadTool.Left = clientW / 2 - toolWidth / 2; roadTool.Top = toolMargin; roadTool.Text = ""; roadTool.image = sys.LoadTexture("RoadIcon"); roadTool.Click += new TomShane.Neoforce.Controls.EventHandler(RoadToolBehavior); roadTool.Pushed = true; roadTool.Mode = ButtonMode.PushButton; eraserTool = new ImageBasedButton(manager); eraserTool.Init(); eraserTool.Parent = toolbarWindow; eraserTool.Width = toolWidth; eraserTool.Height = toolHeight; eraserTool.Left = clientW / 2 - toolWidth/2; eraserTool.Top = toolHeight + toolMargin*2; eraserTool.Text = ""; eraserTool.image = sys.LoadTexture("EraserIcon"); eraserTool.Click += new TomShane.Neoforce.Controls.EventHandler(EraseToolBehavior); paintTool = new ImageBasedButton(manager); paintTool.Init(); paintTool.Parent = toolbarWindow; paintTool.Width = toolWidth; paintTool.Height = toolHeight; paintTool.Left = clientW / 2 - toolWidth / 2; paintTool.Top = (toolHeight*2 + toolMargin * 3); paintTool.Text = ""; paintTool.image = sys.LoadTexture("PaintingIcon"); paintTool.Click += new TomShane.Neoforce.Controls.EventHandler(PaintToolBehavior); // int top = (toolHeight * 3 + toolMargin * 4) +10; pathsValid = new CheckBox(manager); pathsValid.Init(); pathsValid.Parent = toolbarWindow; pathsValid.Text = ""; pathsValid.Left = clientW/2 - 15/2 - 16; pathsValid.Top = top; pathsValid.Width = 15; pathsValid.Enabled = false; pathsValid.TextColor = Color.Red; pathsValid.ToolTip = new CustomToolTip(manager); pathsValid.ToolTip.Parent = pathsValid; pathsValid.ToolTip.Init(); pathsValid.ToolTip.Text = "0"; pathsValid.ToolTip.TextColor = Color.White; pathsValid.ToolTip.Visible = false; pathsValid.ToolTip.Color = Color.Red; playerValid = new CheckBox(manager); playerValid.Init(); playerValid.Parent = toolbarWindow; playerValid.Text = ""; playerValid.Left = clientW / 2 - 15/2; playerValid.Top = top; playerValid.Width = 15; playerValid.Enabled = false; playerValid.TextColor = Color.Red; playerValid.ToolTip = new CustomToolTip(manager); playerValid.ToolTip.Parent = playerValid; playerValid.ToolTip.Init(); playerValid.ToolTip.Text = "1"; playerValid.ToolTip.TextColor = Color.White; playerValid.ToolTip.Visible = false; playerValid.ToolTip.Color = Color.Red; switchesValid = new CheckBox(manager); switchesValid.Init(); switchesValid.Parent = toolbarWindow; switchesValid.Text = ""; switchesValid.Left = clientW/2 - 15/2 +16; switchesValid.Top = top; switchesValid.Width = 15; switchesValid.Enabled = false; switchesValid.TextColor = Color.Red; switchesValid.ToolTip = new CustomToolTip(manager); switchesValid.ToolTip.Parent = switchesValid; switchesValid.ToolTip.Init(); switchesValid.ToolTip.Text = "2"; switchesValid.ToolTip.TextColor = Color.White; switchesValid.ToolTip.Visible = false; switchesValid.ToolTip.Color = Color.Red; // int btnW = (int)(toolbarWindow.ClientWidth * 0.8f); exportMap = new Button(manager); exportMap.Init(); exportMap.Parent = toolbarWindow; exportMap.Text = "Export Map"; exportMap.Width = btnW; exportMap.Height = 24; exportMap.Left = clientW / 2 - btnW / 2; exportMap.Top = toolbarWindow.ClientHeight - 26 * 5; exportMap.Click += new TomShane.Neoforce.Controls.EventHandler(ExportMapBehavior); saveMap = new Button(manager); saveMap.Init(); saveMap.Parent = toolbarWindow; saveMap.Text = "Save Map"; saveMap.Width = btnW; saveMap.Height = 24; saveMap.Left = clientW / 2 - btnW / 2; saveMap.Top = toolbarWindow.ClientHeight - 26 * 4; saveMap.Click += new TomShane.Neoforce.Controls.EventHandler(SaveMapBehavior); newMap = new Button(manager); newMap.Init(); newMap.Parent = toolbarWindow; newMap.Text = "New Map"; newMap.Width = btnW; newMap.Height = 24; newMap.Left = clientW / 2 - btnW / 2; newMap.Top = toolbarWindow.ClientHeight - 26 * 3; newMap.Click += new TomShane.Neoforce.Controls.EventHandler(NewMapBehavior); backToStartScreen = new Button(manager); backToStartScreen.Init(); backToStartScreen.Parent = toolbarWindow; backToStartScreen.Text = "To Start Screen"; backToStartScreen.Width = btnW; backToStartScreen.Height = 24; backToStartScreen.Left = clientW / 2 - btnW / 2; backToStartScreen.Top = toolbarWindow.ClientHeight - 26 * 2; backToStartScreen.Click += new TomShane.Neoforce.Controls.EventHandler(BackToStartScreenBehavior); exitButton = new Button(manager); exitButton.Init(); exitButton.Parent = toolbarWindow; exitButton.Text = "Exit"; exitButton.Width = btnW; exitButton.Height = 24; exitButton.Left = clientW / 2 - btnW/2; exitButton.Top = toolbarWindow.ClientHeight - 26; exitButton.Click += new TomShane.Neoforce.Controls.EventHandler(ExitBehavior); newMapConfirmationWindow = new Window(manager); newMapConfirmationWindow.Init(); newMapConfirmationWindow.Text = "Start a new map?"; newMapConfirmationWindow.Width = 248; newMapConfirmationWindow.Height = 48; newMapConfirmationWindow.Center(); newMapConfirmationWindow.CloseButtonVisible = false; newMapConfirmationWindow.IconVisible = false; newMapConfirmationWindow.Visible = false; newMapConfirmationWindow.Resizable = false; manager.Add(newMapConfirmationWindow); accept = new Button(manager); accept.Init(); accept.Parent = newMapConfirmationWindow; accept.Width = 100; accept.Height = 24; accept.Click += new TomShane.Neoforce.Controls.EventHandler(ConfirmedNewMapBehavior); accept.Left = 12; accept.Top = 8; accept.Text = "Yes"; cancel = new Button(manager); cancel.Init(); cancel.Parent = newMapConfirmationWindow; cancel.Width = 100; cancel.Height = 24; cancel.Click += new TomShane.Neoforce.Controls.EventHandler(CancelNewMapBehavior); cancel.Left = 124; cancel.Top = 8; cancel.Text = "No thanks"; }
void AddSettingsWindow(Manager gui) { SettingsWindow = new Window(gui); SettingsWindow.Width = 300; SettingsWindow.Height = 200; SettingsWindow.CloseButtonVisible = false; SettingsWindow.Text = GlblRes.Settings; SettingsWindow.Parent = MainMenuBackground; SettingsWindow.Init(); SettingsWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT)); SettingsWindow.Visible = false; SettingsWindow.Resizable = false; SettingsWindow.IconVisible = false; SettingsWindow.DragAlpha = 255; SettingsWindow.Movable = false; var MusicVolumeLabel = new Label(gui); MusicVolumeLabel.Init(); MusicVolumeLabel.Width = 120; MusicVolumeLabel.Parent = SettingsWindow; MusicVolumeLabel.Text = GlblRes.Music_Volume; MusicVolumeLabel.Top = 5; MusicVolumeLabel.Left = 5; var MusicVolumeBar = new TrackBar(gui); MusicVolumeBar.Init(); MusicVolumeBar.Width = 160; MusicVolumeBar.Value = (int)(GameSettings.MusicVolume * 100); MusicVolumeBar.ValueChanged += (o, e) => { GameSettings.MusicVolume = (float)MusicVolumeBar.Value / 100f; Engine.ApplyGameSettingsVolume(); MediaPlayer.Volume = MathHelper.Clamp(GameSettings.MusicVolume, 0.0f, 1.0f); MainMenuLabel.Text = string.Empty; }; MusicVolumeBar.Top = 5; MusicVolumeBar.Left = 120; MusicVolumeBar.Parent = SettingsWindow; var SoundVolumeLabel = new Label(gui); SoundVolumeLabel.Init(); SoundVolumeLabel.Width = 120; SoundVolumeLabel.Parent = SettingsWindow; SoundVolumeLabel.Text = GlblRes.Sound_Volume; SoundVolumeLabel.Top = 30; SoundVolumeLabel.Left = 5; var SoundVolumeBar = new TrackBar(gui); SoundVolumeBar.Init(); SoundVolumeBar.Width = 160; SoundVolumeBar.Value = (int)(GameSettings.SoundEffectVolume * 100); SoundVolumeBar.ValueChanged += (o, e) => { GameSettings.SoundEffectVolume = (float)SoundVolumeBar.Value / 100f; Engine.ApplyGameSettingsVolume(); MainMenuLabel.Text = string.Empty; }; SoundVolumeBar.Top = 30; SoundVolumeBar.Left = 120; SoundVolumeBar.Parent = SettingsWindow; var BloomLabel = new Label(gui); BloomLabel.Init(); BloomLabel.Width = 120; BloomLabel.Parent = SettingsWindow; BloomLabel.Text = GlblRes.Bloom; BloomLabel.Top = 55; BloomLabel.Left = 5; var BloomCheckBox = new CheckBox(gui); BloomCheckBox.Init(); BloomCheckBox.Parent = SettingsWindow; BloomCheckBox.Text = string.Empty; BloomCheckBox.Checked = GameSettings.Bloom; BloomCheckBox.CheckedChanged += (o, e) => { GameSettings.Bloom = BloomCheckBox.Checked; MainMenuLabel.Text = GlblRes.Restart_the_game_for_this_setting_to_take_effect; }; BloomCheckBox.Top = 55; BloomCheckBox.Left = 120; var VSyncLabel = new Label(gui); VSyncLabel.Init(); VSyncLabel.Width = 120; VSyncLabel.Parent = SettingsWindow; VSyncLabel.Text = GlblRes.VSync; VSyncLabel.Top = 80; VSyncLabel.Left = 5; var VSyncCheckBox = new CheckBox(gui); VSyncCheckBox.Init(); VSyncCheckBox.Parent = SettingsWindow; VSyncCheckBox.Text = string.Empty; VSyncCheckBox.Checked = GameSettings.VSync; VSyncCheckBox.CheckedChanged += (o, e) => { GameSettings.VSync = VSyncCheckBox.Checked; MainMenuLabel.Text = GlblRes.Restart_the_game_for_this_setting_to_take_effect; }; VSyncCheckBox.Top = 80; VSyncCheckBox.Left = 120; var DisplayModeLabel = new Label(gui); DisplayModeLabel.Init(); DisplayModeLabel.Width = 120; DisplayModeLabel.Parent = SettingsWindow; DisplayModeLabel.Text = GlblRes.Display_Mode; DisplayModeLabel.Top = 105; DisplayModeLabel.Left = 5; var DisplayModeCombo = new ComboBox(gui); DisplayModeCombo.Init(); DisplayModeCombo.Items = GetDisplayModes(); DisplayModeCombo.Width = 120; DisplayModeCombo.Parent = SettingsWindow; DisplayModeCombo.Width = 160; DisplayModeCombo.Text = DisplayModeToString(GameSettings.DisplayMode); DisplayModeCombo.ItemIndexChanged += (o, e) => { GameSettings.DisplayMode = StringToDisplayMode(DisplayModeCombo.Text); MainMenuLabel.Text = GlblRes.Restart_the_game_for_this_setting_to_take_effect; }; DisplayModeCombo.Top = 105; DisplayModeCombo.Left = 120; var Bevel = new Bevel(gui); Bevel.Parent = SettingsWindow; Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right; Bevel.Height = 35; Bevel.Style = BevelStyle.Raised; Bevel.Top = SettingsWindow.ClientHeight - Bevel.Height; Bevel.Width = SettingsWindow.ClientWidth; var OKButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings); OKButton.Init(); OKButton.Parent = Bevel; OKButton.Text = GlblRes.OK; OKButton.Click += (s, e) => { SettingsWindow.Close(); ShowLogo(true); GameSettings.Save(Engine.Game.SaveGameFolder); }; OKButton.Width = 130; OKButton.Left = 150; OKButton.Top = 5; gui.Add(SettingsWindow); }
public override void Initialize() { #region Initialize Window //Create Window m_Window = new Window(Global.GUIManager); m_Window.Init(); m_Window.CloseButtonVisible = false; m_Window.Movable = false; m_Window.StayOnBack = true; m_Window.Resizable = false; m_Window.Text = "Inititalize Editor"; m_Window.Top = Global.INITEDITORWINDOW_TOP; m_Window.Left = Global.INITEDITORWINDOW_LEFT; m_Window.Width = Global.INITEDITORWINDOW_WIDTH; m_Window.Height = Global.INITEDITORWINDOW_HEIGHT; m_Panel.Add(m_Window); Global.GUIManager.Add(m_Window); #endregion #region Initialize combo box for board height and width m_ComboBoxs = new ComboBox[2]; for (int i = 0; i < m_ComboBoxs.Length; i++) { m_ComboBoxs[i] = new ComboBox(Global.GUIManager); m_ComboBoxs[i].Top = Global.INITCOMBO_TOP + (i * Global.INITCOMBO_SPACE); m_ComboBoxs[i].Left = Global.INITCOMBO_LEFT; m_ComboBoxs[i].Width = Global.INITCOMBO_WIDTH; m_ComboBoxs[i].Items.Add(4); m_ComboBoxs[i].Items.Add(5); m_ComboBoxs[i].Items.Add(6); m_ComboBoxs[i].Items.Add(7); m_ComboBoxs[i].Items.Add(8); m_ComboBoxs[i].Items.Add(9); m_ComboBoxs[i].ReadOnly = true; m_ComboBoxs[i].Init(); //Add the buttons m_Panel.Add(m_ComboBoxs[i]); Global.GUIManager.Add(m_ComboBoxs[i]); } #endregion #region Initialize Buttons m_Buttons = new Button[Global.INITEDITOR_MENU.Length]; for (int i = 0; i < m_Buttons.Length; i++) { //Create buttons m_Buttons[i] = new Button(Global.GUIManager); m_Buttons[i].Text = Global.INITEDITOR_MENU[i]; m_Buttons[i].Top = Global.INITEDITOR_TOP; m_Buttons[i].Left = Global.INITEDITOR_LEFT + (i * (Global.INITEDITOR_WIDTH + Global.INITEDITOR_SPACE)); m_Buttons[i].Width = Global.INITEDITOR_WIDTH; m_Buttons[i].Init(); //Add the buttons m_Panel.Add(m_Buttons[i]); Global.GUIManager.Add(m_Buttons[i]); //Set event handler m_Buttons[i].Click += InitChoose; } #endregion //Create label m_Label = new Label(Global.GUIManager); m_Label.Init(); m_Label.Text = Global.INITEDITORLABEL_TEXT; m_Label.Top = Global.INITEDITORLABEL_TOP; m_Label.Left = Global.INITEDITORLABEL_LEFT; m_Label.Width = Global.INITEDITORLABEL_WIDTH; m_Label.Height = Global.INITEDITORLABEL_HEIGHT; //Add Label m_Panel.Add(m_Label); Global.GUIManager.Add(m_Label); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, PloobsEngine.SceneControl.IContentManager contentManager) { tile = factory.GetTexture2D("Textures/tile"); FarseerWorld fworld = this.World.PhysicWorld as FarseerWorld; ///border border = new Border(fworld, factory, GraphicInfo, factory.CreateTexture2DColor(1, 1, Color.Red)); ///from texture { Texture2D tex = factory.GetTexture2D("Textures//goo"); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, 0); this.World.AddObject(o); } ///from texture, scale usage sample { Texture2D tex = factory.GetTexture2D("Textures//goo"); tex = factory.GetScaledTexture(tex, new Vector2(2)); IModelo2D model = new SpriteFarseer(tex); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.OnHasMoved += new PloobsEngine.SceneControl._2DScene.OnHasMoved(o_OnHasMoved); this.World.AddObject(o); } ///rectangle Vertices verts = PolygonTools.CreateRectangle(50, 50); { IModelo2D model = new SpriteFarseer(factory, verts, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(-200, 0); this.World.AddObject(o); } ///circle CircleShape circle = new CircleShape(50, 1); { IModelo2D model = new SpriteFarseer(factory, circle, Color.Orange); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); FarseerObject fs = new FarseerObject(fworld, model); I2DObject o = new I2DObject(fs, mat, model); o.PhysicObject.Position = new Vector2(200, -100); this.World.AddObject(o); } ///animated sprite { Texture2D tex = factory.GetTexture2D("Textures//DudeSheet"); SpriteAnimated sa = new SpriteAnimated(tex, 8, 2); sa.AddAnimation("ANIM1", 1, 8, 0); sa.AddAnimation("ANIM2", 2, 4, MathHelper.PiOver2); Basic2DTextureMaterial mat = new Basic2DTextureMaterial(); Texture2D frame = factory.GetTexturePart(tex, sa.GetFrameRectangle("ANIM1", 0)); FarseerObject fs = new FarseerObject(fworld, frame); //GhostObject fs = new GhostObject(Vector2.Zero); sheet = new I2DObject(fs, mat, sa); sheet.PhysicObject.Position = new Vector2(500, 0); this.World.AddObject(sheet); } { PointLight2D l = new PointLight2D(new Vector2(-GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Red, 1); this.World.AddLight(l); } { SpotLight2D l = new SpotLight2D(new Vector2(+GraphicInfo.BackBufferWidth / 4, -GraphicInfo.BackBufferWidth / 4), Color.Blue, new Vector2(0, 1), MathHelper.ToRadians(45)); this.World.AddLight(l); } { SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space); sc.KeyStateChange += new KeyStateChange(sc_KeyStateChange); this.BindInput(sc); } ///camera this.World.Camera2D = new Camera2D(GraphicInfo); DPFSParticleSystem ps = new DPFSParticleSystem("TESTE", new SpriteParticleSystem(null)); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///add a post effect =P //this.RenderTechnic.AddPostEffect(new WigglePostEffect()); ///updateable JointUpdateable ju = new JointUpdateable(this, fworld, this.World.Camera2D); base.LoadContent(GraphicInfo, factory, contentManager); { NeoforceGui guiManager = this.Gui as NeoforceGui; System.Diagnostics.Debug.Assert(guiManager != null); // Create and setup Window control. Window window = new Window(guiManager.Manager); window.Init(); window.Text = "Getting Started"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. Button button = new Button(guiManager.Manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; // Add the window control to the manager processing queue. guiManager.Manager.Add(window); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { base.Initialize(); diagnostics = new DiagnosticInfo("System Performance"); // Add the content to the textures singleton Textures.Instance.Graphics = GraphicsDevice; Textures.Instance.Content = Content; world = new GameWorld(); world.Systems.Add(world.Input); world.Systems.Add(new CameraSystem()); world.Systems.Add(new InspectionSystem()); world.Systems.Add(new ControlSystem()); world.Systems.Add(new DateTimeSystem()); world.Systems.Add(new BehaviorSystem()); world.Systems.Add(new ImmigrationSystem()); world.Systems.Add(new ProductionSystem()); world.Systems.Add(new CityInformationSystem()); world.Systems.Add(new HousingUpgradeSystem()); world.Systems.Add(new OverlaySystem() { Graphics = GraphicsDevice }); world.Systems.Add(new CollapsibleSystem()); world.Systems.Add(new IsometricMapSystem() { Graphics = GraphicsDevice }); world.Renderer = new DefaultRenderSystem() { Graphics = GraphicsDevice, ClearColor = Color.Black }; world.Systems.Add(world.Renderer); world.UI = new Manager(this, "Pixel") { AutoCreateRenderTarget = false, AutoUnfocus = true, TargetFrames = 60 }; world.UI.Initialize(); world.UI.RenderTarget = world.UI.CreateRenderTarget(); Window w = new TomShane.Neoforce.Controls.Window(world.UI) { Text = "My Quick Test Window" }; w.Init(); w.Center(); // Load the scenario // TODO: put this in a method somewhere string s = File.ReadAllText("Content/Data/Scenarios/alpha.json"); Scenario scenario = JsonConvert.DeserializeObject <Scenario>(s); // Load textures from config Textures.Instance.LoadFromJson(scenario.Textures, true); // Load the drawables world.Prototypes.LoadFromFile( new DrawablesLoader(), scenario.Drawables, true); world.City = scenario.City; // Load in entities world.Prototypes.LoadFromFile( new CustomEntityLoader() { Converter = new CustomComponentConverter() }, scenario.Entities, true); // load scenario data world.Prototypes.LoadFromFile( new DataLoader <Item>(), scenario.Items, true); world.Prototypes.LoadFromFile( new DataLoader <Recipe>(), scenario.Recipes, true); //GameData.Instance.LoadItemsFromJson(scenario.Items, true); //GameData.Instance.LoadRecipesFromJson(scenario.Recipes, true); CustomEntityLoader cel = new CustomEntityLoader() { Library = world.Prototypes, Converter = new CustomComponentConverter() }; foreach (JObject o in scenario.DefaultEntities) { Entity e = (Entity)cel.LoadPrototype(o); world.Entities.Add(e); } // start up the pathfinder thread PathfinderSystem pfs = new PathfinderSystem() { Map = world.Map, Collisions = world.Collisions }; pathThread = new Thread(new ThreadStart(pfs.Run)); pathThread.Start(); pfs = new PathfinderSystem() { Map = world.Map, Collisions = world.Collisions }; pathThread2 = new Thread(new ThreadStart(pfs.Run)); //pathThread2.Start(); // TODO: create a settings file to read any key bindings from inputControlEntity = new Entity(); inputControlEntity.AddComponent(new PositionComponent()); inputControlEntity.AddComponent(new CameraController()); world.Entities.Add(inputControlEntity); DrawableComponent diagDrawable = new DrawableComponent(); diagDrawable.Add("Text", new DrawableText() { Text = "", Color = Color.White, Visible = true, Layer = "Text", Static = true }); diagnosticEntity = new Entity(); diagnosticEntity.AddComponent(new PositionComponent() { X = 0, Y = 50f }); diagnosticEntity.AddComponent(diagDrawable); world.Entities.Add(diagnosticEntity); }
private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black) { const int spacing = 20; const int width = 500; int yPos = spacing; var window = new Window(manager) { Text = "Story card", Width = 600 }; window.Init(); var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30}; descriptionlabel.Text = "When this window closes you will be required to spin the spinner.\n" + "If the spinner lands on a black spot you will undergo what the black card says.\n" + "If the spinner lands on a red spot you will undergo what the red card says.\n\n" + "These are stories you are spinning for!"; yPos += descriptionlabel.Height + spacing / 2; var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White}; redstorybox.Init(); yPos += redstorybox.Height; var redstorylabel = new Label(manager) { Width = redstorybox.Width, Height = redstorybox.Height, Parent = redstorybox, Text = red.DisplayedMessage, Left = spacing, StayOnTop = true }; redstorylabel.Init(); var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White }; blackstorybox.Init(); yPos += blackstorybox.Height+spacing/2; var blackstorylabel = new Label(manager) { Width = blackstorybox.Width, Height = blackstorybox.Height, Parent = blackstorybox, Text = black.DisplayedMessage, Left = spacing, StayOnTop = true }; blackstorylabel.Init(); var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window }; close.Init(); close.Click += (sender, args) => window.Close(); yPos += close.Height + spacing; window.Add(descriptionlabel); window.Height = blackstorybox.Height + redstorybox.Height + yPos/2; manager.Add(window); window.Closed += (sender, args) => WindowClosed(gameInfo); gameInfo.CreateMessage("Click the spinner to see your story!"); }
void AddLoadGameWindow(Manager gui) { var LoadButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings); LoadGameWindow = new Window(gui); LoadGameWindow.Width = 300; LoadGameWindow.Height = 200; LoadGameWindow.CloseButtonVisible = false; LoadGameWindow.Text = GlblRes.Load_Savegame; LoadGameWindow.Parent = MainMenuBackground; LoadGameWindow.Init(); LoadGameWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT)); LoadGameWindow.Visible = false; LoadGameWindow.Resizable = false; LoadGameWindow.IconVisible = false; LoadGameWindow.DragAlpha = 255; LoadGameWindow.Movable = false; var SaveGameScreenshot = new ImageBox(gui); SaveGameScreenshot.Parent = MainMenuBackground; SaveGameScreenshot.Width = MainMenuBackground.Width; SaveGameScreenshot.Height = MainMenuBackground.Height; SaveGameScreenshot.Visible = false; SaveGameScreenshot.SizeMode = SizeMode.Stretched; LoadGameWindow.Closed += (s, e) => { LoadGameListbox.ItemIndex = -1; }; LoadGameListbox = new ListBox(gui); LoadGameListbox.Width = LoadGameWindow.ClientWidth; LoadGameListbox.Parent = LoadGameWindow; LoadGameListbox.Height = LoadGameWindow.ClientHeight - 35; LoadGameListbox.ItemIndexChanged += (s, e) => { ClickSound.Play(GameSettings.SoundEffectVolume, 0f, 0f); MainMenuLabel.Text = string.Empty; if (LoadGameListbox.ItemIndex > -1) { if (SaveGameScreenshot.Image != null) { SaveGameScreenshot.Image.Dispose(); } var Screenshot = SaveGames[SaveGames.Keys.ElementAt(LoadGameListbox.ItemIndex)].Screenshot; if (Screenshot != null) { using (Stream ScreenshotStream = new MemoryStream(Screenshot)) { SaveGameScreenshot.Image = Texture2D.FromStream(Engine.Renderer.GraphicsDevice, ScreenshotStream); } } SaveGameScreenshot.Show(); LoadButton.Enabled = true; } else { SaveGameScreenshot.Hide(); LoadButton.Enabled = false; } }; var Bevel = new Bevel(gui); Bevel.Parent = LoadGameWindow; Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right; Bevel.Height = 35; Bevel.Style = BevelStyle.Raised; Bevel.Top = LoadGameWindow.ClientHeight - Bevel.Height; Bevel.Width = LoadGameWindow.ClientWidth; LoadButton.Init(); LoadButton.Parent = Bevel; LoadButton.Enabled = false; LoadButton.Text = GlblRes.Load_Savegame; LoadButton.Click += (s, e) => { MainMenuLabel.Text = string.Empty; try { Engine.LoadState(SaveGames.Keys.ElementAt(LoadGameListbox.ItemIndex)); } catch { MainMenuLabel.Text = GlblRes.Could_not_load_save_game_Maybe_it_was_created_in_an_earlier_game_version; return; } LoadGameWindow.Close(); MainMenuBackground.Hide(); Engine.Resume(); Engine.Renderer.GUIManager.ShowSoftwareCursor = false; }; LoadButton.Width = 130; LoadButton.Left = 5; LoadButton.Top = 5; var CancelButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings); CancelButton.Init(); CancelButton.Parent = Bevel; CancelButton.Text = GlblRes.Cancel; CancelButton.Click += (s, e) => { LoadGameWindow.Close(); ShowLogo(true); }; CancelButton.Width = 130; CancelButton.Left = 150; CancelButton.Top = 5; gui.Add(LoadGameWindow); }
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Methods /////////// //////////////////////////////////////////////////////////////////////////// protected override void Initialize() { base.Initialize(); // Create sprite batch for ploting texture with rendered UI. sprite = new SpriteBatch(GraphicsDevice); // Initialize manager. manager.Initialize(); // Create and assign render target for UI rendering. manager.RenderTarget = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents); // Maximum of frames we want to render per second (applies only for Neoforce, not Game itself) manager.TargetFrames = 60; // Create and setup Window control. window = new Window(manager); window.Init(); window.Text = "Render Targets"; window.Width = 480; window.Height = 200; window.Center(); window.Visible = true; // Create Button control and set the previous window as its parent. button = new Button(manager); button.Init(); button.Text = "OK"; button.Width = 72; button.Height = 24; button.Left = (window.ClientWidth / 2) - (button.Width / 2); button.Top = window.ClientHeight - button.Height - 8; button.Anchor = Anchors.Bottom; button.Parent = window; // Add the window control to the manager processing queue. manager.Add(window); }
void AddExitConfirmationWindow(Manager gui) { ExitConfirmationWindow = new Window(gui); ExitConfirmationWindow.Init(); ExitConfirmationWindow.Text = GlblRes.Really_quit; ExitConfirmationWindow.Width = 290; ExitConfirmationWindow.Height = 130; ExitConfirmationWindow.Resizable = false; ExitConfirmationWindow.IconVisible = false; ExitConfirmationWindow.Movable = false; ExitConfirmationWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT)); ExitConfirmationWindow.Visible = false; ExitConfirmationWindow.CloseButtonVisible = false; var Bevel = new Bevel(gui); Bevel.Parent = ExitConfirmationWindow; Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right; Bevel.Height = 35; Bevel.Style = BevelStyle.Raised; Bevel.Top = ExitConfirmationWindow.ClientHeight - Bevel.Height; Bevel.Width = ExitConfirmationWindow.ClientWidth; var Text = new Label(gui); Text.Text = GlblRes.Do_you_really_want_to_quit_the_game; Text.Parent = ExitConfirmationWindow; Text.Top = 10; Text.Left = 10; Text.Width = ExitConfirmationWindow.ClientWidth - 20; Text.Height = 20; var Yes = new MenuButton(gui, ClickSound, FocusSound, GameSettings); Yes.Parent = Bevel; Yes.Width = 100; Yes.Text = GlblRes.Yes; Yes.Left = 10; Yes.Top = 5; Yes.Click += (se, ve) => { Engine.Exit(); }; var No = new MenuButton(gui, ClickSound, FocusSound, GameSettings); No.Parent = Bevel; No.Text = GlblRes.Menu_AddExitConfirmationWindow_No; No.Width = 100; No.Left = 165; No.Top = 5; No.Click += (se, ev) => { ExitConfirmationWindow.Close(); ShowLogo(true); }; gui.Add(ExitConfirmationWindow); }
public OptionsWindow(Sidebar sidebar) { UserInterface.GameInputDisabled = true; this.manager = sidebar.manager; this.sidebar = sidebar; window = new Window(manager); window.Init(); window.Left = sidebar.master.Left; window.Width = sidebar.master.Width; window.Top = 200; window.Height = 200; window.Width = 240; window.Text = "Options"; window.Resizable = false; window.Movable = false; window.Closed += delegate { UserInterface.GameInputDisabled = false; }; window.ShowModal(); manager.Add(window); btnOk = new Button(manager); btnOk.Init(); btnOk.Parent = window; btnOk.Left = LeftPadding; btnOk.Top = window.Height - (btnOk.Height * 3); btnOk.Text = "Ok";// +"\u2713"; btnOk.Click += (s, e) => window.Close(); //btnLoadLevel = new Button(manager); //btnLoadLevel.Init(); //window.Add(btnLoadLevel); //btnLoadLevel.Width += 30; //btnLoadLevel.Left = window.Width - btnLoadLevel.Width - LeftPadding * 5; //btnLoadLevel.Text = "Load Level"; //btnLoadLevel.Top = window.Height - (btnLoadLevel.Height * 3); //btnLoadLevel.Click += btnLoadLevel_Click; // //btnSaveLevel = new Button(manager); //btnSaveLevel.Init(); //window.Add(btnSaveLevel); //btnSaveLevel.Width += 30; //btnSaveLevel.Left = window.Width - btnSaveLevel.Width - LeftPadding * 5; //btnSaveLevel.Text = "Save Level"; //btnSaveLevel.Top = btnLoadLevel.Top - btnSaveLevel.Height - LeftPadding; //btnSaveLevel.Click += btnSaveLevel_Click; lblUserLevel = new Label(manager); lblUserLevel.Init(); lblUserLevel.Parent = window; lblUserLevel.Left = LeftPadding; lblUserLevel.Top = HeightCounter; lblUserLevel.Text = "User Level"; lblUserLevel.Width += 10; cbUserLevel = new ComboBox(manager); cbUserLevel.Init(); cbUserLevel.Parent = window; cbUserLevel.Top = HeightCounter; cbUserLevel.Left = lblUserLevel.Width; cbUserLevel.Width = 150; HeightCounter += cbUserLevel.Height; cbUserLevel.TextColor = Color.Black; foreach(string ul in Enum.GetNames(typeof(UserLevel))) { cbUserLevel.Items.Add(ul); } cbUserLevel.ItemIndexChanged += (s, e) => { sidebar.userLevel = (UserLevel)cbUserLevel.ItemIndex; }; int count = 0; foreach(object s in cbUserLevel.Items) { if (s.ToString().Equals(sidebar.userLevel.ToString())) { cbUserLevel.ItemIndex = count; } count++; } Label lblRes = new Label(manager); lblRes.Init(); lblRes.Parent = window; lblRes.Left = LeftPadding; lblRes.Top = HeightCounter; lblRes.Text = "Resolution"; lblRes.Width += 10; ComboBox cbResolutions = new ComboBox(manager); cbResolutions.Init(); cbResolutions.Parent = window; cbResolutions.Top = HeightCounter; cbResolutions.Left = lblUserLevel.Width; cbResolutions.Width = 150; HeightCounter += cbResolutions.Height; cbUserLevel.TextColor = Color.Black; foreach (resolutions r in Enum.GetValues(typeof(resolutions))) { cbResolutions.Items.Add(r); } cbResolutions.ItemIndexChanged += (s, e) => { OrbIt.game.setResolution((resolutions)cbResolutions.ItemIndex, OrbIt.game.Graphics.IsFullScreen); if (OrbIt.game.Graphics.IsFullScreen) OrbIt.game.prefFullScreenResolution = (resolutions)cbResolutions.ItemIndex; else OrbIt.game.prefWindowedResolution = (resolutions)cbResolutions.ItemIndex; }; CreateCheckBox("FullScreen", OrbIt.isFullScreen, (o, e) => { if ((o as CheckBox).Checked) OrbIt.game.setResolution(resolutions.AutoFullScreen, true); else OrbIt.game.setResolution(resolutions.WXGA_1280x800, false); }); CreateCheckBox("Hide Links", sidebar.ui.game.room.DrawLinks, (o, e) => sidebar.ui.game.room.DrawLinks = !(o as CheckBox).Checked); CreateCheckBox("Edit Selected Node", false, (o, e) => Utils.notImplementedException() ); //CreateCheckBox("Edit Selected Node", sidebar.EditSelectedNode, (o, e) => sidebar.EditSelectedNode = (o as CheckBox).Checked); }
void AddSaveGameWindow(Manager gui) { var SaveButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings); var NameTextBox = new TextBox(gui); SaveGameWindow = new Window(gui); SaveGameWindow.Width = 300; SaveGameWindow.Height = 240; SaveGameWindow.CloseButtonVisible = false; SaveGameWindow.Text = GlblRes.Save; SaveGameWindow.IconVisible = false; SaveGameWindow.Parent = MainMenuBackground; SaveGameWindow.Init(); SaveGameWindow.Visible = false; SaveGameWindow.Resizable = false; SaveGameWindow.Center(new Point(Game.VIRTUAL_WIDTH, Game.VIRTUAL_HEIGHT)); SaveGameWindow.Movable = false; SaveGameWindow.Closed += (s, e) => { SaveGameListbox.ItemIndex = -1; }; SaveGameListbox = new ListBox(gui); SaveGameListbox.Width = SaveGameWindow.ClientWidth; SaveGameListbox.Parent = SaveGameWindow; SaveGameListbox.Height = SaveGameWindow.ClientHeight - 35 - 30; SaveGameListbox.ItemIndexChanged += (s, e) => { ClickSound.Play(GameSettings.SoundEffectVolume, 0f, 0f); if (SaveGameListbox.ItemIndex > -1) { NameTextBox.Text = SaveGames[SaveGames.Keys.ElementAt(SaveGameListbox.ItemIndex)].Name; } }; var Bevel = new Bevel(gui); Bevel.Parent = SaveGameWindow; Bevel.Anchor = Anchors.Bottom | Anchors.Left | Anchors.Right; Bevel.Height = 35; Bevel.Style = BevelStyle.Raised; Bevel.Top = SaveGameWindow.ClientHeight - Bevel.Height; Bevel.Width = SaveGameWindow.ClientWidth; SaveButton.Init(); SaveButton.Parent = Bevel; SaveButton.Enabled = false; SaveButton.Text = GlblRes.Save; SaveButton.Click += (s, e) => { Engine.SaveState(NameTextBox.Text); ShowLogo(true); SaveGameWindow.Close(); RefreshSaveGames(); }; SaveButton.Width = 130; SaveButton.Left = 5; SaveButton.Top = 5; var CancelButton = new MenuButton(gui, ClickSound, FocusSound, GameSettings); CancelButton.Init(); CancelButton.Parent = Bevel; CancelButton.Text = GlblRes.Cancel; CancelButton.Click += (s, e) => { SaveGameWindow.Close(); ShowLogo(true); }; CancelButton.Width = 130; CancelButton.Left = Bevel.ClientWidth - 130 - 5; CancelButton.Top = 5; gui.Add(SaveGameWindow); var SaveGameNameLabel = new Label(gui); SaveGameNameLabel.Parent = SaveGameWindow; SaveGameNameLabel.Top = SaveGameListbox.Height + 5; SaveGameNameLabel.Left = 5; SaveGameNameLabel.Width = 95; SaveGameNameLabel.Text = GlblRes.Name; NameTextBox.Parent = SaveGameWindow; NameTextBox.Init(); NameTextBox.Left = 60; NameTextBox.Top = SaveGameListbox.Height + 5; NameTextBox.Width = 220; NameTextBox.Height = 20; NameTextBox.TextChanged += (s, e) => { SaveButton.Enabled = !string.IsNullOrWhiteSpace(NameTextBox.Text); }; NameTextBox.KeyPress += (s, e) => { if (e.Key == Microsoft.Xna.Framework.Input.Keys.Enter) { Engine.SaveState(NameTextBox.Text); SaveGameWindow.Close(); ShowLogo(true); RefreshSaveGames(); } }; gui.Add(SaveGameWindow); }