void Evaluate::addVariant(QVariant &object) { if (object.isValid()) { switch(object.type()) { case QMetaType::QString: { QString string = object.toString(); addString(string); } break; case QMetaType::QVariantList: { QVariantList list = object.toList(); addArray(list); } break; case QMetaType::Double: m_buffer.append(object.toString()); break; case QMetaType::QVariantMap: { QVariantMap map = object.toMap(); addMap(map); break; } case QMetaType::Bool: { m_buffer.append(object.toString()); break; } default: m_buffer.append("null"); } } else { m_buffer.append("null"); } }
bool GameScene::init() { if (!Layer::init())return false; initPlist(); initEffect(); //set game status Config::getInstance()->setGameSatus(ING); Config::getInstance()->setScore(0);//rest score //loding effect auto _SimpleAudioEngine = SimpleAudioEngine::getInstance(); _SimpleAudioEngine->preloadEffect(air_shoot_effect1); _SimpleAudioEngine->preloadEffect(ship_explode_effect0); //init game map //init enemy type switch (levelNum) { case GAMEMAP1://0 if (Config::getInstance()->getmusicState()) { auto simpleAudio = SimpleAudioEngine::getInstance(); simpleAudio->preloadBackgroundMusic(battle_bg_stage0); simpleAudio->setBackgroundMusicVolume(1.0f); simpleAudio->playBackgroundMusic(battle_bg_stage0, true); } addMap("Map1.png"); levelScore = BOOS_LEVEL1; break; case GAMEMAP2://1 if (Config::getInstance()->getmusicState()) { auto simpleAudio = SimpleAudioEngine::getInstance(); simpleAudio->preloadBackgroundMusic(battle_bg_stage1); simpleAudio->setBackgroundMusicVolume(1.0f); simpleAudio->playBackgroundMusic(battle_bg_stage1, true); } addMap("Map2.png"); levelScore = BOOS_LEVEL2; //add particle Kit::addParticle(snow_plist, this, VisibleRect::top()); break; case GAMEMAP3://2 if (Config::getInstance()->getmusicState()) { auto simpleAudio = SimpleAudioEngine::getInstance(); simpleAudio->preloadBackgroundMusic(battle_bg_stage2); simpleAudio->setBackgroundMusicVolume(1.0f); simpleAudio->playBackgroundMusic(battle_bg_stage2, true); } addMap("Map3.png"); levelScore = BOOS_LEVEL3; break; case GAMEMAP4://3 if (Config::getInstance()->getmusicState()) { auto simpleAudio = SimpleAudioEngine::getInstance(); simpleAudio->preloadBackgroundMusic(battle_bg_stage2); simpleAudio->setBackgroundMusicVolume(1.0f); simpleAudio->playBackgroundMusic(battle_bg_stage2, true); } addMap("Map4.png"); levelScore = BOOS_LEVEL4; //add fire paticle Kit::addParticle(battle_fire_bg_particle_plist, this, VisibleRect::top()); break; default: log("there's no game map to do !"); return false; break; } //add logo one top-left auto logoShip = Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(SHIP_FILE_NAME)); float offset = logoShip->getContentSize().width / 2; logoShip->setScale(0.8f); auto winsize = Director::getInstance()->getWinSize(); logoShip->setPosition(Vec2(offset, winsize.height - offset)); this->addChild(logoShip, SHIP_Z_ORDER); //set life value beside of logoShip Config::getInstance()->setShipLife(SHIP_LIFES); __String life("X"); life.appendWithFormat("%02d", Config::getInstance()->getShipLife()); lifeValue = Label::createWithSystemFont(life.getCString(), "Arial", 12); lifeValue->setPosition(Vec2(offset * 3, winsize.height - offset)); lifeValue->setColor(Color3B::RED); this->addChild(lifeValue, SHIP_Z_ORDER); //add score __String tempscore("得分:"); tempscore.appendWithFormat("%07d", Config::getInstance()->getScore()); score = Label::createWithSystemFont(tempscore.getCString(), "Arial", 12); score->setPosition(Vec2(winsize.width - 45, winsize.height - offset)); score->setColor(Color3B::RED); this->addChild(score, SHIP_Z_ORDER); ship = Ship::creatShip(this, 0, SHIP_LIFE_VALUE); auto initPosition = VisibleRect::center(); ship->setPosition(Vec2(initPosition.x, initPosition.y - 120.0f)); this->addChild(ship, SHIP_Z_ORDER); //add bone btn auto bone_btn_sprite = Sprite::create(btn_bone_res); bone_btn_sprite->setScale(0.8f); auto bone_btn = MenuItemSprite::create(bone_btn_sprite, nullptr, [&](Ref* _bone_btn){ //处理炸弹效果 log("bone released ......"); //can shake auto j = JumpBy::create(0.5f, Vec2::ZERO, 5, 5); this->runAction(j); auto config = Config::getInstance(); //remove enemy and bullet for (auto bullet : *config->enemy_bullet_list) { bullet->boneDestory(); } for (auto enemy : *config->enemy_list) { //effect it log("effect it ......"); enemy->boneDestory(this); } config->enemy_bullet_list->clear(); config->enemy_list->clear(); }); auto menue = Menu::create(bone_btn, NULL); menue->setPosition(Vec2(35, 200)); this->addChild(menue, BTN_BACK_Z_ORDER); menue->runAction(Kit::creatEaseSineInOut(100.0f)); //add back btn auto btn_sprite = Sprite::createWithTexture(Director::getInstance()->getTextureCache()->addImage(btn_back_res)); btn_sprite->setColor(Color3B(0, 245, 255)); auto btn_back = MenuItemSprite::create(btn_sprite, nullptr, [&](Ref* item){ auto menuSprite = (MenuItemSprite*)item; auto scale = ScaleBy::create(0.2f, 1.1); auto jumpToGameLevel = CallFunc::create([](){ auto config=Config::getInstance(); if (config->getmusicState()) SimpleAudioEngine::getInstance()->stopBackgroundMusic();// 停止当前背景音乐 if (config->getmusicState()) { SimpleAudioEngine::getInstance()->playBackgroundMusic(main_bg_stage1, true); } Director::getInstance()->replaceScene(TransitionFade::create(1.2f, GameLevelLayer::creatScene())); }); //call back std::function<void()> releaseResources = [&](){ this->releaseR(); }; menuSprite->runAction(Sequence::create(CallFunc::create(releaseResources), scale, scale->reverse(), jumpToGameLevel, NULL)); }); menue = Menu::create(btn_back, NULL); auto btn_back_position = VisibleRect::rightBottom(); offset = btn_sprite->getContentSize().width / 2; menue->setPosition(Vec2(btn_back_position.x - 50, btn_back_position.y + 25)); this->addChild(menue, BTN_BACK_Z_ORDER); menue->runAction(Kit::creatEaseSineInOut(100.0f)); //添加敌机 this->schedule(schedule_selector(GameScene::addEnemy), 2.0f, kRepeatForever, 1.2f); this->scheduleUpdate(); //初始化地图移动 this->scheduleOnce(schedule_selector(GameScene::initMoveMap), 1.2f); return true; }
// ------------------------------------------------------------- TRasterMapsDialog::TRasterMapsDialog(IMapAdapterInterfaces MapInterfaces_, QString Organization_, QString Application_, QWidget *Parent_) : QDialog(Parent_), PI(acos(-1.0)), m_Organization(Organization_), m_Application(Application_), m_Mode(Consts::ListMode), m_KeyControlPressed(false) { setWindowTitle(QNetMapTranslator::tr("Raster map list" /* Russian: Список растровых карт */)); QPalette palette/*(palette())*/; palette.setColor(backgroundRole(), Qt::white); setPalette(palette); setAutoFillBackground(true); setMinimumSize(800, 600); // карта w_MapWidget = new TMapWidget(MapInterfaces_, "", 12, QPointF(0,0), Organization_, Application_); // Лайаут основной setLayout(&m_MainVerticalLayout); m_MainVerticalLayout.setSpacing(8); m_MainVerticalLayout.setMargin(8); // Лайаут для размещения элементов верхней строки с подсказкой QHBoxLayout *TopLayout = new QHBoxLayout; m_MainVerticalLayout.addLayout(TopLayout); TopLayout->addWidget(&m_TextHint); hint(QNetMapTranslator::tr("Select the map or action" /* Russian: Выберите карту или действие */)); TopLayout->addStretch(); // Лайаут для списка, кнопок и карты QHBoxLayout *MiddleLayout = new QHBoxLayout; m_MainVerticalLayout.addLayout(MiddleLayout); // Лайаут для списка и кнопок QVBoxLayout *ListLayout = new QVBoxLayout; // Лайаут для карты QVBoxLayout *MapLayout = new QVBoxLayout; // Путь к карте MapLayout->addWidget(&m_MapPath); // Рамка для виджета карты QFrame *MapWidgetFrame = new QFrame; MapWidgetFrame->setFrameStyle(QFrame::Box | QFrame::Plain); QHBoxLayout *MapWidgetFrameLayout = new QHBoxLayout(MapWidgetFrame); MapWidgetFrameLayout->setMargin(0); MapWidgetFrameLayout->addWidget(w_MapWidget); MapLayout->addWidget(MapWidgetFrame); // лайоут для списка точек привязки w_MapAnchors = new QVBoxLayout; w_MapAnchors->setMargin(0); MapLayout->addLayout(w_MapAnchors); // Список карт QStringList ListMaps; IMapAdapterInterfaces RasterMapInterfaces = w_MapWidget->rasterMapInterfaces(); foreach(IMapAdapterInterface* Interface, RasterMapInterfaces) { ListMaps << Interface->pluginName(); } m_Model.setStringList(ListMaps); m_MapsListView.setModel(&m_Model); ListLayout->addWidget(&m_MapsListView); QGroupBox *ListGroup = new QGroupBox(QNetMapTranslator::tr("Raster maps" /* Russian: Растровые карты */)); ListGroup->setMaximumWidth(200); ListGroup->setLayout(ListLayout); // кнопки m_CenterMapButton.setText(QNetMapTranslator::tr("Map's center" /* Russian: Центр карты */)); m_LinkingButton.setText(QNetMapTranslator::tr("Add reference points..." /* Russian: Привязать... */)); m_DeleteLinkingButton.setText(QNetMapTranslator::tr("Delete reference points" /* Russian: Удалить привязку */)); m_AddButton.setText(QNetMapTranslator::tr("Add to list..." /* Russian: Добавить в список... */)); m_DeleteButton.setText(QNetMapTranslator::tr("Delete from list" /* Ru: Удалить из списка */)); m_ExitDialogButton.setText(QNetMapTranslator::tr("OK")); ListLayout->addWidget(&m_CenterMapButton); ListLayout->addWidget(&m_LinkingButton); ListLayout->addWidget(&m_DeleteLinkingButton); ListLayout->addWidget(&m_AddButton); ListLayout->addWidget(&m_DeleteButton); ListLayout->addItem(new QSpacerItem(0, 7)); ListLayout->addWidget(&m_ExitDialogButton); // Кнопки подтверждения / отмены m_ButtonBox.setMinimumSize(QSize(0, 30)); m_ButtonBox.setOrientation(Qt::Horizontal); m_ButtonBox.setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); // находим кнопку ОК и делаем ее недоступной QList<QAbstractButton*> ListButtons = m_ButtonBox.buttons(); foreach(QAbstractButton* Button, ListButtons) { if(m_ButtonBox.buttonRole(Button) == QDialogButtonBox::AcceptRole) { w_ButtonOK = Button; w_ButtonOK->setEnabled(false); break; } } MapLayout->addWidget(&m_ButtonBox); m_ButtonBox.setVisible(false); MiddleLayout->addWidget(ListGroup); MiddleLayout->addLayout(MapLayout); // устанавливаем текущей первую карту в списке if(m_Model.rowCount()) mapNameClicked(m_Model.index(0, 0)); // сигналы QNM_DEBUG_CHECK(connect(&m_MapsListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(mapNameClicked(const QModelIndex&)))); QNM_DEBUG_CHECK(connect(&m_MapsListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(mapNameClicked(const QModelIndex&)))); QNM_DEBUG_CHECK(connect(&m_ButtonBox, SIGNAL(accepted()), this, SLOT(acceptLinking()))); QNM_DEBUG_CHECK(connect(&m_ButtonBox, SIGNAL(rejected()), this, SLOT(rejectLinking()))); QNM_DEBUG_CHECK(connect(&m_AddButton, SIGNAL(clicked()), this, SLOT(addMap()))); QNM_DEBUG_CHECK(connect(&m_DeleteButton, SIGNAL(clicked()), this, SLOT(deleteMap()))); QNM_DEBUG_CHECK(connect(&m_LinkingButton, SIGNAL(clicked()), this, SLOT(viewMap()))); QNM_DEBUG_CHECK(connect(&m_DeleteLinkingButton, SIGNAL(clicked()), this, SLOT(deleteLinking()))); QNM_DEBUG_CHECK(connect(&m_CenterMapButton, SIGNAL(clicked()), this, SLOT(viewCenterMap()))); QNM_DEBUG_CHECK(connect(&m_ExitDialogButton, SIGNAL(clicked()), this, SLOT(accept()))); // widgetsEnabling(); }
/* ------------------------------------------------------------------------------------------- * * ------------------------------------------------------------------------------------------- */ void DMWindow::createDockWindows() { // maps this->mapDock = new QDockWidget(tr("Maps"),this); this->mapList = new DockListWidget(this->mapDock); this->mapDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->mapDock->setObjectName("map-dock"); this->mapDock->setWidget(this->mapList); this->mapList->addButton("Add map",this, SLOT(addMap()), false); this->mapList->addButton("Remove map", this, SLOT(removeMap()), false); this->mapList->addButton("Show Map on Table", this, SLOT(showMapOnTable()), true); this->mapList->addButton("Show Map in Popup", this, SLOT(showMapOnPopup()), false); this->addDockWidget(Qt::LeftDockWidgetArea, this->mapDock); this->viewMenu->addAction(this->mapDock->toggleViewAction()); // artifacts -- things like letters, artifacts, etc can be shown to the players this->artifactDock = new QDockWidget(tr("Artifacts"),this); this->assetList = new DockListWidget(this->artifactDock); this->artifactDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->artifactDock->setObjectName("artifact-dock"); this->artifactDock->setWidget(this->assetList); this->addDockWidget(Qt::LeftDockWidgetArea, this->artifactDock); this->viewMenu->addAction(this->artifactDock->toggleViewAction()); // initiative this->initiativeDock = new QDockWidget(tr("Initiative"),this); this->initiativeDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->initiativeDock->setObjectName("initiative-dock"); this->initiativeList = new DockListWidget(this->initiativeDock); this->initiativeDock->setWidget(this->initiativeList); this->addDockWidget(Qt::LeftDockWidgetArea, this->initiativeDock); this->viewMenu->addAction(this->initiativeDock->toggleViewAction()); // player characters this->pcDock = new QDockWidget(tr("PCs"),this); this->pcList = new DockListWidget(this->pcDock); this->pcDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->pcDock->setObjectName("player-character-dock"); this->pcDock->setWidget(this->pcList); this->pcList->addButton("Add Player Character",this,SLOT(addPc()), false); this->pcList->addButton("Remove Player Character",this,SLOT(removePc()), false); this->addDockWidget(Qt::RightDockWidgetArea, this->pcDock); this->viewMenu->addAction(this->pcDock->toggleViewAction()); // non player characters this->npcDock = new QDockWidget(tr("NPCs"),this); this->npcDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->npcDock->setObjectName("non-player-character-dock"); this->npcList = new DockListWidget(this->npcDock); this->npcDock->setWidget(this->npcList); this->addDockWidget(Qt::RightDockWidgetArea, this->npcDock); this->viewMenu->addAction(this->npcDock->toggleViewAction()); // monsters this->monsterDock = new QDockWidget(tr("Monsters"),this); this->monsterDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); this->monsterDock->setObjectName("monster-dock"); this->monsterList = new DockListWidget(this->monsterDock); this->monsterDock->setWidget(this->monsterList); this->addDockWidget(Qt::RightDockWidgetArea, this->monsterDock); this->viewMenu->addAction(this->monsterDock->toggleViewAction()); }
bool processPackage( QDomDocument* list, QString path ) { QString map = findMapInDir( path ); if( map.isEmpty() ) { printf( "no map file in dir (required for parsing)\n" ); printf( "package path: " + path.toUtf8() + "\n" ); return false; } QDomElement mapElement = findPackageElement( *list, "map", map ); if( path.endsWith( "MoNav.ini" ) ) { if( !mapElement.isNull() ) { QString pHash = computePackageHash( path ); if( mapElement.attribute( "hash" ) != pHash ) { updateMap( list, &mapElement ); mapElement.setAttribute( "hash", pHash ); } else printf( "map already in list\n" ); return false; } addMap( list, map, path ); } else if( path.endsWith( ".mmm" ) ) { if( mapElement.isNull() ) addMap( list, map, path ); QString package = path.right( path.size() - path.lastIndexOf( '/' ) - 1 ); QStringList packageAttributes = package.split( "_" ); QString type = packageAttributes[0]; QString name = packageAttributes[1].replace( ".mmm", "" ); QDomElement packageElement = findPackageElement( *list, "module", name, map ); if( !packageElement.isNull() ) { QString pHash = computePackageHash( path ); if( packageElement.attribute( "hash" ) != pHash ) { updateModule( list, &packageElement ); packageElement.setAttribute( "hash", pHash ); } else printf( "package already in list\n" ); return false; } addModule( list, &mapElement, name, type, path ); } else { printf( "unrecognized package format\n" ); return false; } return true; }