void MainMenu::callbackActive(Widget &widget) { if (widget.getTag() == "BTN_NEWGAME") { if (_module->load("lev_m40aa")) _returnCode = 2; return; } if(widget.getTag() == "BTN_LOADGAME") { } if(widget.getTag() == "BTN_MOVIES") { createMovies(); sub(*_movies); return; } if(widget.getTag() == "BTN_OPTIONS") { createOptions(); sub(*_options); return; } if (widget.getTag() == "BTN_EXIT") { EventMan.requestQuit(); _returnCode = 1; return; } }
bool RtspStreamWorker::setup() { ASSERT_WORKER_THREAD(); m_ctx = avformat_alloc_context(); m_ctx->interrupt_callback.callback = rtspStreamInterruptCallback; m_ctx->interrupt_callback.opaque = this; AVDictionary *options = createOptions(); bool prepared = prepareStream(&m_ctx, options); av_dict_free(&options); if (prepared) { m_frameFormatter.reset(new RtspStreamFrameFormatter(m_ctx->streams[m_videoStreamIndex])); m_frameFormatter->setAutoDeinterlacing(m_autoDeinterlacing); } else if (m_ctx) { avformat_close_input(&m_ctx); m_ctx = 0; } return prepared; }
void MainMenu::callbackActive(Widget &widget) { if (widget.getTag() == "BTN_NEWGAME") { // Stop the currently running main music stopMenuMusic(); createClassSelection(); // Start the charGen music startCharGenMusic(); if (sub(*_classSelection) == 2) { _returnCode = 2; stopMenuMusic(); return; } // If we return from the chargen we stop the music and play the main music stopMenuMusic(); startMainMusic(); return; } if (widget.getTag() == "BTN_LOADGAME") { createLoadGame(); if (sub(*_loadGame) == 2) { _returnCode = 2; stopMenuMusic(); } return; } if (widget.getTag() == "BTN_MOVIES") { createMovies(); sub(*_movies); return; } if (widget.getTag() == "BTN_OPTIONS") { createOptions(); sub(*_options); return; } if (widget.getTag() == "BTN_EXIT") { EventMan.requestQuit(); _returnCode = 1; return; } }
static void loadWidgetSet(char *filename) { cJSON *root, *node; char *text; Widget *w; SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename); text = readFile(filename); root = cJSON_Parse(text); for (node = root->child ; node != NULL ; node = node->next) { w = malloc(sizeof(Widget)); memset(w, 0, sizeof(Widget)); w->type = lookup(cJSON_GetObjectItem(node, "type")->valuestring); STRNCPY(w->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH); STRNCPY(w->group, cJSON_GetObjectItem(node, "group")->valuestring, MAX_NAME_LENGTH); w->rect.x = cJSON_GetObjectItem(node, "x")->valueint; w->rect.y = cJSON_GetObjectItem(node, "y")->valueint; w->rect.w = cJSON_GetObjectItem(node, "w")->valueint; w->rect.h = cJSON_GetObjectItem(node, "h")->valueint; w->enabled = 1; w->visible = 1; if (w->rect.x == -1) { w->rect.x = SCREEN_WIDTH / 2; } switch (w->type) { case WT_BUTTON: STRNCPY(w->text, cJSON_GetObjectItem(node, "text")->valuestring, MAX_NAME_LENGTH); w->rect.x -= w->rect.w / 2; w->rect.y -= (w->rect.h / 2) + 8; break; case WT_SELECT: STRNCPY(w->text, cJSON_GetObjectItem(node, "text")->valuestring, MAX_NAME_LENGTH); w->rect.x -= w->rect.w / 2; w->rect.y -= (w->rect.h / 2) + 8; createOptions(w, cJSON_GetObjectItem(node, "options")->valuestring); break; } tail->next = w; tail = w; } cJSON_Delete(root); free(text); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PdmUiTreeSelectionQModelTest, SetDataAndSignal) { QList<caf::PdmOptionItemInfo> options = createOptions(); caf::PdmUiTreeSelectionQModel myModel; myModel.setOptions(nullptr, options); QModelIndex parentIndex = myModel.index(0, 0); myModel.setData(parentIndex, QVariant(true)); }
osg::ref_ptr<osg::Node> p3d::readPresentation(const std::string& filename,const osgDB::ReaderWriter::Options* options) { std::string ext = osgDB::getFileExtension(filename); if (!osgDB::equalCaseInsensitive(ext,"xml") && !osgDB::equalCaseInsensitive(ext,"p3d")) return 0; osg::ref_ptr<osgDB::Options> local_options = createOptions(options); local_options->setOptionString("main"); return osgDB::readRefNodeFile(filename, local_options.get()); }
osg::ref_ptr<osg::Node> p3d::readHoldingSlide(const std::string& filename) { std::string ext = osgDB::getFileExtension(filename); if (!osgDB::equalCaseInsensitive(ext,"xml") && !osgDB::equalCaseInsensitive(ext,"p3d")) return 0; osg::ref_ptr<osgDB::ReaderWriter::Options> options = createOptions(0); options->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_NONE); options->setOptionString("preview"); return osgDB::readRefNodeFile(filename, options.get()); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PdmUiTreeSelectionQModelTest, SetCheckedStateForItems) { QList<caf::PdmOptionItemInfo> options = createOptions(); caf::PdmUiTreeSelectionQModel myModel; myModel.setOptions(nullptr, options); QModelIndex parentIndex = myModel.index(1, 0); QModelIndex firstChildIndex = myModel.index(0, 0, parentIndex); QModelIndexList indices; indices << firstChildIndex; myModel.setCheckedStateForItems(indices, false); // No test code for this behaviour, only making sure this runs without any errors }
void MainMenu::callbackActive(Widget &widget) { if (widget.getTag() == "OPTIONS") { if (!_options) createOptions(); sub(*_options); } if (widget.getTag() == "NEW_GAME") { newGame(); return; } if (widget.getTag() == "CREDITS") { playVideo("creditmovie"); return; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PdmUiTreeSelectionQModelTest, BasicUsage) { QList<caf::PdmOptionItemInfo> options = createOptions(); caf::PdmUiTreeSelectionQModel myModel; myModel.setOptions(nullptr, options); EXPECT_EQ(options.size(), myModel.optionItemCount()); EXPECT_EQ(4, myModel.rowCount(myModel.index(-1, -1))); EXPECT_EQ(0, myModel.rowCount(myModel.index(0, 0))); EXPECT_EQ(2, myModel.rowCount(myModel.index(1, 0))); EXPECT_EQ(0, myModel.rowCount(myModel.index(2, 0))); EXPECT_EQ(0, myModel.rowCount(myModel.index(3, 0))); // Test for row out of bounds EXPECT_FALSE(myModel.index(4, 0).isValid()); }
void QgsRasterFormatSaveOptionsWidget::updateProfiles() { // build profiles list = user + builtin(last) QString format = mPyramids ? "_pyramids" : mFormat; QStringList profileKeys = profiles(); QMapIterator<QString, QStringList> it( mBuiltinProfiles ); while ( it.hasNext() ) { it.next(); QString profileKey = it.key(); if ( ! profileKeys.contains( profileKey ) && !it.value().isEmpty() ) { // insert key if is for all formats or this format (GTiff) if ( it.value()[0] == "" || it.value()[0] == format ) { profileKeys.insert( 0, profileKey ); } } } qSort( profileKeys ); // populate mOptionsMap and mProfileComboBox mOptionsMap.clear(); mProfileComboBox->blockSignals( true ); mProfileComboBox->clear(); Q_FOREACH ( const QString& profileKey, profileKeys ) { QString profileName, profileOptions; profileOptions = createOptions( profileKey ); if ( mBuiltinProfiles.contains( profileKey ) ) { profileName = mBuiltinProfiles[ profileKey ][ 1 ]; if ( profileOptions.isEmpty() ) profileOptions = mBuiltinProfiles[ profileKey ][ 2 ]; } else { profileName = profileKey; } mOptionsMap[ profileKey ] = profileOptions; mProfileComboBox->addItem( profileName, profileKey ); }
void MainMenu::callbackActive(Widget &widget) { if (widget.getTag() == "BTN_NEWGAME") { try { _module->load("end_m01aa"); } catch (...) { Common::exceptionDispatcherWarning(); return; } _returnCode = 2; return; } if (widget.getTag() == "BTN_LOADGAME") { } if (widget.getTag() == "BTN_MOVIES") { createMovies(); sub(*_movies); return; } if (widget.getTag() == "BTN_OPTIONS") { createOptions(); sub(*_options); return; } if (widget.getTag() == "BTN_EXIT") { EventMan.requestQuit(); _returnCode = 1; return; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- TEST(PdmUiTreeSelectionQModelTest, ParentBehaviour) { QList<caf::PdmOptionItemInfo> options = createOptions(); caf::PdmUiTreeSelectionQModel myModel; myModel.setOptions(nullptr, options); QModelIndex parentIndex = myModel.index(1, 0); EXPECT_EQ(2, myModel.rowCount(parentIndex)); { QModelIndex firstChildIndex = myModel.index(0, 0, parentIndex); EXPECT_STREQ("Second_a", myModel.data(firstChildIndex).toString().toLatin1()); EXPECT_TRUE(parentIndex == myModel.parent(firstChildIndex)); } { QModelIndex secondChildIndex = myModel.index(1, 0, parentIndex); EXPECT_STREQ("Second_b", myModel.data(secondChildIndex).toString().toLatin1()); EXPECT_TRUE(parentIndex == myModel.parent(secondChildIndex)); } }
void MainMenu::callbackActive(Widget &widget) { if (widget.getTag() == "ExitButton") { EventMan.requestQuit(); return; } if (widget.getTag() == "NewButton") { createNew(); NewGameFogs fogs(ConfigMan.getInt("menufogcount", 4)); fogs.show(); if (sub(*_new, 0, false) == 2) { _returnCode = 2; return; } show(); return; } if (widget.getTag() == "MoviesButton") { createMovies(); sub(*_movies); return; } if (widget.getTag() == "OptionsButton") { createOptions(); sub(*_options); return; } }
AncovaMultivariate::AncovaMultivariate(int id) : Analysis(id, "AncovaMultivariate", createOptions()) { }
Correlation::Correlation(int id) : Analysis(id, "Correlation", createOptions()) { }
static uid_t uidFor(const string &userName) { return getpwnam(userName.c_str())->pw_uid; } static gid_t gidFor(const string &groupName) { return getgrnam(groupName.c_str())->gr_gid; } static string primaryGroupFor(const string &userName) { gid_t gid = getpwnam(userName.c_str())->pw_gid; return getgrgid(gid)->gr_name; } TEST_METHOD(1) { // Basic spawning test. Options options = createOptions(); options.appRoot = "stub/rack"; options.startCommand = "ruby\t" "start.rb"; options.startupFile = "start.rb"; SpawnerPtr spawner = createSpawner(options); process = spawner->spawn(options); process->requiresShutdown = false; ensure_equals(process->sockets->size(), 1u); Connection conn = process->sockets->front().checkoutConnection(); ScopeGuard guard(boost::bind(checkin, process, &conn)); writeExact(conn.fd, "ping\n"); ensure_equals(readAll(conn.fd), "pong\n"); } TEST_METHOD(2) {
SEMSimple::SEMSimple(int id) : Analysis(id, "SEMSimple", createOptions()) { }
bool Game::update() { frect tempRec; char buffer[256]; if(curState != gplay) { if(curState != cselect) { menu.update(); menu.render(); tempInfo.type = screenSprite; tempInfo.asset = &backGround; D3DXMatrixIdentity(&tempInfo.matrix); if(curState != finish) { D3DXMatrixTranslation(&tempInfo.matrix,Engine::instance()->width()/2,Engine::instance()->height()/4,0); } else { D3DXMatrixTranslation(&tempInfo.matrix,Engine::instance()->width()/2,Engine::instance()->height()/2,0); } Engine::instance()->addRender(tempInfo); if(curState == finish) { tempInfo.type = text; tempRec.top = 0.1f; tempRec.bottom = 0.2f; tempRec.left = 0.0f; tempRec.right = 1.0f; if(p1Won) { sprintf(buffer,"%s WINS!",charList[p1Select].name.c_str()); p1Name.text = buffer; p1Name.rect = tempRec; tempInfo.asset = &p1Name; } else { sprintf(buffer,"%s WINS!",charList[p2Select].name.c_str()); p2Name.text = buffer; p2Name.rect = tempRec; tempInfo.asset = &p2Name; } Engine::instance()->addRender(tempInfo); } if(Engine::instance()->getMessage("CharSelect")) { menu.resetSelection(); p1Lock = false; p2Lock = false; p1Select = 0; p2Select = 0; startDelay = 3.0f; curState = cselect; } if(Engine::instance()->getMessage("MainMenu")) { menu.resetSelection(); createMenu(); } if(Engine::instance()->getMessage("Options")) { menu.resetSelection(); createOptions(); } if(Engine::instance()->getMessage("Help")) { menu.resetSelection(); createHelp(); } if(Engine::instance()->getMessage("Quit")) { play = false; } if(Engine::instance()->getMessage("ToggleRensa")) { _rensa = !_rensa; createOptions(); } if(Engine::instance()->getMessage("ToggleMagic")) { _magic = !_magic; createOptions(); } if(Engine::instance()->getMessage("replay")) { startTetris(); } //if (Engine::instance()->getMessage("BindControllers")) { // thought about it, and this is actually not necessary since it's only two controllers that are loaded kinda. fuckit man. fuckit. //} } else { //character select menu if(!p1Lock) { if (Engine::instance()->getFlags("SelectionUp")&buttonFlags::_repeat || Engine::instance()->getFlags("SelectionUpDpad")&buttonFlags::_repeat) { --p1Select; Engine::instance()->playSound(rollover, soundvec, soundvec); } else if (Engine::instance()->getFlags("SelectionDown")&buttonFlags::_repeat || Engine::instance()->getFlags("SelectionDownDpad")&buttonFlags::_repeat) { ++p1Select; Engine::instance()->playSound(rollover, soundvec, soundvec); } else if(Engine::instance()->getFlags("Accept")&buttonFlags::_pushed) { p1Lock = true; Engine::instance()->playSound(click, soundvec, soundvec); } if(p1Select < 0) { p1Select = charList.size()-1; } else if(p1Select >= charList.size()) { p1Select = 0; } } if(!p2Lock) { if (Engine::instance()->getFlags("SelectionUp2")&buttonFlags::_repeat || Engine::instance()->getFlags("SelectionUp2Dpad")&buttonFlags::_repeat) { --p2Select; Engine::instance()->playSound(rollover, soundvec, soundvec); } else if (Engine::instance()->getFlags("SelectionDown2")&buttonFlags::_repeat || Engine::instance()->getFlags("SelectionDown2Dpad")&buttonFlags::_repeat) { ++p2Select; Engine::instance()->playSound(rollover, soundvec, soundvec); } else if(Engine::instance()->getFlags("Accept2")&buttonFlags::_pushed) { p2Lock = true; Engine::instance()->playSound(click, soundvec, soundvec); } if(p2Select < 0) { p2Select = charList.size() - 1; } else if(p2Select >= charList.size()) { p2Select = 0; } } //draw character select tempInfo.type = text; if(p1Lock) { tempRec.top = 0.1f; tempRec.bottom = 0.2f; tempRec.left = 0.0f; tempRec.right = 0.5f; p1Name.text = charList[p1Select].name; } else { tempRec.top = (p1Select*(1.0f/charList.size())); tempRec.bottom = tempRec.top + 0.1; tempRec.left = 0.4f; tempRec.right = 0.6f; p1Name.text = "P1"; } p1Name.rect = tempRec; tempInfo.asset = &p1Name; Engine::instance()->addRender(tempInfo); //p1 magic tempRec.left = 0.0f; tempRec.right = 0.5f; for(int i = 0; i < 4; ++i) { tempRec.top = 0.6f+(i*0.1f); tempRec.bottom = 0.7f+(i*0.1f); p1Power[i].text = charList[p1Select].aName[i]; p1Power[i].rect = tempRec; tempInfo.asset = &p1Power[i]; Engine::instance()->addRender(tempInfo); } if(p2Lock) { tempRec.top = 0.1f; tempRec.bottom = 0.2f; tempRec.left = 0.5f; tempRec.right = 1.0f; p2Name.text = charList[p2Select].name; } else { tempRec.top = 0.2+(p2Select*(1.0f/charList.size())); tempRec.bottom = tempRec.top + 0.1; tempRec.left = 0.4f; tempRec.right = 0.6f; p2Name.text = "P2"; } p2Name.rect = tempRec; tempInfo.asset = &p2Name; Engine::instance()->addRender(tempInfo); //p2 magic tempRec.left = 0.5f; tempRec.right = 1.0f; for(int i = 0; i < 4; ++i) { tempRec.top = 0.6f+(i*0.1f); tempRec.bottom = 0.7f+(i*0.1f); p2Power[i].text = charList[p2Select].aName[i]; p2Power[i].rect = tempRec; tempInfo.asset = &p2Power[i]; Engine::instance()->addRender(tempInfo); } tempInfo.type = screenSprite; for(int i = 0; i < charList.size(); ++i) { tempInfo.asset = &charList[i].icon; D3DXMatrixIdentity(&tempInfo.matrix); D3DXMatrixIdentity(&charTrans); D3DXMatrixScaling(&tempInfo.matrix,((float)(Engine::instance()->height()/charList.size()))/charList[i].icon.image->texInfo.Width,((float)(Engine::instance()->height()/charList.size()))/charList[i].icon.image->texInfo.Height,0); D3DXMatrixTranslation(&charTrans,Engine::instance()->width()/2.0f,((Engine::instance()->height()/charList.size())/2.0f)+(i*(Engine::instance()->height()/charList.size())),0); D3DXMatrixMultiply(&tempInfo.matrix,&tempInfo.matrix,&charTrans); Engine::instance()->addRender(tempInfo); } if(p1Lock&&p2Lock) { startDelay -= Engine::instance()->dt(); if(startDelay <= 0) { //start game startTetris(); } } } } else { // GPLAY! tetris.Update(); //draw background tempInfo.type = screenSprite; tempInfo.asset = &charList[p2Select].selectBackground; D3DXMatrixIdentity(&tempInfo.matrix); D3DXMatrixIdentity(&charTrans); D3DXMatrixTranslation(&charTrans,Engine::instance()->width()/2.0f,Engine::instance()->height()/2.0f,0); D3DXMatrixScaling(&tempInfo.matrix,(Engine::instance()->width()*1.0f)/(charList[p2Select].selectBackground.rec.right*1.0f),(Engine::instance()->height()*1.0f)/(charList[p2Select].selectBackground.rec.bottom*1.0f),1.0f); D3DXMatrixMultiply(&tempInfo.matrix,&tempInfo.matrix,&charTrans); Engine::instance()->addRender(tempInfo); tetris.Draw(); // SAD AUST IT CRASHES BECAUSE OF THIS I'M GOING TO BED WTF IS WRONG AAAAAAAAAAAAHHHHHHHHHHHHHHHHHHH // CTRL+F FOR: dammitrender // to get to my other comments showing where things are. // never mind these comments if(Engine::instance()->getMessage("P1Wins")) { p1Won = true; createFinish(); backGround = charList[p1Select].victoryBackground; Engine::instance()->playSound(youwin, soundvec, soundvec); } else if(Engine::instance()->getMessage("P2Wins")) { p1Won = false; createFinish(); backGround = charList[p2Select].victoryBackground; Engine::instance()->playSound(youwin, soundvec, soundvec); } } if(showFPS) { fps = 1/Engine::instance()->dt(); sprintf(buffer,"%d",(int)fps); fpsText.text = buffer; tempInfo.type = text; tempInfo.asset = &fpsText; Engine::instance()->addRender(tempInfo); } Engine::instance()->render(); Engine::instance()->clearMessages(); return play; }
AnovaBayesian::AnovaBayesian(int id) : Analysis(id, "AnovaBayesian", createOptions()) { }
ViewerState::ViewerState(const std::string& stateID, GUI* gui, ModelViewer& modelViewer) : GUIState(stateID, gui) { createSliders(); createOptions(); p_modelViewer = &modelViewer; }
osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const osgDB::ReaderWriter::Options* options) { osg::ref_ptr<osgDB::Options> local_options = createOptions(options); local_options->setOptionString("main"); typedef std::vector< osg::ref_ptr<osg::Node> > NodeList; NodeList nodeList; std::string filename; while (arguments.read("--image",filename)) { osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get()); if (image.valid()) nodeList.push_back(osg::createGeodeForImage(image.get())); } while (arguments.read("--movie",filename)) { osg::ref_ptr<osg::Image> image = readImageFile(filename.c_str(), local_options.get()); osg::ref_ptr<osg::ImageStream> imageStream = dynamic_cast<osg::ImageStream*>(image.get()); if (image.valid()) { imageStream->play(); nodeList.push_back(osg::createGeodeForImage(imageStream.get())); } } while (arguments.read("--dem",filename)) { osg::HeightField* hf = readHeightFieldFile(filename.c_str(), local_options.get()); if (hf) { osg::Geode* geode = new osg::Geode; geode->addDrawable(new osg::ShapeDrawable(hf)); nodeList.push_back(geode); } } // note currently doesn't delete the loaded file entries from the command line yet... for(int pos=1;pos<arguments.argc();++pos) { if (!arguments.isOption(pos)) { // not an option so assume string is a filename. osg::Node *node = osgDB::readNodeFile( arguments[pos], local_options.get()); if(node) { if (node->getName().empty()) node->setName( arguments[pos] ); nodeList.push_back(node); } } } if (nodeList.empty()) { return NULL; } osg::ref_ptr<osg::Node> root; if (nodeList.size()==1) { root = nodeList.front().get(); } else // size >1 { osg::Switch* sw = new osg::Switch; for(NodeList::iterator itr=nodeList.begin(); itr!=nodeList.end(); ++itr) { sw->addChild((*itr).get()); } sw->setSingleChildOn(0); sw->setEventCallback(new p3d::ShowEventHandler()); root = sw; } if (root.valid()) { osg::notify(osg::INFO)<<"Got node now adding callback"<<std::endl; AddVolumeEditingCallbackVisitor avecv; root->accept(avecv); } return root; }
// Included in DirectSpawnerTest.cpp and SmartSpawnerTest.cpp. typedef boost::shared_ptr<Spawner> SpawnerPtr; TEST_METHOD(1) { set_test_name("Basic spawning test"); SpawningKit::AppPoolOptions options = createOptions(); options.appRoot = "stub/rack"; options.startCommand = "ruby start.rb"; options.startupFile = "start.rb"; SpawnerPtr spawner = createSpawner(options); result = spawner->spawn(options); ensure_equals(result.sockets.size(), 1u); FileDescriptor fd(connectToServer(result.sockets[0].address, __FILE__, __LINE__), NULL, 0); writeExact(fd, "ping\n"); ensure_equals(readAll(fd, 1024).first, "pong\n"); } TEST_METHOD(2) { set_test_name("It enforces the given start timeout"); SpawningKit::AppPoolOptions options = createOptions(); options.appRoot = "stub"; options.startCommand = "sleep 60"; options.startupFile = "."; options.startTimeout = 100; if (defaultLogLevel == (LoggingKit::Level) DEFAULT_LOG_LEVEL) { // If the user did not customize the test's log level, // then we'll want to tone down the noise.