Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
130b950878 | ||
|
|
c0b935e3f1 | ||
|
|
90451e6da9 | ||
|
|
6db34fcdc7 | ||
|
|
5bb53622ca | ||
|
|
b9308f060f | ||
|
|
f715367849 | ||
|
|
07b757b3c1 | ||
|
|
3325e393bc | ||
|
|
48a8c99c83 | ||
|
|
8d687158f6 | ||
|
|
f966793490 | ||
|
|
d824122219 | ||
|
|
65900b5881 | ||
|
|
e6ed1eab71 | ||
|
|
1a3c31a141 | ||
|
|
c0ef592f72 |
No files matched your search
+4
-9
@@ -1,14 +1,7 @@
|
||||
language: java
|
||||
sudo: false
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
before_deploy:
|
||||
- git config --global user.email ${GITHUB_EMAIL}
|
||||
- git config --global user.name ${GITHUB_NAME}
|
||||
- git tag ${TRAVIS_BUILD_NUMBER}
|
||||
- git push -q ${REPO} --tags
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key: ${DEPLOY_REPO}
|
||||
@@ -20,7 +13,9 @@ deploy:
|
||||
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe
|
||||
- HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}-MacOSApp.zip
|
||||
on:
|
||||
tags: false
|
||||
repo: mclauncher/HMCL
|
||||
branch: master
|
||||
tags: true
|
||||
skip_cleanup: true
|
||||
install: echo "skip 'gradle assemble' step"
|
||||
script: gradle build --continue
|
||||
|
||||
+7
-8
@@ -54,8 +54,7 @@ def readBuildNumber() {
|
||||
|
||||
if (versionPropsFile.canRead()) {
|
||||
versionProps.load(new FileInputStream(versionPropsFile))
|
||||
def code = versionProps['VERSION_CODE'].toInteger() + 1
|
||||
|
||||
def code = versionProps['VERSION_CODE'].toInteger()
|
||||
return code.toString()
|
||||
} else {
|
||||
versionPropsFile.createNewFile()
|
||||
@@ -66,10 +65,10 @@ def readBuildNumber() {
|
||||
def branches = json.getAsJsonArray('branches')
|
||||
if (branches != null && branches.size() > 0) {
|
||||
def info = branches.get(0).getAsJsonObject()
|
||||
def code = info.get('number').getAsInt()
|
||||
versionProps['VERSION_CODE'] = code.toString()
|
||||
def code = info.get('number').getAsInt().toString()
|
||||
versionProps['VERSION_CODE'] = code
|
||||
versionProps.store(versionPropsFile.newWriter(), null)
|
||||
return (code + 1).toString()
|
||||
return code
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,9 +85,9 @@ if (buildnumber == null)
|
||||
if (buildnumber == null)
|
||||
buildnumber = readBuildNumber()
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
def versionroot = System.getenv("HMCL_VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
versionroot = "2.5.0"
|
||||
versionroot = "2.5.3"
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = versionroot + '.' + buildnumber
|
||||
@@ -187,7 +186,7 @@ launch4j {
|
||||
icon = new File(project.buildDir, '../icon.ico').absolutePath
|
||||
version = mavenVersion
|
||||
downloadUrl = 'http://java.com/download'
|
||||
copyright = "Copyright(c) 2013-2015 HMCLSoft."
|
||||
copyright = "Copyright(c) 2013-2016 HMCLSoft."
|
||||
|
||||
jar = new File(project.buildDir, 'libs/' + mavenGroupId + '-' + mavenVersion + '.jar').absolutePath
|
||||
outfile = mavenGroupId + '-' + mavenVersion + '.exe'
|
||||
|
||||
+12
-11
@@ -112,14 +112,16 @@ public class DynamicDownloadProvider extends MojangDownloadProvider {
|
||||
|
||||
@Override
|
||||
public String getParsedDownloadURL(String str) {
|
||||
if (StrUtils.isNotBlank(librariesAddr)) {
|
||||
str = str.replace("https://libraries.minecraft.net", librariesAddr);
|
||||
}
|
||||
if (StrUtils.isNotBlank(launcherMetaAddr)) {
|
||||
str = str.replace("https://launchermeta.mojang.com", launcherMetaAddr);
|
||||
}
|
||||
if (StrUtils.isNotBlank(launcherMetaAddr)) {
|
||||
str = str.replace("https://launcher.mojang.com", launcherAddr);
|
||||
if (str != null) {
|
||||
if (StrUtils.isNotBlank(librariesAddr)) {
|
||||
str = str.replace("https://libraries.minecraft.net", librariesAddr);
|
||||
}
|
||||
if (StrUtils.isNotBlank(launcherMetaAddr)) {
|
||||
str = str.replace("https://launchermeta.mojang.com", launcherMetaAddr);
|
||||
}
|
||||
if (StrUtils.isNotBlank(launcherAddr)) {
|
||||
str = str.replace("https://launcher.mojang.com", launcherAddr);
|
||||
}
|
||||
}
|
||||
return super.getParsedDownloadURL(str);
|
||||
}
|
||||
@@ -142,8 +144,7 @@ public class DynamicDownloadProvider extends MojangDownloadProvider {
|
||||
try {
|
||||
String providerInfo = NetUtils.get(PROVIDER_ADDR);
|
||||
Map<String, String> addrInfo = null;
|
||||
addrInfo = C.GSON.fromJson(providerInfo, new TypeToken<Map<String, String>>() {
|
||||
}.getType());
|
||||
addrInfo = C.GSON.fromJson(providerInfo, new TypeToken<Map<String, String>>() {}.getType());
|
||||
if (addrInfo != null) {
|
||||
setLibrariesAddr(getValue(addrInfo, "libraries"));
|
||||
setAssetsAddr(getValue(addrInfo, "assets"));
|
||||
@@ -151,7 +152,7 @@ public class DynamicDownloadProvider extends MojangDownloadProvider {
|
||||
setLauncherAddr(getValue(addrInfo, "launcher"));
|
||||
setVersionManifestAddr(getValue(addrInfo, "versionManifest"));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
} catch (Throwable t) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class MojangDownloadProvider extends IDownloadProvider {
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
||||
else if (str.contains("typesafe") || str.contains("scala"))
|
||||
if (SupportedLocales.NOW_LOCALE.self == Locale.CHINA)
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://maven.oschina.net/content/groups/public");
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://maven.aliyun.com/nexus/content/groups/public");
|
||||
else
|
||||
return str.replace("http://files.minecraftforge.net/maven", "http://repo1.maven.org/maven2");
|
||||
else
|
||||
|
||||
+111
-111
@@ -31,122 +31,122 @@ import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
*/
|
||||
public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
|
||||
@SerializedName("rules")
|
||||
public ArrayList<Rules> rules;
|
||||
@SerializedName("url")
|
||||
public String url;
|
||||
@SerializedName("natives")
|
||||
public Natives natives;
|
||||
@SerializedName("extract")
|
||||
public Extract extract;
|
||||
@SerializedName("downloads")
|
||||
public LibrariesDownloadInfo downloads;
|
||||
@SerializedName("rules")
|
||||
public ArrayList<Rules> rules;
|
||||
@SerializedName("url")
|
||||
public String url;
|
||||
@SerializedName("natives")
|
||||
public Natives natives;
|
||||
@SerializedName("extract")
|
||||
public Extract extract;
|
||||
@SerializedName("downloads")
|
||||
public LibrariesDownloadInfo downloads;
|
||||
|
||||
public MinecraftLibrary(String name) {
|
||||
super(name);
|
||||
}
|
||||
public MinecraftLibrary(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public MinecraftLibrary(ArrayList<Rules> rules, String url, Natives natives, String name, Extract extract, LibraryDownloadInfo downloads) {
|
||||
super(name);
|
||||
this.rules = (rules == null) ? null : (ArrayList<Rules>) rules.clone();
|
||||
this.url = url;
|
||||
this.natives = (natives == null) ? null : (Natives) natives.clone();
|
||||
this.extract = (extract == null) ? null : (Extract) extract.clone();
|
||||
}
|
||||
public MinecraftLibrary(ArrayList<Rules> rules, String url, Natives natives, String name, Extract extract, LibraryDownloadInfo downloads) {
|
||||
super(name);
|
||||
this.rules = (rules == null) ? null : (ArrayList<Rules>) rules.clone();
|
||||
this.url = url;
|
||||
this.natives = (natives == null) ? null : (Natives) natives.clone();
|
||||
this.extract = (extract == null) ? null : (Extract) extract.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allow() {
|
||||
if (rules != null) {
|
||||
boolean flag = false;
|
||||
for (Rules r : rules) {
|
||||
if ("disallow".equals(r.action()))
|
||||
return false;
|
||||
else if ("allow".equals(r.action()))
|
||||
flag = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatArch(String nati) {
|
||||
return nati == null ? "" : nati.replace("${arch}", Platform.getPlatform().getBit());
|
||||
}
|
||||
|
||||
private String getNative() {
|
||||
switch (OS.os()) {
|
||||
case WINDOWS:
|
||||
return formatArch(natives.windows);
|
||||
case OSX:
|
||||
return formatArch(natives.osx);
|
||||
default:
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
return natives != null && allow();
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
String[] s = name.split(":");
|
||||
if (s.length < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(s[0].replace('.', '/')).append('/').append(s[1]).append('/').append(s[2]).append('/').append(s[1]).append('-').append(s[2]);
|
||||
if (natives != null) {
|
||||
sb.append('-').append(getNative());
|
||||
}
|
||||
|
||||
return sb.append(".jar").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFilePath(File gameDir) {
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(gameDir, "libraries/" + info.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extract getDecompressExtractRules() {
|
||||
return extract == null ? new Extract() : extract;
|
||||
}
|
||||
|
||||
public LibraryDownloadInfo getDownloadInfo() {
|
||||
if (downloads == null) {
|
||||
downloads = new LibrariesDownloadInfo();
|
||||
}
|
||||
|
||||
LibraryDownloadInfo info = null;
|
||||
if (natives != null) {
|
||||
if (downloads.classifiers == null) {
|
||||
downloads.classifiers = new HashMap<>();
|
||||
} else {
|
||||
if (!downloads.classifiers.containsKey(getNative())) {
|
||||
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
|
||||
} else {
|
||||
info = downloads.classifiers.get(getNative());
|
||||
@Override
|
||||
public boolean allow() {
|
||||
if (rules != null) {
|
||||
boolean flag = false;
|
||||
for (Rules r : rules) {
|
||||
if ("disallow".equals(r.action())) {
|
||||
return false;
|
||||
} else if ("allow".equals(r.action())) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
} else if (downloads.artifact == null) {
|
||||
downloads.artifact = info = new LibraryDownloadInfo();
|
||||
} else {
|
||||
info = downloads.artifact;
|
||||
return flag;
|
||||
}
|
||||
|
||||
if (StrUtils.isBlank(info.path)) {
|
||||
info.path = formatName();
|
||||
if (info.path == null) {
|
||||
return null;
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatArch(String nati) {
|
||||
return nati == null ? "" : nati.replace("${arch}", Platform.getPlatform().getBit());
|
||||
}
|
||||
|
||||
private String getNative() {
|
||||
switch (OS.os()) {
|
||||
case WINDOWS:
|
||||
return formatArch(natives.windows);
|
||||
case OSX:
|
||||
return formatArch(natives.osx);
|
||||
default:
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredToUnzip() {
|
||||
return natives != null && allow();
|
||||
}
|
||||
|
||||
public String formatName() {
|
||||
String[] s = name.split(":");
|
||||
if (s.length < 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(s[0].replace('.', '/')).append('/').append(s[1]).append('/').append(s[2]).append('/').append(s[1]).append('-').append(s[2]);
|
||||
if (natives != null) {
|
||||
sb.append('-').append(getNative());
|
||||
}
|
||||
|
||||
return sb.append(".jar").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFilePath(File gameDir) {
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
return new File(gameDir, "libraries/" + info.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extract getDecompressExtractRules() {
|
||||
return extract == null ? new Extract() : extract;
|
||||
}
|
||||
|
||||
public LibraryDownloadInfo getDownloadInfo() {
|
||||
if (downloads == null) {
|
||||
downloads = new LibrariesDownloadInfo();
|
||||
}
|
||||
|
||||
LibraryDownloadInfo info = null;
|
||||
if (natives != null) {
|
||||
if (downloads.classifiers == null) {
|
||||
downloads.classifiers = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
info.forgeURL = this.url;
|
||||
return info;
|
||||
}
|
||||
if (!downloads.classifiers.containsKey(getNative())) {
|
||||
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
|
||||
} else {
|
||||
info = downloads.classifiers.get(getNative());
|
||||
}
|
||||
} else if (downloads.artifact == null) {
|
||||
downloads.artifact = info = new LibraryDownloadInfo();
|
||||
} else {
|
||||
info = downloads.artifact;
|
||||
}
|
||||
|
||||
if (StrUtils.isBlank(info.path)) {
|
||||
info.path = formatName();
|
||||
if (info.path == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
info.forgeURL = this.url;
|
||||
return info;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -21,8 +21,10 @@ import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
@@ -76,6 +78,16 @@ public final class Config implements Cloneable {
|
||||
private Map<String, Map> auth;
|
||||
@SerializedName("ignoreUpdateVersion")
|
||||
private String ignoreUpdateVersion;
|
||||
@SerializedName("ignoreRecommend")
|
||||
private Set<String> ignoreRecommend;
|
||||
|
||||
public Set<String> getIgnoreRecommend() {
|
||||
if (ignoreRecommend == null) {
|
||||
ignoreRecommend = new HashSet<>();
|
||||
Settings.save();
|
||||
}
|
||||
return ignoreRecommend;
|
||||
}
|
||||
|
||||
public List<JdkVersion> getJava() {
|
||||
return java == null ? java = new ArrayList<>() : java;
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -36,9 +35,13 @@ import java.util.ArrayList;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
/**
|
||||
@@ -49,12 +52,21 @@ public class RecommendPanel extends JPanel {
|
||||
|
||||
private static final int SWITCH_INTERVAL = 10;
|
||||
|
||||
private static final int SPACE = 10;
|
||||
private static final int TOP_POSITION = 2;
|
||||
|
||||
private JButton closeButton;
|
||||
|
||||
private Image currImage;
|
||||
private String imageKey = null;
|
||||
private boolean ignoreSwitch = false;
|
||||
private List<RecommendInfo> recommends;
|
||||
public ScheduledExecutorService scheduledexec = Executors.newScheduledThreadPool(1);
|
||||
|
||||
public final ScheduledExecutorService scheduledexec = Executors.newScheduledThreadPool(1);
|
||||
|
||||
public RecommendPanel() {
|
||||
initComponents();
|
||||
|
||||
recommends = new ArrayList<RecommendInfo>();
|
||||
new LoadImages().execute();
|
||||
setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
@@ -67,12 +79,42 @@ public class RecommendPanel extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
this.setLayout(null);
|
||||
|
||||
closeButton = new JButton(Main.getIcon("re_close.png"));
|
||||
closeButton.setRolloverIcon(Main.getIcon("re_close_enter.png"));
|
||||
closeButton.setBorder(BorderFactory.createEmptyBorder());
|
||||
closeButton.setContentAreaFilled(false);
|
||||
closeButton.addActionListener((e) -> ignoreTheRecommend(imageKey));
|
||||
closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
closeButton.setFocusable(false);
|
||||
closeButton.setBounds(0, 0, 12, 12);
|
||||
closeButton.setVisible(false);
|
||||
this.add(closeButton);
|
||||
}
|
||||
|
||||
private void ignoreTheRecommend(String url) {
|
||||
synchronized(RecommendPanel.class) {
|
||||
if (StrUtils.isNotBlank(url)) {
|
||||
Settings.getInstance().getIgnoreRecommend().add(url);
|
||||
Settings.save();
|
||||
|
||||
ignoreSwitch = true;
|
||||
showNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MouseClicked(MouseEvent evt) {
|
||||
if (imageKey == null) {
|
||||
return;
|
||||
}
|
||||
RecommendInfo info = recommends.get(getCurrentImageIndex());
|
||||
if (info.link != null && !info.link.equals("")) {
|
||||
if (StrUtils.isNotBlank(info.link)) {
|
||||
if (info.once) {
|
||||
ignoreTheRecommend(info.url);
|
||||
}
|
||||
SwingUtils.openLink(info.link);
|
||||
}
|
||||
}
|
||||
@@ -86,13 +128,14 @@ public class RecommendPanel extends JPanel {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RecommendInfo info : recommends) {
|
||||
try {
|
||||
File tempFile = File.createTempFile("hmcl", "png");
|
||||
String tempPath = tempFile.getCanonicalPath();
|
||||
if (NetUtils.download(info.url, tempPath)) {
|
||||
info.image = ImageIO.read(tempFile);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
if (!ignoreShowUrl(info.url)) {
|
||||
try {
|
||||
File tempFile = File.createTempFile("hmcl", "png");
|
||||
String tempPath = tempFile.getCanonicalPath();
|
||||
if (NetUtils.download(info.url, tempPath)) {
|
||||
info.image = ImageIO.read(tempFile);
|
||||
}
|
||||
} catch (Throwable t) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +148,13 @@ public class RecommendPanel extends JPanel {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int showIndex = getNextImageIndex();
|
||||
RecommendInfo info = recommends.get(showIndex);
|
||||
RecommendPanel.this.setImage(info.url, info.image);
|
||||
synchronized(RecommendPanel.class) {
|
||||
if (ignoreSwitch) {
|
||||
ignoreSwitch = false;
|
||||
} else {
|
||||
showNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -142,25 +189,49 @@ public class RecommendPanel extends JPanel {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showNext() {
|
||||
if (getCanShowImageCount() == 0) {
|
||||
setVisible(false);
|
||||
scheduledexec.shutdown();
|
||||
} else {
|
||||
int showIndex = getNextImageIndex();
|
||||
RecommendInfo info = recommends.get(showIndex);
|
||||
setImage(info.url, info.image);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean ignoreShowUrl(String url) {
|
||||
if (StrUtils.isBlank(url)) {
|
||||
return true;
|
||||
}
|
||||
return Settings.getInstance().getIgnoreRecommend().contains(url);
|
||||
}
|
||||
|
||||
public int getCanShowImageCount() {
|
||||
int imageCount = 0;
|
||||
for (RecommendInfo recommend : recommends) {
|
||||
if (recommend.image != null && !ignoreShowUrl(recommend.url)) {
|
||||
imageCount++;
|
||||
}
|
||||
}
|
||||
return imageCount;
|
||||
}
|
||||
|
||||
public int getNextImageIndex(int showIndex) {
|
||||
if (showIndex >= recommends.size()) {
|
||||
showIndex = 0;
|
||||
}
|
||||
RecommendInfo info = recommends.get(showIndex);
|
||||
if (info.image == null) {
|
||||
showIndex = getNextImageIndex(++showIndex);
|
||||
if (info.image == null || ignoreShowUrl(info.url)) {
|
||||
showIndex = getNextImageIndex(++showIndex);
|
||||
}
|
||||
return showIndex;
|
||||
}
|
||||
|
||||
public int getNextImageIndex() {
|
||||
int showIndex = 0;
|
||||
if (imageKey != null) {
|
||||
showIndex = getCurrentImageIndex();
|
||||
showIndex++;
|
||||
}
|
||||
if (showIndex >= recommends.size()) {
|
||||
int showIndex = getCurrentImageIndex();
|
||||
if (++showIndex >= recommends.size()) {
|
||||
showIndex = 0;
|
||||
}
|
||||
showIndex = getNextImageIndex(showIndex);
|
||||
@@ -171,43 +242,49 @@ public class RecommendPanel extends JPanel {
|
||||
int currIndex = 0;
|
||||
for (int i = 0; i < recommends.size(); i++) {
|
||||
RecommendInfo info = recommends.get(i);
|
||||
if (imageKey != null && info.url.equals(imageKey)) {
|
||||
if (StrUtils.isNotBlank(imageKey) && info.url.equals(imageKey)) {
|
||||
currIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return currIndex;
|
||||
}
|
||||
|
||||
|
||||
public void setImage(String key, Image image) {
|
||||
this.imageKey = key;
|
||||
this.currImage = image;
|
||||
//setToolTipText(C.i18n("ui.message.recommend_tip"));
|
||||
setSize(image.getWidth(this), image.getHeight(this));
|
||||
|
||||
int btnWidth = closeButton.getWidth();
|
||||
|
||||
setSize(image.getWidth(this) + SPACE + btnWidth, image.getHeight(this));
|
||||
closeButton.setLocation(getWidth() - btnWidth, TOP_POSITION);
|
||||
closeButton.setVisible(true);
|
||||
|
||||
SwingUtilities.updateComponentTreeUI(this.getRootPane());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
if (null == currImage) {
|
||||
return;
|
||||
if (currImage != null) {
|
||||
g.drawImage(currImage, 0, 0, currImage.getWidth(this), currImage.getHeight(this), this);
|
||||
}
|
||||
g.drawImage(currImage, 0, 0, currImage.getWidth(this), currImage.getHeight(this), this);
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
static class RecommendInfo {
|
||||
String url;
|
||||
String link;
|
||||
boolean once;
|
||||
Image image;
|
||||
}
|
||||
|
||||
class LoadImages extends SwingWorker<List<Map<String, String>>, Void> {
|
||||
class LoadImages extends SwingWorker<List<Map<String, Object>>, Void> {
|
||||
|
||||
private static final String RECOMMEND_URL = "http://client.api.mcgogogo.com:81/recommend.php";
|
||||
|
||||
|
||||
@Override
|
||||
protected List<Map<String, String>> doInBackground() throws Exception {
|
||||
List<Map<String, String>> infos = null;
|
||||
protected List<Map<String, Object>> doInBackground() throws Exception {
|
||||
List<Map<String, Object>> infos = null;
|
||||
do {
|
||||
String content = NetUtils.get(RECOMMEND_URL);
|
||||
if (content == null || content.equals("")) {
|
||||
@@ -215,13 +292,12 @@ public class RecommendPanel extends JPanel {
|
||||
}
|
||||
|
||||
Map<String, Object> data = new Gson().fromJson(content,
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
new TypeToken<Map<String, Object>>() {}.getType());
|
||||
if (data == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
infos = (List<Map<String, String>>) data.get("data");
|
||||
infos = (List<Map<String, Object>>) data.get("data");
|
||||
} while (false);
|
||||
return infos;
|
||||
}
|
||||
@@ -229,14 +305,27 @@ public class RecommendPanel extends JPanel {
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
List<Map<String, String>> infos = this.get();
|
||||
List<Map<String, Object>> infos = this.get();
|
||||
if (infos == null) {
|
||||
return;
|
||||
}
|
||||
for (Map<String, String> info : infos) {
|
||||
for (Map<String, Object> info : infos) {
|
||||
RecommendInfo recommend = new RecommendInfo();
|
||||
recommend.url = info.get("url");
|
||||
recommend.link = info.get("link");
|
||||
if (info.get("url") != null) {
|
||||
recommend.url = (String) info.get("url");
|
||||
} else {
|
||||
recommend.url = "";
|
||||
}
|
||||
if (info.get("link") != null) {
|
||||
recommend.link = (String) info.get("link");
|
||||
} else {
|
||||
recommend.link = "";
|
||||
}
|
||||
if (info.get("once") != null) {
|
||||
recommend.once = (boolean) info.get("once");
|
||||
} else {
|
||||
recommend.once = false;
|
||||
}
|
||||
recommend.image = null;
|
||||
recommends.add(recommend);
|
||||
}
|
||||
|
||||
@@ -138,9 +138,9 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("CrashReport", text);
|
||||
try {
|
||||
NetUtils.post(NetUtils.constantURL("http://huangyuhui.duapp.com/crash.php"), map);
|
||||
} catch (IOException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to post HMCL server.", ex);
|
||||
NetUtils.post(NetUtils.constantURL("http://client.api.mcgogogo.com:81/crash_report.php"), map);
|
||||
} catch (Throwable error) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to post HMCL server.", error);
|
||||
}
|
||||
});
|
||||
t.setDaemon(true);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user