enable download resoucepack from modrinth
This commit is contained in:
parent
681a6ceb1c
commit
4a103f3fc8
|
@ -25,7 +25,7 @@ public class DownloadPageManager extends PageManager {
|
|||
private InstallVersionPage installVersionPage;
|
||||
private ModpackDownloadPage downloadModpackPage;
|
||||
private ModDownloadPage downloadModPage;
|
||||
private DownloadPage downloadResourcePackPage;
|
||||
private ResourcePackDownloadPage downloadResourcePackPage;
|
||||
private DownloadPage downloadWorldPage;
|
||||
|
||||
public static DownloadPageManager getInstance() {
|
||||
|
@ -45,7 +45,7 @@ public class DownloadPageManager extends PageManager {
|
|||
installVersionPage = new InstallVersionPage(getContext(), PAGE_ID_DOWNLOAD_GAME, getParent(), R.layout.page_install_version);
|
||||
downloadModpackPage = new ModpackDownloadPage(getContext(), PAGE_ID_DOWNLOAD_MODPACK, getParent(), R.layout.page_download);
|
||||
downloadModPage = new ModDownloadPage(getContext(), PAGE_ID_DOWNLOAD_MOD, getParent(), R.layout.page_download);
|
||||
downloadResourcePackPage = new DownloadPage(getContext(), PAGE_ID_DOWNLOAD_RESOURCE_PACK, getParent(), R.layout.page_download, CurseForgeRemoteModRepository.RESOURCE_PACKS);
|
||||
downloadResourcePackPage = new ResourcePackDownloadPage(getContext(), PAGE_ID_DOWNLOAD_RESOURCE_PACK, getParent(), R.layout.page_download);
|
||||
downloadWorldPage = new DownloadPage(getContext(), PAGE_ID_DOWNLOAD_WORLD, getParent(), R.layout.page_download, CurseForgeRemoteModRepository.WORLDS);
|
||||
|
||||
if (listener != null) {
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.tungsten.fcl.ui.download;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.tungsten.fcl.R;
|
||||
import com.tungsten.fcl.game.LocalizedRemoteModRepository;
|
||||
import com.tungsten.fcl.util.AndroidUtils;
|
||||
import com.tungsten.fclcore.mod.RemoteModRepository;
|
||||
import com.tungsten.fclcore.mod.curse.CurseForgeRemoteModRepository;
|
||||
import com.tungsten.fclcore.mod.modrinth.ModrinthRemoteModRepository;
|
||||
import com.tungsten.fcllibrary.component.view.FCLUILayout;
|
||||
|
||||
public class ResourcePackDownloadPage extends DownloadPage {
|
||||
|
||||
public ResourcePackDownloadPage(Context context, int id, FCLUILayout parent, int resId) {
|
||||
super(context, id, parent, resId, null);
|
||||
|
||||
repository = new Repository();
|
||||
|
||||
supportChinese.set(true);
|
||||
downloadSources.get().setAll(context.getString(R.string.mods_curseforge), context.getString(R.string.mods_modrinth));
|
||||
if (CurseForgeRemoteModRepository.isAvailable())
|
||||
downloadSource.set(context.getString(R.string.mods_curseforge));
|
||||
else
|
||||
downloadSource.set(context.getString(R.string.mods_modrinth));
|
||||
|
||||
create();
|
||||
}
|
||||
|
||||
private class Repository extends LocalizedRemoteModRepository {
|
||||
|
||||
@Override
|
||||
protected RemoteModRepository getBackedRemoteModRepository() {
|
||||
if (getContext().getString(R.string.mods_modrinth).equals(downloadSource.get())) {
|
||||
return ModrinthRemoteModRepository.RESOURCE_PACKS;
|
||||
} else {
|
||||
return CurseForgeRemoteModRepository.RESOURCE_PACKS;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.MOD;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLocalizedCategory(String category) {
|
||||
if (getContext().getString(R.string.mods_modrinth).equals(downloadSource.get())) {
|
||||
return AndroidUtils.getLocalizedText(getContext(), "modrinth_category_" + category.replaceAll("-", "_"));
|
||||
} else {
|
||||
return AndroidUtils.getLocalizedText(getContext(), "curse_category_" + category);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLocalizedOfficialPage() {
|
||||
return downloadSource.get();
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ import java.util.stream.Stream;
|
|||
public final class ModrinthRemoteModRepository implements RemoteModRepository {
|
||||
public static final ModrinthRemoteModRepository MODS = new ModrinthRemoteModRepository("mod");
|
||||
public static final ModrinthRemoteModRepository MODPACKS = new ModrinthRemoteModRepository("modpack");
|
||||
public static final ModrinthRemoteModRepository RESOURCE_PACKS = new ModrinthRemoteModRepository("resourcepack");
|
||||
|
||||
private static final String PREFIX = "https://api.modrinth.com";
|
||||
|
||||
|
|
Loading…
Reference in New Issue