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


C++ FileParser::error方法代码示例

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


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

示例1: loadUpgrade

void MenuPowers::loadUpgrade(FileParser &infile) {
	// @ATTR upgrade.id|integer|A power id from powers/powers.txt for this upgrade.
	if (infile.key == "id") {
		int id = popFirstInt(infile.val);
		if (id > 0) {
			skip_section = false;
			power_cell_upgrade.back().id = static_cast<short>(id);
		}
		else {
			skip_section = true;
			power_cell_upgrade.pop_back();
			infile.error("MenuPowers: Power index out of bounds 1-%d, skipping power.", INT_MAX);
		}
		return;
	}

	if (skip_section)
		return;

	// @ATTR upgrade.requires_physoff|integer|Upgrade requires Physical and Offense stat of this value.
	if (infile.key == "requires_physoff") power_cell_upgrade.back().requires_physoff = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_physdef|integer|Upgrade requires Physical and Defense stat of this value.
	else if (infile.key == "requires_physdef") power_cell_upgrade.back().requires_physdef = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_mentoff|integer|Upgrade requires Mental and Offense stat of this value.
	else if (infile.key == "requires_mentoff") power_cell_upgrade.back().requires_mentoff = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_mentdef|integer|Upgrade requires Mental and Defense stat of this value.
	else if (infile.key == "requires_mentdef") power_cell_upgrade.back().requires_mentdef = static_cast<short>(toInt(infile.val));

	// @ATTR upgrade.requires_defense|integer|Upgrade requires Defense stat of this value.
	else if (infile.key == "requires_defense") power_cell_upgrade.back().requires_defense = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_offense|integer|Upgrade requires Offense stat of this value.
	else if (infile.key == "requires_offense") power_cell_upgrade.back().requires_offense = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_physical|integer|Upgrade requires Physical stat of this value.
	else if (infile.key == "requires_physical") power_cell_upgrade.back().requires_physical = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_mental|integer|Upgrade requires Mental stat of this value.
	else if (infile.key == "requires_mental") power_cell_upgrade.back().requires_mental = static_cast<short>(toInt(infile.val));

	// @ATTR upgrade.requires_point|boolean|Upgrade requires a power point to unlock.
	else if (infile.key == "requires_point") power_cell_upgrade.back().requires_point = toBool(infile.val);
	// @ATTR upgrade.requires_level|integer|Upgrade requires at least this level for the hero.
	else if (infile.key == "requires_level") power_cell_upgrade.back().requires_level = static_cast<short>(toInt(infile.val));
	// @ATTR upgrade.requires_power|integer|Upgrade requires another power id.
	else if (infile.key == "requires_power") power_cell_upgrade.back().requires_power.push_back(static_cast<short>(toInt(infile.val)));

	// @ATTR upgrade.visible_requires_status|string|Hide the upgrade if we don't have this campaign status.
	else if (infile.key == "visible_requires_status") power_cell_upgrade.back().visible_requires_status.push_back(infile.val);
	// @ATTR upgrade.visible_requires_not_status|string|Hide the upgrade if we have this campaign status.
	else if (infile.key == "visible_requires_not_status") power_cell_upgrade.back().visible_requires_not.push_back(infile.val);

	else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str());
}
开发者ID:Jeffry84,项目名称:flare-engine,代码行数:51,代码来源:MenuPowers.cpp

示例2: loadLayer

void Map::loadLayer(FileParser &infile) {
	if (infile.key == "type") {
		// @ATTR layer.type|string|Map layer type.
		layers.resize(layers.size()+1);
		layers.back().resize(w);
		for (size_t i=0; i<layers.back().size(); ++i) {
			layers.back()[i].resize(h);
		}
		layernames.push_back(infile.val);
		if (infile.val == "collision")
			collision_layer = static_cast<int>(layernames.size())-1;
	}
	else if (infile.key == "format") {
		// @ATTR layer.format|string|Format for map layer, must be 'dec'
		if (infile.val != "dec") {
			infile.error("Map: The format of a layer must be 'dec'!");
			logErrorDialog("Map: The format of a layer must be 'dec'!");
			mods->resetModConfig();
			Exit(1);
		}
	}
	else if (infile.key == "data") {
		// @ATTR layer.data|raw|Raw map layer data
		// layer map data handled as a special case
		// The next h lines must contain layer data.
		for (int j=0; j<h; j++) {
			std::string val = infile.getRawLine();
			infile.incrementLineNum();
			if (!val.empty() && val[val.length()-1] != ',') {
				val += ',';
			}

			// verify the width of this row
			int comma_count = 0;
			for (unsigned i=0; i<val.length(); ++i) {
				if (val[i] == ',') comma_count++;
			}
			if (comma_count != w) {
				infile.error("Map: A row of layer data has a width not equal to %d.", w);
				mods->resetModConfig();
				Exit(1);
			}

			for (int i=0; i<w; i++)
				layers.back()[i][j] = static_cast<unsigned short>(popFirstInt(val));
		}
	}
	else {
		infile.error("Map: '%s' is not a valid key.", infile.key.c_str());
	}
}
开发者ID:hansjoachim,项目名称:flare-engine,代码行数:51,代码来源:Map.cpp

