Пример #1
0
 void RefreshRowSizes() {
     const GG::Pt row_size = ListRowSize();
     ColHeaders().Resize ( row_size );
     for ( GG::ListBox::iterator it = begin(); it != end(); ++it ) {
         ( *it )->Resize ( row_size );
     }
 }
Пример #2
0
 void SizeMove(const GG::Pt& ul, const GG::Pt& lr) override {
     const GG::Pt old_size = Size();
     CUIListBox::SizeMove(ul, lr);
     //std::cout << "PlayerListBox::SizeMove size: (" << Value(Width()) << ", " << Value(Height()) << ")" << std::endl;
     if (old_size != Size()) {
         const GG::Pt row_size = ListRowSize();
         //std::cout << "PlayerListBox::SizeMove list row size: (" << Value(row_size.x) << ", " << Value(row_size.y) << ")" << std::endl;
         for (GG::ListBox::Row* row : *this)
             row->Resize(row_size);
     }
 }
Пример #3
0
 virtual void    SizeMove(const GG::Pt& ul, const GG::Pt& lr) {
     const GG::Pt old_size = Size();
     CUIListBox::SizeMove(ul, lr);
     //std::cout << "PlayerListBox::SizeMove size: (" << Value(Width()) << ", " << Value(Height()) << ")" << std::endl;
     if (old_size != Size()) {
         const GG::Pt row_size = ListRowSize();
         //std::cout << "PlayerListBox::SizeMove list row size: (" << Value(row_size.x) << ", " << Value(row_size.y) << ")" << std::endl;
         for (GG::ListBox::iterator it = begin(); it != end(); ++it)
             (*it)->Resize(row_size);
     }
 }
