Search in sources :

Example 6 with MusicList

use of main.music.entity.MusicList in project Eidolons by IDemiurge.

the class MusicMouseListener method playM3uList.

public static void playM3uList(String listPath, PLAY_MODE playMode) {
    File file = new File(listPath);
    if (playMode != null) {
        if (playMode != PLAY_MODE.NORMAL) {
            // getList()
            List<Track> tracks = MusicCore.getTracks(listPath);
            String newPath = AHK_Master.SYSTEM_LISTS_FOLDER + "Play Mode Gen\\ " + playMode.toString() + " " + StringMaster.getLastPathSegment(StringMaster.cropFormat(listPath)) + // getList().getName()
            ".m3u";
            tracks = getTracksForPlayMode(playMode, tracks);
            String content = M3uGenerator.getM3uForTracks(tracks);
            FileManager.write(content, newPath);
            file = new File(newPath);
        }
    }
    try {
        Desktop.getDesktop().open(file);
        MusicList playList = MusicCore.findList(StringMaster.cropFormat(file.getName()));
        if (!MusicCore.getLastPlayed().contains(playList)) {
            MusicCore.getLastPlayed().add(playList);
        }
        AHK_Master.getPanel().getControlPanel().refresh();
    // Runtime.getRuntime().exec(function.replaceFirst("Run ", ""));
    } catch (IOException e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
}
Also used : IOException(java.io.IOException) MusicList(main.music.entity.MusicList) File(java.io.File) Track(main.music.entity.Track)

Example 7 with MusicList

use of main.music.entity.MusicList in project Eidolons by IDemiurge.

the class MusicCore method getGroupedView.

public static MusicListPanel getGroupedView(int option, Class<?> constClass) {
    if (option == -1) {
        return null;
    }
    PROPERTY filterProp = ContentManager.getPROP(constClass.getSimpleName());
    // String[] array = (AHK_Master.qwerty + " " +
    // AHK_Master.qwerty.substring(1).toUpperCase() + " 123")
    // .split(" ");
    String viewName = "All " + StringMaster.getWellFormattedString(constClass.getSimpleName());
    Map<String, List<String>> map = new XLinkedMap<>();
    List<String> musicConsts = EnumMaster.getEnumConstantNames(constClass);
    if (option != 0) {
        musicConsts = getMusicConsts(constClass, option);
        viewName = getViewName(constClass, option);
    }
    Map<ObjType, String> multiPropMap = new HashMap<>();
    loop: for (String g : musicConsts) {
        // map.
        List<String> list = new ArrayList<>();
        // for (MusicList musList : listTypeMap.values()) {
        typeLoop: for (ObjType type : DataManager.getTypes(AT_OBJ_TYPE.MUSIC_LIST)) {
            if (type.checkProperty(filterProp, g)) {
                if (filterProp.isContainer()) {
                    containerLoop: for (String sub : StringMaster.open(type.getProperty(filterProp))) {
                        for (String c : musicConsts) {
                            if (StringMaster.compare(c, sub)) {
                                if (c.equalsIgnoreCase(g)) {
                                    break containerLoop;
                                } else {
                                    multiPropMap.put(type, c);
                                    continue typeLoop;
                                }
                            }
                        }
                    }
                }
                list.add(AHK_Master.getScriptLineForList(type));
            }
        }
        map.put(g, list);
    }
    for (ObjType sub : multiPropMap.keySet()) {
        for (String c : map.keySet()) {
            if (multiPropMap.get(sub).equals(c)) {
                map.get(c).add(AHK_Master.getScriptLineForList(sub));
            }
        }
    }
    for (String sub : map.keySet()) {
        map.put(sub, new ArrayList<>(new LinkedHashSet<>(map.get(sub))));
    }
    // TODO adapt to max list size also
    int wrap = 5 - map.size() / 2;
    MusicListPanel musicListPanel = new MusicListPanel("", null);
    G_Panel view = // AHK_Master.getPanel()
    musicListPanel.initView(map, false, wrap, musicConsts);
    musicListPanel.setView(view);
    view.setName(viewName);
    return musicListPanel;
}
Also used : PROPERTY(main.content.values.properties.PROPERTY) XLinkedMap(main.data.XLinkedMap) G_Panel(main.swing.generic.components.G_Panel) ObjType(main.entity.type.ObjType) MusicListPanel(main.music.gui.MusicListPanel) MusicList(main.music.entity.MusicList) List(java.util.List)

Example 8 with MusicList

use of main.music.entity.MusicList in project Eidolons by IDemiurge.

the class MusicListMaster method newList.

public static void newList(MusicList list, boolean alt) {
    boolean fromSelected = !alt && list != null;
    /*
         * 1) select type -> music list
		 * 2) select via click
		 * 3) select genre -> track add dialog 
		 *  
		 */
    // create m3u in Custom ? hotkey?
    // addType -> save
    // what View will it belong to?
    // M3uGenerator.generateCustomM3Us()
    ObjType type = null;
    String tracks = "";
    String name = "";
    if (fromSelected) {
        if (!MusicMouseListener.getSelectedLists().isEmpty()) {
            name = "Merged ";
            for (MusicList sub : MusicMouseListener.getSelectedLists()) {
                tracks += sub.getProperty(AT_PROPS.TRACKS, true) + ";";
                name += sub.getName() + " ";
            }
        } else if (!MusicMouseListener.getSelectedTracks().isEmpty()) {
            // TODO
            name = (NameMaster.getUniqueVersionedName("Track Group", AT_OBJ_TYPE.MUSIC_LIST));
            tracks = StringMaster.constructEntityNameContainer(MusicMouseListener.getSelectedTracks());
        } else {
            type = new ObjType(list.getType());
        }
    } else {
    // type = new ObjType(typeName, AT_OBJ_TYPE.MUSIC_LIST);
    }
    if (DialogMaster.confirm("Manual Edit?")) {
        GenericListChooser.setStaticTYPE(AT_OBJ_TYPE.TRACK);
        tracks = ListChooser.chooseStrings(StringMaster.openContainer(tracks));
    } else {
    // if (DialogMaster.confirm("Apply transformation?")){
    // int option = DialogMaster.optionChoice("", "Shuffle",
    // "Slice", "Criss-Cross");
    // //TODO
    // }
    }
    if (type == null) {
        if (DialogMaster.confirm("Input Name?")) {
            name = DialogMaster.inputText("Input Name!", name);
        }
        type = new ObjType(name, AT_OBJ_TYPE.MUSIC_LIST);
    }
    type.setProperty(AT_PROPS.TRACKS, tracks);
    String value = AHK_Master.CUSTOM_LISTS_FOLDER + type.getName() + ".m3u";
    type.setProperty(AT_PROPS.PATH, value);
    if (list != null) {
        type.setProperty(G_PROPS.HOTKEY, list.getProperty(G_PROPS.HOTKEY));
    } else {
        DialogMaster.inputText("HOTKEY?", "+#^!" + name.charAt(0));
    }
    if (list != null) {
        value = list.getProperty(AT_PROPS.MUSIC_TYPE);
        type.setProperty(AT_PROPS.MUSIC_TYPE, value);
        value = list.getProperty(AT_PROPS.MUSIC_GENRE);
        type.setProperty(AT_PROPS.MUSIC_GENRE, value);
    }
    list = new MusicList(type);
    // list.setName(name)
    // MusicCore.getList(name, keyPart, funcPart)
    DataManager.addType(type);
    MusicCore.saveList(list);
    MusicCore.saveAll();
    DialogMaster.inform("Created " + type.getName());
}
Also used : ObjType(main.entity.type.ObjType) MusicList(main.music.entity.MusicList)

Example 9 with MusicList

use of main.music.entity.MusicList in project Eidolons by IDemiurge.

the class MusicKeyMaster method playFromGroupHotkey.

protected void playFromGroupHotkey(int aIdentifier, boolean random) {
    int i = aIdentifier % 1000;
    if (aIdentifier >= 3000) {
        random = false;
        aIdentifier -= 2000;
    }
    boolean tag = aIdentifier >= 2000;
    Object c = tag ? MUSIC_TAG_GROUPS.values()[i] : MUSIC_TYPE.values()[i];
    List<ObjType> types;
    if (random) {
        types = new ArrayList<>(DataManager.getTypes(AT_OBJ_TYPE.MUSIC_LIST));
        Collections.shuffle(types);
    } else {
        types = new ArrayList<>();
    }
    for (ObjType type : random ? types : DataManager.getTypes(AT_OBJ_TYPE.MUSIC_LIST)) {
        if (checkRandomGroup(type, c, tag, random)) {
            if (random) {
                try {
                    new MusicList(type).play();
                    return;
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            } else {
                types.add(type);
            }
        }
    }
    ObjType type = ListChooser.chooseType(types);
    if (type != null) {
        new MusicList(type).play();
    }
}
Also used : ObjType(main.entity.type.ObjType) MusicList(main.music.entity.MusicList)

Example 10 with MusicList

use of main.music.entity.MusicList in project Eidolons by IDemiurge.

the class M3uMaster method exportListsIntoFolder.

public static void exportListsIntoFolder(String path, PROPERTY p, boolean empty) {
    for (ObjType type : DataManager.getTypes(AT_OBJ_TYPE.MUSIC_LIST)) {
        if (type.checkProperty(AT_PROPS.MUSIC_TAGS)) {
            continue;
        }
        empty = false;
        String filepath = path;
        String content = "";
        if (!empty) {
            try {
                content = M3uGenerator.getM3uForList(new MusicList(type));
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
                continue;
            }
        }
        if (p != null) {
            if (p.isContainer()) {
                for (String sub : StringMaster.open(type.getProperty(p))) {
                    FileManager.write(content, path + sub + "\\" + type.getName() + ".m3u");
                }
                continue;
            } else {
                filepath += (type.getProperty(p)).replace(";", "") + "\\";
            }
        }
        FileManager.write(content, filepath + type.getName() + ".m3u");
    }
}
Also used : ObjType(main.entity.type.ObjType) MusicList(main.music.entity.MusicList)

Aggregations

MusicList (main.music.entity.MusicList)10 ObjType (main.entity.type.ObjType)7 Track (main.music.entity.Track)2 File (java.io.File)1 IOException (java.io.IOException)1 List (java.util.List)1 VALUE (main.content.VALUE)1 PROPERTY (main.content.values.properties.PROPERTY)1 XLinkedMap (main.data.XLinkedMap)1 MusicListPanel (main.music.gui.MusicListPanel)1 G_Panel (main.swing.generic.components.G_Panel)1