diff --git a/.drone.yml b/.drone.yml
index bfc8767..6282950 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -3,8 +3,8 @@ type: docker
name: default
steps:
- - name: build-install-locally
- image: maven:3-jdk-11
+ - name: build
+ image: maven:3-openjdk-17
commands:
- mvn -B -DskipTests clean install
- mvn test -B
@@ -17,6 +17,7 @@ steps:
commands:
- mkdir -p /builds/Tihwin
- cp target/Tihwin-*[0-9].jar /builds/Tihwin/
+ - cp target/Tihwin-*[0-9].exe /builds/Tihwin/
volumes:
- name: builds
path: /builds
diff --git a/README.md b/README.md
index 4df2f71..1069811 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,9 @@
## Tihwin
![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![LatestVer](https://img.shields.io/github/release/developersu/Tihwin.svg) [![Build Status](https://ci.redrise.ru/api/badges/desu/Tihwin/status.svg)](https://ci.redrise.ru/desu/Tihwin)
-OPL-compatible PS2 tool for making split files. Sort of ul.cfg manager or USBUtil.
+[по-русски](README_RU.md)
+
+OPL-compatible PS2 tool for making split files. Sort of ul.cfg manager or USBUtil. Good for use on mac and linux.
![Application screenshot1](screenshots/1.png)
![Application screenshot2](screenshots/2.png)
@@ -14,6 +16,10 @@ GitHubs are arising and passing, cozy mirrors are eternal: https://git.redrise.r
GNU GLPv3 or higher. Please see LICENSE.
+#### Requirements
+
+* Java
+
#### Feedback
Create new GitHub issue with bug report or proposition
@@ -21,6 +27,7 @@ Create new GitHub issue with bug report or proposition
#### Thanks
* [DDinghoya](https://github.com/DDinghoya), who translated this application to Korean!
+* [Ignacio Grosso](https://github.com/blckbearx), who translated this application to Spanish!
#### Translations
diff --git a/README_RU.md b/README_RU.md
new file mode 100644
index 0000000..c7274ef
--- /dev/null
+++ b/README_RU.md
@@ -0,0 +1,38 @@
+## Tihwin
+![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![LatestVer](https://img.shields.io/github/release/developersu/Tihwin.svg) [![Build Status](https://ci.redrise.ru/api/badges/desu/Tihwin/status.svg)](https://ci.redrise.ru/desu/Tihwin)
+
+Это OPL-совместимая утилита для PS2. Используется для создания т.н. «сплит-файлов». Это что-то вроде менеджера ul.cfg или, другими словами, аналог USBUtil. Отличной подойдёт для использования в маке и линуксе.
+
+![Application screenshot1](screenshots/1.png)
+![Application screenshot2](screenshots/2.png)
+
+#### Не будем теряться!
+
+Гитхабы приходят и уходят, уютные зеркала же − вечны! https://git.redrise.ru/desu/Tihwin
+
+#### Лицензия
+
+GNU GLPv3 или выше. Ознакомьтесь с файлом LICENSE.
+
+#### Требования
+
+* Java
+
+#### Обратная связь
+
+Просто создайте новую issue с отчётом об ошибке или предложением.
+
+#### Спасибо
+
+* [DDinghoya](https://github.com/DDinghoya), кто перевели приложение на Корейский!
+* [Ignacio Grosso](https://github.com/blckbearx), кто перевели приложение на Испанский!
+
+#### Переводы
+
+Все знают что [вставьте_сюда_ваш_родной_язык] просто лучший! Вообще, просто на всякий случай, сделайте PR (пул реквест) или создайте issue с переведённым файлом `.../src/main/resources/locale.properties`
+
+(Кстати, чтобы конвертировать фалйы ил любой локали в читабельный формат и обратно, можете воспользоваться этим сайтом [https://itpro.cz/juniconv/](https://itpro.cz/juniconv/))
+
+#### Как поддержать
+
+Да просто влепите звездочку GitHub
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 7931a0d..595783a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
Tihwin
Tihwin
- 2.1
+ 2.2
https://github.com/developersu/${project.artifactId}/
@@ -120,6 +120,48 @@
+
+ com.akathist.maven.plugins.launch4j
+ 2.2.0
+ launch4j-maven-plugin
+
+
+ l4j-Tihwin
+ package
+
+ launch4j
+
+
+ gui
+ tw_icon.ico
+ target/Tihwin-${project.version}-${maven.build.timestamp}.exe
+ target/${project.artifactId}-${project.version}-${maven.build.timestamp}.jar
+ Tihwin
+
+ tihwin.Main
+ false
+ anything
+
+
+ 1.8.0
+ %JAVA_HOME%;%PATH%
+
+
+ ${project.version}.0.0
+ ${project.version}
+ ul.cfg utility
+ GNU General Public License v3, 2022 ${project.organization.name}, Russia
+ ${project.version}.0.0
+ ${project.version}
+ ${project.organization.name}
+ ${project.name}
+ ${project.name}
+ ${project.name}.exe
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/tihwin/Main.java b/src/main/java/tihwin/Main.java
index 3a8293a..926dbce 100644
--- a/src/main/java/tihwin/Main.java
+++ b/src/main/java/tihwin/Main.java
@@ -20,11 +20,13 @@ package tihwin;
import javax.swing.*;
import java.awt.*;
+import java.util.Locale;
import java.util.Objects;
import java.util.ResourceBundle;
public class Main {
public static void main(String[] args) {
+ Locale.setDefault(Settings.INSTANCE.getLocale());
String appVersion = ResourceBundle.getBundle("app").getString("_version");
MainAppUi frame = new MainAppUi("Tihwin "+appVersion);
diff --git a/src/main/java/tihwin/MainAppUi.form b/src/main/java/tihwin/MainAppUi.form
index a3efd14..ec0e66f 100644
--- a/src/main/java/tihwin/MainAppUi.form
+++ b/src/main/java/tihwin/MainAppUi.form
@@ -31,7 +31,7 @@
-
+
@@ -43,7 +43,7 @@
-
+
@@ -75,7 +75,7 @@
-
+
@@ -84,7 +84,7 @@
-
+
@@ -93,7 +93,7 @@
-
+
@@ -167,7 +167,7 @@
-
+
@@ -187,6 +187,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/tihwin/MainAppUi.java b/src/main/java/tihwin/MainAppUi.java
index 79b4d93..e91a71f 100644
--- a/src/main/java/tihwin/MainAppUi.java
+++ b/src/main/java/tihwin/MainAppUi.java
@@ -23,19 +23,20 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import tihwin.cd.ISO9660;
-import tihwin.ui.IsoFileFilter;
-import tihwin.ui.TitleFieldFilter;
-import tihwin.ui.UiUpdater;
+import tihwin.ui.*;
+import tihwin.ui.model.LocaleHolder;
import tihwin.ul.UlConfiguration;
import tihwin.ul.UlMaker;
import javax.swing.*;
+import javax.swing.border.Border;
import javax.swing.text.AbstractDocument;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.lang.reflect.Method;
+import java.util.Locale;
import java.util.ResourceBundle;
public class MainAppUi extends JFrame {
@@ -52,7 +53,11 @@ public class MainAppUi extends JFrame {
private JRadioButton CDRadioButton;
private JRadioButton DVDRadioButton;
private JButton ulCfgBtn;
- private final ResourceBundle resourceBundle;
+ private JComboBox ulLangComboBox;
+ private JLabel diskImageRoLbl;
+ private JLabel titleRoLbl;
+ private JLabel ulDestinationRoLbl;
+ private ResourceBundle resourceBundle;
private String recentRomLocation;
private File diskImage;
@@ -63,6 +68,7 @@ public class MainAppUi extends JFrame {
public MainAppUi(String appName) {
super(appName);
+ $$$setupUI$$$();
resourceBundle = ResourceBundle.getBundle("locale");
AwesomeMediator.setMainUi(this);
setLocationRelativeTo(null); // Set window on [kinda] center
@@ -80,22 +86,29 @@ public class MainAppUi extends JFrame {
CDRadioButton.setSelected(true);
recentRomLocation = Settings.INSTANCE.getRomLocation();
destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination()));
-
addWindowListener(getWindowListener());
+ Border fitMoreTextOnButtonBorder = BorderFactory.createCompoundBorder(
+ BorderFactory.createLineBorder(Color.lightGray),
+ BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ diskImageSelectBtn.setBorder(fitMoreTextOnButtonBorder);
+ destinationSelectBtn.setBorder(fitMoreTextOnButtonBorder);
+
}
private WindowListener getWindowListener() {
return new WindowListener() {
- @Override
- public void windowOpened(WindowEvent windowEvent) {
-
- }
-
@Override
public void windowClosing(WindowEvent windowEvent) {
Settings.INSTANCE.setRomLocation(recentRomLocation);
Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText());
Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected());
+ Settings.INSTANCE.setLocale(
+ ((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocaleCode());
+ }
+
+ @Override
+ public void windowOpened(WindowEvent windowEvent) {
+ diskImageSelectBtn.grabFocus();
}
@Override
@@ -104,22 +117,18 @@ public class MainAppUi extends JFrame {
@Override
public void windowIconified(WindowEvent windowEvent) {
-
}
@Override
public void windowDeiconified(WindowEvent windowEvent) {
-
}
@Override
public void windowActivated(WindowEvent windowEvent) {
-
}
@Override
public void windowDeactivated(WindowEvent windowEvent) {
-
}
};
}
@@ -221,11 +230,26 @@ public class MainAppUi extends JFrame {
new UpdateUlTableUi(destinationDirectoryLbl.getText());
}
- {
-// GUI initializer generated by IntelliJ IDEA GUI Designer
-// >>> IMPORTANT!! <<<
-// DO NOT EDIT OR ADD ANY CODE HERE!
- $$$setupUI$$$();
+ private void onLanguageChanged() {
+ Locale newLocale = ((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocale();
+ Locale.setDefault(newLocale);
+ resourceBundle = ResourceBundle.getBundle("locale");
+
+ diskImageSelectBtn.setText(resourceBundle.getString("SelectBtn"));
+ destinationSelectBtn.setText(resourceBundle.getString("SelectBtn"));
+ if (doWeConvertAnythingNow) {
+ convertBtn.setText(resourceBundle.getString("AbortText"));
+ statusLbl.setText(resourceBundle.getString("InProgressText"));
+ } else
+ convertBtn.setText(resourceBundle.getString("ConvertBtn"));
+
+ diskImageRoLbl.setText(resourceBundle.getString("DiskImageLbl"));
+ titleRoLbl.setText(resourceBundle.getString("TitleLbl"));
+ ulDestinationRoLbl.setText(resourceBundle.getString("ulDestinationLbl"));
+
+ CDRadioButton.setText(resourceBundle.getString("CD"));
+ DVDRadioButton.setText(resourceBundle.getString("DVD"));
+ ulCfgBtn.setText(resourceBundle.getString("editUlCfgBtn"));
}
/**
@@ -236,15 +260,16 @@ public class MainAppUi extends JFrame {
* @noinspection ALL
*/
private void $$$setupUI$$$() {
+ createUIComponents();
mainPanel = new JPanel();
mainPanel.setLayout(new FormLayout("fill:p:noGrow,left:4dlu:noGrow,fill:p:noGrow,left:4dlu:noGrow,fill:p:noGrow,fill:max(d;4px):noGrow,fill:d:grow,left:4dlu:noGrow,fill:p:noGrow", "center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:p:grow,top:4dlu:noGrow,center:max(d;4px):noGrow"));
diskImageSelectBtn = new JButton();
diskImageSelectBtn.setBackground(new Color(-2034433));
this.$$$loadButtonText$$$(diskImageSelectBtn, this.$$$getMessageFromBundle$$$("locale", "SelectBtn"));
CellConstraints cc = new CellConstraints();
- mainPanel.add(diskImageSelectBtn, new CellConstraints(1, 3, 3, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
+ mainPanel.add(diskImageSelectBtn, new CellConstraints(1, 3, 3, 1, CellConstraints.DEFAULT, CellConstraints.CENTER, new Insets(0, 5, 0, 0)));
titleField = new JTextField();
- mainPanel.add(titleField, cc.xyw(7, 5, 3));
+ mainPanel.add(titleField, new CellConstraints(7, 5, 3, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 0, 0, 5)));
destinationDirectoryLbl = new JLabel();
destinationDirectoryLbl.setText("");
mainPanel.add(destinationDirectoryLbl, cc.xyw(7, 7, 3));
@@ -255,15 +280,15 @@ public class MainAppUi extends JFrame {
destinationSelectBtn.setBackground(new Color(-2034433));
this.$$$loadButtonText$$$(destinationSelectBtn, this.$$$getMessageFromBundle$$$("locale", "SelectBtn"));
mainPanel.add(destinationSelectBtn, new CellConstraints(1, 7, 3, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
- final JLabel label1 = new JLabel();
- this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("locale", "ulDestinationLbl"));
- mainPanel.add(label1, cc.xy(5, 7));
- final JLabel label2 = new JLabel();
- this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("locale", "DiskImageLbl"));
- mainPanel.add(label2, cc.xy(5, 3));
- final JLabel label3 = new JLabel();
- this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("locale", "TitleLbl"));
- mainPanel.add(label3, cc.xy(5, 5));
+ ulDestinationRoLbl = new JLabel();
+ this.$$$loadLabelText$$$(ulDestinationRoLbl, this.$$$getMessageFromBundle$$$("locale", "ulDestinationLbl"));
+ mainPanel.add(ulDestinationRoLbl, cc.xy(5, 7));
+ diskImageRoLbl = new JLabel();
+ this.$$$loadLabelText$$$(diskImageRoLbl, this.$$$getMessageFromBundle$$$("locale", "DiskImageLbl"));
+ mainPanel.add(diskImageRoLbl, cc.xy(5, 3));
+ titleRoLbl = new JLabel();
+ this.$$$loadLabelText$$$(titleRoLbl, this.$$$getMessageFromBundle$$$("locale", "TitleLbl"));
+ mainPanel.add(titleRoLbl, cc.xy(5, 5));
CDRadioButton = new JRadioButton();
this.$$$loadButtonText$$$(CDRadioButton, this.$$$getMessageFromBundle$$$("locale", "CD"));
mainPanel.add(CDRadioButton, cc.xy(1, 5));
@@ -288,13 +313,15 @@ public class MainAppUi extends JFrame {
progressBar.setIndeterminate(false);
mainPanel.add(progressBar, cc.xyw(1, 11, 7, CellConstraints.FILL, CellConstraints.DEFAULT));
final JPanel panel1 = new JPanel();
- panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
+ panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
panel1.setBackground(new Color(-9251843));
mainPanel.add(panel1, cc.xyw(1, 1, 9));
- final JLabel label4 = new JLabel();
- label4.setIcon(new ImageIcon(getClass().getResource("/banner.png")));
- label4.setText("");
- panel1.add(label4, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final JLabel label1 = new JLabel();
+ label1.setIcon(new ImageIcon(getClass().getResource("/banner.png")));
+ label1.setText("");
+ panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ ulLangComboBox.putClientProperty("html.disable", Boolean.FALSE);
+ panel1.add(ulLangComboBox, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
ulCfgBtn = new JButton();
ulCfgBtn.setBackground(new Color(-2031648));
ulCfgBtn.setMargin(new Insets(1, 1, 1, 1));
@@ -386,4 +413,8 @@ public class MainAppUi extends JFrame {
return mainPanel;
}
+ private void createUIComponents() {
+ this.ulLangComboBox = new LanguageComboBox();
+ ulLangComboBox.addActionListener(e -> onLanguageChanged());
+ }
}
diff --git a/src/main/java/tihwin/Settings.java b/src/main/java/tihwin/Settings.java
index 87aa2dd..831e612 100644
--- a/src/main/java/tihwin/Settings.java
+++ b/src/main/java/tihwin/Settings.java
@@ -18,15 +18,19 @@
*/
package tihwin;
+import java.util.Locale;
import java.util.prefs.Preferences;
public class Settings {
public static final Settings INSTANCE = new Settings();
private final Preferences preferences;
+ private final Locale locale;
Settings(){
this.preferences = Preferences.userRoot().node("tihwin");
+ String localeCode = preferences.get("locale", Locale.getDefault().toString());
+ this.locale = new Locale(localeCode.substring(0, 2), localeCode.substring(3));
}
public String getRomLocation(){
@@ -48,4 +52,7 @@ public class Settings {
public void setDvdSelected(boolean value) {
preferences.putBoolean("dvd_selected", value);
}
+
+ public Locale getLocale(){ return this.locale; }
+ public void setLocale(String localeId){ preferences.put("locale", localeId); }
}
diff --git a/src/main/java/tihwin/ui/LanguageComboBox.java b/src/main/java/tihwin/ui/LanguageComboBox.java
new file mode 100644
index 0000000..cc47bb3
--- /dev/null
+++ b/src/main/java/tihwin/ui/LanguageComboBox.java
@@ -0,0 +1,76 @@
+/*
+
+ Copyright "2022" Dmitry Isaenko
+
+ This file is part of Tihwin.
+
+ Tihwin 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.
+
+ Tihwin 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 Tihwin. If not, see .
+
+ */
+package tihwin.ui;
+
+import tihwin.ui.model.LocaleHolder;
+import tihwin.ui.model.SettingsLanguagesSetup;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicArrowButton;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+import java.awt.*;
+import java.util.List;
+
+public class LanguageComboBox extends JComboBox {
+ private static final Color COLOR_SKY_BLUE = new Color(114, 211, 253);
+
+ public LanguageComboBox(){
+ super();
+ UIManager.put("ComboBox.selectionForeground", COLOR_SKY_BLUE);
+ UIManager.put("ComboBox.selectionBackground", Color.white);
+ UIManager.put("ComboBox.squareButton", Boolean.FALSE);
+
+ setUI(new BasicComboBoxUI(){
+ @Override
+ protected JButton createArrowButton() {
+ BasicArrowButton button = new BasicArrowButton(BasicArrowButton.SOUTH,
+ COLOR_SKY_BLUE, COLOR_SKY_BLUE, Color.white, COLOR_SKY_BLUE);
+
+ button.setBorder(BorderFactory.createEmptyBorder());
+ button.setVisible(false);
+ return button;
+ }
+ });
+
+ ListCellRenderer current = (ListCellRenderer) getRenderer();
+
+ setRenderer((list, localeHolder, index, isSelected, hasFocus) -> {
+ Component component = current.getListCellRendererComponent(list, localeHolder, index, isSelected, hasFocus);
+
+ if (isSelected) {
+ component.setForeground(Color.black);
+ component.setBackground(Color.ORANGE);
+ } else {
+ component.setForeground(Color.white);
+ component.setBackground(COLOR_SKY_BLUE);
+ }
+ return component;
+ });
+ setForeground(Color.white);
+ setBackground(COLOR_SKY_BLUE);
+ SettingsLanguagesSetup setup = new SettingsLanguagesSetup();
+
+ List languages = setup.getLanguages();
+ for (LocaleHolder lang: languages)
+ addItem(lang);
+ this.setSelectedItem(setup.getRecentLanguage());
+ }
+}
diff --git a/src/main/java/tihwin/ui/model/LocaleHolder.java b/src/main/java/tihwin/ui/model/LocaleHolder.java
new file mode 100644
index 0000000..0dbfd58
--- /dev/null
+++ b/src/main/java/tihwin/ui/model/LocaleHolder.java
@@ -0,0 +1,55 @@
+/*
+
+ Copyright "2022" Dmitry Isaenko
+
+ This file is part of Tihwin.
+
+ Tihwin 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.
+
+ Tihwin 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 Tihwin. If not, see .
+
+ */
+package tihwin.ui.model;
+
+import java.util.Locale;
+
+public class LocaleHolder {
+
+ private final Locale locale;
+ private final String localeCode;
+ private final String languageName;
+
+ public LocaleHolder(String localeFileName) {
+ String language = localeFileName.substring(7, 9);
+ String country;
+ if (localeFileName.length() > 23)
+ country = localeFileName.substring(10, localeFileName.indexOf('.'));
+ else
+ country = localeFileName.substring(10, 12);
+ this.locale = new Locale(language, country);
+ this.localeCode = locale.toString();
+ this.languageName = locale.getDisplayLanguage(locale).toUpperCase();
+ }
+
+ @Override
+ public String toString(){
+ return languageName;
+ }
+
+ public String getLocaleCode(){
+ return localeCode;
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+}
diff --git a/src/main/java/tihwin/ui/model/SettingsLanguagesSetup.java b/src/main/java/tihwin/ui/model/SettingsLanguagesSetup.java
new file mode 100644
index 0000000..a3d9adf
--- /dev/null
+++ b/src/main/java/tihwin/ui/model/SettingsLanguagesSetup.java
@@ -0,0 +1,127 @@
+/*
+
+ Copyright "2022" Dmitry Isaenko
+
+ This file is part of Tihwin.
+
+ Tihwin 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.
+
+ Tihwin 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 Tihwin. If not, see .
+
+ */
+package tihwin.ui.model;
+
+import tihwin.Settings;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.util.*;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+public class SettingsLanguagesSetup {
+ private final List languages;
+ private File thisApplicationFile;
+ private LocaleHolder recentlyUsedLanguageHolder;
+
+ public SettingsLanguagesSetup() {
+ this.languages = new ArrayList<>();
+ parseFiles();
+ sortLanguages();
+ defineRecentlyUsedLanguageHolder();
+ }
+
+ private void parseFiles() {
+ if (isApplicationIsJar()) // Executed as JAR file
+ parseFilesInsideJar();
+ else // Executed within IDE
+ parseFilesInFilesystem();
+ }
+
+ private boolean isApplicationIsJar() {
+ getThisApplicationFile();
+ return thisApplicationFile != null && thisApplicationFile.isFile();
+ }
+
+ private void getThisApplicationFile() {
+ try {
+ String encodedJarLocation =
+ getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replace("+", "%2B");
+ this.thisApplicationFile = new File(URLDecoder.decode(encodedJarLocation, "UTF-8"));
+ } catch (UnsupportedEncodingException uee) {
+ uee.printStackTrace();
+ this.thisApplicationFile = null;
+ }
+ }
+
+ private void parseFilesInsideJar() {
+ try {
+ JarFile jar = new JarFile(thisApplicationFile);
+ Enumeration entries = jar.entries(); //gives ALL entries in jar
+ while (entries.hasMoreElements()) {
+ String name = entries.nextElement().getName();
+ if (name.startsWith("locale_")) {
+ languages.add(new LocaleHolder(name));
+ }
+ }
+ jar.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ private void parseFilesInFilesystem() {
+ URL resourceURL = this.getClass().getResource("/");
+ String[] filesList = new File(resourceURL.getFile()).list(); // Screw it. This WON'T produce NullPointerException
+
+ for (String jarFileName : filesList) {
+ if (jarFileName.startsWith("locale_")) {
+ languages.add(new LocaleHolder(jarFileName));
+ }
+ }
+ }
+
+ private void sortLanguages() {
+ languages.sort(Comparator.comparing(LocaleHolder::toString));
+ }
+
+ private void defineRecentlyUsedLanguageHolder() {
+ Locale localeFromPreferences = Settings.INSTANCE.getLocale();
+
+ for (LocaleHolder holder : languages) {
+ Locale holderLocale = holder.getLocale();
+
+ if (holderLocale.equals(localeFromPreferences)) {
+ this.recentlyUsedLanguageHolder = holder;
+ return;
+ }
+ }
+ // Otherwise define default one that is "en_US"
+ for (LocaleHolder holder : languages) {
+ if (holder.getLocaleCode().equals("en_US")) {
+ this.recentlyUsedLanguageHolder = holder;
+ return;
+ }
+ }
+ }
+
+ public List getLanguages() {
+ return languages;
+ }
+
+ public LocaleHolder getRecentLanguage() {
+ return recentlyUsedLanguageHolder;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/tihwin/ui/ulupdater/UlTableModel.java b/src/main/java/tihwin/ui/ulupdater/UlTableModel.java
index aeeb19d..eb02195 100644
--- a/src/main/java/tihwin/ui/ulupdater/UlTableModel.java
+++ b/src/main/java/tihwin/ui/ulupdater/UlTableModel.java
@@ -27,9 +27,19 @@ import java.util.List;
import java.util.ResourceBundle;
public class UlTableModel extends DefaultTableModel {
- static {
+
+ private final String REMOVE_ME_BUTTON_TEXT;
+
+ private final String OK_STATUS;
+ private final String INCONSISTENT_STATUS;
+
+ private final List rows;
+ private final List removedRows;
+
+ public UlTableModel(){
+ super();
ResourceBundle bundle = ResourceBundle.getBundle("locale");
- COLUMNS = new String[]{
+ String[] columns = new String[]{
bundle.getString("ulManagerWindow_ColumnNameNumber"),
bundle.getString("ulManagerWindow_ColumnNameTitle"),
bundle.getString("ulManagerWindow_ColumnNamePublisherTitle"),
@@ -37,23 +47,11 @@ public class UlTableModel extends DefaultTableModel {
bundle.getString("ulManagerWindow_ColumnCdDvdFlag"),
"",
""};
+ super.setColumnIdentifiers(columns);
REMOVE_ME_BUTTON_TEXT = bundle.getString("ulManagerWindow_Row_RemoveRowBtn");
OK_STATUS = bundle.getString("Ok");
INCONSISTENT_STATUS = bundle.getString("ulManagerWindow_InconsistentFileText");
- }
- private static final String[] COLUMNS;
- private static final String REMOVE_ME_BUTTON_TEXT;
-
- private static final String OK_STATUS;
- private static final String INCONSISTENT_STATUS;
-
- private final List rows;
- private final List removedRows;
-
- public UlTableModel(){
- super();
- super.setColumnIdentifiers(COLUMNS);
this.rows = new ArrayList<>();
this.removedRows = new ArrayList<>();
}
diff --git a/src/main/resources/banner.png b/src/main/resources/banner.png
index b936a6c..efea4a4 100644
Binary files a/src/main/resources/banner.png and b/src/main/resources/banner.png differ
diff --git a/src/main/resources/locale_en_US.properties b/src/main/resources/locale_en_US.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/locale_es_ES.properties b/src/main/resources/locale_es_ES.properties
index f670be1..659fa8f 100644
--- a/src/main/resources/locale_es_ES.properties
+++ b/src/main/resources/locale_es_ES.properties
@@ -27,7 +27,7 @@ ulManager=Administrador de ul.cfg
ulManagerWindow_ColumnNameNumber=#
ulManagerWindow_ColumnNameTitle=T\u00EDtulo
ulManagerWindow_ColumnNamePublisherTitle=T\u00EDtulo del editor
-ulManagerWindow_ColumnNameChunksCount=N\u00FAmero de fragmentos
+ulManagerWindow_ColumnNameChunksCount=N\u00FAm. fragmentos
ulManagerWindow_ColumnCdDvdFlag=CD/DVD
ulManagerWindow_Row_RemoveRowBtn=Eliminar
ulManagerWindow_SaveBtn=Guardar cambios
diff --git a/tw_icon.ico b/tw_icon.ico
new file mode 100644
index 0000000..a314d7c
Binary files /dev/null and b/tw_icon.ico differ