From: <geo...@us...> - 2009-10-07 04:04:29
|
Revision: 3196 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3196&view=rev Author: geoffthemedio Date: 2009-10-07 04:04:20 +0000 (Wed, 07 Oct 2009) Log Message: ----------- Added red X to indicate scrapping a building has been ordered Modified Paths: -------------- trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/UI/InfoPanels.h Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-10-06 03:50:55 UTC (rev 3195) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-10-07 04:04:20 UTC (rev 3196) @@ -1661,7 +1661,7 @@ double partial_turn = std::fmod(progress, turn_cost) / turn_cost; int turns_completed = static_cast<int>(progress / turn_cost); - + BuildingIndicator* ind = new BuildingIndicator(GG::X(indicator_size), *building_type, turns, turns_completed, partial_turn); m_building_indicators.push_back(ind); } @@ -1771,26 +1771,23 @@ BuildingIndicator::BuildingIndicator(GG::X w, int building_id) : Wnd(GG::X0, GG::Y0, w, GG::Y(Value(w)), GG::INTERACTIVE), m_graphic(0), + m_scrap_indicator(0), m_progress_bar(0), m_building_id(building_id) { - if (const Building* building = GetUniverse().Object<Building>(m_building_id)) { - if (const BuildingType* type = building->GetBuildingType()) { - boost::shared_ptr<GG::Texture> texture = ClientUI::BuildingTexture(type->Name()); + SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); - SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); - SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(new IconTextBrowseWnd(texture, UserString(type->Name()), UserString(type->Description())))); + if (const Building* building = GetUniverse().Object<Building>(m_building_id)) + GG::Connect(building->StateChangedSignal, &BuildingIndicator::Refresh, this); - m_graphic = new GG::StaticGraphic(GG::X0, GG::Y0, w, GG::Y(Value(w)), texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); - AttachChild(m_graphic); - } - } + Refresh(); } BuildingIndicator::BuildingIndicator(GG::X w, const BuildingType &type, int turns, int turns_completed, double partial_turn) : Wnd(GG::X0, GG::Y0, w, GG::Y(Value(w)), GG::INTERACTIVE), m_graphic(0), + m_scrap_indicator(0), m_progress_bar(0), m_building_id(UniverseObject::INVALID_OBJECT_ID) { @@ -1850,6 +1847,36 @@ glEnable(GL_TEXTURE_2D); } +void BuildingIndicator::Refresh() +{ + if (const Building* building = GetUniverse().Object<Building>(m_building_id)) { + ClearBrowseInfoWnd(); + + if (m_graphic) { + delete m_graphic; + m_graphic = 0; + } + if (m_scrap_indicator) { + delete m_scrap_indicator; + m_scrap_indicator = 0; + } + + if (const BuildingType* type = building->GetBuildingType()) { + boost::shared_ptr<GG::Texture> texture = ClientUI::BuildingTexture(type->Name()); + m_graphic = new GG::StaticGraphic(GG::X0, GG::Y0, Width(), GG::Y(Value(Width())), texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); + AttachChild(m_graphic); + + SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(new IconTextBrowseWnd(texture, UserString(type->Name()), UserString(type->Description())))); + + if (building->OrderedScrapped()) { + boost::shared_ptr<GG::Texture> scrap_texture = ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "missing.png", true); + m_scrap_indicator = new GG::StaticGraphic(GG::X0, GG::Y0, Width(), GG::Y(Value(Width())), scrap_texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); + AttachChild(m_scrap_indicator); + } + } + } +} + void BuildingIndicator::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { Wnd::SizeMove(ul, lr); @@ -1859,6 +1886,9 @@ if (m_graphic) m_graphic->SizeMove(GG::Pt(GG::X0, GG::Y0), child_lr); + if (m_scrap_indicator) + m_scrap_indicator->SizeMove(GG::Pt(GG::X0, GG::Y0), child_lr); + GG::Y bar_top = Height() * 4 / 5; if (m_progress_bar) m_progress_bar->SizeMove(GG::Pt(GG::X0, bar_top), child_lr); Modified: trunk/FreeOrion/UI/InfoPanels.h =================================================================== --- trunk/FreeOrion/UI/InfoPanels.h 2009-10-06 03:50:55 UTC (rev 3195) +++ trunk/FreeOrion/UI/InfoPanels.h 2009-10-07 04:04:20 UTC (rev 3196) @@ -218,15 +218,17 @@ double partial_turn); ///< constructor for use when building is partially complete, to show progress bar virtual void Render(); + void Refresh(); virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); virtual void MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys); virtual void RClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); private: - GG::StaticGraphic* m_graphic; - MultiTurnProgressBar* m_progress_bar; - int m_building_id; + GG::StaticGraphic* m_graphic; + GG::StaticGraphic* m_scrap_indicator; ///< shown to indicate building was ordered scrapped + MultiTurnProgressBar* m_progress_bar; + int m_building_id; }; /** Displays a set of specials attached to an UniverseObject */ |