mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-08 19:35:36 -04:00
Clean up
This commit is contained in:
parent
68cfa3a5da
commit
809d7378e2
@ -46,7 +46,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
if (names.contains(s.lib.name))
|
||||
continue;
|
||||
names.add(s.lib.name);
|
||||
parallelTask.addDependsTask(new LibraryDownloadTask(s));
|
||||
parallelTask.addTask(new LibraryDownloadTask(s));
|
||||
}
|
||||
dw.append(parallelTask);
|
||||
boolean flag = true;
|
||||
|
@ -111,10 +111,10 @@ public class GameDownloadPanel extends Page {
|
||||
MinecraftRemoteVersions.refreshRomoteVersions(Settings.getLastProfile().service().getDownloadType())
|
||||
.reg((ver) -> model.addRow(new Object[] { ver.id, ver.time,
|
||||
StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type }))
|
||||
.regDone(() -> {
|
||||
.regDone(SwingUtils.invokeLater(() -> {
|
||||
lstDownloads.requestFocus();
|
||||
model.removeRow(0);
|
||||
}).execute();
|
||||
})).execute();
|
||||
}
|
||||
|
||||
void downloadMinecraft() {
|
||||
|
@ -112,13 +112,6 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
Settings.profileChangedEvent.register(onSelectedProfilesChanged);
|
||||
|
||||
dropTarget = new DropTarget(lstExternalMods, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
||||
|
||||
/*AeroPage pnlAero = new AeroPage();
|
||||
pnlAero.setBounds(0, 0, 800, 480);
|
||||
pnlAero.setLayout(null);
|
||||
pnlAero.addAeroObject(jPanel1);
|
||||
pnlAero.setBackgroundImage(MainFrame.INSTANCE.background.getImage());
|
||||
add(jPanel1);*/
|
||||
}
|
||||
|
||||
void initExplorationMenu() {
|
||||
@ -248,9 +241,11 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
((NewTabPane) tabVersionEdit).initializing = true;
|
||||
tabVersionEdit.addTab(C.i18n("settings.tabs.game_download"), pnlGameDownloads); // NOI18N
|
||||
tabVersionEdit.addTab(C.i18n("settings.tabs.game_download"), pnlGameDownloads);
|
||||
((NewTabPane) tabVersionEdit).initializing = false;
|
||||
|
||||
((NewTabPane) tabInstallers).initializing = true;
|
||||
for (int i = 0; i < InstallerType.values().length; i++)
|
||||
tabInstallers.addTab(InstallerType.values()[i].getLocalizedName(), installerPanels[i]);
|
||||
|
@ -67,16 +67,15 @@
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblModpack" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableBlur" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="chkDecorated" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkEnableBlur" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -121,20 +120,21 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkEnableShadow" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkEnableBlur" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="6" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCheckUpdate" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" alignment="3" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblModpack" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" pref="173" max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
@ -293,14 +293,13 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableBlur)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chkDecorated)))
|
||||
.addComponent(lblRestart)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkEnableBlur))
|
||||
.addComponent(chkDecorated))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
@ -337,9 +336,10 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addComponent(chkDecorated)
|
||||
.addComponent(chkEnableBlur))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkDecorated)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 6, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
@ -348,7 +348,7 @@ public class LauncherSettingsPanel extends RepaintPage {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
@ -31,7 +31,7 @@ import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huang
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class NetUtils {
|
||||
|
||||
|
@ -24,7 +24,7 @@ import java.util.Locale;
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public enum SupportedLocales {
|
||||
def(Locale.getDefault(), "lang.default"), en(Locale.ENGLISH, null), zh_TW(Locale.TRADITIONAL_CHINESE, null), zh_CN(Locale.SIMPLIFIED_CHINESE, null);
|
||||
def(Locale.getDefault(), "lang.default"), en(Locale.ENGLISH, null), zh_TW(Locale.TRADITIONAL_CHINESE, null), zh_CN(Locale.SIMPLIFIED_CHINESE, null), vi(new Locale("vi"), null);
|
||||
|
||||
public Locale self;
|
||||
private String showString, customized;
|
||||
|
@ -26,7 +26,7 @@ import java.util.HashSet;
|
||||
*/
|
||||
public class ParallelTask extends Task {
|
||||
|
||||
Collection<Task> dependsTask = new HashSet<>();
|
||||
Collection<Task> tasks = new HashSet<>();
|
||||
|
||||
public ParallelTask() {
|
||||
hidden = true;
|
||||
@ -43,11 +43,11 @@ public class ParallelTask extends Task {
|
||||
|
||||
@Override
|
||||
public Collection<Task> getDependTasks() {
|
||||
return dependsTask;
|
||||
return tasks;
|
||||
}
|
||||
|
||||
public void addDependsTask(Task t) {
|
||||
dependsTask.add(t);
|
||||
public void addTask(Task t) {
|
||||
tasks.add(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,15 +23,13 @@ package org.jackhuang.hellominecraft.util.tasks;
|
||||
*/
|
||||
public abstract class TaskInfo extends Task {
|
||||
|
||||
String info;
|
||||
|
||||
public TaskInfo(String info) {
|
||||
this.info = info;
|
||||
this.tag = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
return info;
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,12 +70,10 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
return;
|
||||
taskList = new TaskList();
|
||||
taskList.addTaskListener(this);
|
||||
taskList.doneEvent.register(() -> {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
dispose();
|
||||
suc = true;
|
||||
});
|
||||
});
|
||||
taskList.doneEvent.register(SwingUtils.invokeLater(() -> {
|
||||
dispose();
|
||||
suc = true;
|
||||
}));
|
||||
}
|
||||
|
||||
public static String downloadSource = "";
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Hello Minecraft!.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.tasks.comm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
* @param <T> the type of result.
|
||||
*/
|
||||
public class DefaultPreviousResult<T> implements PreviousResult<T> {
|
||||
|
||||
T a;
|
||||
|
||||
public DefaultPreviousResult(T a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getResult() {
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ public interface PreviousResultRegistrar<T> {
|
||||
*
|
||||
* @param pr previous task handler
|
||||
*
|
||||
* @return task self instance
|
||||
* @return task self instance(factory mode!)
|
||||
*/
|
||||
Task registerPreviousResult(PreviousResult<T> pr);
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Hello Minecraft!.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.tasks.download;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.tasks.ProgressProviderListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public interface DownloadListener extends ProgressProviderListener {
|
||||
|
||||
boolean OnFailed();
|
||||
|
||||
void OnFailedMoreThan5Times(String url);
|
||||
}
|
@ -130,12 +130,12 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
||||
|
||||
// Make sure response code is in the 200 range.
|
||||
if (con.getResponseCode() / 100 != 2)
|
||||
throw new NetException(C.i18n("download.not_200") + " " + con.getResponseCode());
|
||||
throw new IOException(C.i18n("download.not_200") + " " + con.getResponseCode());
|
||||
|
||||
// Check for valid content length.
|
||||
int contentLength = con.getContentLength();
|
||||
if (contentLength < 1)
|
||||
throw new NetException("The content length is invalid.");
|
||||
throw new IOException("The content length is invalid.");
|
||||
|
||||
if (!filePath.getParentFile().mkdirs() && !filePath.getParentFile().isDirectory())
|
||||
throw new IOException("Could not make directory");
|
||||
@ -210,8 +210,8 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
||||
if (ppl != null)
|
||||
ppl.onProgressProviderDone(this);
|
||||
return;
|
||||
} catch (IOException | IllegalStateException | NetException e) {
|
||||
setFailReason(new NetException(C.i18n("download.failed") + " " + url, e));
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
setFailReason(new IOException(C.i18n("download.failed") + " " + url, e));
|
||||
} finally {
|
||||
closeFiles();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class HTTPGetTask extends Task implements PreviousResult<String> {
|
||||
doneEvent.execute(result);
|
||||
return;
|
||||
} catch (IOException ex) {
|
||||
t = new NetException("Failed to get " + url, ex);
|
||||
t = new IOException("Failed to get " + url, ex);
|
||||
}
|
||||
}
|
||||
if (t != null)
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Hello Minecraft!.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.tasks.download;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class NetException extends RuntimeException {
|
||||
|
||||
public NetException(Exception message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NetException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NetException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
|
||||
}
|
@ -51,12 +51,9 @@ public class LogWindowOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
private void append(final String str) {
|
||||
try {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
txt.log(str, Level.guessLevel(str, sas));
|
||||
});
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
txt.log(str, Level.guessLevel(str, sas));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ import javax.swing.JScrollBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
@ -55,58 +56,58 @@ import org.jackhuang.hellominecraft.util.system.OS;
|
||||
* @author huang
|
||||
*/
|
||||
public final class SwingUtils {
|
||||
|
||||
|
||||
private SwingUtils() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make DefaultTableModel by overriding getColumnClass and isCellEditable of
|
||||
* DefaultTableModel.
|
||||
*
|
||||
* @param titleA The title of each column.
|
||||
* @param typesA The type of each column value.
|
||||
* @param titleA The title of each column.
|
||||
* @param typesA The type of each column value.
|
||||
* @param canEditA Is column editable?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static DefaultTableModel makeDefaultTableModel(String[] titleA, final Class[] typesA, final boolean[] canEditA) {
|
||||
return new DefaultTableModel(
|
||||
new Object[][] {},
|
||||
titleA) {
|
||||
new Object[][] {},
|
||||
titleA) {
|
||||
Class[] types = typesA;
|
||||
boolean[] canEdit = canEditA;
|
||||
|
||||
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
return types[columnIndex];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return canEdit[columnIndex];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static void openFolder(File f) {
|
||||
f.mkdirs();
|
||||
String path = f.getAbsolutePath();
|
||||
switch (OS.os()) {
|
||||
case OSX:
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { "/usr/bin/open", path });
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Failed to open " + path + " through /usr/bin/open", ex);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
java.awt.Desktop.getDesktop().open(f);
|
||||
} catch (Throwable ex) {
|
||||
MessageBox.show(C.i18n("message.cannot_open_explorer") + ex.getMessage());
|
||||
HMCLog.warn("Failed to open " + path + " through java.awt.Desktop.getDesktop().open()", ex);
|
||||
}
|
||||
break;
|
||||
case OSX:
|
||||
try {
|
||||
Runtime.getRuntime().exec(new String[] { "/usr/bin/open", path });
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Failed to open " + path + " through /usr/bin/open", ex);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
java.awt.Desktop.getDesktop().open(f);
|
||||
} catch (Throwable ex) {
|
||||
MessageBox.show(C.i18n("message.cannot_open_explorer") + ex.getMessage());
|
||||
HMCLog.warn("Failed to open " + path + " through java.awt.Desktop.getDesktop().open()", ex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,18 +166,18 @@ public final class SwingUtils {
|
||||
/**
|
||||
* Append new element to JList
|
||||
*
|
||||
* @param list the JList
|
||||
* @param list the JList
|
||||
* @param element the Element
|
||||
*/
|
||||
public static void appendLast(JList list, Object element) {
|
||||
getDefaultListModel(list).addElement(element);
|
||||
}
|
||||
|
||||
|
||||
public static void replaceLast(JList list, Object element) {
|
||||
DefaultListModel model = getDefaultListModel(list);
|
||||
model.set(model.getSize() - 1, element);
|
||||
}
|
||||
|
||||
|
||||
public static void clear(JList list) {
|
||||
list.setModel(new DefaultListModel());
|
||||
}
|
||||
@ -194,17 +195,17 @@ public final class SwingUtils {
|
||||
model.removeRow(0);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
public static void appendLast(JTable table, Object... elements) {
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
model.addRow(elements);
|
||||
}
|
||||
|
||||
|
||||
public static void setValueAt(JTable table, Object element, int row, int col) {
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
model.setValueAt(element, row, col);
|
||||
}
|
||||
|
||||
|
||||
public static Object[] getValueBySelectedRow(JTable table, int rows[], int col) {
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
Object[] ret = new Object[rows.length];
|
||||
@ -212,12 +213,12 @@ public final class SwingUtils {
|
||||
ret[i] = model.getValueAt(rows[i], col);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public static void removeRow(JTable table, int row) {
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
model.removeRow(row);
|
||||
}
|
||||
|
||||
|
||||
public static String getParsedJPanelText(JLabel jLabel1, String longString) {
|
||||
if (StrUtils.isBlank(longString))
|
||||
return longString;
|
||||
@ -239,11 +240,11 @@ public final class SwingUtils {
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
private static final Map<Integer, Object> INVOKE_AND_WAIT_MAP = Collections.synchronizedMap(new HashMap<>());
|
||||
private static int INVOKE_AND_WAIT_ID = 0;
|
||||
private static final Object INVOKE_AND_WAIT_LOCK = new Object();
|
||||
|
||||
|
||||
public static <T> T invokeAndWait(NonFunction<T> x) {
|
||||
int id;
|
||||
synchronized (INVOKE_AND_WAIT_LOCK) {
|
||||
@ -254,7 +255,7 @@ public final class SwingUtils {
|
||||
invokeAndWait(r);
|
||||
return (T) INVOKE_AND_WAIT_MAP.remove(id);
|
||||
}
|
||||
|
||||
|
||||
public static void invokeAndWait(Runnable r) {
|
||||
if (EventQueue.isDispatchThread())
|
||||
r.run();
|
||||
@ -266,7 +267,7 @@ public final class SwingUtils {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int select(String[] selList, String msg) {
|
||||
Object msgs[] = new Object[2];
|
||||
msgs[0] = msg;
|
||||
@ -276,7 +277,7 @@ public final class SwingUtils {
|
||||
return -1;
|
||||
return ((JComboBox) msgs[1]).getSelectedIndex();
|
||||
}
|
||||
|
||||
|
||||
public static void setEnabled(JComponent component, boolean t) {
|
||||
synchronized (component.getTreeLock()) {
|
||||
for (Component c : component.getComponents())
|
||||
@ -285,11 +286,11 @@ public final class SwingUtils {
|
||||
}
|
||||
component.setEnabled(t);
|
||||
}
|
||||
|
||||
|
||||
public static void exitIfNoWindow(Window thisFrame) {
|
||||
exitIfNoWindow(thisFrame, false);
|
||||
}
|
||||
|
||||
|
||||
public static void exitIfNoWindow(Window thisFrame, boolean neededDispose) {
|
||||
boolean flag = false;
|
||||
for (Window f : Window.getWindows()) {
|
||||
@ -308,11 +309,11 @@ public final class SwingUtils {
|
||||
else
|
||||
thisFrame.dispose();
|
||||
}
|
||||
|
||||
|
||||
public static ImageIcon scaleImage(ImageIcon i, int x, int y) {
|
||||
return new ImageIcon(i.getImage().getScaledInstance(x, y, Image.SCALE_SMOOTH));
|
||||
}
|
||||
|
||||
|
||||
public static ImageIcon searchBackgroundImage(ImageIcon init, String bgpath, int width, int height) {
|
||||
Random r = new Random();
|
||||
boolean loaded = false;
|
||||
@ -362,9 +363,15 @@ public final class SwingUtils {
|
||||
HMCLog.log("Prepared background image in background.jpg.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (background == null)
|
||||
return init;
|
||||
return background;
|
||||
}
|
||||
|
||||
public static Runnable invokeLater(Runnable r) {
|
||||
return () -> {
|
||||
SwingUtilities.invokeLater(r);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
43
README.md
43
README.md
@ -1,31 +1,26 @@
|
||||
# Hello Minecraft! Launcher [](https://travis-ci.org/huanghongxun/HMCL)
|
||||
开源协议为GPL v3, 详情参见http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
## 介绍
|
||||
## Introduction
|
||||
|
||||
HMCL是一个Minecraft启动器,支持Mod管理,游戏定制,自动安装,整合包制作,界面主题定制等功能。
|
||||
并且一天的使用次数在工作日时有40万左右、节假日有150万左右的使用次数,也就是说日活跃用户在10万以上。
|
||||
但是本项目的代码不够完善,希望有更多的人能加入HMCL的开发。
|
||||
HMCL is a Minecraft launcher which supports Mod management, game customizing, auto installing(Forge, LiteLoader and OptiFine), modpack creating, UI customizing and so on.
|
||||
|
||||
## 贡献
|
||||
如果你很想为本项目贡献代码,这里有一些要求:
|
||||
* 开发环境为Netbeans 8.1
|
||||
* 编译器为Java 1.8,通过retrolambda兼容Java 1.7,所以请不要使用Java 8的新API(如Stream)
|
||||
* 请不要修改`gradle`文件
|
||||
## Contribution
|
||||
If you want to submit a pull request, there're some requirements:
|
||||
* IDE: Netbeans 8.1
|
||||
* Compiler: Java 1.8 and libraries only supports Java 1.7(because of retrolambda).
|
||||
* Do NOT modify `gradle` files.
|
||||
|
||||
## 代码
|
||||
* 包 `org.jackhuang.hellominecraft.util` 为HMCL和HMCSM的共用工具代码
|
||||
* 包 `org.jackhuang.hellominecraft.launcher` 包含了HMCL的界面以及逻辑代码
|
||||
* 包 `org.jackhuang.hellominecraft.launcher.core` 为HMCL的启动核心
|
||||
* 包 `org.jackhuang.hellominecraft.launcher.api` 是HMCL为了便于定制提供的API,暂不支持加载插件
|
||||
* 包 `org.jackhuang.hellominecraft.svrmgr` 为HMCSM的所有代码
|
||||
* 文件夹 `HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang` 包含了HMCL和HMCSM使用的语言文件
|
||||
## Code
|
||||
* package `org.jackhuang.hellominecraft.util`: HMCL development utilities.
|
||||
* package `org.jackhuang.hellominecraft.launcher`: HMCL UI core.
|
||||
* package `org.jackhuang.hellominecraft.launcher.core`: HMCL game launcher core.
|
||||
* package `org.jackhuang.hellominecraft.launcher.api`: Nothing here!
|
||||
* package `org.jackhuang.hellominecraft.svrmgr`: All HMCSM codes.
|
||||
* Folder `HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang` contains language files.
|
||||
|
||||
由于包树已经相当清晰,因此不再赘述各包各类的用途。
|
||||
|
||||
## 注意事项
|
||||
* 包 `org.jackhuang.hellominecraft.util.logging` 包含了经过精简的Apache License 2.0的Log4j项目的代码
|
||||
* 包 `com.google.gson` 为Google Gson项目Apache License 2.0的代码
|
||||
* 包 `org.jackhuang.hellominecraft.lookandfeel.ui` 包含了Sun Microsystems的NimbusLookAndFeel项目的部分LGPL代码
|
||||
* 所有Pull Request提交的代码均会被重写
|
||||
* 本项目的开源协议是GPL v3,因此包含LGPL和Apache License 2.0的代码是没有法律问题的
|
||||
## Pay Attention
|
||||
* When you do decide to modify this app, please and you MUST delete `org.jackhuang.hellominecraft.launcher.util.CrashReporter`, or errors your code cause will be sent to my server.
|
||||
* package `org.jackhuang.hellominecraft.util.logging`: repackaged Apache Log4j, Apache License 2.0.
|
||||
* package `com.google.gson`: Apache License 2.0
|
||||
* package `org.jackhuang.hellominecraft.lookandfeel.ui`: contains some NimbusLAF's code belonging to Sun Microsystems under LGPL.
|
Loading…
x
Reference in New Issue
Block a user