Exemplo n.º 1
0
void CStringTable::Load	(LPCSTR xml_file)
{
	CUIXml						uiXml;
	string_path					xml_file_full;
	strconcat					(sizeof(xml_file_full),xml_file_full, xml_file, ".xml");
	string_path					_s;
	strconcat					(sizeof(_s),_s, STRING_TABLE_PATH, "\\", *(pData->m_sLanguage) );

	bool xml_result				= uiXml.Init(CONFIG_PATH, _s, xml_file_full);
	if(!xml_result)
		Debug.fatal(DEBUG_INFO,"string table xml file not found %s, for language %s", xml_file_full, *(pData->m_sLanguage));

	//общий список всех записей таблицы в файле
	int string_num = uiXml.GetNodesNum		(uiXml.GetRoot(), "string");

	for(int i=0; i<string_num; ++i)
	{
		LPCSTR string_name = uiXml.ReadAttrib(uiXml.GetRoot(), "string", i, "id", NULL);

		VERIFY3					(pData->m_StringTable.find(string_name) == pData->m_StringTable.end(), "duplicate string table id", string_name);

		LPCSTR string_text		= uiXml.Read(uiXml.GetRoot(), "string:text", i,  NULL);

		if(m_bWriteErrorsToLog && string_text)
			Msg("[string table] '%s' no translation in '%s'", string_name, *(pData->m_sLanguage));
		
		VERIFY3						(string_text, "string table entry does not has a text", string_name);
		
		STRING_VALUE str_val		= ParseLine(string_text, string_name, true);
		
		pData->m_StringTable[string_name] = str_val;
	}
}
Exemplo n.º 2
0
void CUIStatsListItem::XmlInit(const char *path, CUIXml &uiXml)
{
	CUIXmlInit	xml_init;
//	CUIStatic	*pStatic;
	CUIButton	*pButton;

	string256 buf;
	strconcat(sizeof(buf),buf, path, ":static");

	int tabsCount = uiXml.GetNodesNum(path, 0, "static");

	XML_NODE* tab_node = uiXml.NavigateToNode(path,0);
	uiXml.SetLocalRoot(tab_node);

	for (int i = 0; i < tabsCount; ++i)
	{
		pButton = new CUIButton();
		pButton->SetAutoDelete(true);
		xml_init.InitStatic(uiXml, "static", i, pButton);
		pButton->SetTextAlignment(CGameFont::alLeft);
		AttachChild(pButton);
		FieldsVector.push_back(pButton);
	}

	FieldsVector[0]->SetEllipsis(1, 0);
}
Exemplo n.º 3
0
void CUITextureMaster::ParseShTexInfo(LPCSTR xml_file){
	CUIXml xml;
	xml.Init(CONFIG_PATH, UI_PATH, xml_file);
	shared_str file = xml.Read("file_name",0,""); 

//	shared_textures_it	sht_it = m_shTex.find(texture);
//	if (m_shTex.end() == sht_it)
//	{
		int num = xml.GetNodesNum("",0,"texture");
//		regions regs;
		for (int i = 0; i<num; i++)
		{
			TEX_INFO info;

			info.file = file;

			info.rect.x1 = xml.ReadAttribFlt("texture",i,"x");
			info.rect.x2 = xml.ReadAttribFlt("texture",i,"width") + info.rect.x1;
			info.rect.y1 = xml.ReadAttribFlt("texture",i,"y");
			info.rect.y2 = xml.ReadAttribFlt("texture",i,"height") + info.rect.y1;
			shared_str id = xml.ReadAttrib("texture",i,"id");

			m_textures.insert(mk_pair(id,info));
		}
//		m_shTex.insert(mk_pair(texture, regs));
//	}
}
Exemplo n.º 4
0
void CUITextureMaster::ParseShTexInfo(LPCSTR xml_file)
{
	CUIXml						xml;
	xml.Load					(CONFIG_PATH, "ui\\textures_descr", xml_file);

	int files_num				= xml.GetNodesNum("",0,"file");


	for(int fi=0; fi<files_num; ++fi)
	{
		XML_NODE* root_node			= xml.GetLocalRoot();
		shared_str file				= xml.ReadAttrib("file", fi, "name"); 

		XML_NODE* node				= xml.NavigateToNode("file", fi);

//.		Msg("-%s",file.c_str());
		int num						= xml.GetNodesNum(node, "texture");
		for (int i = 0; i<num; i++)
		{
			TEX_INFO info;

			info.file = file;

			info.rect.x1 = xml.ReadAttribFlt(node, "texture",i,"x");
			info.rect.x2 = xml.ReadAttribFlt(node, "texture",i,"width") + info.rect.x1;
			info.rect.y1 = xml.ReadAttribFlt(node, "texture",i,"y");
			info.rect.y2 = xml.ReadAttribFlt(node, "texture",i,"height") + info.rect.y1;
			shared_str id = xml.ReadAttrib	(node, "texture",i,"id");
//.			Msg("--%s",id.c_str());

			m_textures.insert(mk_pair(id,info));
		}

		xml.SetLocalRoot		(root_node);
	}
}
Exemplo n.º 5
0
void CUIStatsPlayerList::Init(CUIXml& xml_doc, LPCSTR path)
{
	// init window
	CUIXmlInit::InitScrollView	(xml_doc, path, 0, this);
	SetFixedScrollBar			(false);


	m_bStatus_mode				= xml_doc.ReadAttribInt(path,0,"status_mode",0)? true: false;
	m_bSpectator				= xml_doc.ReadAttribInt(path,0,"spectator",0)? true: m_bStatus_mode;
	SetSpectator				(m_bSpectator);

	// init item structure
	int tabsCount				= xml_doc.GetNodesNum(path, 0, "field");
	XML_NODE* tab_node			= xml_doc.NavigateToNode(path,0);
	xml_doc.SetLocalRoot		(tab_node);

	for (int i = 0; i < tabsCount; ++i)
	{
		LPCSTR name 			= xml_doc.ReadAttrib("field",i,"name");
		float width 			= xml_doc.ReadAttribFlt("field",i,"width");

		if (0 == xr_strcmp(name, "artefacts") && GameID() != eGameIDArtefactHunt)
			continue;
		
		AddField				(name,width);
	}
	xml_doc.SetLocalRoot		(xml_doc.GetRoot());
	string256					 _path;
	// init item text params
	CUIXmlInit::InitFont		(xml_doc, strconcat(sizeof(_path),_path, path, ":text_format"), 0, m_i.c, m_i.f);
	m_i.h						= xml_doc.ReadAttribFlt(strconcat(sizeof(_path),_path, path, ":text_format"), 0, "height", 25);

	// init list header
	switch (GameID())
	{
	case eGameIDCaptureTheArtefact:
	case eGameIDArtefactHunt:
	case eGameIDTeamDeathmatch:
		if (!m_bSpectator || m_bStatus_mode)
            InitTeamHeader(xml_doc, path);
	case eGameIDDeathmatch:
		InitHeader(xml_doc, path);
	default:
		break;
	}
}
Exemplo n.º 6
0
void CUIArtefactDetectorElite::construct(CEliteDetector* p)
{
	m_parent							= p;
	CUIXml								uiXml;
	uiXml.Load							(CONFIG_PATH, UI_PATH, "ui_detector_artefact.xml");

	CUIXmlInit							xml_init;
	string512							buff;
	xr_strcpy							(buff, p->ui_xml_tag());

	xml_init.InitWindow					(uiXml, buff, 0, this);

	m_wrk_area							= xr_new<CUIWindow>();

	xr_sprintf							(buff, "%s:wrk_area", p->ui_xml_tag());

	xml_init.InitWindow					(uiXml, buff, 0, m_wrk_area);
	m_wrk_area->SetAutoDelete			(true);
	AttachChild							(m_wrk_area);

	xr_sprintf							(buff, "%s", p->ui_xml_tag());
	int num = uiXml.GetNodesNum			(buff,0,"palette");
	XML_NODE* pStoredRoot				= uiXml.GetLocalRoot();
	uiXml.SetLocalRoot					(uiXml.NavigateToNode(buff,0));
	for(int idx=0; idx<num;++idx)
	{
		CUIStatic* S					= xr_new<CUIStatic>();
		shared_str name					= uiXml.ReadAttrib("palette",idx,"id");
		m_palette[name]					= S;
		xml_init.InitStatic				(uiXml, "palette", idx, S);
		S->SetAutoDelete				(true);
		m_wrk_area->AttachChild			(S);
		S->SetCustomDraw				(true);
	}
	uiXml.SetLocalRoot					(pStoredRoot);

	Fvector _map_attach_p				= pSettings->r_fvector3(m_parent->cNameSect(), "ui_p");
	Fvector _map_attach_r				= pSettings->r_fvector3(m_parent->cNameSect(), "ui_r");
	
	_map_attach_r.mul					(PI/180.f);
	m_map_attach_offset.setHPB			(_map_attach_r.x, _map_attach_r.y, _map_attach_r.z);
	m_map_attach_offset.translate_over	(_map_attach_p);
}
Exemplo n.º 7
0
void UIPlayerItem::InitIconParams(CUIXml& uiXml)
{
	VERIFY(m_player_node_root);
	int temp_number = uiXml.GetNodesNum(m_player_node_root, ICONPARAM_NODE_NAME);
	for (int i = 0; i < temp_number; ++i)
	{
		XML_NODE* icon_param_node = uiXml.NavigateToNode(ICONPARAM_NODE_NAME, i);
		if (!icon_param_node)
			break;
		LPCSTR param_name = uiXml.ReadAttrib(icon_param_node, "name", 
			"param_name_not_set_in_name_attribute");
		CUIStatic* temp_static = new CUIStatsIcon();
		VERIFY(temp_static);
		this->AttachChild(temp_static);
		temp_static->SetAutoDelete(true);
		CUIXmlInit::InitStatic(uiXml, ICONPARAM_NODE_NAME, i, temp_static);
		m_icon_params.insert(std::make_pair(shared_str(param_name), temp_static));
	}
}
Exemplo n.º 8
0
void CMMSound::Init(CUIXml& xml_doc, LPCSTR path){
	string256 _path;	
	m_bRandom = xml_doc.ReadAttribInt(path, 0, "random")? true : false;

	int nodes_num	= xml_doc.GetNodesNum(path, 0, "menu_music");

	XML_NODE* tab_node = xml_doc.NavigateToNode(path,0);
	xml_doc.SetLocalRoot(tab_node);	
	for (int i = 0; i < nodes_num; ++i)
		m_play_list.push_back(xml_doc.Read("menu_music", i, ""));		
	xml_doc.SetLocalRoot(xml_doc.GetRoot());

    strconcat(sizeof(_path),_path, path,":whell_sound");
	if (check_file(xml_doc.Read(_path, 0, "")))
        m_whell.create(xml_doc.Read(_path, 0, "") ,st_Effect,sg_SourceType);

	strconcat(sizeof(_path),_path, path,":whell_click");
	if (check_file(xml_doc.Read(_path, 0, "")))
        m_whell_click.create(xml_doc.Read(_path, 0, ""),st_Effect,sg_SourceType );
}
Exemplo n.º 9
0
void CUIMMShniaga::CreateList(xr_vector<CUIStatic*>& lst, CUIXml& xml_doc, LPCSTR path){
	CGameFont* pF;
	u32	color;
	float button_height				= xml_doc.ReadAttribFlt("button", 0, "h");
	R_ASSERT						(button_height);

	CUIXmlInit::InitFont			(xml_doc, path, 0, color, pF);
	R_ASSERT						(pF);

	int nodes_num					= xml_doc.GetNodesNum(path, 0, "btn");

	XML_NODE* tab_node				= xml_doc.NavigateToNode(path,0);
	xml_doc.SetLocalRoot			(tab_node);

	CUIStatic* st;

	for (int i = 0; i < nodes_num; ++i)
	{		
		st							= new CUIStatic();
		st->SetWndPos				(Fvector2().set(0,0));
		st->SetWndSize				(Fvector2().set(m_view->GetDesiredChildWidth(), button_height));
		st->SetTextComplexMode		(false);
		st->SetTextST				(xml_doc.ReadAttrib	("btn", i, "caption"));
		if (pF)
			st->SetFont				(pF);

		float font_height			= st->GetFont()->GetHeight();
		UI()->ClientToScreenScaledHeight(font_height);

		st->SetTextY				( (button_height-font_height)/2.0f );
		st->SetTextColor			(color);
		st->SetTextAlignment		(CGameFont::alCenter);
		st->SetWindowName			(xml_doc.ReadAttrib("btn", i, "name"));
		st->SetMessageTarget		(this);


		lst.push_back(st);
	}
	xml_doc.SetLocalRoot(xml_doc.GetRoot());

}
Exemplo n.º 10
0
void CUISequencer::Start(LPCSTR tutor_name)
{
	VERIFY(m_items.size()==0);
	Device.seqFrame.Add			(this, REG_PRIORITY_LOW-10000);
	Device.seqRender.Add		(this, 3);
	
	m_UIWindow					= xr_new<CUIWindow>();

	CUIXml uiXml;
	uiXml.Init					(CONFIG_PATH, UI_PATH, "game_tutorials.xml");
	
	int items_count				= uiXml.GetNodesNum	(tutor_name,0,"item");	VERIFY(items_count>0);
	uiXml.SetLocalRoot			(uiXml.NavigateToNode(tutor_name,0));

	m_bPlayEachItem				= !!uiXml.ReadInt("play_each_item",0,0);

	CUIXmlInit xml_init;
	xml_init.InitWindow			(uiXml, "global_wnd", 0,	m_UIWindow);
//.	xml_init.InitAutoStaticGroup(uiXml, "global_wnd",		m_UIWindow);

	for(int i=0;i<items_count;++i){
		LPCSTR	_tp				= uiXml.ReadAttrib			("item",i,"type","");
		bool bVideo				= 0==_stricmp(_tp,"video");
		CUISequenceItem* pItem	= 0;
		if (bVideo)	pItem		= xr_new<CUISequenceVideoItem>(this);
		else		pItem		= xr_new<CUISequenceSimpleItem>(this);
		m_items.push_back		(pItem);
		pItem->Load				(&uiXml,i);
	}

	CUISequenceItem* pCurrItem	= m_items.front();
	pCurrItem->Start			();
	m_pStoredInputReceiver		= pInput->CurrentIR();
	IR_Capture					();
	m_bActive					= true;
}
Exemplo n.º 11
0
void CInfoPortion::load_shared	(LPCSTR)
{
	const ITEM_DATA& item_data = *id_to_index::GetById(m_InfoId);

	CUIXml*		pXML		= item_data._xml;
	pXML->SetLocalRoot		(pXML->GetRoot());

	//loading from XML
	XML_NODE* pNode			= pXML->NavigateToNode(id_to_index::tag_name, item_data.pos_in_file);
	THROW3					(pNode, "info_portion id=", *item_data.id);

	//список названий диалогов
	int dialogs_num			= pXML->GetNodesNum(pNode, "dialog");
	info_data()->m_DialogNames.clear();
	int i = 0;
	for(; i<dialogs_num; ++i)
	{
		shared_str dialog_name = pXML->Read(pNode, "dialog", i,"");
		info_data()->m_DialogNames.push_back(dialog_name);
	}

	
	//список названий порций информации, которые деактивируются,
	//после получения этой порции
	int disable_num = pXML->GetNodesNum(pNode, "disable");
	info_data()->m_DisableInfo.clear();
	for(i=0; i<disable_num; ++i)
	{
		shared_str info_id		= pXML->Read(pNode, "disable", i,"");
		info_data()->m_DisableInfo.push_back(info_id);
	}

	//имена скриптовых функций
	info_data()->m_PhraseScript.Load(pXML, pNode);


	//индексы статей
	info_data()->m_Articles.clear();
	int articles_num	= pXML->GetNodesNum(pNode, "article");
	for(i=0; i<articles_num; ++i)
	{
		LPCSTR article_str_id = pXML->Read(pNode, "article", i, NULL);
		THROW(article_str_id);
		info_data()->m_Articles.push_back(article_str_id);
	}

	info_data()->m_ArticlesDisable.clear();
	articles_num = pXML->GetNodesNum(pNode, "article_disable");
	for(i=0; i<articles_num; ++i)
	{
		LPCSTR article_str_id = pXML->Read(pNode, "article_disable", i, NULL);
		THROW(article_str_id);
		info_data()->m_ArticlesDisable.push_back(article_str_id);
	}
	
	info_data()->m_GameTasks.clear();
	int task_num = pXML->GetNodesNum(pNode, "task");
	for(i=0; i<task_num; ++i)
	{
		LPCSTR task_str_id = pXML->Read(pNode, "task", i, NULL);
		THROW(task_str_id);
		info_data()->m_GameTasks.push_back(task_str_id);
	}
}