diff --git a/app/src/main/java/org/vibecoders/moongazer/buttons/IngameButton.java b/app/src/main/java/org/vibecoders/moongazer/buttons/IngameButton.java new file mode 100644 index 0000000..0a0c082 --- /dev/null +++ b/app/src/main/java/org/vibecoders/moongazer/buttons/IngameButton.java @@ -0,0 +1,11 @@ +package org.vibecoders.moongazer.buttons; + +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; + +public class IngameButton extends BaseButton { + private ImageButton imageButton; + + public IngameButton() { + + } +} diff --git a/app/src/main/java/org/vibecoders/moongazer/buttons/MenuButton.java b/app/src/main/java/org/vibecoders/moongazer/buttons/MenuButton.java index b454a69..bc18bd6 100644 --- a/app/src/main/java/org/vibecoders/moongazer/buttons/MenuButton.java +++ b/app/src/main/java/org/vibecoders/moongazer/buttons/MenuButton.java @@ -1,46 +1,31 @@ package org.vibecoders.moongazer.buttons; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; public class MenuButton extends BaseButton { private TextButton textButton; public MenuButton(String text, BitmapFont font) { - this(text, font, Color.WHITE, Color.YELLOW); - } - - public MenuButton(String text, BitmapFont font, Color normalColor, Color hoverColor) { + Texture buttonTexture = new Texture(Gdx.files.internal("icons/MenuIcon.png")); + TextureRegionDrawable buttonDrawable = new TextureRegionDrawable(new TextureRegion(buttonTexture)); TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(); style.font = font; - style.fontColor = normalColor; - style.overFontColor = hoverColor; - style.downFontColor = hoverColor; + style.fontColor = Color.BLACK; + style.overFontColor = Color.BLUE; + style.downFontColor = Color.BLUE; - // Transparent backgrounds - style.up = null; - style.down = null; - style.over = null; - style.checked = null; + style.up = buttonDrawable; + style.down = buttonDrawable; + style.over = buttonDrawable; textButton = new TextButton(text, style); - - // Add the text button as an actor to this button this.actor = textButton; } - - public TextButton getTextButton() { - return textButton; - } - - public void setText(String text) { - textButton.setText(text); - } - - public String getText() { - return textButton.getText().toString(); - } } \ No newline at end of file diff --git a/app/src/main/java/org/vibecoders/moongazer/scenes/MainMenu.java b/app/src/main/java/org/vibecoders/moongazer/scenes/MainMenu.java index 65cd246..06c720a 100644 --- a/app/src/main/java/org/vibecoders/moongazer/scenes/MainMenu.java +++ b/app/src/main/java/org/vibecoders/moongazer/scenes/MainMenu.java @@ -2,8 +2,10 @@ package org.vibecoders.moongazer.scenes; import static org.vibecoders.moongazer.Constants.*; +import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import org.vibecoders.moongazer.buttons.MenuButton; import org.vibecoders.moongazer.managers.Assets; import org.vibecoders.moongazer.Game; @@ -24,10 +26,61 @@ public class MainMenu extends Scene { var font = Assets.getFont("ui", 24); textLabel = new Label("Moongazer", new LabelStyle(font, Color.BLACK)); textLabel.setPosition(WINDOW_WIDTH / 2f - textLabel.getWidth() / 2f, WINDOW_HEIGHT / 2f - textLabel.getHeight() / 2f); + + MenuButton playButton = new MenuButton("Play", font); + MenuButton loadButton = new MenuButton("Load", font); + MenuButton settingsButton = new MenuButton("Settings", font); + MenuButton exitButton = new MenuButton("Exit", font); + + int buttonWidth = 220; + int buttonHeight = 65; + playButton.setSize(buttonWidth, buttonHeight); + loadButton.setSize(buttonWidth, buttonHeight); + settingsButton.setSize(buttonWidth, buttonHeight); + exitButton.setSize(buttonWidth, buttonHeight); + + int centerX = WINDOW_WIDTH / 2 - buttonWidth / 2; + int startY = WINDOW_HEIGHT / 2 - buttonHeight / 2; + int buttonSpacing = 50; + + playButton.setPosition(centerX, startY); + loadButton.setPosition(centerX, startY - buttonSpacing); + settingsButton.setPosition(centerX, startY - buttonSpacing * 2); + exitButton.setPosition(centerX, startY - buttonSpacing * 3); + + playButton.getActor().addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + System.out.println("Play clicked"); + } + }); + + loadButton.getActor().addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + System.out.println("Load clicked"); + } + }); + + settingsButton.getActor().addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + System.out.println("Settings clicked"); + } + }); + + exitButton.getActor().addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + System.out.println("Exit clicked"); + } + }); + game.root.addActor(textLabel); - MenuButton startButton = new MenuButton("Start", font); - startButton.getActor().setPosition(WINDOW_WIDTH / 2f, WINDOW_HEIGHT / 2f); - game.root.addActor(startButton.getActor()); + game.root.addActor(playButton.getActor()); + game.root.addActor(loadButton.getActor()); + game.root.addActor(settingsButton.getActor()); + game.root.addActor(exitButton.getActor()); } /** * Renders the main menu scene. @@ -35,7 +88,7 @@ public class MainMenu extends Scene { */ @Override public void render(SpriteBatch batch) { - batch.draw(TEXTURE_BLACK, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); + batch.draw(TEXTURE_WHITE, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT); // Unneeded as using Scene2D Stage to render the label // textLabel.draw(batch, 1.0f); } diff --git a/app/src/main/resources/icons/MenuIcon.png b/app/src/main/resources/icons/MenuIcon.png new file mode 100644 index 0000000..0802ffb Binary files /dev/null and b/app/src/main/resources/icons/MenuIcon.png differ