From: <geo...@us...> - 2008-06-25 18:57:01
|
Revision: 2609 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2609&view=rev Author: geoffthemedio Date: 2008-06-25 11:57:10 -0700 (Wed, 25 Jun 2008) Log Message: ----------- -Exposed leastJumpsPath and updateMeterEstimates on Universe class to Python -Made FleetWnd use ClientUI::ShipIcon to get icon for fleets, so that nicer and more specific icons are used when available -Minor whitespace grooming Modified Paths: -------------- trunk/FreeOrion/Empire/Empire.cpp trunk/FreeOrion/UI/FleetWnd.cpp trunk/FreeOrion/python/PythonEmpireWrapper.cpp trunk/FreeOrion/python/PythonUniverseWrapper.cpp trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/Empire/Empire.cpp =================================================================== --- trunk/FreeOrion/Empire/Empire.cpp 2008-06-25 05:56:42 UTC (rev 2608) +++ trunk/FreeOrion/Empire/Empire.cpp 2008-06-25 18:57:10 UTC (rev 2609) @@ -1816,7 +1816,8 @@ Logger().debugStream() << "New Fleet created on turn: " << fleet->CreationTurn(); // add ship - Ship *ship = new Ship(m_id, m_production_queue[i].item.design_id); + Ship* ship = new Ship(m_id, m_production_queue[i].item.design_id); + int ship_id = universe.Insert(ship); #if 0 const ShipDesign* ship_design = GetShipDesign(m_production_queue[i].item.design_id); Modified: trunk/FreeOrion/UI/FleetWnd.cpp =================================================================== --- trunk/FreeOrion/UI/FleetWnd.cpp 2008-06-25 05:56:42 UTC (rev 2608) +++ trunk/FreeOrion/UI/FleetWnd.cpp 2008-06-25 18:57:10 UTC (rev 2609) @@ -601,17 +601,10 @@ } else if (m_fleet->NumShips() == 1) { Ship* ship = GetUniverse().Object<Ship>(*m_fleet->begin()); const ShipDesign* design = ship->Design(); - std::string design_name; - if (design) { - design_name = design->Name(); - std::string::size_type space = design_name.find(' '); - if (space != std::string::npos) { - design_name[space] = '_'; - } - } else { - design_name = "Scout"; - } - icon = ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / (design_name + ".png")); + if (design) + icon = ClientUI::ShipIcon(design->ID()); + else + icon = ClientUI::ShipIcon(-1); // default icon } } else { // the "new fleet" data panel icon = ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "newfleet.png"); Modified: trunk/FreeOrion/python/PythonEmpireWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonEmpireWrapper.cpp 2008-06-25 05:56:42 UTC (rev 2608) +++ trunk/FreeOrion/python/PythonEmpireWrapper.cpp 2008-06-25 18:57:10 UTC (rev 2609) @@ -7,7 +7,9 @@ namespace { // Research queue tests whether it contains a Tech but Python needs a __contains__ function that takes a // *Queue::Element. This helper functions take an Element and returns the associated Tech. - const Tech* TechFromResearchQueueElement(const ResearchQueue::Element& element) { return element.tech; } + const Tech* TechFromResearchQueueElement(const ResearchQueue::Element& element) { + return element.tech; + } std::vector<std::string> (TechManager::*TechNamesVoid)(void) const = &TechManager::TechNames; boost::function<std::vector<std::string>(const TechManager*)> TechNamesMemberFunc = TechNamesVoid; Modified: trunk/FreeOrion/python/PythonUniverseWrapper.cpp =================================================================== --- trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2008-06-25 05:56:42 UTC (rev 2608) +++ trunk/FreeOrion/python/PythonUniverseWrapper.cpp 2008-06-25 18:57:10 UTC (rev 2609) @@ -21,6 +21,17 @@ const System* (Universe::*UniverseGetSystem)(int) = &Universe::Object; const Building* (Universe::*UniverseGetBuilding)(int) = &Universe::Object; + void (Universe::*UpdateMeterEstimatesVoidFunc)(void) = &Universe::UpdateMeterEstimates; + + std::vector<int> LeastJumpsPath(const Universe* universe, int start_sys, int end_sys, int empire_id) { + std::pair<std::list<System*>, int> path = universe->LeastJumpsPath(start_sys, end_sys, empire_id); + std::vector<int> retval; + for (std::list<System*>::const_iterator it = path.first.begin(); it != path.first.end(); ++it) + retval.push_back((*it)->ID()); + return retval; + } + boost::function<std::vector<int>(const Universe*, int, int, int)> LeastJumpsFunc = &LeastJumpsPath; + const Meter* (UniverseObject::*ObjectGetMeter)(MeterType) const = &UniverseObject::GetMeter; boost::function<double(const UniverseObject*, MeterType)> InitialCurrentMeterValueFromObject = @@ -94,8 +105,17 @@ // put as part of universe class so one doesn't need a UniverseObject object in python to access these .def_readonly("invalidObjectID", &UniverseObject::INVALID_OBJECT_ID) .def_readonly("invalidObjectAge", &UniverseObject::INVALID_OBJECT_AGE) + + .def("updateMeterEstimates", UpdateMeterEstimatesVoidFunc) + + .def("leastJumpsPath", make_function( + LeastJumpsFunc, + return_value_policy<return_by_value>(), + boost::mpl::vector<std::vector<int>, const Universe*, int, int, int>() + )) ; + //////////////////// // UniverseObject // //////////////////// Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2008-06-25 05:56:42 UTC (rev 2608) +++ trunk/FreeOrion/universe/Universe.cpp 2008-06-25 18:57:10 UTC (rev 2609) @@ -204,8 +204,8 @@ std::vector<int> predecessors(boost::num_vertices(graph)); for (unsigned int i = 0; i < boost::num_vertices(graph); ++i) predecessors[i] = i; - - + + // do the actual path finding using verbose boost magic... try { boost::queue<int> buf; @@ -234,7 +234,7 @@ // add start system to path, as it wasn't added by traversing predecessors array retval.first.push_front(pointer_property_map[system1_index]); } - + return retval; } |