void update_avail_modules (int popup) { int i; int f; /* remembers if a change is made to what is available, so we can draw if necessary */ for (i = 0; i < NUMOF_MODULES; i++) { int g = inv_sbut(i); f = module_tflag[i]; if (tech_level >= main_groups[g].tech * MAX_TECH_LEVEL/1000) { if (module_tflag[i] == 0) if (popup) activate_module (i); f = 1; } else if (module_tflag[i] != 0 && tech_level < ((main_groups[g].tech - (main_groups[g].tech/10)) * MAX_TECH_LEVEL/1000) ) f = 0; if (module_tflag[i] != f) { module_tflag[i] = f; draw_module (i, module_graphic[i]); } } /* XXX: Why is this here? Should be with rest of tech gained messages! */ /* GCS: Because the modern windmill tech reuses the same module number as the primative windmill? */ if (tech_level > MODERN_WINDMILL_TECH && modern_windmill_flag == 0) { ok_dial_box ("mod_wind_up.mes", GOOD, 0L); modern_windmill_flag = 1; } }
/* Display possible modules and select one */ bool select_module() { s32b k, sel, max; /* Hack */ use_color = TRUE; /* Init some lua */ init_lua(); /* Some ports need to separate the module scripts from the installed mods, so we need to check for these in two different places */ if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "mods_aux.lua", FALSE)) tome_dofile_anywhere(ANGBAND_DIR_MODULES, "mods_aux.lua", TRUE); if(!tome_dofile_anywhere(ANGBAND_DIR_CORE, "modules.lua", FALSE)) tome_dofile_anywhere(ANGBAND_DIR_MODULES, "modules.lua", TRUE); /* Grab the savefiles */ call_lua("max_modules", "()", "d", &max); /* No need to bother the player if there is only one module */ sel = -1; if (force_module) call_lua("find_module", "(s)", "d", force_module, &sel); if (max == 1) sel = 0; if (sel != -1) { cptr tmp; /* Process the module */ call_lua("init_module", "(d)", "", sel); call_lua("get_module_name", "(d)", "s", sel, &tmp); game_module = string_make(tmp); activate_module(); return FALSE; } sel = 0; /* Preprocess the basic prefs, we need them to have movement keys */ process_pref_file("pref.prf"); while (TRUE) { /* Clear screen */ Term_clear(); /* Let the user choose */ c_put_str(TERM_YELLOW, "Welcome to ToME, you must select a module to play,", 1, 12); c_put_str(TERM_YELLOW, "either ToME official module or third party ones.", 2, 13); put_str("Press 8/2/4/6 to move, Return to select and Esc to quit.", 4, 3); dump_modules(sel, max); k = inkey(); if (k == ESCAPE) { quit(NULL); } if (k == '6') { sel++; if (sel >= max) sel = 0; continue; } else if (k == '4') { sel--; if (sel < 0) sel = max - 1; continue; } else if (k == '2') { sel += 4; if (sel >= max) sel = sel % max; continue; } else if (k == '8') { sel -= 4; if (sel < 0) sel = (sel + max - 1) % max; continue; } else if (k == '\r') { if (sel < 26) k = I2A(sel); else k = toupper(I2A(sel)); } { int x; cptr tmp; if (islower(k)) x = A2I(k); else x = A2I(tolower(k)) + 26; if ((x < 0) || (x >= max)) continue; /* Process the module */ call_lua("init_module", "(d)", "", x); call_lua("get_module_name", "(d)", "s", x, &tmp); game_module = string_make(tmp); activate_module(); return (FALSE); } } /* Shouldnt happen */ return (FALSE); }