/* * menu_base_t */ void menu_base_t::open() { init(gengine); place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); font(B_NORMAL_FONT); foreground(wmain->map_rgb(0xffffff)); background(wmain->map_rgb(0x000000)); build_all(); }
void new_player_t::open() { init(gengine); place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); font(B_NORMAL_FONT); foreground(wmain->map_rgb(255, 255, 255)); background(wmain->map_rgb(0, 0, 0)); memset(name, 0, sizeof(name)); name[0] = 'A'; currentIndex = 0; editing = 1; build_all(); SDL_EnableUNICODE(1); }
/** * Resets all data based on the provided config. * This includes some processing of the config, such as expanding base units. * A pointer to the config is stored, so the config must be persistent. */ void unit_type_data::set_config(config &cfg) { DBG_UT << "unit_type_data::set_config, name: " << cfg["name"] << "\n"; clear(); unit_cfg_ = &cfg; for (const config &mt : cfg.child_range("movetype")) { movement_types_.insert(std::make_pair(mt["name"].str(), movetype(mt))); gui2::tloadscreen::progress(); } for (const config &r : cfg.child_range("race")) { const unit_race race(r); races_.insert(std::pair<std::string,unit_race>(race.id(),race)); gui2::tloadscreen::progress(); } // Movetype resistance patching for (const config &r : cfg.child_range("resistance_defaults")) { const std::string& dmg_type = r["id"]; config temp_cfg; for (const config::attribute &attr : r.attribute_range()) { const std::string &mt = attr.first; if (mt == "id" || mt == "default" || movement_types_.find(mt) == movement_types_.end()) { continue; } patch_movetype(movement_types_[mt].get_resistances(), dmg_type, attr.second, 100, true); } if (r.has_attribute("default")) { for (movement_type_map::value_type &mt : movement_types_) { // Don't apply a default if a value is explicitly specified. if (r.has_attribute(mt.first)) { continue; } patch_movetype(mt.second.get_resistances(), dmg_type, r["default"], 100, false); } } } // Movetype move/defend patching for (const config &terrain : cfg.child_range("terrain_defaults")) { const std::string& ter_type = terrain["id"]; config temp_cfg; static const std::string terrain_info_tags[] = {"movement", "vision", "jamming", "defense"}; for (const std::string &tag : terrain_info_tags) { if (!terrain.has_child(tag)) { continue; } const config& info = terrain.child(tag); for (const config::attribute &attr : info.attribute_range()) { const std::string &mt = attr.first; if (mt == "default" || movement_types_.find(mt) == movement_types_.end()) { continue; } if (tag == "defense") { patch_movetype(movement_types_[mt].get_defense(), ter_type, attr.second, 100, true); } else if (tag == "vision") { patch_movetype(movement_types_[mt].get_vision(), ter_type, attr.second, 99, true); } else if (tag == "movement") { patch_movetype(movement_types_[mt].get_movement(), ter_type, attr.second, 99, true); } else if (tag == "jamming") { patch_movetype(movement_types_[mt].get_jamming(), ter_type, attr.second, 99, true); } } if (info.has_attribute("default")) { for (movement_type_map::value_type &mt : movement_types_) { // Don't apply a default if a value is explicitly specified. if (info.has_attribute(mt.first)) { continue; } if (tag == "defense") { patch_movetype(mt.second.get_defense(), ter_type, info["default"], 100, false); } else if (tag == "vision") { patch_movetype(mt.second.get_vision(), ter_type, info["default"], 99, false); } else if (tag == "movement") { patch_movetype(mt.second.get_movement(), ter_type, info["default"], 99, false); } else if (tag == "jamming") { patch_movetype(mt.second.get_jamming(), ter_type, info["default"], 99, false); } } } } } // Apply base units. for (config &ut : cfg.child_range("unit_type")) { if ( ut.has_child("base_unit") ) { // Derived units must specify a new id. // (An error message will be emitted later if id is empty.) const std::string id = ut["id"]; if ( !id.empty() ) { std::vector<std::string> base_tree(1, id); apply_base_unit(ut, cfg, base_tree); gui2::tloadscreen::progress(); } } } // Handle inheritance and recording of unit types. for (config &ut : cfg.child_range("unit_type")) { std::string id = ut["id"]; // Every type is required to have an id. if ( id.empty() ) { ERR_CF << "[unit_type] with empty id=, ignoring:\n" << ut.debug(); continue; } // Complete the gender-specific children of the config. if ( config &male_cfg = ut.child("male") ) { fill_unit_sub_type(male_cfg, ut, true); handle_variations(male_cfg); } if ( config &female_cfg = ut.child("female") ) { fill_unit_sub_type(female_cfg, ut, true); handle_variations(female_cfg); } // Complete the variation-defining children of the config. handle_variations(ut); // Record this unit type. if ( insert(std::make_pair(id, unit_type(ut))).second ) { LOG_CONFIG << "added " << id << " to unit_type list (unit_type_data.unit_types)\n"; } else { ERR_CF << "Multiple [unit_type]s with id=" << id << " encountered." << std::endl; } gui2::tloadscreen::progress(); } // Build all unit types. (This was not done within the loop for performance.) build_all(unit_type::CREATED); // Suppress some unit types (presumably used as base units) from the help. if (const config &hide_help = cfg.child("hide_help")) { hide_help_all_ = hide_help["all"].to_bool(); read_hide_help(hide_help); } }
static fd_set build_all_er () { return build_all (2); }
static fd_set build_all_write () { return build_all (1); }
static fd_set build_all_read () { return build_all (0); }
void new_player_t::rebuild() { int sel = selected_index(); build_all(); select(sel); }
void yesno_menu_t::rebuild() { int sel = selected_index(); build_all(); select(sel); }