当前位置: 首页>>代码示例>>C++>>正文


C++ CList::GetItemName方法代码示例

本文整理汇总了C++中CList::GetItemName方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::GetItemName方法的具体用法?C++ CList::GetItemName怎么用?C++ CList::GetItemName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CList的用法示例。


在下文中一共展示了CList::GetItemName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NameDelete

void CScreenPlayerSelect::NameDelete()
{
    CWindow* pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if (pw == nullptr) return;
    CList* pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
    if (pl == nullptr) return;

    int sel = pl->GetSelect();
    if (sel == -1)
    {
        m_sound->Play(SOUND_TZOING);
        return;
    }

    std::string gamer = pl->GetItemName(sel);

    m_main->SelectPlayer(gamer);
    if (!m_main->GetPlayerProfile()->Delete())
    {
        m_sound->Play(SOUND_TZOING);
        return;
    }

    pl->SetSelect(-1);
    CEdit* pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
    if (pe != nullptr)
    {
        pe->SetText("");
    }

    ReadNameList();
    UpdateNameList();
    UpdateNameControl();
}
开发者ID:2asoft,项目名称:colobot,代码行数:34,代码来源:screen_player_select.cpp

示例2: NameSelect

void CScreenPlayerSelect::NameSelect()
{
    CWindow*    pw;
    CList*      pl;
    CEdit*      pe;
    std::string name;
    int         sel;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if ( pw == nullptr )  return;
    pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
    if ( pl == nullptr )  return;
    pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
    if ( pe == nullptr )  return;

    name = pe->GetText(100);
    sel  = pl->GetSelect();

    if ( sel == -1 )
    {
        NameCreate();
    }
    else
    {
        m_main->SelectPlayer(pl->GetItemName(sel));
    }

    m_main->ChangePhase(PHASE_MAIN_MENU);
}
开发者ID:2asoft,项目名称:colobot,代码行数:29,代码来源:screen_player_select.cpp

示例3: UpdateNameList

void CScreenPlayerSelect::UpdateNameList()
{
    CWindow*    pw;
    CList*      pl;
    CEdit*      pe;
    std::string name;
    int         total, i;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if ( pw == nullptr )  return;
    pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
    if ( pl == nullptr )  return;
    pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
    if ( pe == nullptr )  return;

    name = pe->GetText(100);
    total = pl->GetTotal();

    for ( i=0 ; i<total ; i++ )
    {
        // TODO: stricmp?
        if ( name == pl->GetItemName(i) )
        {
            pl->SetSelect(i);
            pl->ShowSelect(false);
            return;
        }
    }

    pl->SetSelect(-1);
}
开发者ID:2asoft,项目名称:colobot,代码行数:31,代码来源:screen_player_select.cpp

示例4: UpdateNameEdit

void CScreenPlayerSelect::UpdateNameEdit()
{
    CWindow*    pw;
    CList*      pl;
    CEdit*      pe;
    std::string name;
    int         sel;

    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if ( pw == nullptr )  return;
    pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
    if ( pl == nullptr )  return;
    pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
    if ( pe == nullptr )  return;

    sel = pl->GetSelect();
    if ( sel == -1 )
    {
        pe->SetText("");
        pe->SetCursor(0, 0);
    }
    else
    {
        name = pl->GetItemName(sel);
        pe->SetText(name.c_str());
        pe->SetCursor(name.length(), 0);
    }

    UpdateNameControl();
}
开发者ID:2asoft,项目名称:colobot,代码行数:30,代码来源:screen_player_select.cpp

示例5: EventProcess

bool CScreenPlayerSelect::EventProcess(const Event &event)
{
    CWindow* pw;
    CList*   pl;
    std::string name;
    std::string gamer;

    switch( event.type )
    {
        case EVENT_KEY_DOWN:
        {
            auto data = event.GetData<KeyEventData>();
            if (data->key == KEY(RETURN) || data->key == KEY(ESCAPE))
            {
                NameSelect();
            }
            break;
        }

        case EVENT_INTERFACE_NEDIT:
            UpdateNameList();
            UpdateNameControl();
            break;

        case EVENT_INTERFACE_NLIST:
            UpdateNameEdit();
            break;

        case EVENT_INTERFACE_NOK:
            NameSelect();
            break;

        case EVENT_INTERFACE_PERSO:
            NameSelect();
            m_main->ChangePhase(PHASE_APPERANCE);
            break;

        case EVENT_INTERFACE_NDELETE:
            pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
            if ( pw == nullptr )  break;
            pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
            if ( pl == nullptr )  break;

            GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
            gamer = pl->GetItemName(pl->GetSelect());
            m_dialog->StartQuestion(
                StrUtils::Format(name.c_str(), gamer.c_str()), true, false, false,
                [&]()
                {
                    NameDelete();
                }
            );
            break;

        default:
            return true;
    }
    return false;
}
开发者ID:2asoft,项目名称:colobot,代码行数:59,代码来源:screen_player_select.cpp


注:本文中的CList::GetItemName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。