LPCSTR CUIListBox::GetText(int idx) { if(idx==-1) return NULL; CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(GetItem(idx)); return item->GetText(); }
void CUIMapList::SaveMapList() { string_path temp; FS.update_path (temp,"$app_data_root$", MAP_ROTATION_LIST); if(m_pList2->GetSize()<=1){ FS.file_delete(temp); return; } IWriter* pW = FS.w_open (temp); if (!pW){ Msg("! Cant create map rotation file [%s]", temp); return; } string_path map_name; for(u32 idx=0; idx<m_pList2->GetSize(); ++idx) { CUIListBoxItem* itm = m_pList2->GetItemByIDX(idx); u32 _idx = (u32)(__int64)(itm->GetData()); const shared_str& _map_name = GetMapNameInt(GetCurGameType(), _idx); sprintf_s (map_name, "sv_addmap %s", _map_name.c_str() ); pW->w_string (map_name); } FS.w_close (pW); }
const char* CUIMapList::GetCommandLine(LPCSTR player_name){ string16 buf; CUIListBoxItem* itm = m_pList2->GetItemByIDX(0); if (!itm) return NULL; u32 _idx = (u32)(__int64)(itm->GetData()); const shared_str& _map_name = GetMapNameInt (GetCurGameType(), _idx); m_command.clear(); m_command = "start server("; m_command += _map_name.c_str(); m_command += "/"; m_command += GetCLGameModeName(); m_command += m_srv_params; m_command += "/estime="; const char* weather = m_pWeatherSelector->GetText(); int estime = (*m_mapWeather.find(weather)).second; m_command += itoa(estime/60,buf,10); m_command += ":"; m_command += itoa(estime%60,buf,10); m_command += ")"; m_command +=" client(localhost/name="; if (player_name == NULL || 0 == xr_strlen(player_name)) m_command += Core.UserName; else m_command +=player_name; m_command +=")"; return m_command.c_str(); }
CUIListBoxItem* CUIListBox::AddTextItem(LPCSTR text) { CUIListBoxItem* pItem = AddItem(); pItem->SetWndSize (Fvector2().set(GetDesiredChildWidth(), m_def_item_height)); pItem->SetTextColor (m_text_color); pItem->SetText (CStringTable().translate(text).c_str()); pItem->GetTextItem()->SetWidth (GetDesiredChildWidth()); return pItem; }
void CUIMapList::UpdateMapList(EGameTypes GameType){ m_pList1->Clear (); m_pList2->Clear (); for (u32 i=0; i<m_maps[GameType].size(); ++i) { CUIListBoxItem* itm = m_pList1->AddItem( CStringTable().translate(m_maps[GameType][i]).c_str() ); itm->SetData ( (void*)(__int64)i ); itm->Enable(m_pExtraContentFilter->IsDataEnabled(m_maps[GameType][i].c_str())); } }
LPCSTR CUIListBox::GetSelectedText() { CUIWindow* w = GetSelected(); if(w) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(w); return item->GetText(); }else return NULL; }
void CUIMpChangeMapAdm::FillUpList() { lst->Clear(); const SGameTypeMaps& M = gMapListHelper.GetMapListFor((EGameIDs)GameID()); u32 cnt = M.m_map_names.size(); for (u32 i=0; i<cnt; ++i) { CUIListBoxItem* itm = lst->AddTextItem(CStringTable().translate(M.m_map_names[i].map_name).c_str()); itm->Enable(true); } }
CUIListBoxItem* CUIListBox::GetItemByText(LPCSTR txt) { for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { if (0 == xr_strcmp(item->GetText(), txt)) return item; } } return NULL; }
void CUIMapList::UpdateMapList(EGameTypes GameType) { m_pList1->Clear (); m_pList2->Clear (); const SGameTypeMaps& M = gMapListHelper.GetMapListFor(GameType); u32 cnt = M.m_map_names.size(); for (u32 i=0; i<cnt; ++i) { CUIListBoxItem* itm = m_pList1->AddItem( CStringTable().translate(M.m_map_names[i]).c_str() ); itm->SetData ( (void*)(__int64)i ); itm->Enable(m_pExtraContentFilter->IsDataEnabled(M.m_map_names[i].c_str())); } }
CUIListBoxItem* CUIListBox::GetItemByTAG(u32 tag_val) { for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { if (item->GetTAG() == tag_val) return item; } } return NULL; }
void CUIKickPlayer::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) { if (LIST_ITEM_SELECT == msg && pWnd == m_ui_players_list) { CUIListBoxItem* itm = smart_cast<CUIListBoxItem*>(m_ui_players_list->GetSelected()); m_selected_item_text = itm->GetText(); } else if (BUTTON_CLICKED == msg) { if (pWnd == btn_ok) OnBtnOk (); else if (pWnd == btn_cancel) OnBtnCancel (); } }
const char* CUIMapList::GetCommandLine(LPCSTR player_name){ CUIListBoxItem* itm = m_pList2->GetItemByIDX(0); if (!itm) return NULL; u32 _idx = (u32)(__int64)(itm->GetData()); const SGameTypeMaps::SMapItm& M = GetMapNameInt (GetCurGameType(), _idx); m_command.clear(); m_command = "start server("; m_command += M.map_name.c_str(); m_command += "/"; m_command += GameTypeToString(GetCurGameType(),true); m_command += m_srv_params; m_command += "/ver="; m_command += M.map_ver.c_str(); m_command += "/estime="; u32 id = m_pWeatherSelector->m_list_box.GetSelectedItem()->GetTAG(); m_command += m_mapWeather[id].weather_time.c_str(); m_command += ")"; m_command += " client(localhost/name="; if (player_name == NULL || 0 == xr_strlen(player_name)) { string64 player_name2; GetPlayerName_FromRegistry( player_name2, sizeof(player_name2) ); if ( xr_strlen(player_name2) == 0 ) { xr_strcpy( player_name2, xr_strlen(Core.UserName) ? Core.UserName : Core.CompName ); } VERIFY( xr_strlen(player_name2) ); m_command += player_name2; } else { m_command += player_name; } m_command += ")"; return m_command.c_str(); }
float CUIListBox::GetLongestLength() { float len = 0; for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { float tmp_len = item->GetFont()->SizeOf_(item->m_text.GetText()); //all ok UI()->ClientToScreenScaledWidth(tmp_len); if (tmp_len > len) len = tmp_len; } } return len; }
void CUIMapList::OnListItemClicked() { xr_string map_name = "intro\\intro_map_pic_"; CUIListBoxItem* itm = m_pList1->GetSelectedItem(); u32 _idx = (u32)(__int64)(itm->GetData()); const shared_str& _map_name = GetMapNameInt(GetCurGameType(), _idx); map_name += _map_name.c_str(); xr_string full_name = map_name + ".dds"; if (FS.exist("$game_textures$",full_name.c_str())) m_pMapPic->InitTexture(map_name.c_str()); else m_pMapPic->InitTexture("ui\\ui_noise"); m_pMapInfo->InitMap(_map_name.c_str()); }
int CUIListBox::GetIdxByTAG(u32 tag_val) { int result = -1; for(WINDOW_LIST_it it = m_pad->GetChildWndList().begin(); m_pad->GetChildWndList().end()!=it; ++it) { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(*it); if (item) { if(result==-1) result=0; else ++result; if (item->GetTAG() == tag_val) break; } } return result; }
void CUIMapList::UpdateMapList(EGameIDs GameType) { typedef buffer_vector<shared_str> MapList; m_pList1->Clear (); const SGameTypeMaps& M = gMapListHelper.GetMapListFor(GameType); u32 cnt = M.m_map_names.size(); for (u32 i=0; i<cnt; ++i) { CUIListBoxItem* itm = m_pList1->AddTextItem( CStringTable().translate(M.m_map_names[i].map_name).c_str() ); itm->SetData ( (void*)(__int64)i ); itm->Enable (true); } u32 list_size = m_pList2->GetSize(); if ( list_size == 0 ) { m_pList2->Clear (); return; } MapList map_list( _alloca( sizeof(shared_str) * list_size ), list_size ); for ( u32 i = 0; i < list_size; ++i ) { LPCSTR st = m_pList2->GetText( i ); map_list.push_back( st ); } m_pList2->Clear(); MapList::const_iterator itb = map_list.begin(); MapList::const_iterator ite = map_list.end(); for ( ; itb != ite; ++itb ) { CUIListBoxItem* itm1 = GetMapItem_fromList1( *itb ); if ( itm1 ) { CUIListBoxItem* itm2 = m_pList2->AddTextItem( (*itb).c_str() ); itm2->SetData( itm1->GetData() ); itm2->Enable( true ); } } }
CUIListBoxItem* CUIListBox::AddItem() { CUIListBoxItem* item = xr_new<CUIListBoxItem>(m_def_item_height); item->InitFrameLineWnd (Fvector2().set(0,0), Fvector2().set(GetDesiredChildWidth()-5, m_def_item_height)); item->GetTextItem()->SetWidth (GetDesiredChildWidth()); item->SetWidth (GetDesiredChildWidth()); if(m_selection_texture.size()) item->InitTexture (m_selection_texture.c_str(), "hud\\default"); else item->InitDefault (); item->SetFont (GetFont()); item->SetSelected (false); item->SetMessageTarget (this); AddWindow (item, true); return item; }
void CUIMapList::OnListItemClicked() { xr_string map_name = "intro\\intro_map_pic_"; CUIListBoxItem* itm = m_pList1->GetSelectedItem(); u32 _idx = (u32)(__int64)(itm->GetData()); const SGameTypeMaps::SMapItm& M = GetMapNameInt(GetCurGameType(), _idx); map_name += M.map_name.c_str(); xr_string full_name = map_name + ".dds"; Frect orig_rect = m_pMapPic->GetTextureRect(); if (FS.exist("$game_textures$",full_name.c_str())) m_pMapPic->InitTexture (map_name.c_str()); else m_pMapPic->InitTexture ("ui\\ui_noise"); m_pMapPic->SetTextureRect(orig_rect); m_pMapInfo->InitMap (M.map_name.c_str(), M.map_ver.c_str()); }
void CUIKickPlayer::OnBtnOk() { CUIListBoxItem* item = smart_cast<CUIListBoxItem*>(m_ui_players_list->GetSelected()); if (item) { string512 command; switch (mode) { case MODE_KICK: xr_sprintf(command, "cl_votestart kick %s", item->GetText()); break; case MODE_BAN: { xr_sprintf(command, "cl_votestart ban %s %d", item->GetText(), m_spin_ban_sec->Value()); }break; } Console->Execute (command); HideDialog (); } else return; }
CUIListBoxItem* CUIListBox::AddItem(LPCSTR text) { if (!text) return NULL; CUIListBoxItem* pItem = new CUIListBoxItem(); pItem->InitFrameLineWnd (Fvector2().set(0,0), Fvector2().set(this->GetDesiredChildWidth()-5, m_def_item_height) ); if (!m_selection_texture) pItem->InitDefault (); else pItem->InitTexture (*m_selection_texture,"hud\\default"); pItem->SetSelected (false); pItem->m_text.SetText (*CStringTable().translate(text)); pItem->SetTextColor (m_text_color, m_text_color_s); pItem->SetMessageTarget (this); AddWindow (pItem, true); return pItem; }
void CServerList::FillUpDetailedServerInfo() { bool t1 = false; bool t2 = false; bool spect = false; CUIListItemServer* pItem = (CUIListItemServer*)m_list[LST_SERVER].GetSelectedItem(); if(pItem) { ServerInfo srvInfo; browser().GetServerInfoByIndex(&srvInfo, pItem->GetInfo()->info.Index); u32 teams = srvInfo.m_aTeams.size(); if (2 == teams) { LPSTR _buff = NULL; CUIListBoxItem* pItemAdv; // TEAM 1 xr_vector<PlayerInfo>::iterator it; for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); ++it) { PlayerInfo pf = *it; if (1 != pf.Team) continue; if (pf.Spectator) continue; if (!t1) // add header { STRCONCAT(_buff, CStringTable().translate("ui_st_team").c_str(), "\"", CTeamInfo::GetTeam1_name().c_str(), "\""); pItemAdv = m_list[LST_PLAYERS].AddItem(); pItemAdv->SetTextColor (m_list[LST_PLAYERS].GetTextColor()); pItemAdv->SetFont (m_list[LST_PLAYERS].GetFont()); pItemAdv->SetText (_buff); pItemAdv->GetTextItem()->SetWidth(m_list[LST_PLAYERS].GetDesiredChildWidth()); t1 = true; } pItemAdv = m_list[LST_PLAYERS].AddItem(); char buf[16]; pItemAdv->SetTextColor (m_list[LST_PLAYERS].GetTextColor()); pItemAdv->SetFont (m_list[LST_PLAYERS].GetFont()); pItemAdv->SetText (pf.Name); pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Frags); pItemAdv->AddTextField (buf, m_header2[2].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Deaths); pItemAdv->AddTextField (buf, m_header2[3].GetWidth()); } // TEAM 2 for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); it++) { PlayerInfo pf = *it; if (2 != pf.Team) continue; if (pf.Spectator) continue; if (!t2) { STRCONCAT(_buff, CStringTable().translate("ui_st_team").c_str(), "\"", CTeamInfo::GetTeam2_name().c_str(), "\""); m_list[LST_PLAYERS].AddTextItem (_buff); t2 = true; } pItemAdv = m_list[LST_PLAYERS].AddItem(); char buf[16]; pItemAdv->SetTextColor (m_list[LST_PLAYERS].GetTextColor()); pItemAdv->SetFont (m_list[LST_PLAYERS].GetFont()); pItemAdv->SetText (pf.Name); pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Frags); pItemAdv->AddTextField (buf, m_header2[2].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Deaths); pItemAdv->AddTextField (buf, m_header2[3].GetWidth()); } // SPECTATORS for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end();++it) { PlayerInfo pf = *it; if (!pf.Spectator) continue; if (!spect) { pItemAdv = m_list[LST_PLAYERS].AddTextItem(CStringTable().translate("mp_spectator").c_str()); spect = true; } pItemAdv = m_list[LST_PLAYERS].AddItem(); char buf[16]; pItemAdv->SetFont (m_list[LST_PLAYERS].GetFont()); pItemAdv->SetTextColor (m_list[LST_PLAYERS].GetTextColor()); pItemAdv->SetText (pf.Name); pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Frags); pItemAdv->AddTextField (buf, m_header2[2].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Deaths); pItemAdv->AddTextField (buf, m_header2[3].GetWidth()); } } else { xr_vector<PlayerInfo>::iterator it; for (it = srvInfo.m_aPlayers.begin(); it != srvInfo.m_aPlayers.end(); ++it) { PlayerInfo pf = *it; CUIListBoxItem* pItemAdv = m_list[LST_PLAYERS].AddItem(); char buf[16]; pItemAdv->SetTextColor (m_list[LST_PLAYERS].GetTextColor()); pItemAdv->SetFont (m_list[LST_PLAYERS].GetFont()); pItemAdv->SetText (pf.Name); pItemAdv->GetTextItem()->SetWidth(m_header2[1].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Frags); pItemAdv->AddTextField (buf, m_header2[2].GetWidth()); xr_sprintf (buf,sizeof(buf),"%d",pf.Deaths); pItemAdv->AddTextField (buf, m_header2[3].GetWidth()); } } xr_vector<GameInfo>::iterator it; for (it = srvInfo.m_aInfos.begin(); it != srvInfo.m_aInfos.end(); ++it) { GameInfo gi = *it; CUIListBoxItem* pItemAdv = m_list[LST_SRV_PROP].AddItem(); pItemAdv->SetText (gi.InfoName.c_str()); pItemAdv->GetTextItem()->SetWidth (m_list[LST_SRV_PROP].GetWidth()/2); pItemAdv->AddTextField (gi.InfoData.c_str(), m_list[LST_SRV_PROP].GetWidth()/2); } } else ClearDetailedServerInfo (); }