当前位置: 首页>>代码示例>>C++>>正文


C++ CmdLineArgs::Has方法代码示例

本文整理汇总了C++中CmdLineArgs::Has方法的典型用法代码示例。如果您正苦于以下问题:C++ CmdLineArgs::Has方法的具体用法?C++ CmdLineArgs::Has怎么用?C++ CmdLineArgs::Has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmdLineArgs的用法示例。


在下文中一共展示了CmdLineArgs::Has方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProcessCommandLineArgs

static void ProcessCommandLineArgs(const CmdLineArgs& args)
{
    // TODO: all these options (and the ones processed elsewhere) should
    // be documented somewhere for users.

    // Handle "-conf=key:value" (potentially multiple times)
    std::vector<CStr> conf = args.GetMultiple("conf");
    for (size_t i = 0; i < conf.size(); ++i)
    {
        CStr name_value = conf[i];
        if (name_value.Find(':') != -1)
        {
            CStr name = name_value.BeforeFirst(":");
            CStr value = name_value.AfterFirst(":");
            g_ConfigDB.SetValueString(CFG_COMMAND, name, value);
        }
    }

    if (args.Has("g"))
    {
        g_Gamma = args.Get("g").ToFloat();
        if (g_Gamma == 0.0f)
            g_Gamma = 1.0f;
    }

//	if (args.Has("listfiles"))
//		trace_enable(true);

    if (args.Has("profile"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "profile", args.Get("profile"));

    if (args.Has("quickstart"))
    {
        g_Quickstart = true;
        g_DisableAudio = true; // do this for backward-compatibility with user expectations
    }

    if (args.Has("nosound"))
        g_DisableAudio = true;

    if (args.Has("shadows"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "shadows", "true");

    if (args.Has("xres"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "xres", args.Get("xres"));

    if (args.Has("yres"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "yres", args.Get("yres"));

    if (args.Has("vsync"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "vsync", "true");

    if (args.Has("ooslog"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "ooslog", "true");

    if (args.Has("serializationtest"))
        g_ConfigDB.SetValueString(CFG_COMMAND, "serializationtest", "true");
}
开发者ID:righnatios,项目名称:0ad,代码行数:58,代码来源:Config.cpp

示例2: ProcessCommandLineArgs

static void ProcessCommandLineArgs(const CmdLineArgs& args)
{
	// TODO: all these options (and the ones processed elsewhere) should
	// be documented somewhere for users.

	if (args.Has("buildarchive"))
	{
		// note: VFS init is sure to have been completed by now
		// (since CONFIG_Init reads from file); therefore,
		// it is safe to call this from here directly.
//		vfs_opt_rebuild_main_archive("mods/official/official1.zip", "../logs/trace.txt");
	}

	// Handle "-conf=key:value" (potentially multiple times)
	std::vector<CStr> conf = args.GetMultiple("conf");
	for (size_t i = 0; i < conf.size(); ++i)
	{
		CStr name_value = conf[i];
		if (name_value.Find(':') != -1)
		{
			CStr name = name_value.BeforeFirst(":");
			CStr value = name_value.AfterFirst(":");
			g_ConfigDB.CreateValue(CFG_COMMAND, name)->m_String = value;
		}
	}

	if (args.Has("g"))
	{
		g_Gamma = args.Get("g").ToFloat();
		if (g_Gamma == 0.0f)
			g_Gamma = 1.0f;
	}

//	if (args.Has("listfiles"))
//		trace_enable(true);

	if (args.Has("profile"))
		g_ConfigDB.CreateValue(CFG_COMMAND, "profile")->m_String = args.Get("profile");

	if (args.Has("quickstart"))
	{
		g_Quickstart = true;
		g_DisableAudio = true; // do this for backward-compatibility with user expectations
	}

	if (args.Has("nosound"))
		g_DisableAudio = true;

	if (args.Has("shadows"))
		g_ConfigDB.CreateValue(CFG_COMMAND, "shadows")->m_String = "true";

	if (args.Has("xres"))
		g_ConfigDB.CreateValue(CFG_COMMAND, "xres")->m_String = args.Get("xres");

	if (args.Has("yres"))
		g_ConfigDB.CreateValue(CFG_COMMAND, "yres")->m_String = args.Get("yres");

	if (args.Has("vsync"))
		g_ConfigDB.CreateValue(CFG_COMMAND, "vsync")->m_String = "true";
}
开发者ID:TiriliPiitPiit,项目名称:0ad,代码行数:60,代码来源:Config.cpp

示例3: ATLAS_RunIfOnCmdLine

// starts the Atlas UI if an "-editor" switch is found on the command line.
// this is the alternative to starting the main menu and clicking on
// the editor button; it is much faster because it's called during early
// init and therefore skips GUI setup.
// notes:
// - GUI init still runs, but some GUI setup will be skipped since
//   ATLAS_IsRunning() will return true.
bool ATLAS_RunIfOnCmdLine(const CmdLineArgs& args, bool force)
{
	if (force || args.Has("editor"))
	{
		ATLAS_Run(args, ATLAS_NO_GUI);
		return true;
	}

	return false;
}
开发者ID:Marlinc,项目名称:0ad,代码行数:17,代码来源:Atlas.cpp

示例4: home

Paths::Paths(const CmdLineArgs& args)
{
	m_root = Root(args.GetArg0());

#ifdef INSTALLED_DATADIR
	m_rdata = OsPath(STRINGIZE(INSTALLED_DATADIR))/"";
#else
	m_rdata = m_root/"data"/"";
#endif

	const char* subdirectoryName = args.Has("writableRoot")? 0 : "0ad";

	// everything is a subdirectory of the root
	if(!subdirectoryName)
	{
		m_data = m_rdata;
		m_config = m_data/"config"/"";
		m_cache = m_data/"cache"/"";
		m_logs = m_root/"logs"/"";
	}
	else
	{
#if OS_WIN
		const OsPath appdata = wutil_AppdataPath() / subdirectoryName/"";
		m_data = appdata/"data"/"";
		m_config = appdata/"config"/"";
		m_cache = appdata/"cache"/"";
		m_logs = appdata/"logs"/"";
#else
		const char* envHome = getenv("HOME");
		ENSURE(envHome);
		const OsPath home(envHome);
		const OsPath xdgData   = XDG_Path("XDG_DATA_HOME",   home, home/".local/share/") / subdirectoryName;
		const OsPath xdgConfig = XDG_Path("XDG_CONFIG_HOME", home, home/".config/"     ) / subdirectoryName;
		const OsPath xdgCache  = XDG_Path("XDG_CACHE_HOME",  home, home/".cache/"      ) / subdirectoryName;
		m_data   = xdgData/"";
		m_cache  = xdgCache/"";
		m_config = xdgConfig/"config"/"";
		m_logs   = xdgConfig/"logs"/"";
#endif
	}
}
开发者ID:Marlinc,项目名称:0ad,代码行数:42,代码来源:Paths.cpp

示例5: home

Paths::Paths(const CmdLineArgs& args)
{
	m_root = Root(args.GetArg0());

	m_rdata = RootData(args.GetArg0());

	const char* subdirectoryName = args.Has("writableRoot")? 0 : "0ad";

	if(!subdirectoryName)
	{
		// Note: if writableRoot option is passed to the game, then
		//	all the data is a subdirectory of the root
		m_gameData = m_rdata;
		m_userData = m_gameData;
		m_config = m_gameData / "config"/"";
		m_cache = m_gameData / "cache"/"";
		m_logs = m_root / "logs"/"";
	}
	else // OS-specific path handling
	{

#if OS_ANDROID

		const OsPath appdata = OsPath("/sdcard/0ad/appdata");

		// We don't make the game vs. user data distinction on Android
		m_gameData = appdata/"data"/"";
		m_userData = m_gameData;
		m_config = appdata/"config"/"";
		m_cache = appdata/"cache"/"";
		m_logs = appdata/"logs"/"";

#elif OS_WIN

		/* For reasoning behind our Windows paths, see the discussion here:
		 * http://www.wildfiregames.com/forum/index.php?showtopic=14759
		 * 
		 * Summary:
		 *	1. Local appdata: for bulky unfriendly data like the cache,
		 *      which can be recreated if deleted; doesn't need backing up.
		 *  2. Roaming appdata: for slightly less unfriendly data like config
		 *      files that might theoretically be shared between different
		 *      machines on a domain.
		 *  3. Personal / My Documents: for data explicitly created by the user,
		 *      and which should be visible and easily accessed. We use a non-
		 *      localized My Games subfolder for improved organization.
		 */

		// %localappdata%/0ad/
		const OsPath localAppdata = wutil_LocalAppdataPath() / subdirectoryName/"";
		// %appdata%/0ad/
		const OsPath roamingAppData = wutil_RoamingAppdataPath() / subdirectoryName/"";
		// My Documents/My Games/0ad/
		const OsPath personalData = wutil_PersonalPath() / "My Games" / subdirectoryName/"";

		m_cache = localAppdata / "cache"/"";
		m_gameData = roamingAppData / "data"/"";
		m_userData = personalData/"";
		m_config = roamingAppData / "config"/"";
		m_logs = localAppdata / "logs"/"";

#elif OS_MACOSX

		/* For reasoning behind our OS X paths, see the discussion here:
		 * http://www.wildfiregames.com/forum/index.php?showtopic=15511
		 *
		 * Summary:
		 *  1. Application Support: most data associated with the app
		 *		should be stored here, with few exceptions (e.g. temporary
		 *		data, cached data, and managed media files).
		 *  2. Caches: used for non-critial app data that can be easily
		 *		regenerated if this directory is deleted. It is not
		 *		included in backups by default.
		 *
		 * Note: the paths returned by osx_Get*Path are not guaranteed to exist,
		 *     but that's OK since we always create them on demand.
		 */

		// We probably want to use the same subdirectoryName regardless
		//	of whether running a bundle or from SVN. Apple recommends using
		//	company name, bundle name or bundle identifier.
		OsPath appSupportPath;  // ~/Library/Application Support/0ad
		OsPath cachePath;       // ~/Library/Caches/0ad

		{
			std::string path = osx_GetAppSupportPath();
			ENSURE(!path.empty());
			appSupportPath = OsPath(path) / subdirectoryName;
		}
		{
			std::string path = osx_GetCachesPath();
			ENSURE(!path.empty());
			cachePath = OsPath(path) / subdirectoryName;
		}

		// We don't make the game vs. user data distinction on OS X
		m_gameData = appSupportPath /"";
		m_userData = m_gameData;
		m_cache = cachePath/"";
		m_config = appSupportPath / "config"/"";
//.........这里部分代码省略.........
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:101,代码来源:Paths.cpp


注:本文中的CmdLineArgs::Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。