void SortWidget::readSortPath( const QString &sortPath ) { trimToLevel(); QStringList levels = sortPath.split( '-' ); foreach( const QString &level, levels ) { QStringList levelParts = level.split( '_' ); /* * Check whether the configuration is valid. If indexOf * returns -1, the entry is corrupted. We can't use columnForName * here, as it will do a static_cast, which is UB when indexOf is -1 * as there's no corresponding enum value * (C++ standard 5.2.9 Static cast [expr.static.cast] paragraph 7) */ if( levelParts.count() > 2 || ( Playlist::PlaylistColumnInfos::internalNames(). indexOf( levelParts.value(0) ) == -1) ) warning() << "Playlist sorting load error: Invalid sort level " << level; else if( levelParts.value( 1 ) == QString( "asc" ) ) addLevel( levelParts.value( 0 ), Qt::AscendingOrder ); else if( levelParts.value( 1 ) == QString( "des" ) ) addLevel( levelParts.value( 0 ), Qt::DescendingOrder ); else warning() << "Playlist sorting load error: Invalid sort order for level " << level; }
void Tiled2DGraphics::addLevelsSuitableForZoomify(float tile_width, float tile_height) { float w(getWidth()), h(getHeight()); float zoom = 1.0f; while ((w > tile_width) || (h > tile_height)) { addLevel(new Level(zoom, std::ceil(w/tile_width), std::ceil(h/tile_height))); w *= 0.5; h *= 0.5; zoom *= 0.5; } // so nun letzten level hinzufügen addLevel(new Level(w/getWidth(), 1, 1)); }
void ComponentSkill::onMessage(const Message& message) { Message newMessage; switch (message.type) { case Message::TRY_BUY: canBuy(message.value, message.gameObject); break; case Message::ADD_EXPERIENCE: jade += message.value*2/3; newMessage.type = Message::JADE_CHANGED; newMessage.value = jade; parent->broadcastMessage(newMessage); break; case Message::USE_SKILL: useSkill(message.value); break; case Message::LEVEL_CHANGED: addLevel(message.value); break; case Message::DEATH: down = true; for(size_t i = 0;i < skills.size();i++) { skills[i]->deselect(); } break; case Message::REPAIRED: down = false; break; } }
void SortWidget::onItemSiblingClicked( QString internalColumnName ) { const int level = m_ribbon->indexOf( qobject_cast< QWidget * >( sender()->parent() ) ); trimToLevel( level - 1 ); addLevel( internalColumnName ); }
void NaviHeightmap::update(const vector<IBox> &walkable, const vector<IBox> &blockers) { m_level_count = 0; m_data.clear(); PodArray<IBox> bboxes(walkable.size()); for(int n = 0; n < bboxes.size(); n++) { IBox bbox = walkable[n]; bboxes[n] = { vmax(bbox.min(), int3(0, 0, 0)), vmin(bbox.max(), int3(m_size.x, 255, m_size.y))}; } std::sort(bboxes.data(), bboxes.end(), [](const IBox &a, const IBox &b) { return a.y() == b.y()? a.x() == b.x()? a.z() < b.z() : a.x() < b.x() : a.y() < b.y(); } ); for(int n = 0; n < bboxes.size(); n++) { const IBox &bbox = bboxes[n]; int min_y = bbox.y(), max_y = bbox.ey(); for(int z = 0; z < bbox.depth(); z++) for(int x = 0; x < bbox.width(); x++) { int level = 0; int px = x + bbox.x(); int pz = z + bbox.z(); while(level < m_level_count) { int value = m_data[index(px, pz, level)]; if(value == invalid_value || value >= min_y - 4) break; level++; } if(level == m_level_count) { if(level == max_levels) continue; addLevel(); } m_data[index(px, pz, level)] = max_y; } } for(int n = 0; n < (int)blockers.size(); n++) { IBox blocker( vmax(blockers[n].min(), int3(0, 0, 0)), vmin(blockers[n].max(), int3(m_size.x, 255, m_size.y))); u8 min_y = max(0, blocker.y() - 4), max_y = blocker.ey(); for(int z = 0; z < blocker.depth(); z++) for(int x = 0; x < blocker.width(); x++) { int level = 0; int px = x + blocker.x(); int pz = z + blocker.z(); while(level < m_level_count) { u8 &value = m_data[index(px, pz, level++)]; if(value >= min_y && value <= max_y) value = invalid_value; } } } }
void LevelSelectState::buildLevelPanel(){ sf::Vector2f windowSize(getContext().window->getSize()); sf::Texture &bgPanelTexture = getContext().textureManager->get(TextureID::LevelSelectionPanel); mLevelPanel = sf::Sprite(bgPanelTexture); mLevelPanel.setOrigin(sf::Vector2f( mLevelPanel.getGlobalBounds().width / 2, mLevelPanel.getGlobalBounds().height / 2)); mLevelPanel.setPosition(windowSize * 0.5f); mLevelPanel.setColor(sf::Color(255, 255, 255, 100)); //Set a centered view for our level display panel to handle //overflowing levels and scrolling down sf::View levelPanelView; levelPanelView.setCenter(mLevelPanel.getPosition()); levelPanelView.setSize(sf::Vector2f( static_cast<float>(bgPanelTexture.getSize().x), static_cast<float>(bgPanelTexture.getSize().y))); //Set viewport ratio according to the ratio of panel size //to window size, with a small amount of padding levelPanelView.setViewport(sf::FloatRect( (windowSize.x - bgPanelTexture.getSize().x) / 2.f / windowSize.x, ((windowSize.y - bgPanelTexture.getSize().y) / 2.f / windowSize.y) + 0.01f, bgPanelTexture.getSize().x / windowSize.x, bgPanelTexture.getSize().y / windowSize.y - 0.02f)); mLevelContainer->setView(levelPanelView); SaveManager &saveManager = SaveManager::getInstance(); int collectedGems = getCollectedGems(); //Level selection buttons std::vector<std::string> lPaths = saveManager.getLevelPaths(); LevelData data = saveManager.getLevelData(lPaths[0]); addLevel(data, lPaths[0], true); LevelData previousData; for (auto it = lPaths.begin() + 1; it != lPaths.end(); ++it){ previousData = data; data = saveManager.getLevelData(*it); addLevel(data, (*it), (previousData.completed) && (collectedGems >= data.requiredGems)); } mGUIContainer.add(mLevelContainer); }
eoLogger::eoLogger() : std::ostream( &_obuf ), //_verbose("quiet", "verbose", "Set the verbose level", 'v'), //_printVerboseLevels(false, "print-verbose-levels", "Print verbose levels", 'l'), //_output("", "output", "Redirect a standard output to a file", 'o'), _selectedLevel( eo::progress ), _contextLevel( eo::quiet ), _fd( 2 ), _obuf( _fd, _contextLevel, _selectedLevel ) { _standard_io_streams[&std::cout] = 1; _standard_io_streams[&std::clog] = 2; _standard_io_streams[&std::cerr] = 2; // /!\ If you want to add a level dont forget to add it at the header file in the enumerator Levels addLevel( "quiet", eo::quiet ); addLevel( "errors", eo::errors ); addLevel( "warnings", eo::warnings ); addLevel( "progress", eo::progress ); addLevel( "logging", eo::logging ); addLevel( "debug", eo::debug ); addLevel( "xdebug", eo::xdebug ); }
void Mob::setExp(unsigned int exp) { while (exp >= maxCurrentExp) { addLevel(1); exp-=maxCurrentExp; calculateMaxCurrentExp(); } this->exp = exp; }
Dialog::Dialog(Config *nConfig, QWidget *parent) : QDialog(parent) , ui(new Ui::Dialog) , helpManager(this) , scoreBoardManager(this) , gameOver(false) , config(nConfig) , level(0) , levelText(new QGraphicsSimpleTextItem()) { ui->setupUi(this); this->resize(config->getWidth(), config->getHeight()); this->setFixedSize(this->size()); scene = new QGraphicsScene(this); scene->setSceneRect(0, 0, config->getWidth(), config->getHeight()); scene->setBackgroundBrush(Defaults::BOX_COLOR); /* Create connection of the timer's timeout with the scences advance slot. */ QObject::connect(&timer, SIGNAL(timeout()), scene, SLOT(advance())); view = new QGraphicsView(this); view->setScene(scene); view->setRenderHint(QPainter::Antialiasing); /* Add this object to the chain for key handling, too. */ ChainOfResponsibility::get().add(this); /* Reseting the score, will render the string, which is then used for positioning. */ Score::get().reset(); /* Tell the score item where to display itself. Add 5 points distance to the border. */ Score::get().setPos(scene->width()- Score::get().boundingRect().width()- 5.0, 5.0); scene->addItem(&Score::get()); /* Add the usual items to the scene. */ AbstractResponsibility *respChainItem; QGraphicsItem *madeItem; for (size_t i = 0; i < config->size(); i++) { if((madeItem= ItemFactory::make((*config)[i]))){ scene->addItem(madeItem); if((respChainItem= dynamic_cast<AbstractResponsibility *>(madeItem))) { /* When no keypress handlers are on the chain, then a null is inserted. */ ChainOfResponsibility::get().add(respChainItem); } } } /* Configure stable parts of the text giving the level number, just once. */ levelText->setBrush(QBrush(Defaults::DEFAULT_FONT_COLOR)); levelText->setFont(Defaults::DEFAULT_FONT); scene->addItem(levelText); /* Add the first level to the scene. */ addLevel(config, 1); }
void Mortal::addExp(double n) { if(this->exp + n > max_exp) { max_exp += max_exp*(level/10.); max_health += max_health*(level/50.); addLevel(1); this->exp = 0; this->health = max_health; } else this->exp += n; }
void Mob::addExp(long exp) { long currentExp = this->exp + exp; while (currentExp >= maxCurrentExp) { addLevel(1); currentExp-=maxCurrentExp; calculateMaxCurrentExp(); } if (currentExp < 0) currentExp =0; this->exp = currentExp; }
void SearchManager::continueSearch() { Q_ASSERT(!links_being_checked_); vector<LinkStatus*> const& no = nodeToAnalize(); if((uint)current_index_ < no.size()) checkVectorLinks(no); else { current_index_ = 0; kdDebug(23100) << "Next node_____________________\n\n"; ++current_node_; if( (uint)current_node_ < (search_results_[current_depth_ - 1]).size() ) checkVectorLinks(nodeToAnalize()); else { kdDebug(23100) << "Next Level_____________________________________________________________________________________\n\n\n"; if(search_mode_ == SearchManager::domain || current_depth_ < depth_) { current_node_ = 0; ++current_depth_; addLevel(); if( (uint)current_depth_ == search_results_.size() ) checkVectorLinks(nodeToAnalize()); else { kdDebug(23100) << "Search Finished! (SearchManager::continueSearch#1)" << endl; finnish(); } } else { kdDebug(23100) << "Search Finished! (SearchManager::continueSearch#2)" << endl; finnish(); } } } }
/** Handle the key presses for the dialog window, i.e., act on Q to quit. */ void Dialog::handleEvent(Event *event) { KeyEvent *ke; if(((ke= dynamic_cast<KeyEvent *>(event)))&& ke->keycode== Qt::Key_Q) this->close(); else if (dynamic_cast<OutOfLivesEvent *>(event)) { stopTimer(); gameOver= true; QGraphicsSimpleTextItem *goText(new QGraphicsSimpleTextItem(QString("Game over !!!"))); goText->setFont(QFont("sans", 20, 2)); goText->setBrush(QColor("red")); goText->setPos(scene->sceneRect().center()- goText->boundingRect().center()); scene->addItem(goText); /* The score board manager also depends on the event, therefore propagate it. */ AbstractResponsibility::handleEvent(event); } else if (dynamic_cast<LevelClearedEvent *>(event)) { if(addLevel(config, level->getLevelNum()+ 1)) { Ball *currBall; for(QList<QGraphicsItem *>::iterator iter(scene->items().begin()), iterEnd(scene->items().end()); iter!= iterEnd; ++iter){ /* Find all balls and update their velocity. */ if((currBall= dynamic_cast<Ball *>(*iter))) { currBall->setVelocity(currBall->getVelocity()* level->getBallVelocityFactor()); } } } else { stopTimer(); gameOver= true; QGraphicsSimpleTextItem *goText(new QGraphicsSimpleTextItem(QString("Game over !!!"))); goText->setFont(QFont("sans", 20, 4)); goText->setBrush(QColor("green")); goText->setPos(scene->sceneRect().center()- goText->boundingRect().center()); scene->addItem(goText); /* For each remaining live add 100 points. */ /* The score board manager depends on the out of lives event, which is not quite * correct here. */ OutOfLivesEvent oole; AbstractResponsibility::handleEvent(&oole); } } else AbstractResponsibility::handleEvent(event); }
eoLogger::eoLogger() : std::ostream(&_obuf), _selectedLevel(eo::progress), _contextLevel(eo::quiet), _fd(2), _obuf(_fd, _contextLevel, _selectedLevel) { _standard_io_streams[&std::cout] = 1; _standard_io_streams[&std::clog] = 2; _standard_io_streams[&std::cerr] = 2; // /!\ If you want to add a level dont forget to add it at the header file in the enumerator Levels addLevel("quiet", eo::quiet); addLevel("errors", eo::errors); addLevel("warnings", eo::warnings); addLevel("progress", eo::progress); addLevel("logging", eo::logging); addLevel("debug", eo::debug); addLevel("xdebug", eo::xdebug); }
Scene::Scene(unsigned int n) { std::cout << "\nCreating Scene..."; mLightSourcePosition = glm::vec3(0.0f, 0.0f, 0.0f); if(n > 7) { std::cout << "\nYou tried to create more levels than possible, 7 is the maximum amount!\n"; std::cout << "\n\nUsing 7 levels instead!\n\n"; n = 7; } for(unsigned int i = 1; i <= n; i++) { addLevel(new Level(("../assets/objs/_level" + std::to_string(i) + ".obj").c_str(), sColorScale[i-1])); } mCharacter = new Character("../assets/objs/character.obj", "../assets/textures/char_texture.png"); mGift = new Character("../assets/objs/gift.obj", "../assets/textures/gift.png"); mSkySphere = new SkySphere(35); mWords[START].push_back(new Letter("../assets/objs/start.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[FIVE].push_back(new Letter("../assets/objs/5.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[FOUR].push_back(new Letter("../assets/objs/4.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[THREE].push_back(new Letter("../assets/objs/3.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[TWO].push_back(new Letter("../assets/objs/2.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[ONE].push_back(new Letter("../assets/objs/1.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); mWords[TACK].push_back(new Letter("../assets/objs/tack.obj", glm::vec4(0.8f, 0.2f, 0.2f, 1.0f))); std::cout << "Scene created!\n"; }
SortWidget::SortWidget( QWidget *parent ) : QWidget( parent ) { setFixedHeight( 28 ); setContentsMargins( 3, 0, 3, 0 ); m_layout = new QHBoxLayout( this ); setLayout( m_layout ); m_layout->setSpacing( 0 ); m_layout->setContentsMargins( 0, 0, 0, 0 ); BreadcrumbItemButton *rootItem = new BreadcrumbItemButton( KIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/playlist-sorting-16.png" ) ) ), QString(), this ); rootItem->setToolTip( i18n( "Clear the playlist sorting configuration." ) ); m_layout->addWidget( rootItem ); connect( rootItem, SIGNAL(clicked()), this, SLOT(trimToLevel()) ); m_ribbon = new QHBoxLayout(); m_layout->addLayout( m_ribbon ); m_ribbon->setContentsMargins( 0, 0, 0, 0 ); m_ribbon->setSpacing( 0 ); m_addButton = new BreadcrumbAddMenuButton( this ); m_addButton->setToolTip( i18n( "Add a playlist sorting level." ) ); m_layout->addWidget( m_addButton ); m_layout->addStretch( 10 ); m_urlButton = new BreadcrumbUrlMenuButton( "playlist", this ); m_layout->addWidget( m_urlButton ); connect( m_addButton->menu(), SIGNAL(actionClicked(QString)), this, SLOT(addLevel(QString)) ); connect( m_addButton->menu(), SIGNAL(shuffleActionClicked()), The::playlistActions(), SLOT(shuffle()) ); QString sortPath = Amarok::config( "Playlist Sorting" ).readEntry( "SortPath", QString() ); readSortPath( sortPath ); }
void SkipList_Int2::tryAddLevel() { if (m_size > (1 << (m_maxLevel))) addLevel(); }
void CQTs_Character::addLevel(QString classCode, QMap<QString,int> ranks){ int zero[6]={0,0,0,0,0,0}; addLevel(classCode,ranks,zero); }