mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Fikser problemet med at stage ikke tar hensyn til viewport. Closes #61
This commit is contained in:
parent
1c47b627af
commit
1abaea3e3b
@ -49,12 +49,12 @@ public class BoardActiveScreen extends AbstractScreen implements InputProcessor
|
|||||||
camera.position.set(viewPortWidth / 2f, viewPortHeight / 2f, 0);
|
camera.position.set(viewPortWidth / 2f, viewPortHeight / 2f, 0);
|
||||||
viewport = new ExtendViewport(viewPortWidth, viewPortHeight, camera);
|
viewport = new ExtendViewport(viewPortWidth, viewPortHeight, camera);
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(this);
|
|
||||||
lastTouch = new Vector2();
|
lastTouch = new Vector2();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(this);
|
||||||
resetCamera();
|
resetCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
|
|||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.math.Vector3;
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
import com.badlogic.gdx.scenes.scene2d.*;
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
@ -44,6 +41,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
private final List<CardRectangle> chosenCards;
|
private final List<CardRectangle> chosenCards;
|
||||||
private final int maxCards;
|
private final int maxCards;
|
||||||
private final Stage stage;
|
private final Stage stage;
|
||||||
|
private final InputMultiplexer inputMultiplexer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new card choice screen
|
* Instantiates a new card choice screen
|
||||||
@ -60,8 +58,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
shapeRenderer = new ShapeRenderer();
|
shapeRenderer = new ShapeRenderer();
|
||||||
shapeRenderer.setAutoShapeType(true);
|
shapeRenderer.setAutoShapeType(true);
|
||||||
|
|
||||||
InputMultiplexer inputMultiplexer = new InputMultiplexer();
|
inputMultiplexer = new InputMultiplexer();
|
||||||
inputMultiplexer.addProcessor(this);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
generateCards();
|
generateCards();
|
||||||
@ -71,25 +68,25 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
this.chosenCards = new ArrayList<>();
|
this.chosenCards = new ArrayList<>();
|
||||||
this.maxCards = 5;
|
this.maxCards = 5;
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
inputMultiplexer.addProcessor(stage);
|
|
||||||
|
|
||||||
TextButton confirmCards = new SimpleButton("Confirm cards", roboRallyWrapper.font).getButton();
|
TextButton confirmCards = new SimpleButton("Confirm cards", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(confirmCards);
|
stage.addActor(confirmCards);
|
||||||
confirmCards.setY(viewport.getWorldHeight() + 60);
|
confirmCards.setY(viewport.getWorldHeight() - confirmCards.getHeight());
|
||||||
confirmCards.setX(15);
|
confirmCards.setX(15);
|
||||||
confirmCards.setTouchable(Touchable.enabled);
|
|
||||||
confirmCards.addListener(new InputListener() {
|
confirmCards.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
System.out.println(chosenCards.size());
|
|
||||||
System.out.println(maxCards);
|
|
||||||
if (chosenCards.size() == maxCards) {
|
if (chosenCards.size() == maxCards) {
|
||||||
System.out.println("Lock cards!");
|
System.out.println("Lock cards!");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Gdx.input.setInputProcessor(inputMultiplexer);
|
stage.setViewport(viewport);
|
||||||
|
inputMultiplexer.addProcessor(this);
|
||||||
|
inputMultiplexer.addProcessor(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,7 +116,7 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
//Nothing to do
|
Gdx.input.setInputProcessor(inputMultiplexer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,9 +68,13 @@ public class IPAddressScreen extends AbstractScreen {
|
|||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
stage.setViewport(viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
|
@ -41,7 +41,6 @@ public class LobbyScreen extends AbstractScreen {
|
|||||||
startGameButton.setX(applicationWidth / 2f + startGameButton.getWidth() / 4f);
|
startGameButton.setX(applicationWidth / 2f + startGameButton.getWidth() / 4f);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
|
||||||
startGameButton.addListener(new InputListener() {
|
startGameButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
@ -52,8 +51,13 @@ public class LobbyScreen extends AbstractScreen {
|
|||||||
return true;//her we do stuff
|
return true;//her we do stuff
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
stage.setViewport(viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
|
@ -31,13 +31,13 @@ public class PowerDownScreen extends AbstractScreen {
|
|||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
|
stage.setViewport(viewport);
|
||||||
TextButton powerDownButton = new SimpleButton("PowerDown", roboRallyWrapper.font).getButton();
|
TextButton powerDownButton = new SimpleButton("PowerDown", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(powerDownButton);
|
stage.addActor(powerDownButton);
|
||||||
powerDownButton.setY(applicationHeight / 2f);
|
powerDownButton.setY(applicationHeight / 2f);
|
||||||
powerDownButton.setX(applicationWidth / 2f + powerDownButton.getWidth() / 4f);
|
powerDownButton.setX(applicationWidth / 2f + powerDownButton.getWidth() / 4f);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
powerDownButton.addListener(new InputListener() {
|
powerDownButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +78,8 @@ public class PowerDownScreen extends AbstractScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show(){
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
camera = new OrthographicCamera();
|
camera = new OrthographicCamera();
|
||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
stage = new Stage();
|
stage = new Stage();
|
||||||
|
stage.setViewport(viewport);
|
||||||
TextButton serverButton = new SimpleButton("Create", roboRallyWrapper.font).getButton();
|
TextButton serverButton = new SimpleButton("Create", roboRallyWrapper.font).getButton();
|
||||||
stage.addActor(serverButton);
|
stage.addActor(serverButton);
|
||||||
serverButton.setY(applicationHeight / 2f);
|
serverButton.setY(applicationHeight / 2f);
|
||||||
serverButton.setX(applicationWidth / 2f);
|
serverButton.setX(applicationWidth / 2f);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
|
||||||
|
|
||||||
serverButton.addListener(new InputListener() {
|
serverButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -77,7 +77,6 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
quitButton.setY(applicationHeight / 2f);
|
quitButton.setY(applicationHeight / 2f);
|
||||||
quitButton.setX(applicationWidth / 2f + serverButton.getWidth() + 40 + clientButton.getWidth());
|
quitButton.setX(applicationWidth / 2f + serverButton.getWidth() + 40 + clientButton.getWidth());
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
|
||||||
quitButton.addListener(new InputListener() {
|
quitButton.addListener(new InputListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||||
@ -87,6 +86,11 @@ public class StartMenuScreen extends AbstractScreen {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
|
@ -44,8 +44,6 @@ public class UsernameScreen extends AbstractScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void touchUp(InputEvent e, float x, float y, int point, int button) {
|
public void touchUp(InputEvent e, float x, float y, int point, int button) {
|
||||||
String userName = textInput.getText();
|
String userName = textInput.getText();
|
||||||
System.out.println(userName);
|
|
||||||
System.out.println(validateName(userName));
|
|
||||||
if (!validateName(userName)) {
|
if (!validateName(userName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,8 +65,7 @@ public class UsernameScreen extends AbstractScreen {
|
|||||||
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
viewport = new FitViewport(applicationWidth, applicationHeight, camera);
|
||||||
this.roboRallyWrapper = roboRallyWrapper;
|
this.roboRallyWrapper = roboRallyWrapper;
|
||||||
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
camera.setToOrtho(false, applicationWidth, applicationHeight);
|
||||||
Gdx.input.setInputProcessor(stage);
|
stage.setViewport(viewport);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,6 +78,11 @@ public class UsernameScreen extends AbstractScreen {
|
|||||||
return !userName.equals("");
|
return !userName.equals("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user