package de.samdev.colorrunner.screens.menu.impl;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;

import de.samdev.colorrunner.CRGame;
import de.samdev.colorrunner.game.world.map.CRMapStorage;
import de.samdev.colorrunner.game.world.map.CRTiledMap;
import de.samdev.colorrunner.game.world.map.provider.EndlessMapProvider;
import de.samdev.colorrunner.game.world.map.provider.StaticMapProvider;
import de.samdev.colorrunner.screens.gameScreen.GameScreen;
import de.samdev.colorrunner.screens.menu.BaseMenu;
import de.samdev.colorrunner.screens.menu.impl.elements.CRMenuRectangle;

public class LevelSelectMenu extends BaseMenu {

    @Override
    protected void init() {
        var dbg0 = new Texture("dbg_off.png");
        var dbg1 = new Texture("dbg_on.png");

        var c = new Color(0.25f, 0.25f, 0.25f, 1f);

        add(new CRMenuRectangle(48,  480, 128, 128, c, new Texture("lvl_01.png"),  (cx, cy, r) -> CRGame.Inst().setScreen(new GameScreen(new StaticMapProvider(CRMapStorage.lvl_01)))));
        add(new CRMenuRectangle(208, 480, 128, 128, c, new Texture("lvl_02.png"),  (cx, cy, r) -> CRGame.Inst().setScreen(new GameScreen(new StaticMapProvider(CRMapStorage.lvl_02)))));
        add(new CRMenuRectangle(368, 480, 128, 128, c, new Texture("lvl_03.png"),  (cx, cy, r) -> CRGame.Inst().setScreen(new GameScreen(new StaticMapProvider(CRMapStorage.lvl_03)))));
        add(new CRMenuRectangle(528, 480, 128, 128, c, new Texture("lvl_04.png"),  (cx, cy, r) -> CRGame.Inst().setScreen(new GameScreen(new StaticMapProvider(CRMapStorage.lvl_04)))));
        add(new CRMenuRectangle(688, 480, 128, 128, c, new Texture("lvl_05.png"),  (cx, cy, r) -> { }));
        add(new CRMenuRectangle(848, 480, 128, 128, c, new Texture("lvl_06.png"),  (cx, cy, r) -> { }));
        add(new CRMenuRectangle(48,  336, 128, 128, c, new Texture("lvl_07.png"),  (cx, cy, r) -> { }));
        add(new CRMenuRectangle(208, 336, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(368, 336, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(528, 336, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(688, 336, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(848, 336, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(48,  192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(208, 192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(368, 192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(528, 192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(688, 192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(848, 192, 128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(48,  48,  128, 128, c, CRGame.DEBUG ? dbg1 : dbg0, (cx, cy, r) -> { CRGame.DEBUG = !CRGame.DEBUG; r.Tex = CRGame.DEBUG ? dbg1 : dbg0; }));
        add(new CRMenuRectangle(208, 48,  128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(368, 48,  128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(528, 48,  128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(688, 48,  128, 128, c, null,                       (cx, cy, r) -> { }));
        add(new CRMenuRectangle(848, 48,  128, 128, c, new Texture("lvl_x1.png"),  (cx, cy, r) -> CRGame.Inst().setScreen(new GameScreen(new EndlessMapProvider(System.currentTimeMillis())))));
    }

    @Override
    protected Color getClearColor() {
        return new Color(0, 0, 0, 1f);
    }

    @Override
    public void touchDown(int screenX, int screenY) {
        super.touchDown(screenX, screenY);
        //CRGame.Inst().setScreen(new GameScreen(new EndlessMapProvider(System.currentTimeMillis())));
    }
}

