//////////////////////////////////////////////////////////////////////////////
// This file is part of the Journey MMORPG client                           //
// Copyright © 2015-2016 Daniel Allendorf                                   //
//                                                                          //
// This program is free software: you can redistribute it and/or modify     //
// it under the terms of the GNU Affero General Public License as           //
// published by the Free Software Foundation, either version 3 of the       //
// License, or (at your option) any later version.                          //
//                                                                          //
// This program is distributed in the hope that it will be useful,          //
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
// GNU Affero General Public License for more details.                      //
//                                                                          //
// You should have received a copy of the GNU Affero General Public License //
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    //
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../UIElement.h"

#include "../Components/Textfield.h"

#include "../../Template/BoolPair.h"
#include "../../Graphics/Geometry.h"

namespace jrc
{
    class UILogin : public UIElement
    {
    public:
        static constexpr Type TYPE = LOGIN;
        static constexpr bool FOCUSED = false;
        static constexpr bool TOGGLED = false;

        UILogin();

        void draw(float alpha) const override;
        void update() override;

        CursorResult send_cursor(bool clicked, Point<int16_t> cursor_pos) override;

    protected:
        Button::State button_pressed(uint16_t id) override;

    private:
        void login();

        enum Buttons
        {
            BT_LOGIN,
            BT_REGISTER,
            BT_HOMEPAGE,
            BT_PASSLOST,
            BT_IDLOST,
            BT_SAVEID,
            BT_QUIT,
            NUM_BUTTONS
        };

        Textfield account;
        Textfield password;
        Texture accountbg;
        Texture passwordbg;
        // v83 UI.wz ships no ID/PW field art; draw our own so the
        // inputs are visible instead of floating over the background.
        bool legacy_ui = false;
        ColorBox legacy_fieldbg;
        BoolPair<Texture> checkbox;

        bool saveid;
    };
}
