foreach (Misc misc, miscs_) { html += "<tr>\n<td>" + misc.quantity().toString(2) + "</td>\n"; html += "<td></td>\n"; html += "<td>" + escape(misc.name()) + "</td>\n"; html += "<td></td>\n"; html += "<td>" + misc.type() + "</td>\n"; html += "<td></td>\n"; html += "<td colspan=3>" + escape(misc.notes()) + "</td>\n</tr>\n\n"; }
static void play_video(HINSTANCE hInstance, int videoId) { String movieFileStr; // movieFileStr = DIR_MOVIE; if( videoId == 0 ) { movieFileStr += "INTRO.AVI"; } else { movieFileStr += "MOVIE"; movieFileStr += videoId; movieFileStr += ".AVI"; } video.set_skip_on_fail(); if( m.is_file_exist(movieFileStr) ) { //---------- play the movie now ---------// video.init(); if( video.init_success ) { video.play_until_end( movieFileStr, hInstance, 60 ); } else { // display a message box (note:sys.main_hwnd is not valid) // MessageBox( NULL, "Cannot initialize ActiveMovie", // "Virtual U", MB_OK | MB_ICONWARNING | MB_DEFBUTTON1 | MB_TASKMODAL ); } video.deinit(); } }
static void open_http(char* shortcutFilename, char* httpAddr) { if( !m.is_file_exist(shortcutFilename) ) { // create 7k2home.url file String str = "[InternetShortcut]\r\nURL="; str += httpAddr; str += "\r\n"; File urlFile; urlFile.file_create(shortcutFilename); urlFile.file_write( str, strlen(str) ); urlFile.file_close(); } if( m.is_file_exist(shortcutFilename) ) { sys.deinit(); HINSTANCE hinst = ShellExecute( sys.main_hwnd, "open", shortcutFilename, NULL, "", SW_SHOWNORMAL ); } }
void miscTest(int argc, char ** argv) { Misc mscTest; vector<int> A = buildVector(argc, argv); cout << mscTest.maxDiff_DP(A) << endl; cout << mscTest.maxDiff_divide(A) << endl; cout << mscTest.maxDiff_subArray(A) << endl; // mscTest.testprintA(); // vector<vector<int> > A{{1,2,3}, {4,5,6}, {7,8,9}, {10,11,12}}; // mscTest.printMatrixClockwisely(A); // vector<int> A = buildVector(argc, argv); // try { // cout << mscTest.findMajorityNum(A) << endl; // } catch (exception &e) { // cout << e.what() << endl; // } // cout << mscTest.getLongestSymmetrySubString(string(argv[1])) << endl; // mscTest.calcProbDices(atoi(argv[1])); // cout << endl; // mscTest.calcProbDices_DP(atoi(argv[1])); // cout << mscTest.addWithConstrains(atoi(argv[1])) << endl; // vector<int> a = buildVector(argc, argv); // cout << mscTest.minRotateSortArray(a) << endl; // mscTest.findMinIntCombination(a); // mscTest.printNDigits(atoi(argv[1])); // mscTest.printUglyNum(15); // cout << mscTest.findLongestCommonSubarray(string(argv[1]), string(argv[2])) << endl; // vector<int> pushV{1,2,3,4,5}; // cout << mscTest.findLastElmentInRemove_efficient(pushV, atoi(argv[1])) << endl; // mscTest.findContinuousSequence3(15); // cout << endl; // mscTest.findContinuousSequence2(10, 15); // mscTest.ArrayToOddEvenArray(pushV); // vector<int> popV{4,5,3,1,2}; // cout << mscTest.checkPushPop(pushV, popV) << endl; }
void MiscEditor::save() { Misc* m = obsMisc; if( m == 0 ) { setVisible(false); return; } m->setName(lineEdit_name->text()); m->setType( static_cast<Misc::Type>(comboBox_type->currentIndex()) ); m->setUse( static_cast<Misc::Use>(comboBox_use->currentIndex()) ); // TODO: fill in the rest of the "set" methods. m->setTime(lineEdit_time->toSI()); m->setAmountIsWeight( (checkBox_isWeight->checkState() == Qt::Checked)? true : false ); m->setAmount( lineEdit_amount->toSI()); m->setUseFor(textEdit_useFor->toPlainText()); m->setNotes( textEdit_notes->toPlainText() ); setVisible(false); }
//---------- Begin of function main ----------// // // Compilation constants: // // DEBUG - normal debugging // DEBUG2 - shortest path searching and unit action debugging // DEBUG3 - debugging some functions (e.g. Location::get_loc()) which // will cause major slowdown. // // Command line paramters: // -join <named or ip address> // Begin the program by attempting to connect to the specified address. // -host // Begin the program by hosting a multiplayer match // -name <player name> // Set the name you wish to be known as. // // You cannot specify -join or -host more than once. // int main(int argc, char **argv) { #ifndef _MSC_VER setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif const char *lobbyJoinCmdLine = "-join"; const char *lobbyHostCmdLine = "-host"; const char *lobbyNameCmdLine = "-name"; char *join_host = NULL; int lobbied = 0; sys.set_config_dir(); //try to read from CONFIG.DAT, moved to AM.CPP if( !config.load("CONFIG.DAT") ) { new_config_dat_flag = 1; config.init(); } //----- read command line arguments -----// for (int i = 0; i < argc; i++) { if (!strcmp(argv[i], lobbyJoinCmdLine)) { if (lobbied) { ERR("You cannot specify multiple -host or -join options.\n"); return 1; } if (i >= argc - 1) { ERR("The %s switch requires a hostname parameter.\n", lobbyJoinCmdLine); return 1; } lobbied = 1; join_host = argv[i+1]; i++; } else if (!strcmp(argv[i], lobbyHostCmdLine)) { if (lobbied) { ERR("You cannot specify multiple -host or -join options.\n"); return 1; } lobbied = 1; } else if (!strcmp(argv[i], lobbyNameCmdLine)) { if (i >= argc - 1) { ERR("The %s switch requires a hostname parameter.\n", lobbyNameCmdLine); return 1; } strncpy(config.player_name, argv[i+1], config.PLAYER_NAME_LEN); config.player_name[config.PLAYER_NAME_LEN] = 0; i++; } } #ifdef ENABLE_INTRO_VIDEO //----------- play movie ---------------// if (!sys.set_game_dir()) return 1; if (!lobbied) { String movieFileStr; movieFileStr = DIR_MOVIE; movieFileStr += "INTRO.AVI"; video.set_skip_on_fail(); // ###### begin Gilbert 29/10 #####// if( !misc.is_file_exist("SKIPAVI.SYS") && misc.is_file_exist(movieFileStr) ) // ###### end Gilbert 29/10 #####// { //---------- play the movie now ---------// video.init(); if( video.init_success ) { video.play_until_end( movieFileStr, hInstance, 60 ); } else { // display a message box (note:sys.main_hwnd is not valid) // MessageBox( NULL, "Cannot initialize ActiveMovie", // "Seven Kingdoms", MB_OK | MB_ICONWARNING | MB_DEFBUTTON1 | MB_TASKMODAL ); } video.deinit(); } } #endif // ENABLE_INTRO_VIDEO if( !sys.init() ) return FALSE; err.set_extra_handler( extra_error_handler ); // set extra error handler, save the game when a error happens if (!lobbied) game.main_menu(); #ifndef DISABLE_MULTI_PLAYER else game.multi_player_menu(lobbied, join_host); #endif // DISABLE_MULTI_PLAYER sys.deinit(); return 1; }
//---------- Begin of function WinMain ----------// //¹ç // WinMain - initialization, message loop // // Compilation constants: // // DEBUG - normal debugging // DEBUG2 - shortest path searching and unit action debugging // DEBUG3 - debugging some functions (e.g. Location::get_loc()) which // will cause major slowdown. // int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //try to read from CONFIG.DAT, moved to AM.CPP if( !config.load("CONFIG.DAT") ) { new_config_dat_flag = 1; config.init(); } //--------------------------------------// #ifdef IMAGICMP static char lobbyLaunchCmdLine[] = "IM"; #else static char lobbyLaunchCmdLine[] = "-!lobby!"; #endif #ifdef ENABLE_INTRO_VIDEO //----------- play movie ---------------// sys.set_game_dir(); if( strstr(lpCmdLine, lobbyLaunchCmdLine) == NULL ) // skip if launch from lobby { String movieFileStr; movieFileStr = DIR_MOVIE; movieFileStr += "INTRO.AVI"; video.set_skip_on_fail(); // ###### begin Gilbert 29/10 #####// if( !m.is_file_exist("SKIPAVI.SYS") && m.is_file_exist(movieFileStr) ) // ###### end Gilbert 29/10 #####// { //---------- play the movie now ---------// video.init(); if( video.init_success ) { video.play_until_end( movieFileStr, hInstance, 60 ); } else { // display a message box (note:sys.main_hwnd is not valid) // MessageBox( NULL, "Cannot initialize ActiveMovie", // "Seven Kingdoms", MB_OK | MB_ICONWARNING | MB_DEFBUTTON1 | MB_TASKMODAL ); } video.deinit(); } } #endif // ENABLE_INTRO_VIDEO if( !sys.init(hInstance) ) return FALSE; err.set_extra_handler( extra_error_handler ); // set extra error handler, save the game when a error happens #ifdef DEMO game.demo_disp_logo(); game.main_menu(); #else if( strstr(lpCmdLine, lobbyLaunchCmdLine) == NULL ) game.main_menu(); #ifndef DISABLE_MULTI_PLAYER else game.multi_player_menu(lpCmdLine); // if detect launched from lobby #endif // DISABLE_MULTI_PLAYER #endif sys.deinit(); return 1; }
//---------- Begin of function WinMain ----------// //! //! WinMain - initialization, message loop //! //! Compilation constants: //! //! DEBUG - normal debugging //! //! DEMO - demo version //! ADMIN - administrator version //! NO_CDCHECK - no CD check //! NO_AUTOSAVE - no autosave //! //! Release version defines: //! Standard version: DEBUG, NO_MEM_CLASS //! Administrator version: DEBUG, NO_MEM_CLASS, ADMIN //! Demo version: DEBUG, NO_MEM_CLASS, DEMO //! int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //------ set game directory and check CD ------// sys.set_game_dir(); #ifndef NO_CDCHECK #ifndef DEMO if( !sys.cdrom_drive ) { #ifdef ADMIN char* msg = "Please insert Virtual U - Administrator Version CDROM and try again."; #else char* msg = "Please insert Virtual U CDROM and try again."; #endif MessageBox(sys.main_hwnd, msg, WIN_TITLE, MB_OK | MB_ICONERROR); return 0; } #endif #endif //----------- play movie ---------------// OSVERSIONINFO osVersion; memset( &osVersion, 0, sizeof(osVersion) ); // do not play movie in Win2000 osVersion.dwOSVersionInfoSize = sizeof(osVersion); if( !m.is_file_exist("SKIPAVI.SYS") && GetVersionEx(&osVersion) && osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { play_video(hInstance, 0); } config.init(); //--------------------------------------// if( !sys.init(hInstance) ) return FALSE; err.set_extra_handler( extra_error_handler ); // set extra error handler, save the game when a error happens #ifdef DEBUG // break at exception, for debugging if( sys.debug_session ) { // directX may change fpu control word, so change after sys.init // all exception but no inexact, underflow and denormal number exception _control87( _EM_INEXACT | _EM_UNDERFLOW | _EM_DENORMAL, _MCW_EM ); } #endif // DEBUG #ifdef DEMO audio.play_wav("DEMOOPEN",audio.int_to_DsVolume(config.sound_effect_volume)); #endif game.main_menu(); #ifdef DEMO demo_screen(); #endif sys.deinit(); return 0; }
void ScaleRecipeTool::scale(Equipment* equip, double newEff) { if( recObs == 0 || equip == 0 ) return; int i, size; // Calculate volume ratio double currentBatchSize_l = recObs->batchSize_l(); double newBatchSize_l = equip->batchSize_l(); double volRatio = newBatchSize_l / currentBatchSize_l; // Calculate efficiency ratio double oldEfficiency = recObs->efficiency_pct(); double effRatio = oldEfficiency / newEff; Database::instance().addToRecipe(recObs, equip); recObs->setBatchSize_l(newBatchSize_l); recObs->setBoilSize_l(equip->boilSize_l()); recObs->setEfficiency_pct(newEff); recObs->setBoilTime_min(equip->boilTime_min()); QList<Fermentable*> ferms = recObs->fermentables(); size = ferms.size(); for( i = 0; i < size; ++i ) { Fermentable* ferm = ferms[i]; // NOTE: why the hell do we need this? if( ferm == 0 ) continue; if( !ferm->isSugar() && !ferm->isExtract() ) { ferm->setAmount_kg(ferm->amount_kg() * effRatio * volRatio); } else { ferm->setAmount_kg(ferm->amount_kg() * volRatio); } } QList<Hop*> hops = recObs->hops(); size = hops.size(); for( i = 0; i < size; ++i ) { Hop* hop = hops[i]; // NOTE: why the hell do we need this? if( hop == 0 ) continue; hop->setAmount_kg(hop->amount_kg() * volRatio); } QList<Misc*> miscs = recObs->miscs(); size = miscs.size(); for( i = 0; i < size; ++i ) { Misc* misc = miscs[i]; // NOTE: why the hell do we need this? if( misc == 0 ) continue; misc->setAmount( misc->amount() * volRatio ); } QList<Water*> waters = recObs->waters(); size = waters.size(); for( i = 0; i < size; ++i ) { Water* water = waters[i]; // NOTE: why the hell do we need this? if( water == 0 ) continue; water->setAmount_l(water->amount_l() * volRatio); } Mash* mash = recObs->mash(); if( mash == 0 ) return; QList<MashStep*> mashSteps = mash->mashSteps(); size = mashSteps.size(); for( i = 0; i < size; ++i ) { MashStep* step = mashSteps[i]; // NOTE: why the hell do we need this? if( step == 0 ) continue; // Reset all these to zero so that the user // will know to re-run the mash wizard. step->setDecoctionAmount_l(0); step->setInfuseAmount_l(0); } // I don't think I should scale the yeasts. // Let the user know what happened. QMessageBox::information(this, tr("Recipe Scaled"), tr("The equipment and mash have been reset due to the fact that mash temperatures do not scale easily. Please re-run the mash wizard.") ); }