public override void onStart() { // Fondo var texture = content.Load <Texture2D>(Content.Image.credits); Image imag = canvas.stage.addElement(new Image(texture)); imag.setWidth(Constants.SCREEN_WIDTH); imag.setHeight(Constants.SCREEN_HEIGHT); imag.setZIndex(0); // Boton atras //--------------- var buttonStyle = new TextButtonStyle(new PrimitiveDrawable(new Color(78, 91, 98), 10f), new PrimitiveDrawable(new Color(244, 23, 135)), new PrimitiveDrawable(new Color(168, 207, 115))) { downFontColor = Color.Black }; var backButton = canvas.stage.addElement(new TextButton(Constants.MENU_BACK, buttonStyle)); backButton.onClicked += BackMenu => { Game.ManagerState.SetState(StateType.MainMenu, true); }; backButton.setWidth(100); backButton.setHeight(20); backButton.setPosition(Constants.SCREEN_WIDTH - backButton.getWidth() - 15, Constants.SCREEN_HEIGHT - backButton.getHeight() - 5); //--------------- }
private void AddLevelSelectButton(string text, LevelBase level) { float minHeight = Core.graphicsDevice.Viewport.Height / 12; float minWidth = Core.graphicsDevice.Viewport.Width / 6; float margin = 10f; var buttonStyle = new TextButtonStyle(new PrimitiveDrawable(Color.Black, 10f), new PrimitiveDrawable(Color.Yellow), new PrimitiveDrawable(Color.DarkSlateBlue)) { downFontColor = Color.Black }; this._table.add(new TextButton(text, buttonStyle)) .setFillY() .setMinHeight(minHeight) .setMinWidth(minWidth) .getElement <Button>() .onClicked += (obj) => { this.TransitionToLevel(level); }; this._currentRowWidth += minWidth; if (this._currentRowWidth >= Core.graphicsDevice.Viewport.Width - margin) { this._table.row(); this._currentRowWidth = 0f; } }
public EndGameMenu(String gameResult) : base() { clearColor = Color.Black; this.addRenderer(new DefaultRenderer()); addPostProcessor(new ScanlinesPostProcessor(0)); addPostProcessor(new VignettePostProcessor(0)); var canvas = createEntity("ui").addComponent(new UICanvas()); canvas.isFullScreen = true; canvas.renderLayer = Game1.SCREEN_SPACE_RENDER_LAYER; var backgroundTexture = content.Load <Texture2D>("backgrounds/" + gameResult + "Screen"); var background = createEntity("titleScreenBackground", new Vector2(Screen.width / 2f, Screen.height / 1.5f)); background.addComponent(new Sprite(backgroundTexture)); var table = canvas.stage.addElement(new Table()); table.setFillParent(true).center().bottom(); var mainMenuFont = content.Load <BitmapFont>("fonts/futuraDouble"); var topButtonStyle = new TextButtonStyle(new PrimitiveDrawable(Color.Transparent, 10f), new PrimitiveDrawable(Color.Transparent, 10f), new PrimitiveDrawable(Color.Transparent, 10f), mainMenuFont) { downFontColor = Color.Red, overFontColor = Color.LightGray }; TextButton restartButton = new TextButton("CONSUME MORE", topButtonStyle); TextButton quitButton = new TextButton("STAY ASLEEP", topButtonStyle); table.add(restartButton).setFillX().setMinHeight(10).setMinWidth(100).getElement <Button>().onClicked += Game1.startLevelOne; table.row().setPadBottom(100); table.add(quitButton).setFillX().setMinHeight(10).setMinWidth(100).getElement <Button>().onClicked += Game1.quitGame; initialize(); }
public override void onStart() { // Fondo de menu var texture = content.Load <Texture2D>(Content.Image.menu_background); Image imag = canvas.stage.addElement(new Image(texture)); imag.setWidth(Constants.SCREEN_WIDTH); imag.setHeight(Constants.SCREEN_HEIGHT); imag.setZIndex(0); // Cargamos el estilo var textFont = content.Load <BitmapFont>(Content.Font.text); TextButtonStyle topButtonStyle = new TextButtonStyle() { font = textFont, fontColor = Color.Black, overFontColor = Color.Brown, downFontColor = Color.DarkRed }; // Creamos los botones _table.add(new TextButton(Constants.MENU_PLAY, topButtonStyle)).setFillX().setMinHeight(30).getElement <Button>().onClicked += MenuPlay; _table.row(); _table.add(new TextButton(Constants.MENU_CONFIG, topButtonStyle)).setFillX().setMinHeight(30).getElement <Button>().onClicked += MenuConfig; _table.row(); _table.add(new TextButton(Constants.MENU_CREDITS, topButtonStyle)).setFillX().setMinHeight(30).getElement <Button>().onClicked += MenuCredits; _table.row(); _table.add(new TextButton(Constants.MENU_EXIT, topButtonStyle)).setFillX().setMinHeight(30).getElement <Button>().onClicked += MenuExit; }
public MainMenu() : base() { clearColor = Color.Black; this.addRenderer(new DefaultRenderer()); var canvas = createEntity("ui").addComponent(new UICanvas()); var backgroundTexture = content.Load <Texture2D>("backgrounds/titleScreen"); var background = createEntity("titleScreenBackground", new Vector2(Screen.width / 3f, Screen.height / 2f)); background.addComponent(new Sprite(backgroundTexture)); canvas.addComponent <Sprite>(new Sprite(backgroundTexture)); var table = canvas.stage.addElement(new Table()); //table.setDebug(true); table.setFillParent(true).center().bottom(); var mainMenuFont = content.Load <BitmapFont>("fonts/futuraDouble"); var topButtonStyle = new TextButtonStyle(new PrimitiveDrawable(Color.Transparent, 10f), new PrimitiveDrawable(Color.Transparent, 10f), new PrimitiveDrawable(Color.Transparent, 10f), mainMenuFont) { downFontColor = Color.Red, overFontColor = Color.LightGray }; TextButton playButton = new TextButton("CONSUME", topButtonStyle); TextButton quitButton = new TextButton("SLEEP", topButtonStyle); table.add(playButton).setFillX().setMinHeight(10).setMinWidth(100).getElement <Button>().onClicked += Game1.startLevelOne; table.row().setPadBottom(100); table.add(quitButton).setFillX().setMinHeight(10).setMinWidth(100).getElement <Button>().onClicked += Game1.quitGame; addPostProcessor(new VignettePostProcessor(999)); addPostProcessor(new ScanlinesPostProcessor(0)); initialize(); }
public void ApplyButtonStyle(TextButtonStyle style) { ApplyButtonBaseStyle(style); if (style.LabelStyle != null) { _textBlock.ApplyTextBlockStyle(style.LabelStyle); } }
public void ApplyTextButtonStyle(TextButtonStyle style) { ApplyButtonStyle(style); if (style.LabelStyle != null) { InternalChild.ApplyTextBlockStyle(style.LabelStyle); } }
void setupSceneSelector() { _table = canvas.stage.addElement(new Table()); _table.setFillParent(true).right().top(); var topButtonStyle = new TextButtonStyle(new PrimitiveDrawable(Color.Black, 10f), new PrimitiveDrawable(Color.Yellow), new PrimitiveDrawable(Color.DarkSlateBlue)) { downFontColor = Color.Black }; _table.add(new TextButton("Toggle Scene List", topButtonStyle)).setFillX().setMinHeight(30).getElement <Button>().onClicked += onToggleSceneListClicked; _table.row().setPadTop(10); var checkbox = _table.add(new CheckBox("Debug Render", new CheckBoxStyle { checkboxOn = new PrimitiveDrawable(30, Color.Green), checkboxOff = new PrimitiveDrawable(30, new Color(0x00, 0x3c, 0xe7, 0xff)) })).getElement <CheckBox>(); checkbox.onChanged += enabled => Core.debugRenderEnabled = enabled; checkbox.isChecked = Core.debugRenderEnabled; _table.row().setPadTop(30); var buttonStyle = new TextButtonStyle(new PrimitiveDrawable(new Color(78, 91, 98), 10f), new PrimitiveDrawable(new Color(244, 23, 135)), new PrimitiveDrawable(new Color(168, 207, 115))) { downFontColor = Color.Black }; // find every Scene with the SampleSceneAttribute and create a button for each one foreach (var type in getTypesWithSampleSceneAttribute()) { foreach (var attr in type.GetCustomAttributes(true)) { if (attr.GetType() == typeof(SampleSceneAttribute)) { var sampleAttr = attr as SampleSceneAttribute; var button = _table.add(new TextButton(sampleAttr.buttonName, buttonStyle)).setFillX().setMinHeight(30).getElement <TextButton>(); _sceneButtons.Add(button); button.onClicked += butt => { // stop all tweens in case any demo scene started some up TweenManager.stopAllTweens(); Core.startSceneTransition(new FadeTransition(() => Activator.CreateInstance(type) as Scene)); }; _table.row().setPadTop(10); // optionally add instruction text for the current scene if (sampleAttr.instructionText != null && type == GetType()) { addInstructionText(sampleAttr.instructionText); } } } } }
public void SetStyle(TextButtonStyle style) { if (style != default) { SetStyle(style.normalColor, style.highlightedColor, style.pressedColor, style.selectedColor, style.disabledColor); } }
public override void Initialize() { // scene AddSceneComponent(new SceneSprites(this)); Shared.PrintBackground(this); // setup a pixel perfect screen ClearColor = Color.Black; SetDesignResolution(SD.SCREEN_WIDTH, SD.SCREEN_HEIGHT, SceneResolutionPolicy.ShowAllPixelPerfect); Screen.SetSize(SD.SCREEN_WIDTH * SD.SCALE, SD.SCREEN_HEIGHT * SD.SCALE); // add a renderer renderer = AddRenderer(new DefaultRenderer()); // canvas canvas = CreateEntity("ui").AddComponent(new UICanvas()); canvas.IsFullScreen = true; canvas.RenderLayer = SCREEN_RENDER_LAYER; // table table = canvas.Stage.AddElement(new Table()); table.SetFillParent(false).SetBounds(0, 0, SD.SCREEN_WIDTH, SD.SCREEN_HEIGHT); table.Left().Top(); table.SetScale(SD.SCALE); Cell c; // title var labelStyle = new LabelStyle(Color.Black); c = table.Add(new Label("You Won!", labelStyle).SetFontScale(4)); table.Row().SetPadTop(10); c = table.Add(new Label("A Game by Sainer").SetFontScale(1)); table.Row().SetPadTop(30); // button style var buttonStyle = new TextButtonStyle( new PrimitiveDrawable(Color.Black, 10f), new PrimitiveDrawable(Color.Yellow), new PrimitiveDrawable(Color.DarkSlateBlue)) { DownFontColor = Color.Black }; // buttons c = table.Add(new TextButton("To Main Menu", buttonStyle)).SetMinHeight(30); c.GetElement <Button>().OnClicked += Shared.TransitionToMainMenu; table.Row().SetPadTop(10); // put table in the middle table.PadTop(10); table.PadLeft((SD.SCREEN_WIDTH - table.GetWidth()) / 2); }
public TextButton(TextButtonStyle style) { InternalChild = new TextBlock(style != null ? style.LabelStyle : null) { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Wrap = true }; if (style != null) { ApplyTextButtonStyle(style); } }
private void Awake() { ClickButton.OnUpdateEvent += UpdateButton; if (textStyle == default) { ClickButtonStyle clickButtonStyle = ClickButton.style; if (clickButtonStyle != default) { textStyle = clickButtonStyle.textButtonStyle; } } SetStyle(textStyle); }
public TextButton(TextButtonStyle style) { _textBlock = new TextBlock { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; Widget = _textBlock; if (style != null) { ApplyButtonStyle(style); } }
public override void Initialize() { // scene AddSceneComponent(new SceneSprites(this)); Shared.PrintBackground(this); // setup a pixel perfect screen ClearColor = Color.Black; SetDesignResolution(SD.SCREEN_WIDTH, SD.SCREEN_HEIGHT, SceneResolutionPolicy.ShowAllPixelPerfect); Screen.SetSize(SD.SCREEN_WIDTH * SD.SCALE, SD.SCREEN_HEIGHT * SD.SCALE); // add a renderer renderer = AddRenderer(new DefaultRenderer()); // canvas table = Shared.InitTable(this, out Label a, out Label b); a.SetText("ChessNuts"); b.SetText("A Game by Sainer"); // button style var buttonStyle = new TextButtonStyle( new PrimitiveDrawable(Color.Black, 10f), new PrimitiveDrawable(Color.Yellow), new PrimitiveDrawable(Color.DarkSlateBlue)) { DownFontColor = Color.Black }; // buttons var c = table.Add(new TextButton("Play", buttonStyle)).SetMinHeight(30); c.GetElement <Button>().OnClicked += Shared.TransitionToGame; table.Row().SetPadTop(10); c = table.Add(new TextButton("Settings", buttonStyle)).SetMinHeight(30); table.Row().SetPadTop(10); c = table.Add(new TextButton("Quit", buttonStyle)).SetMinHeight(30); c.GetElement <Button>().OnClicked += button => { Core.Exit(); }; table.Row().SetPadTop(10); // put table in the middle // var value = (SD.SCREEN_WIDTH - width) / 2; // table.PadLeft(value); // Debug.Log(value); // Debug.Log(width); }
/// <summary> /// Creates skin styles /// </summary> /// <param name="contentManager">Content manager</param> public GameSkin(NezContentManager contentManager) { Skin = new Skin(); Skin.Add("title-label", new LabelStyle() { Font = contentManager.LoadBitmapFont(Content.OswaldTitleFont) }); Skin.Add("label", new LabelStyle() { Font = contentManager.LoadBitmapFont(Content.DefaultTitleFont) }); var inputCursor = new PrimitiveDrawable(Color.Black); inputCursor.MinHeight = 10; inputCursor.MinWidth = 5; var font = contentManager.LoadBitmapFont(Content.DefaultTitleFont); font.FontSize = 24; var style = Skin.Add("inputfield", new TextFieldStyle() { Font = font, FontColor = Color.Black, Cursor = inputCursor, FocusedBackground = new PrimitiveDrawable(Color.Gray), Background = new PrimitiveDrawable(Color.White), Selection = new PrimitiveDrawable(Color.Blue) }); Skin.Add("regular-button", TextButtonStyle.Create(Color.Gray, new Color(61, 9, 85), new Color(61, 9, 107))); var sliderStyle = SliderStyle.Create(Color.Yellow, new Color(61, 9, 107)); sliderStyle.Knob.MinWidth *= 1.5f; sliderStyle.Knob.MinHeight *= 1.5f; sliderStyle.Background.MinWidth *= 0.5f; Skin.Add("slider", sliderStyle); }
public override void onAddedToEntity() { base.onAddedToEntity(); var skin = Skin.createDefaultSkin(); var main_table = stage.addElement(new Table()); //main_table.defaults().setPadTop(10).setMinWidth(800).setMinHeight(600).setMaxWidth(1280).setMaxHeight(720); //main_table.defaults().setPrefWidth(600).setPrefHeight(400); main_table.setFillParent(true).center(); /*var pl = entity.scene.content.Load<Texture2D>("plane"); * var im = new Image(pl); * var m = main_table.add(im); * main_table.row();*/ main_table.add(new Label("Starting thrust")); var tsl = new Slider(50, 275, 1, false, SliderStyle.create(Color.Gray, Color.Black)); tsl.setValue(thrust); var thr_label = new Label(thrust.ToString()); tsl.onChanged += (val) => { thrust = val; thr_label.setText(val.ToString()); }; main_table.add(tsl); main_table.add(thr_label); main_table.row(); main_table.add(new Label("Trim")); var sl = new Slider(-1, 1, 0.02f, false, SliderStyle.create(Color.Gray, Color.Black)); sl.setValue(trim); var trm_label = new Label(trim.ToString()); sl.onChanged += (val) => { trim = val; trm_label.setText(val.ToString()); }; main_table.add(sl); main_table.add(trm_label); main_table.row(); var go_button = new TextButton("Fly!", TextButtonStyle.create(Color.LightGray, Color.DarkGray, Color.Gray)); go_button.setWidth(100); go_button.setHeight(50); go_button.onClicked += (but) => { Console.WriteLine("ui " + trim + " " + thrust); Core.scene = new PlaneScene(trim, thrust); }; main_table.add(go_button); }
public UiAssets() { PixeledBMFont = FufCore.contentSource.Load <BitmapFont>("Fonts/bm_pixeled"); AndinaBMFont = FufCore.contentSource.Load <BitmapFont>("Fonts/bm_andina"); Andina = new NezSpriteFont(FufCore.contentSource.Load <SpriteFont>("Fonts/andina")); AndinaLarge = new NezSpriteFont(FufCore.contentSource.Load <SpriteFont>("Fonts/andina_lg")); const int buttonColorVal = 60; TextButtonStyle = new TextButtonStyle( new PrimitiveDrawable(new Color(buttonColorVal, buttonColorVal, buttonColorVal)), new PrimitiveDrawable(new Color(buttonColorVal, buttonColorVal, buttonColorVal, 204)), new PrimitiveDrawable(new Color(buttonColorVal, buttonColorVal, buttonColorVal, 153))) { downFontColor = Color.Gray, font = PixeledBMFont, fontColor = Color.GhostWhite, disabledFontColor = Color.DimGray }; }
public LobbyScene() { _gameSettings = GameSettings.Default; addRenderer(new ScreenSpaceRenderer(100, Constants.Layers.HUD)); addRenderer(new RenderLayerExcludeRenderer(0, Constants.Layers.HUD)); // create our canvas and put it on the screen space render layer canvas = createEntity("ui").addComponent(new UICanvas()); canvas.isFullScreen = true; canvas.renderLayer = Constants.Layers.HUD; clearColor = Color.Black; normalButtonColor = new PrimitiveDrawable(Color.Gray); pressedButtonColor = new PrimitiveDrawable(Color.Red); hoverButtonColor = new PrimitiveDrawable(Color.LightGray); disabledButtonColor = new PrimitiveDrawable(Color.Pink); normalButtonStyle = new TextButtonStyle(normalButtonColor, pressedButtonColor, hoverButtonColor); disabledButtonStyle = new TextButtonStyle(disabledButtonColor, disabledButtonColor, disabledButtonColor); SetupSceneSelector(); }
public TextButtonStyle(TextButtonStyle style) : base(style) { LabelStyle = style.LabelStyle != null ? new LabelStyle(style.LabelStyle) : null; }
/** Adds a text button to the button table. * @param object The object that will be passed to {@link #result(Object)} if this button is clicked. May be null. */ public Button AddButton(string text, TextButtonStyle buttonStyle) { return(AddButton(new TextButton(text, buttonStyle))); }
public TextButtonStyle(TextButtonStyle style) : base(style) { LabelStyle = new TextBlockStyle(style.LabelStyle); }
void SetupSceneSelector() { _table = Canvas.Stage.AddElement(new Table()); var sampleScenes = new Table().PadRight(5); _table.SetFillParent(true).Right().Top(); var topButtonStyle = new TextButtonStyle(new PrimitiveDrawable(Color.Black, 10f), new PrimitiveDrawable(Color.Yellow), new PrimitiveDrawable(Color.DarkSlateBlue)) { DownFontColor = Color.Black }; _table.Add(new TextButton("Toggle Scene List", topButtonStyle)).SetFillX().SetMinHeight(30) .GetElement <Button>().OnClicked += butt => { sampleScenes.SetIsVisible(!sampleScenes.IsVisible()); }; _table.Row().SetPadTop(10); var checkbox = _table.Add(new CheckBox("Debug Render", new CheckBoxStyle { CheckboxOn = new PrimitiveDrawable(30, Color.Green), CheckboxOff = new PrimitiveDrawable(30, new Color(0x00, 0x3c, 0xe7, 0xff)) })).GetElement <CheckBox>(); checkbox.OnChanged += enabled => Core.DebugRenderEnabled = enabled; checkbox.IsChecked = Core.DebugRenderEnabled; _table.Row(); _table.Add(sampleScenes).SetAlign(Align.Top); sampleScenes.Row(); sampleScenes.Add(new Label("Samples", new LabelStyle())).SetFillX().SetMinHeight(30); sampleScenes.Row(); var buttonStyle = new TextButtonStyle(new PrimitiveDrawable(new Color(78, 91, 98), 10f), new PrimitiveDrawable(new Color(244, 23, 135)), new PrimitiveDrawable(new Color(168, 207, 115))) { DownFontColor = Color.Black }; // find every Scene with the SampleSceneAttribute and create a button for each one foreach (var type in GetTypesWithSampleSceneAttribute()) { foreach (var attr in type.GetCustomAttributes(true)) { if (attr.GetType() == typeof(SampleSceneAttribute)) { var sampleAttr = attr as SampleSceneAttribute; var button = sampleScenes.Add(new TextButton(sampleAttr.ButtonName, buttonStyle)).SetFillX() .SetMinHeight(30).GetElement <TextButton>(); button.OnClicked += butt => { // stop all tweens in case any demo scene started some up TweenManager.StopAllTweens(); Core.GetGlobalManager <ImGuiManager>()?.SetEnabled(false); Core.StartSceneTransition(new FadeTransition(() => Activator.CreateInstance(type) as Scene)); }; sampleScenes.Row().SetPadTop(10); // optionally add instruction text for the current scene if (sampleAttr.InstructionText != null && type == GetType()) { AddInstructionText(sampleAttr.InstructionText); } } } } }
public override void Initialize() { base.Initialize(); //Load Assets, always load textures before generating items so they can match texture and ID TextureContainer.LoadTextures(); AbilityContainerClient.LoadAbilities(); KeyBindContainer.SetKeyBinds(); Entity e = CreateEntity("Wallpaper"); e.AddComponent(new SpriteRenderer(TextureContainer.LoginWallpaper)).SetOrigin(new Vector2(0, 0)); float h = (float)Screen.Height / (float)TextureContainer.LoginWallpaper.Height; float w = (float)Screen.Width / (float)TextureContainer.LoginWallpaper.Width; e.SetScale(new Vector2(w, h)); Sprite textfieldTexture = TextureContainer.GetSpriteAtlasByName("UI").GetSprite("Plank_03"); TextFieldStyle textFields = TextFieldStyle.Create(Color.White, Color.White, Color.Black, Color.DarkGray); NinePatchDrawable drawable = new NinePatchDrawable(textfieldTexture, 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; NinePatchDrawable drawablebutton = new NinePatchDrawable(TextureContainer.GetSpriteAtlasByName("UI").GetSprite("plank_15"), 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; NinePatchDrawable drawablehover = new NinePatchDrawable(TextureContainer.GetSpriteAtlasByName("UI").GetSprite("plank_18"), 0, 0, 0, 0) { MinHeight = 20, MinWidth = 50 }; textFields.Background = drawable; Label label = new Label("Menu").SetFontScale(5).SetFontColor(Color.MediumVioletRed); Table.Add(label); Label user = new Label("Username").SetFontScale(2).SetFontColor(Color.MediumVioletRed); Table.Row().SetPadTop(10); Table.Add(user).Pad(20); textFieldu = new TextField("", textFields); Table.Row().SetPadTop(10); Table.Add(textFieldu); Label pass = new Label("Password").SetFontScale(2).SetFontColor(Color.MediumVioletRed); Table.Row().SetPadTop(10); Table.Add(pass); textFieldp = new TextField("", textFields); Table.Row().SetPadTop(10); textFieldp.SetPasswordMode(true); Table.Add(textFieldp); TextButtonStyle textButtonStyle = new TextButtonStyle(drawablebutton, drawablehover, drawablehover); TextButton button = new TextButton("Login", textButtonStyle); button.Pad(10); button.PadLeft(20); button.PadRight(20); button.OnClicked += SendLogin; Table.Row().SetPadTop(10); Table.Add(button); TextButton buttonr = new TextButton("Register", textButtonStyle); buttonr.Pad(10); buttonr.PadLeft(20); buttonr.PadRight(20); buttonr.OnClicked += Sendregister; Table.Row().SetPadTop(10); Table.Add(buttonr); //var imGuiManager = new ImGuiManager(); //Core.RegisterGlobalManager(imGuiManager); //imGuiManager.SetEnabled(false); //imGuiManager.ShowDemoWindow = true; }