//初始化方法 bool AppDelegate::applicationDidFinishLaunching() { //获取导演 auto director = Director::getInstance(); //获取绘制用GLView auto glview = director->getOpenGLView(); //若不存在glview则重新创建 if(!glview) { glview = GLView::create("Test Cpp"); } //设置绘制用GLView director->setOpenGLView(glview); //设置目标分辨率,别的分辨率的屏幕将自动上下或左右留白进行多分辨率自适应 glview->setDesignResolutionSize(540,960, kResolutionShowAll); //设置为显示FPS等信息 director->setDisplayStats(false); //系统模拟时间间隔 director->setAnimationInterval(1.0 / 60); //创建欢迎场景 auto scene = new GameSceneManager(); scene->createMainScene(); //跌换到欢迎场景显示 director->runWithScene(scene->mainScene); //加载音乐 initSound(); return true; }
//------------------------------------------------------------------------------------- bool BaseApplication::setup(void) { mRoot = std::shared_ptr<Ogre::Root>(new Ogre::Root(mPluginsCfg)); setupResources(); bool carryOn = configure(); if (!carryOn) return false; chooseSceneManager(); createCamera(); createViewports(); // Set default mipmap level (NB some APIs ignore this) Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); // Create any resource listeners (for loading screens) createResourceListener(); // Load resources loadResources(); initSound(); // Create the scene createScene(); createFrameListener(); return true; };
int main(int argc, char *argv[]) { int done = 0; long prvTickCount = 0; int i; int btn; SDL_Event event; long nowTick; int frame; parseArgs(argc, argv); initDegutil(); initSDL(windowMode); if ( !noSound ) initSound(); initFirst(); initTitle(); while ( !done ) { SDL_PollEvent(&event); keys = SDL_GetKeyState(NULL); if ( keys[SDLK_ESCAPE] == SDL_PRESSED || event.type == SDL_QUIT ) done = 1; if ( keys[SDLK_p] == SDL_PRESSED ) { if ( !pPrsd ) { if ( status == IN_GAME ) { status = PAUSE; } else if ( status == PAUSE ) { status = IN_GAME; } } pPrsd = 1; } else { pPrsd = 0; } nowTick = SDL_GetTicks(); frame = (int)(nowTick-prvTickCount) / interval; if ( frame <= 0 ) { frame = 1; SDL_Delay(prvTickCount+interval-nowTick); if ( accframe ) { prvTickCount = SDL_GetTicks(); } else { prvTickCount += interval; } } else if ( frame > 5 ) { frame = 5; prvTickCount = nowTick; } else { prvTickCount += frame*interval; } for ( i=0 ; i<frame ; i++ ) { move(); tick++; } smokeScreen(); draw(); flipScreen(); } quitLast(); }
JNIEXPORT jint JNICALL Java_net_xtapi_serviceProvider_MSTAPI_initTapi (JNIEnv *pEnv, jobject oObj) { unsigned long dwNumLines; g_thisObj = oObj; g_env = pEnv; long lRet = InitTapi(&dwNumLines); if(0 == lRet) { // Success! jclass cls; jfieldID fld; cls = g_env->GetObjectClass(g_thisObj); fld = g_env->GetFieldID(cls,"m_numLines","I"); g_env->SetIntField(g_thisObj, fld, dwNumLines); initSound(dwNumLines); } else return - 1; SecondaryThread(0); return 0; }
int main( int argc, char *argv[] ) { char *path; #ifdef __FreeBSD__ fpsetmask(0); #endif SystemInit(&argc, argv); path = getFullPath("settings.txt"); if(path != 0) initMainGameSettings(path); /* reads defaults from ~/.gltronrc */ else { printf("fatal: could not settings.txt, exiting...\n"); exit(1); } parse_args(argc, argv); /* sound */ #ifdef SOUND printf("initializing sound\n"); initSound(); path = getFullPath("gltron.it"); if(path == 0 || loadSound(path)) printf("error trying to load sound\n"); else { if(game->settings->playMusic) playSound(); free(path); } #endif printf("loading menu\n"); path = getFullPath("menu.txt"); if(path != 0) pMenuList = loadMenuFile(path); else { printf("fatal: could not load menu.txt, exiting...\n"); exit(1); } printf("menu loaded\n"); free(path); initGameStructures(); resetScores(); initData(); setupDisplay(game->screen); switchCallbacks(&guiCallbacks); switchCallbacks(&guiCallbacks); SystemMainLoop(); return 0; }
void OpenALPlayer::init() { //Taken from http://www.gamedev.net/page/resources/_/technical/game-programming/a-guide-to-starting-with-openal-r2008 (26.12.2014) alutInit(0, nullptr); //Audio data - Similar to http://www.edenwaith.com/products/pige/tutorials/openal.php (26.12.2014) alListenerfv(AL_POSITION, listenerPos); alListenerfv(AL_VELOCITY, listenerVel); //alListenerfv(AL_ORIENTATION, instance->listenerOri); ALenum error = alGetError(); if (error != AL_NO_ERROR) { qDebug() << "some rror"; } initSound(moveSources, &moveBufferNumber, "resources/sound/move.wav"); initSound(eatSources, &eatBufferNumber, "resources/sound/eat.wav"); initSound(hitSources, &hitBufferNumber, "resources/sound/hit.wav"); }
Player::Player(sf::Vector2f position): playerVel(0.0), fireMod(0.0), isHit(false) { if(!initSound(hurtBuf, hurtSound, "ouch.wav", 95.0f) || !initSound(rocketBuf, rocketSound, "rocketloop.wav", 70.0f)) throw E_SOUND_INIT_FAILURE; rocketSound.setLoop(true); playerT.setPointCount(3); playerT.setPoint(0, sf::Vector2f(0, 0)); playerT.setPoint(1, sf::Vector2f(6, 15)); playerT.setPoint(2, sf::Vector2f(12, 0)); playerT.setOrigin(6, 6); playerT.setFillColor(sf::Color(0, 0, 0)); playerT.setOutlineColor(sf::Color(255, 255, 255)); playerT.setOutlineThickness(2); playerT.setPosition(position); }
//-------------------------------------------------------------- const SoundItem & SoundMixer::addSound(std::string soundPath, std::string soundID) { sounds.push_back(initSound()); SoundItem & sound = *sounds.back(); sound.soundPath = soundPath; sound.soundID = soundID; if(sound.soundID.length() == 0) { sound.soundID = sound.soundPath; } return sound; }
// Initialize and load preference. static void initFirst() { time_t timer; time(&timer); srand(timer); loadPreference(); initBarragemanager(); initAttractManager(); if ( !noSound ) initSound(); initGameStateFirst(); }
void SoundEmitter::startSound(RealWorldViewPoint* viewpoint) { if (isActive()) { if (!getSource()) { initSound(viewpoint) ; } alSourcePlay(getSource()); } }
bool GameLayer::init() { bool bRet = false; do { CCLayer::init(); initView(); initSound(); this->setTouchEnabled(true); this->setKeypadEnabled(true); scheduleUpdate(); bRet = true; } while (0); return bRet; }
CRRCAirplaneV2::CRRCAirplaneV2(SimpleXMLTransfer* xml) { printf("CRRCAirplaneV2(xml)\n"); // initialize the airplane's sound initSound(xml); // initialize the visual representation // first collect all relevant information from the model file std::string s; s = XMLModelFile::getGraphics(xml)->getString("model"); // Offset of center of gravity CRRCMath::Vector3 pCG; pCG = CRRCMath::Vector3(0, 0, 0); if (xml->indexOfChild("CG") >= 0) { SimpleXMLTransfer* i; i = xml->getChild("CG"); pCG.r[0] = i->attributeAsDouble("x", 0); pCG.r[1] = i->attributeAsDouble("y", 0); pCG.r[2] = i->attributeAsDouble("z", 0); if (i->attributeAsInt("units") == 1) pCG *= M_TO_FT; } // plib automatically loads the texture file, but it does not know which directory to use. // where is the object file? std::string of = FileSysTools::getDataPath("objects/" + s); // compile and set relative texture path std::string tp = of.substr(0, of.length()-s.length()-1-7) + "textures"; lVisID = Video::new_visualization(of, tp, pCG, xml); if (lVisID == INVALID_AIRPLANE_VISUALIZATION) { std::string msg = "Unable to open airplane model file \""; msg += s; msg += "\"\nspecified in \""; msg += xml->getSourceDescr(); msg += "\""; throw std::runtime_error(msg); } }
bool Map::initMap(int x, int y) { initSound(); _mapX = x; _mapY = y; _map = new Cell *[_mapX]; for (int i = 0; i < _mapX; i++) _map[i] = new Cell[_mapY]; for (int j = 0; j < 7; j++) { if (!_stoneTex[j].loadFromFile(STONESET, sf::IntRect(j * SPRITE_W, 0, SPRITE_W, SPRITE_H))) { std::cerr << "Error : can't load stones tileset." << std::endl; return (false); } _stoneSprite[j].setTexture(_stoneTex[j]); } return (true); }
void Player_SID::startSound(int nr) { byte *data = _vm->getResourceAddress(rtSound, nr); assert(data); // WORKAROUND: // sound[4] contains either a song prio or a music channel usage byte. // As music channel usage is always 0x07 for all music files and // prio 7 is never used in any sound file use this byte for auto-detection. bool isMusic = (data[4] == 0x07); Common::StackLock lock(_mutex); if (isMusic) { initMusic(nr); } else { stopSound_intern(nr); initSound(nr); } }
void EvaGlobal::initialize() { dirPath = KGlobal::dirs()->findResource("data", QString::fromLatin1("eva/servers")); // QStringList dirs = KGlobal::dirs()->findDirs("data", QString::fromLatin1("eva")); // for(uint i=0; i<dirs.size(); i++){ // //printf("dir %i:%s\n", i, dirs[i].ascii()); // //dirPath = dirs[0]; // break; // } if(dirPath == QString::null){ QFileInfo fi; fi.setFile(QString(getenv("_"))); dirPath = fi.dirPath(true); }else dirPath = dirPath.left(dirPath.length() - strlen("/servers")); //printf("found data path: %s\n", dirPath.ascii()); initImage(); initSound(); initEvaSetting(); initServers(); }
int main(){ initScreen(); initSound(); initLedButtons(); lcdTest(); while(1){ fillBoard(); printBoard(); for (int i = 0; i < 100; i++){ setLeds((char)i); setFrequency(120*(i%20)); playerStep(); printBoard(); playSounds(); if (readButtons() & 0x01 > 0) break; } } closeLedButtons(); closeScreen(); closeSound(); }
kpok::kpok(QWidget *parent, const char *name) : QWidget(parent, name), m_game(&m_random) { QString version; m_random.setSeed(0); // This class owns the players. Create them here. // Currently we always allocate two - one human and one computer. m_numPlayers = 2; // FIXME: Hard coded!! m_players = new PokerPlayer[m_numPlayers]; // Initialize the first one to human... m_players[0].setHuman(); m_players[0].setName(i18n("You")); // ...and the rest to computer players. for (int unsigned i = 1; i < m_numPlayers; i++) m_players[i].setName(QString("Computer %1").arg(i-1)); lastHandText = ""; version = kapp->caption() + " " + KPOKER_VERSION; setCaption( version ); mOptions = 0; playerBox = 0; adjust = false; initWindow(); // FIXME: Change this name!!! initSound(); if (!readEntriesAndInitPoker()) exit(0); }
//-------------------------------------------------------------- void ofApp::update() { if(soundPath != "") { initSound(soundPath); soundPath = ""; } if(fft.bFrameSync == false) { return; } int soundFrameIndex = fft.frameSyncIndex; fft.update(); vector<float> & soundData = fft.fftData.data; unsigned char * soundImagePixels = soundImage.getPixels().getData(); int soundImageIndex = soundFrameIndex * numOfPixelsPerSoundFrame; for(int i=0; i<numOfPixelsPerSoundFrame; i++) { float d0 = soundData[i+0]; float d1 = soundData[i+1]; float data = MAX(d0, d1); int j = soundImageIndex + i; soundImagePixels[j] = data * 255; } soundImage.update(); bool bExportFinished = (fft.bFrameSync == false); if(bExportFinished == true) { saveSound(); ofSetFrameRate(30); ofSetVerticalSync(true); } }
void Gui::guiEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); int kind = e.widget->getKind(); // ofxUIWidget* parent = e.widget->getParent(); // if (parent != NULL && parent->getKind() == OFX_UI_WIDGET_DROPDOWNLIST) { // ofxUILabelToggle* toggle = (ofxUILabelToggle *) e.widget; // if (!toggle->getValue()) { // return; // } // name = parent->getName(); // } cout << "got event from: " << name << endl; if (name == "RESOLUTION") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setResolution(slider->getValue()); } else if (name == "VCOUNT") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setVCount(slider->getValue()); } else if (name == "VWIDTH") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setVWidth(slider->getValue()); } else if (name == "HCOUNT") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setHCount(slider->getValue()); } else if (name == "HWIDTH") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setHWidth(slider->getValue()); } else if (name == "VCOLORS") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setVColors(slider->getValue()); } else if (name == "HCOLORS") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setHColors(slider->getValue()); } else if (name == "COLORES") { ofxUISlider *slider = (ofxUISlider *) e.widget; grid->setColorRes(slider->getValue()); } else if (name == "SOUND") { initSound(); } else if (name == "SMOOTHING") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.widget; sound->setSmoothing(slider->getValue()); } else if (name == "THRESHOLD") { ofxUIIntSlider *slider = (ofxUIIntSlider *) e.widget; sound->setThreshold(slider->getValue()); } else if (name == "MIDI") { initMidi(); } else if (name == "Refresh") { midiDropDown->clearToggles(); midiDropDown->addToggles(midi->getPortList()); } else if (name == "OSC") { ofxUINumberDialer *numberDialer = (ofxUINumberDialer *) e.widget; osc->setup(numberDialer->getValue()); } }
void initGame(void) { lcdMainOnTop(); int oldv=getMemFree(); NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("initializing..."); videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); glInit(); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000); vramSetBankH(VRAM_H_SUB_BG); vramSetBankI(VRAM_I_SUB_BG_0x06208000); glEnable(GL_TEXTURE_2D); // glEnable(GL_ANTIALIAS); glDisable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(31,0,0)); //TEMP? glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? glClearColor(31,31,0,31); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); // initVramBanks(1); initVramBanks(2); initTextures(); initSound(); initCamera(NULL); initPlayer(NULL); initLights(); initParticles(); initMaterials(); loadMaterialSlices("slices.ini"); loadMaterials("materials.ini"); loadControlConfiguration("config.ini"); initElevators(); initWallDoors(); initTurrets(); initBigButtons(); initTimedButtons(); initEnergyBalls(); initPlatforms(); initCubes(); initEmancipation(); initDoors(); initSludge(); initPause(); initText(); NOGBA("lalala"); getPlayer()->currentRoom=&gameRoom; currentBuffer=false; getVramStatus(); fadeIn(); mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgSetPriority(mainBG, 0); REG_BG0CNT=BG_PRIORITY(3); #ifdef DEBUG_GAME consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true); consoleSelect(&bottomScreen); #endif // glSetToonTableRange(0, 14, RGB15(16,16,16)); // glSetToonTableRange(15, 31, RGB15(26,26,26)); initPortals(); //PHYSICS initPI9(); strcpy(&mapFilePath[strlen(mapFilePath)-3], "map"); newReadMap(mapFilePath, NULL, 255); transferRectangles(&gameRoom); makeGrid(); generateRoomGrid(&gameRoom); gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false); getVramStatus(); startPI(); NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv); levelInfoCounter=60; }
void Game::init() { #ifdef WIN32 device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(640, 480)); #else device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480)); #endif driver = device->getVideoDriver(); smgr = device->getSceneManager(); guienv = device->getGUIEnvironment(); device->setWindowCaption(L"Not So Much Super Offroad - By Andreas Kröhnke"); IMeshSceneNode *node = smgr->addMeshSceneNode( smgr->getMesh("data/car3.3ds")->getMesh(0) ); GameObject *car = new GameObject(); car->setSceneNode(node); node->setMaterialFlag(EMF_LIGHTING, false); node->setScale(vector3df(0.09,0.09,0.09)); node->setRotation(vector3df(0,0,0)); node->setPosition(vector3df(3454,500,1256)); //node->setDebugDataVisible(EDS_BBOX); object->push_back(car); ITerrainSceneNode *terrain = smgr->addTerrainSceneNode("data/level1.bmp"); GameObject *go_terrain = new GameObject(); go_terrain->setSceneNode(terrain); terrain->setMaterialFlag(EMF_LIGHTING, false); terrain->setScale(core::vector3df(18, 3.0f, 18)); terrain->setMaterialFlag(video::EMF_LIGHTING, false); terrain->setMaterialTexture(0, driver->getTexture("data/terrain-texture.jpg")); terrain->setMaterialTexture(1, driver->getTexture("data/detailmap3.jpg")); terrain->setMaterialType(video::EMT_DETAIL_MAP); terrain->scaleTexture(1.0f, 20.0f); terrain->setDebugDataVisible(EDS_BBOX); object->push_back(go_terrain); // Camera Camera *cam = new Camera(); cam->setSceneNode(smgr->addCameraSceneNode()); object->push_back(cam); cam->followNode(car->getSceneNode()); reciever = new EventReciever(); reciever->setSteer(car->getSceneNode()); device->setEventReceiver(reciever); // create triangle selector for the terrain ITriangleSelector* selector = smgr->createTerrainTriangleSelector(terrain, 0); terrain->setTriangleSelector(selector); selector->drop(); // create collision response animator and attach it to the camera ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(selector, car->getSceneNode(), core::vector3df(10,10,10), core::vector3df(0,-5.0f,0), core::vector3df(0,0,0) ); car->getSceneNode()->addAnimator(anim); anim->drop(); // Skybox smgr->addSkyBoxSceneNode( driver->getTexture("data/irrlicht2_up.jpg"), driver->getTexture("data/irrlicht2_dn.jpg"), driver->getTexture("data/irrlicht2_lf.jpg"), driver->getTexture("data/irrlicht2_rt.jpg"), driver->getTexture("data/irrlicht2_ft.jpg"), driver->getTexture("data/irrlicht2_bk.jpg")); // Checkpoints pair<vector3df, vector3df> cp1(vector3df(3112,393,1234), vector3df(90,90,0)); addCheckPoint(cp1.first, cp1.second); pair<vector3df, vector3df> cp2(vector3df(2531,281,1389), vector3df(90,120,0)); addCheckPoint(cp2.first, cp2.second); addCheckPoint(vector3df(2304,160,1826), vector3df(90,140,0)); addCheckPoint(vector3df(2132,111,2672), vector3df(90,120,0)); addCheckPoint(vector3df(1130,415,3313), vector3df(90,75,0)); addCheckPoint(vector3df(746,471,1753), vector3df(90,0,0)); addCheckPoint(vector3df(1985,269,1457), vector3df(90,-120,0)); addCheckPoint(vector3df(2475,146,2868), vector3df(90,-120,0)); addCheckPoint(vector3df(3707,417,2915), vector3df(90,-60,0)); // Arrows addArrow(vector3df(3012,320,1234), vector3df(100,-55,0)); addArrow(vector3df(2531,220,1389), vector3df(100,-10,0)); //addArrow(vector3df(2304,110,1826), vector3df(90,10,0)); addArrow(vector3df(2232,20,2272), vector3df(90,-20,0)); // HUD info = guienv->addStaticText(L"USE ARROW KEYS TO PLAY", rect<int>(10,10,200,60), true); info->setOverrideColor(SColor(255, 255, 255, 255)); //IGUIStaticText *quick_info = guienv->addStaticText(L"Arrow keys to play\n", rect<int>(10,50,200,50), true); //quick_info->setOverrideColor(SColor(255,255,255,255)); initSound(); }
static void init() { bool error = true; HANDLE hMapping = OpenFileMapping(FILE_MAP_READ,FALSE,_T("__kkapture_parameter_block")); if(hMapping == 0) // no parameter block available. return; InitializeCriticalSection(&shuttingDown); // initialize params with all zero (ahem) initLog(); printLog("main: initializing...\n"); memset(¶ms,0,sizeof(params)); // get file mapping containing capturing info ParameterBlock *block = (ParameterBlock *) MapViewOfFile(hMapping,FILE_MAP_READ,0,0,sizeof(ParameterBlock)); if(block) { // correct version if(block->VersionTag == PARAMVERSION) { memcpy(¶ms,block,sizeof(params)); error = false; } UnmapViewOfFile(block); } CloseHandle(hMapping); // if kkapture is being debugged, wait for the user to attach the debugger to this process if(params.IsDebugged) { // create message window HWND waiting = CreateWindowEx(0,"STATIC", "Please attach debugger now.",WS_POPUP|WS_DLGFRAME|SS_CENTER|SS_CENTERIMAGE,0,0,240,50,0,0, GetModuleHandle(0),0); SendMessage(waiting,WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT),TRUE); // center it RECT rcWork,rcDlg; SystemParametersInfo(SPI_GETWORKAREA,0,&rcWork,0); GetWindowRect(waiting,&rcDlg); SetWindowPos(waiting,0,(rcWork.left+rcWork.right-rcDlg.right+rcDlg.left)/2, (rcWork.top+rcWork.bottom-rcDlg.bottom+rcDlg.top)/2,-1,-1,SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // show it and wait for user to attach debugger ShowWindow(waiting,SW_SHOW); while(!IsDebuggerPresent()) { MSG msg; while(PeekMessage(&msg,0,0,0,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } Sleep(10); } // user has attached the debugger, bring window to foreground then destroy it SetForegroundWindow(waiting); ShowWindow(waiting,SW_HIDE); MessageBox(waiting,"Debugger attached, set any breakpoints etc. you need to and press OK.","kkapture", MB_ICONINFORMATION|MB_OK); DestroyWindow(waiting); } // rest of initialization code initTiming(true); initVideo(); initSound(); initProcessIntercept(); printLog("main: all main components initialized.\n"); if(error) { printLog("main: couldn't access parameter block or wrong version\n"); frameRateScaled = 1000; frameRateDenom = 100; encoder = new DummyVideoEncoder; } else { printLog("main: reading parameter block...\n"); frameRateScaled = params.FrameRateNum; frameRateDenom = params.FrameRateDenom; encoder = 0; } // install our hook so we get notified of process exit (hopefully) HookFunction(&Real_ExitProcess, Mine_ExitProcess); hHookThread = (HANDLE) _beginthread(HookThreadProc,0,0); initialized = true; printLog("main: initialization done\n"); }
int main( int argc, char *argv[] ) { char *path; list *l; #ifdef SOUND int c; #endif #ifdef __FreeBSD__ fpsetmask(0); #endif #ifdef macintosh setupHomeEnvironment (); #endif SystemInit(&argc, argv); #ifndef CURRENT_EQ_DATA_DIR goto_installpath(argv[0]); #endif /* initialize artpack list before loading settigns! */ initArtpacks(); path = getFullPath("settings.txt"); if(path != NULL) initMainGameSettings(path); /* reads defaults from ~/.gltronrc */ else { printf("fatal: could not settings.txt, exiting...\n"); exit(1); } parse_args(argc, argv); consoleInit(); initGameStructures(); resetScores(); /* sound */ path = getMusicPath(MUSIC_DIR); game->settings->soundList = readDirectoryContents(path, SONG_PREFIX); game->settings->soundIndex = -1; l = game->settings->soundList; #ifdef SOUND printf("initializing sound\n"); initSound(); setFxVolume(game->settings->fxVolume); if(l->next != NULL) { char *tmp; tmp = malloc(strlen(path) + 1 + /* seperator */ strlen((char*) l->data) + 1); sprintf(tmp, "%s%c%s", path, SEPERATOR, (char*) l->data); fprintf(stderr, "loading song %s\n", tmp); loadSound(tmp); free(tmp); game->settings->soundIndex = 0; } c = 0; while(l->next != NULL) { l = l->next; c++; } game->settings->soundSongCount = c; if(game->settings->playMusic) playSound(); fprintf(stderr, "setting music volume to %.3f\n", game->settings->musicVolume); setMusicVolume(game->settings->musicVolume); free(path); #endif printf("loading menu\n"); path = getFullPath("menu.txt"); if(path != NULL) pMenuList = loadMenuFile(path); else { printf("fatal: could not load menu.txt, exiting...\n"); exit(1); } printf("menu loaded\n"); free(path); setupDisplay(game->screen); switchCallbacks(&guiCallbacks); switchCallbacks(&guiCallbacks); SystemMainLoop(); return 0; }
/** * Author: Joel Denke, Marcus Isaksson * Description: Run the game on client */ int main(int argc, char *argv[]) { int i, j, no, yb, keysHeld[323] = {0}; int result = 0; SDL_Thread * eventBuffer; SDL_Thread * runBuffer; struct timer_t2 fps; char * server_ip = malloc(sizeof(char) * 16); char * elem = malloc(sizeof(char) * MESSAGE_SIZE); pColor = malloc(sizeof(SDL_Color)); oColor = malloc(sizeof(SDL_Color)); connection = malloc(sizeof(connection_data)); for (i = 0; i < NO_BUFFERS; i++) { cb[i] = malloc(sizeof(cBuffer)); b_lock[i] = SDL_CreateMutex(); } strcpy(server_ip, "127.0.0.1"); pColor->r = 0; pColor->g = 255; pColor->b = 255; oColor->r = 0; oColor->g = 0; oColor->b = 255; initGraphics(); initSound(); printf("Render menu\n"); graphicsMenu(&gameWorld, server_ip); initSlots(cb[0], BUFFER_SIZE); initSlots(cb[1], NO_OBJECTS); initSlots(cb[2], BUFFER_SIZE); state = gStart; if (clientConnect(connection, server_ip) == 0) { eventBuffer = SDL_CreateThread(listenEventBuffer, &connection); while (1) { switch (state) { case gStart: runData(2); break; case gInit: timer_start(&fps); startDraw(); drawLoadScr(SCREEN_WIDTH, SCREEN_HEIGHT); endDraw(); initWorld(); if (timer_get_ticks(&fps) < 1000 / FPS) { //delay the as much time as we need to get desired frames per second SDL_Delay( ( 1000 / FPS ) - timer_get_ticks(&fps) ); } break; case gRunning : timer_start(&fps); drawGraphics(); listenInput(keysHeld); // i = 0: players; i = 1: objects; i = 2: messages for (i = 0; i < NO_BUFFERS; i++) { runData(i); } if (timer_get_ticks(&fps) < 1000 / FPS) { //delay the as much time as we need to get desired frames per second SDL_Delay( ( 1000 / FPS ) - timer_get_ticks(&fps) ); } break; case gExit : //sprintf(string, "%d,quit", connection->client_id); printf("Freeing music now\n"); pauseMusic(); freeMusic(); end_session(connection); printf("Player is exit game now\n"); exitClient(eventBuffer); break; default : printf("test\n"); break; } } } else { printf("Misslyckade med att kontakta servern på ip-adress: '%s'\n", server_ip); state = gExit; pauseMusic(); freeMusic(); exitClient(eventBuffer); } return 0; }
GameEnvironment::GameEnvironment() { std::cout << "Konstruktor gameenvironment" << std::endl; initVariables(); try { initModels(); } catch (Exception e) { MessageBoxA(NULL, "Oops, something went wrong :(\nPlease press OK and restart game", "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } try { initCollision(); } catch (LoadingFileError e) { MessageBoxA(NULL, e.type().c_str(), "Error", MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL); } catch (Exception e) { MessageBoxA(NULL, "Oops, something went wrong :(\nPlease press OK and restart game", "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } try { initSound(); } catch (InitFmodError e) { MessageBoxA(NULL, e.type().c_str(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } catch (SoundError e) { MessageBoxA(NULL, e.type().c_str(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } catch (Exception e) { MessageBoxA(NULL, "Oops, something with sounds went wrong :(\nPlease press OK and restart game", "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } try { initShaders(); } catch (LoadingFileError e) { MessageBoxA(NULL, e.type().c_str(), "Error", MB_OK | MB_ICONWARNING | MB_SYSTEMMODAL); } catch (Exception e) { MessageBoxA(NULL, "Oops, something went wrong :(\nPlease press OK and restart game", "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); exit(0); } }
bool rd::RobotDevastation::configure(yarp::os::ResourceFinder &rf) { //-- Show help //printf("--------------------------------------------------------------\n"); if (rf.check("help")) { printf("RobotDevastation options:\n"); printf("\t--help (this help)\t--from [file.ini]\t--context [path]\n"); printf("\t--id integer\n"); printf("\t--name string\n"); printf("\t--team integer\n"); printf("\t--robotName string\n"); // Do not exit: let last layer exit so we get help from the complete chain. } printf("RobotDevastation using no additional special options.\n"); //-- Get player data //----------------------------------------------------------------------------- if( ! rf.check("id") ) { RD_ERROR("No id!\n"); return false; } RD_INFO("id: %d\n",rf.find("id").asInt()); if( ! rf.check("name") ) { RD_ERROR("No name!\n"); return false; } RD_INFO("name: %s\n",rf.find("name").asString().c_str()); if( ! rf.check("team") ) { RD_ERROR("No team!\n"); return false; } RD_INFO("team: %d\n",rf.find("team").asInt()); if( ! rf.check("robotName") ) { RD_ERROR("No robotName!\n"); return false; } RD_INFO("robotName: %s\n",rf.find("robotName").asString().c_str()); //-- Init mentalMap mentalMap = RdMentalMap::getMentalMap(); mentalMap->configure( rf.find("id").asInt() ); std::vector< RdPlayer > players; players.push_back( RdPlayer(rf.find("id").asInt(),std::string(rf.find("name").asString()),100,100,rf.find("team").asInt(),0) ); mentalMap->updatePlayers(players); mentalMap->addWeapon(RdWeapon("Default gun", 10, 5)); //-- Init input manager RdSDLInputManager::RegisterManager(); inputManager = RdInputManager::getInputManager("SDL"); inputManager->addInputEventListener(this); if (!inputManager->start() ) { RD_ERROR("Could not init inputManager!\n"); return false; } //-- Init sound if( ! initSound( rf ) ) return false; if( ! rf.check("noMusic") ) audioManager->play("bso", -1); //-- Init robot if( rf.check("mockupRobotManager") ) { robotManager = new RdMockupRobotManager(rf.find("robotName").asString()); } else { robotManager = new RdYarpRobotManager(rf.find("robotName").asString()); } if( ! robotManager->connect() ) { RD_ERROR("Could not connect to robotName \"%s\"!\n",rf.find("robotName").asString().c_str()); RD_ERROR("Use syntax: robotDevastation --robotName %s\n",rf.find("robotName").asString().c_str()); return false; } //-- Init network manager RdYarpNetworkManager::RegisterManager(); networkManager = RdYarpNetworkManager::getNetworkManager(RdYarpNetworkManager::id); networkManager->addNetworkEventListener(mentalMap); mentalMap->addMentalMapEventListener((RdYarpNetworkManager *)networkManager); networkManager->login(mentalMap->getMyself()); //-- Init image manager if( rf.check("mockupImageManager") ) { RdMockupImageManager::RegisterManager(); imageManager = RdImageManager::getImageManager(RdMockupImageManager::id); } else { RdYarpImageManager::RegisterManager(); imageManager = RdImageManager::getImageManager(RdYarpImageManager::id); } //-- Add the image processing listener to the image manager imageManager->addImageEventListener(&processorImageEventListener); //-- Configure the camera port std::ostringstream remoteCameraPortName; //-- Default looks like "/0/rd1/img:o" remoteCameraPortName << "/"; remoteCameraPortName << rf.find("robotName").asString(); remoteCameraPortName << "/img:o"; imageManager->configure("remote_img_port", remoteCameraPortName.str() ); std::ostringstream localCameraPortName; //-- Default should look like "/0/robot/img:i" localCameraPortName << "/"; localCameraPortName << rf.find("id").asInt(); localCameraPortName << "/robot/img:i"; imageManager->configure("local_img_port", localCameraPortName.str() ); //-- Name given by me if( ! imageManager->start() ) return false; //-- Init output thread rateThreadOutput.init(rf); return true; }
int main(int argc, char *argv[]) { int doScale=0; // 0=Undefined, 1=320x240, -1=OpenGL, >1=SwScale char* dumpPack=NULL; int state=1; //Game, Menu, Editor, Quit int sdlVideoModeFlags = SDL_SWSURFACE; #ifdef PSP //Note to PSP porter, please test if HW is actually faster, Wizznic does a lot of memory-manipulation in the screen-surface, each call might initiate a full copy back/forth from video memory. Remove comment when read. :) sdlVideoModeFlags = (SDL_HWSURFACE | SDL_DOUBLEBUF |SDL_HWACCEL); SetupCallbacks();//Callbacks actifs scePowerSetClockFrequency(333,333,166); #endif // #ifdef WIN32 //Redirect stdout to console on windows, so we can see what's going in. // FILE *stream; // stream = freopen("CON", "w", stdout); // #endif //Print welcome message printf( "Wizznic "VERSION_STRING". GPLv3 or newer Copyleft 2010-2013\n\n"); //initialize path strings initUserPaths(); //Tell where stuff's at. printf("Directories:\n Settings: %s\n DLC: %s\n Highscores: %s\n Editorlevels: %s\n Datafiles: %s\n\n", \ getConfigDir(), getUsrPackDir(), getHighscoreDir(), getUserLevelDir(), (!strlen(DATADIR))?".":DATADIR); //Print the command line parameters printf("Command-line parameters:\n"STR_VID_OPTIONS); //Quit if user wants help if( argc > 1 && ( strcmp(argv[1], "-h")==0 || strcmp(argv[1], "--help")==0 || strcmp(argv[1], "-help")==0 )) { printf("Please see readme.txt or http://wizznic.org/ for more help.\n"); return(0); } //Read settings printf("Loading settings...\n"); initSettings(); #if defined(WITH_OPENGL) //We start by enabling glScaling if it was enabled in settings, it can then be overwritten by command line options. if( setting()->glEnable && doScale==0 ) doScale=-1; #endif //Set scaling setting()->scaleFactor=1.0; atexit(SDL_Quit); //Init SDL if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER ) <0 ) { printf("SDL_Init failed: %s\n",SDL_GetError()); return(-1); } //Setup display #if defined (GP2X) || defined (PSP) || defined (WIZ) SDL_Surface* screen = SDL_SetVideoMode(SCREENW,SCREENH,16, sdlVideoModeFlags); #else SDL_Surface* screen=NULL; int i; for( i=0; i < argc; i++ ) { if( strcmp( argv[i], "-sw" ) == 0 ) { setting()->glEnable=0; doScale=0; saveSettings(); } else if( strcmp( argv[i], "-gl" ) == 0 ) { setting()->glEnable=1; doScale=-1; saveSettings(); } else if( strcmp( argv[i], "-z" ) == 0 ) { if( i+1 < argc ) { doScale = atoi( argv[i+1] ); setting()->glEnable=0; i++; saveSettings(); } else { printf(" -z requires zoom level ( -z 2 for example ).\n"); return(1); } } else if( strcmp( argv[i], "-f" ) == 0 ) { setting()->fullScreen=1; saveSettings(); } else if( strcmp( argv[i], "-w" ) == 0 ) { setting()->fullScreen=0; saveSettings(); } else if( strcmp( argv[i], "-glheight" ) == 0 ) { if( i+1 < argc ) { setting()->glHeight = atoi( argv[i+1] ); setting()->glEnable=1; doScale=-1; i++; printf("Setting OpenGL window height to %i.\n", setting()->glHeight); saveSettings(); } else { printf(" -glheight requires an argument (-1 or size in pixels).\n"); return(1); } } else if( strcmp( argv[i], "-glwidth" ) == 0 ) { if( i+1 < argc ) { setting()->glWidth = atoi( argv[i+1] ); setting()->glEnable=1; doScale=-1; i++; printf("Setting OpenGL window width to %i.\n", setting()->glWidth); saveSettings(); } else { printf(" -glwidth requires an argument (-1 or size in pixels).\n"); return(1); } } else if( strcmp( argv[i], "-glfilter" ) == 0 ) { if( i+1 < argc ) { setting()->glFilter=atoi(argv[i+1]); printf("OpenGL texture filtering set to %s.\n", (setting()->glFilter)?"Smooth":"Off"); i++; saveSettings(); } else { printf("-glfilter requires 0 or 1 as argument.\n"); return(1); } } else if( strcmp( argv[i] , "-d" ) == 0 ) { if( argc == 3 && i < argc+1 ) { dumpPack = malloc( sizeof(char)*strlen(argv[i+1])+1 ); strcpy( dumpPack, argv[i+1] ); doScale=0; setting()->glEnable=0; i++; } else { printf("-d requires a packname, and must not be used with other parameters.\n"); return(1); } } else if( strcmp( argv[i], "-rift") == 0 ) { setting()->glWidth = 1280; setting()->glHeight = 800; setting()->glEnable=1; setting()->rift=1; doScale=-1; } else if( i > 0 ) { printf("\nError: Invalid argument '%s', quitting.\n", argv[i]); return(1); } } if( setting()->fullScreen ) { sdlVideoModeFlags |= SDL_FULLSCREEN; } if(doScale) { //Hardware accelerated scaling if( doScale == -1 ) { #ifdef HAVE_ACCELERATION printf("Enabling platform specific accelerated scaling.\n"); screen = platformInitAccel(sdlVideoModeFlags); if( !screen ) { printf("Failed to set platform accelerated scaling, falling back to software window.\n"); screen=swScreen(SDL_SWSURFACE); doScale=0; } #else printf("\nError:\n Not compiled with hardware-scaling support, don't give me -z -1\n Exiting...\n"); return(-1); #endif } else if( doScale > 0 ) { #ifdef WANT_SWSCALE //Set up software scaling printf("Enabling slow software-based scaling to %ix%i.\n",320*doScale, 240*doScale); screen = swScaleInit(sdlVideoModeFlags,doScale); #else printf("\nError:\n I don't support software scaling, don't give me any -z options\n Exiting...\n"); return(-1); #endif } } else { screen=swScreen(sdlVideoModeFlags); doScale=0; } printf("Scaling factor: %f\n", setting()->scaleFactor); if( screen == NULL ) { printf("ERROR: Couldn't init video.\n"); return(-1); } //Set window title SDL_WM_SetCaption("Wizznic!", "Wizznic!"); //Set window icon SDL_Surface* icon = IMG_Load( DATADIR"data/wmicon.png"); SDL_WM_SetIcon(icon, NULL); SDL_FreeSurface(icon); #endif setting()->bpp = screen->format->BytesPerPixel; setAlphaCol( setting()->bpp ); printf("Screen surface using %i bytes per pixel.\n",setting()->bpp); //Open Joysticks (for wiz) if (SDL_NumJoysticks() > 0) SDL_JoystickOpen(0); //Hide mouse cursor SDL_ShowCursor(SDL_DISABLE); //Load fonts txtInit(); //Load sounds if(!initSound()) { printf("Couldn't init sound.\n"); return(-1); } //Menu Graphics if(!initMenu(screen)) { printf("Couldn't load menu graphics.\n"); return(-1); } //Init controls initControls(); //Init stats statsInit(); //Init packs packInit(); //Scan userlevels dir makeUserLevelList(screen); //Init particles initParticles(screen); //Seed the pseudo random number generator (for particles 'n' stuff) srand( (int)time(NULL) ); #if defined(PC) //Need to dump level-screenshots? if(dumpPack) { printf("Dumping level-images for pack: %s\n", dumpPack); dumplevelimages(screen, dumpPack, 0); return(0); } #endif //init starfield initStars(screen); //Init pointer initPointer(screen); printf("Applying settings..\n"); //Apply settings (has to be done after packs are inited) applySettings(); //Set Pack packSetByPath( setting()->packDir ); #if defined( PLATFORM_SUPPORTS_STATSUPLOAD ) if( (setting()->uploadStats) && !(setting()->firstRun) ) { statsUpload(0,0,0,0,0,"check",1, &(setting()->session) ); statsUpload(0,0,0,0,0,"q_solved",1, &(setting()->solvedWorldWide) ); //DLC only works when stats-uploading is enabled so we can use the same nag-screen. dlcCheckOnline(); } #endif printf("Setting Music...\n"); //Start playing music (has to be done after readong settings) soundSetMusic(); //Initialize credits initCredits(screen); initTransition(); #if SCREENW != 320 || SCREENH != 240 SDL_Rect *borderSrcRect = malloc(sizeof(SDL_Rect)); SDL_Surface* border = loadImg( BORDER_IMAGE ); if( border ) { printf("Border image loaded.\n"); borderSrcRect->x=(border->w-SCREENW)/2; borderSrcRect->y=(border->h-SCREENH)/2; borderSrcRect->w=SCREENW; borderSrcRect->h=SCREENH; SDL_BlitSurface( border, borderSrcRect, screen, NULL ); SDL_FreeSurface(border); } else { printf("Could not load border image: %s\n", BORDER_IMAGE); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0,0,0)); } free(borderSrcRect); borderSrcRect=NULL; #endif int lastTick; while(state!=STATEQUIT) { lastTick=SDL_GetTicks(); frameStart(); if(runControls()) state=STATEQUIT; switch(state) { case STATEPLAY: state = runGame(screen); break; case STATEMENU: state = runMenu(screen); break; case STATEEDIT: state=runEditor(screen); break; } drawPointer(screen); soundRun(screen,state); runTransition(screen); if(setting()->showFps) drawFPS(screen); switch( doScale ) { #if defined(HAVE_ACCELERATION) case -1: platformDrawScaled(screen); break; #endif case 0: SDL_Flip(screen); break; #if defined(WANT_SWSCALE) default: swScale(screen,doScale); break; #else default: state=STATEQUIT; break; #endif } #if defined(CRUDE_TIMING) //Oh how I loathe this, is there no better way? while(SDL_GetTicks()-lastTick <= PLATFORM_CRUDE_TIMING_TICKS) { //Burn, burn baby burn! } #else int t=SDL_GetTicks()-lastTick; if(t < 20) { SDL_Delay( 20 -t); } #endif } #if defined(PLATFORM_NEEDS_EXIT) platformExit(); #endif SDL_Quit(); return(0); }
kpok::kpok(QWidget *parent, const char *name) : QWidget(parent, name) { int w; char version[270]; setFixedSize(420,220); locale = kapp->getLocale(); sprintf(version, "%s %s", kapp->getCaption(), KPOKER_VERSION); setCaption( version ); QString bitmapdir = kapp->kde_datadir() + QString("/kpoker/pics/"); kacc = new KAccel( this ); KStdAccel stdacc; // Access to standard accelerators /* KKeyCode initialization */ kacc->insertItem(i18n("Quit"), "Quit", stdacc.quit()); kacc->insertItem(i18n("New game"), "New", "F2"); kacc->insertItem(i18n("Help"), "Help", stdacc.help()); // kacc->insertItem(i18n("Ok dialog"), "ok", "Return"); ?? // kacc->insertItem(i18n("Cancel dialog"), "dialog", "Escape"); ?? /* connections */ kacc->connectItem("Quit", qApp, SLOT(quit())); kacc->connectItem("New", this, SLOT(initPoker())); QFont myFixedFont("Helvetica",12); drawButton = new QPushButton(this,0); drawButton->setText(locale->translate("Draw !")); drawButton->setGeometry(210-drawButton->sizeHint().width() / 2,CLHDistFromTop,drawButton->sizeHint().width(),drawButton->sizeHint().height()); connect( drawButton, SIGNAL(clicked()), this, SLOT( drawClick() ) ); for (w=0;w < 5; w++) { CardFrames[w] = new QFrame(this, 0); CardFrames[w]->setGeometry(cardHDist+w*(cardHDist+cardWidth),cardDistFromTop,cardWidth +2,cardHeight +2); CardFrames[w]->setFrameStyle(QFrame::Panel | QFrame::Sunken); } QFont wonFont("Helvetica", 14, QFont::Bold); wonLabel = new QLabel(this, 0); wonLabel->hide(); wonLabel->setFont(wonFont); wonLabel->setAutoResize(true); wonLabel->move(this->width() /2 - wonLabel->width() / 2, wonLabelVDist); QFont clickToHoldFont("Helvetica", 11); clickToHold = new QLabel(this,0); clickToHold->hide(); clickToHold->setFont(clickToHoldFont); clickToHold->setAutoResize(true); clickToHold->setText(locale->translate("Click a card to hold it")); clickToHold->move(this->width() /2 - clickToHold->width() / 2, clickToHoldVDist); /* load all cards into pixmaps */ cardImage = new CardImages(this,0); cardImage->hide(); cardImage->loadCards(bitmapdir); for (w=0;w<5;w++) { cardW[w] = new CardWidget(CardFrames[w], 0); connect( cardW[w], SIGNAL(clicked()), cardW[w], SLOT( ownClick() ) ); connect( cardW[w], SIGNAL(pClicked(CardWidget *)), this, SLOT(frameClick(CardWidget *))); } for (w=0; w<5;w++) { heldLabels[w] = new QLabel(this, 0); heldLabels[w]->hide(); heldLabels[w]->setFont(myFixedFont); heldLabels[w]->setAutoResize(true); heldLabels[w]->setText(locale->translate("Held")); heldLabels[w]->move( ((cardWidth+2) /2 - heldLabels[w]->width() /2) + cardHDist+w*(cardHDist + cardWidth), cardDistFromTop -15 ); cardW[w]->heldLabel = heldLabels[w]; } cashFrame = new QFrame(this,0); cashFrame->setGeometry(CLHBorderDistance, CLHDistFromTop, CLHWidth, 30); cashFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); cashLabel= new QLabel(cashFrame,0); cashLabel->setAutoResize(true); cashLabel->setFont(myFixedFont); LHFrame = new QFrame(this,0); LHFrame->setGeometry(this->width() - CLHBorderDistance - CLHWidth, CLHDistFromTop, CLHWidth, 30); LHFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); LHLabel= new QLabel(LHFrame,0); LHLabel->setAutoResize(true); LHLabel->setFont(myFixedFont); for (w=0; w<= highestCard / 4; w++) cardHelp[w*4+1]=cardHelp[w*4+2]=cardHelp[w*4+3]=cardHelp[w*4+4]=w; blinkTimer = new QTimer(this); connect( blinkTimer, SIGNAL(timeout()), SLOT(bTimerEvent()) ); blinkStat=0; waveTimer = new QTimer(this); connect( waveTimer, SIGNAL(timeout()), SLOT(waveTimerEvent()) ); drawTimer = new QTimer(this); connect (drawTimer, SIGNAL(timeout()), SLOT(drawCardsEvent()) ); srandom(time(NULL)); QToolTip::add( drawButton,locale->translate("draw new cards")); QToolTip::add( LHLabel,locale->translate("your last hand")); QToolTip::add( LHFrame,locale->translate("your last hand")); QToolTip::add( cashLabel,locale->translate("money left")); QToolTip::add( cashFrame,locale->translate("money left")); initPoker(); initSound(); }
CRRCAirplaneLaRCSim::CRRCAirplaneLaRCSim(SimpleXMLTransfer* xml) { initSound(xml); }
void RingControl::startRinging(RingType t) { stopRing(); if(t == Call && !d->callEnabled) return; else if(t == Msg && !d->msgEnabled) return; if(qLogEnabled(QtopiaServer)) { QString type; switch(t) { case NotRinging: type = "NotRinging"; break; case Call: type = "Call"; break; case Msg: type = "Message"; break; } qLog(QtopiaServer) << "RingControl: Ringing" << type; } if(t == NotRinging) return; d->ringtime.start(); QPhoneProfile profile = d->profileManager->activeProfile(); QString ringToneDoc; // try contact ringtone if (t == Call) { // try personalized ring tone ringToneDoc = findRingTone(); // try profile ring tone // try video ring tone first. if (ringToneDoc.isEmpty()) { ringToneDoc = profile.videoTone().fileName(); if (!ringToneDoc.isEmpty()) { d->videoTone = true; } } // try profile ring tone if (ringToneDoc.isEmpty() || d->videoToneFailed) { ringToneDoc = profile.callTone().fileName(); d->videoTone = false; d->videoToneFailed = false; } // last resort, fall back to system ring tone if (ringToneDoc.isEmpty()) ringToneDoc = profile.systemCallTone().fileName(); d->curRingTone = ringToneDoc; d->curAlertType = profile.callAlert(); } else if (t == Msg) { d->curAlertType = profile.msgAlert(); if (d->curAlertType == QPhoneProfile::Continuous || d->curAlertType == QPhoneProfile::Ascending) { d->msgTid = startTimer(msgRingTime()); } ringToneDoc = profile.messageTone().fileName(); // fall back if above settings lead to non-existent ringtone. if (ringToneDoc.isEmpty()) ringToneDoc = profile.systemMessageTone().fileName(); d->curRingTone = ringToneDoc; } if (profile.vibrate()) { QVibrateAccessory vib; vib.setVibrateNow( true ); d->vibrateActive = true; d->vrbTid = startTimer(vibrateDuration()); } if(d->curAlertType == QPhoneProfile::Ascending) d->lastRingVolume = 1; else d->lastRingVolume = d->ringVolume; d->currentRingSource = t; if(d->lastRingVolume && d->curAlertType != QPhoneProfile::Off) { initSound(); #ifdef MEDIA_SERVER if ( !d->videoTone ) { if(d->soundcontrol && d->soundcontrol->sound()->fileName() != ringToneDoc) { delete d->soundcontrol->sound(); delete d->soundcontrol; d->soundcontrol = 0; } if (!d->soundcontrol) { d->soundcontrol = new QSoundControl(new QSound(d->curRingTone)); connect(d->soundcontrol, SIGNAL(done()), this, SLOT(nextRing()) ); } d->soundcontrol->setPriority(QSoundControl::RingTone); d->soundcontrol->setVolume(volmap[d->lastRingVolume]); d->soundcontrol->sound()->play(); } else { qLog(Media) << "Video ringtone selected" << d->curRingTone; QtopiaIpcSendEnvelope env = d->videoAdaptor->send( MESSAGE(playVideo(QString)) ); env << d->curRingTone; } #elif defined(Q_WS_QWS) if(d->soundclient) d->soundclient->play(0, d->curRingTone, volmap[d->lastRingVolume], QWSSoundClient::Priority); #endif } emit ringTypeChanged(d->currentRingSource); }