コード例 #1
0
ファイル: System.cpp プロジェクト: J-d-H/freeorion
StarType System::NextYoungerStarType() const {
    if (m_star <= INVALID_STAR_TYPE || m_star >= NUM_STAR_TYPES)
        return INVALID_STAR_TYPE;
    if (m_star >= STAR_RED)
        return m_star;  // STAR_RED, STAR_NEUTRON, STAR_BLACK, STAR_NONE
    if (m_star <= STAR_BLUE)
        return STAR_BLUE;
    return StarType(m_star - 1);
}
コード例 #2
0
StarType ModeratorActionsWnd::StarTypeFromIndex(std::size_t i) const {
    if (i == static_cast<std::size_t>(-1) || i >= NUM_STAR_TYPES)
        return STAR_BLUE;
    return StarType(i);     // assumes first enum and first index are value 0, and that items in list are in same order as enum values
}
コード例 #3
0
////////////////////////////////////////////////
// ModeratorActionsWnd
////////////////////////////////////////////////
ModeratorActionsWnd::ModeratorActionsWnd(GG::X w, GG::Y h) :
    CUIWnd(UserString("MODERATOR"), GG::X1, GG::Y1, w - 1, h - 1, GG::ONTOP | GG::INTERACTIVE | GG::DRAGABLE | GG::RESIZABLE | CLOSABLE | PINABLE ),
    m_actions_enabled(true),
    m_selected_action(MAS_NoAction),
    m_no_action_button(0),
    m_create_system_button(0),
    m_star_type_drop(0),
    m_create_planet_button(0),
    m_planet_type_drop(0),
    m_planet_size_drop(0),
    m_delete_object_button(0),
    m_set_owner_button(0),
    m_empire_drop(0),
    m_add_starlane_button(0),
    m_remove_starlane_button(0)
{
    ClientUI* ui = ClientUI::GetClientUI();
    GG::Flags<GG::GraphicStyle> style = GG::GRAPHIC_CENTER | GG::GRAPHIC_VCENTER | GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE;

    boost::filesystem::path button_texture_dir = ClientUI::ArtDir() / "icons" / "buttons";

    // button for no action
    m_no_action_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "nomoderatoraction_mouseover.png")));

    m_no_action_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_no_action_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_NONE"), UserString("MOD_NONE"))));
    AttachChild(m_no_action_button);
    GG::Connect(m_no_action_button->LeftClickedSignal,  &ModeratorActionsWnd::NoActionClicked,      this);

    // button for create system and droplist to select system type to create
    m_create_system_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstar_mouseover.png")));

    m_create_system_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_create_system_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_CREATE_SYSTEM"), UserString("MOD_CREATE_SYSTEM"))));
    AttachChild(m_create_system_button);

    GG::Connect(m_create_system_button->LeftClickedSignal,  &ModeratorActionsWnd::CreateSystemClicked,  this);
    m_star_type_drop = new CUIDropDownList(6);
    m_star_type_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT));
    for (StarType star_type = STAR_BLUE; star_type != NUM_STAR_TYPES; star_type = StarType(star_type + 1)) {
        boost::shared_ptr<GG::Texture> disc_texture = ui->GetModuloTexture(
            ClientUI::ArtDir() / "stars", ClientUI::StarTypeFilePrefixes()[star_type], 0);
        GG::DropDownList::Row* row = new GG::DropDownList::Row();
        GG::StaticGraphic* icon = new GG::StaticGraphic(disc_texture, style);
        icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT));
        row->push_back(icon);
        m_star_type_drop->Insert(row);
    }
    m_star_type_drop->Select(m_star_type_drop->begin());        // default select first type
    GG::Connect(m_star_type_drop->SelChangedSignal,     &ModeratorActionsWnd::StarTypeSelected,     this);

    // button for create planet and droplists to select planet type and size
    m_create_planet_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addplanet_mouseover.png")));

    m_create_planet_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_create_planet_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_CREATE_PLANET"), UserString("MOD_CREATE_PLANET"))));
    AttachChild(m_create_planet_button);
    GG::Connect(m_create_planet_button->LeftClickedSignal,  &ModeratorActionsWnd::CreatePlanetClicked,  this);

    m_planet_type_drop = new CUIDropDownList(6);
    m_planet_type_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT));
    for (PlanetType planet_type = PT_SWAMP; planet_type != NUM_PLANET_TYPES; planet_type = PlanetType(planet_type + 1)) {
        boost::shared_ptr<GG::Texture> texture = ClientUI::PlanetIcon(planet_type);
        GG::DropDownList::Row* row = new GG::DropDownList::Row();
        GG::StaticGraphic* icon = new GG::StaticGraphic(texture, style);
        icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT));
        row->push_back(icon);
        m_planet_type_drop->Insert(row);
    }
    m_planet_type_drop->Select(m_planet_type_drop->begin());    // default select first type
    GG::Connect(m_planet_type_drop->SelChangedSignal,   &ModeratorActionsWnd::PlanetTypeSelected,   this);

    m_planet_size_drop = new CUIDropDownList(6);
    m_planet_size_drop->Resize(GG::Pt(DROP_WIDTH, CONTROL_HEIGHT));
    for (PlanetSize planet_size = SZ_TINY; planet_size != NUM_PLANET_SIZES; planet_size = PlanetSize(planet_size + 1)) {
        boost::shared_ptr<GG::Texture> texture = ClientUI::PlanetSizeIcon(planet_size);
        GG::DropDownList::Row* row = new GG::DropDownList::Row();
        GG::StaticGraphic* icon = new GG::StaticGraphic(texture, style);
        icon->Resize(GG::Pt(CONTROL_WIDTH, CONTROL_HEIGHT));
        row->push_back(icon);
        m_planet_size_drop->Insert(row);
    }
    GG::DropDownList::iterator it = m_planet_size_drop->begin();
    std::advance(it, 2);
    m_planet_size_drop->Select(it); // default select 3rd size (should be medium?)
    GG::Connect(m_planet_size_drop->SelChangedSignal,   &ModeratorActionsWnd::PlanetSizeSelected,   this);

    // button for destroying object
    m_delete_object_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "delete_mouseover.png")));

    m_delete_object_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_delete_object_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_DESTROY"), UserString("MOD_DESTROY"))));
    AttachChild(m_delete_object_button);
    GG::Connect(m_delete_object_button->LeftClickedSignal,  &ModeratorActionsWnd::DeleteObjectClicked,  this);

    // button for setting owner
    m_set_owner_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "setowner_mouseover.png")));

    m_set_owner_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_set_owner_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_SET_OWNER"), UserString("MOD_SET_OWNER"))));
    AttachChild(m_set_owner_button);

    GG::Connect(m_set_owner_button->LeftClickedSignal,      &ModeratorActionsWnd::SetOwnerClicked,      this);
    m_empire_drop = new CUIDropDownList(6);
    m_empire_drop->SetStyle(GG::LIST_NOSORT);
    // empires added later when gamestate info available
    GG::Connect(m_empire_drop->SelChangedSignal,        &ModeratorActionsWnd::EmpireSelected,       this);

    // button for creating starlane
    m_add_starlane_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "addstarlane_mouseover.png")));

    m_add_starlane_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_add_starlane_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_ADD_STARLANE"), UserString("MOD_ADD_STARLANE"))));
    AttachChild(m_add_starlane_button);
    GG::Connect(m_add_starlane_button->LeftClickedSignal,&ModeratorActionsWnd::AddStarlane,         this);

    // button for removing starlane
    m_remove_starlane_button = new CUIButton(
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane_clicked.png")),
        GG::SubTexture(ClientUI::GetTexture(button_texture_dir / "removestarlane_mouseover.png")));

    m_remove_starlane_button->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay"));
    m_remove_starlane_button->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>(
        new TextBrowseWnd(UserString("MOD_REMOVE_STARLANE"), UserString("MOD_REMOVE_STARLANE"))));
    AttachChild(m_remove_starlane_button);
    GG::Connect(m_remove_starlane_button->LeftClickedSignal,&ModeratorActionsWnd::RemoveStarlane,   this);

    DoLayout();
}