From: <geo...@us...> - 2009-01-11 12:25:18
|
Revision: 2734 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2734&view=rev Author: geoffthemedio Date: 2009-01-11 11:33:07 +0000 (Sun, 11 Jan 2009) Log Message: ----------- -Used new EncyclopediaDetailPanel functionality of displaying ShipDesigns to make clicking a finished ship design on the Design screen show the encyclopedia info about that design, as was previously possible for parts and hulls. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2009-01-11 11:01:36 UTC (rev 2733) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2009-01-11 11:33:07 UTC (rev 2734) @@ -704,6 +704,8 @@ DesignSelectedSignal; //!< an existing complete design that is known to this empire was selected (double-clicked) mutable boost::signal<void (const std::string&, const std::vector<std::string>&)> DesignComponentsSelectedSignal; //!< a hull and a set of parts (which may be empty) was selected (double-clicked) + mutable boost::signal<void (const ShipDesign*)> + DesignBrowsedSignal; //!< a completed design was browsed (clicked once) mutable boost::signal<void (const HullType*)> HullBrowsedSignal; //!< a hull was browsed (clicked once) @@ -1020,6 +1022,14 @@ void BasesListBox::PropagateLeftClickSignal(GG::ListBox::iterator it, const GG::Pt& pt) { // determine type of row that was clicked, and emit appropriate signal + CompletedDesignListBoxRow* design_row = dynamic_cast<CompletedDesignListBoxRow*>(*it); + if (design_row) { + int id = design_row->DesignID(); + const ShipDesign* design = GetShipDesign(id); + if (design) + DesignBrowsedSignal(design); + } + HullAndPartsListBoxRow* box_row = dynamic_cast<HullAndPartsListBoxRow*>(*it); if (box_row) { const std::string& hull_name = box_row->Hull(); @@ -1115,6 +1125,8 @@ DesignSelectedSignal; //!< an existing complete design that is known to this empire was selected (double-clicked) mutable boost::signal<void (const std::string&, const std::vector<std::string>&)> DesignComponentsSelectedSignal; //!< a hull and a set of parts (which may be empty) was selected (double-clicked) + mutable boost::signal<void (const ShipDesign*)> + DesignBrowsedSignal; //!< a complete design was browsed (clicked once) mutable boost::signal<void (const HullType*)> HullBrowsedSignal; //!< a hull was browsed (clicked once) private: @@ -1161,6 +1173,7 @@ m_tabs->AddWnd(m_designs_list, UserString("DESIGN_WND_FINISHED_DESIGNS")); m_designs_list->ShowCompletedDesigns(false); GG::Connect(m_designs_list->DesignSelectedSignal, DesignWnd::BaseSelector::DesignSelectedSignal); + GG::Connect(m_designs_list->DesignBrowsedSignal, DesignWnd::BaseSelector::DesignBrowsedSignal); //m_saved_designs_list = new CUIListBox(GG::X0, GG::Y0, GG::X(10), GG::X(10)); m_tabs->AddWnd(new GG::TextControl(GG::X0, GG::Y0, GG::X(30), GG::Y(20), UserString("DESIGN_NO_PART"), @@ -1894,6 +1907,7 @@ AttachChild(m_base_selector); GG::Connect(m_base_selector->DesignSelectedSignal, &MainPanel::SetDesign, m_main_panel); GG::Connect(m_base_selector->DesignComponentsSelectedSignal,&MainPanel::SetDesignComponents, m_main_panel); + GG::Connect(m_base_selector->DesignBrowsedSignal, &EncyclopediaDetailPanel::SetItem, m_detail_panel); GG::Connect(m_base_selector->HullBrowsedSignal, &EncyclopediaDetailPanel::SetItem, m_detail_panel); m_base_selector->MoveTo(GG::Pt()); |
From: <geo...@us...> - 2009-05-12 00:29:45
|
Revision: 3033 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3033&view=rev Author: geoffthemedio Date: 2009-05-12 00:29:44 +0000 (Tue, 12 May 2009) Log Message: ----------- -Increased height of rows in parts list so parts in stacked rows don't overlap -Tweaked default design screen layout Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2009-05-12 00:19:33 UTC (rev 3032) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2009-05-12 00:29:44 UTC (rev 3033) @@ -321,7 +321,7 @@ if (cur_row) Insert(cur_row); cur_col = 0; - cur_row = new PartsListBoxRow(TOTAL_WIDTH, PART_CONTROL_HEIGHT); + cur_row = new PartsListBoxRow(TOTAL_WIDTH, SLOT_CONTROL_HEIGHT + GG::Y(PAD)); } ++cur_col; @@ -1940,9 +1940,9 @@ GG::X most_panels_left = base_selector_width; GG::X most_panels_width = ClientWidth() - most_panels_left; GG::Y detail_top = GG::Y0; - GG::Y detail_height(200); + GG::Y detail_height(180); GG::Y main_top = detail_top + detail_height; - GG::Y part_palette_height(140); + GG::Y part_palette_height(160); GG::Y part_palette_top = ClientHeight() - part_palette_height; GG::Y main_height = part_palette_top - main_top; |
From: <geo...@us...> - 2009-05-12 01:22:20
|
Revision: 3032 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3032&view=rev Author: geoffthemedio Date: 2009-05-12 00:19:33 +0000 (Tue, 12 May 2009) Log Message: ----------- -Added some padding between PartControls in the list of parts on the design screen -Removed solid black background that was behind SlotControls Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2009-05-12 00:09:52 UTC (rev 3031) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2009-05-12 00:19:33 UTC (rev 3032) @@ -31,6 +31,7 @@ const GG::Y PART_CONTROL_HEIGHT(64); const GG::X SLOT_CONTROL_WIDTH(72); const GG::Y SLOT_CONTROL_HEIGHT(72); + const int PAD(3); /** Returns texture with which to render a SlotControl, depending on \a slot_type. */ boost::shared_ptr<GG::Texture> SlotBackgroundTexture(ShipSlotType slot_type) { @@ -42,6 +43,8 @@ return ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "missing.png", true); } + /** Returns background texture with which to render a PartControl, depending on the + * types of slot that the indicated \a part can be put into. */ boost::shared_ptr<GG::Texture> PartBackgroundTexture(const PartType* part) { if (part) { bool ex = part->CanMountInSlotType(SL_EXTERNAL); @@ -265,7 +268,7 @@ if (Visible() && old_size != GG::Wnd::Size()) { // determine how many columns can fit in the box now... const GG::X TOTAL_WIDTH = Size().x - ClientUI::ScrollWidth(); - const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / SLOT_CONTROL_WIDTH)); + const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / (SLOT_CONTROL_WIDTH + GG::X(PAD)))); if (NUM_COLUMNS != m_previous_num_columns) Populate(); @@ -274,7 +277,7 @@ void PartsListBox::Populate() { const GG::X TOTAL_WIDTH = ClientWidth() - ClientUI::ScrollWidth(); - const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / SLOT_CONTROL_WIDTH)); + const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / (SLOT_CONTROL_WIDTH + GG::X(PAD)))); const int empire_id = HumanClientApp::GetApp()->EmpireID(); const Empire* empire = Empires().Lookup(empire_id); @@ -1510,17 +1513,9 @@ m_part_control->Hide(); } -void SlotControl::Render() { - GG::Pt ul = UpperLeft(); - GG::Pt lr = LowerRight(); - // TODO: Render differently depending on ShipSlotType +void SlotControl::Render() +{} - if (m_highlighted) - GG::FlatRectangle(ul, lr, ClientUI::WndColor(), GG::CLR_WHITE, 2); - else - GG::FlatRectangle(ul, lr, ClientUI::WndColor(), ClientUI::WndOuterBorderColor(), 1); -} - void SlotControl::Highlight(bool actually) { m_highlighted = actually; } |
From: <geo...@us...> - 2010-07-23 00:12:43
|
Revision: 3697 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3697&view=rev Author: geoffthemedio Date: 2010-07-23 00:12:37 +0000 (Fri, 23 Jul 2010) Log Message: ----------- Modified PartPalette on the Design screen to not show part class buttons if no parts exists with that class. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-22 19:39:51 UTC (rev 3696) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-23 00:12:37 UTC (rev 3697) @@ -497,8 +497,23 @@ GG::Connect(m_parts_list->PartTypeClickedSignal, PartTypeClickedSignal); GG::Connect(m_parts_list->PartTypeDoubleClickedSignal, PartTypeDoubleClickedSignal); + const PartTypeManager& part_manager = GetPartTypeManager(); + // class buttons for (ShipPartClass part_class = ShipPartClass(0); part_class != NUM_SHIP_PART_CLASSES; part_class = ShipPartClass(part_class + 1)) { + // are there any parts of this class? + bool part_of_this_class_exists = false; + for (PartTypeManager::iterator part_it = part_manager.begin(); part_it != part_manager.end(); ++part_it) { + if (const PartType* part = part_it->second) { + if (part->Class() == part_class) { + part_of_this_class_exists = true; + break; + } + } + } + if (!part_of_this_class_exists) + continue; + m_class_buttons[part_class] = (new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString(boost::lexical_cast<std::string>(part_class)))); AttachChild(m_class_buttons[part_class]); GG::Connect(m_class_buttons[part_class]->ClickedSignal, |
From: <geo...@us...> - 2010-07-23 07:46:20
|
Revision: 3699 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3699&view=rev Author: geoffthemedio Date: 2010-07-23 07:46:13 +0000 (Fri, 23 Jul 2010) Log Message: ----------- Made clicking on the background of the design screen main panel show the current design or incomplete design in the encyclopedia detail panel. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-23 06:57:12 UTC (rev 3698) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-23 07:46:13 UTC (rev 3699) @@ -1612,9 +1612,12 @@ const std::string& DesignDescription() const; //!< returns description currently entered for design boost::shared_ptr<const ShipDesign> GetIncompleteDesign() const;//!< returns a pointer to the design currently being modified (if any). may return an empty pointer if not currently modifying a design. + int GetCompleteDesignID() const;//!< returns ID of complete design currently being shown in this panel. returns ShipDesign::INVALID_DESIGN_ID if not showing a complete design //@} /** \name Mutators */ //@{ + virtual void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); + virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); void Sanitize(); @@ -1642,6 +1645,7 @@ mutable boost::signal<void ()> DesignChangedSignal; //!< emitted when the design is changed (by adding or removing parts, not name or description changes) mutable boost::signal<void (const PartType*)> PartTypeClickedSignal; //!< propegates signals from contained SlotControls that signal that a part has been clicked mutable boost::signal<void ()> DesignConfirmedSignal; //!< emitted when the user clicks the m_confirm_button to add the new design to the player's empire + mutable boost::signal<void (int)> CompleteDesignClickedSignal;//!< emitted when the user clicks on the background of this main panel and a completed design is showing private: // disambiguate overloaded SetPart function, because otherwise boost::bind wouldn't be able to tell them apart @@ -1655,6 +1659,7 @@ const HullType* m_hull; std::vector<SlotControl*> m_slots; + int m_complete_design_id; mutable boost::shared_ptr<ShipDesign> m_incomplete_design; GG::StaticGraphic* m_background_image; @@ -1673,6 +1678,7 @@ CUIWnd(UserString("DESIGN_WND_MAIN_PANEL_TITLE"), GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::DRAGABLE | GG::RESIZABLE), m_hull(0), m_slots(), + m_complete_design_id(ShipDesign::INVALID_DESIGN_ID), m_incomplete_design(), m_background_image(0), m_design_name_label(0), @@ -1758,6 +1764,19 @@ return m_incomplete_design; } +int DesignWnd::MainPanel::GetCompleteDesignID() const +{ + return m_complete_design_id; +} + +void DesignWnd::MainPanel::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) +{ + if (m_incomplete_design.get()) + DesignChangedSignal(); + else if (m_complete_design_id != ShipDesign::INVALID_DESIGN_ID) + CompleteDesignClickedSignal(m_complete_design_id); +} + void DesignWnd::MainPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { CUIWnd::SizeMove(ul, lr); DoLayout(); @@ -1831,11 +1850,15 @@ } void DesignWnd::MainPanel::SetDesign(const ShipDesign* ship_design) { + m_incomplete_design.reset(); + if (!ship_design) { SetHull(0); return; } + m_complete_design_id = ship_design->ID(); + m_design_name->SetText(ship_design->Name()); m_design_description->SetText(ship_design->Description()); @@ -1973,10 +1996,12 @@ } void DesignWnd::MainPanel::DesignChanged() { + m_complete_design_id = ShipDesign::INVALID_DESIGN_ID; if (m_hull && !(m_hull->Name()).empty() && ShipDesign::ValidDesign(m_hull->Name(), Parts())) m_confirm_button->Disable(false); else m_confirm_button->Disable(true); + RefreshIncompleteDesign(); } void DesignWnd::MainPanel::RefreshIncompleteDesign() const @@ -2052,6 +2077,7 @@ m_detail_panel, boost::bind(&DesignWnd::MainPanel::GetIncompleteDesign, m_main_panel))); + GG::Connect(m_main_panel->CompleteDesignClickedSignal, &EncyclopediaDetailPanel::SetDesign,m_detail_panel); m_main_panel->MoveTo(GG::Pt(most_panels_left, main_top)); m_part_palette = new PartPalette(most_panels_width, part_palette_height); |
From: <geo...@us...> - 2010-07-23 22:45:00
|
Revision: 3700 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=3700&view=rev Author: geoffthemedio Date: 2010-07-23 22:44:54 +0000 (Fri, 23 Jul 2010) Log Message: ----------- Fixed completed ship design list available / unavailable filters, which I broke in a recent commit. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-23 07:46:13 UTC (rev 3699) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2010-07-23 22:44:54 UTC (rev 3700) @@ -926,7 +926,7 @@ { GG::Connect(DoubleClickedSignal, &BasesListBox::BaseDoubleClicked, this); GG::Connect(LeftClickedSignal, &BasesListBox::BaseLeftClicked, this); - GG::Connect(RightClickedSignal, &BasesListBox::BaseRightClicked, this); + GG::Connect(RightClickedSignal, &BasesListBox::BaseRightClicked, this); } const std::pair<bool, bool>& BasesListBox::GetAvailabilitiesShown() const { @@ -1067,17 +1067,23 @@ // add rows for designs this empire is keeping for (Empire::ShipDesignItr it = empire->ShipDesignBegin(); it != empire->ShipDesignEnd(); ++it) { int design_id = *it; - CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); - Insert(row); - row->Resize(row_size); + bool available = empire->ShipDesignAvailable(design_id); + if ((available && showing_available) || (!available && showing_unavailable)) { + CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); + Insert(row); + row->Resize(row_size); + } } } else { // add all known / existing designs for (Universe::ship_design_iterator it = universe.beginShipDesigns(); it != universe.endShipDesigns(); ++it) { int design_id = it->first; - CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); - Insert(row); - row->Resize(row_size); + bool available = empire->ShipDesignAvailable(design_id); + if ((available && showing_available) || (!available && showing_unavailable)) { + CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); + Insert(row); + row->Resize(row_size); + } } } } @@ -1117,24 +1123,24 @@ Logger().debugStream() << "BasesListBox::BaseRightClicked on design id : " << design_id; - // create popup menu with a commands in it - GG::MenuItem menu_contents; - menu_contents.next_level.push_back(GG::MenuItem(UserString("DESIGN_DELETE"), 1, false, false)); - GG::PopupMenu popup(pt.x, pt.y, ClientUI::GetFont(), menu_contents, ClientUI::TextColor()); - if (popup.Run()) { - switch (popup.MenuID()) { - - case 1: { // delete design + // create popup menu with a commands in it + GG::MenuItem menu_contents; + menu_contents.next_level.push_back(GG::MenuItem(UserString("DESIGN_DELETE"), 1, false, false)); + GG::PopupMenu popup(pt.x, pt.y, ClientUI::GetFont(), menu_contents, ClientUI::TextColor()); + if (popup.Run()) { + switch (popup.MenuID()) { + + case 1: { // delete design HumanClientApp::GetApp()->Orders().IssueOrder( OrderPtr(new ShipDesignOrder(empire_id, design_id, true))); - break; - } - - default: - break; - } - } - } + break; + } + + default: + break; + } + } + } } void BasesListBox::BaseDoubleClicked(GG::ListBox::iterator it) { @@ -1616,7 +1622,7 @@ //@} /** \name Mutators */ //@{ - virtual void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); + virtual void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); void Sanitize(); @@ -1769,12 +1775,12 @@ return m_complete_design_id; } -void DesignWnd::MainPanel::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) -{ - if (m_incomplete_design.get()) - DesignChangedSignal(); - else if (m_complete_design_id != ShipDesign::INVALID_DESIGN_ID) - CompleteDesignClickedSignal(m_complete_design_id); +void DesignWnd::MainPanel::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) +{ + if (m_incomplete_design.get()) + DesignChangedSignal(); + else if (m_complete_design_id != ShipDesign::INVALID_DESIGN_ID) + CompleteDesignClickedSignal(m_complete_design_id); } void DesignWnd::MainPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { |
From: <geo...@us...> - 2011-07-04 03:23:06
|
Revision: 4017 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4017&view=rev Author: geoffthemedio Date: 2011-07-04 03:23:00 +0000 (Mon, 04 Jul 2011) Log Message: ----------- -Fixed crash when attempting to view completed designs on design screen as an observer. -Made parts be shown on design screen as an observer. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2011-07-02 21:56:36 UTC (rev 4016) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2011-07-04 03:23:00 UTC (rev 4017) @@ -300,10 +300,7 @@ const GG::X TOTAL_WIDTH = ClientWidth() - ClientUI::ScrollWidth(); const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / (SLOT_CONTROL_WIDTH + GG::X(PAD)))); - const int empire_id = HumanClientApp::GetApp()->EmpireID(); - const Empire* empire = Empires().Lookup(empire_id); - if (!empire) - return; + const Empire* empire = Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); // may be 0 const PartTypeManager& manager = GetPartTypeManager(); int cur_col = NUM_COLUMNS; @@ -331,7 +328,7 @@ if (!can_mount_in_shown_slot_type) continue; - bool part_available = empire->ShipPartAvailable(part->Name()); + bool part_available = empire ? empire->ShipPartAvailable(part->Name()) : true; if (!(part_available && m_availabilities_shown.first) && !(!part_available && m_availabilities_shown.second)) continue; // part is available but available parts shouldn't be shown, or part isn't available and not available parts shouldn't be shown @@ -1074,16 +1071,13 @@ row->Resize(row_size); } } - } else { + } else if (showing_available) { // add all known / existing designs for (Universe::ship_design_iterator it = universe.beginShipDesigns(); it != universe.endShipDesigns(); ++it) { int design_id = it->first; - bool available = empire->ShipDesignAvailable(design_id); - if ((available && showing_available) || (!available && showing_unavailable)) { - CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); - Insert(row); - row->Resize(row_size); - } + CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); + Insert(row); + row->Resize(row_size); } } } |
From: <geo...@us...> - 2011-07-13 08:27:10
|
Revision: 4038 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4038&view=rev Author: geoffthemedio Date: 2011-07-13 08:27:04 +0000 (Wed, 13 Jul 2011) Log Message: ----------- Disabled design screen confirm design button for observers. Wouldn't do anything anyway... Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2011-07-13 08:16:11 UTC (rev 4037) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2011-07-13 08:27:04 UTC (rev 4038) @@ -1998,7 +1998,8 @@ void DesignWnd::MainPanel::DesignChanged() { m_complete_design_id = ShipDesign::INVALID_DESIGN_ID; - if (m_hull && !(m_hull->Name()).empty() && ShipDesign::ValidDesign(m_hull->Name(), Parts())) + int client_empire_id = HumanClientApp::GetApp()->EmpireID(); + if (client_empire_id != ALL_EMPIRES && m_hull && !(m_hull->Name()).empty() && ShipDesign::ValidDesign(m_hull->Name(), Parts())) m_confirm_button->Disable(false); else m_confirm_button->Disable(true); |
From: <geo...@us...> - 2011-10-02 07:36:44
|
Revision: 4329 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=4329&view=rev Author: geoffthemedio Date: 2011-10-02 07:36:38 +0000 (Sun, 02 Oct 2011) Log Message: ----------- Made design wnd not show unproducible parts on the parts list or unproducible hulls or designs on the hull / design list. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2011-10-02 07:32:37 UTC (rev 4328) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2011-10-02 07:36:38 UTC (rev 4329) @@ -312,6 +312,8 @@ // loop through all possible parts for (PartTypeManager::iterator part_it = manager.begin(); part_it != manager.end(); ++part_it) { const PartType* part = part_it->second; + if (!part->Producible()) + continue; // check whether this part should be shown in list ShipPartClass part_class = part->Class(); @@ -994,6 +996,10 @@ for (HullTypeManager::iterator it = manager.begin(); it != manager.end(); ++it) { const std::string& hull_name = it->first; + const HullType* hull_type = manager.GetHullType(hull_name); + if (!hull_type || !hull_type->Producible()) + continue; + // add or retain in list 1) all hulls if no empire is specified, or // 2) hulls of appropriate availablility for set empire if (!empire || @@ -1065,6 +1071,9 @@ for (Empire::ShipDesignItr it = empire->ShipDesignBegin(); it != empire->ShipDesignEnd(); ++it) { int design_id = *it; bool available = empire->ShipDesignAvailable(design_id); + const ShipDesign* design = GetShipDesign(design_id); + if (!design || !design->Producible()) + continue; if ((available && showing_available) || (!available && showing_unavailable)) { CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); Insert(row); @@ -1075,6 +1084,9 @@ // add all known / existing designs for (Universe::ship_design_iterator it = universe.beginShipDesigns(); it != universe.endShipDesigns(); ++it) { int design_id = it->first; + const ShipDesign* design = it->second; + if (!design->Producible()) + continue; CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, design_id); Insert(row); row->Resize(row_size); @@ -1355,7 +1367,6 @@ } } - void DesignWnd::BaseSelector::DoLayout() { const GG::X LEFT_PAD(5); const GG::Y TOP_PAD(2); |
From: <geo...@us...> - 2012-07-18 05:19:01
|
Revision: 5034 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5034&view=rev Author: geoffthemedio Date: 2012-07-18 05:18:55 +0000 (Wed, 18 Jul 2012) Log Message: ----------- Hid/removed slot type and availability buttons to simplify design screen parts palette interface. Now all (and just) available parts are shown. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2012-07-18 05:17:10 UTC (rev 5033) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2012-07-18 05:18:55 UTC (rev 5034) @@ -515,32 +515,32 @@ boost::bind(&DesignWnd::PartPalette::ToggleClass, this, part_class, true)); } - // slot type buttons - for (ShipSlotType slot_type = ShipSlotType(0); slot_type != NUM_SHIP_SLOT_TYPES; slot_type = ShipSlotType(slot_type + 1)) { - m_slot_type_buttons[slot_type] = (new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString(boost::lexical_cast<std::string>(slot_type)))); - AttachChild(m_slot_type_buttons[slot_type]); - GG::Connect(m_slot_type_buttons[slot_type]->ClickedSignal, - boost::bind(&DesignWnd::PartPalette::ToggleSlotType, this, slot_type, true)); - } + //// slot type buttons + //for (ShipSlotType slot_type = ShipSlotType(0); slot_type != NUM_SHIP_SLOT_TYPES; slot_type = ShipSlotType(slot_type + 1)) { + // m_slot_type_buttons[slot_type] = (new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString(boost::lexical_cast<std::string>(slot_type)))); + // AttachChild(m_slot_type_buttons[slot_type]); + // GG::Connect(m_slot_type_buttons[slot_type]->ClickedSignal, + // boost::bind(&DesignWnd::PartPalette::ToggleSlotType, this, slot_type, true)); + //} - // availability buttons - CUIButton* button = new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString("PRODUCTION_WND_AVAILABILITY_AVAILABLE")); - m_availability_buttons.first = button; - AttachChild(button); - GG::Connect(button->ClickedSignal, - boost::bind(&DesignWnd::PartPalette::ToggleAvailability, this, true, true)); - button = new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString("PRODUCTION_WND_AVAILABILITY_UNAVAILABLE")); - m_availability_buttons.second = button; - AttachChild(button); - GG::Connect(button->ClickedSignal, - boost::bind(&DesignWnd::PartPalette::ToggleAvailability, this, false, true)); + //// availability buttons + //CUIButton* button = new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString("PRODUCTION_WND_AVAILABILITY_AVAILABLE")); + //m_availability_buttons.first = button; + //AttachChild(button); + //GG::Connect(button->ClickedSignal, + // boost::bind(&DesignWnd::PartPalette::ToggleAvailability, this, true, true)); + //button = new CUIButton(GG::X(10), GG::Y(10), GG::X(10), UserString("PRODUCTION_WND_AVAILABILITY_UNAVAILABLE")); + //m_availability_buttons.second = button; + //AttachChild(button); + //GG::Connect(button->ClickedSignal, + // boost::bind(&DesignWnd::PartPalette::ToggleAvailability, this, false, true)); // default to showing nothing ShowAllClasses(false); ShowAvailability(true, false); for (ShipSlotType slot_type = ShipSlotType(0); slot_type != NUM_SHIP_SLOT_TYPES; slot_type = ShipSlotType(slot_type + 1)) { m_parts_list->ShowSlotType(slot_type, false); - m_slot_type_buttons[slot_type]->MarkSelectedGray(); + //m_slot_type_buttons[slot_type]->MarkSelectedGray(); } DoLayout(); } @@ -564,14 +564,14 @@ const int MAX_BUTTONS_PER_ROW = std::max(Value(USABLE_WIDTH / (MIN_BUTTON_WIDTH + BUTTON_SEPARATION)), 1); const int NUM_CLASS_BUTTONS = std::max(1, static_cast<int>(m_class_buttons.size())); - const int NUM_SLOT_TYPE_BUTTONS = std::max(1, static_cast<int>(m_slot_type_buttons.size())); - const int NUM_AVAILABILITY_BUTTONS = 2; + const int NUM_SLOT_TYPE_BUTTONS = 0;//std::max(1, static_cast<int>(m_slot_type_buttons.size())); + const int NUM_AVAILABILITY_BUTTONS = 0;//2; const int NUM_NON_CLASS_BUTTONS = NUM_SLOT_TYPE_BUTTONS + NUM_AVAILABILITY_BUTTONS; // determine whether to put non-class buttons (availability and slot type) in one column or two. // -> if class buttons fill up fewer rows than (the non-class buttons in one column), split the // non-class buttons into two columns - int num_non_class_buttons_per_row = 1; + int num_non_class_buttons_per_row = 0;//1; if (NUM_CLASS_BUTTONS < NUM_NON_CLASS_BUTTONS*(MAX_BUTTONS_PER_ROW - num_non_class_buttons_per_row)) num_non_class_buttons_per_row = 2; @@ -604,28 +604,28 @@ // be the case given how num_non_class_buttons_per_row is determined m_parts_list->SizeMove(GG::Pt(GG::X0, BUTTON_EDGE_PAD + ROW_OFFSET*(row + 1)), ClientSize() - GG::Pt(GG::X(BUTTON_SEPARATION), GG::Y(BUTTON_SEPARATION))); - // place slot type buttons - col = NUM_CLASS_BUTTONS_PER_ROW; - row = 0; - for (std::map<ShipSlotType, CUIButton*>::iterator it = m_slot_type_buttons.begin(); it != m_slot_type_buttons.end(); ++it) { - GG::Pt ul(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); - GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); - it->second->SizeMove(ul, lr); - ++row; - } + //// place slot type buttons + //col = NUM_CLASS_BUTTONS_PER_ROW; + //row = 0; + //for (std::map<ShipSlotType, CUIButton*>::iterator it = m_slot_type_buttons.begin(); it != m_slot_type_buttons.end(); ++it) { + // GG::Pt ul(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); + // GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + // it->second->SizeMove(ul, lr); + // ++row; + //} - // place availability buttons - if (num_non_class_buttons_per_row > 1) { - ++col; - row = 0; - } - GG::Pt ul(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); - GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); - m_availability_buttons.first->SizeMove(ul, lr); - ++row; - ul = GG::Pt(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); - lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); - m_availability_buttons.second->SizeMove(ul, lr); + //// place availability buttons + //if (num_non_class_buttons_per_row > 1) { + // ++col; + // row = 0; + //} + //GG::Pt ul(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); + //GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + //m_availability_buttons.first->SizeMove(ul, lr); + //++row; + //ul = GG::Pt(BUTTON_EDGE_PAD + col*COL_OFFSET, BUTTON_EDGE_PAD + row*ROW_OFFSET); + //lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + //m_availability_buttons.second->SizeMove(ul, lr); } void DesignWnd::PartPalette::ShowClass(ShipPartClass part_class, bool refresh_list) { @@ -682,7 +682,7 @@ void DesignWnd::PartPalette::ShowSlotType(ShipSlotType slot_type, bool refresh_list) { if (slot_type >= ShipSlotType(0) && slot_type < NUM_SHIP_SLOT_TYPES) { m_parts_list->ShowSlotType(slot_type, refresh_list); - m_slot_type_buttons[slot_type]->MarkSelectedGray(); + //m_slot_type_buttons[slot_type]->MarkSelectedGray(); } else { throw std::invalid_argument("PartPalette::ShowSlotType was passed an invalid ShipSlotType"); } @@ -691,7 +691,7 @@ void DesignWnd::PartPalette::HideSlotType(ShipSlotType slot_type, bool refresh_list) { if (slot_type >= ShipSlotType(0) && slot_type < NUM_SHIP_SLOT_TYPES) { m_parts_list->HideSlotType(slot_type, refresh_list); - m_slot_type_buttons[slot_type]->MarkNotSelected(); + //m_slot_type_buttons[slot_type]->MarkNotSelected(); } else { throw std::invalid_argument("PartPalette::HideSlotType was passed an invalid ShipSlotType"); } @@ -711,18 +711,18 @@ void DesignWnd::PartPalette::ShowAvailability(bool available, bool refresh_list) { m_parts_list->ShowAvailability(available, refresh_list); - if (available) - m_availability_buttons.first->MarkSelectedGray(); - else - m_availability_buttons.second->MarkSelectedGray(); + //if (available) + // m_availability_buttons.first->MarkSelectedGray(); + //else + // m_availability_buttons.second->MarkSelectedGray(); } void DesignWnd::PartPalette::HideAvailability(bool available, bool refresh_list) { m_parts_list->HideAvailability(available, refresh_list); - if (available) - m_availability_buttons.first->MarkNotSelected(); - else - m_availability_buttons.second->MarkNotSelected(); + //if (available) + // m_availability_buttons.first->MarkNotSelected(); + //else + // m_availability_buttons.second->MarkNotSelected(); } void DesignWnd::PartPalette::ToggleAvailability(bool available, bool refresh_list) { |
From: <geo...@us...> - 2012-09-04 18:41:24
|
Revision: 5206 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5206&view=rev Author: geoffthemedio Date: 2012-09-04 18:41:18 +0000 (Tue, 04 Sep 2012) Log Message: ----------- Minor tweak to DesignWnd::MainPanel::LClick which seems to help with an issue I was having where the window couldn't be moved after it was resized once. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2012-09-04 04:40:29 UTC (rev 5205) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2012-09-04 18:41:18 UTC (rev 5206) @@ -1781,6 +1781,7 @@ DesignChangedSignal(); else if (m_complete_design_id != ShipDesign::INVALID_DESIGN_ID) CompleteDesignClickedSignal(m_complete_design_id); + CUIWnd::LClick(pt, mod_keys); } void DesignWnd::MainPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { |
From: <dil...@us...> - 2013-04-14 05:56:58
|
Revision: 5981 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5981&view=rev Author: dilvish-fo Date: 2013-04-14 05:56:49 +0000 (Sun, 14 Apr 2013) Log Message: ----------- presentation of Parts in PartsListBox is pared to eliminate display of effectively superceded parts Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2013-04-12 20:54:14 UTC (rev 5980) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2013-04-14 05:56:49 UTC (rev 5981) @@ -60,6 +60,39 @@ } return ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "missing.png", true); } + + double getMainStat(ShipPartClass spclass, PartTypeStats spstats) { + switch (spclass) { + case PC_SHORT_RANGE: + case PC_POINT_DEFENSE: { + const DirectFireStats& stats = boost::get<DirectFireStats>(spstats); + return stats.m_damage; //stats.m_ROF stats.m_range + break; + } + case PC_MISSILES: { + const LRStats& stats = boost::get<LRStats>(spstats); + return stats.m_damage; //stats.m_ROF stats.m_range stats.m_speed stats.m_stealth stats.m_structure stats.m_capacity + break; + } + case PC_FIGHTERS: { + const FighterStats& stats = boost::get<FighterStats>(spstats); + return stats.m_anti_ship_damage; //stats.m_anti_fighter_damage stats.m_launch_rate stats.m_fighter_weapon_range stats.m_speed stats.m_stealth stats.m_structure stats.m_detection stats.m_capacity + break; + } + case PC_SHIELD: + case PC_DETECTION: + case PC_STEALTH: + case PC_FUEL: + case PC_ARMOUR: + case PC_BATTLE_SPEED: + case PC_STARLANE_SPEED: + return boost::get<float>(spstats); + break; + default: + return 0; + } + } + typedef std::map<std::pair<ShipPartClass,ShipSlotType>, std::set<const PartType* > > partGroupsType; } ////////////////////////////////////////////////// @@ -142,6 +175,7 @@ void PartControl::LDoubleClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { DoubleClickedSignal(m_part); } + ////////////////////////////////////////////////// // PartsListBox // ////////////////////////////////////////////////// @@ -167,6 +201,8 @@ /** \name Mutators */ //@{ virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); + partGroupsType GroupAvailableDisplayableParts(const Empire* empire); + void CullSuperfluousParts(std::set<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id); void Populate(); void ShowClass(ShipPartClass part_class, bool refresh_list = true); @@ -272,21 +308,10 @@ } } -void PartsListBox::Populate() { - ScopedTimer scoped_timer("PartsListBox::Populate"); - const GG::X TOTAL_WIDTH = ClientWidth() - ClientUI::ScrollWidth(); - const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / (SLOT_CONTROL_WIDTH + GG::X(PAD)))); - - const Empire* empire = Empires().Lookup(HumanClientApp::GetApp()->EmpireID()); // may be 0 +partGroupsType PartsListBox::GroupAvailableDisplayableParts(const Empire* empire) { const PartTypeManager& manager = GetPartTypeManager(); - - int cur_col = NUM_COLUMNS; - PartsListBoxRow* cur_row = 0; - - // remove parts currently in rows of listbox - Clear(); - + partGroupsType partGroups; // loop through all possible parts for (PartTypeManager::iterator part_it = manager.begin(); part_it != manager.end(); ++part_it) { const PartType* part = part_it->second; @@ -298,36 +323,122 @@ if (m_part_classes_shown.find(part_class) == m_part_classes_shown.end()) continue; // part of this class is not requested to be shown - bool can_mount_in_shown_slot_type = false; + bool part_available = empire ? empire->ShipPartAvailable(part->Name()) : true; + if (!(part_available && m_availabilities_shown.first) && !(!part_available && m_availabilities_shown.second)) + continue; // part is available but available parts shouldn't be shown, or part isn't available and not available parts shouldn't be shown + for (std::set<ShipSlotType>::const_iterator it = m_slot_types_shown.begin(); it != m_slot_types_shown.end(); ++it) { if (part->CanMountInSlotType(*it)) { - can_mount_in_shown_slot_type = true; + partGroups[ std::make_pair<ShipPartClass,ShipSlotType>(part_class, *it) ].insert( part ); + } + } + } + return partGroups; +} + +void PartsListBox::CullSuperfluousParts(std::set<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id) { + /// This is not merely a check for obsolescence; see PartsListBox::Populate for more info + std::set<const PartType* >::reverse_iterator delete_it = thisGroup.rend(); + for (std::set<const PartType* >::reverse_iterator part_it = thisGroup.rbegin(); part_it != thisGroup.rend(); ++part_it) { + if (delete_it != thisGroup.rend()) { + thisGroup.erase( --delete_it.base()); + delete_it = thisGroup.rend(); + } + const PartType* checkPart = *part_it; + for (std::set<const PartType* >::iterator check_it = thisGroup.begin(); check_it != thisGroup.end(); ++check_it ) { + const PartType* refPart = *check_it; + // if thisPart is superior to a part previously put into 'keepers' flag that keeper as pared, via keepNoMore + if ( (getMainStat(pclass, checkPart->Stats()) < getMainStat(pclass, refPart->Stats()) ) && + ( checkPart->ProductionCost(empire_id, loc_id) >= refPart->ProductionCost(empire_id, loc_id) ) && + ( checkPart->ProductionTime(empire_id, loc_id) >= refPart->ProductionTime(empire_id, loc_id) ) ) { + delete_it = std::find(thisGroup.rbegin(), thisGroup.rend(), checkPart); break; } } - if (!can_mount_in_shown_slot_type) - continue; + } + if (delete_it != thisGroup.rend()) + thisGroup.erase( --delete_it.base()); +} - bool part_available = empire ? empire->ShipPartAvailable(part->Name()) : true; - if (!(part_available && m_availabilities_shown.first) && !(!part_available && m_availabilities_shown.second)) - continue; // part is available but available parts shouldn't be shown, or part isn't available and not available parts shouldn't be shown +void PartsListBox::Populate() { + ScopedTimer scoped_timer("PartsListBox::Populate"); - // part should be shown in list. + const GG::X TOTAL_WIDTH = ClientWidth() - ClientUI::ScrollWidth(); + const int NUM_COLUMNS = std::max(1, Value(TOTAL_WIDTH / (SLOT_CONTROL_WIDTH + GG::X(PAD)))); - // check if current row is full, and make a new row if necessary - if (cur_col >= NUM_COLUMNS) { - if (cur_row) - Insert(cur_row); - cur_col = 0; - cur_row = new PartsListBoxRow(TOTAL_WIDTH, SLOT_CONTROL_HEIGHT + GG::Y(PAD)); + int empire_id = HumanClientApp::GetApp()->EmpireID(); + const Empire* empire = Empires().Lookup(empire_id); // may be 0 + + int cur_col = NUM_COLUMNS; + PartsListBoxRow* cur_row = 0; + + // remove parts currently in rows of listbox + Clear(); + + /** + * The Parts are first filtered for availability to this empire and according to the current selections of which part classes + * are to be displayed. Then, in order to eliminate presentation of clearly suboptimal parts, such as Mass Driver I + * when Mass Driver II is available at the same cost & build time, some orgnization, paring and sorting of parts is done. + * The previously filtered parts are grouped into sets according to (class, slot); only parts within the same set may + * suppress display of each other. Within each group, parts are compared and pared for display. The paring is (currently) done + * on the basis of main stat, construction cost, and construction time. If two parts have the same class and slot, and one has + * a lower main stat but also a lower cost, they will both be presented; if one has a higher main stat and is at least as good + * on cost and time, it will suppress the other. + */ + + /// filter parts by availability and current designation of classes for display; group according to (class, slot) + partGroupsType partGroups = GroupAvailableDisplayableParts(empire); + + // get empire id and location to use for cost and time comparisons + int loc_id = INVALID_OBJECT_ID; + if (empire) { + const UniverseObject* location = GetUniverseObject(empire->CapitalID()); + loc_id = location ? location->ID() : INVALID_OBJECT_ID; + } + + // if the empire id is not ALL_EMPIRES, and unavailable parts are not to be displayed, cull Parts for display + if ( empire_id != ALL_EMPIRES && !m_availabilities_shown.second ) { + for (partGroupsType::iterator group_it=partGroups.begin(); group_it != partGroups.end(); group_it++) { + ShipPartClass pclass = group_it->first.first; + // currently, only cull ShortRange Weapons, though the culling code is more broadly applicable. + if ( pclass == PC_SHORT_RANGE ) + CullSuperfluousParts(group_it->second, pclass, empire_id, loc_id); } - ++cur_col; + } + + // now sort the parts within each group according to main stat, via weak sorting in a multimap + // also, if a part was in multiple groups due to being compatible with multiple slot types, ensure it is only displayed once + std::set<const PartType* > alreadyAdded; + for (partGroupsType::iterator group_it=partGroups.begin(); group_it != partGroups.end(); group_it++) { + std::set<const PartType* > thisGroup = group_it->second; + ShipPartClass pclass = group_it->first.first; + std::multimap<double, const PartType*> sortedGroup; + for (std::set<const PartType* >::iterator part_it = thisGroup.begin(); part_it != thisGroup.end(); ++part_it) { + const PartType* part = *part_it; + if (alreadyAdded.find(part) != alreadyAdded.end()) + continue; + alreadyAdded.insert(part); + sortedGroup.insert(std::make_pair<double, const PartType*>(getMainStat(pclass, part->Stats()), part)); + } - // make new part control and add to row - PartControl* control = new PartControl(part); - GG::Connect(control->ClickedSignal, PartsListBox::PartTypeClickedSignal); - GG::Connect(control->DoubleClickedSignal, PartsListBox::PartTypeDoubleClickedSignal); - cur_row->push_back(control); + // take the sorted parts and make UI elements (technically rows) for the PartsListBox + for (std::multimap<double, const PartType*>::iterator sorted_it = sortedGroup.begin(); sorted_it != sortedGroup.end(); ++sorted_it) { + const PartType* part = sorted_it->second; + // check if current row is full, and make a new row if necessary + if (cur_col >= NUM_COLUMNS) { + if (cur_row) + Insert(cur_row); + cur_col = 0; + cur_row = new PartsListBoxRow(TOTAL_WIDTH, SLOT_CONTROL_HEIGHT + GG::Y(PAD)); + } + ++cur_col; + + // make new part control and add to row + PartControl* control = new PartControl(part); + GG::Connect(control->ClickedSignal, PartsListBox::PartTypeClickedSignal); + GG::Connect(control->DoubleClickedSignal, PartsListBox::PartTypeDoubleClickedSignal); + cur_row->push_back(control); + } } // add any incomplete rows if (cur_row) @@ -2109,7 +2220,7 @@ GG::X most_panels_left = base_selector_width; GG::X most_panels_width = ClientWidth() - most_panels_left; GG::Y detail_top = GG::Y0; - GG::Y detail_height(180); + GG::Y detail_height(380); GG::Y main_top = detail_top + detail_height; GG::Y part_palette_height(160); GG::Y part_palette_top = ClientHeight() - part_palette_height; |
From: <dil...@us...> - 2013-04-15 01:49:30
|
Revision: 5983 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5983&view=rev Author: dilvish-fo Date: 2013-04-15 01:49:23 +0000 (Mon, 15 Apr 2013) Log Message: ----------- misc minor improvements to PartsListBox code and comments Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2013-04-14 20:23:01 UTC (rev 5982) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2013-04-15 01:49:23 UTC (rev 5983) @@ -83,6 +83,7 @@ case PC_DETECTION: case PC_STEALTH: case PC_FUEL: + case PC_COLONY: case PC_ARMOUR: case PC_BATTLE_SPEED: case PC_STARLANE_SPEED: @@ -92,7 +93,7 @@ return 0; } } - typedef std::map<std::pair<ShipPartClass,ShipSlotType>, std::set<const PartType* > > partGroupsType; + typedef std::map<std::pair<ShipPartClass,ShipSlotType>, std::vector<const PartType* > > partGroupsType; } ////////////////////////////////////////////////// @@ -202,7 +203,7 @@ virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); partGroupsType GroupAvailableDisplayableParts(const Empire* empire); - void CullSuperfluousParts(std::set<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id); + void CullSuperfluousParts(std::vector<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id); void Populate(); void ShowClass(ShipPartClass part_class, bool refresh_list = true); @@ -329,35 +330,27 @@ for (std::set<ShipSlotType>::const_iterator it = m_slot_types_shown.begin(); it != m_slot_types_shown.end(); ++it) { if (part->CanMountInSlotType(*it)) { - partGroups[ std::make_pair<ShipPartClass,ShipSlotType>(part_class, *it) ].insert( part ); + partGroups[ std::make_pair<ShipPartClass,ShipSlotType>(part_class, *it) ].push_back( part ); } } } return partGroups; } -void PartsListBox::CullSuperfluousParts(std::set<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id) { +void PartsListBox::CullSuperfluousParts(std::vector<const PartType* >& thisGroup, ShipPartClass pclass, int empire_id, int loc_id) { /// This is not merely a check for obsolescence; see PartsListBox::Populate for more info - std::set<const PartType* >::reverse_iterator delete_it = thisGroup.rend(); - for (std::set<const PartType* >::reverse_iterator part_it = thisGroup.rbegin(); part_it != thisGroup.rend(); ++part_it) { - if (delete_it != thisGroup.rend()) { - thisGroup.erase( --delete_it.base()); - delete_it = thisGroup.rend(); - } + for (std::vector<const PartType* >::iterator part_it = thisGroup.begin(); part_it != thisGroup.end(); ++part_it) { const PartType* checkPart = *part_it; - for (std::set<const PartType* >::iterator check_it = thisGroup.begin(); check_it != thisGroup.end(); ++check_it ) { + for (std::vector<const PartType* >::iterator check_it = thisGroup.begin(); check_it != thisGroup.end(); ++check_it ) { const PartType* refPart = *check_it; - // if thisPart is superior to a part previously put into 'keepers' flag that keeper as pared, via keepNoMore if ( (getMainStat(pclass, checkPart->Stats()) < getMainStat(pclass, refPart->Stats()) ) && ( checkPart->ProductionCost(empire_id, loc_id) >= refPart->ProductionCost(empire_id, loc_id) ) && ( checkPart->ProductionTime(empire_id, loc_id) >= refPart->ProductionTime(empire_id, loc_id) ) ) { - delete_it = std::find(thisGroup.rbegin(), thisGroup.rend(), checkPart); + thisGroup.erase(part_it--); break; } } } - if (delete_it != thisGroup.rend()) - thisGroup.erase( --delete_it.base()); } void PartsListBox::Populate() { @@ -376,14 +369,22 @@ Clear(); /** - * The Parts are first filtered for availability to this empire and according to the current selections of which part classes - * are to be displayed. Then, in order to eliminate presentation of clearly suboptimal parts, such as Mass Driver I - * when Mass Driver II is available at the same cost & build time, some orgnization, paring and sorting of parts is done. - * The previously filtered parts are grouped into sets according to (class, slot); only parts within the same set may - * suppress display of each other. Within each group, parts are compared and pared for display. The paring is (currently) done - * on the basis of main stat, construction cost, and construction time. If two parts have the same class and slot, and one has - * a lower main stat but also a lower cost, they will both be presented; if one has a higher main stat and is at least as good - * on cost and time, it will suppress the other. + * The Parts are first filtered for availability to this empire and according to the current + * selections of which part classes are to be displayed. Then, in order to eliminate presentation + * of clearly suboptimal parts, such as Mass Driver I when Mass Driver II is available at the same + * cost & build time, some orgnization, paring and sorting of parts is done. The previously + * filtered parts are grouped according to (class, slot). Within each group, parts are compared + * and pared for display; only parts within the same group may suppress display of each other. + * The paring is (currently) done on the basis of main stat, construction cost, and construction + * time. If two parts have the same class and slot, and one has a lower main stat but also a lower + * cost, they will both be presented; if one has a higher main stat and is at least as good on cost + * and time, it will suppress the other. + * + * An example of one of the more subtle possible results is that if a part class had multiple parts + * with different but overlapping MountableSlotType patterns, then a part with two possible slot + * types might be rendered superfluous for the first slot type by a first other part, be rendered + * superfluous for the second slot type by a second other part, even if neither of the latter two + * parts would be considered to individually render the former part obsolete. */ /// filter parts by availability and current designation of classes for display; group according to (class, slot) @@ -410,10 +411,10 @@ // also, if a part was in multiple groups due to being compatible with multiple slot types, ensure it is only displayed once std::set<const PartType* > alreadyAdded; for (partGroupsType::iterator group_it=partGroups.begin(); group_it != partGroups.end(); group_it++) { - std::set<const PartType* > thisGroup = group_it->second; + std::vector<const PartType* > thisGroup = group_it->second; ShipPartClass pclass = group_it->first.first; std::multimap<double, const PartType*> sortedGroup; - for (std::set<const PartType* >::iterator part_it = thisGroup.begin(); part_it != thisGroup.end(); ++part_it) { + for (std::vector<const PartType* >::iterator part_it = thisGroup.begin(); part_it != thisGroup.end(); ++part_it) { const PartType* part = *part_it; if (alreadyAdded.find(part) != alreadyAdded.end()) continue; |
From: <dil...@us...> - 2013-05-10 20:49:37
|
Revision: 6020 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=6020&view=rev Author: dilvish-fo Date: 2013-05-10 20:49:31 +0000 (Fri, 10 May 2013) Log Message: ----------- reducing height of DesignWnd detail panel to be close to its old, smaller value Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2013-05-10 20:31:15 UTC (rev 6019) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2013-05-10 20:49:31 UTC (rev 6020) @@ -2221,7 +2221,7 @@ GG::X most_panels_left = base_selector_width; GG::X most_panels_width = ClientWidth() - most_panels_left; GG::Y detail_top = GG::Y0; - GG::Y detail_height(380); + GG::Y detail_height(200); GG::Y main_top = detail_top + detail_height; GG::Y part_palette_height(160); GG::Y part_palette_top = ClientHeight() - part_palette_height; |
From: <bi...@us...> - 2014-01-25 20:38:57
|
Revision: 6700 http://sourceforge.net/p/freeorion/code/6700 Author: bigjoe5 Date: 2014-01-25 20:38:52 +0000 (Sat, 25 Jan 2014) Log Message: ----------- - Removed unnecessary client-side duplication of an Order. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-01-25 20:38:18 UTC (rev 6699) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-01-25 20:38:52 UTC (rev 6700) @@ -1246,7 +1246,6 @@ if (result != "" && result != design->Name()) { HumanClientApp::GetApp()->Orders().IssueOrder( OrderPtr(new ShipDesignOrder(empire_id, design_id, result))); - GetUniverse().RenameShipDesign(design_id, result); ShipDesignPanel* design_panel = dynamic_cast<ShipDesignPanel*>((*design_row)[0]); design_panel->Update(); } |
From: <bi...@us...> - 2014-02-02 03:29:54
|
Revision: 6803 http://sourceforge.net/p/freeorion/code/6803 Author: bigjoe5 Date: 2014-02-02 03:29:50 +0000 (Sun, 02 Feb 2014) Log Message: ----------- - grooming Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-02-02 03:14:29 UTC (rev 6802) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-02-02 03:29:50 UTC (rev 6803) @@ -1755,7 +1755,7 @@ boost::shared_ptr<const ShipDesign> GetIncompleteDesign() const; //!< returns a pointer to the design currently being modified (if any). may return an empty pointer if not currently modifying a design. int GetCompleteDesignID() const; //!< returns ID of complete design currently being shown in this panel. returns ShipDesign::INVALID_DESIGN_ID if not showing a complete design static std::string dummy; - bool CurrentDesignIsRegistered(std::string& design_name = dummy); //!< returns true iff a design with the same hull and parts is already registered with thsi empire; if so, also populates design_name with the name of that design + bool CurrentDesignIsRegistered(std::string& design_name = dummy);//!< returns true iff a design with the same hull and parts is already registered with thsi empire; if so, also populates design_name with the name of that design //@} /** \name Mutators */ //@{ |
From: <geo...@us...> - 2014-02-09 07:47:32
|
Revision: 6870 http://sourceforge.net/p/freeorion/code/6870 Author: geoffthemedio Date: 2014-02-09 07:47:28 +0000 (Sun, 09 Feb 2014) Log Message: ----------- Typo fix? Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-02-09 07:46:24 UTC (rev 6869) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-02-09 07:47:28 UTC (rev 6870) @@ -98,8 +98,9 @@ return boost::get<float>(spstats); break; case PC_GENERAL: + case PC_BOMBARD: default: - return 0.9f; + return 0.0f; } } typedef std::map<std::pair<ShipPartClass,ShipSlotType>, std::vector<const PartType* > > partGroupsType; |
From: <dil...@us...> - 2014-06-12 04:42:57
|
Revision: 7152 http://sourceforge.net/p/freeorion/code/7152 Author: dilvish-fo Date: 2014-06-12 04:42:46 +0000 (Thu, 12 Jun 2014) Log Message: ----------- streamlining of Design name validity checking Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-06-11 17:05:38 UTC (rev 7151) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-06-12 04:42:46 UTC (rev 7152) @@ -1829,6 +1829,7 @@ void Populate(); //!< creates and places SlotControls for current hull void DoLayout(); //!< positions buttons, text entry boxes and SlotControls void DesignChanged(); //!< responds to the design being changed + void DesignNameChanged(); //!< responds to the design name being changed void RefreshIncompleteDesign() const; std::string GetCleanDesignDump(const ShipDesign* ship_design); //!< similar to ship design dump but without 'lookup_strings', icon and model entries @@ -1855,6 +1856,7 @@ GG::Edit* m_design_description; GG::Button* m_confirm_button; GG::Button* m_clear_button; + bool m_disabled_by_name; // if the design confirm button is currently disabled due to empty name boost::signals2::connection m_empire_designs_changed_signal; }; @@ -1874,7 +1876,8 @@ m_design_description_label(0), m_design_description(0), m_confirm_button(0), - m_clear_button(0) + m_clear_button(0), + m_disabled_by_name(false) { SetChildClippingMode(ClipToClient); @@ -2078,7 +2081,7 @@ } void DesignWnd::MainPanel::EditedSignal(const std::string& new_name) { - DesignChangedSignal(); // Check whether the confirmation button should be enabled or disabled each time the name changes. + DesignNameChanged(); // Check whether the confirmation button should be enabled or disabled each time the name changes. } std::pair<int, int> DesignWnd::MainPanel::FindSlotForPartWithSwapping(const PartType* part) { @@ -2283,6 +2286,7 @@ m_complete_design_id = ShipDesign::INVALID_DESIGN_ID; int client_empire_id = HumanClientApp::GetApp()->EmpireID(); std::string design_name; + m_disabled_by_name = false; if (!m_hull) { m_confirm_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( @@ -2299,7 +2303,7 @@ else if (m_design_name->Text().empty()) { // Whitespace probably shouldn't be OK either. m_confirm_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new TextBrowseWnd(UserString("DESIGN_INVALID"), UserString("DESIGN_INV_NO_NAME")))); - + m_disabled_by_name = true; m_confirm_button->Disable(true); } else if (!ShipDesign::ValidDesign(m_hull->Name(), Parts())) { @@ -2318,6 +2322,11 @@ } } +void DesignWnd::MainPanel::DesignNameChanged() { + if (m_disabled_by_name || (m_design_name->Text().empty() && !m_confirm_button->Disabled())) + DesignChangedSignal; +} + std::string DesignWnd::MainPanel::GetCleanDesignDump(const ShipDesign* ship_design) { std::string retval = "ShipDesign\n"; retval += ship_design->Name() + "\"\n"; |
From: <dil...@us...> - 2014-06-16 23:25:31
|
Revision: 7164 http://sourceforge.net/p/freeorion/code/7164 Author: dilvish-fo Date: 2014-06-16 23:25:26 +0000 (Mon, 16 Jun 2014) Log Message: ----------- Design window design name edits via the main panel name textbox are now immediately reflected in the pedia detail panel Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-06-16 17:19:15 UTC (rev 7163) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-06-16 23:25:26 UTC (rev 7164) @@ -1809,6 +1809,9 @@ * name or description changes) */ mutable boost::signals2::signal<void ()> DesignChangedSignal; + /** emitted when the design name is changed */ + mutable boost::signals2::signal<void ()> DesignNameChangedSignal; + /** propegates signals from contained SlotControls that signal that a part * has been clicked */ mutable boost::signals2::signal<void (const PartType*)> PartTypeClickedSignal; @@ -2324,7 +2327,9 @@ void DesignWnd::MainPanel::DesignNameChanged() { if (m_disabled_by_name || (m_design_name->Text().empty() && !m_confirm_button->Disabled())) - DesignChangedSignal; + DesignChangedSignal(); + else + DesignNameChangedSignal(); } std::string DesignWnd::MainPanel::GetCleanDesignDump(const ShipDesign* ship_design) { @@ -2417,6 +2422,10 @@ m_detail_panel, boost::bind(&DesignWnd::MainPanel::GetIncompleteDesign, m_main_panel))); + GG::Connect(m_main_panel->DesignNameChangedSignal, boost::bind(&EncyclopediaDetailPanel::SetIncompleteDesign, + m_detail_panel, + boost::bind(&DesignWnd::MainPanel::GetIncompleteDesign, + m_main_panel))); GG::Connect(m_main_panel->CompleteDesignClickedSignal, static_cast<void (EncyclopediaDetailPanel::*)(int)>(&EncyclopediaDetailPanel::SetDesign),m_detail_panel); m_main_panel->MoveTo(GG::Pt(most_panels_left, main_top)); m_main_panel->Sanitize(); |
From: <mar...@us...> - 2014-07-06 10:42:06
|
Revision: 7214 http://sourceforge.net/p/freeorion/code/7214 Author: marcel_metz Date: 2014-07-06 10:42:03 +0000 (Sun, 06 Jul 2014) Log Message: ----------- Most widgets in the design window exist during the whole lifetime of the window. There is no need to check if they exist. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-05 22:57:00 UTC (rev 7213) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-06 10:42:03 UTC (rev 7214) @@ -1548,8 +1548,6 @@ left = LEFT_PAD; top = top + BUTTON_HEIGHT + BUTTON_SEPARATION; - if (!m_tabs) - return; m_tabs->SizeMove(GG::Pt(left, top), ClientSize() - GG::Pt(LEFT_PAD, TOP_PAD)); } @@ -1979,17 +1977,11 @@ } const std::string& DesignWnd::MainPanel::DesignName() const { - if (m_design_name) - return m_design_name->Text(); - else - return EMPTY_STRING; + return m_design_name->Text(); } const std::string& DesignWnd::MainPanel::DesignDescription() const { - if (m_design_description) - return m_design_description->Text(); - else - return EMPTY_STRING; + return m_design_description->Text(); } boost::shared_ptr<const ShipDesign> DesignWnd::MainPanel::GetIncompleteDesign() const { @@ -2257,62 +2249,41 @@ const GG::X BUTTON_WIDTH = PTS_WIDE*GUESSTIMATE_NUM_CHARS_IN_BUTTON_TEXT; GG::X edit_right = ClientWidth(); - GG::Y edit_height = BUTTON_HEIGHT; GG::X confirm_right = ClientWidth() - PAD; - if (m_confirm_button) { - GG::Pt lr = GG::Pt(confirm_right, BUTTON_HEIGHT) + GG::Pt(GG::X0, GG::Y(PAD)); - GG::Pt ul = lr - GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); - m_confirm_button->SizeMove(ul, lr); - edit_right = ul.x - PAD; - } - if (m_clear_button) { - GG::Pt lr = ClientSize() + GG::Pt(-GG::X(PAD), -GG::Y(PAD)); - GG::Pt ul = lr - GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); - m_clear_button->SizeMove(ul, lr); - } + GG::Pt lr = GG::Pt(confirm_right, BUTTON_HEIGHT) + GG::Pt(GG::X0, GG::Y(PAD)); + GG::Pt ul = lr - GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + m_confirm_button->SizeMove(ul, lr); + edit_right = ul.x - PAD; - if (m_design_name) - edit_height = m_design_name->Height(); + lr = ClientSize() + GG::Pt(-GG::X(PAD), -GG::Y(PAD)); + ul = lr - GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + m_clear_button->SizeMove(ul, lr); - GG::X x(PAD); - GG::Y y(PAD); - if (m_design_name_label) { - GG::Pt ul = GG::Pt(x, y); - GG::Pt lr = ul + GG::Pt(LABEL_WIDTH, edit_height); - m_design_name_label->SizeMove(ul, lr); - x = lr.x + PAD; - } - if (m_design_name) { - GG::Pt ul = GG::Pt(x, y); - GG::Pt lr = GG::Pt(edit_right, y + edit_height); - m_design_name->SizeMove(ul, lr); - x = lr.x + PAD; - } + ul = GG::Pt(GG::X(PAD), GG::Y(PAD)); + lr = ul + GG::Pt(LABEL_WIDTH, m_design_name->Height()); + m_design_name_label->SizeMove(ul, lr); - x = GG::X(PAD); - y += (edit_height + PAD); + ul.x += lr.x; + lr.x = edit_right; + m_design_name->SizeMove(ul, lr); - if (m_design_description_label) { - GG::Pt ul = GG::Pt(x, y); - GG::Pt lr = ul + GG::Pt(LABEL_WIDTH, edit_height); - m_design_description_label->SizeMove(ul, lr); - x = lr.x + PAD; - } - if (m_design_description) { - GG::Pt ul = GG::Pt(x, y); - GG::Pt lr = GG::Pt(confirm_right, y + edit_height); - m_design_description->SizeMove(ul, lr); - x = lr.x + PAD; - } + ul.x = GG::X(PAD); + ul.y += (m_design_name->Height() + PAD); + lr = ul + GG::Pt(LABEL_WIDTH, m_design_name->Height()); + m_design_description_label->SizeMove(ul, lr); - y += (edit_height); + ul.x = lr.x + PAD; + lr.x = confirm_right; + m_design_description->SizeMove(ul, lr); // place background image of hull - GG::Rect background_rect = GG::Rect(GG::Pt(GG::X0, y), ClientLowerRight()); + ul.x = GG::X0; + ul.y += m_design_name->Height(); + GG::Rect background_rect = GG::Rect(ul, ClientLowerRight()); if (m_background_image) { - GG::Pt ul = GG::Pt(GG::X0, y); + GG::Pt ul = background_rect.UpperLeft(); GG::Pt lr = ClientSize(); m_background_image->SizeMove(ul, lr); background_rect = m_background_image->RenderedArea(); |
From: <geo...@us...> - 2014-07-26 10:36:17
|
Revision: 7296 http://sourceforge.net/p/freeorion/code/7296 Author: geoffthemedio Date: 2014-07-26 10:36:13 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Added code to set size of hulls list column to 0 so that it will properly resize when the enclosing window is resized (avoids commonly occurring issue with GG::ListBox where the initial column widths become the minimum to which contained controls will be resized). Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-25 10:16:32 UTC (rev 7295) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-26 10:36:13 UTC (rev 7296) @@ -939,14 +939,15 @@ mutable boost::signals2::signal<void (const ShipDesign*)> DesignRightClickedSignal; private: - void BaseDoubleClicked(GG::ListBox::iterator it); - void BaseLeftClicked(GG::ListBox::iterator it, const GG::Pt& pt); - void BaseRightClicked(GG::ListBox::iterator it, const GG::Pt& pt); + void BaseDoubleClicked(GG::ListBox::iterator it); + void BaseLeftClicked(GG::ListBox::iterator it, const GG::Pt& pt); + void BaseRightClicked(GG::ListBox::iterator it, const GG::Pt& pt); - GG::Pt ListRowSize(); + GG::Pt ListRowSize(); + void InitRowSizes(); - void PopulateWithEmptyHulls(); - void PopulateWithCompletedDesigns(); + void PopulateWithEmptyHulls(); + void PopulateWithCompletedDesigns(); int m_empire_id_shown; std::pair<bool, bool> m_availabilities_shown; // first indicates whether available parts should be shown. second indicates whether unavailable parts should be shown @@ -1068,6 +1069,8 @@ m_showing_empty_hulls(false), m_showing_completed_designs(false) { + InitRowSizes(); + GG::Connect(DoubleClickedSignal, &BasesListBox::BaseDoubleClicked, this); GG::Connect(LeftClickedSignal, &BasesListBox::BaseLeftClicked, this); GG::Connect(RightClickedSignal, &BasesListBox::BaseRightClicked, this); @@ -1118,6 +1121,14 @@ GG::Pt BasesListBox::ListRowSize() { return GG::Pt(Width() - ClientUI::ScrollWidth() - 5, BASES_LIST_BOX_ROW_HEIGHT); } +void BasesListBox::InitRowSizes() { + // preinitialize listbox/row column widths, because what + // ListBox::Insert does on default is not suitable for this case + SetNumCols(1); + SetColWidth(0, GG::X0); + LockColWidths(); +} + void BasesListBox::PopulateWithEmptyHulls() { ScopedTimer scoped_timer("BasesListBox::PopulateWithEmptyHulls"); |
From: <geo...@us...> - 2014-07-26 22:00:09
|
Revision: 7300 http://sourceforge.net/p/freeorion/code/7300 Author: geoffthemedio Date: 2014-07-26 22:00:00 +0000 (Sat, 26 Jul 2014) Log Message: ----------- Added dragging hulls and complete designs from the list to the main design panel. (Annoying reorders the list when doing so, but seemingly works.) Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-26 21:58:59 UTC (rev 7299) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-26 22:00:00 UTC (rev 7300) @@ -1,16 +1,16 @@ #include "DesignWnd.h" -#include "../util/i18n.h" -#include "../util/Logger.h" -#include "../util/Order.h" -#include "../util/OptionsDB.h" -#include "../util/ScopedTimer.h" #include "ClientUI.h" #include "CUIWnd.h" #include "CUIControls.h" #include "EncyclopediaDetailPanel.h" #include "InfoPanels.h" #include "Sound.h" +#include "../util/i18n.h" +#include "../util/Logger.h" +#include "../util/Order.h" +#include "../util/OptionsDB.h" +#include "../util/ScopedTimer.h" #include "../Empire/Empire.h" #include "../client/human/HumanClientApp.h" #include "../universe/UniverseObject.h" @@ -29,6 +29,8 @@ namespace { const std::string PART_CONTROL_DROP_TYPE_STRING = "Part Control"; + const std::string HULL_PARTS_ROW_DROP_TYPE_STRING = "Hull and Parts Row"; + const std::string COMPLETE_DESIGN_ROW_DROP_STRING = "Complete Design Row"; const std::string EMPTY_STRING = ""; const GG::Y BASES_LIST_BOX_ROW_HEIGHT(100); const GG::X PART_CONTROL_WIDTH(64); @@ -147,7 +149,9 @@ m_background(0), m_part(part) { - if (m_part) { + if (!m_part) + return; + m_background = new GG::StaticGraphic(GG::X0, GG::Y0, SLOT_CONTROL_WIDTH, SLOT_CONTROL_HEIGHT, PartBackgroundTexture(m_part), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); @@ -175,11 +179,10 @@ SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( new IconTextBrowseWnd(ClientUI::PartIcon(m_part->Name()), - UserString(m_part->Name()), - UserString(m_part->Description())) - ) - ); - } + UserString(m_part->Name()), + UserString(m_part->Description())) + ) + ); } void PartControl::Render() {} @@ -252,10 +255,10 @@ void PartsListBox::PartsListBoxRow::ChildrenDraggedAway(const std::vector<GG::Wnd*>& wnds, const GG::Wnd* destination) { if (wnds.empty()) return; - const GG::Wnd* wnd = wnds.front(); // should only be one wnd in list due because PartControls can only be dragged one-at-a-time + const GG::Wnd* wnd = wnds.front(); // should only be one wnd in list because PartControls doesn't allow selection, so dragging is only one-at-a-time const GG::Control* control = dynamic_cast<const GG::Control*>(wnd); if (!control) - return; + delete wnd; GG::Control* dragged_control = 0; @@ -912,6 +915,7 @@ /** \name Mutators */ //@{ virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); + virtual void ChildrenDraggedAway(const std::vector<GG::Wnd*>& wnds, const GG::Wnd* destination); void SetEmpireShown(int empire_id, bool refresh_list = true); @@ -938,26 +942,6 @@ /** a complete design was right-clicked (once) */ mutable boost::signals2::signal<void (const ShipDesign*)> DesignRightClickedSignal; -private: - void BaseDoubleClicked(GG::ListBox::iterator it); - void BaseLeftClicked(GG::ListBox::iterator it, const GG::Pt& pt); - void BaseRightClicked(GG::ListBox::iterator it, const GG::Pt& pt); - - GG::Pt ListRowSize(); - void InitRowSizes(); - - void PopulateWithEmptyHulls(); - void PopulateWithCompletedDesigns(); - - int m_empire_id_shown; - std::pair<bool, bool> m_availabilities_shown; // first indicates whether available parts should be shown. second indicates whether unavailable parts should be shown - bool m_showing_empty_hulls, m_showing_completed_designs; - - std::set<int> m_designs_in_list; - std::set<std::string> m_hulls_in_list; - - boost::signals2::connection m_empire_designs_changed_signal; - class BasesListBoxRow : public CUIListBox::Row { public: BasesListBoxRow(GG::X w, GG::Y h); @@ -978,8 +962,8 @@ GG::TextControl* m_cost_and_build_time; }; HullAndPartsListBoxRow(GG::X w, GG::Y h, const std::string& hull, const std::vector<std::string>& parts); - const std::string& Hull() const { return m_hull; } - const std::vector<std::string>& Parts() const { return m_parts; } + const std::string& Hull() const { return m_hull; } + const std::vector<std::string>& Parts() const { return m_parts; } private: std::string m_hull; std::vector<std::string> m_parts; @@ -989,12 +973,29 @@ public: CompletedDesignListBoxRow(GG::X w, GG::Y h, int design_id); int DesignID() const { return m_design_id; } -// void Update() { -// ShipDesignPanel* panel = dynamic_cast<ShipDesignPanel*>(this->operator[](0)); -// } private: int m_design_id; }; + +private: + void BaseDoubleClicked(GG::ListBox::iterator it); + void BaseLeftClicked(GG::ListBox::iterator it, const GG::Pt& pt); + void BaseRightClicked(GG::ListBox::iterator it, const GG::Pt& pt); + + GG::Pt ListRowSize(); + void InitRowSizes(); + + void PopulateWithEmptyHulls(); + void PopulateWithCompletedDesigns(); + + int m_empire_id_shown; + std::pair<bool, bool> m_availabilities_shown; // first indicates whether available parts should be shown. second indicates whether unavailable parts should be shown + bool m_showing_empty_hulls, m_showing_completed_designs; + + std::set<int> m_designs_in_list; + std::set<std::string> m_hulls_in_list; + + boost::signals2::connection m_empire_designs_changed_signal; }; BasesListBox::BasesListBoxRow::BasesListBoxRow(GG::X w, GG::Y h) : @@ -1050,6 +1051,7 @@ // contents are a hull and parts TODO: make a HullAndPartsPanel push_back(new GG::StaticGraphic(GG::X0, GG::Y0, w, h, ClientUI::HullTexture(hull), GG::GRAPHIC_PROPSCALE | GG::GRAPHIC_FITGRAPHIC)); } + SetDragDropDataType(HULL_PARTS_ROW_DROP_TYPE_STRING); } BasesListBox::CompletedDesignListBoxRow::CompletedDesignListBoxRow(GG::X w, GG::Y h, int design_id) : @@ -1060,6 +1062,7 @@ if (const ShipDesign* ship_design = GetShipDesign(design_id)) hull = ship_design->Hull(); push_back(new ShipDesignPanel(w, h, design_id)); + SetDragDropDataType(COMPLETE_DESIGN_ROW_DROP_STRING); } BasesListBox::BasesListBox(GG::X x, GG::Y y, GG::X w, GG::Y h) : @@ -1070,6 +1073,7 @@ m_showing_completed_designs(false) { InitRowSizes(); + SetStyle(GG::LIST_NOSEL); GG::Connect(DoubleClickedSignal, &BasesListBox::BaseDoubleClicked, this); GG::Connect(LeftClickedSignal, &BasesListBox::BaseLeftClicked, this); @@ -1089,6 +1093,49 @@ } } +void BasesListBox::ChildrenDraggedAway(const std::vector<GG::Wnd*>& wnds, const GG::Wnd* destination) { + if (wnds.empty()) + return; + if (!wnds.size() == 1) + Logger().errorStream() << "BasesListBox::ChildrenDraggedAway unexpected informed that multiple Wnds were dragged away..."; + const GG::Wnd* wnd = wnds.front(); // should only be one wnd in list as BasesListBost doesn't allow selection, so dragging is only one-at-a-time + const GG::Control* control = dynamic_cast<const GG::Control*>(wnd); + if (!control) + return; + + // remove dragged-away row from this ListBox + CUIListBox::ChildrenDraggedAway(wnds, destination); + + // replace dragged-away control with new copy + const GG::Pt row_size = ListRowSize(); + std::vector<std::string> empty_parts_vec; + + if (wnd->DragDropDataType() == COMPLETE_DESIGN_ROW_DROP_STRING) { + // find design that was dragged away, and replace + const BasesListBox::CompletedDesignListBoxRow* design_row = + boost::polymorphic_downcast<const BasesListBox::CompletedDesignListBoxRow*>(wnd); + + int design_id = design_row->DesignID(); + CompletedDesignListBoxRow* row = new CompletedDesignListBoxRow(row_size.x, row_size.y, + design_id); + Insert(row); + row->Resize(row_size); + m_designs_in_list.insert(design_id);// should be redundant + + } else if (wnd->DragDropDataType() == HULL_PARTS_ROW_DROP_TYPE_STRING) { + // find type of hull that was dragged away, and replace + const BasesListBox::HullAndPartsListBoxRow* design_row = + boost::polymorphic_downcast<const BasesListBox::HullAndPartsListBoxRow*>(wnd); + + const std::string& hull_name = design_row->Hull(); + HullAndPartsListBoxRow* row = new HullAndPartsListBoxRow(row_size.x, row_size.y, + hull_name, empty_parts_vec); + Insert(row); + row->Resize(row_size); + m_hulls_in_list.insert(hull_name); // should be redundant + } +} + void BasesListBox::SetEmpireShown(int empire_id, bool refresh_list) { m_empire_id_shown = empire_id; @@ -1121,12 +1168,12 @@ GG::Pt BasesListBox::ListRowSize() { return GG::Pt(Width() - ClientUI::ScrollWidth() - 5, BASES_LIST_BOX_ROW_HEIGHT); } -void BasesListBox::InitRowSizes() { - // preinitialize listbox/row column widths, because what - // ListBox::Insert does on default is not suitable for this case - SetNumCols(1); - SetColWidth(0, GG::X0); - LockColWidths(); +void BasesListBox::InitRowSizes() { + // preinitialize listbox/row column widths, because what + // ListBox::Insert does on default is not suitable for this case + SetNumCols(1); + SetColWidth(0, GG::X0); + LockColWidths(); } void BasesListBox::PopulateWithEmptyHulls() { @@ -1630,7 +1677,7 @@ m_y_position_fraction(0.4), m_part_control(0), m_background(0) -{ SetDragDropDataType(""); } +{} SlotControl::SlotControl(double x, double y, ShipSlotType slot_type) : GG::Control(GG::X0, GG::Y0, SLOT_CONTROL_WIDTH, SLOT_CONTROL_HEIGHT, GG::INTERACTIVE), @@ -1641,7 +1688,6 @@ m_part_control(0), m_background(0) { - SetDragDropDataType(""); m_background = new GG::StaticGraphic(GG::X0, GG::Y0, SLOT_CONTROL_WIDTH, SLOT_CONTROL_HEIGHT, SlotBackgroundTexture(m_slot_type), GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); @@ -1664,6 +1710,11 @@ } void SlotControl::DropsAcceptable(DropsAcceptableIter first, DropsAcceptableIter last, const GG::Pt& pt) const { + for (DropsAcceptableIter it = first; it != last; ++it) + it->second = false; + if (std::distance(first, last) != 1) + return; + bool acceptable_part_found = false; for (DropsAcceptableIter it = first; it != last; ++it) { if (!acceptable_part_found && it->first->DragDropDataType() == PART_CONTROL_DROP_TYPE_STRING) { @@ -1671,7 +1722,8 @@ const PartType* part_type = part_control->Part(); if (part_type && part_type->CanMountInSlotType(m_slot_type) && - part_control != m_part_control) { + part_control != m_part_control) + { it->second = true; acceptable_part_found = true; } else { @@ -1726,16 +1778,23 @@ } void SlotControl::AcceptDrops(const std::vector<GG::Wnd*>& wnds, const GG::Pt& pt) { - assert(wnds.size() == 1); + if (wnds.size() != 1) { + // delete any extra wnds that won't be processed below + std::vector<GG::Wnd*>::const_iterator it = wnds.begin(); + ++it; + for (; it != wnds.end(); ++it) + delete *it; + Logger().errorStream() << "SlotControl::AcceptDrops given multiple wnds unexpectedly..."; + } const GG::Wnd* wnd = *(wnds.begin()); const PartControl* control = boost::polymorphic_downcast<const PartControl*>(wnd); - const PartType* part_type = control->Part(); + const PartType* part_type = control ? control->Part() : 0; - delete control; + delete wnd; - //Logger().debugStream() << "SlotControl::AcceptDrops part_type: " << (part_type ? part_type->Name() : "no part"); - SlotContentsAlteredSignal(part_type); + if (part_type) + SlotContentsAlteredSignal(part_type); } void SlotControl::ChildrenDraggedAway(const std::vector<GG::Wnd*>& wnds, const GG::Wnd* destination) { @@ -1816,6 +1875,10 @@ //@} /** \name Accessors */ //@{ + virtual void DropsAcceptable(DropsAcceptableIter first, + DropsAcceptableIter last, + const GG::Pt& pt) const; + const std::vector<std::string> Parts() const; //!< returns vector of names of parts in slots of current shown design. empty slots are represented with empty stri const std::string& Hull() const; //!< returns name of hull of current shown design const std::string& DesignName() const; //!< returns name currently entered for design @@ -1829,6 +1892,7 @@ /** \name Mutators */ //@{ virtual void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); + virtual void AcceptDrops(const std::vector<GG::Wnd*>& wnds, const GG::Pt& pt); virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); void Sanitize(); @@ -2414,6 +2478,75 @@ } } +void DesignWnd::MainPanel::DropsAcceptable(DropsAcceptableIter first, + DropsAcceptableIter last, + const GG::Pt& pt) const +{ + for (DropsAcceptableIter it = first; it != last; ++it) + it->second = false; + if (std::distance(first, last) != 1) + return; + + bool accepted_something = false; + for (DropsAcceptableIter it = first; it != last; ++it) { + if (!accepted_something && it->first->DragDropDataType() == COMPLETE_DESIGN_ROW_DROP_STRING) { + //const BasesListBox::CompletedDesignListBoxRow* design_row = + // boost::polymorphic_downcast<const BasesListBox::CompletedDesignListBoxRow*>(it->first); + accepted_something = true; + it->second = true; + + } else if (!accepted_something && it->first->DragDropDataType() == HULL_PARTS_ROW_DROP_TYPE_STRING) { + //const BasesListBox::HullAndPartsListBoxRow* design_row = + // boost::polymorphic_downcast<const BasesListBox::HullAndPartsListBoxRow*>(it->first); + accepted_something = true; + it->second = true; + + } else { + it->second = false; + } + } +} + +void DesignWnd::MainPanel::AcceptDrops(const std::vector<GG::Wnd*>& wnds, const GG::Pt& pt) { + if (wnds.size() != 1) { + // delete any extra wnds that won't be processed below + std::vector<GG::Wnd*>::const_iterator it = wnds.begin(); + ++it; + for (; it != wnds.end(); ++it) + delete *it; + Logger().errorStream() << "DesignWnd::MainPanel::AcceptDrops given multiple wnds unexpectedly..."; + } + + const GG::Wnd* wnd = *(wnds.begin()); + if (!wnd) + return; + + if (wnd->DragDropDataType() == COMPLETE_DESIGN_ROW_DROP_STRING) { + const BasesListBox::CompletedDesignListBoxRow* control = + boost::polymorphic_downcast<const BasesListBox::CompletedDesignListBoxRow*>(wnd); + if (control) { + int design_id = control->DesignID(); + if (design_id != ShipDesign::INVALID_DESIGN_ID) + SetDesign(design_id); + } + } + else if (wnd->DragDropDataType() == HULL_PARTS_ROW_DROP_TYPE_STRING) { + const BasesListBox::HullAndPartsListBoxRow* control = + boost::polymorphic_downcast<const BasesListBox::HullAndPartsListBoxRow*>(wnd); + if (control) { + const std::string& hull = control->Hull(); + const std::vector<std::string>& parts = control->Parts(); + + if (!hull.empty()) + SetHull(hull); + SetParts(parts); + } + } + + delete wnd; +} + + ////////////////////////////////////////////////// // DesignWnd // ////////////////////////////////////////////////// |
From: <geo...@us...> - 2014-07-27 08:55:42
|
Revision: 7301 http://sourceforge.net/p/freeorion/code/7301 Author: geoffthemedio Date: 2014-07-27 08:55:33 +0000 (Sun, 27 Jul 2014) Log Message: ----------- -Made clicking the background of the main design panel (the hull) show the hull in the pedia. -grooming Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-26 22:00:00 UTC (rev 7300) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-27 08:55:33 UTC (rev 7301) @@ -1804,7 +1804,11 @@ const PartControl* part_control = dynamic_cast<const PartControl*>(wnd); if (part_control != m_part_control) return; - m_part_control = 0; // SlotContentsAlteredSignal is connected to this->SetPart, which will delete m_part_control if it is not null. The drop-accepting Wnd is responsible for deleting the accepted Wnd, so setting m_part_control = 0 here prevents this->SetPart from deleting it prematurely + // SlotContentsAlteredSignal is connected to this->SetPart, which will + // delete m_part_control if it is not null. The drop-accepting Wnd is + // responsible for deleting the accepted Wnd, so setting m_part_control = 0 + // here prevents this->SetPart from deleting it prematurely + m_part_control = 0; SlotContentsAlteredSignal(0); } @@ -1933,6 +1937,8 @@ * has been clicked */ mutable boost::signals2::signal<void (const PartType*)> PartTypeClickedSignal; + mutable boost::signals2::signal<void (const HullType*)> HullTypeClickedSignal; + /** emitted when the user clicks the m_confirm_button to add the new * design to the player's empire */ mutable boost::signals2::signal<void ()> DesignConfirmedSignal; @@ -2091,10 +2097,8 @@ } void DesignWnd::MainPanel::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { - if (m_incomplete_design.get()) - DesignChangedSignal(); - else if (m_complete_design_id != ShipDesign::INVALID_DESIGN_ID) - CompleteDesignClickedSignal(m_complete_design_id); + if (m_hull) + HullTypeClickedSignal(m_hull); CUIWnd::LClick(pt, mod_keys); } @@ -2152,10 +2156,13 @@ } void DesignWnd::MainPanel::AddPart(const PartType* part) { - if (!AddPartEmptySlot(part, FindEmptySlotForPart(part))) { - if (!AddPartWithSwapping(part, FindSlotForPartWithSwapping(part))) - Logger().debugStream() << "DesignWnd::MainPanel::AddPart(" << (part ? part->Name() : "no part") << ") couldn't find a slot for the part"; - } + if (AddPartEmptySlot(part, FindEmptySlotForPart(part))) + return; + + if (!AddPartWithSwapping(part, FindSlotForPartWithSwapping(part))) + Logger().debugStream() << "DesignWnd::MainPanel::AddPart(" + << (part ? part->Name() : "no part") + << ") couldn't find a slot for the part"; } bool DesignWnd::MainPanel::CanPartBeAdded(const PartType* part) { @@ -2173,8 +2180,10 @@ bool DesignWnd::MainPanel::AddPartWithSwapping(const PartType* part, std::pair<int, int> swap_and_empty_slot) { if (!part || swap_and_empty_slot.first < 0 || swap_and_empty_slot.second < 0) return false; - SetPart(m_slots[swap_and_empty_slot.first]->GetPart(), swap_and_empty_slot.second); // Move the flexible part to the first open spot - SetPart(part, swap_and_empty_slot.first); // Move ourself into the newly opened slot + // Move the flexible part to the first open spot + SetPart(m_slots[swap_and_empty_slot.first]->GetPart(), swap_and_empty_slot.second); + // Move replacement part into the newly opened slot + SetPart(part, swap_and_empty_slot.first); return true; } @@ -2577,6 +2586,7 @@ m_main_panel = new MainPanel(most_panels_width, main_height); AttachChild(m_main_panel); GG::Connect(m_main_panel->PartTypeClickedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const PartType*)>(&EncyclopediaDetailPanel::SetItem), m_detail_panel); + GG::Connect(m_main_panel->HullTypeClickedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const HullType*)>(&EncyclopediaDetailPanel::SetItem), m_detail_panel); GG::Connect(m_main_panel->DesignConfirmedSignal, &DesignWnd::AddDesign, this); GG::Connect(m_main_panel->DesignChangedSignal, boost::bind(&EncyclopediaDetailPanel::SetIncompleteDesign, m_detail_panel, @@ -2598,10 +2608,14 @@ m_base_selector = new BaseSelector(base_selector_width, ClientHeight()); AttachChild(m_base_selector); - GG::Connect(m_base_selector->DesignSelectedSignal, static_cast<void (MainPanel::*)(int)>(&MainPanel::SetDesign), m_main_panel); - GG::Connect(m_base_selector->DesignComponentsSelectedSignal,&MainPanel::SetDesignComponents, m_main_panel); - GG::Connect(m_base_selector->DesignBrowsedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const ShipDesign*)>(&EncyclopediaDetailPanel::SetItem), m_detail_panel); - GG::Connect(m_base_selector->HullBrowsedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const HullType*)>(&EncyclopediaDetailPanel::SetItem), m_detail_panel); + GG::Connect(m_base_selector->DesignSelectedSignal, static_cast<void (MainPanel::*)(int)>(&MainPanel::SetDesign), + m_main_panel); + GG::Connect(m_base_selector->DesignComponentsSelectedSignal,&MainPanel::SetDesignComponents, + m_main_panel); + GG::Connect(m_base_selector->DesignBrowsedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const ShipDesign*)>(&EncyclopediaDetailPanel::SetItem), + m_detail_panel); + GG::Connect(m_base_selector->HullBrowsedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const HullType*)>(&EncyclopediaDetailPanel::SetItem), + m_detail_panel); m_base_selector->MoveTo(GG::Pt()); } |
From: <dil...@us...> - 2014-07-29 05:18:07
|
Revision: 7313 http://sourceforge.net/p/freeorion/code/7313 Author: dilvish-fo Date: 2014-07-29 05:17:58 +0000 (Tue, 29 Jul 2014) Log Message: ----------- changed layout of DetailPanel, PartsPalettePanel, and MainPanel within the DesignWnd Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-28 22:45:13 UTC (rev 7312) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-29 05:17:58 UTC (rev 7313) @@ -2572,14 +2572,17 @@ GG::X base_selector_width(300); GG::X most_panels_left = base_selector_width; GG::X most_panels_width = ClientWidth() - most_panels_left; + GG::X detail_width = 5*most_panels_width/11; + GG::X part_palette_left = base_selector_width + detail_width; + GG::X part_palette_width = most_panels_width - detail_width; GG::Y detail_top = GG::Y0; - GG::Y detail_height(200); + GG::Y detail_height = 2*ClientHeight()/5; //(200); GG::Y main_top = detail_top + detail_height; - GG::Y part_palette_height(160); - GG::Y part_palette_top = ClientHeight() - part_palette_height; - GG::Y main_height = part_palette_top - main_top; + GG::Y part_palette_height = detail_height; //(160); + GG::Y part_palette_top = detail_top;//ClientHeight() - part_palette_height; + GG::Y main_height = ClientHeight() - main_top;//part_palette_top - main_top; - m_detail_panel = new EncyclopediaDetailPanel(most_panels_width, detail_height, GG::ONTOP | GG::INTERACTIVE | GG::DRAGABLE | GG::RESIZABLE); + m_detail_panel = new EncyclopediaDetailPanel(detail_width, detail_height, GG::ONTOP | GG::INTERACTIVE | GG::DRAGABLE | GG::RESIZABLE); AttachChild(m_detail_panel); m_detail_panel->MoveTo(GG::Pt(most_panels_left, detail_top)); @@ -2600,11 +2603,11 @@ m_main_panel->MoveTo(GG::Pt(most_panels_left, main_top)); m_main_panel->Sanitize(); - m_part_palette = new PartPalette(most_panels_width, part_palette_height); + m_part_palette = new PartPalette(part_palette_width, part_palette_height); AttachChild(m_part_palette); GG::Connect(m_part_palette->PartTypeClickedSignal, static_cast<void (EncyclopediaDetailPanel::*)(const PartType*)>(&EncyclopediaDetailPanel::SetItem), m_detail_panel); GG::Connect(m_part_palette->PartTypeDoubleClickedSignal, &DesignWnd::MainPanel::AddPart, m_main_panel); - m_part_palette->MoveTo(GG::Pt(most_panels_left, part_palette_top)); + m_part_palette->MoveTo(GG::Pt(part_palette_left, part_palette_top)); m_base_selector = new BaseSelector(base_selector_width, ClientHeight()); AttachChild(m_base_selector); |
From: <dil...@us...> - 2014-07-29 15:44:18
|
Revision: 7315 http://sourceforge.net/p/freeorion/code/7315 Author: dilvish-fo Date: 2014-07-29 15:44:13 +0000 (Tue, 29 Jul 2014) Log Message: ----------- Some further adjustment of DesignWnd layout, and reducing the size of displayed part icons Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-29 07:41:59 UTC (rev 7314) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2014-07-29 15:44:13 UTC (rev 7315) @@ -33,10 +33,10 @@ const std::string COMPLETE_DESIGN_ROW_DROP_STRING = "Complete Design Row"; const std::string EMPTY_STRING = ""; const GG::Y BASES_LIST_BOX_ROW_HEIGHT(100); - const GG::X PART_CONTROL_WIDTH(64); - const GG::Y PART_CONTROL_HEIGHT(64); - const GG::X SLOT_CONTROL_WIDTH(72); - const GG::Y SLOT_CONTROL_HEIGHT(72); + const GG::X PART_CONTROL_WIDTH(54); + const GG::Y PART_CONTROL_HEIGHT(54); + const GG::X SLOT_CONTROL_WIDTH(60); + const GG::Y SLOT_CONTROL_HEIGHT(60); const int PAD(3); /** Returns texture with which to render a SlotControl, depending on \a slot_type. */ @@ -2569,7 +2569,7 @@ Sound::TempUISoundDisabler sound_disabler; SetChildClippingMode(ClipToClient); - GG::X base_selector_width(300); + GG::X base_selector_width(250); GG::X most_panels_left = base_selector_width; GG::X most_panels_width = ClientWidth() - most_panels_left; GG::X detail_width = 5*most_panels_width/11; |