示例3: Menu

MenuExit::MenuExit() : Menu() {

	// Load config settings
	FileParser infile;
	if(infile.open("menus/exit.txt")) {
		while(infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;
			else
				infile.error("MenuExit: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}

	exitClicked = false;

	buttonExit = new WidgetButton();

	if (SAVE_ONEXIT)
		buttonExit->label = msg->get("Save & Exit");
	else
		buttonExit->label = msg->get("Exit");

	buttonClose = new WidgetButton("images/menus/buttons/button_x.png");

	setBackground("images/menus/confirm_bg.png");

	tablist.add(buttonExit);
	tablist.add(buttonClose);

	align();
}
开发者ID:RetroAsh,项目名称:flare-engine-next,代码行数:32,代码来源:MenuExit.cpp

示例4: timer

MenuActiveEffects::MenuActiveEffects(StatBlock *_stats)
	: timer(NULL)
	, stats(_stats)
	, orientation(false) { // horizontal
	// Load config settings
	FileParser infile;
	// @CLASS MenuActiveEffects|Description of menus/activeeffects.txt
	if(infile.open("menus/activeeffects.txt")) {
		while(infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;

			// @ATTR orientation|bool|True is vertical orientation; False is horizontal orientation.
			if(infile.key == "orientation") {
				orientation = toBool(infile.val);
			}
			else {
				infile.error("MenuActiveEffects: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	loadGraphics();
	align();
}
开发者ID:LungTakumi,项目名称:flare-engine,代码行数:26,代码来源:MenuActiveEffects.cpp

示例5: loadText

void MenuBook::loadText(FileParser &infile) {
	// @ATTR text.text_pos|int, int, int, ["left", "center", "right"] : X, Y, Width, Text justify|Position of the text.
	if (infile.key == "text_pos") {
		size.back().x = popFirstInt(infile.val);
		size.back().y = popFirstInt(infile.val);
		size.back().w = popFirstInt(infile.val);
		std::string _justify = popFirstString(infile.val);

		if (_justify == "left") justify.back() = JUSTIFY_LEFT;
		else if (_justify == "center") justify.back() = JUSTIFY_CENTER;
		else if (_justify == "right") justify.back() = JUSTIFY_RIGHT;
	}
	// @ATTR text.text_font|color, string : Font color, Font style|Font color and style.
	else if (infile.key == "text_font") {
		Color color;
		color.r = static_cast<Uint8>(popFirstInt(infile.val));
		color.g = static_cast<Uint8>(popFirstInt(infile.val));
		color.b = static_cast<Uint8>(popFirstInt(infile.val));
		textColor.back() = color;
		textFont.back() = popFirstString(infile.val);
	}
	// @ATTR text.text|string|The text to be displayed.
	else if (infile.key == "text") {
		// we use substr here to remove the comma from the end
		textData.back() = msg->get(infile.val.substr(0, infile.val.length() - 1));
	}
	else {
		infile.error("MenuBook: '%s' is not a valid key.", infile.key.c_str());
	}
}
开发者ID:igorko,项目名称:flare-engine,代码行数:30,代码来源:MenuBook.cpp

示例6: loadMusic

void GameSwitcher::loadMusic() {
	if (AUDIO && MUSIC_VOLUME) {
		Mix_FreeMusic(music);
		music = NULL;

		std::string music_filename = "";
		FileParser infile;
		// @CLASS GameSwitcher: Default music|Description of engine/default_music.txt
		if (infile.open("engine/default_music.txt", true, "")) {
			while (infile.next()) {
				// @ATTR music|string|Filename of a music file to play during game states that don't already have music.
				if (infile.key == "music") music_filename = infile.val;
				else infile.error("GameSwitcher: '%s' is not a valid key.", infile.key.c_str());
			}
			infile.close();
		}

		if (music_filename != "") {
			music = Mix_LoadMUS((mods->locate(music_filename)).c_str());
			if (!music)
				logError("GameSwitcher: Mix_LoadMUS: %s\n", Mix_GetError());
		}
	}

	if (music) {
		Mix_VolumeMusic(MUSIC_VOLUME);
		Mix_PlayMusic(music, -1);
	}
}
开发者ID:skyserpent,项目名称:flare-engine,代码行数:29,代码来源:GameSwitcher.cpp

示例7:

MenuHUDLog::MenuHUDLog()
	: overlay_bg(NULL)
	, click_to_dismiss(false)
	, hide_overlay(false)
{

	// Load config settings
	FileParser infile;
	if(infile.open("menus/hudlog.txt")) {
		while(infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;
			else
				infile.error("MenuHUDLog: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}

	align();

	font->setFont("font_regular");
	paragraph_spacing = font->getLineHeight()/2;

	color_normal = font->getColor("menu_normal");
}
开发者ID:hansjoachim,项目名称:flare-engine,代码行数:25,代码来源:MenuHUDLog.cpp

示例8: if

CombatText::CombatText() {
	msg_color[MSG_GIVEDMG] = font->getColor(FontEngine::COLOR_COMBAT_GIVEDMG);
	msg_color[MSG_TAKEDMG] = font->getColor(FontEngine::COLOR_COMBAT_TAKEDMG);
	msg_color[MSG_CRIT] = font->getColor(FontEngine::COLOR_COMBAT_CRIT);
	msg_color[MSG_BUFF] = font->getColor(FontEngine::COLOR_COMBAT_BUFF);
	msg_color[MSG_MISS] = font->getColor(FontEngine::COLOR_COMBAT_MISS);

	duration = settings->max_frames_per_sec; // 1 second
	speed = 60.f / settings->max_frames_per_sec;
	offset = 48; // average height of flare-game enemies, so a sensible default

	// Load config settings
	FileParser infile;
	// @CLASS CombatText|Description of engine/combat_text.txt
	if(infile.open("engine/combat_text.txt", FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) {
		while(infile.next()) {
			if(infile.key == "duration") {
				// @ATTR duration|duration|Duration of the combat text in 'ms' or 's'.
				duration = Parse::toDuration(infile.val);
			}
			else if(infile.key == "speed") {
				// @ATTR speed|int|Motion speed of the combat text.
				speed = static_cast<float>(Parse::toInt(infile.val) * 60) / settings->max_frames_per_sec;
			}
			else if (infile.key == "offset") {
				// @ATTR offset|int|The vertical offset for the combat text's starting position.
				offset = Parse::toInt(infile.val);
			}
			else {
				infile.error("CombatText: '%s' is not a valid key.",infile.key.c_str());
			}
		}
		infile.close();
	}
}
开发者ID:clintbellanger,项目名称:flare-engine,代码行数:35,代码来源:CombatText.cpp

示例9: if

CombatText::CombatText() {
	msg_color[COMBAT_MESSAGE_GIVEDMG] = font->getColor("combat_givedmg");
	msg_color[COMBAT_MESSAGE_TAKEDMG] = font->getColor("combat_takedmg");
	msg_color[COMBAT_MESSAGE_CRIT] = font->getColor("combat_crit");
	msg_color[COMBAT_MESSAGE_BUFF] = font->getColor("combat_buff");
	msg_color[COMBAT_MESSAGE_MISS] = font->getColor("combat_miss");

	duration = MAX_FRAMES_PER_SEC; // 1 second
	speed = 60.f / MAX_FRAMES_PER_SEC;
	offset = 48; // average height of flare-game enemies, so a sensible default

	// Load config settings
	FileParser infile;
	// @CLASS CombatText|Description of engine/combat_text.txt
	if(infile.open("engine/combat_text.txt")) {
		while(infile.next()) {
			if(infile.key == "duration") {
				// @ATTR duration|duration|Duration of the combat text in 'ms' or 's'.
				duration = parse_duration(infile.val);
			}
			else if(infile.key == "speed") {
				// @ATTR speed|int|Motion speed of the combat text.
				speed = static_cast<float>(toInt(infile.val) * 60) / MAX_FRAMES_PER_SEC;
			}
			else if (infile.key == "offset") {
				// @ATTR offset|int|The vertical offset for the combat text's starting position.
				offset = toInt(infile.val);
			}
			else {
				infile.error("CombatText: '%s' is not a valid key.",infile.key.c_str());
			}
		}
		infile.close();
	}
}
开发者ID:hansjoachim,项目名称:flare-engine,代码行数:35,代码来源:CombatText.cpp

示例10: loadText

void MenuBook::loadText(FileParser &infile) {
	// @ATTR text.text_pos|x (integer), y (integer), w (integer), [left:center:right]|Position of the text.
	if (infile.key == "text_pos") {
		size.back().x = popFirstInt(infile.val);
		size.back().y = popFirstInt(infile.val);
		size.back().w = popFirstInt(infile.val);
		std::string _justify = popFirstString(infile.val);

		if (_justify == "left") justify.back() = JUSTIFY_LEFT;
		else if (_justify == "center") justify.back() = JUSTIFY_CENTER;
		else if (_justify == "right") justify.back() = JUSTIFY_RIGHT;
	}
	// @ATTR text.text_font|r (integer), g (integer), b (integer), style (string)|Font color and style.
	else if (infile.key == "text_font") {
		Color color;
		color.r = popFirstInt(infile.val);
		color.g = popFirstInt(infile.val);
		color.b = popFirstInt(infile.val);
		textColor.back() = color;
		textFont.back() = popFirstString(infile.val);
	}
	// @ATTR text.text|string|The text to be displayed.
	else if (infile.key == "text") {
		textData.back() = infile.val;
		// remove comma from the end
		textData.back() = textData.back().substr(0, textData.back().length() - 1);
	}
	else {
		infile.error("MenuBook: '%s' is not a valid key.", infile.key.c_str());
	}
}
开发者ID:RetroAsh,项目名称:flare-engine-next,代码行数:31,代码来源:MenuBook.cpp

示例11: readConfig

void GameStateConfigBase::readConfig() {
	//Load the menu configuration from file

	FileParser infile;
	if (infile.open("menus/config.txt")) {
		while (infile.next()) {
			if (parseKeyButtons(infile))
				continue;

			int x1 = popFirstInt(infile.val);
			int y1 = popFirstInt(infile.val);
			int x2 = popFirstInt(infile.val);
			int y2 = popFirstInt(infile.val);

			if (parseKey(infile, x1, y1, x2, y2))
				continue;
			else if (parseStub(infile))
				continue;
			else {
				infile.error("GameStateConfigBase: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}
}
开发者ID:sudoman,项目名称:flare-engine,代码行数:25,代码来源:GameStateConfigBase.cpp

示例12: if

LootManager::LootManager()
	: sfx_loot(0)
	, drop_max(1)
	, drop_radius(1)
	, hero(NULL)
	, tooltip_margin(0)
{
	tip = new WidgetTooltip();

	FileParser infile;
	// load loot animation settings from engine config file
	// @CLASS Loot|Description of engine/loot.txt
	if (infile.open("engine/loot.txt")) {
		while (infile.next()) {
			if (infile.key == "tooltip_margin") {
				// @ATTR tooltip_margin|integer|Vertical offset of the loot tooltip from the loot itself.
				tooltip_margin = toInt(infile.val);
			}
			else if (infile.key == "autopickup_currency") {
				// @ATTR autopickup_currency|boolean|Enable autopickup for currency
				AUTOPICKUP_CURRENCY = toBool(infile.val);
			}
			else if (infile.key == "currency_name") {
				// @ATTR currenct_name|string|Define the name of currency in game
				CURRENCY = msg->get(infile.val);
			}
			else if (infile.key == "vendor_ratio") {
				// @ATTR vendor_ratio|integer|Prices ratio for vendors
				VENDOR_RATIO = toInt(infile.val) / 100.0f;
			}
			else if (infile.key == "sfx_loot") {
				// @ATTR sfx_loot|string|Sound effect for dropping loot.
				sfx_loot =  snd->load(infile.val, "LootManager dropping loot");
			}
			else if (infile.key == "drop_max") {
				// @ATTR drop_max|integer|The maximum number of random item stacks that can drop at once
				drop_max = toInt(infile.val);
				clampFloor(drop_max, 1);
			}
			else if (infile.key == "drop_radius") {
				// @ATTR drop_radius|integer|The distance (in tiles) away from the origin that loot can drop
				drop_radius = toInt(infile.val);
				clampFloor(drop_radius, 1);
			}
			else {
				infile.error("LootManager: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	// reset current map loot
	loot.clear();

	loadGraphics();

	full_msg = false;

	loadLootTables();
}
开发者ID:Gallaecio,项目名称:flare-engine,代码行数:60,代码来源:LootManager.cpp

示例13: loadNPC

void Map::loadNPC(FileParser &infile) {
	std::string s;
	if (infile.key == "type") {
		// @ATTR npc.type|string|(IGNORED BY ENGINE) The "type" field, as used by Tiled and other mapping tools.
		npcs.back().type = infile.val;
	}
	else if (infile.key == "filename") {
		// @ATTR npc.filename|string|Filename of an NPC definition.
		npcs.back().id = infile.val;
	}
	else if (infile.key == "requires_status") {
		// @ATTR npc.requires_status|list(string)|Status required for NPC load. There can be multiple states, separated by comma
		while ( (s = popFirstString(infile.val)) != "")
			npcs.back().requires_status.push_back(s);
	}
	else if (infile.key == "requires_not_status") {
		// @ATTR npc.requires_not_status|list(string)|Status required to be missing for NPC load. There can be multiple states, separated by comma
		while ( (s = popFirstString(infile.val)) != "")
			npcs.back().requires_not_status.push_back(s);
	}
	else if (infile.key == "location") {
		// @ATTR npc.location|point|Location of NPC
		npcs.back().pos.x = static_cast<float>(popFirstInt(infile.val)) + 0.5f;
		npcs.back().pos.y = static_cast<float>(popFirstInt(infile.val)) + 0.5f;
	}
	else {
		infile.error("Map: '%s' is not a valid key.", infile.key.c_str());
	}
}
开发者ID:hansjoachim,项目名称:flare-engine,代码行数:29,代码来源:Map.cpp

示例14: loadFPS

void GameSwitcher::loadFPS() {
	// Load FPS rendering settings
	FileParser infile;
	// @CLASS GameSwitcher: FPS counter|Description of menus/fps.txt
	if (infile.open("menus/fps.txt")) {
		while(infile.next()) {
			// @ATTR position|x (integer), y (integer), align (alignment)|Position of the fps counter.
			if(infile.key == "position") {
				fps_position.x = popFirstInt(infile.val);
				fps_position.y = popFirstInt(infile.val);
				fps_corner = parse_alignment(popFirstString(infile.val));
			}
			// @ATTR color|r (integer), g (integer), b (integer)|Color of the fps counter text.
			else if(infile.key == "color") {
				fps_color = toRGB(infile.val);
			}
			else {
				infile.error("GameSwitcher: '%s' is not a valid key.", infile.key.c_str());
			}
		}
		infile.close();
	}

	// this is a dummy string used to approximate the fps position when aligned to the right
	font->setFont("font_regular");
	fps_position.w = font->calc_width("00 fps");
	fps_position.h = font->getLineHeight();

	// Delete the label object if it exists (we'll recreate this with showFPS())
	if (label_fps) {
		delete label_fps;
		label_fps = NULL;
	}
}
开发者ID:mactec0,项目名称:flare-engine,代码行数:34,代码来源:GameSwitcher.cpp

示例15: loadTitles

void GameStatePlay::loadTitles() {
	FileParser infile;
	// @CLASS GameStatePlay: Titles|Description of engine/titles.txt
	if (infile.open("engine/titles.txt")) {
		while (infile.next()) {
			if (infile.new_section && infile.section == "title") {
				Title t;
				titles.push_back(t);
			}

			if (titles.empty()) continue;

			// @ATTR title.title|string|The displayed title.
			if (infile.key == "title") titles.back().title = infile.val;
			// @ATTR title.level|int|Requires level.
			else if (infile.key == "level") titles.back().level = toInt(infile.val);
			// @ATTR title.power|power_id|Requires power.
			else if (infile.key == "power") titles.back().power = toInt(infile.val);
			// @ATTR title.requires_status|string|Requires status.
			else if (infile.key == "requires_status") titles.back().requires_status = infile.val;
			// @ATTR title.requires_not_status|string|Requires not status.
			else if (infile.key == "requires_not_status") titles.back().requires_not = infile.val;
			// @ATTR title.primary_stat|["physical", "mental", "offense", "defense", "physoff", "physment", "physdef", "mentoff", "offdef", "mentdef"]|Required primary stat.
			else if (infile.key == "primary_stat") titles.back().primary_stat = infile.val;
			else infile.error("GameStatePlay: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}
}
开发者ID:MORTAL2000,项目名称:flare-engine,代码行数:29,代码来源:GameStatePlay.cpp


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