Scaling-image-thonk
This commit is contained in:
@@ -101,8 +101,8 @@ public class WhatAStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadGame() {
|
public void loadGame() {
|
||||||
questGenerator = questManager.get("test");
|
//questGenerator = questManager.get("test");
|
||||||
//questGenerator = new RandomQuestGenerator();
|
questGenerator = new RandomQuestGenerator();
|
||||||
quests.clear();
|
quests.clear();
|
||||||
storage = new Storage(GRID_SIZE, GRID_SIZE, GRID_SIZE);
|
storage = new Storage(GRID_SIZE, GRID_SIZE, GRID_SIZE);
|
||||||
balance = new Balance();
|
balance = new Balance();
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package de.siphalor.was.visual.jfx;
|
||||||
|
|
||||||
|
import javafx.beans.property.ObjectProperty;
|
||||||
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
|
public class ScalingImagePane extends ScrollPane {
|
||||||
|
private final ImageView imageView;
|
||||||
|
|
||||||
|
public ScalingImagePane() {
|
||||||
|
setHbarPolicy(ScrollBarPolicy.NEVER);
|
||||||
|
setVbarPolicy(ScrollBarPolicy.NEVER);
|
||||||
|
setFocusTraversable(false);
|
||||||
|
getStyleClass().add("edge-to-edge");
|
||||||
|
|
||||||
|
imageView = new ImageView();
|
||||||
|
imageView.setPreserveRatio(true);
|
||||||
|
imageView.setSmooth(true);
|
||||||
|
imageView.fitWidthProperty().bind(widthProperty());
|
||||||
|
imageView.fitHeightProperty().bind(heightProperty());
|
||||||
|
|
||||||
|
setContent(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage() {
|
||||||
|
return imageView.getImage();
|
||||||
|
}
|
||||||
|
public void setImage(Image image) {
|
||||||
|
imageView.setImage(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectProperty<Image> imageProperty() {
|
||||||
|
return imageView.imageProperty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.input.*;
|
import javafx.scene.input.*;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -16,13 +15,13 @@ public class StorageSlotController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Parent slot;
|
private Parent slot;
|
||||||
|
|
||||||
public ImageView slot0;
|
public ScalingImagePane slot0;
|
||||||
public Label slot0Title;
|
public Label slot0Title;
|
||||||
|
|
||||||
public ImageView slot1;
|
public ScalingImagePane slot1;
|
||||||
public Label slot1Title;
|
public Label slot1Title;
|
||||||
|
|
||||||
public ImageView slot2;
|
public ScalingImagePane slot2;
|
||||||
public Label slot2Title;
|
public Label slot2Title;
|
||||||
|
|
||||||
public StorageSlotController(int x, int y) {
|
public StorageSlotController(int x, int y) {
|
||||||
|
|||||||
@@ -12,7 +12,14 @@ Button.red:pressed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScrollPane {
|
ScrollPane {
|
||||||
-fx-background-color: inherit;
|
-fx-background-insets: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScalingImagePane {
|
||||||
|
-fx-background-color: transparent;
|
||||||
|
}
|
||||||
|
ScalingImagePane > .viewport {
|
||||||
|
-fx-background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label.red {
|
Label.red {
|
||||||
@@ -81,12 +88,12 @@ Label.green {
|
|||||||
-fx-background-color: #dddddd;
|
-fx-background-color: #dddddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#storage-grid > * {
|
|
||||||
-fx-background-color: #ffffff;
|
|
||||||
}
|
|
||||||
#storage-grid > .drop-hover {
|
#storage-grid > .drop-hover {
|
||||||
-fx-background-color: #eeeeee;
|
-fx-background-color: #eeeeee;
|
||||||
}
|
}
|
||||||
.storage-slot-item-title {
|
.storage-slot-item-title {
|
||||||
|
-fx-padding: 0 0 0 5;
|
||||||
-fx-end-margin: 10;
|
-fx-end-margin: 10;
|
||||||
}
|
}
|
||||||
|
.storage-slot-item-image {
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,62 +1,55 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import de.siphalor.was.visual.jfx.ScalingImagePane?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
|
||||||
<?import javafx.scene.layout.GridPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
<GridPane fx:id="slot" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onDragDetected="#onDragDetected" onDragDropped="#onDragDropped" onDragEntered="#onDragEntered" onDragExited="#onDragExited" onDragOver="#onDragOver" GridPane.valignment="CENTER" alignment="CENTER_LEFT" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<VBox fx:id="slot" fillWidth="false" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onDragDetected="#onDragDetected" onDragDropped="#onDragDropped" onDragEntered="#onDragEntered" onDragExited="#onDragExited" onDragOver="#onDragOver" GridPane.valignment="CENTER" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
<columnConstraints>
|
||||||
<children>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" percentWidth="15"/>
|
||||||
<GridPane alignment="CENTER_LEFT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308">
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" percentWidth="15"/>
|
||||||
<columnConstraints>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" percentWidth="15"/>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" percentWidth="15"/>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" percentWidth="40" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" />
|
</columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="30.0" />
|
<rowConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="0.0" />
|
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" percentHeight="25"/>
|
||||||
</columnConstraints>
|
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" percentHeight="25"/>
|
||||||
<rowConstraints>
|
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" percentHeight="25"/>
|
||||||
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" percentHeight="25"/>
|
||||||
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
|
</rowConstraints>
|
||||||
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
|
<children>
|
||||||
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
|
<ScalingImagePane styleClass="storage-slot-item-image" fx:id="slot0" maxHeight="100" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowSpan="2"/>
|
||||||
</rowConstraints>
|
<ScalingImagePane styleClass="storage-slot-item-image" fx:id="slot1" maxHeight="100" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.rowSpan="2"/>
|
||||||
<children>
|
<ScalingImagePane styleClass="storage-slot-item-image" fx:id="slot2" maxHeight="100" GridPane.columnSpan="2" GridPane.rowIndex="2" GridPane.rowSpan="2"/>
|
||||||
<ImageView fx:id="slot0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowSpan="2" />
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="4" GridPane.rowIndex="1">
|
||||||
<ImageView fx:id="slot1" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="1" GridPane.rowSpan="2" />
|
<children>
|
||||||
<ImageView fx:id="slot2" fitWidth="60.0" pickOnBounds="true" preserveRatio="true" GridPane.columnSpan="2" GridPane.rowIndex="2" GridPane.rowSpan="2" />
|
<Label fx:id="slot0Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="4" GridPane.rowIndex="1">
|
<font>
|
||||||
<children>
|
<Font name="System Bold" size="15.0"/>
|
||||||
<Label fx:id="slot0Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
</font>
|
||||||
<font>
|
</Label>
|
||||||
<Font name="System Bold" size="12.0" />
|
</children>
|
||||||
</font>
|
</HBox>
|
||||||
</Label>
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="3" GridPane.columnSpan="2147483647"
|
||||||
</children>
|
GridPane.rowIndex="2">
|
||||||
</HBox>
|
<children>
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="3" GridPane.columnSpan="2147483647" GridPane.rowIndex="2">
|
<Label fx:id="slot1Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
||||||
<children>
|
<font>
|
||||||
<Label fx:id="slot1Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
<Font name="System Bold" size="15.0"/>
|
||||||
<font>
|
</font>
|
||||||
<Font name="System Bold" size="12.0" />
|
</Label>
|
||||||
</font>
|
</children>
|
||||||
</Label>
|
</HBox>
|
||||||
</children>
|
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="2" GridPane.columnSpan="2147483647"
|
||||||
</HBox>
|
GridPane.rowIndex="3">
|
||||||
<HBox alignment="CENTER_LEFT" prefHeight="100.0" GridPane.columnIndex="2" GridPane.columnSpan="2147483647" GridPane.rowIndex="3">
|
<children>
|
||||||
<children>
|
<Label fx:id="slot2Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
||||||
<Label fx:id="slot2Title" styleClass="storage-slot-item-title" text="%game.storage.empty">
|
<font>
|
||||||
<font>
|
<Font name="System Bold" size="15.0"/>
|
||||||
<Font name="System Bold" size="12.0" />
|
</font>
|
||||||
</font>
|
</Label>
|
||||||
</Label>
|
</children>
|
||||||
</children>
|
</HBox>
|
||||||
</HBox>
|
</children>
|
||||||
</children>
|
</GridPane>
|
||||||
</GridPane>
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user