mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-29 05:29:44 +01:00
added and centered buttons
This commit is contained in:
parent
f4c4f6bc93
commit
ada067a2a0
@ -43,12 +43,8 @@ public class TradeMenu extends Dialog {
|
|||||||
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
|
mainContainer.setPreferredSize(new Vector3f(1200, 800, 0));
|
||||||
mainContainer.setBackground(translucentWhiteBackground);
|
mainContainer.setBackground(translucentWhiteBackground);
|
||||||
|
|
||||||
|
// Add header container
|
||||||
// Add title with background
|
mainContainer.addChild(createHeaderContainer());
|
||||||
Label headerLabel = mainContainer.addChild(new Label("Handelsmenu", new ElementId("label-Bold")));
|
|
||||||
headerLabel.setFontSize(40);
|
|
||||||
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f)));
|
|
||||||
|
|
||||||
// Add main content (three columns: left, middle, right)
|
// Add main content (three columns: left, middle, right)
|
||||||
mainContainer.addChild(createMainContent());
|
mainContainer.addChild(createMainContent());
|
||||||
|
|
||||||
@ -64,6 +60,26 @@ public class TradeMenu extends Dialog {
|
|||||||
//TODO Ebenen prüfen und eine Ebene Hochsetzen
|
//TODO Ebenen prüfen und eine Ebene Hochsetzen
|
||||||
//TODO Farben der Label anpassen
|
//TODO Farben der Label anpassen
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a container for the header with a fixed size.
|
||||||
|
*
|
||||||
|
* @return The header container.
|
||||||
|
*/
|
||||||
|
private Container createHeaderContainer() {
|
||||||
|
// Create a container for the header
|
||||||
|
Container headerContainer = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
|
headerContainer.setPreferredSize(new Vector3f(200, 100, 0)); // Set fixed width and height
|
||||||
|
|
||||||
|
// Add the header label
|
||||||
|
Label headerLabel = headerContainer.addChild(new Label("Handelsmenü", new ElementId("label-Bold")));
|
||||||
|
headerLabel.setFontSize(32); // Adjust font size as needed
|
||||||
|
headerLabel.setInsets(new Insets3f(10, 10, 10, 10)); // Add padding around the label
|
||||||
|
headerLabel.setBackground(new QuadBackgroundComponent(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f))); // Optional background
|
||||||
|
|
||||||
|
return headerContainer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the main content layout (left, middle, right columns).
|
* Creates the main content layout (left, middle, right columns).
|
||||||
*
|
*
|
||||||
@ -71,6 +87,7 @@ public class TradeMenu extends Dialog {
|
|||||||
*/
|
*/
|
||||||
private Container createMainContent() {
|
private Container createMainContent() {
|
||||||
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
Container mainContent = new Container(new SpringGridLayout(Axis.X, Axis.Y));
|
||||||
|
mainContent.setPreferredSize(new Vector3f(1200, 700, 0));
|
||||||
|
|
||||||
// Left Column
|
// Left Column
|
||||||
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
|
mainContent.addChild(createTradeColumn("Wähle Handelsobjekt:", true));
|
||||||
@ -86,11 +103,29 @@ public class TradeMenu extends Dialog {
|
|||||||
arrows.setFontSize(40);
|
arrows.setFontSize(40);
|
||||||
|
|
||||||
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
|
TextField rightSelectionsField = middleSection.addChild(new TextField("Zielobjekte..."));
|
||||||
|
// "Bestätigen" button
|
||||||
|
lowerRightMenu = new Container();
|
||||||
|
tradeButton.setPreferredSize(new Vector3f(200, 60, 0));
|
||||||
|
tradeButton.setFontSize(30);
|
||||||
|
tradeButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
close();
|
||||||
|
new TradeMenu(app).open();
|
||||||
|
}));
|
||||||
|
lowerRightMenu.addChild(tradeButton);
|
||||||
|
|
||||||
|
// Position the container near the bottom-right corner
|
||||||
|
lowerRightMenu.setLocalTranslation(new Vector3f(app.getCamera().getWidth() - 680, 100, 8)); // X: 220px from the right, Y: 50px above the bottom
|
||||||
|
app.getGuiNode().attachChild(lowerRightMenu);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Right Column
|
// Right Column
|
||||||
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
|
mainContent.addChild(createTradeColumn("Wähle Zielobjekt:", false));
|
||||||
|
|
||||||
|
Label spacer = middleSection.addChild(new Label("")); // Spacer
|
||||||
|
spacer.setPreferredSize(new Vector3f(1, 50, 0));
|
||||||
|
|
||||||
return mainContent;
|
return mainContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +138,7 @@ public class TradeMenu extends Dialog {
|
|||||||
*/
|
*/
|
||||||
private Container createTradeColumn(String label, boolean isLeft) {
|
private Container createTradeColumn(String label, boolean isLeft) {
|
||||||
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
Container column = new Container(new SpringGridLayout(Axis.Y, Axis.X));
|
||||||
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
column.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.White)));
|
||||||
|
|
||||||
Label columnLabel = column.addChild(new Label(label));
|
Label columnLabel = column.addChild(new Label(label));
|
||||||
columnLabel.setFontSize(24);
|
columnLabel.setFontSize(24);
|
||||||
@ -112,22 +147,46 @@ public class TradeMenu extends Dialog {
|
|||||||
// Add dropdowns
|
// Add dropdowns
|
||||||
column.addChild(new Label("Gebäude:"));
|
column.addChild(new Label("Gebäude:"));
|
||||||
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
Selector<String> buildingSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
|
buildingSelector.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||||
|
|
||||||
column.addChild(new Label("Währung:"));
|
column.addChild(new Label("Währung:"));
|
||||||
Selector<String> currencySelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
Selector<String> currencySelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
|
currencySelector.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||||
|
|
||||||
column.addChild(new Label("Sonderkarten:"));
|
column.addChild(new Label("Sonderkarten:"));
|
||||||
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
Selector<String> specialCardSelector = column.addChild(new Selector<>(getSampleItems(),"glass"));
|
||||||
|
specialCardSelector.setBackground(new QuadBackgroundComponent(new ColorRGBA(ColorRGBA.Black)));
|
||||||
|
|
||||||
// Assign selectors to corresponding fields
|
// Assign selectors to corresponding fields
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
leftBuildingSelector = buildingSelector;
|
leftBuildingSelector = buildingSelector;
|
||||||
leftCurrencySelector = currencySelector;
|
leftCurrencySelector = currencySelector;
|
||||||
leftSpecialCardSelector = specialCardSelector;
|
leftSpecialCardSelector = specialCardSelector;
|
||||||
} else {
|
|
||||||
|
// "Abbrechen" button
|
||||||
|
lowerLeftMenu = new Container();
|
||||||
|
cancelButton.setPreferredSize(new Vector3f(200, 60, 0));
|
||||||
|
cancelButton.setFontSize(30);
|
||||||
|
cancelButton.addClickCommands(s -> ifTopDialog(() -> {
|
||||||
|
app.getGameLogic().playSound(Sound.BUTTON);
|
||||||
|
close();
|
||||||
|
}));
|
||||||
|
lowerLeftMenu.addChild(cancelButton);
|
||||||
|
|
||||||
|
// Position the container near the bottom-left corner
|
||||||
|
lowerLeftMenu.setLocalTranslation(new Vector3f(70, 100, 8)); // Adjust X and Y to align with the bottom-left corner
|
||||||
|
app.getGuiNode().attachChild(lowerLeftMenu);
|
||||||
|
|
||||||
|
Label spacer = column.addChild(new Label("")); // Spacer
|
||||||
|
spacer.setPreferredSize(new Vector3f(1, 130, 0));
|
||||||
|
|
||||||
|
} else {
|
||||||
rightBuildingSelector = buildingSelector;
|
rightBuildingSelector = buildingSelector;
|
||||||
rightCurrencySelector = currencySelector;
|
rightCurrencySelector = currencySelector;
|
||||||
rightSpecialCardSelector = specialCardSelector;
|
rightSpecialCardSelector = specialCardSelector;
|
||||||
|
|
||||||
|
Label spacer = column.addChild(new Label("")); // Spacer
|
||||||
|
spacer.setPreferredSize(new Vector3f(1, 130, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
|
Loading…
Reference in New Issue
Block a user