From: <geo...@us...> - 2008-06-17 03:55:14
|
Revision: 2589 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2589&view=rev Author: geoffthemedio Date: 2008-06-16 20:55:20 -0700 (Mon, 16 Jun 2008) Log Message: ----------- -Fixed research screen so default view has techs on it, and the view starts centred on a tech instead of the top left empty space as was the case before -Made research screen open faster by changing when the tree layout and list populating is redone -Slightly reworked signalling from systems that a fleet's been added or removed, and fleet change signals to SystemIcon -Removed some unused fleet signals from SidePanel -Misc. code grooming -Removed the save directory that was seemingly pointlessly being maintained in SVN Modified Paths: -------------- trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/ProductionWnd.cpp trunk/FreeOrion/UI/ProductionWnd.h trunk/FreeOrion/UI/ResearchWnd.cpp trunk/FreeOrion/UI/ResearchWnd.h trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/UI/SidePanel.h trunk/FreeOrion/UI/SystemIcon.cpp trunk/FreeOrion/UI/SystemIcon.h trunk/FreeOrion/UI/TechTreeWnd.cpp trunk/FreeOrion/universe/System.cpp trunk/FreeOrion/universe/System.h Removed Paths: ------------- trunk/FreeOrion/save/ Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/MapWnd.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -998,8 +998,9 @@ else ShowSystemNames(); - // center the map on player's home system at the start of the game (if we're at the default start position, the odds are very good that this is a fresh game) + // if we're at the default start position, the odds are very good that this is a fresh game if (ClientUpperLeft() == GG::Pt()) { + // center the map on player's home system at the start of the game int capitol_id = empire->CapitolID(); UniverseObject *obj = universe.Object(capitol_id); if (obj) { @@ -1008,6 +1009,9 @@ // default to centred on whole universe if there is no capitol CenterOnMapCoord(Universe::UniverseWidth() / 2, Universe::UniverseWidth() / 2); } + + // default the tech tree to be centred on something interesting + m_research_wnd->Reset(); } // empire is recreated each turn based on turn update from server, so connections of signals emitted from @@ -1878,7 +1882,7 @@ const unsigned int PROJECTED_PATH_STIPPLE = (PATTERN << PROJECTED_PATH_SHIFT) | (PATTERN >> (GLUSHORT_BIT_LENGTH - PROJECTED_PATH_SHIFT)); - //// render projected move lines + //// render projected move liens glLineStipple(static_cast<int>(STARLANE_WIDTH), PROJECTED_PATH_STIPPLE); for (std::map<const Fleet*, MovementLineData>::const_iterator it = m_projected_fleet_lines.begin(); it != m_projected_fleet_lines.end(); ++it) RenderMovementLine(it->second); @@ -2032,7 +2036,7 @@ if (execute_move && !route.empty()) HumanClientApp::GetApp()->Orders().IssueOrder(OrderPtr(new FleetMoveOrder(empire_id, fleet->ID(), start_system, system_id))); - // display projected move line + // show route on map SetProjectedFleetMovementLine(fleet, route); } } @@ -2362,8 +2366,6 @@ DetachChild(m_side_panel); GG::GUI::GetGUI()->MoveUp(m_production_wnd); - - m_production_wnd->Reset(); } return true; } Modified: trunk/FreeOrion/UI/ProductionWnd.cpp =================================================================== --- trunk/FreeOrion/UI/ProductionWnd.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/ProductionWnd.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -387,6 +387,11 @@ m_build_designator_wnd->Reset(); } +void ProductionWnd::Update() +{ + Reset(); +} + void ProductionWnd::CenterOnBuild(int queue_idx) { m_build_designator_wnd->CenterOnBuild(queue_idx); Modified: trunk/FreeOrion/UI/ProductionWnd.h =================================================================== --- trunk/FreeOrion/UI/ProductionWnd.h 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/ProductionWnd.h 2008-06-17 03:55:20 UTC (rev 2589) @@ -31,6 +31,7 @@ void Render(); void Reset(); + void Update(); void CenterOnBuild(int queue_idx); void SelectSystem(int system); void SelectPlanet(int planet); Modified: trunk/FreeOrion/UI/ResearchWnd.cpp =================================================================== --- trunk/FreeOrion/UI/ResearchWnd.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/ResearchWnd.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -293,6 +293,12 @@ m_queue_lb->BringRowIntoView(0); } +void ResearchWnd::Update() +{ + m_tech_tree_wnd->Update(); + UpdateQueue(); +} + void ResearchWnd::CenterOnTech(const std::string& tech_name) { m_tech_tree_wnd->CenterOnTech(GetTech(tech_name)); Modified: trunk/FreeOrion/UI/ResearchWnd.h =================================================================== --- trunk/FreeOrion/UI/ResearchWnd.h 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/ResearchWnd.h 2008-06-17 03:55:20 UTC (rev 2589) @@ -21,6 +21,7 @@ /** \name Mutators */ //@{ void Reset(); + void Update(); void CenterOnTech(const std::string& tech_name); void QueueItemMoved(int row_idx, GG::ListBox::Row* row); void Sanitize(); Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/SidePanel.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -545,7 +545,7 @@ { return static_cast<int>(ClientUI::Pts()*3/2); } - + boost::shared_ptr<GG::Texture> IconPopulation() {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "pop.png" );} boost::shared_ptr<GG::Texture> IconIndustry () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "industry.png" );} boost::shared_ptr<GG::Texture> IconTrade () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "trade.png" );} @@ -1277,37 +1277,30 @@ // update individual PlanetPanels in PlanetPanelContainer, then redo layout of panel container m_planet_panel_container->RefreshAllPlanetPanels(); } + void SidePanel::SetSystemImpl() { TempUISoundDisabler sound_disabler; - m_fleet_icons.clear(); m_planet_panel_container->Clear(); m_system_name->Clear(); DeleteChild(m_star_graphic); m_star_graphic = 0; - // disconnect any existing system signals - while (!m_system_connections.empty()) { - m_system_connections.begin()->disconnect(); - m_system_connections.erase(m_system_connections.begin()); - } - while (!m_fleet_connections.empty()) { - m_fleet_connections.begin()->second.disconnect(); - m_fleet_connections.erase(m_fleet_connections.begin()); - } + // disconnect any existing system and fleet signals + for (std::set<boost::signals::connection>::iterator it = m_system_connections.begin(); it != m_system_connections.end(); ++it) + it->disconnect(); + m_system_connections.clear(); + for (std::map<int, boost::signals::connection>::iterator it = m_fleet_connections.begin(); it != m_fleet_connections.end(); ++it) + it->second.disconnect(); + m_fleet_connections.clear(); - if (s_system) - { - m_system_connections.insert(GG::Connect(s_system->FleetAddedSignal, &SidePanel::SystemFleetAdded, this)); - m_system_connections.insert(GG::Connect(s_system->FleetRemovedSignal, &SidePanel::SystemFleetRemoved, this)); - + if (s_system) { std::vector<const System*> sys_vec = GetUniverse().FindObjects<const System>(); GG::ListBox::Row *select_row = 0; int system_names_in_droplist = 0; - for (unsigned int i = 0; i < sys_vec.size(); i++) - { + for (unsigned int i = 0; i < sys_vec.size(); i++) { GG::ListBox::Row *row = new SystemRow(sys_vec[i]->ID()); if (sys_vec[i]->Name().length()==0) { @@ -1323,7 +1316,7 @@ } else { row->push_back(new OwnerColoredSystemName(sys_vec[i], HumanClientApp::GetApp()->GetFont(ClientUI::Font(), SystemNameFontSize()), UserString("SP_SYSTEM_NAME"))); } - + m_system_name->Insert(row); ++system_names_in_droplist; @@ -1337,8 +1330,7 @@ m_system_name->SetDropHeight(drop_height); for (int i = 0; i < m_system_name->NumRows(); i++) { - if (select_row == &m_system_name->GetRow(i)) - { + if (select_row == &m_system_name->GetRow(i)) { m_system_name->Select(i); break; } @@ -1354,12 +1346,6 @@ AttachChild(m_star_graphic); MoveChildDown(m_star_graphic); - // TODO: add fleet icons - std::pair<System::const_orbit_iterator, System::const_orbit_iterator> range = s_system->non_orbit_range(); - std::vector<const Fleet*> flt_vec = s_system->FindObjects<Fleet>(); - for (unsigned int i = 0; i < flt_vec.size(); i++) - m_fleet_connections.insert(std::pair<int, boost::signals::connection>(flt_vec[i]->ID(), GG::Connect(flt_vec[i]->StateChangedSignal, &SidePanel::FleetsChanged, this))); - // add planets std::vector<const Planet*> plt_vec = s_system->FindObjects<Planet>(); @@ -1459,26 +1445,3 @@ } } -void SidePanel::SystemFleetAdded(const Fleet& flt) -{ - m_fleet_connections.insert(std::pair<int, boost::signals::connection>(flt.ID(), GG::Connect(flt.StateChangedSignal, &SidePanel::FleetsChanged, this))); - FleetsChanged(); -} - -void SidePanel::SystemFleetRemoved(const Fleet& flt) -{ - std::map<int, boost::signals::connection>::iterator map_it = m_fleet_connections.find(flt.ID()); - if (map_it != m_fleet_connections.end()) { - map_it->second.disconnect(); - m_fleet_connections.erase(map_it); - } - FleetsChanged(); -} - -void SidePanel::FleetsChanged() -{ - // may need to add or remove colonize buttons - m_planet_panel_container->RefreshAllPlanetPanels(); - - // TODO: if there are fleet status indicators on the SidePanel, update them -} Modified: trunk/FreeOrion/UI/SidePanel.h =================================================================== --- trunk/FreeOrion/UI/SidePanel.h 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/SidePanel.h 2008-06-17 03:55:20 UTC (rev 2589) @@ -36,29 +36,29 @@ //@} /** \name Accessors */ //@{ - virtual bool InWindow(const GG::Pt& pt) const; + virtual bool InWindow(const GG::Pt& pt) const; - int PlanetPanels() const; - const PlanetPanel* GetPlanetPanel(int n) const; - int SystemID() const; - int PlanetID() const; ///< returns the id of the currently-selected planet, if any + int PlanetPanels() const; + const PlanetPanel* GetPlanetPanel(int n) const; + int SystemID() const; + int PlanetID() const; ///< returns the id of the currently-selected planet, if any //@} /** \name Mutators */ //@{ - virtual void Render(); + virtual void Render(); - static void Refresh(); ///< causes all sidepanels to refresh / update indicators + static void Refresh(); ///< causes all sidepanels to refresh / update indicators - void SelectPlanet(int planet_id); ///< selects the planet with id \a planet_id within the current system, if such a planet exists + void SelectPlanet(int planet_id); ///< selects the planet with id \a planet_id within the current system, if such a planet exists /** sets the predicate that determines what planets can be selected in the side panel. If none is set, planet selection is disabled. */ - void SetValidSelectionPredicate(const boost::shared_ptr<UniverseObjectVisitor> &visitor); + void SetValidSelectionPredicate(const boost::shared_ptr<UniverseObjectVisitor> &visitor); //@} - static void SetSystem(int system_id); ///< sets the system currently being viewed in all side panels + static void SetSystem(int system_id); ///< sets the system currently being viewed in all side panels - static const int MAX_PLANET_DIAMETER; // size of a huge planet, in on-screen pixels - static const int MIN_PLANET_DIAMETER; // size of a tiny planet, in on-screen pixels + static const int MAX_PLANET_DIAMETER; // size of a huge planet, in on-screen pixels + static const int MIN_PLANET_DIAMETER; // size of a tiny planet, in on-screen pixels mutable boost::signal<void (int)> PlanetSelectedSignal; ///< emitted when a rotating planet in the side panel is clicked by the user mutable boost::signal<void (int)> SystemSelectedSignal; ///< emitted when something in the sidepanel wants to change the selected system, including the droplist or back/forward arrows @@ -67,19 +67,17 @@ private: class PlanetPanelContainer; - void RefreshImpl(); - void SetSystemImpl(); - void SystemSelectionChanged(int selection); - void SystemFleetAdded(const Fleet& flt); - void SystemFleetRemoved(const Fleet& flt); - void FleetsChanged(); - void PrevButtonClicked(); - void NextButtonClicked(); - void PlanetSelected(int planet_id); + void RefreshImpl(); + void SetSystemImpl(); + void SystemSelectionChanged(int selection); + void PrevButtonClicked(); + void NextButtonClicked(); + void PlanetSelected(int planet_id); - CUIDropDownList *m_system_name; - GG::Button *m_button_prev, *m_button_next; - GG::DynamicGraphic *m_star_graphic; + CUIDropDownList* m_system_name; + GG::Button* m_button_prev; + GG::Button* m_button_next; + GG::DynamicGraphic* m_star_graphic; std::vector<GG::SubTexture> m_fleet_icons; @@ -89,10 +87,10 @@ static const System* s_system; static std::set<SidePanel*> s_side_panels; - std::set<boost::signals::connection> m_system_connections; - std::map<int, boost::signals::connection> m_fleet_connections; + std::set<boost::signals::connection> m_system_connections; + std::map<int, boost::signals::connection> m_fleet_connections; - static const int EDGE_PAD = 4; + static const int EDGE_PAD = 4; }; #endif // _SidePanel_h_ Modified: trunk/FreeOrion/UI/SystemIcon.cpp =================================================================== --- trunk/FreeOrion/UI/SystemIcon.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/SystemIcon.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -92,8 +92,13 @@ } void SystemIcon::Init() { + // state change signals for system itself and fleets in it Connect(m_system.StateChangedSignal, &SystemIcon::Refresh, this); + std::vector<const Fleet*> fleets = m_system.FindObjects<Fleet>(); + for (std::vector<const Fleet*>::const_iterator it = fleets.begin(); it != fleets.end(); ++it) + m_fleet_state_change_signals[*it] = GG::Connect((*it)->StateChangedSignal, &SystemIcon::FleetStateChanged, this); + SetText(m_system.Name()); // everything is resized by SizeMove @@ -119,6 +124,9 @@ { AttachChild(m_selection_indicator); AttachChild(m_mouseover_indicator); + for (std::map<const Fleet*, boost::signals::connection>::iterator it = m_fleet_state_change_signals.begin(); it != m_fleet_state_change_signals.end(); ++it) + it->second.disconnect(); + m_fleet_state_change_signals.clear(); } const System& SystemIcon::GetSystem() const @@ -319,47 +327,11 @@ PositionSystemName(); } - std::vector<const Fleet*> fleets = m_system.FindObjects<Fleet>(); - for (unsigned int i = 0; i < fleets.size(); ++i) - Connect(fleets[i]->StateChangedSignal, &SystemIcon::CreateFleetButtons, this); - Connect(m_system.FleetAddedSignal, &SystemIcon::FleetCreatedOrDestroyed, this); - Connect(m_system.FleetRemovedSignal, &SystemIcon::FleetCreatedOrDestroyed, this); - - CreateFleetButtons(); + RefreshFleetButtons(); } -void SystemIcon::ClickFleetButton(Fleet* fleet) +void SystemIcon::RefreshFleetButtons() { - for (std::map<int, FleetButton*>::iterator it = m_stationary_fleet_markers.begin(); it != m_stationary_fleet_markers.end(); ++it) { - if (std::find(it->second->Fleets().begin(), it->second->Fleets().end(), fleet) != it->second->Fleets().end()) { - it->second->LClick(GG::Pt(), GG::MOD_KEY_NONE); - return; - } - } - for (std::map<int, FleetButton*>::iterator it = m_moving_fleet_markers.begin(); it != m_moving_fleet_markers.end(); ++it) { - if (std::find(it->second->Fleets().begin(), it->second->Fleets().end(), fleet) != it->second->Fleets().end()) { - it->second->LClick(GG::Pt(), GG::MOD_KEY_NONE); - return; - } - } -} - -void SystemIcon::ShowName() -{ - if (m_name) - m_name->Show(); - m_showing_name = true; -} - -void SystemIcon::HideName() -{ - if (m_name) - m_name->Hide(); - m_showing_name = false; -} - -void SystemIcon::CreateFleetButtons() -{ // clear out old fleet buttons for (std::map<int, FleetButton*>::iterator it = m_stationary_fleet_markers.begin(); it != m_stationary_fleet_markers.end(); ++it) DeleteChild(it->second); @@ -369,7 +341,7 @@ m_moving_fleet_markers.clear(); MapWnd* map_wnd = ClientUI::GetClientUI()->GetMapWnd(); - FleetButton* fb; + FleetButton* fb = 0; // create new fleet buttons for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) { @@ -399,7 +371,7 @@ // create movement lines (after positioning buttons, so lines will originate from button location) for (EmpireManager::const_iterator empire_it = Empires().begin(); empire_it != Empires().end(); ++empire_it) { const int empire_id = empire_it->first; - + std::map<int, FleetButton*>::iterator button_it = m_stationary_fleet_markers.find(empire_id); if (button_it != m_stationary_fleet_markers.end()) map_wnd->SetFleetMovementLine(button_it->second); @@ -410,6 +382,36 @@ } } +void SystemIcon::ClickFleetButton(Fleet* fleet) +{ + for (std::map<int, FleetButton*>::iterator it = m_stationary_fleet_markers.begin(); it != m_stationary_fleet_markers.end(); ++it) { + if (std::find(it->second->Fleets().begin(), it->second->Fleets().end(), fleet) != it->second->Fleets().end()) { + it->second->LClick(GG::Pt(), GG::MOD_KEY_NONE); + return; + } + } + for (std::map<int, FleetButton*>::iterator it = m_moving_fleet_markers.begin(); it != m_moving_fleet_markers.end(); ++it) { + if (std::find(it->second->Fleets().begin(), it->second->Fleets().end(), fleet) != it->second->Fleets().end()) { + it->second->LClick(GG::Pt(), GG::MOD_KEY_NONE); + return; + } + } +} + +void SystemIcon::ShowName() +{ + if (m_name) + m_name->Show(); + m_showing_name = true; +} + +void SystemIcon::HideName() +{ + if (m_name) + m_name->Hide(); + m_showing_name = false; +} + void SystemIcon::DoFleetButtonLayout() { const int FLEETBUTTON_SIZE = FleetButtonSize(); @@ -438,11 +440,6 @@ m_name->MoveTo(GG::Pt((Width() - m_name->Width()) / 2, Height())); } -void SystemIcon::FleetCreatedOrDestroyed(const Fleet&) -{ - CreateFleetButtons(); -} - bool SystemIcon::InWindow(const GG::Pt& pt) const { // Before we blindly check our bounding rect, make sure it doesn't fall in any of our fleets. @@ -458,6 +455,28 @@ return Wnd::InWindow(pt); } +void SystemIcon::FleetInserted(Fleet& fleet) +{ + m_fleet_state_change_signals[&fleet].disconnect(); // in case already present + m_fleet_state_change_signals[&fleet] = GG::Connect(fleet.StateChangedSignal, &SystemIcon::FleetStateChanged, this); + RefreshFleetButtons(); +} + +void SystemIcon::FleetRemoved(Fleet& fleet) +{ + std::map<const Fleet*, boost::signals::connection>::iterator it = m_fleet_state_change_signals.find(&fleet); + if (it != m_fleet_state_change_signals.end()) { + it->second.disconnect(); + m_fleet_state_change_signals.erase(it); + } + RefreshFleetButtons(); +} + +void SystemIcon::FleetStateChanged() +{ + RefreshFleetButtons(); +} + //////////////////////////////////////////////// // SystemIcon::FleetButtonClickedFunctor //////////////////////////////////////////////// Modified: trunk/FreeOrion/UI/SystemIcon.h =================================================================== --- trunk/FreeOrion/UI/SystemIcon.h 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/SystemIcon.h 2008-06-17 03:55:20 UTC (rev 2589) @@ -14,7 +14,9 @@ class TextControl; } -/** A TextControl-like GG::Control that displays the name of a system in the color(s) of the owning empire(s). */ +/** A TextControl-like GG::Control that displays the name of a system in the color(s) of the owning empire(s). + This class is derived from GG::Control because GG::ListBox::Row accepts GG::Control but not GG::Wnd being + added to them. OwnerColoredSystemName are added to the list of systems on the SidePanel. */ class OwnerColoredSystemName : public GG::Control { public: @@ -68,7 +70,9 @@ virtual void MouseLeave(); void SetSelected(bool selected = true); //!< shows/hides the system selection indicator over this system - void Refresh(); //!< sets up the icon's fleet buttons, generates fleet movement lines, etc. Should be called after an icon is attached to the map + void Refresh(); //!< Resets system name text and calls RefreshFleetButtons(). Should be called after an icon is attached to the map + void RefreshFleetButtons(); //!< Recreates all fleet buttons and fleet move lines from them + void DoFleetButtonLayout(); //!< arranges and resizes fleet buttons void ClickFleetButton(Fleet* fleet); //!< clicks the FleetButton containing \a fleet void ShowName(); //!< enables the system name text @@ -91,10 +95,11 @@ GG::Pt NthFleetButtonUpperLeft(int n, bool moving) const; //!< returns upper left point of moving or stationary fleetbutton owned by empire \a n, where n is the position in order of fleetbuttons shown, not empire id int FleetButtonSize() const; //!< returns absolute size of fleetbuttons at current zoom level - void CreateFleetButtons(); + void FleetInserted(Fleet& fleet); + void FleetRemoved(Fleet& fleet); + void FleetStateChanged(); void PositionSystemName(); - void FleetCreatedOrDestroyed(const Fleet&); const System& m_system; //!< the System object associated with this SystemIcon boost::shared_ptr<GG::Texture> m_disc_texture; //!< solid star disc texture @@ -107,9 +112,11 @@ OwnerColoredSystemName* m_name; //!< the control that holds the name of the system bool m_showing_name; //!< is the icon supposed to show its name? - std::map<int, FleetButton*> m_stationary_fleet_markers; //!< the fleet buttons for the fleets that are stationary in the system, indexed by Empire ID of the owner - std::map<int, FleetButton*> m_moving_fleet_markers; //!< the fleet buttons for the fleets that are under orders to move out of the system, indexed by Empire ID of the owner + std::map<int, FleetButton*> m_stationary_fleet_markers; //!< the fleet buttons for the fleets that are stationary in the system, indexed by Empire ID of the owner + std::map<int, FleetButton*> m_moving_fleet_markers; //!< the fleet buttons for the fleets that are under orders to move out of the system, indexed by Empire ID of the owner + std::map<const Fleet*, boost::signals::connection> m_fleet_state_change_signals; + struct FleetButtonClickedFunctor { FleetButtonClickedFunctor(FleetButton& fleet_btn, SystemIcon& system_icon, bool fleet_departing); Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -388,7 +388,7 @@ for (unsigned int i = 0; i < cats.size(); ++i) { m_category_buttons.push_back(new CUIButton(0, 0, 20, UserString(cats[i]))); AttachChild(m_category_buttons.back()); - m_category_buttons.back()->MarkSelectedTechCategoryColor(cats[i]); + m_category_buttons.back()->MarkNotSelected(); } // and one for "ALL" m_category_buttons.push_back(new CUIButton(0, 0, 20, UserString("ALL"))); @@ -404,7 +404,7 @@ AttachChild(m_tech_type_buttons[TT_REFINEMENT]); // colour for (std::map<TechType, CUIButton*>::iterator it = m_tech_type_buttons.begin(); it != m_tech_type_buttons.end(); ++it) - it->second->MarkSelectedGray(); + it->second->MarkNotSelected(); // create a button for each tech status m_tech_status_buttons[TS_UNRESEARCHABLE] = new CUIButton(0, 0, 20, UserString("TECH_WND_STATUS_UNRESEARCHABLE")); @@ -415,14 +415,14 @@ AttachChild(m_tech_status_buttons[TS_COMPLETE]); // colour for (std::map<TechStatus, CUIButton*>::iterator it = m_tech_status_buttons.begin(); it != m_tech_status_buttons.end(); ++it) - it->second->MarkSelectedGray(); + it->second->MarkNotSelected(); // create buttons to switch between tree and list views m_list_view_button = new CUIButton(0, 0, 80, UserString("TECH_WND_LIST_VIEW")); m_list_view_button->MarkNotSelected(); AttachChild(m_list_view_button); m_tree_view_button = new CUIButton(0, 30, 80, UserString("TECH_WND_TREE_VIEW")); - m_tree_view_button->MarkSelectedGray(); + m_tree_view_button->MarkNotSelected(); AttachChild(m_tree_view_button); EnableChildClipping(true); @@ -1795,6 +1795,8 @@ GG::Pt client_size = ClientSize(); m_hscroll->ScrollTo(center_point.x - client_size.x / 2); m_vscroll->ScrollTo(center_point.y - client_size.y / 2); + } else { + Logger().debugStream() << "TechTreeWnd::LayoutPanel::CenterOnTech couldn't centre on " << (tech ? tech->Name() : "Null tech pointer") << " due to lack of such a tech panel"; } } @@ -1923,6 +1925,14 @@ if (keep_position) { m_vscroll->ScrollTo(final_position.y); m_hscroll->ScrollTo(final_position.x); + } else { + // find a tech to centre view on + for (TechManager::iterator it = manager.begin(); it != manager.end(); ++it) { + if (TechVisible(*it)) { + CenterOnTech(*it); + break; + } + } } // ensure that the scrolls stay on top @@ -2348,6 +2358,7 @@ m_tech_tree_controls = new TechTreeControls(1, NAVIGATOR_AND_DETAIL_HEIGHT, m_layout_panel->Width() - ClientUI::ScrollWidth()); m_tech_tree_controls->MoveTo(GG::Pt(1, m_layout_panel->Height() - ClientUI::ScrollWidth() - m_tech_tree_controls->Height())); + AttachChild(m_tech_tree_controls); const std::vector<std::string>& tech_categories = GetTechManager().CategoryNames(); // connect category button clicks to update display @@ -2365,7 +2376,13 @@ GG::Connect(m_tech_tree_controls->m_tree_view_button->ClickedSignal, &TechTreeWnd::ShowTreeView, this); GG::Connect(m_tech_tree_controls->m_list_view_button->ClickedSignal, &TechTreeWnd::ShowListView, this); - AttachChild(m_tech_tree_controls); + ShowAllCategories(); + for (TechStatus status = TechStatus(0); status != NUM_TECH_STATUSES; status = TechStatus(status + 1)) + ShowStatus(status); + for (TechType type = TechType(0); type != NUM_TECH_TYPES; type = TechType(type + 1)) + ShowType(type); + + ShowTreeView(); } double TechTreeWnd::Scale() const @@ -2391,6 +2408,7 @@ void TechTreeWnd::Update() { m_layout_panel->Update(); + m_tech_list->Reset(); } void TechTreeWnd::Clear() @@ -2431,7 +2449,7 @@ m_layout_panel->ShowCategory(*cats_it); m_tech_list->ShowCategory(*cats_it); CUIButton* button = m_tech_tree_controls->m_category_buttons[i]; - button->MarkSelectedTechCategoryColor(cats[i]); + button->MarkSelectedTechCategoryColor(*cats_it); } } @@ -2550,6 +2568,7 @@ DetachChild(m_tech_list); m_tech_tree_controls->m_list_view_button->MarkNotSelected(); m_tech_tree_controls->m_tree_view_button->MarkSelectedGray(); + MoveChildUp(m_tech_tree_controls); } void TechTreeWnd::ShowListView() @@ -2559,6 +2578,7 @@ DetachChild(m_layout_panel); m_tech_tree_controls->m_list_view_button->MarkSelectedGray(); m_tech_tree_controls->m_tree_view_button->MarkNotSelected(); + MoveChildUp(m_tech_tree_controls); } void TechTreeWnd::SetScale(double scale) @@ -2570,13 +2590,13 @@ { // ensure tech is visible const Empire* empire = Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); - + if (empire) + ShowStatus(empire->GetTechStatus(tech->Name())); ShowCategory(tech->Category()); - ShowStatus(empire->GetTechStatus(tech->Name())); ShowType(tech->Type()); // centre on it - m_layout_panel->ShowTech(tech); + //m_layout_panel->ShowTech(tech); // show tech is detail window. not really necessary for centring m_layout_panel->CenterOnTech(tech); } Modified: trunk/FreeOrion/universe/System.cpp =================================================================== --- trunk/FreeOrion/universe/System.cpp 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/universe/System.cpp 2008-06-17 03:55:20 UTC (rev 2589) @@ -16,7 +16,7 @@ -System::System() : +System::System() : UniverseObject(), m_star(INVALID_STAR_TYPE), m_orbits(0) @@ -33,7 +33,7 @@ if (m_orbits < 0) throw std::invalid_argument("System::System : Attempted to create a system \"" + Name() + "\" with fewer than 0 orbits."); } - + System::System(StarType star, int orbits, const StarlaneMap& lanes_and_holes, const std::string& name, double x, double y, const std::set<int>& owners/* = std::set<int>()*/) : UniverseObject(name, x, y, owners), @@ -46,11 +46,10 @@ if (m_orbits < 0) throw std::invalid_argument("System::System : Attempted to create a system \"" + Name() + "\" with fewer than 0 orbits."); } - + System::~System() -{ -} - +{} + StarType System::Star() const { return m_star; @@ -272,7 +271,7 @@ if (Planet* planet = universe_object_cast<Planet*>(obj)) UpdateOwnership(); else if (Fleet* fleet = universe_object_cast<Fleet*>(obj)) - FleetAddedSignal(*fleet); + FleetInsertedSignal(*fleet); StateChangedSignal(); @@ -318,7 +317,8 @@ if (Planet* planet = universe_object_cast<Planet*>(obj)) UpdateOwnership(); else if (Fleet* fleet = universe_object_cast<Fleet*>(obj)) - FleetAddedSignal(*fleet); + FleetRemovedSignal(*fleet); + StateChangedSignal(); return; // assuming object isn't in system twice... Modified: trunk/FreeOrion/universe/System.h =================================================================== --- trunk/FreeOrion/universe/System.h 2008-06-15 16:56:15 UTC (rev 2588) +++ trunk/FreeOrion/universe/System.h 2008-06-17 03:55:20 UTC (rev 2589) @@ -39,9 +39,6 @@ typedef StarlaneMap::iterator lane_iterator; ///< iterator for starlanes and wormholes typedef StarlaneMap::const_iterator const_lane_iterator; ///< const_iterator for starlanes and wormholes - /** \name Signal Types */ //@{ - typedef boost::signal<void (const Fleet&)> FleetSignalType; ///< emitted when a fleet is inserted or removed from a system - /** \name Structors */ //@{ System(); ///< default ctor @@ -106,12 +103,12 @@ const_lane_iterator end_lanes() const; ///< end iterator for all starlanes and wormholes terminating in this system virtual UniverseObject::Visibility - GetVisibility(int empire_id) const; ///< returns the visibility status of this universe object relative to the input empire. + GetVisibility(int empire_id) const; ///< returns the visibility status of this universe object relative to the input empire. virtual UniverseObject* Accept(const UniverseObjectVisitor& visitor) const; - mutable FleetSignalType FleetAddedSignal; ///< returns the fleet added signal object for this System - mutable FleetSignalType FleetRemovedSignal; ///< returns the fleet removed changed signal object for this System + mutable boost::signal<void (Fleet& fleet)> FleetInsertedSignal; ///< fleet is inserted into system + mutable boost::signal<void (Fleet& fleet)> FleetRemovedSignal; ///< fleet is removed from system //@} /** \name Mutators */ //@{ |