int invutil_interactive(char *inv_path, char *mountpt, uuid_t *uuidp, time32_t timeSecs) { int keyc; node_t *menulist; menulist = generate_menu(inv_path); if(menulist == NULL) { fprintf(stderr, "%s: abnormal termination\n", g_programName); exit(1); } if(timeSecs > 0) { list_prune(menulist, mountpt, uuidp, timeSecs); } keyc = sizeof(keyv) / sizeof(keyv[0]); create_windows(); menu(mainmenu, 1, 0, menulist, keyc, keyv); endwin(); close_all_stobj(); close_all_invidx(); close_all_fstab(); return 0; }
void tmp_side_wait::process_network_data(const config& data, const network::connection sock) { twindow& window = *sides_table_->get_window(); // ui::process_network_data(data, sock); if (data["message"] != "") { gui2::show_transient_message(gui_.video() , _("Response") , data["message"]); } if (data["failed"].to_bool()) { legacy_result_ = QUIT; window.close(); return; } else if(data.child("stop_updates")) { stop_updates_ = true; } else if(data.child("start_game")) { // LOG_NW << "received start_game message\n"; legacy_result_ = PLAY; window.close(); return; } else if(data.child("leave_game")) { legacy_result_ = QUIT; window.close(); return; } else if (const config &c = data.child("scenario_diff")) { // LOG_NW << "received diff for scenario... applying...\n"; /** @todo We should catch config::error and then leave the game. */ level_.apply_diff(c); generate_menu(window); } else if(data.child("side")) { level_ = data; /* LOG_NW << "got some sides. Current number of sides = " << level_.child_count("side") << ',' << data.child_count("side") << '\n'; */ generate_menu(window); } }
vsx_widget_controller_slider::vsx_widget_controller_slider() { generate_menu(); menu->init(); color.set(85.0f/255.0f,170.0f/255.0f,1,1); set_size(vsx_vector3<>(sizeunit, sizeunit* 4.0f)); handlesize=0.5*sizeunit; value=0.0f;target_value=0.0f; capminv=0; capmaxv=1; capmin = false; capmax = false; amp=1; ofs=0; }
vsx_widget_controller_pad::vsx_widget_controller_pad() { widget_type = 0; a.x = 0; a.y = 0; b.x = 1; b.y = 1; widget_type = VSX_WIDGET_TYPE_CONTROLLER; coord_type = VSX_WIDGET_COORD_CENTER; set_size(vsx_vector3<>(0.1,0.1)); set_pos(vsx_vector3<>(-0.06)); generate_menu(); menu->init(); drawing = false; }
bool tmp_side_wait::handle(int tag, tsock::ttype type, const config& data) { if (type == tsock::t_disconnected) { legacy_result_ = QUIT; sides_table_->get_window()->set_retval(twindow::CANCEL); } if (type != tsock::t_data) { return false; } twindow& window = *sides_table_->get_window(); if (data["message"] != "") { gui2::show_transient_message(disp_.video() , _("Response") , data["message"]); } if (data["failed"].to_bool()) { legacy_result_ = QUIT; window.close(); return true; } else if (data.child("stop_updates")) { stop_updates_ = true; } else if (const config& cfg = data.child("change_faction")) { int type = cfg["type"].to_int(-1); int len = cfg["len"].to_int(-1); if (type == BINARY_HEROS) { heros_.map_from_mem(game_config::savegame_cache, heros_.file_size()); } else if (type == BINARY_HEROS_START) { heros_start_.map_from_mem(game_config::savegame_cache, heros_start_.file_size()); } else if (type == BINARY_REPLAY) { replay_data_.read(game_config::savegame_cache); } else if (type == BINARY_GROUP) { runtime_groups::from_mem(heros_, game_config::savegame_cache, len); } } else if (data.child("start_game")) { // LOG_NW << "received start_game message\n"; legacy_result_ = PLAY; window.close(); } else if(data.child("leave_game")) { legacy_result_ = QUIT; window.close(); } else if (const config &c = data.child("scenario_diff")) { // LOG_NW << "received diff for scenario... applying...\n"; /** @todo We should catch config::error and then leave the game. */ level_.apply_diff(c); generate_menu(window); } else if (data.child("side")) { level_ = data; generate_menu(window); } else { return false; } return true; }
void tmp_side_wait::join_game(twindow& window, bool observe) { // if we have got valid side data // the first condition is to make sure that we don't have another // WML message with a side-tag in it while (!level_.has_attribute("version") || !level_.child("side")) { level_.clear(); // below function has BUG!!! network::connection data_res = dialogs::network_receive_dialog(disp_, _("Getting game data..."), level_); if (!data_res) { legacy_result_ = QUIT; window.close(); return; } mp::check_response(data_res, level_); if (level_.child("leave_game")) { legacy_result_ = QUIT; window.close(); return; } } if (!observe) { //search for an appropriate vacant slot. If a description is set //(i.e. we're loading from a saved game), then prefer to get the side //with the same description as our login. Otherwise just choose the first //available side. const config *side_choice = NULL; int side_num = -1, nb_sides = 0; BOOST_FOREACH (const config &sd, level_.child_range("side")) { if (sd["controller"] == "network" && sd["current_player"].empty()) { if (!side_choice) { // found the first empty side side_choice = &sd; side_num = nb_sides; } if (sd["current_player"] == preferences::login()) { side_choice = &sd; side_num = nb_sides; break; // found the preferred one } } ++nb_sides; } if (!side_choice) { legacy_result_ = QUIT; window.close(); return; } bool allow_changes = (*side_choice)["allow_changes"].to_bool(true); //if the client is allowed to choose their team, instead of having //it set by the server, do that here. std::string leader_choice, gender_choice; int faction_choice = 0; if(allow_changes) { events::event_context context; const config &era = level_.child("era"); /** @todo Check whether we have the era. If we don't inform the user. */ if (!era) throw config::error(_("No era information found.")); /* config::const_child_itors possible_sides = era.child_range("multiplayer_side"); if (possible_sides.first == possible_sides.second) { set_result(QUIT); throw config::error(_("No multiplayer sides found")); return; } */ int color = side_num; const std::string color_str = (*side_choice)["color"].str(); if (!color_str.empty()) color = game_config::color_info(color_str).index() - 1; config faction; config& change = faction.add_child("change_faction"); change["name"] = preferences::login(); change["faction"] = 0; // now, it is ignored change["leader"] = "random"; // now, it is ignored change["gender"] = "random"; // now, it is ignored network::send_data(lobby->chat, faction); } } generate_menu(window); }
void wait::join_game(bool observe) { const bool download_res = download_level_data(); if (!download_res) { DBG_MP << "mp wait: could not download level data, quitting..."; set_result(QUIT); return; } else if (level_["started"].to_bool()) { set_result(PLAY); return; } if (first_scenario_) { state_ = saved_game(); state_.classification() = game_classification(level_); if(state_.classification().campaign_type != game_classification::CAMPAIGN_TYPE::MULTIPLAYER) { ERR_MP << "Mp wait recieved a game that is not a multiplayer game\n"; } // Make sure that we have the same config as host, if possible. game_config_manager::get()->load_game_config_for_game(state_.classification()); } // Add the map name to the title. append_to_title(": " + get_scenario()["name"].t_str()); game_config::add_color_info(get_scenario()); if (!observe) { //search for an appropriate vacant slot. If a description is set //(i.e. we're loading from a saved game), then prefer to get the side //with the same description as our login. Otherwise just choose the first //available side. const config *side_choice = NULL; int side_num = -1, nb_sides = 0; BOOST_FOREACH(const config &sd, get_scenario().child_range("side")) { DBG_MP << "*** side " << nb_sides << "***\n" << sd.debug() << "***\n"; if (sd["controller"] == "reserved" && sd["current_player"] == preferences::login()) { side_choice = &sd; side_num = nb_sides; break; } if (sd["controller"] == "human" && sd["player_id"].empty()) { if (!side_choice) { // found the first empty side side_choice = &sd; side_num = nb_sides; } if (sd["current_player"] == preferences::login()) { side_choice = &sd; side_num = nb_sides; break; // found the preferred one } } if (sd["player_id"] == preferences::login()) { //We already own a side in this game. generate_menu(); return; } ++nb_sides; } if (!side_choice) { size_t count = 0; for(config::child_itors its = get_scenario().child_range("side"); its.second != its.first; ++its.first) { ++count; } DBG_MP << "could not find a side, all " << count << " sides were unsuitable\n"; set_result(QUIT); return; } bool allow_changes = (*side_choice)["allow_changes"].to_bool(true); //if the client is allowed to choose their team, instead of having //it set by the server, do that here. if(allow_changes) { events::event_context context; const config &era = level_.child("era"); /** @todo Check whether we have the era. If we don't inform the user. */ if (!era) throw config::error(_("No era information found.")); config::const_child_itors possible_sides = era.child_range("multiplayer_side"); if (possible_sides.first == possible_sides.second) { set_result(QUIT); throw config::error(_("No multiplayer sides found")); } const std::string color = (*side_choice)["color"].str(); std::vector<const config*> era_factions; BOOST_FOREACH(const config &side, possible_sides) { era_factions.push_back(&side); } const bool lock_settings = get_scenario()["force_lock_settings"].to_bool(); const bool use_map_settings = level_.child("multiplayer")["mp_use_map_settings"].to_bool(); const bool saved_game = level_.child("multiplayer")["savegame"].to_bool(); ng::flg_manager flg(era_factions, *side_choice, lock_settings, use_map_settings, saved_game); std::vector<std::string> choices; BOOST_FOREACH(const config *s, flg.choosable_factions()) { const config &side = *s; const std::string &name = side["name"]; const std::string &icon = side["image"]; if (!icon.empty()) { std::string rgb = side["flag_rgb"]; if (rgb.empty()) rgb = "magenta"; choices.push_back(IMAGE_PREFIX + icon + "~RC(" + rgb + ">" + color + ")" + COLUMN_SEPARATOR + name); } else { choices.push_back(name); } } std::vector<gui::preview_pane* > preview_panes; leader_preview_pane leader_selector(video(), flg, color); preview_panes.push_back(&leader_selector); const int faction_choice = gui::show_dialog(video(), NULL, _("Choose your faction:"), _("Starting position: ") + lexical_cast<std::string>(side_num + 1), gui::OK_CANCEL, &choices, &preview_panes); if(faction_choice < 0) { set_result(QUIT); return; } config faction; config& change = faction.add_child("change_faction"); change["change_faction"] = true; change["name"] = preferences::login(); change["faction"] = flg.current_faction()["id"]; change["leader"] = flg.current_leader(); change["gender"] = flg.current_gender(); network::send_data(faction, 0); } }