From: <geo...@us...> - 2010-05-29 08:56:05
|
Revision: 3611 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3611&view=rev Author: geoffthemedio Date: 2010-05-29 08:55:58 +0000 (Sat, 29 May 2010) Log Message: ----------- -Removed stored signal connection in ResourcePanel, as it wasn't needed. -Moved population of focus droplist to ResourcePanel::Update from the constructor, so that changes during gameplay will be reflected. -Made the ResourcePanel drop list drop height change with the number of foci available, to avoid extra space or scrollbars in the list of focus options. Modified Paths: -------------- trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/UI/InfoPanels.h Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2010-05-29 08:11:13 UTC (rev 3610) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2010-05-29 08:55:58 UTC (rev 3611) @@ -491,27 +491,15 @@ GG::Connect(m_expand_button->ClickedSignal, &ResourcePanel::ExpandCollapseButtonPressed, this); - GG::DropDownList::Row* row; - boost::shared_ptr<GG::Texture> texture; - GG::StaticGraphic* graphic; + int tooltip_delay = GetOptionsDB().Get<int>("UI.tooltip-delay"); - // focus-selection droplists - const std::vector<std::string>& available_foci = res->AvailableFoci(); - m_focus_drop = new CUIDropDownList(GG::X0, GG::Y0, MeterIconSize().x*4, MeterIconSize().y*3/2, MeterIconSize().y*19/2); - for (std::vector<std::string>::const_iterator it = available_foci.begin(); it != available_foci.end(); ++it) { - boost::shared_ptr<GG::Texture> texture = ClientUI::GetTexture(ClientUI::ArtDir() / res->FocusIcon(*it), true); - graphic = new GG::StaticGraphic(GG::X0, GG::Y0, MeterIconSize().x*3/2, MeterIconSize().y*3/2, texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); - row = new GG::DropDownList::Row(graphic->Width(), graphic->Height(), ""); - row->push_back(dynamic_cast<GG::Control*>(graphic)); - m_focus_drop->Insert(row); - } + // focus-selection droplist + m_focus_drop = new CUIDropDownList(GG::X0, GG::Y0, MeterIconSize().x*4, MeterIconSize().y*3/2, MeterIconSize().y*7/2); AttachChild(m_focus_drop); - - int tooltip_delay = GetOptionsDB().Get<int>("UI.tooltip-delay"); + GG::Connect(m_focus_drop->SelChangedSignal, &ResourcePanel::FocusDropListSelectionChanged, this); m_focus_drop->SetBrowseModeTime(tooltip_delay); - m_drop_changed_connections[m_focus_drop] = GG::Connect(m_focus_drop->SelChangedSignal, &ResourcePanel::FocusDropListSelectionChanged, this); // small resource indicators - for use when panel is collapsed m_farming_stat = new StatisticIcon(GG::X0, GG::Y0, MeterIconSize().x, MeterIconSize().y, ClientUI::MeterIcon(METER_FARMING), @@ -573,11 +561,6 @@ delete m_research_stat; delete m_trade_stat; - // get rid of held connections - for (std::map<CUIDropDownList*, boost::signals::connection>::iterator it = m_drop_changed_connections.begin(); it != m_drop_changed_connections.end(); ++it) - it->second.disconnect(); - m_drop_changed_connections.clear(); - delete m_focus_drop; // don't need to manually delete m_expand_button, as it is attached as a child so will be deleted by ~Wnd @@ -832,10 +815,23 @@ browse_wnd = boost::shared_ptr<GG::BrowseInfoWnd>(new MeterBrowseWnd(m_rescenter_id, METER_CONSTRUCTION, METER_TARGET_CONSTRUCTION)); m_multi_icon_value_indicator->SetToolTip(METER_CONSTRUCTION, browse_wnd); - // focus droplists + + // focus droplist + const std::vector<std::string>& available_foci = res->AvailableFoci(); + // refresh items in list + m_focus_drop->Clear(); + for (std::vector<std::string>::const_iterator it = available_foci.begin(); it != available_foci.end(); ++it) { + boost::shared_ptr<GG::Texture> texture = ClientUI::GetTexture(ClientUI::ArtDir() / res->FocusIcon(*it), true); + GG::StaticGraphic* graphic = new GG::StaticGraphic(GG::X0, GG::Y0, MeterIconSize().x*3/2, MeterIconSize().y*3/2, + texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); + GG::DropDownList::Row* row = new GG::DropDownList::Row(graphic->Width(), graphic->Height(), ""); + row->push_back(dynamic_cast<GG::Control*>(graphic)); + m_focus_drop->Insert(row); + } + m_focus_drop->SetDropHeight(static_cast<int>(available_foci.size()) * MeterIconSize().y*3/2 + GG::Y(5)); + // set browse text and select appropriate focus in droplist std::string focus_text; if (!res->Focus().empty()) { - const std::vector<std::string>& available_foci = res->AvailableFoci(); for (unsigned int i = 0; i < available_foci.size(); ++i) { if (available_foci[i] == res->Focus()) { m_focus_drop->Select(i); Modified: trunk/FreeOrion/UI/InfoPanels.h =================================================================== --- trunk/FreeOrion/UI/InfoPanels.h 2010-05-29 08:11:13 UTC (rev 3610) +++ trunk/FreeOrion/UI/InfoPanels.h 2010-05-29 08:55:58 UTC (rev 3611) @@ -117,13 +117,11 @@ MultiIconValueIndicator* m_multi_icon_value_indicator; ///< textually / numerically indicates resource production and construction meter MultiMeterStatusBar* m_multi_meter_status_bar; ///< graphically indicates meter values - CUIDropDownList* m_focus_drop; ///< displays and allows selection of primary focus - std::map<CUIDropDownList*, boost::signals::connection> - m_drop_changed_connections; ///< signals connecting selection changed signals from drop lists to responses. blocked when programmatically changing focus selection, to avoid recursive signal emission + CUIDropDownList* m_focus_drop; ///< displays and allows selection of primary focus - GG::Button* m_expand_button; ///< at top right of panel, toggles the panel open/closed to show details or minimal summary + GG::Button* m_expand_button; ///< at top right of panel, toggles the panel open/closed to show details or minimal summary - static std::map<int, bool> s_expanded_map; ///< map indexed by popcenter ID indicating whether the PopulationPanel for each object is expanded (true) or collapsed (false) + static std::map<int, bool> s_expanded_map; ///< map indexed by popcenter ID indicating whether the PopulationPanel for each object is expanded (true) or collapsed (false) }; /** Shows military-related meters including stealth, detection, shields, defense; with meter bars */ |