package gui;

import gui.constants.Fonts;
import gui.constants.Images;
import gui.constants.Symbols;
import gui.menu.MainMenu;
import gui.menu.StateMachine;
import imgui.app.Application;
import imgui.app.Configuration;
import sudoku.io.SudokuPrinter;
import sudoku.structure.Difficulty;
import sudoku.structure.MultiDoku;
import sudoku.structure.SudokuFactory;

public class Main extends Application {

    private final StateMachine stateMachine = new StateMachine();

    @Override
    protected void configure(Configuration config) {
        config.setTitle("Let's play sudoku!");
    }

    @Override
    protected void disposeWindow() {
        stateMachine.clear();
    }

    @Override
    protected void initImGui(Configuration config) {
        super.initImGui(config);
        Fonts.createFonts();
        stateMachine.pushState(new MainMenu(stateMachine));
    }
    
    @Override
    protected void preRun() {
        super.preRun();
        Images.loadImages();
    }

    @Override
    public void process() {
        stateMachine.render();
        // ImGui.showDemoWindow();
    }

    public static void main(String[] args) {
        MultiDoku doku = SudokuFactory.createBasicPlusShapedMultidoku(3, 3, SudokuFactory.DEFAULT_CONSTRAINTS);
        try {
            SudokuFactory.fillDoku(doku, Difficulty.Easy);
        } catch (Exception e) {
            throw new RuntimeException();
        }
        SudokuPrinter.printMultiDoku(doku, 3, 3, Symbols.Numbers);
        //launch(new Main());
    }
}