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


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

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


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

示例1: getMapName

string GameStateLoad::getMapName(const string& map_filename) {
	FileParser infile;
	if (!infile.open(mods->locate("maps/" + map_filename))) return "";
	string map_name = "";

	while (map_name == "" && infile.next()) {
		if (infile.key == "title")
			map_name = msg->get(infile.val);
	}

	infile.close();
	return map_name;
}
开发者ID:MdreW,项目名称:flare,代码行数:13,代码来源:GameStateLoad.cpp

示例2: if

LootManager::LootManager(StatBlock *_hero)
	: sfx_loot(0)
	, tooltip_margin(0) {
	hero = _hero; // we need the player's position for dropping loot in a valid spot

	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 == "loot_animation") {
				// @ATTR loot_animation|x(int), y(int), w(int), h(int)|
				animation_pos = toRect(infile.val);
			}
			else if (infile.key == "loot_animation_offset") {
				// @ATTR loot_animation_offset|x (integer), y (integer)|
				animation_offset = toPoint(infile.val);
			}
			else if (infile.key == "tooltip_margin") {
				// @ATTR tooltip_margin|integer|
				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");
			}
		}
		infile.close();
	}

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

	loadGraphics();

	full_msg = false;
}
开发者ID:YuanhuanZheng,项目名称:flare-engine,代码行数:51,代码来源:LootManager.cpp

示例3: readGameSlot

void GameStateLoad::readGameSlot(int slot) {

	stringstream filename;
	FileParser infile;

	// abort if not a valid slot number
	if (slot < 0 || slot >= GAME_SLOT_MAX) return;

	// save slots are named save#.txt
	filename << "save" << (slot+1) << ".txt";

	if (!infile.open(PATH_USER + filename.str())) return;

	while (infile.next()) {

		// load (key=value) pairs
		if (infile.key == "name")
			stats[slot].name = infile.val;
		else if (infile.key == "class")
			stats[slot].character_class = infile.val;
		else if (infile.key == "xp")
			stats[slot].xp = atoi(infile.val.c_str());
		else if (infile.key == "build") {
			stats[slot].physical_character = atoi(infile.nextValue().c_str());
			stats[slot].mental_character = atoi(infile.nextValue().c_str());
			stats[slot].offense_character = atoi(infile.nextValue().c_str());
			stats[slot].defense_character = atoi(infile.nextValue().c_str());
		}
		else if (infile.key == "equipped") {
			string repeat_val = infile.nextValue();
			while (repeat_val != "") {
				equipped[slot].push_back(toInt(repeat_val));
				repeat_val = infile.nextValue();
			}
		}
		else if (infile.key == "option") {
			stats[slot].base = infile.nextValue();
			stats[slot].head = infile.nextValue();
			stats[slot].portrait = infile.nextValue();
		}
		else if (infile.key == "spawn") {
			current_map[slot] = getMapName(infile.nextValue());
		}
	}
	infile.close();

	stats[slot].recalc();
	loadPreview(slot);

}
开发者ID:ZabinX,项目名称:concordia,代码行数:50,代码来源:GameStateLoad.cpp

示例4: getLanguagesList

bool GameStateConfig::getLanguagesList() {
	FileParser infile;
	if (infile.open("engine/languages.txt")) {
		unsigned int i=0;
		while (infile.next()) {
			language_ISO[i] = infile.key;
			language_full[i] = infile.nextValue();
			i += 1;
		}
		infile.close();
	}

	return true;
}
开发者ID:fulrbuaa,项目名称:flare-engine,代码行数:14,代码来源:GameStateConfig.cpp

示例5: loadKeyBindings

/**
 * Key bindings are found in config/keybindings.txt
 */
void InputState::loadKeyBindings() {

	FileParser infile;	
	int key1;
	int key2;
	int cursor;

	if (!infile.open("config/keybindings.txt")) return;
	
	while (infile.next()) {

		key1 = eatFirstInt(infile.val, ',');
		key2 = atoi(infile.val.c_str());
		
		cursor = -1;
		
		if (infile.key == "cancel") cursor = CANCEL;
		else if (infile.key == "accept") cursor = ACCEPT;
		else if (infile.key == "up") cursor = UP;
		else if (infile.key == "down") cursor = DOWN;
		else if (infile.key == "left") cursor = LEFT;
		else if (infile.key == "right") cursor = RIGHT;
		else if (infile.key == "bar1") cursor = BAR_1;
		else if (infile.key == "bar2") cursor = BAR_2;
		else if (infile.key == "bar3") cursor = BAR_3;
		else if (infile.key == "bar4") cursor = BAR_4;
		else if (infile.key == "bar5") cursor = BAR_5;
		else if (infile.key == "bar6") cursor = BAR_6;
		else if (infile.key == "bar7") cursor = BAR_7;
		else if (infile.key == "bar8") cursor = BAR_8;
		else if (infile.key == "bar9") cursor = BAR_9;
		else if (infile.key == "bar0") cursor = BAR_0;
		else if (infile.key == "main1") cursor = MAIN1;
		else if (infile.key == "main2") cursor = MAIN2;
		else if (infile.key == "character") cursor = CHARACTER;
		else if (infile.key == "inventory") cursor = INVENTORY;
		else if (infile.key == "powers") cursor = POWERS;
		else if (infile.key == "log") cursor = LOG;
		else if (infile.key == "ctrl") cursor = CTRL;
		else if (infile.key == "shift") cursor = SHIFT;
		else if (infile.key == "delete") cursor = DELETE;
		
		if (cursor != -1) {
			binding[cursor] = key1;
			binding_alt[cursor] = key2;
		}

	}
	infile.close();
}
开发者ID:Longer,项目名称:flare,代码行数:53,代码来源:InputState.cpp

