void InitTextColor(u8 layer, u8 palette, u16 front, u16 back) { consoleInitTextMine(layer, palette, &fontback); setPaletteColor(palette * 0x10, RGB5(31, 0, 31)); setPaletteColor(palette * 0x10 + 1, front); setPaletteColor(palette * 0x10 + 2, back); }
void Cutscene::updatePalette(int palType, int colorsCount, const uint8_t *p) { if (colorsCount != 0) { if (palType == 0) { for (int i = 0; i < colorsCount; ++i) { setPaletteColor(i, p[2], p[1], p[0]); p += 3; } } else { for (int i = 0; i < colorsCount; ++i) { setPaletteColor(p[0], p[3], p[2], p[1]); p += 4; } } } _render->setPalette(_palette, 256, false); }
void PointStyle::loadXml(QXmlStreamReader &reader) { LOG4CPP_INFO_S ((*mainCat)) << "PointStyle::loadXml"; QXmlStreamAttributes attributes = reader.attributes(); if (attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS) && attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH) && attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR) && attributes.hasAttribute(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE)) { setRadius (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_RADIUS).toInt()); setLineWidth (attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_LINE_WIDTH).toInt()); setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_COLOR).toInt()); setShape ((PointShape) attributes.value(DOCUMENT_SERIALIZE_POINT_STYLE_SHAPE).toInt()); // Read until end of this subtree while ((reader.tokenType() != QXmlStreamReader::EndElement) || (reader.name() != DOCUMENT_SERIALIZE_POINT_STYLE)){ loadNextFromReader(reader); } } else { reader.raiseError ("Cannot read point style data"); } }
KMagSelWin::KMagSelWin ( QWidget * parent, Qt::WFlags ) : QWidget(parent) //Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WType_TopLevel | Qt::WX11BypassWM) { setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(QBitmap::fromData( QSize(8, 8), line_bits))); setPalette(p); titleBar = new KMagSelWinCorner (this); titleBar->setObjectName( QLatin1String("titlebar" )); setPaletteColor(titleBar, QPalette::Background, getTitleColor()); setPaletteColor(titleBar, QPalette::Foreground, getTextColor()); titleBar->setText(i18n("Selection Window")+QLatin1String( " - " )+i18n("KMagnifier")); connect (titleBar, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (titleBar, SIGNAL (resized(QPoint)), this, SLOT (titleMoved(QPoint))); topLeftCorner = new KMagSelWinCorner (this); topLeftCorner->setObjectName( QLatin1String("topleft" )); topLeftCorner->setCursor (Qt::SizeFDiagCursor); setPaletteColor(topLeftCorner, QPalette::Background, getTitleBtnColor()); connect (topLeftCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (topLeftCorner, SIGNAL (resized(QPoint)), this, SLOT (topLeftResized(QPoint))); topRightCorner = new KMagSelWinCorner (this); topRightCorner->setObjectName( QLatin1String("topright" )); topRightCorner->setCursor (Qt::SizeBDiagCursor); setPaletteColor(topRightCorner, QPalette::Background, getTitleBtnColor ()); connect (topRightCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (topRightCorner, SIGNAL (resized(QPoint)), this, SLOT (topRightResized(QPoint))); bottomLeftCorner = new KMagSelWinCorner (this); bottomLeftCorner->setObjectName( QLatin1String("bottomleft" )); bottomLeftCorner->setCursor (Qt::SizeBDiagCursor); setPaletteColor(bottomLeftCorner, QPalette::Background, getTitleBtnColor()); connect (bottomLeftCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (bottomLeftCorner, SIGNAL (resized(QPoint)), this, SLOT (bottomLeftResized(QPoint))); bottomRightCorner = new KMagSelWinCorner (this); bottomRightCorner->setObjectName( QLatin1String("bottomright" )); bottomRightCorner->setCursor (Qt::SizeFDiagCursor); setPaletteColor(bottomRightCorner, QPalette::Background, getTitleBtnColor ()); connect (bottomRightCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (bottomRightCorner, SIGNAL (resized(QPoint)), this, SLOT (bottomRightResized(QPoint))); }
void LineStyle::loadXml(QXmlStreamReader &reader) { LOG4CPP_INFO_S ((*mainCat)) << "LineStyle::loadXml"; QXmlStreamAttributes attributes = reader.attributes(); if (attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH) && attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR) && attributes.hasAttribute(DOCUMENT_SERIALIZE_LINE_STYLE_CONNECT_AS)) { setWidth (attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_WIDTH).toInt()); setPaletteColor ((ColorPalette) attributes.value(DOCUMENT_SERIALIZE_LINE_STYLE_COLOR).toInt()); setCurveConnectAs ((CurveConnectAs) attributes.value(DOCUMENT_SERIALIZE_COLOR_FILTER_INTENSITY_HIGH).toInt()); // Read until end of this subtree while ((reader.tokenType() != QXmlStreamReader::EndElement) || (reader.name() != DOCUMENT_SERIALIZE_LINE_STYLE)){ loadNextFromReader(reader); } } else { reader.raiseError ("Cannot read line style data"); } }
void IgorEngine::handleOptionsMenu() { hideCursor(); memcpy(_paletteBuffer, _currentPalette, 768); memset(_screenVGA + 144 * 320, 0, 11 * 320); _system->copyRectToScreen(_screenVGA, 320, 0, 0, 320, 200); for (int m = 3; m < 22; m += 3) { for (int i = 1 * 3; i <= 245 * 3; ++i) { if (_paletteBuffer[i] >= m) { _currentPalette[i] = MAX<int>(_paletteBuffer[i] - m, _currentPalette[i] - 3); } } setPaletteRange(1, 245); _system->updateScreen(); _system->delayMillis(1000 / 60); } setPaletteColor(255, 35, 35, 23); memcpy(_screenTextLayer, _screenVGA + 4800, 36800); uint8 *optionsMenu = loadData(IMG_OptionsMenu); for (int i = 0; i < 36800; ++i) { if (optionsMenu[i]) { _screenTextLayer[i] = optionsMenu[i]; } } free(optionsMenu); uint8 *optionsButton = loadData(IMG_OptionsButton); drawButtonsBar(_screenTextLayer, optionsButton); free(optionsButton); const int yPosCaption = 18 - 15; for (int i = 0; i < 5; ++i) { drawString(_screenTextLayer, pages[i].captions[0], pages[i].xPos[0], yPosCaption, 0xF6, -1, 0); } redrawButton(_screenTextLayer, 0, true); uint8 buttonsBarBackup[320 * 12]; int currentPage = 0; bool menuLoop = true; bool focusOnPage = false; while (menuLoop && !_eventQuitGame && _currentPart != kInvalidPart) { int previousPage = currentPage; Common::Event ev; while (_eventMan->pollEvent(ev)) { switch (ev.type) { case Common::EVENT_QUIT: _currentPart = kInvalidPart; _eventQuitGame = true; break; case Common::EVENT_KEYDOWN: if (focusOnPage) { if ((this->*pages[currentPage].handleKeyDownProc)(ev.kbd.keycode)) { memcpy(_screenTextLayer + 3 * 320, buttonsBarBackup, 320 * 12); for (int y = 22; y <= 110; ++y) { memset(_screenTextLayer + y * 320 + 43 + 4, 0xF8, 226); } focusOnPage = false; } } else { switch (ev.kbd.keycode) { case Common::KEYCODE_ESCAPE: menuLoop = false; break; case Common::KEYCODE_RETURN: if (currentPage == kPagePlay) { menuLoop = false; } else { memcpy(buttonsBarBackup, _screenTextLayer + 3 * 320, 320 * 12); for (int y = 0; y <= 11; ++y) { memset(_screenTextLayer + (y + 3) * 320 + 44, 0xF8, 232); } drawString(_screenTextLayer, pages[currentPage].captions[1], pages[currentPage].xPos[1], yPosCaption, 0xFB, -1, 0); (this->*pages[currentPage].paintProc)(); focusOnPage = true; } break; case Common::KEYCODE_LEFT: --currentPage; if (currentPage < 0) { currentPage = 0; } break; case Common::KEYCODE_RIGHT: ++currentPage; if (currentPage > 4) { currentPage = 4; } break; default: break; } } break; default: break; } } if (previousPage != currentPage) { redrawButton(_screenTextLayer, previousPage, false); redrawButton(_screenTextLayer, currentPage, true); } _system->delayMillis(10); _system->copyRectToScreen(_screenTextLayer, 320, 0, 15, 320, 115); _system->updateScreen(); } for (int m = 21; m >= 3; m -= 3) { for (int i = 1 * 3; i <= 245 * 3; ++i) { if (_paletteBuffer[i] >= m) { _currentPalette[i] = MIN<int>(_paletteBuffer[i], _currentPalette[i] + 3); } } setPaletteRange(1, 245); _system->updateScreen(); _system->delayMillis(1000 / 60); } showCursor(); }
static std::shared_ptr<AndroidStyle> loadAndroidStyle(QPalette *defaultPalette) { std::shared_ptr<AndroidStyle> style(new AndroidStyle); style->m_styleData = AndroidStyle::loadStyleData(); if (style->m_styleData.isEmpty()) return std::shared_ptr<AndroidStyle>(); for (QJsonObject::const_iterator objectIterator = style->m_styleData.constBegin(); objectIterator != style->m_styleData.constEnd(); ++objectIterator) { QString key = objectIterator.key(); QJsonValue value = objectIterator.value(); if (!value.isObject()) { qWarning("Style.json structure is unrecognized."); continue; } QJsonObject item = value.toObject(); QJsonObject::const_iterator attributeIterator = item.find(QLatin1String("qtClass")); QByteArray qtClassName; if (attributeIterator != item.constEnd()) { // The item has palette and font information for a specific Qt Class (e.g. QWidget, QPushButton, etc.) qtClassName = attributeIterator.value().toString().toLatin1(); } const int ft = fontType(key); if (ft > -1 || !qtClassName.isEmpty()) { // Extract font information QFont font; // Font size (in pixels) attributeIterator = item.find(QLatin1String("TextAppearance_textSize")); if (attributeIterator != item.constEnd()) font.setPixelSize(int(attributeIterator.value().toDouble())); // Font style attributeIterator = item.find(QLatin1String("TextAppearance_textStyle")); if (attributeIterator != item.constEnd()) { const int style = int(attributeIterator.value().toDouble()); font.setBold(style & textStyle_bold); font.setItalic(style & textStyle_italic); } // Font typeface attributeIterator = item.find(QLatin1String("TextAppearance_typeface")); if (attributeIterator != item.constEnd()) { QFont::StyleHint styleHint = QFont::AnyStyle; switch (int(attributeIterator.value().toDouble())) { case typeface_sans: styleHint = QFont::SansSerif; break; case typeface_serif: styleHint = QFont::Serif; break; case typeface_monospace: styleHint = QFont::Monospace; break; } font.setStyleHint(styleHint, QFont::PreferMatch); } if (!qtClassName.isEmpty()) style->m_QWidgetsFonts.insert(qtClassName, font); if (ft > -1) { style->m_fonts.insert(ft, font); if (ft == QPlatformTheme::SystemFont) QGuiApplication::setFont(font); } // Extract font information } const int pt = paletteType(key); if (pt > -1 || !qtClassName.isEmpty()) { // Extract palette information QPalette palette = *defaultPalette; attributeIterator = item.find(QLatin1String("defaultTextColorPrimary")); if (attributeIterator != item.constEnd()) palette.setColor(QPalette::WindowText, QRgb(int(attributeIterator.value().toDouble()))); attributeIterator = item.find(QLatin1String("defaultBackgroundColor")); if (attributeIterator != item.constEnd()) palette.setColor(QPalette::Background, QRgb(int(attributeIterator.value().toDouble()))); attributeIterator = item.find(QLatin1String("TextAppearance_textColor")); if (attributeIterator != item.constEnd()) setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::WindowText); attributeIterator = item.find(QLatin1String("TextAppearance_textColorLink")); if (attributeIterator != item.constEnd()) setPaletteColor(attributeIterator.value().toObject().toVariantMap(), palette, QPalette::Link); attributeIterator = item.find(QLatin1String("TextAppearance_textColorHighlight")); if (attributeIterator != item.constEnd()) palette.setColor(QPalette::Highlight, QRgb(int(attributeIterator.value().toDouble()))); if (pt == QPlatformTheme::SystemPalette) *defaultPalette = style->m_standardPalette = palette; if (pt > -1) style->m_palettes.insert(pt, palette); // Extract palette information } } return style; }
bool Magic3D::TGA::decode(DataBuffer* file) { bool result = false; if (file) { if (file->read(&header, sizeof(header)) == 0) { Log::log(eLOG_FAILURE, "Not a TGA"); } bool compressed; switch (header.type){ case TGA_Map: case TGA_RGB: case TGA_Mono: compressed = false; break; case TGA_RLEMap: case TGA_RLERGB: case TGA_RLEMono: compressed = true; break; default: { Log::log(eLOG_FAILURE, "Unknown TGA image type"); return false; } } if (header.width == 0 || header.height == 0 || header.bpp == 0 || header.cmapLength > 256) { Log::log(eLOG_FAILURE, "bad TGA header"); return false; } if (header.bpp != 8 && header.bpp != 15 && header.bpp != 16 && header.bpp != 24 && header.bpp != 32) { Log::log(eLOG_FAILURE, "bad TGA header"); return false; } if (header.idLength > 0) { file->seeki(header.idLength, SEEK_CUR); } create(header.width, header.height, header.bpp); if (isValid()) { if (header.cmapType != 0) { ColorRGBpack pal[256]; file->read(pal, header.cmapLength * sizeof(ColorRGBpack)); for (int i = 0; i < header.cmapLength; i++) { setPaletteColor((byte)i, pal[i].r, pal[i].g, pal[i].b); } } if (header.type == TGA_Mono || header.type == TGA_RLEMono) { setGrayPalette(); } bool xReversed = ((header.desc & 16) == 16); bool yReversed = ((header.desc & 32) == 32); byte* dest; int itY = 0; for (int y = 0; y < header.height; y++){ if (file && !file->eof()) { if (yReversed) { itY = header.height - y - 1; } else { itY = y; } if ((itY >= 0) && (itY <= (int)header.height)) { dest = (byte*)dib + effWidth * itY; if (compressed) { expandCompressedLine(dest, file, header.width); } else { expandUncompressedLine(dest, file, header.width); } } } } if (xReversed) { mirror(); } } } return result; }
void AddTextColor(u8 palette, u16 front, u16 back) { setPaletteColor(palette * 0x10, RGB5(31, 0, 31)); setPaletteColor(palette * 0x10 + 1, front); setPaletteColor(palette * 0x10 + 2, back); }