Skip to content

Commit

Permalink
Fixed enter button to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
David52920 committed Dec 17, 2020
1 parent 3ea27fe commit 3763cf6
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions client-core/src/com/benberi/cadesim/game/screen/LobbyScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.EventListener;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
Expand Down Expand Up @@ -77,8 +79,6 @@ public class LobbyScreen extends AbstractScreen implements InputProcessor {
private final String CODE_URL = "https://github.com/plaza-in-a-heatwave/Cadesim/issues";
private final int CODE_URL_WIDTH = 278; // px

private boolean failed;

/**
* The main stage for elements
*/
Expand Down Expand Up @@ -221,10 +221,9 @@ public void buildStage() {
addStage();
screenWidth = Gdx.graphics.getWidth();
screenHeight = Gdx.graphics.getHeight();
multiplexer.addProcessor(stage);
multiplexer.addProcessor(this);
multiplexer.addProcessor(stage);
Gdx.input.setInputProcessor(multiplexer);

if(!Constants.AUTO_UPDATE) { // test purposes
Constants.PROTOCOL_PORT = 4970;
address.setText("localhost");
Expand Down Expand Up @@ -641,26 +640,17 @@ public void dispose() {
super.dispose();
renderer.dispose();
}

public void setFailed(boolean failed) {
this.failed = failed;
}


@Override
public boolean keyDown(int keycode) {
System.out.println("key"+keycode);
if (keycode == Input.Keys.ENTER || keycode == Input.Keys.CENTER) {
if (!popup.isVisible()) {
if (stage.getKeyboardFocus() != name && name.getText().isEmpty()) {
stage.setKeyboardFocus(name);
} else if (stage.getKeyboardFocus() != address && address.getText().isEmpty()) {
stage.setKeyboardFocus(address);
} else {
try {
performUpdateCheck();
} catch (UnknownHostException e) {
return failed;
}
performClick(buttonConn);
}
}
else {
Expand All @@ -672,13 +662,12 @@ public boolean keyDown(int keycode) {

@Override
public boolean keyUp(int keycode) {
System.out.println(1);

return false;
}

@Override
public boolean keyTyped(char character) {
System.out.println("here");
return false;
}

Expand Down Expand Up @@ -775,6 +764,17 @@ private void performUpdateCheck() throws UnknownHostException{
}
}


public static void performClick(Actor actor) {
Array<EventListener> listeners = actor.getListeners();
for(int i=0;i<listeners.size;i++)
{
if(listeners.get(i) instanceof ClickListener){
((ClickListener)listeners.get(i)).clicked(null, 0, 0);
}
}
}

private void performLogin() throws UnknownHostException {
loginAttemptTimestampMillis = System.currentTimeMillis();

Expand Down

0 comments on commit 3763cf6

Please sign in to comment.