mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-24 22:49:44 +01:00
Buttons im Startmenü angepasst
This commit is contained in:
parent
0d86ba0ca9
commit
c37b850798
@ -3,6 +3,7 @@
|
||||
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
||||
|
||||
import com.simsilica.lemur.*
|
||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||
|
||||
// Farben und allgemeine Stile
|
||||
def bgColor = color(1, 1, 1, 1)
|
||||
@ -10,14 +11,15 @@ def buttonEnabledColor = color(0.8, 0.9, 1, 1)
|
||||
def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
|
||||
def sliderColor = color(0.6, 0.8, 0.8, 1)
|
||||
def sliderBgColor = color(0.5, 0.75, 0.75, 1)
|
||||
def gradientColor = color(0.5, 0.75, 0.85, 0.5)
|
||||
def gradientColor = color(1, 1, 1, 1)
|
||||
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
|
||||
def playButtonBorderColor = color(1, 0.6, 0, 1) // For "Spielen" button
|
||||
def blackColor = color(0, 0, 0, 1) // Define black color for border
|
||||
|
||||
// Hintergrundverläufe
|
||||
def gradient = TbtQuadBackgroundComponent.create(
|
||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
|
||||
1, 1, 1, 126, 126, 1f, false)
|
||||
1, 1, 1, 126, 126, 1f, false)
|
||||
|
||||
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
||||
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png", generateMips: false)
|
||||
@ -77,6 +79,18 @@ selector("menu-button", "pp") {
|
||||
fontSize = 24
|
||||
}
|
||||
|
||||
// Apply border to all buttons in the "pp" style
|
||||
selector("button", "pp") {
|
||||
background = gradient.clone()
|
||||
background.setColor(bgColor) // Set background color
|
||||
background.setBorderColor(blackColor) // Set border color to black
|
||||
background.setBorderSize(2) // Set border thickness (adjust as needed)
|
||||
|
||||
color = buttonEnabledColor
|
||||
insets = new Insets3f(2, 2, 2, 2)
|
||||
buttonCommands = stdButtonCommands
|
||||
}
|
||||
|
||||
// Standard Button Commands (Animationseffekt)
|
||||
def pressedCommand = new Command<Button>() {
|
||||
void execute(Button source) {
|
||||
|
@ -8,6 +8,7 @@ import com.jme3.texture.Texture;
|
||||
import com.simsilica.lemur.Axis;
|
||||
import com.simsilica.lemur.Button;
|
||||
import com.simsilica.lemur.Container;
|
||||
import com.simsilica.lemur.HAlignment;
|
||||
import com.simsilica.lemur.Label;
|
||||
import com.simsilica.lemur.component.SpringGridLayout;
|
||||
|
||||
@ -51,33 +52,36 @@ public class StartMenu extends Dialog {
|
||||
|
||||
// Center container for title and play button
|
||||
Container centerMenu = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||
Label titleLabel = new Label("Hauptmenü");
|
||||
titleLabel.setFontSize(48);
|
||||
centerMenu.addChild(titleLabel);
|
||||
|
||||
Button startButton = new Button("Spielen");
|
||||
startButton.setPreferredSize(new Vector3f(190, 60, 0)); // Increase button size (width, height)
|
||||
startButton.setFontSize(40); // Set the font size for the button text
|
||||
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
|
||||
startButton.addClickCommands(source -> startGame(app));
|
||||
centerMenu.addChild(startButton);
|
||||
|
||||
// Position the center container in the middle of the screen
|
||||
centerMenu.setLocalTranslation(new Vector3f(
|
||||
screenWidth / 2f - centerMenu.getPreferredSize().x / 2f,
|
||||
screenHeight / 2f + centerMenu.getPreferredSize().y / 2f,
|
||||
0));
|
||||
centerMenu.setLocalTranslation(new Vector3f(screenWidth / 2f - centerMenu.getPreferredSize().x / 2f,
|
||||
screenHeight / 2f - 280 + centerMenu.getPreferredSize().y / 2f,
|
||||
0));
|
||||
app.getGuiNode().attachChild(centerMenu);
|
||||
|
||||
// Lower-left container for "Spiel beenden" button
|
||||
Container lowerLeftMenu = new Container();
|
||||
lowerLeftMenu.setLocalTranslation(new Vector3f(50, 50, 0));
|
||||
lowerLeftMenu.setLocalTranslation(new Vector3f(100, 90, 0));
|
||||
Button quitButton = new Button("Spiel beenden");
|
||||
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
||||
quitButton.setFontSize(20);
|
||||
quitButton.addClickCommands(source -> quitGame());
|
||||
lowerLeftMenu.addChild(quitButton);
|
||||
app.getGuiNode().attachChild(lowerLeftMenu);
|
||||
|
||||
// Lower-right container for "Einstellungen" button
|
||||
Container lowerRightMenu = new Container();
|
||||
lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 150, 50, 0));
|
||||
lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 200, 90, 0));
|
||||
Button settingsButton = new Button("Einstellungen");
|
||||
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
|
||||
settingsButton.setFontSize(20); // Increase the font size for the text
|
||||
settingsButton.addClickCommands(source -> openSettings(app));
|
||||
lowerRightMenu.addChild(settingsButton);
|
||||
app.getGuiNode().attachChild(lowerRightMenu);
|
||||
|
Loading…
Reference in New Issue
Block a user