Fixed reseting the color at warning mode

This commit is contained in:
huangyuhui
2017-07-28 08:45:36 +08:00
parent a0b19cfd1b
commit caa77387df
15 changed files with 21 additions and 29 deletions

View File

@@ -310,7 +310,6 @@ public class VersionSetting {
x.setFullscreen(isFullscreen()); x.setFullscreen(isFullscreen());
x.setWrapper(getWrapper()); x.setWrapper(getWrapper());
x.setGameDir(gameDir); x.setGameDir(gameDir);
x.setGameDirType(getGameDirType());
x.setHeight(getHeight()); x.setHeight(getHeight());
x.setJavaArgs(getJavaArgs()); x.setJavaArgs(getJavaArgs());
x.setLaunchVersion(id); x.setLaunchVersion(id);

View File

@@ -394,6 +394,8 @@ public final class MainFrame extends DraggableFrame implements IRepaint {
} }
public void reloadColor(Theme t) { public void reloadColor(Theme t) {
if (isShowedMessage)
return;
for (Map.Entry<String, String> entry : t.settings.entrySet()) { for (Map.Entry<String, String> entry : t.settings.entrySet()) {
if (entry.getValue().startsWith("#")) if (entry.getValue().startsWith("#"))
UIManager.put(entry.getKey(), GraphicsUtils.getWebColor(entry.getValue())); UIManager.put(entry.getKey(), GraphicsUtils.getWebColor(entry.getValue()));

View File

@@ -402,7 +402,7 @@ public class MainPagePanel extends Page {
fc.showOpenDialog(this); fc.showOpenDialog(this);
if (fc.getSelectedFile() == null) if (fc.getSelectedFile() == null)
return; return;
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName())); String suggestedModpackId = JOptionPane.showInputDialog(C.i18n("modpack.enter_name"), FileUtils.getBaseName(fc.getSelectedFile().getName()));
TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).execute(); TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).execute();
Settings.getLastProfile().service().version().refreshVersions(); Settings.getLastProfile().service().version().refreshVersions();
}//GEN-LAST:event_btnImportModpackActionPerformed }//GEN-LAST:event_btnImportModpackActionPerformed

View File

