#pragma once #include #include #include #include namespace ava2 { // AVA2 MapManager::__LoadMapInfoVector and PythonBackground coordinate rules. struct AtlasMap { std::string name; uint32_t x,y,endX,endY; }; class MapCoordinates { public: std::vector maps; uint32_t baseX=0,baseY=0; void load(const std::string& text) { maps.clear(); std::istringstream input(text); std::string line; while(std::getline(input,line)) { std::istringstream row(line); std::string name; uint32_t x,y,w,h; if(row>>name>>x>>y>>w>>h) maps.push_back({name,x,y,x+w*25600u,y+h*25600u}); } } const AtlasMap* find(uint32_t x,uint32_t y) const { for(const auto& map:maps) if(x>=map.x && x=map.y && y(n):static_cast(int64_t(n)-0x100000000ll); } void toLocal(int32_t& x,int32_t& y) const { x=signedBits(uint32_t(x)-baseX); y=signedBits(uint32_t(y)-baseY); } void toGlobal(int32_t& x,int32_t& y) const { x=signedBits(uint32_t(x)+baseX); y=signedBits(uint32_t(y)+baseY); } }; }