add i18n
This commit is contained in:
@@ -42,6 +42,7 @@ import org.jackhuang.hellominecraft.views.LogWindow;
|
|||||||
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
||||||
import org.jackhuang.hellominecraft.launcher.utils.upgrade.IUpgrader;
|
import org.jackhuang.hellominecraft.launcher.utils.upgrade.IUpgrader;
|
||||||
import org.jackhuang.hellominecraft.launcher.views.MainFrame;
|
import org.jackhuang.hellominecraft.launcher.views.MainFrame;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.views.ServerListView;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
|
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
|
||||||
import org.jackhuang.hellominecraft.utils.MathUtils;
|
import org.jackhuang.hellominecraft.utils.MathUtils;
|
||||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String serverIp = v.getServerIp();
|
String serverIp = v.getServerIp();
|
||||||
if (lr.getServerIp() != null) serverIp = lr.getServerIp();
|
if (lr.getServer() != null) serverIp = lr.getServer().addr;
|
||||||
if (StrUtils.isNotBlank(serverIp)) {
|
if (StrUtils.isNotBlank(serverIp)) {
|
||||||
String[] args = serverIp.split(":");
|
String[] args = serverIp.split(":");
|
||||||
res.add("--server");
|
res.add("--server");
|
||||||
@@ -191,7 +191,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You must do these things:<br />
|
* You must do these things:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>minecraft class path</li>
|
* <li>minecraft class path</li>
|
||||||
* <li>main class</li>
|
* <li>main class</li>
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hellominecraft.launcher.utils.auth;
|
package org.jackhuang.hellominecraft.launcher.utils.auth;
|
||||||
|
|
||||||
|
import org.jackhuang.hellominecraft.launcher.version.ServerInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
@@ -115,13 +117,13 @@ public final class UserProfileProvider {
|
|||||||
private String otherInfo = "";
|
private String otherInfo = "";
|
||||||
private String clientIdentifier = "";
|
private String clientIdentifier = "";
|
||||||
private String userType = "Offline";
|
private String userType = "Offline";
|
||||||
private String serverIp = "";
|
private ServerInfo server = null;
|
||||||
|
|
||||||
public String getServerIp() {
|
public ServerInfo getServer() {
|
||||||
return serverIp;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServerIp(String serverIp) {
|
public void setServer(ServerInfo server) {
|
||||||
this.serverIp = serverIp;
|
this.server = server;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* 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.launcher.version;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import javax.swing.Icon;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import org.jackhuang.hellominecraft.tasks.download.FileDownloadTask;
|
||||||
|
import org.jackhuang.hellominecraft.utils.Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class ServerInfo {
|
||||||
|
|
||||||
|
public String name, addr, picurl, type, info, wfjc, tsjs, version, url, depend;
|
||||||
|
public String[] md5;
|
||||||
|
public int port;
|
||||||
|
|
||||||
|
public Icon icon;
|
||||||
|
|
||||||
|
public void downloadIcon() {
|
||||||
|
if (icon == null && Utils.isURL(picurl))
|
||||||
|
try {
|
||||||
|
File tmp = File.createTempFile("HMCLSERVER", ".png");
|
||||||
|
FileDownloadTask.download(picurl, tmp, null);
|
||||||
|
icon = new ImageIcon(tmp.getAbsolutePath());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
throw new RuntimeException("Failed to download icon", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="lblIcon" min="-2" pref="86" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="lblName" max="32767" attributes="0"/>
|
||||||
|
<Component id="lblInfo" pref="267" max="32767" attributes="0"/>
|
||||||
|
<Component id="lblVersion" alignment="1" pref="267" max="32767" attributes="0"/>
|
||||||
|
<Component id="lblType" alignment="1" pref="267" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<Component id="lblName" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="lblVersion" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="lblType" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="lblInfo" pref="83" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Component id="lblIcon" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JLabel" name="lblIcon">
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="lblName">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Name"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="lblInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Info"/>
|
||||||
|
<Property name="verticalAlignment" type="int" value="1"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="lblVersion">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Version"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="lblType">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Type"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* 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.launcher.views;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.ListCellRenderer;
|
||||||
|
import org.jackhuang.hellominecraft.C;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.version.ServerInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class ServerListCellRenderer extends javax.swing.JPanel implements ListCellRenderer<ServerInfo> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form ServerListCellRenderer
|
||||||
|
*/
|
||||||
|
public ServerListCellRenderer() {
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to
|
||||||
|
* initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
* always regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
lblIcon = new javax.swing.JLabel();
|
||||||
|
lblName = new javax.swing.JLabel();
|
||||||
|
lblInfo = new javax.swing.JLabel();
|
||||||
|
lblVersion = new javax.swing.JLabel();
|
||||||
|
lblType = new javax.swing.JLabel();
|
||||||
|
|
||||||
|
lblName.setText("Name");
|
||||||
|
|
||||||
|
lblInfo.setText("Info");
|
||||||
|
lblInfo.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||||
|
|
||||||
|
lblVersion.setText("Version");
|
||||||
|
|
||||||
|
lblType.setText("Type");
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(lblIcon, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(lblName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(lblInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
|
||||||
|
.addComponent(lblVersion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)
|
||||||
|
.addComponent(lblType, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(lblName)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(lblVersion)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(lblType)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(lblInfo, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE))
|
||||||
|
.addComponent(lblIcon, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<? extends ServerInfo> list, ServerInfo value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
lblName.setText(C.i18n("serverlistview.name") + ": " + value.name);
|
||||||
|
lblType.setText(C.i18n("serverlistview.type") + ": " + value.type);
|
||||||
|
lblVersion.setText(C.i18n("serverlistview.version") + ": " + value.version);
|
||||||
|
lblInfo.setText("<html>" + C.i18n("serverlistview.info") + ": " + value.info + "</html>");
|
||||||
|
if (value.icon != null)
|
||||||
|
lblIcon.setIcon(value.icon);
|
||||||
|
if (isSelected) {
|
||||||
|
setBackground(list.getSelectionBackground());
|
||||||
|
setForeground(list.getSelectionForeground());
|
||||||
|
} else {
|
||||||
|
setBackground(list.getBackground());
|
||||||
|
setForeground(list.getForeground());
|
||||||
|
}
|
||||||
|
setFont(list.getFont());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JLabel lblIcon;
|
||||||
|
private javax.swing.JLabel lblInfo;
|
||||||
|
private javax.swing.JLabel lblName;
|
||||||
|
private javax.swing.JLabel lblType;
|
||||||
|
private javax.swing.JLabel lblVersion;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||||
|
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
|
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="serverlistview.title" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="srlList" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Group type="102" alignment="1" attributes="0">
|
||||||
|
<EmptySpace pref="298" max="32767" attributes="0"/>
|
||||||
|
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="btnOK" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="srlList" pref="257" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="javax.swing.JScrollPane" name="srlList">
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||||
|
</Container>
|
||||||
|
<Component class="javax.swing.JButton" name="btnOK">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
|
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.ok" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="btnCancel">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||||
|
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="button.cancel" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher.
|
||||||
|
* 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.launcher.views;
|
||||||
|
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.version.ServerInfo;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.concurrency.Schedulers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author huangyuhui
|
||||||
|
*/
|
||||||
|
public class ServerListView extends javax.swing.JFrame {
|
||||||
|
|
||||||
|
JList<ServerInfo> lstServer;
|
||||||
|
|
||||||
|
public ServerListView(ServerInfo[] servers) {
|
||||||
|
initComponents();
|
||||||
|
lstServer = new JList<>();
|
||||||
|
lstServer.setModel(new DefaultListModel<>());
|
||||||
|
lstServer.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
srlList.setViewportView(lstServer);
|
||||||
|
|
||||||
|
lstServer.setCellRenderer(new ServerListCellRenderer());
|
||||||
|
DefaultListModel<ServerInfo> model = (DefaultListModel) lstServer.getModel();
|
||||||
|
Observable.<ServerInfo[]>createWithEmptySubscription(t -> {
|
||||||
|
for (ServerInfo i : servers)
|
||||||
|
i.downloadIcon();
|
||||||
|
t.onNext(servers);
|
||||||
|
}).observeOn(Schedulers.eventQueue()).subscribeOn(Schedulers.newThread())
|
||||||
|
.flatMap(t -> Observable.from(t))
|
||||||
|
.subscribe(model::addElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChoice() {
|
||||||
|
setVisible(true);
|
||||||
|
return sel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int sel;
|
||||||
|
public static final int FAILED_TO_SELECT = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to
|
||||||
|
* initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
* always regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
srlList = new javax.swing.JScrollPane();
|
||||||
|
btnOK = new javax.swing.JButton();
|
||||||
|
btnCancel = new javax.swing.JButton();
|
||||||
|
|
||||||
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N"); // NOI18N
|
||||||
|
setTitle(bundle.getString("serverlistview.title")); // NOI18N
|
||||||
|
|
||||||
|
btnOK.setText(bundle.getString("ui.button.ok")); // NOI18N
|
||||||
|
btnOK.setToolTipText("");
|
||||||
|
btnOK.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnOKActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnCancel.setText(bundle.getString("button.cancel")); // NOI18N
|
||||||
|
btnCancel.setToolTipText("");
|
||||||
|
btnCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnCancelActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(srlList)
|
||||||
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||||
|
.addContainerGap(298, Short.MAX_VALUE)
|
||||||
|
.addComponent(btnCancel)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(btnOK)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(srlList, javax.swing.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(btnOK)
|
||||||
|
.addComponent(btnCancel))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
|
sel = lstServer.getSelectedIndex();
|
||||||
|
this.dispose();
|
||||||
|
}//GEN-LAST:event_btnOKActionPerformed
|
||||||
|
|
||||||
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
|
sel = FAILED_TO_SELECT;
|
||||||
|
this.dispose();
|
||||||
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton btnCancel;
|
||||||
|
private javax.swing.JButton btnOK;
|
||||||
|
private javax.swing.JScrollPane srlList;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
||||||
@@ -183,7 +183,11 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void download(String url, String file, DownloadListener dl) throws Throwable {
|
public static void download(String url, String file, DownloadListener dl) throws Throwable {
|
||||||
((Task) new FileDownloadTask(url, new File(file)).setProgressProviderListener(dl)).executeTask();
|
download(url, new File(file), dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void download(String url, File file, DownloadListener dl) throws Throwable {
|
||||||
|
((Task) new FileDownloadTask(url, file).setProgressProviderListener(dl)).executeTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
@@ -41,6 +41,16 @@ import org.jackhuang.hellominecraft.HMCLog;
|
|||||||
*/
|
*/
|
||||||
public final class Utils {
|
public final class Utils {
|
||||||
|
|
||||||
|
@SuppressWarnings("ResultOfObjectAllocationIgnored")
|
||||||
|
public static boolean isURL(String s) {
|
||||||
|
try {
|
||||||
|
new URL(s);
|
||||||
|
return true;
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] getURL() {
|
public static String[] getURL() {
|
||||||
URL[] urls = ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
URL[] urls = ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
||||||
String[] urlStrings = new String[urls.length];
|
String[] urlStrings = new String[urls.length];
|
||||||
@@ -133,7 +143,8 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (background == null) return init;
|
if (background == null)
|
||||||
|
return init;
|
||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Selector extends javax.swing.JDialog {
|
|||||||
* The index of the chosen in select list.
|
* The index of the chosen in select list.
|
||||||
*/
|
*/
|
||||||
public int sel;
|
public int sel;
|
||||||
public static int failedToSel = -1;
|
public static final int FAILED_TO_SELECT = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parent null
|
* @param parent null
|
||||||
@@ -44,7 +44,7 @@ public class Selector extends javax.swing.JDialog {
|
|||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
this.selList = selList;
|
this.selList = selList;
|
||||||
this.sel = failedToSel;
|
this.sel = FAILED_TO_SELECT;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
jLabel1.setText(msg);
|
jLabel1.setText(msg);
|
||||||
for (String s : selList)
|
for (String s : selList)
|
||||||
@@ -127,7 +127,7 @@ public class Selector extends javax.swing.JDialog {
|
|||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||||
sel = failedToSel;
|
sel = FAILED_TO_SELECT;
|
||||||
this.dispose();
|
this.dispose();
|
||||||
}//GEN-LAST:event_btnCancelActionPerformed
|
}//GEN-LAST:event_btnCancelActionPerformed
|
||||||
|
|
||||||
|
|||||||
@@ -313,6 +313,12 @@ logwindow.title=\u65e5\u5fd7
|
|||||||
|
|
||||||
selector.choose=\u9009\u62e9
|
selector.choose=\u9009\u62e9
|
||||||
|
|
||||||
|
serverlistview.title=\u9009\u62e9\u670d\u52a1\u5668
|
||||||
|
serverlistview.name=\u540d\u79f0
|
||||||
|
serverlistview.type=\u7c7b\u578b
|
||||||
|
serverlistview.version=\u7248\u672c
|
||||||
|
serverlistview.info=\u4fe1\u606f
|
||||||
|
|
||||||
minecraft.invalid=\u65e0\u6548\u7684
|
minecraft.invalid=\u65e0\u6548\u7684
|
||||||
minecraft.invalid_jar=\u65e0\u6548\u7684jar\u5305
|
minecraft.invalid_jar=\u65e0\u6548\u7684jar\u5305
|
||||||
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
||||||
|
|||||||
@@ -313,6 +313,12 @@ logwindow.title=Log
|
|||||||
|
|
||||||
selector.choose=Choose
|
selector.choose=Choose
|
||||||
|
|
||||||
|
serverlistview.title=Choose a server
|
||||||
|
serverlistview.name=Name
|
||||||
|
serverlistview.type=Type
|
||||||
|
serverlistview.version=Version
|
||||||
|
serverlistview.info=Information
|
||||||
|
|
||||||
minecraft.invalid=Invalid
|
minecraft.invalid=Invalid
|
||||||
minecraft.invalid_jar=Invalid Jar
|
minecraft.invalid_jar=Invalid Jar
|
||||||
minecraft.not_a_file=Not a file
|
minecraft.not_a_file=Not a file
|
||||||
|
|||||||
@@ -313,6 +313,12 @@ logwindow.title=\u65e5\u5fd7
|
|||||||
|
|
||||||
selector.choose=\u9078\u64c7
|
selector.choose=\u9078\u64c7
|
||||||
|
|
||||||
|
serverlistview.title=\u9078\u64c7\u670d\u52d9\u5668
|
||||||
|
serverlistview.name=\u540d\u79f0
|
||||||
|
serverlistview.type=\u7c7b\u578b
|
||||||
|
serverlistview.version=\u7248\u672c
|
||||||
|
serverlistview.info=\u4fe1\u606f
|
||||||
|
|
||||||
minecraft.invalid=\u7121\u6548\u7684
|
minecraft.invalid=\u7121\u6548\u7684
|
||||||
minecraft.invalid_jar=\u7121\u6548\u7684jar\u5305
|
minecraft.invalid_jar=\u7121\u6548\u7684jar\u5305
|
||||||
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
||||||
|
|||||||
@@ -310,6 +310,12 @@ logwindow.title=\u65e5\u5fd7
|
|||||||
|
|
||||||
selector.choose=\u9009\u62e9
|
selector.choose=\u9009\u62e9
|
||||||
|
|
||||||
|
serverlistview.title=\u9009\u62e9\u670d\u52a1\u5668
|
||||||
|
serverlistview.name=\u540d\u79f0
|
||||||
|
serverlistview.type=\u7c7b\u578b
|
||||||
|
serverlistview.version=\u7248\u672c
|
||||||
|
serverlistview.info=\u4fe1\u606f
|
||||||
|
|
||||||
minecraft.invalid=\u65e0\u6548\u7684
|
minecraft.invalid=\u65e0\u6548\u7684
|
||||||
minecraft.invalid_jar=\u65e0\u6548\u7684jar\u5305
|
minecraft.invalid_jar=\u65e0\u6548\u7684jar\u5305
|
||||||
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
minecraft.not_a_file=\u4e0d\u662f\u6587\u4ef6
|
||||||
|
|||||||
Reference in New Issue
Block a user