示例6: loadOptions

/**
 * Load body type "base" and portrait/head "portrait" options from a config file
 *
 * @param filename File containing entries for option=base,look
 */
void GameStateNew::loadOptions(const string& filename) {
	FileParser fin;
	if (!fin.open("engine/" + filename, true, false)) return;

	while (fin.next()) {
		if (fin.key == "option") {
			base.push_back(fin.nextValue());
			head.push_back(fin.nextValue());
			portrait.push_back(fin.nextValue());
			name.push_back(msg->get(fin.nextValue()));
		}
	}
	fin.close();
}
开发者ID:clintbellanger,项目名称:flare-engine-next,代码行数:19,代码来源:GameStateNew.cpp

示例7: getLanguagesList

bool GameStateConfig::getLanguagesList()
{
	FileParser infile;
	if (infile.open(mods->locate("engine/languages.txt"))) {
		unsigned int i=0;
		while (infile.next()) {
			   language_ISO[i] = infile.key;
			   language_full[i] = infile.nextValue();
			   i += 1;
			}
		} else fprintf(stderr, "Unable to open languages.txt!\n");
		infile.close();

	return true;
}
开发者ID:runtime-x86,项目名称:flare,代码行数:15,代码来源:GameStateConfig.cpp

示例8: loadBackgroundList

