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)); // } }
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; } }
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()); }
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); } }
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; } }
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); }
void CUIChangeGameType::InitChangeGameType(CUIXml& xml_doc) { CUIXmlInit::InitWindow(xml_doc, "change_gametype", 0, this); CUIXmlInit::InitTextWnd(xml_doc, "change_gametype:header", 0, header); CUIXmlInit::InitStatic(xml_doc, "change_gametype:background", 0, bkgrnd); string256 _path; for (int i = 0; i<4; i++) { xr_sprintf(_path, "change_gametype:btn_%d", i + 1); CUIXmlInit::Init3tButton(xml_doc, _path, 0, btn[i]); xr_sprintf(_path, "change_gametype:txt_%d", i + 1); CUIXmlInit::InitTextWnd(xml_doc, _path, 0, m_data[i].m_text); m_data[i].m_weather_name = xml_doc.ReadAttrib(_path,0,"id"); } CUIXmlInit::Init3tButton(xml_doc, "change_gametype:btn_cancel", 0, btn_cancel); }
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)); } }
void ChangeGameTypeDialog::InitChangeGameType(CUIXml& xmlDoc) { CUIXmlInit::InitWindow(xmlDoc, "change_gametype", 0, this); CUIXmlInit::InitTextWnd(xmlDoc, "change_gametype:header", 0, Header); CUIXmlInit::InitStatic(xmlDoc, "change_gametype:background", 0, Background); CUIXmlInit::Init3tButton(xmlDoc, "change_gametype:btn_cancel", 0, CancelButton); // XXX nitrocaster: get it from somewhere const int gameTypeCount = 4; Initialize(gameTypeCount); gameTypes.resize(gameTypeCount); string256 path; for (u32 i = 0; i < gameTypes.size(); i++) { xr_sprintf(path, "change_gametype:btn_%d", i+1); CUIXmlInit::Init3tButton(xmlDoc, path, 0, GetButton(i).Button); xr_sprintf(path, "change_gametype:txt_%d", i+1); CUIXmlInit::InitTextWnd(xmlDoc, path, 0, GetButton(i).Text); gameTypes[i] = xmlDoc.ReadAttrib(path, 0, "id"); } }
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; }
void CUIMessageBox::InitMessageBox(LPCSTR box_template) { Clear (); CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, "message_box.xml"); CUIXmlInit xml_init; string512 str; strconcat (sizeof(str),str,box_template,":picture"); m_UIStaticPicture = new CUIStatic(); AttachChild(m_UIStaticPicture); xml_init.InitStatic (uiXml, str, 0, m_UIStaticPicture); strconcat (sizeof(str),str,box_template,":message_text"); if (uiXml.NavigateToNode(str,0)) { m_UIStaticText = new CUIStatic(); AttachChild(m_UIStaticText); xml_init.InitStatic (uiXml, str, 0, m_UIStaticText); } strcpy_s (str,box_template); xml_init.InitStatic (uiXml, str, 0, this); LPCSTR _type = uiXml.ReadAttrib(str,0,"type",NULL); R_ASSERT (_type); m_eMessageBoxStyle = MESSAGEBOX_OK; if(0==stricmp(_type,"ok")) { m_eMessageBoxStyle = MESSAGEBOX_OK; } else if(0==stricmp(_type,"yes_no")) { m_eMessageBoxStyle = MESSAGEBOX_YES_NO; } else if(0==stricmp(_type,"yes_no_cancel")) { m_eMessageBoxStyle = MESSAGEBOX_YES_NO_CANCEL; } else if(0==stricmp(_type,"yes_no_copy")) { m_eMessageBoxStyle = MESSAGEBOX_YES_NO_COPY; } else if(0==stricmp(_type,"direct_ip")) { m_eMessageBoxStyle = MESSAGEBOX_DIRECT_IP; } else if(0==stricmp(_type,"password")) { m_eMessageBoxStyle = MESSAGEBOX_PASSWORD; } else if(0==stricmp(_type,"quit_windows")) { m_eMessageBoxStyle = MESSAGEBOX_QUIT_WINDOWS; } else if(0==stricmp(_type,"quit_game")) { m_eMessageBoxStyle = MESSAGEBOX_QUIT_GAME; } else if(0==stricmp(_type,"info")) { m_eMessageBoxStyle = MESSAGEBOX_INFO; }; switch (m_eMessageBoxStyle) { case MESSAGEBOX_OK: { strconcat (sizeof(str),str,box_template,":button_ok"); m_UIButtonYesOk = new CUI3tButtonEx(); AttachChild (m_UIButtonYesOk); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonYesOk); } break; case MESSAGEBOX_INFO: { } break; case MESSAGEBOX_DIRECT_IP: strconcat (sizeof(str),str,box_template,":cap_host"); m_UIStaticHost = new CUIStatic(); AttachChild (m_UIStaticHost); xml_init.InitStatic (uiXml, str, 0, m_UIStaticHost); strconcat (sizeof(str),str,box_template,":edit_host"); m_UIEditHost = new CUIEditBox(); AttachChild (m_UIEditHost); xml_init.InitEditBox (uiXml, str, 0, m_UIEditHost); strconcat (sizeof(str),str,box_template,":cap_password"); m_UIStaticPass = new CUIStatic(); AttachChild (m_UIStaticPass); xml_init.InitStatic (uiXml, str, 0, m_UIStaticPass); strconcat (sizeof(str),str,box_template,":edit_password"); m_UIEditPass = new CUIEditBox(); AttachChild (m_UIEditPass); xml_init.InitEditBox (uiXml, str, 0, m_UIEditPass); strconcat (sizeof(str),str,box_template,":button_yes"); m_UIButtonYesOk = new CUI3tButtonEx(); AttachChild (m_UIButtonYesOk); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonYesOk); strconcat (sizeof(str),str,box_template,":button_no"); m_UIButtonNo = new CUI3tButtonEx(); AttachChild (m_UIButtonNo); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonNo); //m_message_box_yes_no->func_on_ok = CUIWndCallback::void_function( this, &CUIActorMenu::OnMesBoxYes ); break; case MESSAGEBOX_PASSWORD: strconcat (sizeof(str),str,box_template,":cap_user_password"); m_UIStaticUserPass = new CUIStatic(); AttachChild (m_UIStaticUserPass); xml_init.InitStatic (uiXml, str, 0, m_UIStaticUserPass); strconcat (sizeof(str),str,box_template,":cap_password"); m_UIStaticPass = new CUIStatic(); AttachChild (m_UIStaticPass); xml_init.InitStatic (uiXml, str, 0, m_UIStaticPass); strconcat (sizeof(str),str,box_template,":edit_user_password"); m_UIEditUserPass = new CUIEditBox(); AttachChild (m_UIEditUserPass); xml_init.InitEditBox (uiXml, str, 0, m_UIEditUserPass); strconcat (sizeof(str),str,box_template,":edit_password"); m_UIEditPass = new CUIEditBox(); AttachChild (m_UIEditPass); xml_init.InitEditBox (uiXml, str, 0, m_UIEditPass); case MESSAGEBOX_QUIT_WINDOWS: case MESSAGEBOX_QUIT_GAME: case MESSAGEBOX_YES_NO: { strconcat (sizeof(str),str,box_template,":button_yes"); m_UIButtonYesOk = new CUI3tButtonEx(); AttachChild (m_UIButtonYesOk); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonYesOk); strconcat (sizeof(str),str,box_template,":button_no"); m_UIButtonNo = new CUI3tButtonEx(); AttachChild (m_UIButtonNo); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonNo); } break; case MESSAGEBOX_YES_NO_CANCEL: { strconcat (sizeof(str),str,box_template,":button_yes"); m_UIButtonYesOk = new CUI3tButtonEx(); AttachChild (m_UIButtonYesOk); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonYesOk); strconcat (sizeof(str),str,box_template,":button_no"); m_UIButtonNo = new CUI3tButtonEx(); AttachChild (m_UIButtonNo); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonNo); strconcat (sizeof(str),str,box_template,":button_cancel"); m_UIButtonCancel = new CUI3tButtonEx(); AttachChild (m_UIButtonCancel); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonCancel); } break; case MESSAGEBOX_YES_NO_COPY: { strconcat (sizeof(str),str,box_template,":button_yes"); m_UIButtonYesOk = new CUI3tButtonEx(); AttachChild (m_UIButtonYesOk); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonYesOk); strconcat (sizeof(str),str,box_template,":button_no"); m_UIButtonNo = new CUI3tButtonEx(); AttachChild (m_UIButtonNo); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonNo); strconcat (sizeof(str),str,box_template,":button_copy"); m_UIButtonCopy = new CUI3tButtonEx(); AttachChild (m_UIButtonCopy); xml_init.Init3tButtonEx (uiXml, str, 0, m_UIButtonCopy); strconcat (sizeof(str),str,box_template,":edit_url"); if ( uiXml.NavigateToNode(str) ) { m_UIEditURL = new CUIEditBox(); AttachChild (m_UIEditURL); xml_init.InitEditBox (uiXml, str, 0, m_UIEditURL); // m_UIEditURL->read_only } } break; }; }