Ejemplo n.º 1
0
void tgame_load::xmit_button_callback(twindow& window)
{
	tlistbox& list = *lists_[current_page_];

	const size_t index = size_t(list.get_selected_row());
	if (current_page_ == LOCAL_PAGE) {
		if (index < games_.size()) {
			// See if we should ask the user for deletion confirmation
			std::string message = _("You can upload one only, it will delete existed, continue?");
			const int res = gui2::show_message(disp_.video(), _("Confirm"), message, gui2::tmessage::yes_no_buttons);
			if (res == gui2::twindow::CANCEL) {
				return;
			}

			config cfg_summary;
			std::string dummy;
			try {
				savegame::manager::load_summary(games_[index].name, cfg_summary, &dummy);
			} catch(game::load_game_failed&) {
				message = _("This file is corrupted, can not upload!");
				gui2::show_message(disp_.video(), _("Confirm"), message);
				return;
			}

			http::upload_save(disp_, heros_, get_saves_dir() + "/" + games_[index].name);
		}
	} else if (current_page_ == NETWORK_PAGE) {
		if (index < www_saves_.size()) {

			std::string fname = http::download_save(disp_, heros_, www_saves_[index].sid);
			if (!fname.empty()) {
				sheet_.find(LOCAL_PAGE)->second->set_value(true);
				sheet_toggled(sheet_.find(LOCAL_PAGE)->second);
			}
		}
	}
}
Ejemplo n.º 2
0
void tgame_load::xmit_button_callback(twindow& window)
{
	const size_t index = size_t(savegame_list_->get_selected_row());
	if (current_page_ == LOCAL_PAGE) {
		if (index < games_.size()) {
			// See if we should ask the user for deletion confirmation
			std::string message = dsgettext("wesnoth", "You can upload one only, it will delete existed, continue?");
			const int res = gui2::show_message(disp_.video(), dsgettext("wesnoth", "Confirm"), message, gui2::tmessage::yes_no_buttons);
			if (res == gui2::twindow::CANCEL) {
				return;
			}
			http::upload_save(disp_, get_saves_dir() + "/" + games_[index].name);
		}
	} else if (current_page_ == NETWORK_PAGE) {
		if (index < www_saves_.size()) {

			std::string fname = http::download_save(disp_, www_saves_[index].sid);
			if (!fname.empty()) {
				sheet_.find(LOCAL_PAGE)->second->set_value(true);
				sheet_toggled(sheet_.find(LOCAL_PAGE)->second);
			}
		}
	}
}