// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT

import { StandardButton, VerticalBox, HorizontalBox, Button, LineEdit } from "std-widgets.slint";
import { Page } from "page.slint";
import { State } from "localgame_page.slint";

export global NetplayData {
    in-out property <string> player_name;
    in-out property <string> game_name;
    in-out property <string> game_hash;
    in-out property <string> game_cheats;
    in-out property <string> rom_path;
    in-out property <string> password;
    in-out property <bool> pending_session;
    in-out property <bool> pending_refresh;
    in-out property <string> session_name;
    in-out property <[[StandardListViewItem]]> sessions;
    in-out property <int> current_session: -1;

    in-out property <bool> show_wait_session;
    in-out property <bool> show_create_session;
    in-out property <bool> show_join_session;
}

export component Netplay inherits Page {
    callback create_session_button_clicked;
    callback join_session_button_clicked;
    callback netplay_discord_button_clicked;
    callback netplay_feedback_button_clicked;
    title: @tr("Netplay");

    VerticalBox {
        alignment: start;
        HorizontalBox {
            alignment: center;
            Button {
                enabled: !State.game_running;
                text: @tr("Create Session");
                clicked => {
                    create_session_button_clicked();
                }
            }
        }

        HorizontalBox {
            alignment: center;
            Button {
                enabled: !State.game_running;
                text: @tr("Join Session");
                clicked => {
                    join_session_button_clicked();
                }
            }
        }

        Rectangle {
            height: 20px;
        }

        HorizontalBox {
            alignment: center;
            Button {
                text: @tr("Netplay Discord Channel");
                clicked => {
                    netplay_discord_button_clicked();
                }
            }

            Button {
                text: @tr("Provide Feedback");
                clicked => {
                    netplay_feedback_button_clicked();
                }
            }
        }
    }
}
