mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Add basic field layout
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -16038,6 +16038,7 @@ forge-m-base/src/forge/screens/quest/QuestScreen.java -text
|
||||
forge-m-base/src/forge/screens/sealed/SealedScreen.java -text
|
||||
forge-m-base/src/forge/screens/settings/SettingsScreen.java -text
|
||||
forge-m-base/src/forge/toolbox/FButton.java -text
|
||||
forge-m-base/src/forge/toolbox/FCardPanel.java -text
|
||||
forge-m-base/src/forge/toolbox/FContainer.java -text
|
||||
forge-m-base/src/forge/toolbox/FDisplayObject.java -text
|
||||
forge-m-base/src/forge/toolbox/FGestureAdapter.java -text
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.Forge.Graphics;
|
||||
import forge.assets.FSkinTexture;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.toolbox.FScrollPane;
|
||||
|
||||
public class VField extends FContainer {
|
||||
|
||||
public class VField extends FScrollPane {
|
||||
private boolean flipped;
|
||||
|
||||
private final List<FCardPanel> creatures = new ArrayList<FCardPanel>();
|
||||
private final List<FCardPanel> lands = new ArrayList<FCardPanel>();
|
||||
private final List<FCardPanel> otherPermanents = new ArrayList<FCardPanel>();
|
||||
|
||||
public VField() {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
creatures.add(add(new FCardPanel()));
|
||||
lands.add(add(new FCardPanel()));
|
||||
otherPermanents.add(add(new FCardPanel()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFlipped() {
|
||||
@@ -20,11 +33,25 @@ public class VField extends FContainer {
|
||||
|
||||
@Override
|
||||
protected void doLayout(float width, float height) {
|
||||
// TODO Auto-generated method stub
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float cardSize = height / 3;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(Graphics g) {
|
||||
for (FCardPanel cardPanel : creatures) {
|
||||
cardPanel.setBounds(x, y, cardSize, cardSize);
|
||||
x += cardSize;
|
||||
}
|
||||
x = 0;
|
||||
y += cardSize;
|
||||
for (FCardPanel cardPanel : lands) {
|
||||
cardPanel.setBounds(x, y, cardSize, cardSize);
|
||||
x += cardSize;
|
||||
}
|
||||
x = 0;
|
||||
y += cardSize;
|
||||
for (FCardPanel cardPanel : otherPermanents) { //TODO: Move to right of lands right-aligned if enough room
|
||||
cardPanel.setBounds(x, y, cardSize, cardSize);
|
||||
x += cardSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.Forge.Graphics;
|
||||
import forge.toolbox.FCardPanel;
|
||||
import forge.toolbox.FContainer;
|
||||
import forge.utils.Utils;
|
||||
|
||||
public class VStack extends FContainer {
|
||||
public static final float WIDTH = Utils.AVG_FINGER_WIDTH;
|
||||
public static final float HEIGHT = WIDTH * Utils.CARD_ASPECT_RATIO;
|
||||
public static final float HEIGHT = WIDTH * FCardPanel.ASPECT_RATIO;
|
||||
|
||||
public VStack() {
|
||||
setSize(WIDTH, HEIGHT);
|
||||
|
||||
20
forge-m-base/src/forge/toolbox/FCardPanel.java
Normal file
20
forge-m-base/src/forge/toolbox/FCardPanel.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package forge.toolbox;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import forge.Forge.Graphics;
|
||||
|
||||
public class FCardPanel extends FDisplayObject {
|
||||
public final static float ASPECT_RATIO = 3.5f / 2.5f;
|
||||
private static final float PADDING = 3; //scale to leave vertical space between
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
float y = PADDING;
|
||||
float h = getHeight() - 2 * y;
|
||||
float w = h / ASPECT_RATIO;
|
||||
float x = (getWidth() - w) / 2;
|
||||
|
||||
g.fillRect(Color.BLUE, x, y, w, h);
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ public class Utils {
|
||||
public final static float AVG_FINGER_WIDTH = Math.round(cmToPixelsX(AVG_FINGER_SIZE_CM)); //round to nearest int to reduce floating point display issues
|
||||
public final static float AVG_FINGER_HEIGHT = Math.round(cmToPixelsY(AVG_FINGER_SIZE_CM));
|
||||
|
||||
public final static float CARD_ASPECT_RATIO = 3.5f / 2.5f;
|
||||
|
||||
public static float cmToPixelsX(float cm) {
|
||||
return ppcX * cm;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user