void GameSwitcher::loadBackgroundList() {
	background_list.clear();
	freeBackground();

	FileParser infile;
	// @CLASS GameSwitcher: Background images|Description of engine/menu_backgrounds.txt
	if (infile.open("engine/menu_backgrounds.txt", true, "")) {
		while (infile.next()) {
			// @ATTR background|string|Filename of a background image to be added to the pool of random menu backgrounds
			if (infile.key == "background") background_list.push_back(infile.val);
			else infile.error("GameSwitcher: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}
}
开发者ID:mactec0,项目名称:flare-engine,代码行数:15,代码来源:GameSwitcher.cpp

示例9: if

MenuPowers::MenuPowers(StatBlock *_stats, MenuActionBar *_action_bar)
	: stats(_stats)
	, action_bar(_action_bar)
	, skip_section(false)
	, powers_unlock(NULL)
	, overlay_disabled(NULL)
	, points_left(0)
	, default_background("")
	, tab_control(NULL)
	, tree_loaded(false)
	, prev_powers_list_size(0)
	, newPowerNotification(false)
{

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

	// Read powers data from config file
	FileParser infile;
	// @CLASS MenuPowers: Menu layout|Description of menus/powers.txt
	if (infile.open("menus/powers.txt")) {
		while (infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;

			// @ATTR label_title|label|Position of the "Powers" text.
			if (infile.key == "label_title") title = eatLabelInfo(infile.val);
			// @ATTR unspent_points|label|Position of the text that displays the amount of unused power points.
			else if (infile.key == "unspent_points") unspent_points = eatLabelInfo(infile.val);
			// @ATTR close|point|Position of the close button.
			else if (infile.key == "close") close_pos = toPoint(infile.val);
			// @ATTR tab_area|rectangle|Position and dimensions of the tree pages.
			else if (infile.key == "tab_area") tab_area = toRect(infile.val);

			else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}

	loadGraphics();

	menu_powers = this;

	color_bonus = font->getColor("menu_bonus");
	color_penalty = font->getColor("menu_penalty");
	color_flavor = font->getColor("item_flavor");

	align();
}
开发者ID:sudoman,项目名称:flare-engine,代码行数:48,代码来源:MenuPowers.cpp

示例10: if

WidgetTooltip::WidgetTooltip() {

	FileParser infile;
	// load tooltip settings from engine config file
	if (infile.open("engine/tooltips.txt")) {
		while (infile.next()) {
			if (infile.key == "tooltip_offset")
				offset = toInt(infile.val);
			else if (infile.key == "tooltip_width")
				width = toInt(infile.val);
			else if (infile.key == "tooltip_margin")
				margin = toInt(infile.val);
		}
		infile.close();
	}
}
开发者ID:Herttua,项目名称:flare-engine,代码行数:16,代码来源:WidgetTooltip.cpp

示例11: atoi

FontEngine::FontEngine() {
	font_pt = 10;

	// Initiate SDL_ttf
	if(!TTF_WasInit() && TTF_Init()==-1) {
		printf("TTF_Init: %s\n", TTF_GetError());
		exit(2);
	}

	// load the font
	string font_path;
	FileParser infile;
	if (infile.open(mods->locate("engine/font_settings.txt"))) {
		while (infile.next()) {
			if (infile.key == "font_regular"){
				font_path = infile.val;
			}
			if (infile.key == "ptsize"){
				font_pt = atoi(infile.val.c_str());
			}
		}
	}
	font_path = mods->locate("fonts/" + font_path);
	ttfont = TTF_OpenFont(font_path.c_str(), font_pt);
	if(!ttfont) printf("TTF_OpenFont: %s\n", TTF_GetError());

	// calculate the optimal line height
	line_height = TTF_FontLineSkip(ttfont);
	font_height = TTF_FontHeight(ttfont); 

	// set the font colors
	// RGB values, the last value is 'unused'. For info,
	// see http://www.libsdl.org/cgi/docwiki.cgi/SDL_Color
	SDL_Color white = {255,255,255,0};
	SDL_Color red = {255,0,0,0};
	SDL_Color green = {0,255,0,0};
	SDL_Color blue = {0,0,255,0};
	SDL_Color grey = {128,128,128,0};
	SDL_Color black = {0,0,0,0};

	colors[FONT_WHITE] = white;
	colors[FONT_RED] = red;
	colors[FONT_GREEN] = green;
	colors[FONT_BLUE] = blue;
	colors[FONT_GREY] = grey;
	colors[FONT_BLACK] = black;
}
开发者ID:AI0867,项目名称:flare,代码行数:47,代码来源:FontEngine.cpp

示例12: if

MenuVendor::MenuVendor(ItemManager *_items, StatBlock *_stats)
	: Menu()
	, items(_items)
	, stats(_stats)
	, closeButton(new WidgetButton("images/menus/buttons/button_x.png"))
	, tabControl(new WidgetTabControl(2))
	, activetab(VENDOR_BUY)
	, color_normal(font->getColor("menu_normal"))
	, npc(NULL)
	, buyback_stock()
	, talker_visible(false) {
	background = loadGraphicSurface("images/menus/vendor.png");

	tabControl->setTabTitle(VENDOR_BUY,msg->get("Inventory"));
	tabControl->setTabTitle(VENDOR_SELL,msg->get("Buyback"));

	loadMerchant("");

	// Load config settings
	FileParser infile;
	if(infile.open("menus/vendor.txt")) {
		while(infile.next()) {
			infile.val = infile.val + ',';

			if(infile.key == "close") {
				close_pos.x = eatFirstInt(infile.val,',');
				close_pos.y = eatFirstInt(infile.val,',');
			}
			else if(infile.key == "slots_area") {
				slots_area.x = eatFirstInt(infile.val,',');
				slots_area.y = eatFirstInt(infile.val,',');
			}
			else if (infile.key == "vendor_cols") {
				slots_cols = eatFirstInt(infile.val,',');
			}
			else if (infile.key == "vendor_rows") {
				slots_rows = eatFirstInt(infile.val,',');
			}
			else if (infile.key == "caption") {
				title =  eatLabelInfo(infile.val);
			}
		}
		infile.close();
	}

	VENDOR_SLOTS = slots_cols * slots_rows;
}
开发者ID:blazindragon,项目名称:flare-engine,代码行数:47,代码来源:MenuVendor.cpp

示例13: loadEffects

void PowerManager::loadEffects() {
	FileParser infile;

	if (!infile.open("powers/effects.txt", true, false))
		return;

	std::string input_name = "";
	bool skippingEntry = false;

	while (infile.next()) {
		// name needs to be the first component of each power.  That is how we write
		// data to the correct power.
		if (infile.key == "name") {
			// @ATTR name|string|Uniq identifier for the effect definition.
			input_name = infile.val;
			skippingEntry = input_name == "";
			if (skippingEntry)
				fprintf(stderr, "Effect without a name, skipping\n");
			continue;
		}
		if (skippingEntry)
			continue;

		if (infile.key == "type") {
			// @ATTR type|string|Defines the type of effect
			effects[input_name].type = infile.val;
		}
		else if (infile.key == "icon") {
			// @ATTR icon|integer|The icon to visually represent the effect in the status area
			effects[input_name].icon = toInt(infile.val);
		}
		else if (infile.key == "animation") {
			// @ATTR animation|string|The name of effect animation.
			effects[input_name].animation = infile.val;
		}
		else if (infile.key == "additive") {
			// @ATTR additive|bool|Effect is additive
			effects[input_name].additive = toBool(infile.val);
		}
		else if (infile.key == "render_above") {
			// @ATTR render_above|bool|Effect is rendered above
			effects[input_name].render_above = toBool(infile.val);
		}
	}
	infile.close();
}
开发者ID:YuanhuanZheng,项目名称:flare-engine,代码行数:46,代码来源:PowerManager.cpp

示例14: load

int Map::load(std::string fname) {
	FileParser infile;
	maprow *cur_layer = NULL;

	clearEvents();
	clearLayers();
	clearQueues();

	// @CLASS Map|Description of maps/
	if (!infile.open(fname))
		return 0;

	this->filename = fname;

	while (infile.next()) {
		if (infile.new_section) {

			// for sections that are stored in collections, add a new object here
			if (infile.section == "enemy")
				enemies.push(Map_Enemy());
			else if (infile.section == "enemygroup")
				enemy_groups.push(Map_Group());
			else if (infile.section == "npc")
				npcs.push(Map_NPC());
			else if (infile.section == "event")
				events.push_back(Event());

		}
		if (infile.section == "header")
			loadHeader(infile);
		else if (infile.section == "layer")
			loadLayer(infile, &cur_layer);
		else if (infile.section == "enemy")
			loadEnemy(infile);
		else if (infile.section == "enemygroup")
			loadEnemyGroup(infile, &enemy_groups.back());
		else if (infile.section == "npc")
			loadNPC(infile);
		else if (infile.section == "event")
			EventManager::loadEvent(infile, &events.back());
	}

	infile.close();

	return 0;
}
开发者ID:aceofspades,项目名称:flare-engine,代码行数:46,代码来源:Map.cpp

示例15: if

MenuNPCActions::MenuNPCActions()
	: Menu()
	, npc(NULL)
	, is_selected(false)
	, is_empty(true)
	, first_dialog_node(-1)
	, current_action(-1)
	, action_menu(NULL)
	, vendor_label(msg->get("Trade"))
	, cancel_label(msg->get("Cancel"))
	, dialog_selected(false)
	, vendor_selected(false)
	, cancel_selected(false)
	, selected_dialog_node(-1) {
	// Load config settings
	FileParser infile;
	// @CLASS MenuNPCActions|Description of menus/npc.txt
	if (infile.open("menus/npc.txt")) {
		while(infile.next()) {
			if (parseMenuKey(infile.key, infile.val))
				continue;

			// @ATTR background_color|r (integer), g (integer), b (integer), a (integer)|Color and alpha of the menu's background.
			if(infile.key == "background_color") background_color = toRGBA(infile.val);
			// @ATTR topic_normal_color|r (integer), g (integer), b (integer)|The normal color of a generic topic text.
			else if(infile.key == "topic_normal_color") topic_normal_color = toRGB(infile.val);
			// @ATTR topic_hilight_color|r (integer), g (integer), b (integer)|The color of generic topic text when it's hovered over or selected.
			else if(infile.key == "topic_hilight_color") topic_hilight_color = toRGB(infile.val);
			// @ATTR vendor_normal_color|r (integer), g (integer), b (integer)|The normal color of the vendor option text.
			else if(infile.key == "vendor_normal_color") vendor_normal_color = toRGB(infile.val);
			// @ATTR vendor_hilight_color|r (integer), g (integer), b (integer)|The color of vendor option text when it's hovered over or selected.
			else if(infile.key == "vendor_hilight_color") vendor_hilight_color = toRGB(infile.val);
			// @ATTR cancel_normal_color|r (integer), g (integer), b (integer)|The normal color of the option to close the menu.
			else if(infile.key == "cancel_normal_color") cancel_normal_color = toRGB(infile.val);
			// @ATTR cancel_hilight_color|r (integer), g (integer), b (integer)|The color of the option to close the menu when it's hovered over or selected.
			else if(infile.key == "cancel_hilight_color") cancel_hilight_color = toRGB(infile.val);

			else infile.error("MenuNPCActions: '%s' is not a valid key.", infile.key.c_str());
		}
		infile.close();
	}

	// save the x/y pos coordinates here, since we call align() during each update() call
	base_pos.x = window_area.x;
	base_pos.y = window_area.y;
}
开发者ID:Gallaecio,项目名称:flare-engine,代码行数:46,代码来源:MenuNPCActions.cpp


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