void GameScene::loadTheme() { if (!m_theme->load(Settings::self()->theme())) { return; } if (!m_renderer->load(m_theme->graphics())) { return; } //Update elementIDs, theme properties updateSvgIds(); updateThemeProperties(); update(0, 0, width(), height()); // Update the theme config: if the default theme is selected, no theme entry is written -> the theme selector does not select the theme Settings::self()->config()->group("General").writeEntry("Theme", Settings::self()->theme()); }
ScrollbarThemeGtk::ScrollbarThemeGtk() { updateThemeProperties(); g_signal_connect(static_cast<RenderThemeGtk*>(RenderTheme::defaultTheme().get())->gtkHScrollbar(), "style-set", G_CALLBACK(gtkStyleSetCallback), this); }
void ScrollbarThemeGtk::themeChanged() { gtk_style_context_invalidate(gtkScrollbarStyleContext()); updateThemeProperties(); }
ScrollbarThemeGtk::ScrollbarThemeGtk() { updateThemeProperties(); }
GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem(0) { connect(p_game, SIGNAL(levelStarted(bool)), SLOT(intro(bool))); connect(p_game, SIGNAL(gameStarted()), this, SLOT(start())); connect(p_game, SIGNAL(pauseChanged(bool,bool)), this, SLOT(setPaused(bool,bool))); connect(p_game, SIGNAL(elementEaten(qreal,qreal)), this, SLOT(hideElement(qreal,qreal))); connect(p_game, SIGNAL(bonusOn()), this, SLOT(displayBonus())); connect(p_game, SIGNAL(bonusOff()), this, SLOT(hideBonus())); // Connection between Game and GameScene for the display of won points when a bonus or a ghost is eaten connect(p_game, SIGNAL(pointsToDisplay(long,qreal,qreal)), this, SLOT(displayPoints(long,qreal,qreal))); // Create the theme instance m_theme = new KGameTheme(); // Load the SVG file m_renderer = new QSvgRenderer(); loadTheme(); // Create the MazeItem m_mazeItem = new MazeItem(); // Give the maze the shared renderer to avoid loading the whole SVG file again m_mazeItem->setSharedRenderer(m_renderer); // Set the element Id to the right value m_mazeItem->setElementId(QLatin1Literal("maze")); m_mazeItem->setZValue(-2); // Create the KapmanItem m_kapmanItem = new KapmanItem(p_game->getKapman()); m_kapmanItem->setSharedRenderer(m_renderer); m_kapmanItem->setElementId(QLatin1Literal("kapman_0")); // Corrects the position of the KapmanItem m_kapmanItem->update(p_game->getKapman()->getX(), p_game->getKapman()->getY()); m_kapmanItem->setZValue(2); // Stops the Kapman animation m_kapmanItem->stopAnim(); // Create the GhostItems for (int i = 0; i < p_game->getGhosts().size(); ++i) { GhostItem *ghost = new GhostItem(p_game->getGhosts()[i]); ghost->setSharedRenderer(m_renderer); ghost->setElementId(p_game->getGhosts()[i]->getImageId()); ghost->update(p_game->getGhosts()[i]->getX(), p_game->getGhosts()[i]->getY()); // At the beginning, the ghosts are above the kapman because they eat him ghost->setZValue(3); m_ghostItems.append(ghost); } // Create the Pill and Energizer items m_elementItems = new ElementItem **[m_game->getMaze()->getNbRows()]; for (int i = 0; i < m_game->getMaze()->getNbRows(); ++i) { m_elementItems[i] = new ElementItem*[m_game->getMaze()->getNbColumns()]; for (int j = 0; j < m_game->getMaze()->getNbColumns(); ++j) { if (m_game->getMaze()->getCell(i, j).getElement() != NULL) { // Create the element and set the image ElementItem *element = new ElementItem(m_game->getMaze()->getCell(i, j).getElement()); element->setSharedRenderer(m_renderer); element->setElementId(m_game->getMaze()->getCell(i, j).getElement()->getImageId()); element->update(m_game->getMaze()->getCell(i, j).getElement()->getX(), m_game->getMaze()->getCell(i, j).getElement()->getY()); m_elementItems[i][j] = element; } else { m_elementItems[i][j] = NULL; } } } // Create the Bonus item m_bonusItem = new ElementItem(m_game->getBonus()); m_bonusItem->setSharedRenderer(m_renderer); m_bonusItem->setElementId(QLatin1Literal("bonus1")); // All elements are created, update theme properties updateSvgIds(); updateThemeProperties(); // Create the introduction labels m_introLabel = new QGraphicsTextItem(i18n("GET READY!!!")); m_introLabel->setFont(QFont(QLatin1Literal("Helvetica"), 25, QFont::Bold, false)); m_introLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00"))); m_introLabel->setZValue(4); m_introLabel2 = new QGraphicsTextItem(i18n("Press any arrow key to start")); m_introLabel2->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Bold, false)); m_introLabel2->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00"))); m_introLabel2->setZValue(4); // Create the new level label m_newLevelLabel = new QGraphicsTextItem(); m_newLevelLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false)); m_newLevelLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00"))); m_newLevelLabel->setZValue(4); // Create the pause label m_pauseLabel = new QGraphicsTextItem(i18n("PAUSED")); m_pauseLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false)); m_pauseLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00"))); m_pauseLabel->setZValue(4); // Display the MazeItem addItem(m_mazeItem); // Display the KapmanItem addItem(m_kapmanItem); // Display each GhostItem for (int i = 0; i < m_ghostItems.size(); ++i) { addItem(m_ghostItems[i]); } // Display each Pill and Energizer item and introduction labels intro(true); }