コード例 #1
0
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);
}
コード例 #2
0
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);
}
コード例 #3
0
ファイル: screen_io.cpp プロジェクト: Grunaka/colobot
// Writes the scene.
void CScreenIO::IOWriteScene()
{
    CWindow*    pw;
    CList*      pl;
    CEdit*      pe;
    char        info[100];

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

    int sel = pl->GetSelect();
    if ( sel == -1 ) return;

    pe->GetText(info, 100);

    m_interface->DeleteControl(EVENT_WINDOW5);

    std::string dir;
    if (static_cast<unsigned int>(sel) >= m_saveList.size())
    {
        dir = m_main->GetPlayerProfile()->GetSaveFile("save"+clearName(info));
    }
    else
    {
        dir = m_saveList.at(sel);
    }

    m_main->GetPlayerProfile()->SaveScene(dir, info);
}
コード例 #4
0
void CScreenPlayerSelect::UpdateNameControl()
{
    CWindow*    pw;
    CList*      pl;
    CButton*    pb;
    CEdit*      pe;
    std::string name;
    int         total, 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;

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

    pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NDELETE));
    if ( pb != nullptr )
    {
        pb->SetState(STATE_ENABLE, total>0 && sel!=-1);
    }

    pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NOK));
    if ( pb != nullptr )
    {
        pb->SetState(STATE_ENABLE, !name.empty() || sel!=-1);
    }

    pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PERSO));
    if ( pb != nullptr )
    {
        pb->SetState(STATE_ENABLE, !name.empty() || sel!=-1);
    }
}
コード例 #5
0
bool CScreenPlayerSelect::NameCreate()
{
    CWindow*    pw;
    CEdit*      pe;

    GetLogger()->Info("Creating new player\n");
    pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
    if ( pw == nullptr )  return false;
    pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
    if ( pe == nullptr )  return false;

    std::string name;
    name = pe->GetText(100);
    if ( name.empty() )
    {
        m_sound->Play(SOUND_TZOING);
        return false;
    }

    m_main->SelectPlayer(name);
    m_main->GetPlayerProfile()->Create();

    return true;
}