#pragma once

#include <Zeichnung.h>
#include <Trie.h>

#include "ChunkMap.h"

class DimensionMap : public Framework::ZeichnungHintergrund
{
private:
    Framework::Trie<ChunkMap>* chunks;
    Framework::Punkt originChunkCenter;
    Framework::Punkt scrollOffset;
    int chunkCount;
    int pixelsPerBlock;
    int maxHeight;
    bool waitingForChunk;
    bool drag;
    Framework::Punkt lastMouse;
    Framework::Punkt lastSize;

    void getAddrOf(Framework::Punkt cPos, char* addr) const;
    void getAddrOfWorld(Framework::Punkt wPos, char* addr) const;
    Framework::Punkt getMinVisibleChunkCenter(Framework::Punkt &screenPos) const;
    Framework::Punkt getMaxVisibleChunkCenter(
        Framework::Punkt& screenPos) const;

public:
    DimensionMap();
    ~DimensionMap();
    
    void requestNextChunk();
    void addChunk(ChunkMap* chunk);
    bool tick(double time) override;
    void render(Framework::Bild& rObj) override;
    void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
};