<commit_before>package com.alexaut.kroniax.menu;

import com.alexaut.kroniax.menu.Gui.Layer;
import com.alexaut.kroniax.screens.GameScene;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;

public class LevelSelectionLayer extends Table {

    public LevelSelectionLayer(final Gui gui) {
        super();
        setFillParent(true);
        setPosition(0, 720); // Shouldn't be on screen at the beginning

        setupLevelGrid(gui);

        // Add back button
        TextButton back = new TextButton("Back", gui.getSkin());
        back.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                // Get movement direction
                int direction = 720;
                if (gui.getLayer(Layer.MAIN).getY() > 0)
                    direction = -720;
                addAction(Actions.moveTo(0, direction, 1.5f, Interpolation.swingOut));
                gui.getLayer(Layer.MAIN).addAction(Actions.moveTo(0, 0, 1.5f, Interpolation.swingOut));
                gui.setActiveLayer(Layer.MAIN);
            }
        });

        add(back).colspan(getColumns()).padTop(75.f).width(300);

        pack(); // Don't remove!
    }

    public void setupLevelGrid(final Gui gui) {
        final int unlocked_levels = 3;
        final int rowSize = 3;

        for (int i = 1; i <= 9; i++) {
            TextButton bt = new TextButton(Integer.toString(i), gui.getSkin());
            bt.setName(Integer.toString(i));

            // Callback to start the level
            bt.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    String lvlPath = "data/levels/official/level" + actor.getName() + ".kroniax";
                    gui.getApplication().setScreen(new GameScene(gui.getApplication(), lvlPath));
                }
            });
            
            if(i > unlocked_levels) {
                bt.setVisible(false);
            }

            add(bt).pad(5.f).width(150).height(150);
            if (i != 0 && i % rowSize == 0)
                row();
        }
    }
}<commit_msg>Replaced hard coded unlocked levels value with the actual value from the progressmanager<commit_after>package com.alexaut.kroniax.menu;

import com.alexaut.kroniax.menu.Gui.Layer;
import com.alexaut.kroniax.screens.GameScene;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;

public class LevelSelectionLayer extends Table {

    public LevelSelectionLayer(final Gui gui) {
        super();
        setFillParent(true);
        setPosition(0, 720); // Shouldn't be on screen at the beginning

        setupLevelGrid(gui);

        // Add back button
        TextButton back = new TextButton("Back", gui.getSkin());
        back.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                // Get movement direction
                int direction = 720;
                if (gui.getLayer(Layer.MAIN).getY() > 0)
                    direction = -720;
                addAction(Actions.moveTo(0, direction, 1.5f, Interpolation.swingOut));
                gui.getLayer(Layer.MAIN).addAction(Actions.moveTo(0, 0, 1.5f, Interpolation.swingOut));
                gui.setActiveLayer(Layer.MAIN);
            }
        });

        add(back).colspan(getColumns()).padTop(75.f).width(300);

        pack(); // Don't remove!
    }

    public void setupLevelGrid(final Gui gui) {
        final int unlocked_levels = gui.getApplication().getProgressManager().getUnlockedLevels();
        final int rowSize = 3;

        for (int i = 1; i <= 9; i++) {
            TextButton bt = new TextButton(Integer.toString(i), gui.getSkin());
            bt.setName(Integer.toString(i));

            // Callback to start the level
            bt.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    String lvlPath = "data/levels/official/level" + actor.getName() + ".kroniax";
                    gui.getApplication().setScreen(new GameScene(gui.getApplication(), lvlPath));
                }
            });
            
            if(i > unlocked_levels) {
                bt.setVisible(false);
            }

            add(bt).pad(5.f).width(150).height(150);
            if (i != 0 && i % rowSize == 0)
                row();
        }
    }
}
{'fraction_non_alphanumeric': 0.11836571199679552, 'fraction_numerical': 0.016222711796515122, 'mean_word_length': 2.0675675675675675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '134830', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1435, 'n_words': 290}