mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
move hardcoded url to ForgeConstants
This commit is contained in:
@@ -72,6 +72,8 @@ import forge.util.TextUtil;
|
|||||||
import forge.view.FFrame;
|
import forge.view.FFrame;
|
||||||
import forge.view.FView;
|
import forge.view.FView;
|
||||||
|
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.DAILY_SNAPSHOT_URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* FControl.
|
* FControl.
|
||||||
@@ -244,9 +246,9 @@ public enum FControl implements KeyEventDispatcher {
|
|||||||
//get version string
|
//get version string
|
||||||
try {
|
try {
|
||||||
if (isSnapshot && prefs.getPrefBoolean(FPref.CHECK_SNAPSHOT_AT_STARTUP)) {
|
if (isSnapshot && prefs.getPrefBoolean(FPref.CHECK_SNAPSHOT_AT_STARTUP)) {
|
||||||
URL url = new URL("https://downloads.cardforge.org/dailysnapshots/version.txt");
|
URL url = new URL(DAILY_SNAPSHOT_URL + "version.txt");
|
||||||
snapsVersion = FileUtil.readFileToString(url);
|
snapsVersion = FileUtil.readFileToString(url);
|
||||||
url = new URL("https://downloads.cardforge.org/dailysnapshots/build.txt");
|
url = new URL(DAILY_SNAPSHOT_URL + "build.txt");
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
|
snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
|
||||||
buildTimeStamp = BuildInfo.getTimestamp();
|
buildTimeStamp = BuildInfo.getTimestamp();
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import forge.util.BuildInfo;
|
|||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
|
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.GITHUB_FORGE_URL;
|
||||||
|
|
||||||
public final class HelpMenu {
|
public final class HelpMenu {
|
||||||
private HelpMenu() { }
|
private HelpMenu() { }
|
||||||
|
|
||||||
@@ -71,8 +73,8 @@ public final class HelpMenu {
|
|||||||
JMenu mnu = new JMenu(localizer.getMessage("lblGettingStarted"));
|
JMenu mnu = new JMenu(localizer.getMessage("lblGettingStarted"));
|
||||||
mnu.add(getMenuItem_HowToPlayFile());
|
mnu.add(getMenuItem_HowToPlayFile());
|
||||||
mnu.addSeparator();
|
mnu.addSeparator();
|
||||||
mnu.add(getMenuItem_UrlLink("Forge Wiki", "https://github.com/Card-Forge/forge/wiki", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)));
|
mnu.add(getMenuItem_UrlLink("Forge Wiki", GITHUB_FORGE_URL + "wiki", KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)));
|
||||||
mnu.add(getMenuItem_UrlLink("What is Forge?", "https://github.com/Card-Forge/forge/wiki#what-is-forge"));
|
mnu.add(getMenuItem_UrlLink("What is Forge?", GITHUB_FORGE_URL + "wiki#what-is-forge"));
|
||||||
return mnu;
|
return mnu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,17 @@ import forge.Forge;
|
|||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.download.GuiDownloadZipService;
|
import forge.gui.download.GuiDownloadZipService;
|
||||||
import forge.gui.util.SOptionPane;
|
import forge.gui.util.SOptionPane;
|
||||||
import forge.localinstance.properties.ForgeConstants;
|
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.ADV_TEXTURE_BG_FILE;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.ASSETS_DIR;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.DAILY_SNAPSHOT_URL;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.DEFAULT_SKINS_DIR;
|
||||||
import static forge.localinstance.properties.ForgeConstants.GITHUB_COMMITS_URL_ATOM;
|
import static forge.localinstance.properties.ForgeConstants.GITHUB_COMMITS_URL_ATOM;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.GITHUB_FORGE_URL;
|
||||||
import static forge.localinstance.properties.ForgeConstants.GITHUB_RELEASES_URL_ATOM;
|
import static forge.localinstance.properties.ForgeConstants.GITHUB_RELEASES_URL_ATOM;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.RELEASE_URL;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.RES_DIR;
|
||||||
|
|
||||||
public class AssetsDownloader {
|
public class AssetsDownloader {
|
||||||
private final static ImmutableList<String> downloadIgnoreExit = ImmutableList.of("Download", "Ignore", "Exit");
|
private final static ImmutableList<String> downloadIgnoreExit = ImmutableList.of("Download", "Ignore", "Exit");
|
||||||
@@ -44,11 +50,11 @@ public class AssetsDownloader {
|
|||||||
final String apkSize = "12MB";
|
final String apkSize = "12MB";
|
||||||
|
|
||||||
final boolean isSnapshots = versionString.contains("SNAPSHOT");
|
final boolean isSnapshots = versionString.contains("SNAPSHOT");
|
||||||
final String snapsURL = "https://downloads.cardforge.org/dailysnapshots/";
|
final String snapsURL = DAILY_SNAPSHOT_URL;
|
||||||
final String releaseURL = "https://releases.cardforge.org/forge/forge-gui-android/";
|
final String releaseURL = RELEASE_URL + "forge/forge-gui-android/";
|
||||||
final String versionText = isSnapshots ? snapsURL + "version.txt" : releaseURL + "version.txt";
|
final String versionText = isSnapshots ? snapsURL + "version.txt" : releaseURL + "version.txt";
|
||||||
FileHandle assetsDir = Gdx.files.absolute(ForgeConstants.ASSETS_DIR);
|
FileHandle assetsDir = Gdx.files.absolute(ASSETS_DIR);
|
||||||
FileHandle resDir = Gdx.files.absolute(ForgeConstants.RES_DIR);
|
FileHandle resDir = Gdx.files.absolute(RES_DIR);
|
||||||
FileHandle buildTxtFileHandle = Gdx.files.classpath("build.txt");
|
FileHandle buildTxtFileHandle = Gdx.files.classpath("build.txt");
|
||||||
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
boolean verifyUpdatable = false;
|
boolean verifyUpdatable = false;
|
||||||
@@ -71,8 +77,8 @@ public class AssetsDownloader {
|
|||||||
} else {
|
} else {
|
||||||
//current release on github is tar.bz2, update this to jar installer in the future...
|
//current release on github is tar.bz2, update this to jar installer in the future...
|
||||||
filename = isSnapshots ? "forge-installer-" + version + ".jar" : releaseTag.replace("forge-", "forge-gui-desktop-") + ".tar.bz2";
|
filename = isSnapshots ? "forge-installer-" + version + ".jar" : releaseTag.replace("forge-", "forge-gui-desktop-") + ".tar.bz2";
|
||||||
String releaseBZ2URL = "https://github.com/Card-Forge/forge/releases/download/" + releaseTag + "/" + filename;
|
String releaseBZ2URL = GITHUB_FORGE_URL + "releases/download/" + releaseTag + "/" + filename;
|
||||||
String snapsBZ2URL = "https://downloads.cardforge.org/dailysnapshots/";
|
String snapsBZ2URL = DAILY_SNAPSHOT_URL;
|
||||||
installerURL = isSnapshots ? snapsBZ2URL : releaseBZ2URL;
|
installerURL = isSnapshots ? snapsBZ2URL : releaseBZ2URL;
|
||||||
}
|
}
|
||||||
String snapsBuildDate = "", buildDate = "";
|
String snapsBuildDate = "", buildDate = "";
|
||||||
@@ -97,8 +103,8 @@ public class AssetsDownloader {
|
|||||||
if (verifyUpdatable) {
|
if (verifyUpdatable) {
|
||||||
Forge.getSplashScreen().prepareForDialogs();
|
Forge.getSplashScreen().prepareForDialogs();
|
||||||
|
|
||||||
message = "A new version of Forge is available. - v." + version + "\n" + snapsBuildDate + "\n" +
|
message = "A new version of Forge is available.\n(v." + version + " | " + snapsBuildDate + ")\n" +
|
||||||
"You are currently on an older version. - v." + versionString + "\n" + buildDate + "\n" +
|
"You are currently on an older version.\n(v." + versionString + " | " + buildDate + ")\n" +
|
||||||
"Would you like to update to the new version now?";
|
"Would you like to update to the new version now?";
|
||||||
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
|
if (!Forge.getDeviceAdapter().isConnectedToWifi()) {
|
||||||
message += " If so, you may want to connect to wifi first. The download is around " + (GuiBase.isAndroid() ? apkSize : packageSize) + ".";
|
message += " If so, you may want to connect to wifi first. The download is around " + (GuiBase.isAndroid() ? apkSize : packageSize) + ".";
|
||||||
@@ -158,7 +164,7 @@ public class AssetsDownloader {
|
|||||||
String log = "";
|
String log = "";
|
||||||
|
|
||||||
//see if assets need updating
|
//see if assets need updating
|
||||||
FileHandle advBG = Gdx.files.absolute(ForgeConstants.DEFAULT_SKINS_DIR).child(ForgeConstants.ADV_TEXTURE_BG_FILE);
|
FileHandle advBG = Gdx.files.absolute(DEFAULT_SKINS_DIR).child(ADV_TEXTURE_BG_FILE);
|
||||||
if (!advBG.exists()) {
|
if (!advBG.exists()) {
|
||||||
FileHandle deleteVersion = assetsDir.child("version.txt");
|
FileHandle deleteVersion = assetsDir.child("version.txt");
|
||||||
if (deleteVersion.exists())
|
if (deleteVersion.exists())
|
||||||
@@ -265,7 +271,7 @@ public class AssetsDownloader {
|
|||||||
boolean allowDeletion = Forge.androidVersion < 30 || GuiBase.isUsingAppDirectory();
|
boolean allowDeletion = Forge.androidVersion < 30 || GuiBase.isUsingAppDirectory();
|
||||||
String assetURL = isSnapshots ? snapsURL + "assets.zip" : releaseURL + versionString + "/" + "assets.zip";
|
String assetURL = isSnapshots ? snapsURL + "assets.zip" : releaseURL + versionString + "/" + "assets.zip";
|
||||||
new GuiDownloadZipService("", "resource files", assetURL,
|
new GuiDownloadZipService("", "resource files", assetURL,
|
||||||
ForgeConstants.ASSETS_DIR, ForgeConstants.RES_DIR, Forge.getSplashScreen().getProgressBar(), allowDeletion).downloadAndUnzip();
|
ASSETS_DIR, RES_DIR, Forge.getSplashScreen().getProgressBar(), allowDeletion).downloadAndUnzip();
|
||||||
|
|
||||||
if (allowDeletion)
|
if (allowDeletion)
|
||||||
FSkinFont.deleteCachedFiles(); //delete cached font files in case any skin's .ttf file changed
|
FSkinFont.deleteCachedFiles(); //delete cached font files in case any skin's .ttf file changed
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ import forge.util.Localizer;
|
|||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
import forge.util.WaitCallback;
|
import forge.util.WaitCallback;
|
||||||
|
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.DAILY_SNAPSHOT_URL;
|
||||||
|
import static forge.localinstance.properties.ForgeConstants.RELEASE_URL;
|
||||||
|
|
||||||
public class AutoUpdater {
|
public class AutoUpdater {
|
||||||
private final String SNAPSHOT_VERSION_INDEX = "https://downloads.cardforge.org/dailysnapshots/";
|
|
||||||
private final String RELEASE_VERSION_INDEX = "https://releases.cardforge.org/";
|
|
||||||
private static final boolean VERSION_FROM_METADATA = true;
|
private static final boolean VERSION_FROM_METADATA = true;
|
||||||
private static final Localizer localizer = Localizer.getInstance();
|
private static final Localizer localizer = Localizer.getInstance();
|
||||||
|
|
||||||
@@ -107,13 +108,13 @@ public class AutoUpdater {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionUrlString = SNAPSHOT_VERSION_INDEX + "version.txt";
|
versionUrlString = DAILY_SNAPSHOT_URL + "version.txt";
|
||||||
} else {
|
} else {
|
||||||
if (!updateChannel.equalsIgnoreCase(localizer.getMessageorUseDefault("lblRelease", "Release"))) {
|
if (!updateChannel.equalsIgnoreCase(localizer.getMessageorUseDefault("lblRelease", "Release"))) {
|
||||||
System.out.println("Release build versions must use release update channel to work");
|
System.out.println("Release build versions must use release update channel to work");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
versionUrlString = RELEASE_VERSION_INDEX + "forge/forge-gui-desktop/version.txt";
|
versionUrlString = RELEASE_URL + "forge/forge-gui-desktop/version.txt";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the internet connection
|
// Check the internet connection
|
||||||
@@ -139,7 +140,7 @@ public class AutoUpdater {
|
|||||||
try {
|
try {
|
||||||
retrieveVersion();
|
retrieveVersion();
|
||||||
if (buildVersion.contains("SNAPSHOT")) {
|
if (buildVersion.contains("SNAPSHOT")) {
|
||||||
URL url = new URL("https://downloads.cardforge.org/dailysnapshots/build.txt");
|
URL url = new URL(DAILY_SNAPSHOT_URL + "build.txt");
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
|
Date snapsTimestamp = simpleDateFormat.parse(FileUtil.readFileToString(url));
|
||||||
snapsBuildDate = snapsTimestamp.toString();
|
snapsBuildDate = snapsTimestamp.toString();
|
||||||
@@ -170,14 +171,14 @@ public class AutoUpdater {
|
|||||||
version = FileUtil.readFileToString(versionUrl);
|
version = FileUtil.readFileToString(versionUrl);
|
||||||
}
|
}
|
||||||
if (updateChannel.equalsIgnoreCase(localizer.getMessageorUseDefault("lblRelease", "Release"))) {
|
if (updateChannel.equalsIgnoreCase(localizer.getMessageorUseDefault("lblRelease", "Release"))) {
|
||||||
packageUrl = RELEASE_VERSION_INDEX + "forge/forge-gui-desktop/" + version + "/forge-gui-desktop-" + version + ".tar.bz2";
|
packageUrl = RELEASE_URL + "forge/forge-gui-desktop/" + version + "/forge-gui-desktop-" + version + ".tar.bz2";
|
||||||
} else {
|
} else {
|
||||||
packageUrl = SNAPSHOT_VERSION_INDEX + "forge-installer-" + version + ".jar";
|
packageUrl = DAILY_SNAPSHOT_URL + "forge-installer-" + version + ".jar";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractVersionFromMavenRelease() throws MalformedURLException {
|
private void extractVersionFromMavenRelease() throws MalformedURLException {
|
||||||
String RELEASE_MAVEN_METADATA = RELEASE_VERSION_INDEX + "forge/forge-gui-desktop/maven-metadata.xml";
|
String RELEASE_MAVEN_METADATA = RELEASE_URL + "forge/forge-gui-desktop/maven-metadata.xml";
|
||||||
URL metadataUrl = new URL(RELEASE_MAVEN_METADATA);
|
URL metadataUrl = new URL(RELEASE_MAVEN_METADATA);
|
||||||
String xml = FileUtil.readFileToString(metadataUrl);
|
String xml = FileUtil.readFileToString(metadataUrl);
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,11 @@ import java.util.Collections;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public final class ForgeConstants {
|
public final class ForgeConstants {
|
||||||
public static final String GITHUB_RELEASES_URL_ATOM = "https://github.com/Card-Forge/forge/releases.atom";
|
public static final String GITHUB_FORGE_URL = "https://github.com/Card-Forge/forge/";
|
||||||
public static final String GITHUB_COMMITS_URL_ATOM = "https://github.com/Card-Forge/forge/commits/master.atom";
|
public static final String GITHUB_RELEASES_URL_ATOM = GITHUB_FORGE_URL + "releases.atom";
|
||||||
|
public static final String GITHUB_COMMITS_URL_ATOM = GITHUB_FORGE_URL + "commits/master.atom";
|
||||||
|
public static final String DAILY_SNAPSHOT_URL = "https://downloads.cardforge.org/dailysnapshots/";
|
||||||
|
public static final String RELEASE_URL = "https://releases.cardforge.org/";
|
||||||
public static final String PATH_SEPARATOR = File.separator;
|
public static final String PATH_SEPARATOR = File.separator;
|
||||||
public static final String ASSETS_DIR = GuiBase.getInterface().getAssetsDir();
|
public static final String ASSETS_DIR = GuiBase.getInterface().getAssetsDir();
|
||||||
public static final String PROFILE_FILE = ASSETS_DIR + "forge.profile.properties";
|
public static final String PROFILE_FILE = ASSETS_DIR + "forge.profile.properties";
|
||||||
|
|||||||
Reference in New Issue
Block a user