All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bladecoder.engine.ui.DebugScreen Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright 2014 Rafael Garcia Moreno.
 *
 * 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 com.bladecoder.engine.ui;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Container;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.bladecoder.engine.assets.EngineAssetManager;
import com.bladecoder.engine.ui.UI.Screens;
import com.bladecoder.engine.ui.defaults.ScreenControllerHandler;
import com.bladecoder.engine.util.Config;
import com.bladecoder.engine.util.DPIUtils;
import com.bladecoder.engine.util.EngineLogger;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

public class DebugScreen implements BladeScreen {
    private UI ui;

    private Stage stage;

    private TextField speedText;
    private SelectBox recordings;
    private SelectBox scenes;
    private TextField recFilename;
    private TextButton rec;

    private TextField testerTimeConf;
    private TextField inSceneTimeConf;
    private TextField testerExcludeList;

    private Pointer pointer;

    private ScreenControllerHandler controller;

    public DebugScreen() {
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        stage.act(delta);
        stage.draw();

        controller.update(delta);
    }

    @Override
    public void resize(int width, int height) {
        stage.getViewport().update(width, height, true);
        pointer.resize();
        table.invalidate();
    }

    @Override
    public void dispose() {
        if (stage != null) {
            stage.dispose();
            stage = null;
        }
    }

    Table table;

    @Override
    public void show() {
        float size = DPIUtils.getPrefButtonSize();
        float margin = DPIUtils.getMarginSize();

        stage = new Stage(new ScreenViewport());

        table = new Table(ui.getSkin());
        table.setFillParent(true);
        table.left().top();
        table.pad(margin);

        table.addListener(new InputListener() {
            @Override
            public boolean keyUp(InputEvent event, int keycode) {
                if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK)
                    ui.setCurrentScreen(Screens.SCENE_SCREEN);
                return true;
            }
        });

        stage.setKeyboardFocus(table);
        controller = new ScreenControllerHandler(ui, stage, stage.getViewport());

        Button back = new Button(ui.getSkin(), "back");

        back.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                ui.setCurrentScreen(Screens.SCENE_SCREEN);
            }
        });

        Label title = new Label("DEBUG SCREEN", ui.getSkin(), "title");

        Table header = new Table();
        header.padBottom(margin);
        Container




© 2015 - 2025 Weber Informatics LLC | Privacy Policy