<commit_before>/*
 * Copyright 2021 The Terasology Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.destinationsol.ui.nui.screens.mainMenu;

import com.badlogic.gdx.Gdx;
import org.destinationsol.GameOptions;
import org.destinationsol.SolApplication;
import org.destinationsol.assets.music.OggMusicManager;
import org.destinationsol.common.In;
import org.destinationsol.game.WorldConfig;
import org.destinationsol.ui.nui.NUIManager;
import org.destinationsol.ui.nui.NUIScreenLayer;
import org.terasology.nui.Canvas;
import org.terasology.nui.widgets.UIButton;

/**
 * The main menu screen. This is the first screen shown when you open the game.
 */
public class MainMenuScreen extends NUIScreenLayer {
    @In
    private SolApplication solApplication;

    @Override
    public void initialise() {
        final OggMusicManager musicManager = solApplication.getMusicManager();
        if (!musicManager.getCurrentMusicSet().equals(OggMusicManager.MENU_MUSIC_SET)) {
            musicManager.playMusic(OggMusicManager.MENU_MUSIC_SET, solApplication.getOptions());
        }

        UIButton tutorialButton = find("tutorialButton", UIButton.class);
        tutorialButton.setEnabled(solApplication.getOptions().controlType != GameOptions.ControlType.CONTROLLER);
        tutorialButton.subscribe(button -> {
            solApplication.getMenuScreens().loading.setMode(true, "Imperial Small", true, new WorldConfig());
            nuiManager.pushScreen(solApplication.getMenuScreens().loading);
            nuiManager.removeScreen(this);
        });

        UIButton playGameButton = find("playGameButton", UIButton.class);
        playGameButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().newGame);
            nuiManager.removeScreen(this);
        });

        UIButton optionsButton = find("optionsButton", UIButton.class);
        optionsButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().options);
            nuiManager.removeScreen(this);
        });

        UIButton exitButton = find("exitButton", UIButton.class);
        exitButton.subscribe(button -> {
            if (!solApplication.isMobile()) {
                solApplication.getOptions().save();
            }
            Gdx.app.exit();
            nuiManager.removeScreen(this);
        });

        UIButton creditsButton = find("creditsButton", UIButton.class);
        creditsButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().credits);
            nuiManager.removeScreen(this);
        });
    }

    @Override
    public void update(float delta) {
        super.update(delta);
        solApplication.getMenuBackgroundManager().update();
    }

    @Override
    public void onDraw(Canvas canvas) {
        try (NUIManager.LegacyUiDrawerWrapper wrapper = nuiManager.getLegacyUiDrawer()) {
            solApplication.getMenuBackgroundManager().draw(wrapper.getUiDrawer());
        }

        super.onDraw(canvas);
    }

    @Override
    protected boolean escapeCloses() {
        return false;
    }
}<commit_msg>fix: fix permanently disabled tutorial button when starting with controller controls<commit_after>/*
 * Copyright 2021 The Terasology Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.destinationsol.ui.nui.screens.mainMenu;

import com.badlogic.gdx.Gdx;
import org.destinationsol.GameOptions;
import org.destinationsol.SolApplication;
import org.destinationsol.assets.music.OggMusicManager;
import org.destinationsol.common.In;
import org.destinationsol.game.WorldConfig;
import org.destinationsol.ui.nui.NUIManager;
import org.destinationsol.ui.nui.NUIScreenLayer;
import org.terasology.nui.Canvas;
import org.terasology.nui.widgets.UIButton;

/**
 * The main menu screen. This is the first screen shown when you open the game.
 */
public class MainMenuScreen extends NUIScreenLayer {
    @In
    private SolApplication solApplication;
    private UIButton tutorialButton;

    @Override
    public void initialise() {
        final OggMusicManager musicManager = solApplication.getMusicManager();
        if (!musicManager.getCurrentMusicSet().equals(OggMusicManager.MENU_MUSIC_SET)) {
            musicManager.playMusic(OggMusicManager.MENU_MUSIC_SET, solApplication.getOptions());
        }

        tutorialButton = find("tutorialButton", UIButton.class);
        tutorialButton.subscribe(button -> {
            solApplication.getMenuScreens().loading.setMode(true, "Imperial Small", true, new WorldConfig());
            nuiManager.pushScreen(solApplication.getMenuScreens().loading);
            nuiManager.removeScreen(this);
        });

        UIButton playGameButton = find("playGameButton", UIButton.class);
        playGameButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().newGame);
            nuiManager.removeScreen(this);
        });

        UIButton optionsButton = find("optionsButton", UIButton.class);
        optionsButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().options);
            nuiManager.removeScreen(this);
        });

        UIButton exitButton = find("exitButton", UIButton.class);
        exitButton.subscribe(button -> {
            if (!solApplication.isMobile()) {
                solApplication.getOptions().save();
            }
            Gdx.app.exit();
            nuiManager.removeScreen(this);
        });

        UIButton creditsButton = find("creditsButton", UIButton.class);
        creditsButton.subscribe(button -> {
            nuiManager.pushScreen(solApplication.getMenuScreens().credits);
            nuiManager.removeScreen(this);
        });
    }

    @Override
    public void onAdded() {
        tutorialButton.setEnabled(solApplication.getOptions().controlType != GameOptions.ControlType.CONTROLLER);
    }

    @Override
    public void update(float delta) {
        super.update(delta);
        solApplication.getMenuBackgroundManager().update();
    }

    @Override
    public void onDraw(Canvas canvas) {
        try (NUIManager.LegacyUiDrawerWrapper wrapper = nuiManager.getLegacyUiDrawer()) {
            solApplication.getMenuBackgroundManager().draw(wrapper.getUiDrawer());
        }

        super.onDraw(canvas);
    }

    @Override
    protected boolean escapeCloses() {
        return false;
    }
}
{'fraction_non_alphanumeric': 0.09841992501339046, 'fraction_numerical': 0.0021424745581146223, 'mean_word_length': 3.2150112866817158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7324648', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1976, 'n_words': 440}