Пример #4
0
void CombatSetupWnd::RedoPlacementsButtonClicked() {
    const GG::Pt row_size = ListRowSize();
    for (std::map<int, Ogre::SceneNode*>::iterator it = m_placed_nodes.begin();
            it != m_placed_nodes.end();
            ++it) {
        Ship* ship = *Ogre::any_cast<Ship*>(&it->second->getUserAny());
        UniverseObject* o = m_combat_universe[ship->FleetID()];
        Fleet* fleet = boost::polymorphic_downcast<Fleet*>(o);
        ShipRow* row = new ShipRow(ship, fleet, row_size.x, row_size.y);
        m_listbox->Insert(row);
        m_remove_ship(it->first);
    }
    m_placed_nodes.clear();
}
Пример #5
0
CombatSetupWnd::CombatSetupWnd(
    const std::vector<CombatSetupGroup>& setup_groups,
    CombatWnd* combat_wnd,
    const CombatData* combat_data,
    Ogre::SceneManager* scene_manager,
    boost::function<std::pair<bool, Ogre::Vector3> (const GG::Pt& pt)>
    intersect_mouse_with_ecliptic,
    boost::function<const Ogre::MaterialPtr& (const Ship&)>
    get_ship_material,
    boost::function<void (int, Ogre::SceneNode*, Ogre::Entity*, const Ogre::MaterialPtr&)>
    add_ship_node_to_combat_wnd,
    boost::function<Ogre::MovableObject* (const GG::Pt&)>
    get_object_under_pt,
    boost::function<void (int, const Ogre::Vector3&, const Ogre::Quaternion&)>
    reposition_ship_node,
    boost::function<void (int)>
    remove_ship,
    boost::function<void (const Ogre::Vector3&)>
    look_at,
    GG::Flags<GG::WndFlag> flags/* = GG::INTERACTIVE | GG::DRAGABLE*/) :
    CUIWnd("Ships", GG::X(PAD), GG::GUI::GetGUI()->AppHeight() - SETUP_WND_HEIGHT - GG::Y(PAD),
           GG::X(500), SETUP_WND_HEIGHT, flags),
    m_setup_groups(setup_groups),
    m_current_setup_group(m_setup_groups.size()),
    m_setup_finished_waiting_for_server(false),
    m_dragging_placed_ship(false),
    m_button_press_on_placed_ship(INVALID_PRESS_POS),
    m_button_press_placed_ship_node(0),
    m_mouse_dragged(false),
    m_listbox(new CUIListBox(GG::X0, GG::Y0, GG::X1, GG::Y1)),
    m_redo_placements_button(new CUIButton(GG::X0, GG::Y1, GG::X1, UserString("REDO_PLACEMENTS"))),
    m_auto_place_button(new CUIButton(GG::X0, GG::Y(2), GG::X1, UserString("AUTO_PLACE_SHIPS"))),
    m_done_button(new CUIButton(GG::X0, GG::Y(3), GG::X1, UserString("DONE"))),
    m_selected_placeable_ship(0),
    m_placeable_ship_node(0),
    m_scene_manager(scene_manager),
    m_combat_universe(combat_data->m_combat_universe),
    m_intersect_mouse_with_ecliptic(intersect_mouse_with_ecliptic),
    m_get_ship_material(get_ship_material),
    m_add_ship_node_to_combat_wnd(add_ship_node_to_combat_wnd),
    m_get_object_under_pt(get_object_under_pt),
    m_reposition_ship_node(reposition_ship_node),
    m_remove_ship(remove_ship),
    m_look_at(look_at)
{
    m_listbox->SetStyle(m_listbox->Style() | GG::LIST_SINGLESEL);
    Connect(m_redo_placements_button->ClickedSignal, &CombatSetupWnd::RedoPlacementsButtonClicked, this);
    Connect(m_auto_place_button->ClickedSignal, &CombatSetupWnd::AutoPlaceButtonClicked, this);
    Connect(m_done_button->ClickedSignal, &CombatSetupWnd::DoneButtonClicked, this);

    GG::Y original_button_height = m_done_button->Height();
    GG::Y original_all_buttons_height = original_button_height * 3;

    AttachChild(m_listbox);
    AttachChild(m_redo_placements_button);
    AttachChild(m_auto_place_button);
    AttachChild(m_done_button);
    VerticalLayout();
    GetLayout()->SetRowStretch(0, Value(Height() - original_all_buttons_height));
    GetLayout()->SetRowStretch(1, Value(original_button_height));
    GetLayout()->SetRowStretch(2, Value(original_button_height));
    GetLayout()->SetRowStretch(3, Value(original_button_height));
    GetLayout()->SetCellMargin(2);

    const GG::Pt row_size = ListRowSize();

    for (PathingEngine::const_iterator it = combat_data->m_pathing_engine.begin();
            it != combat_data->m_pathing_engine.end();
            ++it) {
        if (CombatShipPtr combat_ship = boost::dynamic_pointer_cast<CombatShip>(*it)) {
            // create scene node
            Ship& ship = combat_ship->GetShip();

            // TODO: Temporary!  Serialization of CombatData currently sends
            // everything to everyone.  Fix this.
            if (!ship.OwnedBy(HumanClientApp::GetApp()->EmpireID()))
                continue;

            Ogre::SceneNode* node = GetShipNode(ship);

            if (combat_ship->position() == OpenSteer::Vec3(0.0, 0.0, 0.0)) {
                UniverseObject* o = m_combat_universe[ship.FleetID()];
                Fleet* fleet = boost::polymorphic_downcast<Fleet*>(o);
                ShipRow* row = new ShipRow(&ship, fleet, row_size.x, row_size.y);
                m_listbox->Insert(row);
            } else {
                node->setPosition(ToOgre(combat_ship->position()));
                node->setOrientation(Ogre::Quaternion(ToOgre(combat_ship->side()),
                                                      ToOgre(combat_ship->forward()),
                                                      ToOgre(combat_ship->up())));
                PlaceShip(&ship, node);
                node->setVisible(true);
            }
        }
    }

    m_redo_placements_button->Disable(m_placed_nodes.empty());
    m_auto_place_button->Disable(m_listbox->Empty());
    m_done_button->Disable(!m_listbox->Empty());

    GG::Connect(m_listbox->SelChangedSignal, &CombatSetupWnd::PlaceableShipSelected_, this);

    combat_wnd->InstallEventFilter(this);
}