#include "global_inputs.h"
#include "input.h"    // Para Input, InputDeviceToUse, InputType, INPU...
#include "notifier.h" // Para Notifier
#include "options.h"  // Para Options, options, OptionsGame, OptionsAudio
#include "screen.h"   // Para Screen, ScreenVideoMode

namespace globalInputs
{
    // Cambia la paleta
    void switchPalette()
    {
        options.video.palette = options.video.palette == Palette::ZXSPECTRUM ? Palette::ZXARNE : Palette::ZXSPECTRUM;
    }

    // Cambia de seccion
    void skip_section()
    {
        switch (options.section.section)
        {
        case Section::LOGO:
        case Section::LOADING_SCREEN:
        case Section::CREDITS:
        case Section::DEMO:
        case Section::GAME_OVER:
        case Section::ENDING:
        case Section::ENDING2:
            options.section.section = Section::TITLE;
            options.section.subsection = Subsection::NONE;
            break;

        default:
            break;
        }
    }

    // Comprueba los inputs que se pueden introducir en cualquier sección del juego
    void check()
    {
        if (Input::get()->checkInput(input_exit, REPEAT_FALSE))
        {
            options.section.section = Section::QUIT;
        }

        else if (Input::get()->checkInput(input_accept, REPEAT_FALSE))
        {
            skip_section();
        }

        else if (Input::get()->checkInput(input_toggle_border, REPEAT_FALSE))
        {
            Screen::get()->toggleBorder();
        }

        else if (Input::get()->checkInput(input_toggle_videomode, REPEAT_FALSE))
        {
            Screen::get()->toggleVideoMode();
        }

        else if (Input::get()->checkInput(input_window_dec_size, REPEAT_FALSE))
        {
            Screen::get()->decWindowZoom();
        }

        else if (Input::get()->checkInput(input_window_inc_size, REPEAT_FALSE))
        {
            Screen::get()->incWindowZoom();
        }

        else if (Input::get()->checkInput(input_toggle_shaders, REPEAT_FALSE))
        {
            Screen::get()->toggleShaders();
            Notifier::get()->show("HOLA");
        }

        else if (Input::get()->checkInput(input_toggle_palette, REPEAT_FALSE))
        {
            switchPalette();
        }
    }
}