//============================================================== // Функция вызывается при перерисовке //============================================================== void FormAnimationFrames::paintEvent(QPaintEvent*) { QPainter painter {this}; drawFrames(painter); drawCurrentFrame(painter); drawBorder(painter); }
//============================================================== // Функция вызывается при перерисовке //============================================================== void FormAnimation::paintEvent(QPaintEvent*) { QPainter painter {this}; painter.setRenderHint(QPainter::SmoothPixmapTransform); drawTimeScale(&painter); drawFrames(&painter); drawCurrentFrame(&painter); }
//------------------------------------------------------------- void Polaroidframe::draw(){ drawShadow(); drawFrames(); drawBottomBanner(); drawPic(); ofPushMatrix(); ofTranslate(pos); ofRotateZ(angle); ofSetColor(color); ofRect(frame); ofPopMatrix(); animation(); }
void print(gfxScreen_t screen, const char* format, ...) { std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; va_list arguments; char *vaStr; va_start(arguments, format); vasprintf(&vaStr, format, arguments); va_end(arguments); textBuffer += std::string(vaStr); svcOutputDebugString(vaStr, strlen(vaStr)); free(vaStr); drawFrames(); }
void clearScreen(gfxScreen_t screen) { std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom; textBuffer.clear(); drawFrames(); }
void D2Data::loadBackground() { struct ClassInfo { char const* invleft; int invleftx, invlefty; char const* invright; int invrightx, invrighty; int twohanded; int mana; char const* skill; int skillid; } classes[8] = { {"jav", 433, 120, "buc", 649, 135, 0, 15, NULL, 0}, {"sst", 433, 120, "sst", 664, 120, 1, 35, "SoSkillicon", 0}, {"wnd", 433, 136, NULL, 0, 0, 0, 25, "NeSkillicon", 8}, {"ssd", 433, 120, "buc", 649, 135, 0, 15, NULL, 0}, {"hax", 433, 120, "buc", 649, 135, 0, 10, NULL, 0}, {"clb", 433, 120, "buc", 649, 135, 0, 20, NULL, 0}, {"ktr", 433, 120, "buc", 649, 135, 0, 25, NULL, 0}, }; ClassInfo* info = &classes[GetTickCount() % 7]; invBackground = new D2Image(800, 600); int stashx[] = { 80, 336, 80, 336}; int stashy[] = { 61, 61, 317, 317}; drawFrames(invBackground, "data\\global\\ui\\PANEL\\TradeStash.dc6", 0, 4, stashx, stashy); int invenx[] = {400, 656, 400, 656}; int inveny[] = { 61, 61, 317, 317}; drawFrames(invBackground, "data\\global\\ui\\PANEL\\invchar6.dc6", 4, 4, invenx, inveny); int framex[] = { 0, 256, 0, 0, 256, 400, 544, 713, 544, 400}; int framey[] = { -2, -2, 254, 483, 483, -2, -2, 254, 483, 483}; drawFrames(invBackground, "data\\global\\ui\\PANEL\\800BorderFrame.dc6", 0, 10, framex, framey); int ctrlpx[] = { 0, 165, 293, 421, 549, 683, 29, 689, 28, 690}; int ctrlpy[] = {497, 546, 546, 546, 546, 497, 508, 508, 508, 504}; drawFrames(invBackground, "data\\global\\ui\\PANEL\\800ctrlpnl7.dc6", 0, 6, ctrlpx + 0, ctrlpy + 0); drawFrames(invBackground, "data\\global\\ui\\PANEL\\hlthmana.dc6", 0, 2, ctrlpx + 6, ctrlpy + 6); drawFrames(invBackground, "data\\global\\ui\\PANEL\\overlap.dc6", 0, 2, ctrlpx + 8, ctrlpy + 8); int miscx[] = {117, 635, 206, 563, 155, 484, 392, 255, 352, 418}; int miscy[] = {553, 553, 563, 563, 83, 452, 561, 571, 445, 445}; drawFrames(invBackground, "data\\global\\ui\\SPELLS\\Skillicon.dc6", 2, 1, miscx + 0, miscy + 0, tints[9][1]); if (info->skill) { drawFrames(invBackground, String::format("data\\global\\ui\\SPELLS\\%s.dc6", info->skill), info->skillid, 1, miscx + 1, miscy + 1, tints[9][1]); } else drawFrames(invBackground, "data\\global\\ui\\SPELLS\\Skillicon.dc6", 2, 1, miscx + 1, miscy + 1, tints[9][1]); drawFrames(invBackground, "data\\global\\ui\\PANEL\\level.dc6", 2, 1, miscx + 2, miscy + 2); drawFrames(invBackground, "data\\global\\ui\\PANEL\\level.dc6", 2, 1, miscx + 3, miscy + 3); drawFrames(invBackground, "data\\global\\ui\\PANEL\\goldcoinbtn.dc6", 0, 1, miscx + 4, miscy + 4); drawFrames(invBackground, "data\\global\\ui\\PANEL\\goldcoinbtn.dc6", 0, 1, miscx + 5, miscy + 5); drawFrames(invBackground, "data\\global\\ui\\PANEL\\menubutton.dc6", 0, 1, miscx + 6, miscy + 6); drawFrames(invBackground, "data\\global\\ui\\PANEL\\runbutton.dc6", 2, 1, miscx + 7, miscy + 7); drawFrames(invBackground, "data\\global\\ui\\PANEL\\buysellbtn.dc6", 10, 1, miscx + 8, miscy + 8); drawFrames(invBackground, "data\\global\\ui\\PANEL\\buysellbtn.dc6", 10, 1, miscx + 9, miscy + 9); int invx[] = {535, 536, 651, 420, 535, 609, 495, 609, 420, 651}; int invy[] = {136, 239, 239, 240, 66, 95, 240, 240, 109, 109}; drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_armor.dc6", 0, 1, invx + 0, invy + 0); drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_belt.dc6", 0, 1, invx + 1, invy + 1); drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_boots.dc6", 0, 1, invx + 2, invy + 2); drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_helm_glove.dc6", 0, 2, invx + 3, invy + 3); drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_ring_amulet.dc6", 0, 2, invx + 5, invy + 5); drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_ring_amulet.dc6", 1, 1, invx + 7, invy + 7); int itemsx[] = {423, 454, 485, 516}; int itemsy[] = {563, 563, 563, 563}; drawFrames(invBackground, "data\\global\\items\\invhp1.dc6", 0, 1, itemsx + 0, itemsy + 0); drawFrames(invBackground, "data\\global\\items\\invhp1.dc6", 0, 1, itemsx + 1, itemsy + 1); drawFrames(invBackground, "data\\global\\items\\invhp1.dc6", 0, 1, itemsx + 2, itemsy + 2); drawFrames(invBackground, "data\\global\\items\\invhp1.dc6", 0, 1, itemsx + 3, itemsy + 3); if (info->invleft) { drawFrames(invBackground, String::format("data\\global\\items\\inv%s.dc6", info->invleft), 0, 1, &info->invleftx, &info->invlefty); } else drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_weapons.dc6", 0, 1, invx + 8, invy + 8); if (info->invright) { drawFrames(invBackground, String::format("data\\global\\items\\inv%s.dc6", info->invright), 0, 1, &info->invrightx, &info->invrighty); } else drawFrames(invBackground, "data\\global\\ui\\PANEL\\inv_weapons.dc6", 0, 1, invx + 9, invy + 9); if (info->twohanded) invBackground->fill(651, 107, 706, 219, 8, blendTable[2]); invBackground->fill(273, 573, 375, 591, 109, blendTable[0]); D2Font* font = getFont(); drawText(invBackground, 158, 120, "Gold Max: 2500000", -1, font, 0); drawText(invBackground, 245, 95, "0", -1, font, 0); drawText(invBackground, 508, 463, "0", -1, font, 0); drawText(invBackground, 664, 500, String::format("Mana: %d / %d", info->mana, info->mana), -1, font, 0); drawText(invBackground, 425, 584, "1", -1, font, 4); drawText(invBackground, 456, 584, "2", -1, font, 4); drawText(invBackground, 487, 584, "3", -1, font, 4); drawText(invBackground, 518, 584, "4", -1, font, 4); }
Image* D2Data::renderItem(D2Item* item) { File* invfile = loadImageByName(item->image); if (!invfile) return NULL; DC6_FRAME frm; invfile->read(&frm, sizeof frm); int itemWidth = (frm.width + 28) / 29; int itemHeight = (frm.height + 28) / 29; if (item->base) { itemWidth = item->base->invwidth; itemHeight = item->base->invheight; } LocalPtr<D2Image> image = new D2Image(*invBackground); D2Font* font = getFont(); String desc = item->description; int gidSep = desc.lastIndexOf('$'); if (gidSep >= 0) desc.resize(gidSep); Array<String> lines; desc.split(lines, "\\n"); if (!lines.length()) return NULL; int ilvlSep = lines[0].lastIndexOf('('); if (ilvlSep >= 0) { lines[0].resize(ilvlSep); lines[0].trim(); } int boxWidth = 0; for (int i = 0; i < lines.length(); i++) { int width = font->width(lines[i], lines[i].length()); boxWidth = max(boxWidth, width); } boxWidth += 8; int boxHeight = 16 * lines.length(); int storType, storX, storY; int storRoom[2][16][16]; memset(storRoom, 0, sizeof storRoom); int validT[128]; int validX[128]; int validY[128]; int validNum = 0; for (int t = 0; t < 2; t++) { for (int x = 0; x + itemWidth <= storage[t].width; x++) { for (int y = 0; y + itemHeight <= storage[t].height; y++) { if (storage[t].y0 + y * 29 - boxHeight + 1 >= 0 || storage[t].y0 + (y + itemHeight) * 29 + boxHeight <= invBackground->height()) { validT[validNum] = t; validX[validNum] = x; validY[validNum] = y; validNum++; } } } } if (validNum) { validNum = (rand() % validNum); storType = validT[validNum]; storX = validX[validNum]; storY = validY[validNum]; } else { storType = 0; storY = 0; storX = (rand() % (storage[0].width - itemWidth + 1)); } int itemX = storage[storType].x0 + storX * 29; int itemY = storage[storType].y0 + storY * 29; image->fill(itemX, itemY - 1, itemX + itemWidth * 29, itemY - 1 + itemHeight * 29, 118, blendTable[2]); uint8* tint = NULL; if (item->base && item->invColor >= 0) tint = tints[item->base->invtrans][item->invColor]; drawDC6(image, itemX, itemY, &frm, invfile, tint, item->flags & D2Item::fEthereal ? blendTable[1] : NULL); for (int x = 0; x < itemWidth; x++) for (int y = 0; y < itemHeight; y++) storRoom[storType][storX + x][storY + y] = 1; if (item->parent) { for (int curi = 0; curi < item->parent->items.length(); curi++) { D2Item* curitem = item->parent->items[curi]; if (curitem == item) continue; File* curfile = loadImageByName(curitem->image); if (!curfile) continue; DC6_FRAME curfrm; curfile->read(&curfrm, sizeof curfrm); int curWidth = (curfrm.width + 28) / 29; int curHeight = (curfrm.height + 28) / 29; int curT = -1, curX, curY; for (int t = 0; t < 2 && curT < 0; t++) { for (int x = 0; x + curWidth <= storage[t].width && curT < 0; x++) { for (int y = 0; y + curHeight <= storage[t].height; y++) { int valid = 1; for (int cx = 0; cx < curWidth && valid; cx++) for (int cy = 0; cy < curHeight; cy++) { if (storRoom[t][x + cx][y + cy]) { valid = 0; break; } } if (valid) { curT = t; curX = x; curY = y; break; } } } } if (curT >= 0) { for (int x = 0; x < curWidth; x++) for (int y = 0; y < curHeight; y++) storRoom[curT][curX + x][curY + y] = 1; int scrX = storage[curT].x0 + curX * 29; int scrY = storage[curT].y0 + curY * 29; if (curitem->description.find("\\n\\xffc1") >= 0 || !strncmp(curitem->description, "\\xffc1", 6)) image->fill(scrX, scrY - 1, scrX + curWidth * 29, scrY - 1 + curHeight * 29, 8, blendTable[2]); else image->fill(scrX, scrY - 1, scrX + curWidth * 29, scrY - 1 + curHeight * 29, 234, blendTable[2]); uint8* tint = NULL; if (curitem->base && curitem->invColor >= 0) tint = tints[curitem->base->invtrans][curitem->invColor]; drawDC6(image, scrX, scrY, &curfrm, curfile, tint, curitem->flags & D2Item::fEthereal ? blendTable[1] : NULL); } } } if (item->sockets.length()) { File* soxImage = loadImage("data\\global\\ui\\PANEL\\gemsocket.dc6"); int sox = item->sockets.length(); if (sox > 6) sox = 6; D2Point const* pos = getSocketPos(itemWidth, itemHeight, sox); for (int i = 0; i < sox; i++) { soxImage->seek(0, SEEK_SET); drawDC6(image, itemX + pos[i].x - 1, itemY + pos[i].y + 1, NULL, soxImage, NULL, blendTable[2]); if (item->sockets[i] != "gemsocket") { File* gemfile = loadImageByName(item->sockets[i]); if (gemfile) drawDC6(image, itemX + pos[i].x, itemY + pos[i].y, NULL, gemfile); } } } int boxX = itemX + (itemWidth * 29 - boxWidth) / 2; if (boxX < 0) boxX = 0; if (boxX + boxWidth > image->width()) boxX = image->width() - boxWidth; int boxY = itemY - boxHeight + 1; if (boxY < 0) { boxY = itemY + itemHeight * 29; if (boxY + boxHeight > image->height()) boxY = image->height() - boxHeight; } image->fill(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0, blendTable[0]); for (int i = 0; i < lines.length(); i++) { int width = font->width(lines[i], lines[i].length()); int lineX = boxX + (boxWidth - width) / 2; int lineY = boxY + i * 16 + 8; drawText(image, lineX, lineY, lines[i], lines[i].length(), font); } int cursorX = itemX + itemWidth * 29 - 2 - (rand() % 10); int cursorY = itemY + 4 + (rand() % (itemHeight * 29 - 8)); drawFrames(image, "data\\global\\ui\\CURSOR\\protate.dc6", rand() % 8, 1, &cursorX, &cursorY); int resLeft = min(itemX, boxX) - 10; int resTop = min(itemY, boxY) - 10; int resRight = max(itemX + itemWidth * 29, boxX + boxWidth) + 10; int resBottom = max(itemY + itemHeight * 29, boxY + boxHeight) + 10; return image->image(resLeft, resTop, resRight, resBottom, palette); }