This commit is contained in:
Luca Puderbach 2024-11-18 08:05:35 +01:00
commit 20949b641e
3 changed files with 35 additions and 21 deletions

View File

@ -11,14 +11,16 @@ import com.simsilica.lemur.Insets3f
import com.simsilica.lemur.component.QuadBackgroundComponent import com.simsilica.lemur.component.QuadBackgroundComponent
import com.simsilica.lemur.component.TbtQuadBackgroundComponent import com.simsilica.lemur.component.TbtQuadBackgroundComponent
def bgColor = color(0.25, 0.5, 0.5, 1) def bgColor = color(1, 1, 1, 1)
def buttonEnabledColor = color(0.8, 0.9, 1, 1) def buttonEnabledColor = color(0, 0, 0, 1)
def buttonDisabledColor = color(0.8, 0.9, 1, 0.2) def buttonDisabledColor = color(0.8, 0.9, 1, 0.2)
def buttonBgColor = color(0, 0.75, 0.75, 1) def buttonBgColor = color(1, 1, 1, 1)
def sliderColor = color(0.6, 0.8, 0.8, 1) def sliderColor = color(0.6, 0.8, 0.8, 1)
def sliderBgColor = color(0.5, 0.75, 0.75, 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(0.5, 0.75, 0.85, 0.5)
def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1) def tabbuttonEnabledColor = color(0.4, 0.45, 0.5, 1)
def solidWhiteBackground = new QuadBackgroundComponent(color(1, 1, 1, 1)) // Solid white
def gradient = TbtQuadBackgroundComponent.create( def gradient = TbtQuadBackgroundComponent.create(
@ -31,6 +33,13 @@ def doubleGradient = new QuadBackgroundComponent(gradientColor)
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png", doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
generateMips: false) generateMips: false)
def orangeBorder = TbtQuadBackgroundComponent.create(
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", // Replace with an appropriate texture if needed
generateMips: false),
1, 1, 1, 126, 126,
1f, false)
orangeBorder.color = color(1, 0.5, 0, 1) // Orange color
selector("pp") { selector("pp") {
font = font("Interface/Fonts/Metropolis/Metropolis-Regular-32.fnt") font = font("Interface/Fonts/Metropolis/Metropolis-Regular-32.fnt")
} }
@ -48,7 +57,7 @@ selector("header", "pp") {
} }
selector("container", "pp") { selector("container", "pp") {
background = gradient.clone() background = solidWhiteBackground.clone()
background.setColor(bgColor) background.setColor(bgColor)
} }
@ -125,11 +134,14 @@ selector("title", "pp") {
selector("button", "pp") { selector("button", "pp") {
background = gradient.clone() def outerBackground = new QuadBackgroundComponent(color(1, 0.5, 0, 1)) // Orange border
color = buttonEnabledColor def innerBackground = new QuadBackgroundComponent(buttonBgColor) // Inner button background
background.setColor(buttonBgColor)
insets = new Insets3f(2, 2, 2, 2)
// Apply the outer border as the main background
background = outerBackground
// Use insets to create a margin/padding effect for the inner background
insets = new Insets3f(3, 3, 3, 3) // Adjust the border thickness
buttonCommands = stdButtonCommands buttonCommands = stdButtonCommands
} }
@ -194,7 +206,7 @@ selector("tabbedPanel.container", "pp") {
} }
selector("tab.button", "pp") { selector("tab.button", "pp") {
background = gradient.clone() background = solidWhiteBackground.clone()
background.setColor(bgColor) background.setColor(bgColor)
color = tabbuttonEnabledColor color = tabbuttonEnabledColor
insets = new Insets3f(4, 2, 0, 2) insets = new Insets3f(4, 2, 0, 2)

View File

@ -37,6 +37,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
private TestWorld testWorld; private TestWorld testWorld;
private boolean isSettingsMenuOpen = false; private boolean isSettingsMenuOpen = false;
private boolean inputBlocked = false; private boolean inputBlocked = false;
/**
* Path to the styles script for GUI elements.
*/
private static final String STYLES_SCRIPT = "Interface/Lemur/pp-styles.groovy"; //NON-NLS
/**
* Path to the font resource used in the GUI.
*/
private static final String FONT = "Interface/Fonts/Default.fnt"; //NON-NLS
public static void main(String[] args) { public static void main(String[] args) {
new MonopolyApp().start(); new MonopolyApp().start();
@ -73,8 +82,9 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
GuiGlobals.initialize(this); GuiGlobals.initialize(this);
BaseStyles.loadGlassStyle(); BaseStyles.loadStyleResources(STYLES_SCRIPT);
GuiGlobals.getInstance().getStyles().setDefaultStyle("glass"); GuiGlobals.getInstance().getStyles().setDefaultStyle("pp"); //NON-NLS
final BitmapFont normalFont = assetManager.loadFont(FONT); //NON-NLS
setupInput(); setupInput();
setupGui(); setupGui();

View File

@ -60,14 +60,6 @@ public class StartMenu extends Dialog {
startButton.setFontSize(40); // Set the font size for the button text startButton.setFontSize(40); // Set the font size for the button text
startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally startButton.setTextHAlignment(HAlignment.Center); // Center the text horizontally
// Set a custom border and background color
ColorRGBA borderColor = ColorRGBA.Orange; // Example: White border
ColorRGBA backgroundColor = ColorRGBA.LightGray; // Example: light gray background
QuadBackgroundComponent backgroundColorSp = new QuadBackgroundComponent(backgroundColor);
backgroundColorSp.setMargin(2, 2); // Optional: Adjust margin for the border
backgroundColorSp.setColor(borderColor); // Set border color
startButton.setBackground(backgroundColorSp);
startButton.addClickCommands(source -> startGame(app)); startButton.addClickCommands(source -> startGame(app));
centerMenu.addChild(startButton); centerMenu.addChild(startButton);
@ -82,7 +74,7 @@ public class StartMenu extends Dialog {
lowerLeftMenu.setLocalTranslation(new Vector3f(100, 90, 0)); lowerLeftMenu.setLocalTranslation(new Vector3f(100, 90, 0));
Button quitButton = new Button("Spiel beenden"); Button quitButton = new Button("Spiel beenden");
quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) quitButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
quitButton.setFontSize(20); quitButton.setFontSize(18);
quitButton.addClickCommands(source -> quitGame()); quitButton.addClickCommands(source -> quitGame());
lowerLeftMenu.addChild(quitButton); lowerLeftMenu.addChild(quitButton);
app.getGuiNode().attachChild(lowerLeftMenu); app.getGuiNode().attachChild(lowerLeftMenu);
@ -92,7 +84,7 @@ public class StartMenu extends Dialog {
lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 200, 90, 0)); lowerRightMenu.setLocalTranslation(new Vector3f(screenWidth - 200, 90, 0));
Button settingsButton = new Button("Einstellungen"); Button settingsButton = new Button("Einstellungen");
settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height) settingsButton.setPreferredSize(new Vector3f(130, 40, 0)); // Increase button size slightly (width, height)
settingsButton.setFontSize(20); // Increase the font size for the text settingsButton.setFontSize(18); // Increase the font size for the text
settingsButton.addClickCommands(source -> openSettings(app)); settingsButton.addClickCommands(source -> openSettings(app));
lowerRightMenu.addChild(settingsButton); lowerRightMenu.addChild(settingsButton);
app.getGuiNode().attachChild(lowerRightMenu); app.getGuiNode().attachChild(lowerRightMenu);