コード例 #1
0
ファイル: game_load.cpp プロジェクト: coolsee/War-Of-Kingdom
void tgame_load::display_savegame(twindow& window)
{
	const int selected_row = savegame_list_->get_selected_row();

	twidget& preview_pane =
			find_widget<twidget>(&window, "preview_pane", false);

	if (selected_row == -1) {
		preview_pane.set_visible(twidget::HIDDEN);
	} else if (current_page_ == LOCAL_PAGE) {
		preview_pane.set_visible(twidget::VISIBLE);

		savegame::save_info& game = games_[selected_row];
		filename_ = game.name;

		config cfg_summary;
		std::string dummy;

		try {
			savegame::manager::load_summary(game.name, cfg_summary, &dummy);
		} catch(game::load_game_failed&) {
			cfg_summary["corrupt"] = "yes";
		}

		find_widget<timage>(&window, "imgLeader", false).
				set_label(cfg_summary["leader_image"]);

		find_widget<tminimap>(&window, "minimap", false).
				set_map_data(cfg_summary["map_data"]);

		find_widget<tlabel>(&window, "lblScenario", false).set_label(game.name);

		std::stringstream str;
		str << format_time_local(cfg_summary["create"].to_long()) << "\n";
		str << _("Total time") << ": " << format_time_elapse(cfg_summary["duration"].to_int());
		str << "(" << help::tintegrate::generate_format(cfg_summary["hash"].to_int(), "yellow") << ")";
		evaluate_summary_string(str, cfg_summary);

		find_widget<tlabel>(&window, "lblSummary", false).set_label(str.str());

		window.invalidate_layout();

	} else if (current_page_ == NETWORK_PAGE) {
		preview_pane.set_visible(twidget::VISIBLE);

		savegame::www_save_info& game = www_saves_[selected_row];
		filename_ = game.name;

		find_widget<tminimap>(&window, "minimap", false).set_map_data("");

		find_widget<tlabel>(&window, "lblScenario", false).set_label(game.name);

		find_widget<tlabel>(&window, "lblSummary", false).set_label("");
	}
}
コード例 #2
0
ファイル: game_load.cpp プロジェクト: freeors/War-Of-Kingdom
std::string tgame_load::generate_summary(const std::string& game, const config& cfg_summary) const
{
	std::stringstream ss;

	ss << game;
	ss << "\n";
	ss << "\n";

	ss << format_time_local(cfg_summary["create"].to_long()) << "\n";
	ss << _("Total time") << ": " << format_elapse_hms2(cfg_summary["duration"].to_int());
	ss << "(" << tintegrate::generate_format(cfg_summary["hash"].to_int(), "yellow") << ")";
	evaluate_summary_string(ss, cfg_summary);

	return ss.str();
}