@@ -56,7 +56,7 @@ public class HMCLMinecraftService extends IMinecraftService {
public HMCLMinecraftService(Profile p) { public HMCLMinecraftService(Profile p) {
this.p = p; this.p = p;
this.provider = new HMCLGameProvider(this); this.provider = new HMCLGameProvider(this);
provider.initializeMiencraft(); provider.initializeMinecraft();
HMCLApi.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear); HMCLApi.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear);
HMCLApi.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> { HMCLApi.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> {
if (!checkingModpack) { if (!checkingModpack) {

View File

@@ -29,7 +29,6 @@ public class LaunchOptions {
private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand; private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand;
private boolean fullscreen, noJVMArgs, notCheckGame; private boolean fullscreen, noJVMArgs, notCheckGame;
private File gameDir; private File gameDir;
private GameDirType gameDirType;
public String getVersionName() { public String getVersionName() {
return versionName; return versionName;
@@ -115,14 +114,6 @@ public class LaunchOptions {
this.fullscreen = fullscreen; this.fullscreen = fullscreen;
} }
public GameDirType getGameDirType() {
return gameDirType;
}
public void setGameDirType(GameDirType gameDirType) {
this.gameDirType = gameDirType;
}
public String getPermSize() { public String getPermSize() {
return permSize; return permSize;
} }

View File

@@ -120,6 +120,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
HMCLog.warn("Failed to make directories: " + assetsDir); HMCLog.warn("Failed to make directories: " + assetsDir);
File assetsIndex = getIndexFile(assetIndex.getId()); File assetsIndex = getIndexFile(assetIndex.getId());
File renamed = null; File renamed = null;
// This is unnecessary to do such backup job, FileDownloadTask can do this.
if (assetsIndex.exists()) { if (assetsIndex.exists()) {
renamed = new File(assetsDir, "indexes/" + assetIndex.getId() + "-renamed.json"); renamed = new File(assetsDir, "indexes/" + assetIndex.getId() + "-renamed.json");
if (assetsIndex.renameTo(renamed)) if (assetsIndex.renameTo(renamed))
@@ -150,16 +151,16 @@ public class MinecraftAssetService extends IMinecraftAssetService {
@Override @Override
public File getAssetObject(String assetId, String name) throws IOException { public File getAssetObject(String assetId, String name) throws IOException {
try { try {
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class); AssetsIndex index = C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class);
if (index == null || index.getFileMap() == null || index.getFileMap().get(name) == null) if (index == null || index.getFileMap() == null || index.getFileMap().get(name) == null)
throw new IOException("Assets file format malformed."); throw new IOException("Assets file format malformed.");
return getAssetObject(assetId, (AssetsObject) index.getFileMap().get(name)); return getAssetObject(assetId, index.getFileMap().get(name));
} catch (JsonSyntaxException e) { } catch (JsonSyntaxException e) {
throw new IOException("Assets file format malformed.", e); throw new IOException("Assets file format malformed.", e);
} }
} }
protected boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex, LoggingInfo info) { protected boolean checkAssetsExistence(AssetIndexDownloadInfo assetIndex, LoggingInfo info) {
String assetId = assetIndex.getId(); String assetId = assetIndex.getId();
File indexFile = getIndexFile(assetId); File indexFile = getIndexFile(assetId);
File assetDir = getAssets(assetId); File assetDir = getAssets(assetId);
@@ -208,8 +209,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
HMCLog.log("Reconstructing virtual assets folder at " + virtualRoot); HMCLog.log("Reconstructing virtual assets folder at " + virtualRoot);
int tot = index.getFileMap().entrySet().size(); int tot = index.getFileMap().entrySet().size();
for (Map.Entry<String, AssetsObject> entry : index.getFileMap().entrySet()) { for (Map.Entry<String, AssetsObject> entry : index.getFileMap().entrySet()) {
File target = new File(virtualRoot, (String) entry.getKey()); File target = new File(virtualRoot, entry.getKey());
File original = assetObjectPath(assetsDir, (AssetsObject) entry.getValue()); File original = assetObjectPath(assetsDir, entry.getValue());
if (original.exists()) { if (original.exists()) {
cnt++; cnt++;
if (!target.isFile()) if (!target.isFile())
@@ -240,7 +241,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
LoggingInfo logging = null; LoggingInfo logging = null;
if (t.logging != null) if (t.logging != null)
logging = t.logging.get("client"); logging = t.logging.get("client");
if (allow && !checkAssetsExistance(t.getAssetsIndex(), logging)) if (allow && !checkAssetsExistence(t.getAssetsIndex(), logging))
if (MessageBox.show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) if (MessageBox.show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
TaskWindow.factory().execute(downloadAssets(t)); TaskWindow.factory().execute(downloadAssets(t));
return reconstructAssets(t.getAssetsIndex()).getAbsolutePath(); return reconstructAssets(t.getAssetsIndex()).getAbsolutePath();

View File

@@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import org.jackhuang.hmcl.util.C; import org.jackhuang.hmcl.util.C;
import org.jackhuang.hmcl.util.net.HTTPGetTask; import org.jackhuang.hmcl.util.net.HTTPGetTask;
import org.jackhuang.hmcl.util.net.NetUtils;
import org.jackhuang.hmcl.util.task.Task; import org.jackhuang.hmcl.util.task.Task;
import org.jackhuang.hmcl.util.task.TaskWorker; import org.jackhuang.hmcl.util.task.TaskWorker;

View File

@@ -59,7 +59,7 @@ public abstract class InstallerVersionList {
* *
* @return cached result. * @return cached result.
*/ */
public List<InstallerVersion> getVersionsImpl(String mcVersion) { private List<InstallerVersion> getVersionsImpl(String mcVersion) {
if (versions == null || versionMap == null) if (versions == null || versionMap == null)
return null; return null;
if (StrUtils.isBlank(mcVersion)) if (StrUtils.isBlank(mcVersion))

View File

@@ -78,7 +78,6 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
MinecraftForgeVersion v = root.number.get(num); MinecraftForgeVersion v = root.number.get(num);
InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.mcversion)); InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.mcversion));
for (String[] f : v.files) { for (String[] f : v.files) {
String ver = v.mcversion + "-" + v.version; String ver = v.mcversion + "-" + v.version;
if (!StrUtils.isBlank(v.branch)) if (!StrUtils.isBlank(v.branch))
ver = ver + "-" + v.branch; ver = ver + "-" + v.branch;
@@ -105,7 +104,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
versions.add(iv); versions.add(iv);
} }
versionMap.put(StrUtils.formatVersion(mcver), al); versionMap.put(mcver, al);
} }
Collections.sort(versions, new InstallerVersionComparator()); Collections.sort(versions, new InstallerVersionComparator());

View File

@@ -177,7 +177,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
if (StrUtils.isNotBlank(options.getProxyUser()) && StrUtils.isNotBlank(options.getProxyPass())) { if (StrUtils.isNotBlank(options.getProxyUser()) && StrUtils.isNotBlank(options.getProxyPass())) {
res.add("--proxyUser"); res.add("--proxyUser");
res.add(options.getProxyUser()); res.add(options.getProxyUser());
res.add("-=proxyPass"); res.add("--proxyPass");
res.add(options.getProxyPass()); res.add(options.getProxyPass());
} }
} }

View File

@@ -194,7 +194,7 @@ public abstract class GameLauncher {
boolean isWin = OS.os() == OS.WINDOWS; boolean isWin = OS.os() == OS.WINDOWS;
File f = new File(launcherName + (isWin ? ".bat" : ".sh")); File f = new File(launcherName + (isWin ? ".bat" : ".sh"));
if (!f.exists() && !f.createNewFile()) if (!f.exists() && !f.createNewFile())
HMCLog.warn("Failed to create " + f); throw new IOException("Script file " + f.getAbsolutePath() + " does not exist but cannot be created.");
BufferedWriter writer; BufferedWriter writer;
try (FileOutputStream fos = FileUtils.openOutputStream(f)) { try (FileOutputStream fos = FileUtils.openOutputStream(f)) {
writer = new BufferedWriter(new OutputStreamWriter(fos, Charsets.toCharset())); writer = new BufferedWriter(new OutputStreamWriter(fos, Charsets.toCharset()));

View File

@@ -65,7 +65,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
} }
File f = version.getJar(service.baseDirectory()); File f = version.getJar(service.baseDirectory());
if (!f.exists()) if (!f.exists())
throw new GameException("Minecraft jar does not exists"); throw new GameException("Minecraft jar does not exist");
library.append(f.getAbsolutePath()).append(File.pathSeparator); library.append(f.getAbsolutePath()).append(File.pathSeparator);
res.add("-cp"); res.add("-cp");
res.add(library.toString().substring(0, library.length() - File.pathSeparator.length())); res.add(library.toString().substring(0, library.length() - File.pathSeparator.length()));

View File

@@ -44,7 +44,7 @@ public abstract class IMinecraftProvider<T extends IMinecraftService> {
/** /**
* To download mod packs. * To download mod packs.
*/ */
public abstract void initializeMiencraft(); public abstract void initializeMinecraft();
/** /**
* Get the run directory of given version. * Get the run directory of given version.

View File

@@ -108,7 +108,7 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
if (ask) { if (ask) {
HMCLog.warn("Found not matched filenames version: " + id + ", json: " + jsons[0].getName()); HMCLog.warn("Found not matched filenames version: " + id + ", json: " + jsons[0].getName());
if (MessageBox.show(String.format(C.i18n("launcher.versions_json_not_matched"), id, jsons[0].getName()), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) if (MessageBox.show(String.format(C.i18n("launcher.versions_json_not_matched"), id, jsons[0].getName()), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
if (!jsons[0].renameTo(new File(jsons[0].getParent(), id + ".json"))) if (!jsons[0].renameTo(jsonFile))
HMCLog.warn("Failed to rename version json " + jsons[0]); HMCLog.warn("Failed to rename version json " + jsons[0]);
} }
if (!jsonFile.exists()) { if (!jsonFile.exists()) {
@@ -283,6 +283,7 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
@Override @Override
public boolean onLaunch(String id) { public boolean onLaunch(String id) {
// Fix bug in Minecraft 1.8
File resourcePacks = new File(getRunDirectory(id), "resourcepacks"); File resourcePacks = new File(getRunDirectory(id), "resourcepacks");
if (!FileUtils.makeDirectory(resourcePacks)) if (!FileUtils.makeDirectory(resourcePacks))
HMCLog.warn("Failed to make resourcePacks: " + resourcePacks); HMCLog.warn("Failed to make resourcePacks: " + resourcePacks);
@@ -305,6 +306,6 @@ public class MinecraftVersionManager<T extends IMinecraftService> extends IMinec
} }
@Override @Override
public void initializeMiencraft() { public void initializeMinecraft() {
} }
} }

View File

@@ -103,7 +103,7 @@ public class TaskList extends Thread {
} }
Invoker thread = new Invoker(t2, counter, bool); Invoker thread = new Invoker(t2, counter, bool);
invokers.add(thread); invokers.add(thread);
if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated()) if (!EXECUTOR_SERVICE.isShutdown())
futures.put(thread, EXECUTOR_SERVICE.submit(thread)); futures.put(thread, EXECUTOR_SERVICE.submit(thread));
} }
try { try {