#ifndef KarteAuswahl_H
#define KarteAuswahl_H

#include <Klient.h>
#include <Bild.h>
#include <Knopf.h>
#include <Thread.h>
#include <KSGScript.h>
#include <Rahmen.h>

using namespace Framework;
using namespace KSGScript;

class KarteDaten
{
private:
    class Loader : public Thread
    {
    private:
        KarteDaten * kd;
        int aktion;
    public:
        Loader( KarteDaten *kd, int aktion );
        void thread() override;
        Loader *release();
        int getAction() const;
    };
    Loader *loader;
    int karteId;
    Schrift *schrift;
    Bild *hintergrund;
    HINSTANCE ksgs;
    KSGScriptObj *beschreibung;
    LRahmen *rahmen;
    double tickVal;
    int animation;
    bool ausgew�hlt;
    Punkt pos;
    Punkt gr;
    int geladen;
    AlphaFeld *auswahl;
    unsigned char auswAlpha;
    bool erlaubt;
    bool rend;
    unsigned char tAlpha;
    unsigned char alpha;
    int ref;
    friend Loader;

public:
    // Konstruktor
    KarteDaten( Schrift *zSchrift, int id );
    // Destruktor
    ~KarteDaten();
    // nicht constant
    void updateErlaubt();
    void ksgsAktion( RCArray< KSGSVariable > *parameter, KSGSVariable **retVal );
    void setSichtbar( bool sichtbar );
    void setSichtbar();
    void setAuswahl( bool auswahl );
    void setPosition( int lPos );
    bool tick( double tickVal );
    void doMausEreignis( MausEreignis &me );
    void render( Bild &zRObj );
    // constant
    int getKarteId() const;
    bool istausgew�hlt() const;
    // Reference Counting
    KarteDaten *getThis();
    KarteDaten *release();
};

class KarteAuswahlFenster : public Thread
{
private:
    int anzahl;
    int auswahl;
    RCArray< KarteDaten > *members;
    LRahmen *rahmen;
    Schrift *schrift;
    TextRenderer *tr;
    double tickVal;
    int animation;
    Punkt pos;
    Punkt gr;
    int spielId;
    int seite;
    bool rend;
    unsigned char alpha;

public:
    // Konstruktor
    KarteAuswahlFenster( Schrift *zSchrift );
    // Destruktor
    ~KarteAuswahlFenster();
    // nicht constant
    void setSpielId( int spielId );
    void setSichtbar( bool sichtbar );
    void bl�ttern( bool oben );
    void updateListe();
    virtual void thread();
    bool tick( double tickVal );
    void doMausEreignis( MausEreignis &me );
    void render( Bild &zrObj );
    // constant
    int getAnzahl() const;
    int getSeiteAnzahl() const;
    int getSeite() const;
    int getAnzahlAufSeite() const;
    bool hatAuswahl() const;
    KarteDaten *getAuswahl() const;
    // l�scht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
    Thread *release() override;
};

#endif