// Updating function to change highlighting of difficulty options void update(int selection) { // Replace the old selection, so that it is not highlighted. // Need to set the cursor to the line old selection. // Since every line has 8 pixels, we skip 8 pixels for every line if (selection == 1) { tft.setTextColor(WHITE); easy(RED); tft.setTextColor(RED); medium(WHITE); hard(WHITE); } else if (selection == 2) { tft.setTextColor(WHITE); medium(RED); tft.setTextColor(RED); easy(WHITE); hard(WHITE); } else if (selection == 3) { tft.setTextColor(WHITE); hard(RED); tft.setTextColor(RED); easy(WHITE); medium(WHITE); } }
void K3bMediaContentsView::slotMediumChanged( K3bDevice::Device* dev ) { // FIXME: derive a K3bContentsStack from QWidgetStack and let it set an active flag // to replace this hack if( QWidgetStack* stack = dynamic_cast<QWidgetStack*>( parentWidget() ) ) if( stack->visibleWidget() != this ) return; if( !d->autoReload /*|| !isActive()*/ ) return; if( dev == device() ) { K3bMedium m = k3bappcore->mediaCache()->medium( dev ); // no need to reload if the medium did not change (this is even // important since K3b blocks the devices in action and after // the release they are signalled as changed) if( m == medium() ) { kdDebug() << k_funcinfo << " medium did not change" << endl; enableInteraction( true ); } else if( m.content() & supportedMediumContent() && m.diskInfo().mediaType() & supportedMediumTypes() && m.diskInfo().diskState() & supportedMediumStates() ) { kdDebug() << k_funcinfo << " new supported medium found" << endl; reload( m ); } else { kdDebug() << k_funcinfo << " unsupported medium found" << endl; enableInteraction( false ); } } }
// This test represents an invariant test. First, several phases, components, // and properties are generated (more or less randomly). // Then, an XML-tree is generated from those information. The XML tree is then // parsed into a configTree, from which an MPL::MaterialObject is generated. // Last step compares the names (as well as the topology) of the Material object // with the specified parameters. TEST(Material, parseMaterials) { // This is the topology of our new material: The size of the // topology vector determines the number of phases, while each // vector component refers to the number of components of that // phase. // The number of properties is fixed in each case and is // determined by the size of the PropertyEnum enumerator. std::vector<std::size_t> const mediumTopology = {1, 1, 1}; Medium medium(mediumTopology); // the omnivagant medium: medium.property[MPL::name] = "luminiferous_aether"; medium.phases[0].property[MPL::name] = "Solid"; medium.phases[1].property[MPL::name] = "AqueousLiquid"; medium.phases[2].property[MPL::name] = "Gas"; medium.phases[0].component[0].property[MPL::thermal_conductivity] = "0.654"; medium.phases[0].component[0].property[MPL::reference_temperature] = "333"; medium.phases[0].component[0].property[MPL::reference_density] = "2100.0"; medium.phases[0].component[0].property[MPL::drhodT] = "-0.4"; medium.phases[0].component[0].property[MPL::name] = "VerySolid"; medium.phases[1].component[0].property[MPL::name] = "Water"; medium.phases[2].component[0].property[MPL::name] = "SuperFluid"; medium.phases[2].component[0].property[MPL::thermal_conductivity] = "1"; medium.property[MPL::permeability] = "1.0e-12"; // create an actual MaterialProperty-Medium out of the specifier object auto const m = createTestMaterial(makeMedium(medium)); // those two vectors will actually be compared std::vector<std::string> expected; std::vector<std::string> observed; // now we roam through all phases and components, finding their names // and storing them in the two vectors for (std::size_t p = 0; p < m->numberOfPhases(); ++p) { const auto& phase = m->phase(p); getNames(phase.name(), medium.phases[p].property[MPL::name], "no_name", observed, expected); for (std::size_t c = 0; c < phase.numberOfComponents(); ++c) { const auto& component = phase.component(c); getNames(component.name(), medium.phases[p].component[c].property[MPL::name], "no_name", observed, expected); } } // Now, the two vectors are compared. If there is some derivation, // we can easily locate the problem. ASSERT_EQ(expected, observed); }
void new_player_t::build() { medium(); space(2); label("Use arrows, joystick or keyboard"); label("to enter name"); big(); space(); button(name, 1); space(); button("Ok", MENU_TAG_OK); button("Cancel", MENU_TAG_CANCEL); }
int main() { many_names small, medium(10), large(12, 15); int gross = 144; float pi = 3.1415, payroll = 12.50; small.display(); small.display(100); small.display(gross,100); small.display(payroll); medium.display(); large.display(pi); return 0; }
int main() { box small("small box "), //Three boxes to work with medium("medium box "), large("large box "); small.set(5, 7); large.set(15, 20); cout << "The area of the "; cout << small.get_area() << "\n"; cout << "The area of the "; cout << medium.get_area() << "\n"; cout << "The area of the "; cout << large.get_area() << "\n"; return 0; }
void options_main_t::build() { medium(); label("Options"); space(); big(); button("Game", 4); button("Controls", 3); #if 0 button("Video", 1); button("Graphics", 6); #endif button("Audio", 2); button("System", 5); space(); button("DONE!", 0); }
int generate(int x){ time_t l; int p = 0, q = 0, i, j; srand((unsigned)time(&l)); int k = rand() % 100; if(k % 2 == 1){ answer1(); } else answer2(); switch(x){ case 1: p = easy(); break; case 2: p = medium(); break; case 3: p = hard(); break; } for(i = 1; i < 10; i++){ for(j = 1; j < 10; j++){ sudoko.b[i][j] = 0; } } while(q < p){ sudoko.b[a[q]][b[q]] = sudoko.c[a[q]][b[q]]; q++; } for(i = 1; i < 10; i++){ for(j = 1; j < 10; j++){ t[i][j] = sudoko.a[i][j] = 0; } } for(i = 1; i < 10; i++){ for(j = 1; j < 10; j++){ t[i][j] = sudoko.a[i][j] = sudoko.b[i][j]; } } return 0; }
void MediaNotifier::slotStatResult(KIO::Job *job) { bool allowNotification = m_allowNotificationMap[job]; m_allowNotificationMap.remove(job); if(job->error() != 0) return; KIO::StatJob *stat_job = static_cast< KIO::StatJob * >(job); KIO::UDSEntry entry = stat_job->statResult(); KURL url = stat_job->url(); KFileItem medium(entry, url); if(autostart(medium)) return; if(allowNotification) notify(medium); }
void skill_menu_t::build() { halign = ALIGN_CENTER; xoffs = 0.5; medium(); label("Select Skill Level"); space(1); big(); button("Classic", SKILL_CLASSIC + 10); small(); space(); big(); button("Newbie", SKILL_NEWBIE + 10); button("Gamer", SKILL_GAMER + 10); button("Elite", SKILL_ELITE + 10); button("God", SKILL_GOD + 10); space(); small(); switch(skill) { case SKILL_CLASSIC: label("\"I want the original XKobo, dammit!\""); break; case SKILL_NEWBIE: label("\"Damn, this is hard...!\""); break; case SKILL_GAMER: label("\"Classic is too retro for me!\""); break; case SKILL_ELITE: label("\"Bah! Gimme some resistance here.\""); break; case SKILL_GOD: label("\"The dark is afraid of me.\""); break; } }
void UIMedium::refresh() { /* Reset ID parameters: */ m_strId = nullID(); m_strRootId = nullID(); m_strParentId = nullID(); /* Reset cache parameters: */ //m_strKey = nullID(); /* Reset name/location/size parameters: */ m_strName = VBoxGlobal::tr("Empty", "medium"); m_strLocation = m_strSize = m_strLogicalSize = QString("--"); /* Reset hard drive related parameters: */ m_strHardDiskType = QString(); m_strHardDiskFormat = QString(); m_strStorageDetails = QString(); m_strEncryptionPasswordID = QString(); /* Reset data parameters: */ m_strUsage = QString(); m_strToolTip = QString(); m_machineIds.clear(); m_curStateMachineIds.clear(); /* Reset m_noDiffs: */ m_noDiffs.isSet = false; /* Reset flags: */ m_fHidden = false; m_fUsedByHiddenMachinesOnly = false; m_fReadOnly = false; m_fUsedInSnapshots = false; m_fHostDrive = false; m_fEncrypted = false; /* For non NULL medium: */ if (!m_medium.isNull()) { /* Refresh medium ID: */ m_strId = normalizedID(m_medium.GetId()); /* Refresh root medium ID: */ m_strRootId = m_strId; /* Init medium key if necessary: */ if (m_strKey.isNull()) m_strKey = m_strId; /* Check whether this is host-drive medium: */ m_fHostDrive = m_medium.GetHostDrive(); /* Refresh medium name: */ if (!m_fHostDrive) m_strName = m_medium.GetName(); else if (m_medium.GetDescription().isEmpty()) m_strName = VBoxGlobal::tr("Host Drive '%1'", "medium").arg(QDir::toNativeSeparators(m_medium.GetLocation())); else m_strName = VBoxGlobal::tr("Host Drive %1 (%2)", "medium").arg(m_medium.GetDescription(), m_medium.GetName()); /* Refresh medium location: */ if (!m_fHostDrive) m_strLocation = QDir::toNativeSeparators(m_medium.GetLocation()); /* Refresh medium size and logical size: */ if (!m_fHostDrive) { /* Only for created and accessible mediums: */ if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated) { m_strSize = vboxGlobal().formatSize(m_medium.GetSize()); if (m_type == UIMediumType_HardDisk) m_strLogicalSize = vboxGlobal().formatSize(m_medium.GetLogicalSize()); else m_strLogicalSize = m_strSize; } } /* For hard drive medium: */ if (m_type == UIMediumType_HardDisk) { /* Refresh hard drive disk type: */ m_strHardDiskType = vboxGlobal().mediumTypeString(m_medium); /* Refresh hard drive format: */ m_strHardDiskFormat = m_medium.GetFormat(); /* Refresh hard drive storage details: */ qlonglong iMediumVariant = 0; foreach (const KMediumVariant &enmVariant, m_medium.GetVariant()) iMediumVariant |= enmVariant; m_strStorageDetails = gpConverter->toString((KMediumVariant)iMediumVariant); /* Check whether this is read-only hard drive: */ m_fReadOnly = m_medium.GetReadOnly(); /* Refresh parent hard drive ID: */ CMedium parentMedium = m_medium.GetParent(); if (!parentMedium.isNull()) m_strParentId = normalizedID(parentMedium.GetId()); /* Only for created and accessible mediums: */ if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated) { /* Refresh root hard drive ID: */ while (!parentMedium.isNull()) { m_strRootId = normalizedID(parentMedium.GetId()); parentMedium = parentMedium.GetParent(); } /* Refresh encryption attributes: */ if (m_strRootId != m_strId) { m_strEncryptionPasswordID = root().encryptionPasswordID(); m_fEncrypted = root().isEncrypted(); } else { QString strCipher; CMedium medium(m_medium); const QString strEncryptionPasswordID = medium.GetEncryptionSettings(strCipher); if (medium.isOk()) { m_strEncryptionPasswordID = strEncryptionPasswordID; m_fEncrypted = true; } } } }
K3bDevice::Device* K3bMediaContentsView::device() const { return medium().device(); }
int main() { unsigned int userInputChoice = 0; bool isSchedulingAlgorithmCompleted[6] = { false, false, false, false, false, false }; FileUtility small( smallTaskName, smallInputFileName, smallOutputFileName, smallFileNumberCount, timeQuantum ); FileUtility medium( mediumTaskName, mediumInputFileName, mediumOutputFileName, mediumFileNumberCount, timeQuantum ); FileUtility large( largeTaskName, largeInputFileName, largeOutputFileName, largeFileNumberCount, timeQuantum ); halfTime = ( smallFileNumberCount + mediumFileNumberCount + largeFileNumberCount ) / 2; GenerateInputFiles( small, medium, large ); while( userInputChoice != INPUT_CHOICE_EXIT) { userInputChoice = 0; timeStamp = 0; small.InitialiseMemberVariables(); medium.InitialiseMemberVariables(); large.InitialiseMemberVariables(); cout << endl; cout << "Enter input choice based on the Scheduling algorithm you wish to perform." << endl; cout << "1. First Come First Serve : Small -> Medium -> Large" << endl; cout << "2. First Come First Serve : Large -> Medium -> Small" << endl; cout << "3. Priority Scheduling : Equal priority" << endl; cout << "4. Priority Scheduling : Inverse of the file size" << endl; cout << "5. Priority Scheduling : Proportional to the file size" << endl; cout << "6. Print statistics generated so far" << endl; cout << "7. Exit program." << endl; cout << "Please enter your choice :"; cin >> userInputChoice; switch( userInputChoice ) { RemoveOutputFiles( small, medium, large ); case FCFS_SMALL_TO_LARGE: isSchedulingAlgorithmCompleted[ FCFS_SMALL_TO_LARGE ] = true; FirstComeFirstServe( userInputChoice, small, medium, large ); cout << "Completed generating output files for First Come First Serve : Small -> Medium -> Large." << endl; break; case FCFS_LARGE_TO_SMALL: isSchedulingAlgorithmCompleted[ FCFS_LARGE_TO_SMALL ] = true; FirstComeFirstServe( userInputChoice, large, medium, small ); cout << "Completed generating output files for First Come First Serve : Large -> Medium -> Small." << endl; break; case PS_EQUAL_PRIORITY: isSchedulingAlgorithmCompleted[ PS_EQUAL_PRIORITY ] = true; PrioritySchedulingWithEqualPriority( small, medium, large ); cout << "Completed generating output files for Priority Scheduling : Equal priority." << endl; break; case PS_INVERSE_FILE_SIZE: isSchedulingAlgorithmCompleted[ PS_INVERSE_FILE_SIZE ] = true; PriorityScheduling( userInputChoice, small, medium, large ); cout << "Completed generating output files for Priority Scheduling : Inverse of the file size." << endl; break; case PS_PROPORTIONAL_FILE_SIZE: isSchedulingAlgorithmCompleted[ PS_PROPORTIONAL_FILE_SIZE ] = true; PriorityScheduling( userInputChoice, large, medium, small ); cout << "Completed generating output files for Priority Scheduling : Proportional to the file size." << endl; break; case PRINT_STATISTICS: PrintStatistics( isSchedulingAlgorithmCompleted, small, medium, large ); break; case INPUT_CHOICE_EXIT: break; default: cout << "Incorrect choice entered. Enter correct choice." << endl; break; } } cout << endl; cout << "Exiting program..!" << endl; return 0; }
int main(void) { void *mptr; /* memory pointer */ pid_t pid1, pid2; cpu_set_t set, *setp = &set; int res; int *minimum_priority = (int*)&prio_min; *minimum_priority = sched_get_priority_min(policy); if (check_privs()) exit(-1); mptr = mmap_page(); /* Get a page of shared memory */ resource = (pthread_mutex_t*)mptr; /* point our lock to it */ mptr += sizeof(pthread_mutex_t); /* advance the memory pointer */ /* Initialize our mutex via the resource pointer */ init_shared_pthread_mutex(resource, PTHREAD_PRIO_INHERIT, policy); statep = (struct State*)mptr; mptr += sizeof(struct State); init_state(); /* Initialize the state structure */ statep->mutex = (pthread_mutex_t*)mptr; /* point the next lock to it */ mptr += sizeof(pthread_mutex_t); /* advance the memory pointer */ /* Initialize our State mutex */ init_shared_pthread_mutex(statep->mutex, PTHREAD_PRIO_NONE, policy); set_rt_prio(0, prio_min, policy); /* We restrict this program to the first cpu, inorder to increase * the likelihood of a priority inversion */ CPU_ZERO(setp); CPU_SET(0, setp); res = sched_setaffinity(0, sizeof(set), setp); if (res == -1) { int err = errno; err_msg("sched_setaffinity: "); err_exit(err, NULL); } pid1 = fork(); if (pid1 == -1) { perror("fork"); exit(1); } else if (pid1 != 0) { /* parent code */ low(pid1); } else { /* child code */ pid2 = fork(); /* parent code */ if (pid2 == -1) { perror("fork: "); exit(-1); } else if (pid2 != 0) { /* parent code */ high(pid2); } else { /* child code */ medium(); } } exit(0); }
int main ( int argc, char** argv ) { if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } atexit(SDL_Quit); screen = SDL_SetVideoMode(SCREENW, SCREENH, 32, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 800x600 video: %s\n", SDL_GetError()); return 1; } SDL_WM_SetCaption("Szit the Game", NULL); if( TTF_Init() == -1 ) { printf("Unable to initialize font"); return 1; } font=TTF_OpenFont("tahoma.ttf", 28); if(font){printf("Success");} // centre the bitmap on screen CGameManager manager; bool done = false; CBlock blockT(0, -1, 0, 0, 0, 1, 0, 0, -1, 100, 100, 100); //t blockT.TryTurn(); blockT.Turn(); blockT.TryTurn(); blockT.Turn(); CBlock blockZ(0, -1,-1,0,-1,0,0,1,0, 198,255,126); //z CBlock blockS(0, -1,0,0,0,0,-1,1,-1, 126,196,255); //s CBlock blockO(1, 0,0,1,0,0,1,1,1, 100, 100, 0); //o CBlock blockI(0, 0,-1,0,0,0,1,0,2, 255,159,126); //i CBlock blockJ(0, -1,1,0,1,0,0,0,-1, 139,77,156); //j CBlock blockL(0, 0,-1,0,0,0,1,1,1, 255,229,126); //l CBlock GameBlock(0, -1, 0, 0, 0, 1, 0, 0, -1, 179,206,221); //creating t CBlock NextBlock(0, -1, 0, 0, 0, 1, 0, 0, -1, 179,206,221); //t //CBlock GameBlock(0, -1,0,0,0,0,-1,1,-1); //s //CBlock GameBlock(0, 0,-1,0,0,0,1,0,2); //i CButton start(300, 350, 200, 50, 100, 100, 100, 150, 150, 150, 1, "Start"); CButton help(300, 425, 200, 50, 100, 100, 100, 150, 150, 150, 0, "Help"); CButton exit(300, 500, 200, 50, 100, 100, 100, 150, 150, 150, 0, "Exit"); CButton easy(100, 350, 200, 50, 200, 200, 200, 255, 255, 255, 0, "Easy"); CButton medium(300, 350, 200, 50, 200, 200, 200, 255, 255, 255, 1, "Medium"); CButton hard(500, 350, 200, 50, 200, 200, 200, 255, 255, 255, 0, "Hard"); manager.Refresh(&GameBlock, &NextBlock); manager.Refresh(&GameBlock, &NextBlock); srand(time(NULL)); switch(rand()%7){ case 0: GameBlock.Set(0, -1, 0, 0, 0, 1, 0, 0, -1,179,206,221);break; //t case 1: GameBlock.Set(0, -1,-1,0,-1,0,0,1,0, 198,255,126);break; //z case 2: GameBlock.Set(0, -1,0,0,0,0,-1,1,-1, 126,196,255);break; //s case 3: GameBlock.Set(1, 0,0,1,0,0,1,1,1, 100, 100, 0);break; //o case 4: GameBlock.Set(0, 0,-1,0,0,0,1,0,2, 255,159,126);break; //i case 5: GameBlock.Set(0, -1,1,0,1,0,0,0,-1, 139,77,156);break; //j case 6: GameBlock.Set(0, 0,-1,0,0,0,1,1,1, 255,229,126);break; //l } srand(time(NULL)+SDL_GetTicks()); switch(rand()%7){ case 0: NextBlock.Set(0, -1, 0, 0, 0, 1, 0, 0, -1,179,206,221);break; //t case 1: NextBlock.Set(0, -1,-1,0,-1,0,0,1,0, 198,255,126);break; //z case 2: NextBlock.Set(0, -1,0,0,0,0,-1,1,-1, 126,196,255);break; //s case 3: NextBlock.Set(1, 0,0,1,0,0,1,1,1, 100, 100, 0);break; //o case 4: NextBlock.Set(0, 0,-1,0,0,0,1,0,2, 255,159,126);break; //i case 5: NextBlock.Set(0, -1,1,0,1,0,0,0,-1, 139,77,156);break; //j case 6: NextBlock.Set(0, 0,-1,0,0,0,1,1,1, 255,229,126);break; //l } // program main loop while (!done) { // message processing loop SDL_Event event; ++frame; SetFPS(); LastFrame=SDL_GetTicks(); if(gamestatus==1){manager.Refresh(&GameBlock, &NextBlock); } while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: { // exit if ESCAPE is pressed if (event.key.keysym.sym == SDLK_ESCAPE) {done = true;} if(!gamestatus) { if(event.key.keysym.sym == SDLK_DOWN){ if(start.Active()){start.ChangeActivity(); help.ChangeActivity();}else if(help.Active()){help.ChangeActivity(); exit.ChangeActivity();}else if(exit.Active()){exit.ChangeActivity(); start.ChangeActivity();} } else if(event.key.keysym.sym == SDLK_UP){ if(start.Active()){start.ChangeActivity(); exit.ChangeActivity();}else if(help.Active()){help.ChangeActivity(); start.ChangeActivity();}else if(exit.Active()){exit.ChangeActivity(); help.ChangeActivity();} } if(event.key.keysym.sym == SDLK_RETURN){ if(start.Active()){gamestatus=3;} else if(help.Active()){gamestatus=5;} else if(exit.Active()){done=1;} } }else if(gamestatus==1){ if(event.key.keysym.sym == SDLK_DOWN){ manager.MoveBlockDown(&GameBlock, 1); } if(event.key.keysym.sym == SDLK_SPACE){ manager.TurnGameBlock(&GameBlock); } if(event.key.keysym.sym == SDLK_LEFT){ manager.MoveBlockLeft(&GameBlock); } if(event.key.keysym.sym == SDLK_RIGHT){ manager.MoveBlockRight(&GameBlock); } if(event.key.keysym.sym == SDLK_w){ manager.SpeedUp(); } if(event.key.keysym.sym ==SDLK_p){ gamestatus=2; } }else if(gamestatus==2){ if(event.key.keysym.sym ==SDLK_p){ gamestatus=1; } }else if(gamestatus==3){ if(event.key.keysym.sym == SDLK_RETURN){ if(easy.Active()){manager.SetLevel(1);}else if(medium.Active()){manager.SetLevel(2);}else if(hard.Active()){manager.SetLevel(3);} gamestatus=1; }else if(event.key.keysym.sym == SDLK_RIGHT){ if(easy.Active()){easy.ChangeActivity(); medium.ChangeActivity();}else if(medium.Active()){medium.ChangeActivity(); hard.ChangeActivity();}else if(hard.Active()){hard.ChangeActivity(); easy.ChangeActivity();} }else if(event.key.keysym.sym == SDLK_LEFT){ if(easy.Active()){easy.ChangeActivity(); hard.ChangeActivity();}else if(medium.Active()){medium.ChangeActivity(); easy.ChangeActivity();}else if(hard.Active()){hard.ChangeActivity(); medium.ChangeActivity();} } }else if(gamestatus==4){ if(event.key.keysym.sym){ SDL_Delay(1000); gamestatus=0; manager.ClearGame(); } }else if(gamestatus==5){ if(event.key.keysym.sym){ gamestatus=0; } } break; } } // end switch }// end of message processing // DRAWING STARTS HERE // clear screen SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); // draw bitmap if(gamestatus==0){ int a=SDL_GetTicks(); RBC_DrawRect(0, 0, screen->w, screen->h, 0, 0, 50); RBC_DrawRect((0+frame/2)%screen->w, 0, screen->w/5, screen->h, 105,210,231); if(((0+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((0+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 105,210,231);} RBC_DrawRect((screen->w/5+frame/2)%screen->w, 0, screen->w/5, screen->h, 167,219,216); if(((screen->w/5+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 167,219,216);} RBC_DrawRect((screen->w/5*2+frame/2)%screen->w, 0, screen->w/5, screen->h, 224,228,204); if(((screen->w/5*2+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*2+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 224,228,204);} RBC_DrawRect((screen->w/5*3+frame/2)%screen->w, 0, screen->w/5, screen->h, 243,134,48); if(((screen->w/5*3+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*3+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 243,134,48);} RBC_DrawRect((screen->w/5*4+frame/2)%screen->w, 0, screen->w/5, screen->h, 250,105,0); if(((screen->w/5*4+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*4+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 250,105,0);} blockS.Draw(-100, 90+sin(a/100)*50); blockZ.Draw(50, 90+sin(a/100+10)*50); blockI.Draw(200, 90+sin(a/100+20)*50); blockT.Draw(350, 90+sin(a/100+30)*50); start.Draw(); help.Draw(); exit.Draw(); }else if(gamestatus==1){ switch(manager.ReturnSpeed()){ case 2:RBC_DrawRect(0, 0, screen->w, screen->h, 105,210,231);break; case 4:RBC_DrawRect(0, 0, screen->w, screen->h, 167,219,216);break; case 6:RBC_DrawRect(0, 0, screen->w, screen->h, 224,228,204);break; case 8:RBC_DrawRect(0, 0, screen->w, screen->h, 243,134,48);break; case 10:RBC_DrawRect(0, 0, screen->w, screen->h, 250,105,0);break; case 12:RBC_DrawRect(0, 0, screen->w, screen->h, 250,70,0);break; case 14:RBC_DrawRect(0, 0, screen->w, screen->h, 250,35,0);break; case 16:RBC_DrawRect(0, 0, screen->w, screen->h, 250,10,0);break; case 18:RBC_DrawRect(0, 0, screen->w, screen->h, 250,0,0);break; } RBC_DrawRect(245, 0, 310, 600, 0,0,0); RBC_DrawRect(250, 0, 300, 600, 85,98,112); RBC_DrawRect(570, 70, 210, 210, 0,0,0); RBC_DrawRect(575, 75, 200, 200, 200, 200, 200); GameBlock.Draw(manager.GetGameBlockX()*30, manager.GetGameBlockY()*30); NextBlock.Draw(375, 150); manager.DrawTable(); RBC_Write(575, 300, "Speed:", screen); RBC_Write(675, 300, manager.ReturnSpeed(), screen); RBC_Write(575, 330, "Lines:", screen); RBC_Write(675, 330, manager.ReturnDone(), screen); RBC_Write(575, 360, "Score:", screen); RBC_Write(675, 360, manager.ReturnScore(), screen); }else if(gamestatus==2){ switch(manager.ReturnSpeed()){ case 2:RBC_DrawRect(0, 0, screen->w, screen->h, 105,210,231);break; case 4:RBC_DrawRect(0, 0, screen->w, screen->h, 167,219,216);break; case 6:RBC_DrawRect(0, 0, screen->w, screen->h, 224,228,204);break; case 8:RBC_DrawRect(0, 0, screen->w, screen->h, 243,134,48);break; case 10:RBC_DrawRect(0, 0, screen->w, screen->h, 250,105,0);break; case 12:RBC_DrawRect(0, 0, screen->w, screen->h, 250,70,0);break; case 14:RBC_DrawRect(0, 0, screen->w, screen->h, 250,35,0);break; case 16:RBC_DrawRect(0, 0, screen->w, screen->h, 250,10,0);break; case 18:RBC_DrawRect(0, 0, screen->w, screen->h, 250,0,0);break; } RBC_DrawRect(245, 0, 310, 600, 0,0,0); RBC_DrawRect(250, 0, 300, 600, 85,98,112); RBC_Write(360, 250, "Pause", screen); }else if(gamestatus==3){ RBC_DrawRect((0+frame/2)%screen->w, 0, screen->w/5, screen->h, 105,210,231); if(((0+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((0+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 105,210,231);} RBC_DrawRect((screen->w/5+frame/2)%screen->w, 0, screen->w/5, screen->h, 167,219,216); if(((screen->w/5+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 167,219,216);} RBC_DrawRect((screen->w/5*2+frame/2)%screen->w, 0, screen->w/5, screen->h, 224,228,204); if(((screen->w/5*2+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*2+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 224,228,204);} RBC_DrawRect((screen->w/5*3+frame/2)%screen->w, 0, screen->w/5, screen->h, 243,134,48); if(((screen->w/5*3+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*3+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 243,134,48);} RBC_DrawRect((screen->w/5*4+frame/2)%screen->w, 0, screen->w/5, screen->h, 250,105,0); if(((screen->w/5*4+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*4+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 250,105,0);} easy.Draw(); medium.Draw(); hard.Draw(); }else if(gamestatus==4){ switch(manager.ReturnSpeed()){ case 2:RBC_DrawRect(0, 0, screen->w, screen->h, 105,210,231);break; case 4:RBC_DrawRect(0, 0, screen->w, screen->h, 167,219,216);break; case 6:RBC_DrawRect(0, 0, screen->w, screen->h, 224,228,204);break; case 8:RBC_DrawRect(0, 0, screen->w, screen->h, 243,134,48);break; case 10:RBC_DrawRect(0, 0, screen->w, screen->h, 250,105,0);break; case 12:RBC_DrawRect(0, 0, screen->w, screen->h, 250,70,0);break; case 14:RBC_DrawRect(0, 0, screen->w, screen->h, 250,35,0);break; case 16:RBC_DrawRect(0, 0, screen->w, screen->h, 250,10,0);break; case 18:RBC_DrawRect(0, 0, screen->w, screen->h, 250,0,0);break; } RBC_DrawRect(245, 0, 310, 600, 0,0,0); RBC_DrawRect(250, 0, 300, 600, 85,98,112); RBC_DrawRect(570, 70, 210, 210, 0,0,0); RBC_DrawRect(575, 75, 200, 200, 200, 200, 200); GameBlock.Draw(manager.GetGameBlockX()*30, manager.GetGameBlockY()*30); NextBlock.Draw(375, 150); manager.DrawTable(); RBC_Write(575, 300, "Speed:", screen); RBC_Write(675, 300, manager.ReturnSpeed(), screen); RBC_Write(575, 330, "Lines:", screen); RBC_Write(675, 330, manager.ReturnDone(), screen); RBC_Write(575, 360, "Score:", screen); RBC_Write(675, 360, manager.ReturnScore(), screen); for(int i=0; i<screen->w/2; i++){ for(int j=0; j<screen->h/2; j++){ RBC_DrawRect(i*2, j*2, 1,1, 0,0,0); } } RBC_Write(300, 300, "Game Over", screen); RBC_Write(300, 350, manager.ReturnScore(), screen); }else if(gamestatus==5){ RBC_DrawRect((0+frame/2)%screen->w, 0, screen->w/5, screen->h, 105,210,231); if(((0+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((0+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 105,210,231);} RBC_DrawRect((screen->w/5+frame/2)%screen->w, 0, screen->w/5, screen->h, 167,219,216); if(((screen->w/5+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 167,219,216);} RBC_DrawRect((screen->w/5*2+frame/2)%screen->w, 0, screen->w/5, screen->h, 224,228,204); if(((screen->w/5*2+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*2+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 224,228,204);} RBC_DrawRect((screen->w/5*3+frame/2)%screen->w, 0, screen->w/5, screen->h, 243,134,48); if(((screen->w/5*3+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*3+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 243,134,48);} RBC_DrawRect((screen->w/5*4+frame/2)%screen->w, 0, screen->w/5, screen->h, 250,105,0); if(((screen->w/5*4+frame/2)%screen->w+screen->w/5)>screen->w){RBC_DrawRect(0, 0, ((screen->w/5*4+frame/2)%screen->w+screen->w/5)-screen->w, screen->h, 250,105,0);} RBC_Write(20, 300, "Use left and right arrow to move block sideways", screen); RBC_Write(20, 350, "Use down arrow to move block down faster for extra points", screen); RBC_Write(20, 400, "Use space to turn falling tetramino", screen); RBC_Write(20, 450, "Hit 'P' to pause game", screen); } RBC_Write(10, 20, "FPS: ", screen);RBC_Write(70, 20, GetFPS(), screen); // DRAWING ENDS HERE // finally, update the screen :) SDL_Flip(screen); } // end main loop // free loaded bitmap TTF_CloseFont(font); TTF_Quit(); // all is well ;) printf("Exited cleanly\n"); return 0; }
int main() { // SETUP init(); Serial.begin(9600); tft.initR(INITR_BLACKTAB); // initialize screen // Setting the joystick button and LEDs pinMode(JOYSTICK_BUTTON, INPUT); digitalWrite(JOYSTICK_BUTTON, HIGH); // Initialize the SD card Serial.print("Initializing SD card..."); if (!SD.begin(SD_CS)) { Serial.println("failed!"); while(true) {} // something is wrong } else {Serial.println("OK!");} // More initialization Serial.print("Initializing Raw SD card..."); if (!card.init(SPI_HALF_SPEED, SD_CS)) { Serial.println("failed!"); while(true) {} // something is wrong } else {Serial.println("OK!");} // Create states for different modes // C1 for Mode 1 - MENU screen // C2 for Mode 2 - Snake Game // C3 for Mode 3 - GAME OVER screen // C4 for Mode 4 - Choose level // C5 for Mode 5 - PAUSE screen typedef enum {C1 = 1, C2, C3, C4, C5, ERR} State; State state = C1; int select, snakelength; while (state!=ERR) { if (state == C1) { /// ====== MODE 1 - MENU ====== /// Serial.println("Currently in Mode 1"); snakelength = 1; init_vert = analogRead(JOYSTICK_VERT); init_horiz = analogRead(JOYSTICK_HORIZ); // preparations for the game - to not overlap with the pause menu q = q_create(720); i = 64; // x component j = 80; // y component q_add(q,i,j); // load into the queue random_x = food_x(); // load x coordinate of food piece random_y = food_y(); // load y coordinate of food piece pausedirection = 0; // set paused direction to 0 // reset grid to 0 for (int a = 0; a < 24; a++) { for (int b = 0; b < 30; b++) { grid[a][b] = 0; } } // display main menu snake(); tft.setTextSize(2); while(true) { // alternate highlighting of START unsigned long time = millis()%1000; int a = time%1000; if ((a<17)) { tft.setCursor(34, 83); tft.fillRoundRect(30,80,65,20,5,WHITE); tft.setTextColor(RED); tft.print("START"); } else if ((a>500) && (a<520)) { tft.setCursor(34, 83); tft.fillRoundRect(30,80,65,20,5,RED); tft.setTextColor(WHITE); tft.print("START"); } // Read the Joystick - HIGH if not pressed, LOW otherwise select = digitalRead(JOYSTICK_BUTTON); if (select == LOW) { break; } } state = C4; } else if (state == C2) { /// ====== MODE 2 - SNAKE GAME ====== /// Serial.println("Currently in Mode 2"); delay(50); soundsetup(); //setting up sound pin // print the background tft.fillScreen(DARKRED); tft.fillRect(4,5,120,150,DARKGRN); // print the snake int x,y; x = q_frontx(q); y = q_fronty(q); tft.fillRect(x,y,5,5, WHITE); //Bringing the food in, outside while loop first. tft.fillRect(random_x, random_y, 5, 5, YELLOW); // do auto calibration int px, py; int lastmove; // read beginning direction chosen by user if (pausedirection == 0) { direction = read_direction(); } else { direction = pausedirection; } lastmove = direction; while (true) { // to direct movement // (without going in reverse direction of previous movement) // up if (direction == 1) { if (lastmove == 2) { direction = 2; j = j-5; } else { j = j+5; } q_add(q,i,j); } // down else if (direction == 2) { if (lastmove == 1) { direction = 1; j = j+5; } else { j = j-5; } q_add(q,i,j); } // right else if (direction == 3) { if (lastmove == 4) { direction = 4; i = i-5; } else { i = i+5; } q_add(q,i,j); } // left else if (direction == 4) { if (lastmove == 3) { direction = 3; i = i+5; } else { i = i-5; } q_add(q,i,j); } // if the direction is changed, store the new direction & last move int new_direc = read_direction(); if ((new_direc != direction) && (new_direc != 0)) { lastmove = direction; direction = new_direc; } // if the snake hits a piece of food, the food vanishes and gets replaced if ((i == random_x) && (j == random_y)) { // snake grows by 4 squares, except for the first time // this allows for it to end up as a max of 720 in the queue if (snakelength == 1) { q_add(q,i,j); q_add(q,i,j); q_add(q,i,j); snakelength += 3; } else { q_add(q,i,j); q_add(q,i,j); q_add(q,i,j); q_add(q,i,j); snakelength += 4; } if (snakelength < 720) { random_x = food_x(); random_y = food_y(); // if the snake is already there, find a new spot for the food while (grid[random_x/5][random_y/5-1] == 1) { random_x = food_x(); random_y = food_y(); } // print the new food tft.fillRect(random_x, random_y, 5, 5, YELLOW); } } // if the snake runs over itself if ((snakelength > 1) && (grid[i/5][j/5-1] == 1)) { delay(450); // pause when snake runs into itself int m = 0; soundLoop(); while(m < 6000) { int rand_x = dissolve_x(); int rand_y = dissolve_y(); tft.fillRect(rand_x, rand_y, 5, 5, BLACK); m++; } state = C3; break; } px = q_frontx(q); py = q_fronty(q); // reprint the snake if there is movement if ((i != px) || (j != py)) { tft.fillRect(i,j,5,5, WHITE); grid[i/5][j/5-1] = 1; // snake body is in grid tft.fillRect(px,py,5,5,DARKGRN); grid[px/5][py/5-1] = 0; // snake body is no longer in grid q_remove(q); // take away from the queue delay(speed); // controls the speed of the snake } // if any of the borders are hit if ((i < 4)||(j < 5)||(i > 119)||(j > 150)) { delay(450); // pause when border is hit // dissolve the screen int m = 0; soundLoop(); while(m < 6000) { int rand_x = dissolve_x(); int rand_y = dissolve_y(); tft.fillRect(rand_x, rand_y, 5, 5, BLACK); m++; } //~ delay(250); state = C3; break; } // Read the Joystick - HIGH if not pressed, LOW otherwise select = digitalRead(JOYSTICK_BUTTON); if (select == LOW) { state = C5; break; } } } else if (state == C3) { /// ====== MODE 3 - GAME OVER ====== /// Serial.println("Currently in Mode 3"); q_destroy(q); // clear the queue tft.fillScreen(BLACK); tft.fillRoundRect(5,20,118,25,5,RED); tft.setCursor(10, 25); tft.setTextColor(BLACK); tft.setTextSize(2); tft.setTextWrap(true); tft.print("GAME OVER"); tft.print("\n"); tft.setCursor(10, 55); tft.setTextColor(RED); tft.setTextSize(1.5); if (snakelength >= 720) { snakelength = 720; tft.print("YOU WON! CONGRATZ"); } else { tft.print(" Oh no! You hit something!"); } tft.setCursor(10, 80); tft.setTextColor(WHITE); tft.setTextSize(1); tft.print("Length of Snake:"); tft.print(snakelength); tft.setCursor(10, 100); tft.print("Press the joystick to return to main menu"); // Read the Joystick - HIGH if not pressed, LOW otherwise while (true) { select = digitalRead(JOYSTICK_BUTTON); if (select == LOW) { break; } } state = C1; } else if (state == C4) { /// ====== MODE 4 - CHOOSE LEVEL ====== /// Serial.println("Currently in Mode 4"); // printing // snake display snake(); // difficulty levels tft.setTextSize(2); tft.setTextColor(WHITE); easy(RED); tft.setTextColor(RED); medium(WHITE); hard(WHITE); int selection = 1; int oldselection; while(true) { // read direction from the user for updating selection oldselection = selection; vertical = analogRead(JOYSTICK_VERT); // will be 0-1023 delay(100); // scroll down if (vertical > init_vert + 200) { selection++; if (selection > 3) { selection = 0; } } // scroll up else if (vertical < init_vert - 200) { selection--; if (selection < 0) { selection = 3; } } if (selection != oldselection) { update(selection); } // Read the Joystick - HIGH if not pressed, LOW otherwise select = digitalRead(JOYSTICK_BUTTON); if (select == LOW) { Serial.print("made selection: "); Serial.println(selection); if (selection == 1) {speed = 225;} else if (selection == 2) {speed = 150;} else if (selection == 3) {speed = 75;} break; } } state = C2; } else if (state == C5) { /// ====== MODE 5 - PAUSE MENU ====== /// Serial.println("Currently in Mode 5"); pausedirection = direction; // printing snake and pause snake(); tft.setTextSize(2); tft.setCursor(34, 73); tft.fillRoundRect(30,70,65,20,5,WHITE); tft.setTextColor(RED); tft.print("Pause"); while(true) { // Read the Joystick - HIGH if not pressed, LOW otherwise select = digitalRead(JOYSTICK_BUTTON); if (select == LOW) { break; } } // reset grid to 0 for (int a = 0; a < 24; a++) { for (int b = 0; b < 30; b++) { grid[a][b] = 0; } } state = C2; } //if not any of this: else { Serial.println("There has been an error"); state = ERR; } } Serial.end(); return 0; }
void MainWindow::createMenus() { openAct = new QAction(tr("读取地图(&M)"), this); saveAct = new QAction(tr("存档(&S)"), this); loadAct = new QAction(tr("读档(&R)"), this); rechargeAct = new QAction(tr("充值(&C)"), this); exitAct = new QAction(tr("退出(&E)"), this); restartAct = new QAction(tr("重新开始(&L)"), this); hardAct = new QAction(tr("困难"), this); mediumAct = new QAction(tr("中等"), this); easyAct = new QAction(tr("简单"), this); foresoundAct = new QAction(tr("音效开关(&O)"), this); manualAct = new QAction(tr("用户手册(&U)"), this); aboutAct = new QAction(tr("关于(&A)"), this); fileMenu = menuBar()->addMenu(tr("文件(&F)")); settingMenu = menuBar()->addMenu(tr("游戏设置(&G)")); helpMenu = menuBar()->addMenu(tr("帮助(&H)")); fileMenu->addAction(openAct); openAct->setShortcut(QKeySequence("Ctrl+m")); fileMenu->addSeparator(); fileMenu->addAction(saveAct); saveAct->setShortcut(QKeySequence("Ctrl+s")); fileMenu->addAction(loadAct); loadAct->setShortcut(QKeySequence("Ctrl+r")); fileMenu->addSeparator(); fileMenu->addAction(rechargeAct); rechargeAct->setShortcut(QKeySequence("Ctrl+c")); fileMenu->addSeparator(); fileMenu->addAction(exitAct); exitAct->setShortcut(QKeySequence("Ctrl+e")); settingMenu->addAction(restartAct); restartAct->setShortcut(QKeySequence("Ctrl+l")); settingMenu->addSeparator(); difficultyMenu = settingMenu->addMenu(tr("选择难度(&D)")); settingMenu->addSeparator(); settingMenu->addAction(foresoundAct); foresoundAct->setCheckable(true); foresoundAct->setChecked(true); foresoundAct->setShortcut(QKeySequence("Ctrl+o")); difficultyMenu->addAction(hardAct); hardAct->setCheckable(true); hardAct->setChecked(false); difficultyMenu->addAction(mediumAct); mediumAct->setCheckable(true); mediumAct->setChecked(true); difficultyMenu->addAction(easyAct); easyAct->setCheckable(true); easyAct->setChecked(false); helpMenu->addAction(manualAct); manualAct->setShortcut(QKeySequence("Ctrl+u")); helpMenu->addAction(aboutAct); aboutAct->setShortcut(QKeySequence("Ctrl+a")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); connect(openAct, SIGNAL(triggered()), this, SLOT(open())); connect(saveAct, SIGNAL(triggered()), this, SLOT(save())); connect(loadAct, SIGNAL(triggered()), this, SLOT(load())); connect(rechargeAct, SIGNAL(triggered()),this, SLOT(recharge())); connect(restartAct, SIGNAL(triggered()), this, SLOT(restart())); connect(hardAct, SIGNAL(triggered()), this, SLOT(hard())); connect(mediumAct, SIGNAL(triggered()), this, SLOT(medium())); connect(easyAct, SIGNAL(triggered()), this, SLOT(easy())); connect(foresoundAct, SIGNAL(triggered()), this, SLOT(foresound())); connect(manualAct, SIGNAL(triggered()), this, SLOT(manual())); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); }
void K3b::VideoDVDRippingView::reloadMedium() { // // For VideoDVD reading it is important that the DVD is not mounted // if( K3b::isMounted( device() ) && !K3b::unmount( device() ) ) { KMessageBox::error( this, i18n("K3b was unable to unmount device '%1' containing medium '%2'. " "Video DVD ripping will not work if the device is mounted. " "Please unmount manually.", device()->blockDeviceName(), k3bcore->mediaCache()->medium( device() ).shortString() ), i18n("Unmounting failed") ); } // // K3b::VideoDVD::open does not necessarily fail on encrypted DVDs if dvdcss is not // available. Thus, we test the availability of libdvdcss here // if( device()->copyrightProtectionSystemType() == K3b::Device::COPYRIGHT_PROTECTION_CSS ) { K3b::LibDvdCss* css = K3b::LibDvdCss::create(); if( !css ) { KMessageBox::error( this, i18n("<p>Unable to read Video DVD contents: Found encrypted Video DVD." "<p>Install <i>libdvdcss</i> to get Video DVD decryption support.") ); return; } else delete css; } QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); if( d->dvd.open( device() ) ) { setTitle( i18n( "%1 (Video DVD)", medium().beautifiedVolumeId() ) ); d->labelLength->setText( i18np("%1 title", "%1 titles", d->dvd.numTitles() ) ); d->model->setVideoDVD( d->dvd ); QApplication::restoreOverrideCursor(); bool transcodeUsable = true; if( !k3bcore ->externalBinManager() ->foundBin( "transcode" ) ) { KMessageBox::sorry( this, i18n("K3b uses transcode to rip Video DVDs. " "Please make sure it is installed.") ); transcodeUsable = false; } else { int vc = 0, ac = 0; for( int i = 0; i < K3b::VideoDVDTitleTranscodingJob::VIDEO_CODEC_NUM_ENTRIES; ++i ) if( K3b::VideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( (K3b::VideoDVDTitleTranscodingJob::VideoCodec)i ) ) ++vc; for( int i = 0; i < K3b::VideoDVDTitleTranscodingJob::AUDIO_CODEC_NUM_ENTRIES; ++i ) if( K3b::VideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( (K3b::VideoDVDTitleTranscodingJob::AudioCodec)i ) ) ++ac; if( !ac || !vc ) { KMessageBox::sorry( this, i18n("<p>K3b uses transcode to rip Video DVDs. " "Your installation of transcode lacks support for any of the " "codecs supported by K3b." "<p>Please make sure it is installed properly.") ); transcodeUsable = false; } } actionCollection()->action("start_rip")->setEnabled( transcodeUsable ); } else { QApplication::restoreOverrideCursor(); KMessageBox::error( this, i18n("Unable to read Video DVD contents.") ); } }
/** @SYMTestCaseID APPFWK-APPARC-0070 @SYMPREQ @SYMTestCaseDesc Test whether the default app icons change with respect to the locale/language. This testcase checks whether BaflUtils::NearestLanguageFile is called when the locale has been changed. @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call User::Language() to check that the default locale is English; Call CT_LocaleStep::CheckIcons to check the size of the current default icons; Call UserSvr::ChangeLocale to change the Locale to French; Call CT_LocaleStep::CheckIcons to check the size of the new icons; Restore the file system and the locale and check if the icons are restored. API Calls:\n @SYMTestExpectedResults Returns KErrNone */ void CT_LocaleStep::TestLocaleDefaultIconL() { INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL started...")); TInt ret = 0; //first checks that language is not currently set to French (any other language except English since English is the default language TEST(User::Language()!=ELangFrench); // getappiconsizes must be called to check if the icons are the default ones // KUidCustomiseDefaultIconApp - uid of CustomiseDefaultIconApp_reg.RSS; this app has a localisable resource file, CustomiseDefaultIconApp_loc.RSS, that does not define any icon // Hence, the default icons must be picked up when the language changes to French. The default icons for French are defined in default_app_icon.m02 CArrayFixFlat<TSize>* newIconSizes = new(ELeave) CArrayFixFlat<TSize>(3); CleanupStack::PushL(newIconSizes); TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); TEST(ret==KErrNone); TEST(newIconSizes->Count()!=0); // these are the sizes of the default icons TSize small(24,24); TSize medium(32,32); TSize large(48,48); TSize fstIcon; TSize secIcon; TSize trdIcon; CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); // Change the locale to French TRAP(ret,ChangeLocaleL(ELangFrench)); TEST(ret==KErrNone); TEST(User::Language()==ELangFrench);//checks that the language has been set to French //Wait for a small period to let apparc receive language change notification User::After(KDelayForOnDemand); //call getappiconsizes to see if the new icons have been changed as as expected // The size of the icons indicates whether the icon corresponding to French Locale has been picked up newIconSizes->Reset(); TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); TEST(ret==KErrNone); TEST(newIconSizes->Count()!=0); small.SetSize(25,25); medium.SetSize(35,35); large.SetSize(50,50); CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); //have to restore the locale before exiting the testcase TRAP(ret,ChangeLocaleL(ELangEnglish)); TEST(ret==KErrNone); TEST(User::Language()==ELangEnglish); //Again wait for a small period to let apparc receive language change notification User::After(KDelayForOnDemand); //call getappiconsizes to see if the new icons have been changed as as expected // The size of the icons indicates whether the icon corresponding to English Locale has been picked up newIconSizes->Reset(); TRAP(ret,iLs.GetAppIconSizes(KUidCustomiseDefaultIconApp, *newIconSizes)); TEST(ret==KErrNone); TEST(newIconSizes->Count()!=0); small.SetSize(24,24); medium.SetSize(32,32); large.SetSize(48,48); CheckIcons(newIconSizes, small, medium,large, fstIcon, secIcon, trdIcon); // Icon cleanup CleanupStack::PopAndDestroy(newIconSizes); newIconSizes=NULL; INFO_PRINTF1(_L("APPFWK-APPARC-0070: TestLocaleDefaultIconL finished...")); }