// TMainScreen.PanelPaint (Term.pas): the top bar and the bottom panel // (mini map frame, selected unit, units on the tile, terrain info, buttons). #include "Term.MainScreen.h" #include "Cevo/CevoGraphicSet.h" #include "Cevo/CevoScreenTools.h" #include "Cevo/CevoTexture.h" #include "Global.h" #include namespace Cevo { namespace Term { namespace { QString terrainPhrase(int index) { return phrases.lookup(QStringLiteral("TERRAIN"), index); } QString twoTerrains(int first, int second) { return formatPhrase(QStringLiteral("TWOTERRAINS"), { terrainPhrase(first), terrainPhrase(second) }); } QString unitMovementString(const TUn &un) { QString result = movementToString(un.Movement); if (un.Master >= 0) { result = QStringLiteral("(%1)").arg(result); } else { const TModel &model = ClientTools::myModel[un.mix]; if (model.Domain == dAir && model.Kind != mkSpecial_Glider) result = QStringLiteral("%1(%2)").arg(result).arg(un.Fuel); } return result; } // Name of what a map editor brush paints. QString brushName(std::uint32_t brushType) { switch (brushType) { case fDesert: case fPrairie: case fTundra: case fArctic: case fSwamp: case fHills: case fMountains: return terrainPhrase(static_cast(brushType)); case fShore: return twoTerrains(fOcean, fShore); case fGrass: return twoTerrains(fGrass, fGrass + 12); case fForest: return twoTerrains(fForest, fJungle); case fRiver: return phrases[QStringLiteral("RIVER")]; case fDeadLands: case fDeadLands | fCobalt: case fDeadLands | fUranium: case fDeadLands | fMercury: return terrainPhrase(3 * 12 + static_cast(brushType >> 25)); case fPrefStartPos: return phrases[QStringLiteral("MAP_PREFSTART")]; case fStartPos: return phrases[QStringLiteral("MAP_START")]; case fPoll: return phrases[QStringLiteral("POLL")]; default: { int index = 0; switch (brushType) { case fRoad: index = 1; break; case fRR: index = 2; break; case tiIrrigation: index = 4; break; case tiFarm: index = 5; break; case tiMine: index = 7; break; case fCanal: index = 8; break; case tiFort: index = 10; break; case tiBase: index = 12; break; default: break; } return phrases.lookup(QStringLiteral("JOBRESULT"), index); } } } } // namespace void MainScreen::panelPaint() { if (!ClientTools::myRO || m_panel.width() <= 1 || !MainTexture) return; paintPanelBackground(); if (clientMode == cEditMap) paintPanelBrushes(); else if (m_troopLoc >= 0) paintPanelTroops(); paintPanelButtons(); m_eot->setBack(m_panel.canvas(), m_eot->x(), m_eot->y() - (height() - PanelHeight)); m_panel.canvas().end(); invalidateRect(0, height() - PanelHeight, width(), height()); paintTopBar(); } void MainScreen::paintPanelBackground() { const int lx = ClientTools::g.lx; const int ly = ClientTools::g.ly; const int cw = width(); Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; fill(canvas, 0, 3, m_xMidPanel + 7 - 10, PanelHeight - 3, texture.width() - (m_xMidPanel + 7 - 10), texture.height() - PanelHeight); fill(canvas, m_xRightPanel + 10 - 7, 3, m_panel.width() - m_xRightPanel - 10 + 7, PanelHeight - 3, -(m_xRightPanel + 10 - 7), texture.height() - PanelHeight); fillLarge(canvas, m_xMidPanel - 2, PanelHeight - MidPanelHeight, m_xRightPanel + 2, PanelHeight, cw / 2); canvas.brush().setStyle(Qt::NoBrush); canvas.pen().setColor(Qt::black); canvas.moveTo(0, 0); canvas.lineTo(m_xMidPanel + 7 - 8, 0); canvas.lineTo(m_xMidPanel + 7 - 8, PanelHeight - MidPanelHeight); canvas.lineTo(m_xRightPanel, PanelHeight - MidPanelHeight); canvas.lineTo(m_xRightPanel, 0); canvas.lineTo(cw, 0); canvas.pen().setColor(texture.colorBevelLight); canvas.moveTo(m_xMidPanel + 7 - 9, PanelHeight - MidPanelHeight + 2); canvas.lineTo(m_xRightPanel + 10 - 8, PanelHeight - MidPanelHeight + 2); canvas.pen().setColor(texture.colorBevelLight); canvas.moveTo(0, 1); canvas.lineTo(m_xMidPanel + 7 - 9, 1); canvas.pen().setColor(texture.colorBevelShade); canvas.lineTo(m_xMidPanel + 7 - 9, PanelHeight - MidPanelHeight + 1); canvas.pen().setColor(texture.colorBevelLight); canvas.lineTo(m_xRightPanel + 10 - 9, PanelHeight - MidPanelHeight + 1); canvas.pen().setColor(texture.colorBevelLight); canvas.lineTo(m_xRightPanel + 10 - 9, 1); canvas.lineTo(cw, 1); canvas.moveTo(cw, 2); canvas.lineTo(m_xRightPanel + 10 - 8, 2); canvas.lineTo(m_xRightPanel + 10 - 8, PanelHeight); canvas.moveTo(0, 2); canvas.lineTo(m_xMidPanel + 7 - 10, 2); canvas.pen().setColor(texture.colorBevelShade); canvas.lineTo(m_xMidPanel + 7 - 10, PanelHeight); corner(canvas, m_xMidPanel + 7 - 16, 1, 1, texture); corner(canvas, m_xRightPanel + 10 - 9, 1, 0, texture); if (clientMode != cEditMap) { if (supervising) { frame(canvas, cw - XPalace - 1, YPalace - 1, cw - XPalace + xSizeBig, YPalace + ySizeBig, colorFromDelphi(0xB0B0B0), colorFromDelphi(0xFFFFFF)); rframe(canvas, cw - XPalace - 2, YPalace - 2, cw - XPalace + xSizeBig + 1, YPalace + ySizeBig + 1, colorFromDelphi(0xFFFFFF), colorFromDelphi(0xB0B0B0)); bitBltBitmap(m_panel, cw - XPalace, YPalace, xSizeBig, ySizeBig, HGrSystem2->data, 70, 123); } else if (ClientTools::myRO->NatBuilt[imPalace] > 0) { impImage(canvas, cw - XPalace, YPalace, imPalace, -1, gameMode != cMovie); } else { impImage(canvas, cw - XPalace, YPalace, 21, -1, gameMode != cMovie); } } if (gameMode == cMovie) { frame(canvas, m_xMini + 1, m_yMini + 1, m_xMini + 2 + lx * 2, m_yMini + 2 + ly, Qt::black, Qt::black); } else { frame(canvas, m_xMini + 1, m_yMini + 1, m_xMini + 2 + lx * 2, m_yMini + 2 + ly, colorFromDelphi(0xB0B0B0), colorFromDelphi(0xFFFFFF)); rframe(canvas, m_xMini, m_yMini, m_xMini + 3 + lx * 2, m_yMini + 3 + ly, colorFromDelphi(0xFFFFFF), colorFromDelphi(0xB0B0B0)); } copyMiniToPanel(); if (clientMode != cEditMap) { // MapBtn icons for (int i = 0; i <= 5; ++i) { if (i != 3) dump(m_panel, *HGrSystem, m_xMini + lx - 42 + 16 * i, PanelHeight - 26, 8, 8, 121 + i * 9, 61); } } } void MainScreen::paintPanelBrushes() { Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; const int xxt = m_noMapPanel->xxt; const int yyt = m_noMapPanel->yyt; GraphicSet *hGrTerrain = m_noMapPanel->hGrTerrain; const int position = m_verticalScrollBar ? m_verticalScrollBar->position() : 0; for (int i = 0; i < m_trRow; ++i) m_trix[static_cast(i)] = -1; int count = 0; for (const std::uint32_t brush : BrushTypes) { if (count >= m_trRow * position && count < m_trRow * (position + 1)) { const int slot = count - m_trRow * position; m_trix[static_cast(slot)] = static_cast(brush); const int x = slot * m_trPitch; QPoint srcBase(-1, 0); QPoint src; if (brush <= 8) { src = QPoint(static_cast(brush), 0); } else if (brush <= 30) { srcBase = QPoint(2, 2); src = QPoint(0, 2 * static_cast(brush) - 15); } else if (brush == fRiver) { src = QPoint(7, 14); } else if (brush == fRoad) { src = QPoint(0, 9); } else if (brush == fRR) { src = QPoint(0, 10); } else if (brush == fCanal) { src = QPoint(0, 11); } else if (brush == fPoll) { src = QPoint(6, 12); } else if (brush == fDeadLands || brush == (fDeadLands | fCobalt) || brush == (fDeadLands | fUranium) || brush == (fDeadLands | fMercury)) { srcBase = QPoint(6, 2); src = QPoint(8, 12 + static_cast(brush >> 25)); } else if (brush == tiIrrigation || brush == tiFarm || brush == tiMine || brush == tiBase) { src = QPoint(static_cast(brush >> 12) - 1, 12); } else if (brush == tiFort) { src = QPoint(3, 12); srcBase = QPoint(7, 12); } else if (brush == fPrefStartPos) { src = QPoint(0, 1); } else if (brush == fStartPos) { src = QPoint(0, 2); } if (srcBase.x() >= 0) sprite(canvas, *hGrTerrain, m_xTroop + 2 + x, YTroop + 9 - yyt, xxt * 2, yyt * 3, 1 + srcBase.x() * (xxt * 2 + 1), 1 + srcBase.y() * (yyt * 3 + 1)); sprite(canvas, *hGrTerrain, m_xTroop + 2 + x, YTroop + 9 - yyt, xxt * 2, yyt * 3, 1 + src.x() * (xxt * 2 + 1), 1 + src.y() * (yyt * 3 + 1)); if (brush == m_brushType) { frame(canvas, m_xTroop + 2 + x, YTroop + 7 - yyt / 2, m_xTroop + 2 * xxt + x, YTroop + 2 * yyt + 11, Qt::black, Qt::black); frame(canvas, m_xTroop + 1 + x, YTroop + 6 - yyt / 2, m_xTroop + 2 * xxt - 1 + x, YTroop + 2 * yyt + 10, texture.colorMark, texture.colorMark); } } ++count; } loweredTextOut(canvas, -1, texture, m_xTroop + 1, PanelHeight - 19, brushName(m_brushType)); } void MainScreen::paintPanelSelectedUnit() { Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; const int me = ClientTools::me; const TUn &un = ClientTools::myUn[IsoEngine::unFocus]; if (me < 0 || me >= nPl) return; // display info about selected unit const int mixShow = un.Job == jCity ? -1 : un.mix; // building site Tribes::Tribe &tribe = *Tribes::tribe[static_cast(me)]; const Tribes::ModelPicture &picture = tribe.modelPictureAt(mixShow); if (picture.hGr) sprite(canvas, *picture.hGr, m_xMidPanel + 7 + 12, YTroop + 1, 64, 48, picture.pix % 10 * 65 + 1, picture.pix / 10 * 49 + 1); if ((un.Flags & unFortified) && Tribes::hGrStdUnits) sprite(canvas, *Tribes::hGrStdUnits, m_xMidPanel + 7 + 12, YTroop + 1, IsoEngine::xxu * 2, IsoEngine::yyu * 2, 1 + 6 * (IsoEngine::xxu * 2 + 1), 1); makeBlue(m_panel, m_xMidPanel + 7 + 12 + 10, YTroop - 13, 44, 12); QString s = unitMovementString(un); risedTextOut(canvas, m_xMidPanel + 7 + 12 + 32 - biColorTextWidth(canvas, s) / 2, YTroop - 16, s); const int health = un.Health; s = QStringLiteral("%1%").arg(health); lightGradient(canvas, m_xMidPanel + 7 + 12 + 7, PanelHeight - 22, (health + 1) / 2, colorFromDelphi(((ClientTools::colorOfHealth(health) & 0xFEFEFE) >> 2) * 3)); if (health < 100) lightGradient(canvas, m_xMidPanel + 7 + 12 + 7 + (health + 1) / 2, PanelHeight - 22, 50 - (health + 1) / 2, Qt::black); risedTextOut(canvas, m_xMidPanel + 7 + 12 + 32 - biColorTextWidth(canvas, s) / 2, PanelHeight - 23, s); frameImage(canvas, HGrSystem->data, m_xMidPanel + 7 + XUnitText, YTroop + 15, 12, 14, 121 + un.Exp / ExpCost * 13, 28); s = tribe.modelNameAt(un.Job == jCity ? -1 : un.mix); if (un.Home >= 0) { loweredTextOut(canvas, -1, texture, m_xMidPanel + 7 + XUnitText + 18, YTroop + 5, s); loweredTextOut(canvas, -1, texture, m_xMidPanel + 7 + XUnitText + 18, YTroop + 21, QStringLiteral("(%1)").arg(Tribes::cityName(ClientTools::myCity[un.Home].ID))); } else { loweredTextOut(canvas, -1, texture, m_xMidPanel + 7 + XUnitText + 18, YTroop + 13, s); } } void MainScreen::paintPanelTroops() { Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; const int me = ClientTools::me; const std::uint32_t *myMap = ClientTools::myMap; const TUn *myUn = ClientTools::myUn; const int position = m_verticalScrollBar ? m_verticalScrollBar->position() : 0; canvas.brush().setStyle(Qt::NoBrush); if (IsoEngine::unFocus >= 0) paintPanelSelectedUnit(); if (IsoEngine::unFocus >= 0 && myUn[IsoEngine::unFocus].Loc != m_troopLoc) { // divide panel const int x = m_smallScreen && !supervising ? m_xTroop - 8 : m_xTroop - 152; canvas.pen().setColor(texture.colorBevelShade); canvas.moveTo(x - 1, PanelHeight - MidPanelHeight + 2); canvas.lineTo(x - 1, PanelHeight); canvas.pen().setColor(texture.colorBevelLight); canvas.moveTo(x, PanelHeight - MidPanelHeight + 2); canvas.lineTo(x, PanelHeight); } for (int i = 0; i < 24; ++i) m_trix[static_cast(i)] = -1; if (myMap[m_troopLoc] & fUnit) { if (myMap[m_troopLoc] & fOwned) { if (m_trCnt > 1 || IsoEngine::unFocus < 0 || myUn[IsoEngine::unFocus].Loc != m_troopLoc) { loweredTextOut(canvas, -1, texture, m_xTroop + 10, PanelHeight - 24, phrases[QStringLiteral("PRESENT")]); int uixDefender = -1; ClientTools::server(sGetDefender, me, m_troopLoc, &uixDefender); int count = 0; for (int prio = 1; prio >= 0; --prio) { for (int uix = 0; uix < ClientTools::myRO->nUn; ++uix) { if ((uix == uixDefender) != (prio != 0)) continue; const TUn &unx = myUn[uix]; if (unx.Loc != m_troopLoc) continue; // display own units if (count >= m_trRow * position && count < m_trRow * (position + 1) && me >= 0 && me < nPl) { const int slot = count - m_trRow * position; m_trix[static_cast(slot)] = uix; TUnitInfo unitInfo; MakeUnitInfo(me, unx, unitInfo); const int x = slot * m_trPitch; if (uix == IsoEngine::unFocus) { frame(canvas, m_xTroop + 4 + x, YTroop + 3, m_xTroop + 64 + x, YTroop + 47, Qt::black, Qt::black); frame(canvas, m_xTroop + 3 + x, YTroop + 2, m_xTroop + 63 + x, YTroop + 46, texture.colorMark, texture.colorMark); } else if (unx.Master >= 0 && unx.Master == IsoEngine::unFocus) { cframe(canvas, m_xTroop + 4 + x, YTroop + 3, m_xTroop + 64 + x, YTroop + 47, 8, Qt::black); cframe(canvas, m_xTroop + 3 + x, YTroop + 2, m_xTroop + 63 + x, YTroop + 46, 8, texture.colorMark); } m_noMapPanel->setOutput(&m_panel); m_noMapPanel->paintUnit(m_xTroop + 2 + x, YTroop + 1, unitInfo, unx.Status); if (clientMode < scContact && (unx.Job > jNone || (unx.Status & (IsoEngine::usStay | IsoEngine::usRecover | IsoEngine::usGoto)) != 0)) sprite(canvas, *HGrSystem, m_xTroop + 2 + 60 - 20 + x, YTroop + 35, 20, 20, 81, 25); if (!supervising) { makeBlue(m_panel, m_xTroop + 2 + 10 + x, YTroop - 13, 44, 12); const QString s = unitMovementString(unx); risedTextOut(canvas, m_xTroop + x + 34 - biColorTextWidth(canvas, s) / 2, YTroop - 16, s); } } ++count; } } Q_ASSERT(count == m_trCnt); } } else { loweredTextOut(canvas, -1, texture, m_xTroop + 8, PanelHeight - 24, phrases[QStringLiteral("PRESENT")]); int count = 0; ClientTools::server(sGetUnits, me, m_troopLoc, &count); for (int i = 0; i < count; ++i) { if (i >= m_trRow * position && i < m_trRow * (position + 1)) { // display enemy units m_trix[static_cast(i - m_trRow * position)] = i; const int x = (i - m_trRow * position) * m_trPitch; m_noMapPanel->setOutput(&m_panel); m_noMapPanel->paintUnit(m_xTroop + 2 + x, YTroop + 1, (*ClientTools::myRO->EnemyUn)[ClientTools::myRO->nEnemyUn + i], 0); } } } } if (!m_smallScreen || supervising) paintPanelTerrain(); if (m_terrainBtn->isVisible()) rframe(canvas, m_terrainBtn->x() - 1, m_terrainBtn->y() - height() + (PanelHeight - 1), m_terrainBtn->x() + m_terrainBtn->width(), m_terrainBtn->y() + m_terrainBtn->height() - height() + PanelHeight, texture.colorBevelShade, texture.colorBevelLight); } void MainScreen::paintPanelTerrain() { Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; const std::uint32_t *myMap = ClientTools::myMap; const TUn *myUn = ClientTools::myUn; paintZoomedTile(m_panel, m_xTerrain - m_noMapPanel->xxt * 2, 110 - m_noMapPanel->yyt * 3, m_troopLoc); if (IsoEngine::unFocus >= 0 && myUn[IsoEngine::unFocus].Job != jNone) { int jobFocus = myUn[IsoEngine::unFocus].Job; TJobProgressData jobProgressData; ClientTools::server(sGetJobProgress, ClientTools::me, myUn[IsoEngine::unFocus].Loc, jobProgressData); makeBlue(m_panel, m_xTerrain - 72, 148 - 17, 144, 31); paintRelativeProgressBar(canvas, 3, m_xTerrain - 68, 148 + 3, 63, jobProgressData[jobFocus].Done, jobProgressData[jobFocus].NextTurnPlus, jobProgressData[jobFocus].Required, true, texture); QString s = QStringLiteral("%1/%2") .arg(movementToString(jobProgressData[jobFocus].Done)) .arg(movementToString(jobProgressData[jobFocus].Required)); risedTextOut(canvas, m_xTerrain + 6, 148 - 3, s); const std::uint32_t focusTile = myMap[myUn[IsoEngine::unFocus].Loc]; if (jobFocus == jRoad && (focusTile & fRiver)) jobFocus = nJob + 0; else if (jobFocus == jRR && (focusTile & fRiver)) jobFocus = nJob + 1; else if (jobFocus == jClear) { if ((focusTile & fTerrain) == fForest) jobFocus = nJob + 2; else if ((focusTile & fTerrain) == fDesert) jobFocus = nJob + 3; else jobFocus = nJob + 4; } s = phrases.lookup(QStringLiteral("JOBRESULT"), jobFocus); risedTextOut(canvas, m_xTerrain - biColorTextWidth(canvas, s) / 2, 148 - 19, s); } QString s; const std::uint32_t tile = myMap[m_troopLoc]; if ((tile & (fTerrain | fSpecial)) == (fGrass | fSpecial1)) s = terrainPhrase(fGrass + 12); else if (tile & fDeadLands) s = terrainPhrase(3 * 12); else if ((tile & fTerrain) == fForest && IsoEngine::isJungle(m_troopLoc / ClientTools::g.lx)) s = terrainPhrase(fJungle); else s = terrainPhrase(static_cast(tile & fTerrain)); risedTextOut(canvas, m_xTerrain - biColorTextWidth(canvas, s) / 2, 99, s); } void MainScreen::paintPanelButtons() { Dpi::Canvas &canvas = m_panel.canvas(); const Texture &texture = *MainTexture; const int yOffset = PanelHeight - height(); const auto paintButtonB = [&](ButtonB *button) { if (!button->isVisible()) return; dump(m_panel, *HGrSystem, button->x(), button->y() + yOffset, 25, 25, 169, 243); sprite(canvas, *HGrSystem, button->x(), button->y() + yOffset, 25, 25, 1 + 26 * button->buttonIndex(), 337); rframe(canvas, button->x() - 1, button->y() + yOffset - 1, button->x() + button->width(), button->y() + button->height() + yOffset, texture.colorBevelShade, texture.colorBevelLight); }; paintButtonB(m_unitBtn); paintButtonB(m_unitInfoBtn); paintButtonB(m_terrainBtn); for (ButtonB *button : m_movieSpeedBtn) paintButtonB(button); if (clientMode != cEditMap) { for (ButtonC *button : { m_mapBtn0, m_mapBtn1, m_mapBtn4, m_mapBtn5, m_mapBtn6 }) { if (!button->isVisible()) continue; dump(m_panel, *HGrSystem, button->x(), button->y() + yOffset, 12, 12, 169, 178 + 13 * button->buttonIndex()); rframe(canvas, button->x() - 1, button->y() + yOffset - 1, button->x() + button->width(), button->y() + button->height() + yOffset, texture.colorBevelShade, texture.colorBevelLight); } } } void MainScreen::paintTopBar() { Dpi::Canvas &canvas = m_topBar.canvas(); const Texture &texture = *MainTexture; const TPlayerContext &ro = *ClientTools::myRO; const int cw = width(); const int xTreasurySection = cw / 2 - 172; const int xResearchSection = cw / 2; // ClientWidth div 2 + 68 = maximum to right fillLarge(canvas, 0, 0, cw, TopBarHeight - 3, cw / 2); canvas.brush().setStyle(Qt::NoBrush); canvas.pen().setColor(Qt::black); canvas.moveTo(0, TopBarHeight - 1); canvas.lineTo(cw, TopBarHeight - 1); canvas.pen().setColor(texture.colorBevelShade); canvas.moveTo(0, TopBarHeight - 2); canvas.lineTo(cw, TopBarHeight - 2); canvas.moveTo(0, TopBarHeight - 3); canvas.lineTo(cw, TopBarHeight - 3); frame(canvas, 40, -1, xTreasurySection - 1, TopBarHeight - 7, texture.colorBevelShade, texture.colorBevelLight); frame(canvas, xResearchSection + 332, -1, cw, TopBarHeight - 7, texture.colorBevelShade, texture.colorBevelLight); canvas.end(); // the image operations below work on the pixels directly const auto templateOp = [&](const char *itemName, int x, int y, int color1, int color2) { if (const GraphicSetItem *item = Templates ? Templates->searchByName(QLatin1String(itemName)) : nullptr) imageOpBCC(m_topBar, Templates->data, x, y, item->left, item->top, item->width, item->height, color1, color2); }; if (gameMode != cMovie) templateOp("MenuLogo", 2, 1, 0xBFBF20, 0x4040DF); if (ro.nCity > 0) { int trueMoney = ro.Money; int trueResearch = ro.Research; if (supervising) { // normalize values from after-turn state trueMoney = std::max(0, trueMoney - taxSum); trueResearch = std::max(0, trueResearch - scienceSum); } // treasury section templateOp("Treasury", xTreasurySection + 8, 1, 0x40A040, 0x4030C0); loweredTextOut(canvas, -1, texture, xTreasurySection + 48, 0, QStringLiteral("%1%c").arg(trueMoney)); if (ro.Government != gAnarchy) { templateOp("Change", xTreasurySection + 48, 22, 0x0000C0, 0x0080C0); const QString s = formatPhrase( taxSum >= 0 ? QStringLiteral("MONEYGAINPOS") : QStringLiteral("MONEYGAINNEG"), { QString::number(taxSum) }); loweredTextOut(canvas, -1, texture, xTreasurySection + 48 + 15, 18, s); } // research section templateOp("Research", xResearchSection + 8, 1, 0xFF0000, 0x00FFE0); int costFactor = 0; if (myData->farTech != adNexus) { if (ro.ResearchTech < 0) costFactor = 2; else if (ro.ResearchTech == adMilitary || ro.Tech[ro.ResearchTech] == tsSeen) costFactor = 1; else if (IsFutureTech(ro.ResearchTech)) costFactor = ro.Government == gFuture ? 4 : 8; else costFactor = 2; int techCost = 0; ClientTools::server(sGetTechCost, ClientTools::me, 0, &techCost); costFactor *= 22; // length of progress bar paintRelativeProgressBar(canvas, 2, xResearchSection + 48 + 1, 26, costFactor, trueResearch, scienceSum, techCost, true, texture); QString s; if (ro.ResearchTech < 0) { s = phrases[QStringLiteral("SCIENCE")]; } else if (ro.ResearchTech == adMilitary) { s = phrases[QStringLiteral("INITUNIT")]; } else { s = phrases.lookup(QStringLiteral("ADVANCES"), ro.ResearchTech); if (IsFutureTech(ro.ResearchTech)) s += QStringLiteral(" %1").arg(ro.Tech[ro.ResearchTech] >= 1 ? ro.Tech[ro.ResearchTech] + 1 : 1); } loweredTextOut(canvas, -1, texture, xResearchSection + 48, 0, s); } if (myData->farTech != adNexus && scienceSum > 0) { templateOp("Change", xResearchSection + 48 + costFactor + 11, 22, 0x0000C0, 0x0080C0); loweredTextOut(canvas, -1, texture, xResearchSection + 48 + costFactor + 26, 18, formatPhrase(QStringLiteral("TECHGAIN"), { QString::number(scienceSum) })); } } if (clientMode != cEditMap) { canvas.font().assign(UniFont[static_cast(FontType::Caption)]); const QString s = turnToString(ro.Turn); risedTextOut(canvas, 40 + (xTreasurySection - 40 - biColorTextWidth(canvas, s)) / 2, 6, s); canvas.font().assign(UniFont[static_cast(FontType::Normal)]); } canvas.end(); invalidateRect(0, 0, cw, TopBarHeight); } void MainScreen::paintZoomedTile(Dpi::Bitmap &dst, int x, int y, int loc) { IsoEngine::IsoMap &map = *m_noMapPanel; const int xxt = map.xxt; const int yyt = map.yyt; Dpi::Canvas &canvas = dst.canvas(); const auto terrainSprite = [&](int xDst, int yDst, int xSrc, int ySrc) { sprite(canvas, *map.hGrTerrain, x + xDst, y + yDst, xxt * 2, yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1)); }; const auto terrainSprite4 = [&](int xSrc, int ySrc) { sprite(canvas, *map.hGrTerrain, x + xxt, y + yyt + 2, xxt * 2, yyt * 2 - 2, 1 + xSrc * (xxt * 2 + 1), 3 + yyt + ySrc * (yyt * 3 + 1)); sprite(canvas, *map.hGrTerrain, x + 4, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 5 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); sprite(canvas, *map.hGrTerrain, x + xxt * 2, y + 2 * yyt, xxt * 2 - 4, yyt * 2, 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); sprite(canvas, *map.hGrTerrain, x + xxt, y + yyt * 3, xxt * 2, yyt * 2 - 2, 1 + xSrc * (xxt * 2 + 1), 1 + yyt + ySrc * (yyt * 3 + 1)); }; std::uint32_t tile = ClientTools::myMap[loc]; if (tile & fCity) { tile |= ClientTools::myRO->Tech[adRailroad] >= tsApplicable ? static_cast(fRR) : static_cast(fRoad); bool supermarket = false; if (tile & fOwned) { int cix = ClientTools::myRO->nCity - 1; while (cix >= 0 && ClientTools::myCity[cix].Loc != loc) --cix; Q_ASSERT(cix >= 0); supermarket = cix >= 0 && ClientTools::myCity[cix].Built[imSupermarket] > 0; } tile |= supermarket ? static_cast(tiFarm) : static_cast(tiIrrigation); } const std::uint32_t terrain = tile & fTerrain; if (terrain >= fForest) terrainSprite4(2, 2); else terrainSprite4(static_cast(terrain), 0); if (terrain >= fForest) { const int ySrc = terrain == fForest && IsoEngine::isJungle(loc / ClientTools::g.lx) ? 18 : 3 + 2 * static_cast(terrain - fForest); terrainSprite(xxt, 0, 6, ySrc); terrainSprite(0, yyt, 3, ySrc); terrainSprite(xxt * 2, yyt, 4, ySrc + 1); terrainSprite(xxt, yyt * 2, 1, ySrc + 1); } // irrigation switch (tile & fTerImp) { case tiIrrigation: terrainSprite(xxt, 0, 0, 12); terrainSprite(xxt * 2, yyt, 0, 12); break; case tiFarm: terrainSprite(xxt, 0, 1, 12); terrainSprite(xxt * 2, yyt, 1, 12); break; default: break; } // river/canal/road/railroad if (tile & fRiver) { terrainSprite(0, yyt, 2, 14); terrainSprite(xxt, yyt * 2, 2, 14); } if (tile & fCanal) { terrainSprite(xxt, 0, 7, 11); terrainSprite(xxt, 0, 3, 11); terrainSprite(xxt * 2, yyt, 7, 11); terrainSprite(xxt * 2, yyt, 3, 11); } if (tile & fRR) { terrainSprite(xxt * 2, yyt, 1, 10); terrainSprite(xxt * 2, yyt, 5, 10); terrainSprite(xxt, yyt * 2, 1, 10); terrainSprite(xxt, yyt * 2, 5, 10); } else if (tile & fRoad) { terrainSprite(xxt * 2, yyt, 8, 9); terrainSprite(xxt * 2, yyt, 5, 9); terrainSprite(xxt, yyt * 2, 1, 9); terrainSprite(xxt, yyt * 2, 5, 9); } if (tile & fPoll) terrainSprite(xxt, yyt * 2, 6, 12); // special const int special = static_cast((tile & fSpecial) >> 5); if ((tile & (fTerrain | fSpecial)) == (fGrass | fSpecial1)) { terrainSprite4(2, 1); } else if (tile & fSpecial) { if (terrain < fForest) terrainSprite(0, yyt, static_cast(terrain), special); else if (terrain == fForest && IsoEngine::isJungle(loc / ClientTools::g.lx)) terrainSprite(0, yyt, 8, 17 + special); else terrainSprite(0, yyt, 8, 2 + static_cast(terrain - fForest) * 2 + special); } else if (tile & fDeadLands) { terrainSprite4(6, 2); terrainSprite(xxt, yyt, 8, 12 + static_cast((tile >> 25) & 3)); } // other improvements switch (tile & fTerImp) { case tiMine: terrainSprite(xxt, 0, 2, 12); break; case tiFort: terrainSprite(xxt, 0, 7, 12); terrainSprite(xxt, 0, 3, 12); break; case tiBase: terrainSprite(xxt, 0, 4, 12); break; default: break; } } } // namespace Term } // namespace Cevo