Beispiel #1
0
void CUISequenceSimpleItem::Load(CUIXml* xml, int idx)
{
	CUISequenceItem::Load	(xml,idx);

	XML_NODE* _stored_root	= xml->GetLocalRoot();
	xml->SetLocalRoot		(xml->NavigateToNode("item",idx));
	
	LPCSTR m_snd_name		= xml->Read				("sound",0,""			);
	if (m_snd_name&&m_snd_name[0]){
		m_sound.create		(m_snd_name,st_Effect,sg_Undefined);	
		VERIFY				(m_sound._handle());
	}
	m_time_length			= xml->ReadFlt			("length_sec",0,0		);
	m_desired_cursor_pos.x	= xml->ReadAttribFlt	("cursor_pos",0,"x",1024);
	m_desired_cursor_pos.y	= xml->ReadAttribFlt	("cursor_pos",0,"y",768	);
	strcpy					(m_pda_section, xml->Read("pda_section",0,"")	);

	LPCSTR str				= xml->Read				("pause_state",0,"ignore");
	m_flags.set										(etiNeedPauseOn, 0==_stricmp(str, "on"));
	m_flags.set										(etiNeedPauseOff, 0==_stricmp(str, "off"));

	LPCSTR str2				= xml->Read				("pause_sound",0,"ignore");
	m_flags.set										(etiNeedPauseSound, 0==_stricmp(str2, "on"));

	str						= xml->Read				("guard_key",0,NULL		);
	m_continue_dik_guard	= -1;
	if (str && !_stricmp(str,"any")){
		m_continue_dik_guard = 9999;
		str					= NULL;
	}
	if(str){
		EGameActions cmd		= action_name_to_id	(str);
		m_continue_dik_guard	= get_action_dik	(cmd);
	}

	m_flags.set						(etiCanBeStopped,	(m_continue_dik_guard==-1));
	m_flags.set						(etiGrabInput,		1==xml->ReadInt("grab_input",0,1));


	//ui-components
	m_UIWindow						= xr_new<CUIWindow>();
	m_UIWindow->SetAutoDelete		(false);
	XML_NODE* _lsr					= xml->GetLocalRoot();
	CUIXmlInit xml_init;
	xml_init.InitWindow				(*xml, "main_wnd", 0,	m_UIWindow);
//.	xml_init.InitAutoStaticGroup	(*xml, "main_wnd",		m_UIWindow);
	xml->SetLocalRoot				(_lsr);

	// initialize auto_static
	int cnt							= xml->GetNodesNum	("main_wnd",0,"auto_static");
	m_subitems.resize				(cnt);
	string64						sname;
	for(int i=0;i<cnt;++i){
		XML_NODE* _sr				= xml->GetLocalRoot();
		xml->SetLocalRoot			(xml->NavigateToNode("main_wnd",0));

		sprintf_s						(sname,"auto_static_%d", i);

		SSubItem* _si				= &m_subitems[i];
		_si->m_start				= xml->ReadAttribFlt("auto_static",i,"start_time",0);
		_si->m_length				= xml->ReadAttribFlt("auto_static",i,"length_sec",0);
		_si->m_visible				= false;
		_si->m_wnd					= smart_cast<CUIStatic*>(find_child_window(m_UIWindow, sname)); VERIFY(_si->m_wnd);
		_si->m_wnd->SetTextComplexMode(true);
		_si->m_wnd->Show			(false);

		xml->SetLocalRoot			(_sr);
	}
	xml->SetLocalRoot				(_stored_root);
}
void CUISequenceSimpleItem::Load(CUIXml* xml, int idx)
{
	CUISequenceItem::Load	(xml,idx);

	XML_NODE* _stored_root	= xml->GetLocalRoot();
	xml->SetLocalRoot		(xml->NavigateToNode("item",idx));
	
	LPCSTR m_snd_name		= xml->Read				("sound",0,""			);
	if (m_snd_name&&m_snd_name[0]){
		m_sound.create		(m_snd_name,st_Effect,sg_Undefined);	
		VERIFY				(m_sound._handle() || strstr(Core.Params,"-nosound"));
	}
	m_time_length			= xml->ReadFlt			("length_sec",0,0		);
	m_desired_cursor_pos.x	= xml->ReadAttribFlt	("cursor_pos",0,"x",0);
	m_desired_cursor_pos.y	= xml->ReadAttribFlt	("cursor_pos",0,"y",0	);
	xr_strcpy					(m_pda_section, xml->Read("pda_section",0,"")	);

	LPCSTR str				= xml->Read				("pause_state",		0,"ignore");
	m_flags.set										(etiNeedPauseOn,	0==_stricmp(str, "on"));
	m_flags.set										(etiNeedPauseOff,	0==_stricmp(str, "off"));
	m_flags.set										(etiNeedPauseSound, 0==_stricmp(str, "on"));

	str						= xml->Read				("guard_key",0,NULL		);
	m_continue_dik_guard	= -1;
	if (str && !_stricmp(str,"any")){
		m_continue_dik_guard = 9999;
		str					= NULL;
	}
	if(str){
		EGameActions cmd		= action_name_to_id	(str);
		m_continue_dik_guard	= get_action_dik	(cmd);
	}

	m_flags.set						(etiCanBeStopped,	(m_continue_dik_guard==-1));

	LPCSTR str_grab_input			= xml->Read("grab_input",0,"on");
	m_flags.set						(etiGrabInput, (0==_stricmp(str_grab_input, "on")||0==_stricmp(str_grab_input, "1")) );
	
	int actions_count				= xml->GetNodesNum	(0,0,"action");
	m_actions.resize				(actions_count);
	for(int idx=0; idx<actions_count; ++idx)
	{
		SActionItem& itm			= m_actions[idx];
		LPCSTR str					= xml->ReadAttrib("action", idx, "id");
		itm.m_action				= action_name_to_id(str);
		itm.m_bfinalize				= !!xml->ReadAttribInt("action", idx, "finalize", FALSE);
		itm.m_functor				= xml->Read(xml->GetLocalRoot(), "action", idx, "");
	}

	//ui-components
	m_UIWindow						= xr_new<CUIWindow>();
	m_UIWindow->SetAutoDelete		(false);
	XML_NODE* _lsr					= xml->GetLocalRoot();
	CUIXmlInit xml_init;
	xml_init.InitWindow				(*xml, "main_wnd", 0,	m_UIWindow);
	xml->SetLocalRoot				(_lsr);

	// initialize auto_static
	int cnt							= xml->GetNodesNum	("main_wnd", 0, "auto_static");
	m_subitems.resize				(cnt);
	string64						sname;
	for(int i=0;i<cnt;++i)
	{
		XML_NODE* _sr				= xml->GetLocalRoot();
		xml->SetLocalRoot			(xml->NavigateToNode("main_wnd", 0));

		xr_sprintf					(sname, "auto_static_%d", i);

		SSubItem* _si				= &m_subitems[i];
		_si->m_start				= xml->ReadAttribFlt("auto_static", i, "start_time", 0);
		_si->m_length				= xml->ReadAttribFlt("auto_static", i, "length_sec", 0);

		_si->m_visible				= false;
		_si->m_wnd					= smart_cast<CUIStatic*>(find_child_window(m_UIWindow, sname)); 
		VERIFY						(_si->m_wnd);

		_si->m_wnd->TextItemControl()->SetTextComplexMode(true);
		_si->m_wnd->Show			(false);
		_si->m_wnd->SetWidth		(_si->m_wnd->GetWidth()*UI().get_current_kx());
		
		if(UI().is_widescreen())
		{
			XML_NODE* autostatic_node	= xml->NavigateToNode("auto_static", i);
			XML_NODE* ws_rect			= xml->NavigateToNode(autostatic_node, "widescreen_rect", 0);
			if(ws_rect)
			{
				xml->SetLocalRoot		(autostatic_node);

				Fvector2 pos, size;
				pos.x					= xml->ReadAttribFlt("widescreen_rect", 0, "x");
				pos.y					= xml->ReadAttribFlt("widescreen_rect", 0, "y");
				size.x					= xml->ReadAttribFlt("widescreen_rect", 0, "width");
				size.y					= xml->ReadAttribFlt("widescreen_rect", 0, "height");
				_si->m_wnd->SetWndPos	(pos);
				_si->m_wnd->SetWndSize	(size);
			}
		}

		xml->SetLocalRoot			(_sr);
	}
	xml->SetLocalRoot				(_stored_root);
}