void DwarfClipboardPng::waitTillDigMenuClear() { DFHack::Position * Pos = DF->getPosition(); DFHack::WindowIO * Win = DF->getWindowIO(); int32_t screenWidth,screenHeight; Pos->getWindowSize(screenWidth,screenHeight); DFHack::t_screen *screen; screen = new DFHack::t_screen[screenWidth*screenHeight]; Pos->getScreenTiles(screenWidth,screenHeight,screen); while(screen[3*screenWidth+50].symbol == 'M'){ DF->Resume(); Win->TypeSpecial(DFHack::WAIT,1,delay); DF->Resume(); Pos->getScreenTiles(screenWidth,screenHeight,screen); } }
QList<QImage> DwarfClipboardPng::getImagesForRange(QList<cursorIdx> range) { QList<QImage> retImages; DFHack::Position * Pos = DF->getPosition(); DFHack::WindowIO * Win = DF->getWindowIO(); dfLocationIterator itr(range[0],range[1]); cursorIdx begin = itr.begin(); cursorIdx end = itr.end(); cursorIdx size; size.x = (end.x-begin.x)+1; size.y = (end.y-begin.y)+1; size.z = begin.z-end.z+1; cursorIdx oldCursor,oldPosition; START_READ Pos->getCursorCoords(oldCursor.x,oldCursor.y,oldCursor.z); Pos->getViewCoords(oldPosition.x,oldPosition.y,oldPosition.z); Pos->setCursorCoords(-30000,oldCursor.y,oldCursor.z); int32_t screenWidth,screenHeight; Pos->getWindowSize(screenWidth,screenHeight); int32_t effectiveWidth = screenWidth-2-55; // 55 is the width of the map and the menus int32_t effectiveHeight = screenHeight-2; DFHack::t_screen *screen; screen = new DFHack::t_screen[screenWidth*screenHeight]; QString rawComplete = QString("%1,%2,%3|").arg(size.x).arg(size.y).arg(size.z); for(int zitr = 0;zitr < size.z;zitr++){ QVector<QVector<QString> > rawNumbers(size.x,QVector<QString>(size.y)); for(int xIdx = 0;xIdx < int(size.x/effectiveWidth)+1;xIdx++){ for(int yIdx=0;yIdx < int(size.y/effectiveHeight)+1;yIdx++){ Pos->setViewCoords(begin.x+xIdx*effectiveWidth,begin.y+yIdx*effectiveHeight,begin.z-zitr); END_READ Win->TypeSpecial(DFHack::WAIT,1,delay); START_READ Pos->getScreenTiles(screenWidth,screenHeight,screen); END_READ int ylim = effectiveHeight; int xlim = effectiveWidth; if(yIdx == int(size.y/effectiveHeight)){ ylim = size.y % effectiveHeight; } if(xIdx == int(size.x/effectiveWidth)){ xlim = size.x % effectiveWidth; } for(int yitr = 1;yitr < ylim+1;yitr++){ for(int xitr = 1;xitr < xlim+1;xitr++){ QString test = stringFromScreen(screen[yitr*screenWidth+xitr]); rawNumbers[effectiveWidth*xIdx + xitr-1][effectiveHeight*yIdx + yitr-1] = test; } } } } for(int yitr = 0;yitr < rawNumbers[0].size();yitr++){ for(int xitr = 0;xitr < rawNumbers.size();xitr++){ rawComplete.append(rawNumbers[xitr][yitr]); } rawComplete.append(':'); } rawComplete.append("|"); } START_READ Pos->setViewCoords(oldPosition.x,oldPosition.y,oldPosition.z); Pos->setCursorCoords(oldCursor.x,oldCursor.y,oldCursor.z); END_READ retImages = ImagesFromString(rawComplete); // this is a little weird, but it will be easier to only have to debug one way to get the images for(int itr = 0;itr<retImages.size();itr++){ retImages[itr].setText("rawNumbers",rawComplete); } delete screen; return(retImages); }