/*
 * Copyright (C) 2013 Snowsun <http://wyrez.org> and contributors
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.wyrez.shootingstars.gui;

import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector2f;
import org.wyrez.shootingstars.gui.controls.ButtonBase;
import org.wyrez.shootingstars.gui.listener.SelectFileListener;
import tonegod.gui.controls.buttons.Button;
import tonegod.gui.controls.text.Label;
import tonegod.gui.controls.windows.Panel;
import tonegod.gui.core.Screen;

/**
 *
 * @author Snowsun
 */
public class SelectTrackGUI extends Panel implements Gui{

    SelectFileListener listener;
    
    public SelectTrackGUI(Screen screen, SelectFileListener listener) {
        super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
        this.listener = listener;
        this.setIgnoreMouse(true);
        this.setIsVisible(false);
        create();
    }
    
    private void create() {
        float startPointx = 576f;
        float startPointy = 260f;
        float labelFontSize = 76f;
        float buttonWidth = 153f;
        float marginLabelOrLeft = 45f;
        float marginLabelOrTop = 43f;
        float marginButtonYTDownloadTop = 129f;
        
        Button btnSelectFile = new ButtonBase(screen, new Vector2f(startPointx, startPointy), new Vector2f(buttonWidth, 40)) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                listener.selectFile();
            }
        };
        btnSelectFile.setText("Select File");
        
        Label lblOr = new Label(screen, new Vector2f(startPointx + marginLabelOrLeft, startPointy + marginLabelOrTop), new Vector2f(100, 40));
        lblOr.setFontSize(labelFontSize);
        lblOr.setText("Or");
        
        Button btnYTDownload = new ButtonBase(screen, new Vector2f(startPointx, startPointy + marginButtonYTDownloadTop), new Vector2f(buttonWidth, 40)) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                listener.downloadYT();
            }
        };
        btnYTDownload.setText("YT Download");
        
        Button btnCancel = new ButtonBase(screen, new Vector2f(startPointx, startPointy + marginButtonYTDownloadTop + 114f), new Vector2f(buttonWidth, 40)) {
            @Override
            public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
                listener.cancel();
            }
        };
        btnCancel.setText("Cancel");
        
        this.addChild(btnSelectFile);
        this.addChild(lblOr);
        this.addChild(btnYTDownload);
        this.addChild(btnCancel);
    }
    
    public void attach() {
        screen.addElement(this);
    }

    public void detach() {
        screen.removeElement(this);
    }
}
