-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMapView.cpp
More file actions
72 lines (62 loc) · 1.9 KB
/
MapView.cpp
File metadata and controls
72 lines (62 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "MapView.hpp"
MapView::~MapView(){
SDL_DestroyTexture(cacheTexture);
}
void MapView::doDraw(Canvas& c){
auto dimen = gsim->getConfig().dimen;
auto tileSize = painter->mainMapTileSize;
auto localLeft = left;
auto localTop = top;
c.getCurrentWorldXY(localLeft, localTop);
auto const ttop = localTop;
if(cacheTexture != NULL){
c.clip();
c.drawTexture(cacheTexture, localLeft, localTop, scrollX, scrollY, dimen*tileSize,
dimen*tileSize);
c.disableClip();
return;
}
cacheTexture = painter->getTemp(dimen*tileSize, dimen*tileSize);
int xtop = 0, xleft = 0;
int xxtop =0, xxleft=0;
for(UShort i = 0; i<= dimen; ++i){
for(UShort j = 0; j<=dimen; ++j){
auto tile = gsim->getTile(Pair(i,j));
auto sp = painter->getSprite(tile);
//gsim->getTile(Pair(i,j))->generateSubTiles();
c.drawSprite(sp, cacheTexture, xleft, xtop, tileSize, tileSize);
// for(UShort x =0; x < 16; ++x){
// for(UShort y =0; y < 16; ++y){
// auto sp = painter->getSprite(tile, Pair(x,y));
// c.drawSprite(sp, cacheTexture, xxleft, xxtop, tileSize, tileSize);
// xxtop += tileSize;
// }
// xxleft += tileSize;
// xxtop = xtop;
// }
// xtop += tileSize*16;
// xxleft = xleft;
xtop += tileSize;
}
xtop = 0;
xleft += tileSize;
}
//c.disableClip();
}
void MapView::doMeasure(Measure wm, Measure hm){
measuredWt = wm;
measuredHt = hm;
auto dimen = gsim->getConfig().dimen;
auto tileSize = painter->mainMapTileSize;
measuredWt.value = resolveSize(dimen*tileSize, wm);
measuredHt.value = resolveSize(dimen*tileSize, hm);
}
void MapView::doLayout(bool , int ,int ,int ,int ){
}
std::unique_ptr<MapView> MapView::make(GeoSim* geosim, MapPainter* painter){
auto tv = std::make_unique<MapView>();
tv->gsim = geosim;
tv->painter = painter;
tv->cacheTexture = NULL;
return tv;
}