Пример #1
0
void CombatLogWnd::CombatLogWndImpl::SetLog(int log_id) {
    if (!CombatLogAvailable(log_id)) {
        ErrorLogger() << "Couldn't find combat log with id: " << log_id;
        return;
    }

    m_wnd.DeleteChildren();
    GG::Layout* layout = new GG::Layout(m_wnd.UpperLeft().x, m_wnd.UpperLeft().y
                                        , m_wnd.Width(), m_wnd.Height()
                                        , 1, 1 ///< numrows, numcols
                                        , 0, 0 ///< wnd margin, cell margin
                                       );
    m_wnd.SetLayout(layout);

    const CombatLog& log = GetCombatLog(log_id);
    int client_empire_id = HumanClientApp::GetApp()->EmpireID();

    // Write Header text
    DebugLogger() << "Setting log with " << log.combat_events.size() << " events";

    TemporaryPtr<const System> system = GetSystem(log.system_id);
    const std::string& sys_name = (system ? system->PublicName(client_empire_id) : UserString("ERROR"));

    AddRow(DecorateLinkText(str(FlexibleFormat(UserString("ENC_COMBAT_LOG_DESCRIPTION_STR"))
                                % LinkTaggedIDText(VarText::SYSTEM_ID_TAG, log.system_id, sys_name)
                                % log.turn) + "\n"
                           ));
    AddRow(DecorateLinkText(UserString("COMBAT_INITIAL_FORCES")));
    AddRow(DecorateLinkText(CountsToText(CountByOwner(log.empire_ids, log.object_ids))));

    std::stringstream summary_text;
    summary_text << std::endl << UserString("COMBAT_SUMMARY_DESTROYED")
                 << std::endl << CountsToText(CountByOwner(log.empire_ids, log.destroyed_object_ids));
    AddRow(DecorateLinkText(summary_text.str()));

    // Write Logs
    for (std::vector<CombatEventPtr>::const_iterator it = log.combat_events.begin();
         it != log.combat_events.end(); ++it) {
        DebugLogger() << "event debug info: " << it->get()->DebugString();

        std::vector<GG::Wnd *> flat_logs =
            MakeCombatLogPanel(m_font->SpaceWidth()*10, client_empire_id, *it);
        for (std::vector<GG::Wnd *>::iterator log_it = flat_logs.begin();
             log_it != flat_logs.end(); ++log_it) {
            AddRow(*log_it);
        }
    }

    // Add a dummy row that the layout manager can use to add space.
    AddRow(DecorateLinkText(""));
    layout->SetRowStretch(layout->Rows() - 1, 1);

    HandleWndChanged();
}
Пример #2
0
platform_display_type insert<tab_group_t>(display_t&             display,
                                          platform_display_type& parent,
                                          tab_group_t&           element)
{
    assert (!element.control_m);

    // This probably looks odd.  The interface of tab groups in Eve is wildly
    // different from that of GG's TabWnd.  The most expedient way to get all
    // the Wnds in the right styles and still match the Eve interface was to
    // replace the built-in TabBar inside of TabWnd with one created here.

    boost::shared_ptr<GG::StyleFactory> style = GG::GUI::GetGUI()->GetStyleFactory();
    element.tab_bar_m = style->NewTabBar(GG::X0, GG::Y0, GG::X(100),
                                         style->DefaultFont(), element.color_m, element.text_color_m,
                                         element.style_m);
    element.tab_bar_m->SetMinSize(GG::Pt(element.tab_bar_m->MinSize().x, element.tab_bar_m->Height()));

    element.control_m = style->NewTabWnd(GG::X0, GG::Y0, GG::X(100), element.tab_bar_m->Height() + 20,
                                         style->DefaultFont(), element.color_m, element.text_color_m,
                                         element.style_m);

    GG::Layout* layout = element.control_m->DetachLayout();
    delete layout;

    layout = new GG::Layout(GG::X0, GG::Y0,
                            element.control_m->Width(), element.control_m->Height(),
                            2, 1);
    layout->SetRowStretch(1, 1.0);
    layout->Add(element.tab_bar_m, 0, 0);
    layout->Add(new Placeholder, 1, 0);
    element.control_m->SetLayout(layout);

    GG::Connect(element.tab_bar_m->TabChangedSignal,
                boost::bind(&tab_changed, boost::ref(element), _1));

    for (tab_group_t::tab_set_t::iterator
             first(element.items_m.begin()), last(element.items_m.end());
         first != last;
         ++first) {
        element.tab_bar_m->AddTab(first->name_m);
    }

    element.color_proxy_m.initialize(
        boost::bind(&GG::TabBar::SetColor, element.tab_bar_m, _1)
    );
    element.text_color_proxy_m.initialize(
        boost::bind(&GG::TabBar::SetTextColor, element.tab_bar_m, _1)
    );

    return display.insert(parent, element.control_m);
}
Пример #3
0
////////////////////////////////////////////
//   About
////////////////////////////////////////////
About::About():
    CUIWnd(UserString("ABOUT_WINDOW_TITLE"), GG::X(80), GG::Y(130), GG::X(600), GG::Y(500),
           GG::INTERACTIVE | GG::DRAGABLE | GG::MODAL),
    m_end_with_done(false)
{
    m_done_btn = new CUIButton(UserString("DONE"), GG::X(400), GG::Y(440), GG::X(75));
    m_license = new CUIButton(UserString("LICENSE"), GG::X(310), GG::Y(440), GG::X(75));
    m_vision = new CUIButton(UserString("VISION"), GG::X(220), GG::Y(440), GG::X(75));
    m_info = new CUIMultiEdit(GG::X(20), GG::Y(20), GG::X(550), GG::Y(400), UserString("FREEORION_VISION"), 
                              GG::MULTI_WORDBREAK | GG::MULTI_READ_ONLY,
                              ClientUI::GetFont(),
                              ClientUI::CtrlBorderColor(), ClientUI::TextColor(),
                              ClientUI::CtrlColor(), GG::INTERACTIVE);
    GG::Layout* layout = new GG::Layout(GG::X0, GG::Y0, ClientWidth(), ClientHeight(), 2, 6, 5);
    layout->SetMinimumRowHeight(1, m_license->Height() + 5);
    layout->SetRowStretch(0, 1);
    layout->Add(m_info, 0, 0, 1, 6);
    layout->Add(m_vision, 1, 3);
    layout->Add(m_license, 1, 4);
    layout->Add(m_done_btn, 1, 5);
    AttachChild(layout);

    // Read in the copyright info from a file
    boost::filesystem::ifstream fin(GetRootDataDir() / "default" / "COPYING");    // this is not GetResourceDir() / "COPYING" because if a mod or scenario is loaded that changes the settings directory, the copyright notice should be unchanged
    if (!fin.is_open()) return;
    std::string temp_str;
    while (!fin.eof()) {
        std::getline(fin, temp_str, '\n');
        m_license_str.append(temp_str);
        m_license_str.append("\n"); // To ensure new lines are read
    }
    fin.close();

    Init();
}
Пример #4
0
 virtual void        SizeMove ( const GG::Pt& ul, const GG::Pt& lr ) {
     if ( GetLayout() ) {
         GG::Layout* layout = GetLayout();
         int cols = layout->Columns();
         if ( cols > 0 ) {
             layout->SetColumnStretch ( 0, 0 );
             layout->SetMinimumColumnWidth ( 0, m_time_column_width );
         }
         if ( cols > 1 ) {
             layout->SetColumnStretch ( 1, 0 );
             layout->SetMinimumColumnWidth ( 1, m_turn_column_width );
         }
         if ( cols > 2 ) {
             layout->SetColumnStretch ( 2, 1.0 );
         }
         if ( cols > 3 ) {
             layout->SetColumnStretch ( 3, 1.0 );
         }
         if ( cols > 4 ) {
             layout->SetColumnStretch ( 4, 1.0 );
         }
     }
     GG::ListBox::Row::SizeMove ( ul, lr );
 }
