add some localization items
This commit is contained in:
@@ -50,8 +50,8 @@ import org.jackhuang.hellominecraft.utils.version.MinecraftVersionRequest;
|
||||
*
|
||||
* This class can manage mod packs, for example, importing and exporting, the
|
||||
* format of game is the offical one.
|
||||
* Not compatible with MultiMC(no instance.cfg) & FTB(not leaving mcversion in
|
||||
* pack.json).
|
||||
* Not compatible with MultiMC(no instance.cfg processor) & FTB(not leaving
|
||||
* mcversion(jar) in pack.json).
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
@@ -75,19 +75,17 @@ public final class ModpackManager {
|
||||
Compressor.unzip(input, versions, t -> {
|
||||
if (t.equals("minecraft/pack.json"))
|
||||
b.incrementAndGet();
|
||||
if (t.equals("minecraft/pack.jar"))
|
||||
b.incrementAndGet();
|
||||
return true;
|
||||
});
|
||||
if (b.get() < 2)
|
||||
throw new FileNotFoundException("the mod pack is in an incorrect format.");
|
||||
if (b.get() < 1)
|
||||
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_json"));
|
||||
File nowFile = new File(versions, id);
|
||||
oldFile.renameTo(nowFile);
|
||||
|
||||
File json = new File(nowFile, "pack.json");
|
||||
MinecraftVersion mv = C.gson.fromJson(FileUtils.readFileToString(json), MinecraftVersion.class);
|
||||
if (mv.jar == null)
|
||||
throw new FileSystemException("the mod pack is in an incorrect format, pack.json does not have attribute 'jar'.");
|
||||
throw new FileNotFoundException(C.i18n("modpack.incorrect_format.no_jar"));
|
||||
service.download().downloadMinecraftJarTo(mv.jar, new File(nowFile, id + ".jar"));
|
||||
mv.jar = null;
|
||||
FileUtils.writeStringToFile(json, C.gsonPrettyPrinting.toJson(mv));
|
||||
@@ -132,7 +130,7 @@ public final class ModpackManager {
|
||||
mv.runDir = "version";
|
||||
MinecraftVersionRequest r = MinecraftVersionRequest.minecraftVersion(provider.getMinecraftJar(version));
|
||||
if (r.type != MinecraftVersionRequest.OK)
|
||||
throw new FileSystemException("Cannot read vanilla version, " + MinecraftVersionRequest.getResponse(r));
|
||||
throw new FileSystemException(C.i18n("modpack.cannot_read_version") + ": " + MinecraftVersionRequest.getResponse(r));
|
||||
mv.jar = r.version;
|
||||
zip.putTextFile(C.gsonPrettyPrinting.toJson(mv), "minecraft/pack.json");
|
||||
} finally {
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
<Component class="javax.swing.JButton" name="btnExportModpack">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.save.task" replaceFormat="C.i18n("{key}")"/>
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="modpack.save.task" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
@@ -357,7 +357,7 @@
|
||||
<Component class="javax.swing.JButton" name="btnImportModpack">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.install.task" replaceFormat="C.i18n("{key}")"/>
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="modpack.install.task" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -409,14 +407,14 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
});
|
||||
|
||||
btnExportModpack.setText(C.i18n("settings.modpack.save.task")); // NOI18N
|
||||
btnExportModpack.setText(C.i18n("modpack.save.task")); // NOI18N
|
||||
btnExportModpack.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnExportModpackActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
btnImportModpack.setText(C.i18n("settings.modpack.install.task")); // NOI18N
|
||||
btnImportModpack.setText(C.i18n("modpack.install.task")); // NOI18N
|
||||
btnImportModpack.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnImportModpackActionPerformed(evt);
|
||||
@@ -1144,18 +1142,18 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
private void btnImportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportModpackActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.modpack.choose"));
|
||||
fc.setDialogTitle(C.i18n("modpack.choose"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), "zip"));
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("modpack"), "zip"));
|
||||
fc.showOpenDialog(this);
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
||||
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack.install.task"), () -> {
|
||||
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("modpack.install.task"), () -> {
|
||||
try {
|
||||
ModpackManager.install(fc.getSelectedFile(), getProfile().service(), suggestedModpackId);
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show(C.i18n("settings.modpack.install_error"));
|
||||
MessageBox.Show(C.i18n("modpack.install_error"));
|
||||
HMCLog.err("Failed to install modpack", ex);
|
||||
}
|
||||
})).start();
|
||||
@@ -1164,7 +1162,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
private void btnExportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportModpackActionPerformed
|
||||
Map settings = (Map) WizardDisplayer.showWizard(new ModpackWizard(getProfile().service().version()).createWizard());
|
||||
if (settings != null)
|
||||
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack.save.task"),
|
||||
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("modpack.save.task"),
|
||||
() -> {
|
||||
try {
|
||||
ModpackManager.export(new File((String) settings.get(ModpackInitializationPanel.KEY_MODPACK_LOCATION)),
|
||||
@@ -1172,7 +1170,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
(String) settings.get(ModpackInitializationPanel.KEY_GAME_VERSION),
|
||||
((Boolean) settings.get(ModpackInitializationPanel.KEY_SAVE) == false) ? Arrays.asList("saves") : null);
|
||||
} catch (IOException | GameException ex) {
|
||||
MessageBox.Show(C.i18n("settings.modpack.export_error"));
|
||||
MessageBox.Show(C.i18n("modpack.export_error"));
|
||||
HMCLog.err("Failed to export modpack", ex);
|
||||
}
|
||||
})).start();
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblModpackLocation" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="175" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="cboModpackLocation" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="txtModpackLocation" max="32767" attributes="0"/>
|
||||
@@ -30,8 +30,9 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblGameVersion" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkSave" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="67" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -42,19 +43,21 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="92" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="lblModpackLocation" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cboModpackLocation" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtModpackLocation" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblGameVersion" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="cboGameVersion" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkSave" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="133" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -63,7 +66,7 @@
|
||||
<Component class="javax.swing.JLabel" name="lblModpackLocation">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.save" replaceFormat="C.i18n("{key}")"/>
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="modpack.save" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
@@ -106,5 +109,12 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkSaveItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="modpack.warning" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.views.modpack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JFileChooser;
|
||||
@@ -51,7 +50,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
wizardData.put(KEY_SAVE, false);
|
||||
|
||||
configureComboContents();
|
||||
controller.setProblem("Not a valid file location");
|
||||
controller.setProblem(C.i18n("modpack.not_a_valid_location"));
|
||||
|
||||
controller.setForwardNavigationMode(WizardController.MODE_CAN_FINISH);
|
||||
}
|
||||
@@ -78,8 +77,9 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
lblGameVersion = new javax.swing.JLabel();
|
||||
cboGameVersion = new javax.swing.JComboBox<>();
|
||||
chkSave = new javax.swing.JCheckBox();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
lblModpackLocation.setText(C.i18n("settings.modpack.save")); // NOI18N
|
||||
lblModpackLocation.setText(C.i18n("modpack.save")); // NOI18N
|
||||
|
||||
txtModpackLocation.addCaretListener(new javax.swing.event.CaretListener() {
|
||||
public void caretUpdate(javax.swing.event.CaretEvent evt) {
|
||||
@@ -109,6 +109,8 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
jLabel1.setText(C.i18n("modpack.warning")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -118,42 +120,45 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblModpackLocation)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cboModpackLocation))
|
||||
.addComponent(txtModpackLocation)
|
||||
.addComponent(cboGameVersion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblGameVersion)
|
||||
.addComponent(chkSave))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addComponent(chkSave)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 67, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblModpackLocation)
|
||||
.addComponent(cboModpackLocation))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtModpackLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(29, 29, 29)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblGameVersion)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(cboGameVersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkSave)
|
||||
.addContainerGap(133, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cboModpackLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboModpackLocationActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.modpack.save"));
|
||||
fc.setDialogTitle(C.i18n("modpack.save"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack") + "(*.zip)", "zip"));
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("modpack") + "(*.zip)", "zip"));
|
||||
fc.showSaveDialog(this);
|
||||
if (fc.getSelectedFile() != null)
|
||||
txtModpackLocation.setText(fc.getSelectedFile().getAbsolutePath());
|
||||
@@ -163,7 +168,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
wizardData.put(KEY_MODPACK_LOCATION, txtModpackLocation.getText());
|
||||
|
||||
if (txtModpackLocation.getText().trim().isEmpty())
|
||||
controller.setProblem("Please choose a location!!!");
|
||||
controller.setProblem(C.i18n("modpack.not_a_valid_location"));
|
||||
else
|
||||
controller.setProblem(null);
|
||||
}//GEN-LAST:event_txtModpackLocationCaretUpdate
|
||||
@@ -180,6 +185,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
private javax.swing.JComboBox<String> cboGameVersion;
|
||||
private javax.swing.JButton cboModpackLocation;
|
||||
private javax.swing.JCheckBox chkSave;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel lblGameVersion;
|
||||
private javax.swing.JLabel lblModpackLocation;
|
||||
private javax.swing.JTextField txtModpackLocation;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import javax.swing.JComponent;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.utils.C;
|
||||
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardBranchController;
|
||||
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardController;
|
||||
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardPanelProvider;
|
||||
@@ -33,7 +34,7 @@ import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardPanelProvider;
|
||||
public class ModpackWizard extends WizardBranchController {
|
||||
|
||||
public ModpackWizard(IMinecraftProvider provider) {
|
||||
super(new WizardPanelProvider("Modpack Wizard", new String[] { "Settings" }, new String[] { "Select location, version and allow version" }) {
|
||||
super(new WizardPanelProvider(C.i18n("modpack.wizard"), new String[] { C.i18n("modpack.wizard.step.1") }, new String[] { C.i18n("modpack.wizard.step.1.title") }) {
|
||||
|
||||
@Override
|
||||
protected JComponent createPanel(WizardController controller, String id, Map settings) {
|
||||
|
||||
Reference in New Issue
Block a user