| 32 | #define TILES_ACROSS 20 |
| 33 | |
| 34 | TilePickerTab::TilePickerTab(const char* basename, int i, QWidget* parent) : |
| 35 | QWidget(parent) |
| 36 | { |
| 37 | id = i; |
| 38 | filename = basename; |
| 39 | filename += ".txt"; |
| 40 | num = 0; |
| 41 | int index = 0; |
| 42 | for (int real=0; real<2; real++) { |
| 43 | if ( real ) { |
| 44 | image.create( TILES_ACROSS*TILE_X, |
| 45 | ((num+TILES_ACROSS-1)/TILES_ACROSS)*TILE_Y, 32 ); |
| 46 | } |
| 47 | if ( !fopen_text_file(filename.latin1(), RDTMODE) ) { |
| 48 | // XXX handle better |
| 49 | exit(1); |
| 50 | } |
| 51 | pixel p[TILE_Y][TILE_X]; |
| 52 | while ( read_text_tile(p) ) { |
| 53 | if ( real ) { |
| 54 | int ox = (index%TILES_ACROSS)*TILE_X; |
| 55 | int oy = (index/TILES_ACROSS)*TILE_Y; |
| 56 | for ( int y=0; y<TILE_Y; y++ ) { |
| 57 | QRgb* rgb = ((QRgb*)image.scanLine(oy+y)) + ox; |
| 58 | for ( int x=0; x<TILE_X; x++ ) { |
| 59 | *rgb++ = qRgb(p[y][x].r, p[y][x].g, p[y][x].b); |
| 60 | } |
| 61 | } |
| 62 | index++; |
| 63 | } else { |
| 64 | // Just count... |
| 65 | num++; |
| 66 | } |
| 67 | } |
| 68 | fclose_text_file(); |
| 69 | } |
| 70 | image = image.convertDepth( 8, AvoidDither ); |
| 71 | pixmap.convertFromImage( image ); |
| 72 | } |
| 73 | |
| 74 | bool TilePickerTab::save() |
| 75 | { |
nothing calls this directly
no test coverage detected