Search in sources :

Example 1 with ISolderPackApi

use of net.technicpack.solder.ISolderPackApi in project LauncherV3 by TechnicPack.

the class ModpackSelector method selectWidget.

protected void selectWidget(ModpackWidget widget) {
    if (selectedWidget != null)
        selectedWidget.setIsSelected(false);
    selectedWidget = widget;
    selectedWidget.setIsSelected(true);
    selectedWidget.getModpack().select();
    selectedWidget.scrollRectToVisible(new Rectangle(selectedWidget.getSize()));
    if (modpackInfoPanel != null)
        modpackInfoPanel.setModpack(widget.getModpack());
    final ModpackWidget refreshWidget = selectedWidget;
    Thread thread = new Thread("Modpack redownload " + selectedWidget.getModpack().getDisplayName()) {

        @Override
        public void run() {
            try {
                PlatformPackInfo updatedInfo = platformApi.getPlatformPackInfo(refreshWidget.getModpack().getName());
                PackInfo infoToUse = updatedInfo;
                if (updatedInfo != null && updatedInfo.hasSolder()) {
                    try {
                        ISolderPackApi solderPack = solderApi.getSolderPack(updatedInfo.getSolder(), updatedInfo.getName(), solderApi.getMirrorUrl(updatedInfo.getSolder()));
                        infoToUse = new CombinedPackInfo(solderPack.getPackInfo(), updatedInfo);
                    } catch (RestfulAPIException ex) {
                    }
                }
                if (infoToUse != null)
                    refreshWidget.getModpack().setPackInfo(infoToUse);
                EventQueue.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        if (modpackInfoPanel != null)
                            modpackInfoPanel.setModpackIfSame(refreshWidget.getModpack());
                        if (refreshWidget.getModpack().hasRecommendedUpdate()) {
                            refreshWidget.setToolTipText(resources.getString("launcher.packselector.updatetip"));
                        } else {
                            refreshWidget.setToolTipText(null);
                        }
                        iconRepo.refreshRetry(refreshWidget.getModpack());
                        refreshWidget.updateFromPack(iconRepo.startImageJob(refreshWidget.getModpack()));
                        EventQueue.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                revalidate();
                                repaint();
                            }
                        });
                    }
                });
            } catch (RestfulAPIException ex) {
                ex.printStackTrace();
                return;
            }
        }
    };
    thread.start();
}
Also used : RestfulAPIException(net.technicpack.rest.RestfulAPIException) PlatformPackInfo(net.technicpack.platform.io.PlatformPackInfo) CombinedPackInfo(net.technicpack.launchercore.modpacks.packinfo.CombinedPackInfo) CombinedPackInfo(net.technicpack.launchercore.modpacks.packinfo.CombinedPackInfo) PlatformPackInfo(net.technicpack.platform.io.PlatformPackInfo) PackInfo(net.technicpack.rest.io.PackInfo) ISolderPackApi(net.technicpack.solder.ISolderPackApi) ModpackWidget(net.technicpack.launcher.ui.controls.modpacks.ModpackWidget)

Example 2 with ISolderPackApi

use of net.technicpack.solder.ISolderPackApi in project LauncherV3 by TechnicPack.

the class CachedSolderApi method getSolderPack.

@Override
public ISolderPackApi getSolderPack(String solderRoot, String modpackSlug, String mirrorUrl) throws RestfulAPIException {
    CacheTuple tuple = new CacheTuple(solderRoot, modpackSlug, mirrorUrl);
    ISolderPackApi pack = packs.getIfPresent(tuple);
    if (pack == null) {
        pack = new CachedSolderPackApi(directories, innerApi.getSolderPack(solderRoot, modpackSlug, mirrorUrl), cacheInSeconds, modpackSlug);
        packs.put(tuple, pack);
    }
    return pack;
}
Also used : ISolderPackApi(net.technicpack.solder.ISolderPackApi)

Example 3 with ISolderPackApi

use of net.technicpack.solder.ISolderPackApi in project LauncherV3 by TechnicPack.

the class HttpSolderApi method internalGetPublicSolderPacks.

@Override
public Collection<SolderPackInfo> internalGetPublicSolderPacks(String solderRoot, ISolderApi packFactory) throws RestfulAPIException {
    LinkedList<SolderPackInfo> allPackApis = new LinkedList<SolderPackInfo>();
    String allPacksUrl = solderRoot + "modpack?include=full&cid=" + clientId;
    FullModpacks technic = RestObject.getRestObject(FullModpacks.class, allPacksUrl);
    for (SolderPackInfo info : technic.getModpacks().values()) {
        ISolderPackApi solder = packFactory.getSolderPack(solderRoot, info.getName(), technic.getMirrorUrl());
        info.setSolder(solder);
        allPackApis.add(info);
    }
    return allPackApis;
}
Also used : ISolderPackApi(net.technicpack.solder.ISolderPackApi) FullModpacks(net.technicpack.solder.io.FullModpacks) SolderPackInfo(net.technicpack.solder.io.SolderPackInfo) LinkedList(java.util.LinkedList)

Example 4 with ISolderPackApi

use of net.technicpack.solder.ISolderPackApi in project LauncherV3 by TechnicPack.

the class PlatformPackInfoRepository method getInfoFromPlatformInfo.

protected PackInfo getInfoFromPlatformInfo(PlatformPackInfo platformInfo) throws RestfulAPIException {
    if (platformInfo != null && platformInfo.hasSolder()) {
        try {
            ISolderPackApi solderPack = solder.getSolderPack(platformInfo.getSolder(), platformInfo.getName(), solder.getMirrorUrl(platformInfo.getSolder()));
            SolderPackInfo solderInfo = solderPack.getPackInfoForBulk();
            if (solderInfo == null)
                return platformInfo;
            else
                return new CombinedPackInfo(solderInfo, platformInfo);
        } catch (RestfulAPIException ex) {
            ex.printStackTrace();
            return platformInfo;
        }
    } else {
        return platformInfo;
    }
}
Also used : RestfulAPIException(net.technicpack.rest.RestfulAPIException) CombinedPackInfo(net.technicpack.launchercore.modpacks.packinfo.CombinedPackInfo) ISolderPackApi(net.technicpack.solder.ISolderPackApi) SolderPackInfo(net.technicpack.solder.io.SolderPackInfo)

Aggregations

ISolderPackApi (net.technicpack.solder.ISolderPackApi)4 CombinedPackInfo (net.technicpack.launchercore.modpacks.packinfo.CombinedPackInfo)2 RestfulAPIException (net.technicpack.rest.RestfulAPIException)2 SolderPackInfo (net.technicpack.solder.io.SolderPackInfo)2 LinkedList (java.util.LinkedList)1 ModpackWidget (net.technicpack.launcher.ui.controls.modpacks.ModpackWidget)1 PlatformPackInfo (net.technicpack.platform.io.PlatformPackInfo)1 PackInfo (net.technicpack.rest.io.PackInfo)1 FullModpacks (net.technicpack.solder.io.FullModpacks)1