Пример #5
0
ServerConnectWnd::ServerConnectWnd() : 
    CUIWnd(UserString("SCONNECT_WINDOW_TITLE"),
           (GG::GUI::GetGUI()->AppWidth() - WINDOW_WIDTH) / 2, (GG::GUI::GetGUI()->AppHeight() - WINDOW_HEIGHT) / 2,
           WINDOW_WIDTH, WINDOW_HEIGHT, GG::INTERACTIVE | GG::MODAL),
    m_host_or_join_radio_group(0),
    m_LAN_game_label(0),
    m_servers_lb(0),
    m_find_LAN_servers_bn(0),
    m_internet_game_label(0),
    m_IP_address_edit(0),
    m_player_name_edit(0),
    m_ok_bn(0),
    m_cancel_bn(0)
{
    Sound::TempUISoundDisabler sound_disabler;

    boost::shared_ptr<GG::Font> font = ClientUI::GetFont();
    GG::TextControl* player_name_label = new GG::TextControl(GG::X0, GG::Y0, GG::X1, GG::Y1, UserString("PLAYER_NAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT);
    m_player_name_edit = new CUIEdit(GG::X0, GG::Y0, GG::X1, GetOptionsDB().Get<std::string>("multiplayersetup.player-name"));
    m_host_or_join_radio_group = new GG::RadioButtonGroup(GG::X0, GG::Y0, GG::X1, GG::Y1, GG::VERTICAL);
    m_host_or_join_radio_group->AddButton(new CUIStateButton(UserString("HOST_GAME_BN"), GG::X0, GG::Y0, GG::X1, GG::Y1, GG::FORMAT_LEFT, GG::SBSTYLE_3D_RADIO));
    m_host_or_join_radio_group->AddButton(new CUIStateButton(UserString("JOIN_GAME_BN"), GG::X0, GG::Y0, GG::X1, GG::Y1, GG::FORMAT_LEFT, GG::SBSTYLE_3D_RADIO));
    m_LAN_game_label = new GG::TextControl(GG::X0, GG::Y0, UserString("LAN_GAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT);
    m_servers_lb = new CUIListBox(GG::X0, GG::Y0, GG::X1, GG::Y1);
    m_servers_lb->SetStyle(GG::LIST_NOSORT | GG::LIST_SINGLESEL);
    m_find_LAN_servers_bn = new CUIButton(UserString("REFRESH_LIST_BN"));
    m_internet_game_label = new GG::TextControl(GG::X0, GG::Y0, UserString("INTERNET_GAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT);
    m_IP_address_edit = new CUIEdit(GG::X0, GG::Y0, GG::X1, GetOptionsDB().Get<std::string>("multiplayersetup.host-address"));
    m_ok_bn = new CUIButton(UserString("OK"));
    m_cancel_bn = new CUIButton(UserString("CANCEL"));

    const GG::X OK_CANCEL_BUTTON_WIDTH(80);
    const int CONTROL_MARGIN = 5;

    GG::Layout* layout = new GG::Layout(GG::X0, GG::Y0, GG::X1, GG::Y1, 8, 4, CONTROL_MARGIN);
    layout->SetMinimumColumnWidth(0, player_name_label->MinUsableSize().x + CONTROL_MARGIN);
    layout->SetColumnStretch(1, 1.0);
    layout->SetMinimumColumnWidth(2, OK_CANCEL_BUTTON_WIDTH + CONTROL_MARGIN);
    layout->SetMinimumColumnWidth(3, OK_CANCEL_BUTTON_WIDTH + CONTROL_MARGIN);
    layout->SetMinimumRowHeight(0, m_player_name_edit->Height() + CONTROL_MARGIN);
    layout->SetMinimumRowHeight(1, m_host_or_join_radio_group->MinUsableSize().y);
    layout->SetMinimumRowHeight(2, m_LAN_game_label->Height() + (2 * CONTROL_MARGIN));
    layout->SetRowStretch(3, 1.0);
    layout->SetMinimumRowHeight(4, m_find_LAN_servers_bn->Height() + CONTROL_MARGIN);
    layout->SetMinimumRowHeight(5, m_internet_game_label->Height() + CONTROL_MARGIN);
    layout->SetMinimumRowHeight(6, m_IP_address_edit->Height() + CONTROL_MARGIN);
    layout->SetMinimumRowHeight(7, m_ok_bn->Height() + CONTROL_MARGIN);

    layout->Add(player_name_label, 0, 0, 1, 1, GG::ALIGN_VCENTER);
    layout->Add(m_player_name_edit, 0, 1, 1, 3, GG::ALIGN_VCENTER);
    layout->Add(m_host_or_join_radio_group, 1, 0, 1, 4);
    layout->Add(m_LAN_game_label, 2, 0, 1, 4, GG::ALIGN_BOTTOM);
    layout->Add(m_servers_lb, 3, 0, 1, 4);
    layout->Add(m_find_LAN_servers_bn, 4, 3);
    layout->Add(m_internet_game_label, 5, 0, 1, 4);
    layout->Add(m_IP_address_edit, 6, 0, 1, 4);
    layout->Add(m_ok_bn, 7, 2);
    layout->Add(m_cancel_bn, 7, 3);

    SetLayout(layout);

    m_LAN_servers = HumanClientApp::GetApp()->Networking().DiscoverLANServers();
    Init();
}