mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 01:09:46 +01:00
eigenes GUI Styling eingeführt
This commit is contained in:
parent
6dcfb92dba
commit
8e3cb43244
@ -1,76 +1,60 @@
|
|||||||
// Styling of Lemur components
|
// Styling of Lemur components
|
||||||
// For documentation, see:
|
// For documentation, see:
|
||||||
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
// https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Styling
|
||||||
|
|
||||||
import com.simsilica.lemur.*
|
import com.simsilica.lemur.*
|
||||||
import com.simsilica.lemur.component.QuadBackgroundComponent
|
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||||
|
import com.simsilica.lemur.Button
|
||||||
|
import com.simsilica.lemur.Button.ButtonAction
|
||||||
|
import com.simsilica.lemur.Command
|
||||||
|
import com.simsilica.lemur.HAlignment
|
||||||
|
import com.simsilica.lemur.Insets3f
|
||||||
|
import com.simsilica.lemur.component.QuadBackgroundComponent
|
||||||
|
import com.simsilica.lemur.component.TbtQuadBackgroundComponent
|
||||||
|
|
||||||
def bgColor = color(1, 1, 1, 1)
|
def bgColor = color(0.25, 0.5, 0.5, 1)
|
||||||
def buttonEnabledColor = color(0.8, 0.9, 1, 1)
|
def buttonEnabledColor = color(0.8, 0.9, 1, 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(0, 0.75, 0.75, 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(1, 1, 1, 1)
|
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 playButtonBorderColor = color(1, 0.6, 0, 1) // For "Spielen" button
|
|
||||||
def blackColor = color(0, 0, 0, 1) // Define black color for border
|
|
||||||
|
|
||||||
def playButtonBorderColor = color(1, 0.6, 0, 1) // Orange border for "Spielen" button
|
|
||||||
def playButtonTextColor = color(0, 0, 0, 1) // Black text color for "Spielen" button
|
|
||||||
def buttonBgColor = color(1, 1, 1, 1) // White background for "Spiel beenden" and "Einstellungen" buttons
|
|
||||||
def buttonTextColor = color(0, 0, 0, 1) // Black text color for "Spiel beenden" and "Einstellungen" buttons
|
|
||||||
def borderColor = color(0, 0, 0, 1) // Black border for "Spiel beenden" and "Einstellungen"
|
|
||||||
|
|
||||||
|
|
||||||
def gradient = TbtQuadBackgroundComponent.create(
|
def gradient = TbtQuadBackgroundComponent.create(
|
||||||
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png", generateMips: false),
|
texture(name: "/com/simsilica/lemur/icons/bordered-gradient.png",
|
||||||
1, 1, 1, 126, 126, 1f, false)
|
generateMips: false),
|
||||||
|
1, 1, 1, 126, 126,
|
||||||
|
1f, false)
|
||||||
|
|
||||||
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
def doubleGradient = new QuadBackgroundComponent(gradientColor)
|
||||||
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png", generateMips: false)
|
doubleGradient.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
||||||
|
generateMips: false)
|
||||||
|
|
||||||
// Hauptstil für die Schriftart
|
|
||||||
selector("pp") {
|
selector("pp") {
|
||||||
font = font("Interface/Fonts/Metropolis/Metropolis-Regular-32.fnt")
|
font = font("Interface/Fonts/Metropolis/Metropolis-Regular-32.fnt")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Titel für "Einstellungen"
|
selector("label", "pp") {
|
||||||
selector("settings-title", "pp") {
|
insets = new Insets3f(2, 2, 2, 2)
|
||||||
color = color(1, 1, 1, 1)
|
color = buttonEnabledColor
|
||||||
fontSize = 48
|
}
|
||||||
textHAlignment = HAlignment.Center
|
|
||||||
insets = new Insets3f(5, 5, 5, 5)
|
selector("header", "pp") {
|
||||||
|
font = font("Interface/Fonts/Metropolis/Metropolis-Bold-42.fnt")
|
||||||
|
insets = new Insets3f(2, 2, 2, 2)
|
||||||
|
color = color(1, 0.5, 0, 1)
|
||||||
|
textHAlignment = HAlignment.Center
|
||||||
}
|
}
|
||||||
|
|
||||||
// Container Stil
|
|
||||||
selector("container", "pp") {
|
selector("container", "pp") {
|
||||||
background = gradient.clone()
|
background = gradient.clone()
|
||||||
background.setColor(bgColor)
|
background.setColor(bgColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slider Stil
|
|
||||||
selector("slider", "pp") {
|
selector("slider", "pp") {
|
||||||
insets = new Insets3f(5, 10, 5, 10) // Abstand
|
background = gradient.clone()
|
||||||
background = new QuadBackgroundComponent(sliderBgColor)
|
background.setColor(bgColor)
|
||||||
}
|
|
||||||
|
|
||||||
selector("play-button", "pp") {
|
|
||||||
color = playButtonTextColor // Black text color
|
|
||||||
background = new QuadBackgroundComponent(playButtonBorderColor) // Orange border background
|
|
||||||
insets = new Insets3f(15, 25, 15, 25) // Padding for larger button size
|
|
||||||
background.setMargin(5, 5) // Thin border effect around the background color
|
|
||||||
fontSize = 36 // Larger font size for prominence
|
|
||||||
}
|
|
||||||
|
|
||||||
selector("menu-button", "pp") {
|
|
||||||
color = buttonTextColor // Black text color
|
|
||||||
background = new QuadBackgroundComponent(buttonBgColor) // White background
|
|
||||||
insets = new Insets3f(10, 20, 10, 20) // Padding
|
|
||||||
background.setMargin(1, 1) // Thin black border
|
|
||||||
background.setColor(borderColor) // Set black border color
|
|
||||||
|
|
||||||
fontSize = 24 // Standard font size
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def pressedCommand = new Command<Button>() {
|
def pressedCommand = new Command<Button>() {
|
||||||
@ -91,6 +75,30 @@ def enabledCommand = new Command<Button>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def repeatCommand = new Command<Button>() {
|
||||||
|
private long startTime
|
||||||
|
private long lastClick
|
||||||
|
|
||||||
|
void execute(Button source) {
|
||||||
|
// Only do the repeating click while the mouse is
|
||||||
|
// over the button (and pressed of course)
|
||||||
|
if (source.isPressed() && source.isHighlightOn()) {
|
||||||
|
long elapsedTime = System.currentTimeMillis() - startTime
|
||||||
|
// After half a second pause, click 8 times a second
|
||||||
|
if (elapsedTime > 500 && elapsedTime > lastClick + 125) {
|
||||||
|
source.click()
|
||||||
|
|
||||||
|
// Try to quantize the last click time to prevent drift
|
||||||
|
lastClick = ((elapsedTime - 500) / 125) * 125 + 500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startTime = System.currentTimeMillis()
|
||||||
|
lastClick = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def stdButtonCommands = [
|
def stdButtonCommands = [
|
||||||
(ButtonAction.Down) : [pressedCommand],
|
(ButtonAction.Down) : [pressedCommand],
|
||||||
(ButtonAction.Up) : [pressedCommand],
|
(ButtonAction.Up) : [pressedCommand],
|
||||||
@ -98,9 +106,98 @@ def stdButtonCommands = [
|
|||||||
(ButtonAction.Disabled): [enabledCommand]
|
(ButtonAction.Disabled): [enabledCommand]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def sliderButtonCommands = [
|
||||||
|
(ButtonAction.Hover): [repeatCommand]
|
||||||
|
]
|
||||||
|
|
||||||
|
selector("title", "pp") {
|
||||||
|
color = color(0.8, 0.9, 1, 0.85f)
|
||||||
|
highlightColor = color(1, 0.8, 1, 0.85f)
|
||||||
|
shadowColor = color(0, 0, 0, 0.75f)
|
||||||
|
shadowOffset = vec3(2, -2, -1)
|
||||||
|
background = new QuadBackgroundComponent(color(0.5, 0.75, 0.85, 1))
|
||||||
|
background.texture = texture(name: "/com/simsilica/lemur/icons/double-gradient-128.png",
|
||||||
|
generateMips: false)
|
||||||
|
insets = new Insets3f(2, 2, 2, 2)
|
||||||
|
|
||||||
|
buttonCommands = stdButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
selector("button", "pp") {
|
selector("button", "pp") {
|
||||||
background = gradient.clone()
|
background = gradient.clone()
|
||||||
color = buttonEnabledColor
|
color = buttonEnabledColor
|
||||||
|
background.setColor(buttonBgColor)
|
||||||
insets = new Insets3f(2, 2, 2, 2)
|
insets = new Insets3f(2, 2, 2, 2)
|
||||||
|
|
||||||
|
buttonCommands = stdButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider", "pp") {
|
||||||
|
insets = new Insets3f(1, 3, 1, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider", "button", "pp") {
|
||||||
|
background = doubleGradient.clone()
|
||||||
|
//background.setColor(sliderBgColor)
|
||||||
|
insets = new Insets3f(0, 0, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider.thumb.button", "pp") {
|
||||||
|
text = "[]"
|
||||||
|
color = sliderColor
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider.left.button", "pp") {
|
||||||
|
text = "-"
|
||||||
|
background = doubleGradient.clone()
|
||||||
|
//background.setColor(sliderBgColor)
|
||||||
|
background.setMargin(5, 0)
|
||||||
|
color = sliderColor
|
||||||
|
|
||||||
|
buttonCommands = sliderButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider.right.button", "pp") {
|
||||||
|
text = "+"
|
||||||
|
background = doubleGradient.clone()
|
||||||
|
//background.setColor(sliderBgColor)
|
||||||
|
background.setMargin(4, 0)
|
||||||
|
color = sliderColor
|
||||||
|
|
||||||
|
buttonCommands = sliderButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider.up.button", "pp") {
|
||||||
|
buttonCommands = sliderButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("slider.down.button", "pp") {
|
||||||
|
buttonCommands = sliderButtonCommands
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("checkbox", "pp") {
|
||||||
|
color = buttonEnabledColor
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("rollup", "pp") {
|
||||||
|
background = gradient.clone()
|
||||||
|
background.setColor(bgColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("tabbedPanel", "pp") {
|
||||||
|
activationColor = buttonEnabledColor
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("tabbedPanel.container", "pp") {
|
||||||
|
background = null
|
||||||
|
}
|
||||||
|
|
||||||
|
selector("tab.button", "pp") {
|
||||||
|
background = gradient.clone()
|
||||||
|
background.setColor(bgColor)
|
||||||
|
color = tabbuttonEnabledColor
|
||||||
|
insets = new Insets3f(4, 2, 0, 2)
|
||||||
|
|
||||||
buttonCommands = stdButtonCommands
|
buttonCommands = stdButtonCommands
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,15 @@ public class MonopolyApp extends SimpleApplication implements MonopolyClient, Ga
|
|||||||
private SettingsMenu settingsMenu;
|
private SettingsMenu settingsMenu;
|
||||||
private final Draw draw;
|
private final Draw draw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
|
||||||
private boolean isSettingsMenuOpen = false;
|
private boolean isSettingsMenuOpen = false;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -84,8 +93,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();
|
||||||
|
Loading…
Reference in New Issue
Block a user