<commit_before>package wge3.game.gamestates;

import com.badlogic.gdx.Gdx;
import static com.badlogic.gdx.Input.Keys.ENTER;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import wge3.game.GameStateManager;

public final class MenuState extends GameState {
    
    private Stage stage;
    private Skin skin;
    
    private TextField mapNameField;
    private TextButton newGameButton;
    
    public MenuState(GameStateManager gsm) {
        super(gsm);
        init();
    }

    @Override
    public void init() {
        stage = new Stage();
        Gdx.input.setInputProcessor(stage);
        skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
        
        int buttonWidth = 200;
        int buttonHeight = 50;
        int x = Gdx.graphics.getWidth() / 2 - (buttonWidth / 2);
        int y = Gdx.graphics.getHeight() - 200;
        
        Label menuLabel = new Label("WGE3 EXPERIMENTAL HQ", skin);
        menuLabel.setPosition(x, y);
        stage.addActor(menuLabel);
        
        String mapName;
        if (gsm.getNextMap() != null) mapName = gsm.getNextMap();
        else mapName = "";
        
        mapNameField = new TextField(mapName, skin);
        mapNameField.setPosition(x, y - buttonHeight*2);
        mapNameField.setSize(buttonWidth, buttonHeight);
        mapNameField.setMessageText("Enter map name");
        stage.addActor(mapNameField);
        
        newGameButton = new TextButton("NEW GAME", skin);
        newGameButton.setPosition(x, y - buttonHeight*4);
        newGameButton.setSize(buttonWidth, buttonHeight);
        newGameButton.addListener(new ClickListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                startGame();
            }
        });
        stage.addActor(newGameButton);
        
        TextButton exitButton = new TextButton("EXIT", skin);
        exitButton.setPosition(x, y - buttonHeight*6);
        exitButton.setSize(buttonWidth, buttonHeight);
        exitButton.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeListener.ChangeEvent ce, Actor actor) {
                Gdx.app.exit();
            }
        });
        stage.addActor(exitButton);
    }
    
    public void startGame() {
        if (!Gdx.files.internal("maps/" + mapNameField.getText() + ".tmx").exists()) {
            gsm.setState(0);
            return;
        }
        
        gsm.setNextMap(mapNameField.getText());
        gsm.setState(1);
    }

    @Override
    public void update(float delta) {
        stage.act(delta);
        handleInput();
    }

    @Override
    public void draw(Batch batch) {
        stage.draw();
    }

    @Override
    public void handleInput() {
        if (Gdx.input.isKeyPressed(ENTER)) {
            startGame();
        }
    }

    @Override
    public void dispose() {
        stage.dispose();
        skin.dispose();
    }
}<commit_msg>You can now quit the game with esc.<commit_after>package wge3.game.gamestates;

import com.badlogic.gdx.Gdx;
import static com.badlogic.gdx.Input.Keys.ENTER;
import static com.badlogic.gdx.Input.Keys.ESCAPE;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import wge3.game.GameStateManager;

public final class MenuState extends GameState {
    
    private Stage stage;
    private Skin skin;
    
    private TextField mapNameField;
    private TextButton newGameButton;
    
    public MenuState(GameStateManager gsm) {
        super(gsm);
        init();
    }

    @Override
    public void init() {
        stage = new Stage();
        Gdx.input.setInputProcessor(stage);
        skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
        
        int buttonWidth = 200;
        int buttonHeight = 50;
        int x = Gdx.graphics.getWidth() / 2 - (buttonWidth / 2);
        int y = Gdx.graphics.getHeight() - 200;
        
        Label menuLabel = new Label("WGE3 EXPERIMENTAL HQ", skin);
        menuLabel.setPosition(x, y);
        stage.addActor(menuLabel);
        
        String mapName;
        if (gsm.getNextMap() != null) mapName = gsm.getNextMap();
        else mapName = "";
        
        mapNameField = new TextField(mapName, skin);
        mapNameField.setPosition(x, y - buttonHeight*2);
        mapNameField.setSize(buttonWidth, buttonHeight);
        mapNameField.setMessageText("Enter map name");
        stage.addActor(mapNameField);
        
        newGameButton = new TextButton("NEW GAME", skin);
        newGameButton.setPosition(x, y - buttonHeight*4);
        newGameButton.setSize(buttonWidth, buttonHeight);
        newGameButton.addListener(new ClickListener() {
            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                startGame();
            }
        });
        stage.addActor(newGameButton);
        
        TextButton exitButton = new TextButton("EXIT", skin);
        exitButton.setPosition(x, y - buttonHeight*6);
        exitButton.setSize(buttonWidth, buttonHeight);
        exitButton.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeListener.ChangeEvent ce, Actor actor) {
                Gdx.app.exit();
            }
        });
        stage.addActor(exitButton);
    }
    
    public void startGame() {
        if (!Gdx.files.internal("maps/" + mapNameField.getText() + ".tmx").exists()) {
            gsm.setState(0);
            return;
        }
        
        gsm.setNextMap(mapNameField.getText());
        gsm.setState(1);
    }

    @Override
    public void update(float delta) {
        stage.act(delta);
        handleInput();
    }

    @Override
    public void draw(Batch batch) {
        stage.draw();
    }

    @Override
    public void handleInput() {
        if (Gdx.input.isKeyPressed(ENTER)) startGame();
        else if (Gdx.input.isKeyPressed(ESCAPE)) Gdx.app.exit();
    }

    @Override
    public void dispose() {
        stage.dispose();
        skin.dispose();
    }
}
{'fraction_non_alphanumeric': 0.11341830158957468, 'fraction_numerical': 0.008019475869969928, 'mean_word_length': 2.3657831325301206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1205262', 'n_tokens_mistral': 2198, 'n_tokens_neox': 2133, 'n_words': 406}