Пример #1
0
iwMusicPlayer::~iwMusicPlayer()
{
    // Playlist ggf. speichern, die ausgewählt ist, falls eine ausgewählt ist
    unsigned short selection = GetCtrl<ctrlComboBox>(2)->GetSelection();


    // Entsprechende Datei speichern
    if(selection != 0xFFFF)
    {
        Playlist pl;
        pl.ReadMusicPlayer(this);

        std::string str(GetCtrl<ctrlComboBox>(2)->GetText(selection));

        // RTTR-Playlisten dürfen nicht gelöscht werden
        if(str == "S2_Standard")
            return;

        if(!pl.SaveAs(GetFullPlaylistPath(str), true))
            // Fehler, konnte nicht gespeichert werden
            WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("The specified file couldn't be saved!"), this, MSB_OK, MSB_EXCLAMATIONRED));
    }


    // Entsprechenden Dateipfad speichern
    if(selection != 0xFFFF)
        SETTINGS.sound.playlist = GetCtrl<ctrlComboBox>(2)->GetText(selection);

    // Werte in Musikplayer bringen
    if(changed)
    {
        MUSICPLAYER.GetPlaylist().ReadMusicPlayer(this);
        MUSICPLAYER.Play();
    }
}
Пример #2
0
void iwMusicPlayer::Msg_Input(const unsigned int win_id, const std::string& msg)
{
    switch(win_id)
    {
            // Add Track - Window
        case 0:
        {
            bool valid = false;

            // Existiert diese Datei nicht?
            if(ValidateFile(msg))
                valid = true;
            else
            {
                // Evtl ein Siedlerstück ("sNN")?
                if(msg.length() == 3)
                {
                    if(atoi(msg.substr(1).c_str()) <= 14)
                        valid = true;
                }
            }

            // Gültiges Siedlerstück?
            if(valid)
            {
                // Hinzufügen
                GetCtrl<ctrlList>(0)->AddString(msg);
                changed = true;
            }
            else
                WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("The specified file couldn't be opened!"), this, MSB_OK, MSB_EXCLAMATIONRED));

        } break;
        // Add Playlist
        case 1:
        {
            bool valid = true;

            // Ungültige Namen ausschließen
            if(msg.length() == 0) valid = false;
            else if(!((msg[0] >= 'a' && msg[0] <= 'z') || (msg[0] >= 'A' && msg[0] <= 'Z'))) valid = false;

            Playlist pl;
            if(!pl.SaveAs(GetFullPlaylistPath(msg), true))
                valid = false;

            if(valid)
            {
                // Combobox updaten
                UpdatePlaylistCombo(msg);
                changed = true;
            }
            else
            {
                // Fehler, konnte nicht gespeichert werden
                WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("The specified file couldn't be saved!"), this, MSB_OK, MSB_EXCLAMATIONRED));
            }
        } break;
        // Add Track directory of tracks - Window
        case 2:
        {
            std::list<std::string> lst;
            ListDir(msg + "/*.ogg", false, NULL, NULL, &lst);

            for(std::list<std::string>::iterator it = lst.begin(); it != lst.end(); ++it)
                GetCtrl<ctrlList>(0)->AddString(*it);

            changed = true;

        } break;

    }
}