#pragma once

#include <HashMap.h>
#include <Knopf.h>
#include <Liste.h>
#include <TextFeld.h>

#include "Menu.h"

class ServerStatus : public ZeichnungHintergrund
{
private:
    Framework::Text name;
    Framework::Text ip;
    unsigned short sslPort;
    unsigned short port;
    Framework::Text playerName;
    int ping;
    Framework::Text status;
    int statusId;
    int requestId;
    Framework::HashMap<Framework::Text, Framework::Text>* secrets;
    Framework::Knopf* removeButton;
    Framework::Knopf* join;

public:
    ServerStatus(Framework::Text name,
        Framework::Text ip,
        unsigned short sslPort,
        unsigned short port,
        Framework::HashMap<Framework::Text, Framework::Text>* secrets);
    ~ServerStatus();

    virtual void updatePlayerName(Framework::Text playerName);

    virtual void doMausEreignis(
        Framework::MausEreignis& me, bool userRet) override;
    virtual bool tick(double time) override;
    virtual void render(Framework::Bild& rObj) override;

    Framework::Text getName() const;
    Framework::Text getIp() const;
    unsigned short getSSLPort() const;
    unsigned short getPort() const;
    Framework::HashMap<Framework::Text, Framework::Text>* zSecrets() const;
    bool canConnect() const;
};

class ServerSelectionMenu : public Menu
{
private:
    Framework::TextFeld* playerName;
    Framework::TextFeld* playerNameLabel;
    Framework::TextFeld* serverLabel;
    Framework::ZListe* serverList;
    Framework::Knopf* add;
    Framework::Knopf* refresh;
    Framework::Knopf* exit;

public:
    ServerSelectionMenu(Framework::Bildschirm* zScreen);
    void addServer(Framework::Text name,
        Framework::Text ip,
        unsigned short sslPort,
        unsigned short port);
    bool hasServer(Framework::Text name) const;
    void removeServer(Framework::Text name) const;
    void saveServers() const;
};