Skip to content
Snippets Groups Projects
Commit 431010e7 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #33

parent 11c0c758
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,9 @@
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
......@@ -20,7 +22,7 @@
</Label>
<VBox prefHeight="649.0" prefWidth="590.0" AnchorPane.bottomAnchor="36.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0">
<children>
<HBox prefHeight="643.0" prefWidth="622.0">
<HBox prefHeight="296.0" prefWidth="590.0">
<children>
<VBox alignment="TOP_CENTER" spacing="50.0" HBox.hgrow="ALWAYS">
<children>
......@@ -65,6 +67,20 @@
</VBox>
</children>
</HBox>
<Separator prefWidth="200.0" />
<Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Controls">
<font>
<Font name="System Bold" size="25.0" />
</font>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</Label>
<TableView fx:id="tableViewControls" prefHeight="200.0" prefWidth="200.0">
<VBox.margin>
<Insets top="10.0" />
</VBox.margin>
</TableView>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="buttonBack" minHeight="42.0" minWidth="154.0" mnemonicParsing="false" onAction="#back" prefHeight="42.0" prefWidth="150.0" text="Back">
......
package de.bricked.ui;
public class Control
{
private String action;
private String key;
public Control(String action, String key)
{
this.action = action;
this.key = key;
}
public String getAction()
{
return action;
}
public String getKey()
{
return key;
}
}
\ No newline at end of file
package de.bricked.ui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;
import java.util.ResourceBundle;
......@@ -8,6 +9,7 @@ import de.bricked.game.Game;
import de.bricked.game.settings.GameSize;
import de.bricked.ui.cells.ComboBoxLanguageCell;
import de.bricked.ui.cells.ComboBoxResolutionCell;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
......@@ -18,6 +20,9 @@ import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.Slider;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TableView;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
......@@ -35,6 +40,7 @@ public class SettingsController
@FXML private ComboBox<LanguageType> comboBoxLanguage;
@FXML private CheckBox checkBoxSound;
@FXML private Slider sliderVolume;
@FXML private TableView<Control> tableViewControls;
public Stage stage;
public Image icon = new Image("de/bricked/resources/icon.png");
......@@ -101,6 +107,8 @@ public class SettingsController
}
sliderVolume.setValue(game.getSettings().getVolume() * 100);
initTableViewControls();
mainPane.setStyle("-fx-base: " + bundle.getString("color.background") + ";");
}
......@@ -125,6 +133,47 @@ public class SettingsController
controller.stage.show();
}
private void initTableViewControls()
{
ArrayList<Control> controls = new ArrayList<>();
controls.add(new Control("Start Ball", "Space / Left Mouse Button"));
controls.add(new Control("Move Paddle", "Arrow Keys / Mouse"));
controls.add(new Control("Pause", "P"));
controls.add(new Control("Exit Level / Back", "Esc"));
TableColumn<Control, String> columnAction = new TableColumn<>("Action");
columnAction.setCellValueFactory(new Callback<CellDataFeatures<Control, String>, ObservableValue<String>>()
{
public ObservableValue<String> call(CellDataFeatures<Control, String> param)
{
Control control = (Control)param.getValue();
return new SimpleStringProperty(control.getAction());
}
});
tableViewControls.getColumns().add(columnAction);
columnAction.setStyle( "-fx-alignment: CENTER; -fx-font-weight: bold;");
columnAction.prefWidthProperty().bind(tableViewControls.widthProperty().divide(2).subtract(2));
columnAction.setResizable(false);
columnAction.setSortable(false);
TableColumn<Control, String> columnKey = new TableColumn<>("Key");
columnKey.setCellValueFactory(new Callback<CellDataFeatures<Control, String>, ObservableValue<String>>()
{
public ObservableValue<String> call(CellDataFeatures<Control, String> param)
{
Control control = (Control)param.getValue();
return new SimpleStringProperty(control.getKey());
}
});
tableViewControls.getColumns().add(columnKey);
columnKey.setStyle( "-fx-alignment: CENTER; -fx-font-weight: bold;");
columnKey.prefWidthProperty().bind(tableViewControls.widthProperty().divide(2).subtract(2));
columnKey.setResizable(false);
columnKey.setSortable(false);
tableViewControls.getItems().addAll(controls);
}
public void showCommandLine()
{
try
......
......@@ -5,7 +5,9 @@
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
......@@ -20,7 +22,7 @@
</Label>
<VBox prefHeight="649.0" prefWidth="590.0" AnchorPane.bottomAnchor="36.0" AnchorPane.leftAnchor="30.0" AnchorPane.rightAnchor="30.0">
<children>
<HBox prefHeight="643.0" prefWidth="622.0">
<HBox prefHeight="296.0" prefWidth="590.0">
<children>
<VBox alignment="TOP_CENTER" spacing="50.0" HBox.hgrow="ALWAYS">
<children>
......@@ -65,6 +67,20 @@
</VBox>
</children>
</HBox>
<Separator prefWidth="200.0" />
<Label alignment="CENTER" maxWidth="1.7976931348623157E308" text="Controls">
<font>
<Font name="System Bold" size="25.0" />
</font>
<VBox.margin>
<Insets top="15.0" />
</VBox.margin>
</Label>
<TableView fx:id="tableViewControls" prefHeight="200.0" prefWidth="200.0">
<VBox.margin>
<Insets top="10.0" />
</VBox.margin>
</TableView>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Button fx:id="buttonBack" minHeight="42.0" minWidth="154.0" mnemonicParsing="false" onAction="#back" prefHeight="42.0" prefWidth="150.0" text="Back">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment