From: <geo...@us...> - 2008-03-31 19:29:24
|
Revision: 2442 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2442&view=rev Author: geoffthemedio Date: 2008-03-31 12:29:22 -0700 (Mon, 31 Mar 2008) Log Message: ----------- -Added checks to texture getters in case they are passed invalid BuildingType, PartType, HullType, etc. -Made BuildDesignatorWnd's list populate function use the ClientUI texture getters, which seems to get rid of some annoying missing texture error messages Modified Paths: -------------- trunk/FreeOrion/UI/BuildDesignatorWnd.cpp trunk/FreeOrion/UI/ClientUI.cpp Modified: trunk/FreeOrion/UI/BuildDesignatorWnd.cpp =================================================================== --- trunk/FreeOrion/UI/BuildDesignatorWnd.cpp 2008-03-31 03:48:54 UTC (rev 2441) +++ trunk/FreeOrion/UI/BuildDesignatorWnd.cpp 2008-03-31 19:29:22 UTC (rev 2442) @@ -767,7 +767,7 @@ // icon GG::Control* icon = new GG::StaticGraphic(0, 0, icon_col_width, m_row_height, - ClientUI::GetTexture(ClientUI::ArtDir() / type->Graphic()), + ClientUI::BuildingTexture(type->Name()), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); row->push_back(icon); @@ -822,7 +822,7 @@ // icon GG::StaticGraphic* icon = new GG::StaticGraphic(0, 0, icon_col_width, m_row_height, - ClientUI::GetTexture(ClientUI::ArtDir() / ship_design->Graphic()), + ClientUI::ShipIcon(ship_design->ID()), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); row->push_back(dynamic_cast<GG::Control*>(icon)); Modified: trunk/FreeOrion/UI/ClientUI.cpp =================================================================== --- trunk/FreeOrion/UI/ClientUI.cpp 2008-03-31 03:48:54 UTC (rev 2441) +++ trunk/FreeOrion/UI/ClientUI.cpp 2008-03-31 19:29:22 UTC (rev 2442) @@ -95,14 +95,17 @@ { const ShipDesign* design = GetShipDesign(design_id); boost::shared_ptr<GG::Texture> texture = ClientUI::GetTexture(ArtDir() / design->Graphic(), true); - if (texture) return texture; + if (texture) + return texture; return ClientUI::GetTexture(ArtDir() / "icons" / "Scout.png", true); } boost::shared_ptr<GG::Texture> ClientUI::BuildingTexture(const std::string& building_type_name) { const BuildingType* building_type = GetBuildingType(building_type_name); - const std::string graphic_name = building_type->Graphic(); + std::string graphic_name = ""; + if (building_type) + graphic_name = building_type->Graphic(); if (graphic_name.empty()) return ClientUI::GetTexture(ArtDir() / "icons" / "building" / "generic_building.png", true); return ClientUI::GetTexture(ArtDir() / graphic_name, true); @@ -120,17 +123,20 @@ boost::shared_ptr<GG::Texture> ClientUI::TechTexture(const std::string& tech_name) { const Tech* tech = GetTechManager().GetTech(tech_name); - std::string texture_name = tech->Graphic(); - if (texture_name.empty()) { + std::string texture_name = ""; + if (tech) + texture_name = tech->Graphic(); + if (texture_name.empty()) return CategoryIcon(tech->Category()); - } return ClientUI::GetTexture(ArtDir() / texture_name, true); } boost::shared_ptr<GG::Texture> ClientUI::SpecialTexture(const std::string& special_name) { const Special* special = GetSpecial(special_name); - std::string texture_name = special->Graphic(); + std::string texture_name = ""; + if (special) + texture_name = special->Graphic(); if (texture_name.empty()) return ClientUI::GetTexture(ArtDir() / "icons" / "specials_huge" / "generic_special.png", true); return ClientUI::GetTexture(ArtDir() / texture_name); @@ -139,7 +145,9 @@ boost::shared_ptr<GG::Texture> ClientUI::PartTexture(const std::string& part_name) { const PartType* part = GetPartType(part_name); - std::string texture_name = part->Graphic(); + std::string texture_name = ""; + if (part) + std::string texture_name = part->Graphic(); if (texture_name.empty()) return ClientUI::GetTexture(ArtDir() / "icons" / "ship_parts" / "generic_part.png", true); return ClientUI::GetTexture(ArtDir() / texture_name); @@ -148,7 +156,9 @@ boost::shared_ptr<GG::Texture> ClientUI::HullTexture(const std::string& hull_name) { const HullType* hull = GetHullType(hull_name); - std::string texture_name = "";//hull->Graphic(); + std::string texture_name = ""; + if (hull) + texture_name = "";//hull->Graphic(); if (texture_name.empty()) return ClientUI::GetTexture(ArtDir() / "hulls_design" / "generic_hull.png", true); return ClientUI::GetTexture(ArtDir() / texture_name); |