UBZoomPalette::UBZoomPalette(QWidget* parent) : UBFloatingPalette(Qt::BottomRightCorner, parent) , mIsExpanded(1) { mBoardController = UBApplication::boardController; QLayout* layout = new QVBoxLayout(this); mCurrentZoomButton = new QPushButton(parent); mCurrentZoomButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); mCurrentZoomButton->setFocusPolicy(Qt::NoFocus); connect(mCurrentZoomButton, SIGNAL(clicked(bool)), this, SLOT(showHideExtraButton())); connect(mBoardController, SIGNAL(zoomChanged(qreal)), this, SLOT(refreshPalette())); connect(mBoardController, SIGNAL(activeSceneChanged()), this, SLOT(refreshPalette())); mHundredButton = new QPushButton(parent); mHundredButton->setStyleSheet(QString("QPushButton { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); mHundredButton->setFocusPolicy(Qt::NoFocus); mHundredButton->setIcon(QIcon(":/images/stylusPalette/restoreZoom.png")); mHundredButton->setIconSize(QSize(42,42)); connect(mHundredButton, SIGNAL(clicked(bool)), this, SLOT(goHundred())); layout->setContentsMargins(radius() + 15, 4, radius() + 15, 4); layout->addWidget(mHundredButton); layout->addWidget(mCurrentZoomButton); hide(); refreshPalette(); }
/** * Copy part of backup palette to active palette and transform * @param first First color to transform * @param last Last color to transform * @param r Red channel transformation * @param g Green channel transformation * @param b Blue channel transformation */ void FWRenderer::transformPalette(int first, int last, int r, int g, int b) { if (!_activePal.isValid() || _activePal.empty()) { _activePal = Cine::Palette(kLowPalFormat, kLowPalNumColors); } _backupPal.saturatedAddColor(_activePal, first, last, r, g, b); refreshPalette(); }
/** * Copy part of backup palette to active palette and transform * @param first First color to transform * @param last Last color to transform * @param r Red channel transformation * @param g Green channel transformation * @param b Blue channel transformation */ void OSRenderer::transformPalette(int first, int last, int r, int g, int b) { palBg *bg = _bgShift ? &_bgTable[_scrollBg] : &_bgTable[_currentBg]; // Initialize active palette to current background's palette format and size if they differ if (_activePal.colorFormat() != bg->pal.colorFormat() || _activePal.colorCount() != bg->pal.colorCount()) { _activePal = Cine::Palette(bg->pal.colorFormat(), bg->pal.colorCount()); } bg->pal.saturatedAddColor(_activePal, first, last, r, g, b, kLowPalFormat); refreshPalette(); }
/** * Fade to black * \bug Operation Stealth sometimes seems to fade to black using * transformPalette resulting in double fadeout */ void FWRenderer::fadeToBlack() { assert(_activePal.isValid() && !_activePal.empty()); for (int i = 0; i < 8; i++) { // Fade out the whole palette by 1/7th // (Operation Stealth used 36 / 252, which is 1 / 7. Future Wars used 1 / 7 directly). _activePal.saturatedAddNormalizedGray(_activePal, 0, _activePal.colorCount() - 1, -1, 7); refreshPalette(); g_system->updateScreen(); g_system->delayMillis(50); } }
/** * Draw another frame */ void FWRenderer::drawFrame() { drawBackground(); drawOverlays(); if (!_cmd.empty()) { drawCommand(); } if (_changePal) { refreshPalette(); } const int menus = _menuStack.size(); for (int i = 0; i < menus; ++i) _menuStack[i]->drawMenu(*this, (i == menus - 1)); blit(); }
/** * Rotate active palette * @param a First color to rotate * @param b Last color to rotate * @param c Possibly rotation step, must be 0 or 1 at the moment */ void FWRenderer::rotatePalette(int a, int b, int c) { _activePal.rotateRight(a, b, c); refreshPalette(); }