From: <dil...@us...> - 2013-11-27 23:28:11
|
Revision: 6543 http://sourceforge.net/p/freeorion/code/6543 Author: dilvish-fo Date: 2013-11-27 23:28:06 +0000 (Wed, 27 Nov 2013) Log Message: ----------- sorts System Selection DropDown list alphabetically. Caveat: done by true name, so 'deep space' listings will still be scattered throughout Modified Paths: -------------- trunk/FreeOrion/UI/SidePanel.cpp Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2013-11-27 18:38:30 UTC (rev 6542) +++ trunk/FreeOrion/UI/SidePanel.cpp 2013-11-27 23:28:06 UTC (rev 6543) @@ -2731,17 +2731,17 @@ // populate droplist of system names { ScopedTimer("SidePanel::RefreshImpl droplist population", true); - int system_names_in_droplist = 0; + std::map< std::string, int > system_map; //alphabetize Systems here for (ObjectMap::const_iterator<System> sys_it = Objects().const_begin<System>(); - sys_it != Objects().const_end<System>(); ++sys_it) + sys_it != Objects().const_end<System>(); ++sys_it) { - int sys_id = sys_it->ID(); + if (!sys_it->Name().empty() || sys_it->ID()==s_system_id) // skip rows for systems that aren't known to this client, except the selected system + system_map.insert(std::make_pair<std::string, int>(sys_it->Name(), sys_it->ID())); + } + for ( std::map< std::string, int >::iterator sys_it = system_map.begin(); sys_it != system_map.end(); sys_it++) { + int sys_id = sys_it->second; - if (sys_it->Name().empty() && sys_id != s_system_id) - continue; // skip rows for systems that aren't known to this client, except the selected system - GG::DropDownList::iterator latest_it = m_system_name->Insert(new SystemRow(sys_id)); - ++system_names_in_droplist; if (sys_id == s_system_id) m_system_name->Select(latest_it); @@ -2752,7 +2752,7 @@ const GG::Y TEXT_ROW_HEIGHT = CUISimpleDropDownListRow::DEFAULT_ROW_HEIGHT; const GG::Y MAX_DROPLIST_DROP_HEIGHT = TEXT_ROW_HEIGHT * 10; const int TOTAL_LISTBOX_MARGIN = 4; - GG::Y drop_height = std::min(TEXT_ROW_HEIGHT * system_names_in_droplist, MAX_DROPLIST_DROP_HEIGHT) + TOTAL_LISTBOX_MARGIN; + GG::Y drop_height = std::min(TEXT_ROW_HEIGHT * int(system_map.size()), MAX_DROPLIST_DROP_HEIGHT) + TOTAL_LISTBOX_MARGIN; m_system_name->SetDropHeight(drop_height); } |