public MenuWindow() : base("MainMenu", new Vector2i(140, 130)) { _screenPos = new Vector2i((int)(CluwneLib.CurrentRenderTarget.Size.X / 2f) - (int)(ClientArea.Width / 2f), (int)(CluwneLib.CurrentRenderTarget.Size.Y / 2f) - (int)(ClientArea.Height / 2f)); var buttonEntity = new Button("Spawn Entities"); buttonEntity.LocalPosition = new Vector2i(5, 5); Container.AddControl(buttonEntity); buttonEntity.Clicked += button_entity_Clicked; var buttonTile = new Button("Spawn Tiles"); buttonTile.LocalPosition = new Vector2i(0, 5); buttonTile.Alignment = ControlAlignments.Bottom; buttonEntity.AddControl(buttonTile); buttonTile.Clicked += button_tile_Clicked; var buttonQuit = new Button("Quit"); buttonQuit.LocalPosition = new Vector2i(0, 20); buttonQuit.Alignment = ControlAlignments.Bottom; buttonTile.AddControl(buttonQuit); buttonQuit.Clicked += button_quit_Clicked; }
private Dictionary <string, IControl> InitializeActionButtons() { var actionIds = _gameConfigCache.GetActionConfigIds(); var actionButtons = new Dictionary <string, IControl>(); var i = 0; var x = 10; var y = 806; var buttonSize = new Vector2(110.0f, 30.0f); foreach (var actionId in actionIds) { var action = _gameConfigCache.GetActionConfigById(actionId); var xOffset = buttonSize.X * (i % 2); var yOffset = buttonSize.Y * (i / 2); // math.Floor var position = new Vector2(x + xOffset, y + yOffset); i++; var textureString = "GUI_Textures_1.simpleb_"; var button = new Button(action.Name) { TextureNormal = $"{textureString}n", TextureActive = $"{textureString}a", TextureHover = $"{textureString}h", TextureDisabled = $"{textureString}a", Size = buttonSize.ToPointI(), Position = position.ToPointI() }; button.AddPackage(new ControlClick((o, args) => BtnClick(o, new ButtonClickEventArgs(action.Name)))); var label = new Label($"label{i}") { FontName = "Maleficio-Regular-12", Size = button.Size, ContentAlignment = Alignment.MiddleCenter, Text = action.ButtonName, Color = Color.Black }; button.AddControl(label, Alignment.MiddleCenter, Alignment.MiddleCenter); actionButtons.Add(action.Name, button); } return(actionButtons); }
/// <inheritdoc /> public override void InitializeGUI() { _uiScreen = new Screen(); _uiScreen.BackgroundImage = ResourceCache.GetSprite("ss14_logo_background"); // added to interface manager in startup _bgPanel = new Panel(); _bgPanel.BackgroundImage = ResourceCache.GetResource <SpriteResource>(@"Textures/UserInterface/TicketOverlay.png"); _bgPanel.BackgroundColor = new Color(128, 128, 128, 128); _bgPanel.Alignment = ControlAlignments.HCenter | ControlAlignments.VCenter; _bgPanel.Layout += (sender, args) => { _bgPanel.Width = (int)(_uiScreen.Width * 0.85f); _bgPanel.Height = (int)(_uiScreen.Height * 0.85f); }; _uiScreen.AddControl(_bgPanel); _lblTitle = new Label("Options", "CALIBRI", 48); _lblTitle.LocalPosition = new Vector2i(10, 10); _bgPanel.AddControl(_lblTitle); _lstResolution = new Listbox(250, 150); _lstResolution.Alignment = ControlAlignments.Bottom; _lstResolution.LocalPosition = new Vector2i(50, 50); _lstResolution.ItemSelected += _lstResolution_ItemSelected; PopulateAvailableVideoModes(_lstResolution); _lblTitle.AddControl(_lstResolution); _chkFullScreen = new Checkbox(); _chkFullScreen.Value = ConfigurationManager.GetCVar <bool>("display.fullscreen"); _chkFullScreen.ValueChanged += _chkFullScreen_ValueChanged; _chkFullScreen.Alignment = ControlAlignments.Bottom; _chkFullScreen.LocalPosition = new Vector2i(0, 50); _lstResolution.AddControl(_chkFullScreen); _lblFullScreen = new Label("Fullscreen", "CALIBRI"); _lblFullScreen.Alignment = ControlAlignments.Right; _lblFullScreen.LocalPosition = new Vector2i(3, 0); _chkFullScreen.AddControl(_lblFullScreen); _chkVSync = new Checkbox(); _chkVSync.Value = ConfigurationManager.GetCVar <bool>("display.vsync"); _chkVSync.ValueChanged += _chkVSync_ValueChanged; _chkVSync.Alignment = ControlAlignments.Bottom; _chkVSync.LocalPosition = new Vector2i(0, 3); _chkFullScreen.AddControl(_chkVSync); _lblVSync = new Label("Vsync", "CALIBRI"); _lblVSync.Alignment = ControlAlignments.Right; _lblVSync.LocalPosition = new Vector2i(3, 0); _chkVSync.AddControl(_lblVSync); _btnApply = new Button("Apply Settings"); _btnApply.Clicked += _btnApply_Clicked; _btnApply.Alignment = ControlAlignments.Bottom | ControlAlignments.Right; _btnApply.Resize += (sender, args) => { _btnApply.LocalPosition = new Vector2i(-10 + -_btnApply.ClientArea.Width, -10 + -_btnApply.ClientArea.Height); }; _bgPanel.AddControl(_btnApply); _btnBack = new Button("Back"); _btnBack.Clicked += _btnBack_Clicked; _btnBack.Resize += (sender, args) => { _btnBack.LocalPosition = new Vector2i(-10 + -_btnBack.ClientArea.Width, 0); }; _btnApply.AddControl(_btnBack); }