Add language selector, update build config, add launch4j, other small changes that does not make impact on functionality
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dmitry Isaenko 2022-12-25 07:03:37 +03:00
parent 8d860189d4
commit 2d30683436
16 changed files with 454 additions and 61 deletions

View file

@ -3,8 +3,8 @@ type: docker
name: default name: default
steps: steps:
- name: build-install-locally - name: build
image: maven:3-jdk-11 image: maven:3-openjdk-17
commands: commands:
- mvn -B -DskipTests clean install - mvn -B -DskipTests clean install
- mvn test -B - mvn test -B
@ -17,6 +17,7 @@ steps:
commands: commands:
- mkdir -p /builds/Tihwin - mkdir -p /builds/Tihwin
- cp target/Tihwin-*[0-9].jar /builds/Tihwin/ - cp target/Tihwin-*[0-9].jar /builds/Tihwin/
- cp target/Tihwin-*[0-9].exe /builds/Tihwin/
volumes: volumes:
- name: builds - name: builds
path: /builds path: /builds

View file

@ -1,7 +1,9 @@
## Tihwin ## 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) ![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 screenshot1](screenshots/1.png)
![Application screenshot2](screenshots/2.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. GNU GLPv3 or higher. Please see LICENSE.
#### Requirements
* Java
#### Feedback #### Feedback
Create new GitHub issue with bug report or proposition Create new GitHub issue with bug report or proposition
@ -21,6 +27,7 @@ Create new GitHub issue with bug report or proposition
#### Thanks #### Thanks
* [DDinghoya](https://github.com/DDinghoya), who translated this application to Korean! * [DDinghoya](https://github.com/DDinghoya), who translated this application to Korean!
* [Ignacio Grosso](https://github.com/blckbearx), who translated this application to Spanish!
#### Translations #### Translations

38
README_RU.md Normal file
View file

@ -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

44
pom.xml
View file

@ -8,7 +8,7 @@
<name>Tihwin</name> <name>Tihwin</name>
<artifactId>Tihwin</artifactId> <artifactId>Tihwin</artifactId>
<version>2.1</version> <version>2.2</version>
<url>https://github.com/developersu/${project.artifactId}/</url> <url>https://github.com/developersu/${project.artifactId}/</url>
<description> <description>
@ -120,6 +120,48 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<version>2.2.0</version>
<artifactId>launch4j-maven-plugin</artifactId>
<executions>
<execution>
<id>l4j-Tihwin</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<icon>tw_icon.ico</icon>
<outfile>target/Tihwin-${project.version}-${maven.build.timestamp}.exe</outfile>
<jar>target/${project.artifactId}-${project.version}-${maven.build.timestamp}.jar</jar>
<errTitle>Tihwin</errTitle>
<classPath>
<mainClass>tihwin.Main</mainClass>
<addDependencies>false</addDependencies>
<preCp>anything</preCp>
</classPath>
<jre>
<minVersion>1.8.0</minVersion>
<path>%JAVA_HOME%;%PATH%</path>
</jre>
<versionInfo>
<fileVersion>${project.version}.0.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>ul.cfg utility</fileDescription>
<copyright>GNU General Public License v3, 2022 ${project.organization.name}, Russia</copyright>
<productVersion>${project.version}.0.0</productVersion>
<txtProductVersion>${project.version}</txtProductVersion>
<companyName>${project.organization.name}</companyName>
<productName>${project.name}</productName>
<internalName>${project.name}</internalName>
<originalFilename>${project.name}.exe</originalFilename>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View file

@ -20,11 +20,13 @@ package tihwin;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
Locale.setDefault(Settings.INSTANCE.getLocale());
String appVersion = ResourceBundle.getBundle("app").getString("_version"); String appVersion = ResourceBundle.getBundle("app").getString("_version");
MainAppUi frame = new MainAppUi("Tihwin "+appVersion); MainAppUi frame = new MainAppUi("Tihwin "+appVersion);

View file

@ -31,7 +31,7 @@
<component id="3f7d8" class="javax.swing.JButton" binding="diskImageSelectBtn"> <component id="3f7d8" class="javax.swing.JButton" binding="diskImageSelectBtn">
<constraints> <constraints>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<forms top="0" left="5" bottom="0" right="0"/> <forms top="0" left="5" bottom="0" right="0" defaultalign-vert="false"/>
</constraints> </constraints>
<properties> <properties>
<background color="-2034433"/> <background color="-2034433"/>
@ -43,7 +43,7 @@
<grid row="4" column="6" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" use-parent-layout="false"> <grid row="4" column="6" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="1" use-parent-layout="false">
<preferred-size width="150" height="-1"/> <preferred-size width="150" height="-1"/>
</grid> </grid>
<forms/> <forms top="0" left="0" bottom="0" right="5"/>
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
@ -75,7 +75,7 @@
<text resource-bundle="locale" key="SelectBtn"/> <text resource-bundle="locale" key="SelectBtn"/>
</properties> </properties>
</component> </component>
<component id="ed01c" class="javax.swing.JLabel"> <component id="ed01c" class="javax.swing.JLabel" binding="ulDestinationRoLbl">
<constraints> <constraints>
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/> <forms/>
@ -84,7 +84,7 @@
<text resource-bundle="locale" key="ulDestinationLbl"/> <text resource-bundle="locale" key="ulDestinationLbl"/>
</properties> </properties>
</component> </component>
<component id="778d6" class="javax.swing.JLabel"> <component id="778d6" class="javax.swing.JLabel" binding="diskImageRoLbl">
<constraints> <constraints>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/> <forms/>
@ -93,7 +93,7 @@
<text resource-bundle="locale" key="DiskImageLbl"/> <text resource-bundle="locale" key="DiskImageLbl"/>
</properties> </properties>
</component> </component>
<component id="cbd88" class="javax.swing.JLabel"> <component id="cbd88" class="javax.swing.JLabel" binding="titleRoLbl">
<constraints> <constraints>
<grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="4" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/> <forms/>
@ -167,7 +167,7 @@
<indeterminate value="false"/> <indeterminate value="false"/>
</properties> </properties>
</component> </component>
<grid id="a5cce" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="a5cce" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="9" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="9" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -187,6 +187,15 @@
<text value=""/> <text value=""/>
</properties> </properties>
</component> </component>
<component id="92f10" class="javax.swing.JComboBox" binding="ulLangComboBox" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="9" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<clientProperties>
<html.disable class="java.lang.Boolean" value="false"/>
</clientProperties>
</component>
</children> </children>
</grid> </grid>
<component id="824ea" class="javax.swing.JButton" binding="ulCfgBtn"> <component id="824ea" class="javax.swing.JButton" binding="ulCfgBtn">

View file

@ -23,19 +23,20 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout; import com.jgoodies.forms.layout.FormLayout;
import tihwin.cd.ISO9660; import tihwin.cd.ISO9660;
import tihwin.ui.IsoFileFilter; import tihwin.ui.*;
import tihwin.ui.TitleFieldFilter; import tihwin.ui.model.LocaleHolder;
import tihwin.ui.UiUpdater;
import tihwin.ul.UlConfiguration; import tihwin.ul.UlConfiguration;
import tihwin.ul.UlMaker; import tihwin.ul.UlMaker;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.text.AbstractDocument; import javax.swing.text.AbstractDocument;
import java.awt.*; import java.awt.*;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.awt.event.WindowListener; import java.awt.event.WindowListener;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class MainAppUi extends JFrame { public class MainAppUi extends JFrame {
@ -52,7 +53,11 @@ public class MainAppUi extends JFrame {
private JRadioButton CDRadioButton; private JRadioButton CDRadioButton;
private JRadioButton DVDRadioButton; private JRadioButton DVDRadioButton;
private JButton ulCfgBtn; private JButton ulCfgBtn;
private final ResourceBundle resourceBundle; private JComboBox<LocaleHolder> ulLangComboBox;
private JLabel diskImageRoLbl;
private JLabel titleRoLbl;
private JLabel ulDestinationRoLbl;
private ResourceBundle resourceBundle;
private String recentRomLocation; private String recentRomLocation;
private File diskImage; private File diskImage;
@ -63,6 +68,7 @@ public class MainAppUi extends JFrame {
public MainAppUi(String appName) { public MainAppUi(String appName) {
super(appName); super(appName);
$$$setupUI$$$();
resourceBundle = ResourceBundle.getBundle("locale"); resourceBundle = ResourceBundle.getBundle("locale");
AwesomeMediator.setMainUi(this); AwesomeMediator.setMainUi(this);
setLocationRelativeTo(null); // Set window on [kinda] center setLocationRelativeTo(null); // Set window on [kinda] center
@ -80,22 +86,29 @@ public class MainAppUi extends JFrame {
CDRadioButton.setSelected(true); CDRadioButton.setSelected(true);
recentRomLocation = Settings.INSTANCE.getRomLocation(); recentRomLocation = Settings.INSTANCE.getRomLocation();
destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination())); destinationDirectoryLbl.setText(FilesHelper.getRealFolder(Settings.INSTANCE.getDestination()));
addWindowListener(getWindowListener()); 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() { private WindowListener getWindowListener() {
return new WindowListener() { return new WindowListener() {
@Override
public void windowOpened(WindowEvent windowEvent) {
}
@Override @Override
public void windowClosing(WindowEvent windowEvent) { public void windowClosing(WindowEvent windowEvent) {
Settings.INSTANCE.setRomLocation(recentRomLocation); Settings.INSTANCE.setRomLocation(recentRomLocation);
Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText()); Settings.INSTANCE.setDestination(destinationDirectoryLbl.getText());
Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected()); Settings.INSTANCE.setDvdSelected(DVDRadioButton.isSelected());
Settings.INSTANCE.setLocale(
((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocaleCode());
}
@Override
public void windowOpened(WindowEvent windowEvent) {
diskImageSelectBtn.grabFocus();
} }
@Override @Override
@ -104,22 +117,18 @@ public class MainAppUi extends JFrame {
@Override @Override
public void windowIconified(WindowEvent windowEvent) { public void windowIconified(WindowEvent windowEvent) {
} }
@Override @Override
public void windowDeiconified(WindowEvent windowEvent) { public void windowDeiconified(WindowEvent windowEvent) {
} }
@Override @Override
public void windowActivated(WindowEvent windowEvent) { public void windowActivated(WindowEvent windowEvent) {
} }
@Override @Override
public void windowDeactivated(WindowEvent windowEvent) { public void windowDeactivated(WindowEvent windowEvent) {
} }
}; };
} }
@ -221,11 +230,26 @@ public class MainAppUi extends JFrame {
new UpdateUlTableUi(destinationDirectoryLbl.getText()); new UpdateUlTableUi(destinationDirectoryLbl.getText());
} }
{ private void onLanguageChanged() {
// GUI initializer generated by IntelliJ IDEA GUI Designer Locale newLocale = ((LocaleHolder) ulLangComboBox.getSelectedItem()).getLocale();
// >>> IMPORTANT!! <<< Locale.setDefault(newLocale);
// DO NOT EDIT OR ADD ANY CODE HERE! resourceBundle = ResourceBundle.getBundle("locale");
$$$setupUI$$$();
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 * @noinspection ALL
*/ */
private void $$$setupUI$$$() { private void $$$setupUI$$$() {
createUIComponents();
mainPanel = new JPanel(); 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")); 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 = new JButton();
diskImageSelectBtn.setBackground(new Color(-2034433)); diskImageSelectBtn.setBackground(new Color(-2034433));
this.$$$loadButtonText$$$(diskImageSelectBtn, this.$$$getMessageFromBundle$$$("locale", "SelectBtn")); this.$$$loadButtonText$$$(diskImageSelectBtn, this.$$$getMessageFromBundle$$$("locale", "SelectBtn"));
CellConstraints cc = new CellConstraints(); 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(); 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 = new JLabel();
destinationDirectoryLbl.setText(""); destinationDirectoryLbl.setText("");
mainPanel.add(destinationDirectoryLbl, cc.xyw(7, 7, 3)); mainPanel.add(destinationDirectoryLbl, cc.xyw(7, 7, 3));
@ -255,15 +280,15 @@ public class MainAppUi extends JFrame {
destinationSelectBtn.setBackground(new Color(-2034433)); destinationSelectBtn.setBackground(new Color(-2034433));
this.$$$loadButtonText$$$(destinationSelectBtn, this.$$$getMessageFromBundle$$$("locale", "SelectBtn")); 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))); mainPanel.add(destinationSelectBtn, new CellConstraints(1, 7, 3, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets(0, 5, 0, 0)));
final JLabel label1 = new JLabel(); ulDestinationRoLbl = new JLabel();
this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("locale", "ulDestinationLbl")); this.$$$loadLabelText$$$(ulDestinationRoLbl, this.$$$getMessageFromBundle$$$("locale", "ulDestinationLbl"));
mainPanel.add(label1, cc.xy(5, 7)); mainPanel.add(ulDestinationRoLbl, cc.xy(5, 7));
final JLabel label2 = new JLabel(); diskImageRoLbl = new JLabel();
this.$$$loadLabelText$$$(label2, this.$$$getMessageFromBundle$$$("locale", "DiskImageLbl")); this.$$$loadLabelText$$$(diskImageRoLbl, this.$$$getMessageFromBundle$$$("locale", "DiskImageLbl"));
mainPanel.add(label2, cc.xy(5, 3)); mainPanel.add(diskImageRoLbl, cc.xy(5, 3));
final JLabel label3 = new JLabel(); titleRoLbl = new JLabel();
this.$$$loadLabelText$$$(label3, this.$$$getMessageFromBundle$$$("locale", "TitleLbl")); this.$$$loadLabelText$$$(titleRoLbl, this.$$$getMessageFromBundle$$$("locale", "TitleLbl"));
mainPanel.add(label3, cc.xy(5, 5)); mainPanel.add(titleRoLbl, cc.xy(5, 5));
CDRadioButton = new JRadioButton(); CDRadioButton = new JRadioButton();
this.$$$loadButtonText$$$(CDRadioButton, this.$$$getMessageFromBundle$$$("locale", "CD")); this.$$$loadButtonText$$$(CDRadioButton, this.$$$getMessageFromBundle$$$("locale", "CD"));
mainPanel.add(CDRadioButton, cc.xy(1, 5)); mainPanel.add(CDRadioButton, cc.xy(1, 5));
@ -288,13 +313,15 @@ public class MainAppUi extends JFrame {
progressBar.setIndeterminate(false); progressBar.setIndeterminate(false);
mainPanel.add(progressBar, cc.xyw(1, 11, 7, CellConstraints.FILL, CellConstraints.DEFAULT)); mainPanel.add(progressBar, cc.xyw(1, 11, 7, CellConstraints.FILL, CellConstraints.DEFAULT));
final JPanel panel1 = new JPanel(); 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)); panel1.setBackground(new Color(-9251843));
mainPanel.add(panel1, cc.xyw(1, 1, 9)); mainPanel.add(panel1, cc.xyw(1, 1, 9));
final JLabel label4 = new JLabel(); final JLabel label1 = new JLabel();
label4.setIcon(new ImageIcon(getClass().getResource("/banner.png"))); label1.setIcon(new ImageIcon(getClass().getResource("/banner.png")));
label4.setText(""); label1.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)); 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 = new JButton();
ulCfgBtn.setBackground(new Color(-2031648)); ulCfgBtn.setBackground(new Color(-2031648));
ulCfgBtn.setMargin(new Insets(1, 1, 1, 1)); ulCfgBtn.setMargin(new Insets(1, 1, 1, 1));
@ -386,4 +413,8 @@ public class MainAppUi extends JFrame {
return mainPanel; return mainPanel;
} }
private void createUIComponents() {
this.ulLangComboBox = new LanguageComboBox();
ulLangComboBox.addActionListener(e -> onLanguageChanged());
}
} }

View file

@ -18,15 +18,19 @@
*/ */
package tihwin; package tihwin;
import java.util.Locale;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
public class Settings { public class Settings {
public static final Settings INSTANCE = new Settings(); public static final Settings INSTANCE = new Settings();
private final Preferences preferences; private final Preferences preferences;
private final Locale locale;
Settings(){ Settings(){
this.preferences = Preferences.userRoot().node("tihwin"); 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(){ public String getRomLocation(){
@ -48,4 +52,7 @@ public class Settings {
public void setDvdSelected(boolean value) { public void setDvdSelected(boolean value) {
preferences.putBoolean("dvd_selected", value); preferences.putBoolean("dvd_selected", value);
} }
public Locale getLocale(){ return this.locale; }
public void setLocale(String localeId){ preferences.put("locale", localeId); }
} }

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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<LocaleHolder> {
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<LocaleHolder> current = (ListCellRenderer<LocaleHolder>) 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<LocaleHolder> languages = setup.getLanguages();
for (LocaleHolder lang: languages)
addItem(lang);
this.setSelectedItem(setup.getRecentLanguage());
}
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
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<LocaleHolder> 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<JarEntry> 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<LocaleHolder> getLanguages() {
return languages;
}
public LocaleHolder getRecentLanguage() {
return recentlyUsedLanguageHolder;
}
}

View file

@ -27,9 +27,19 @@ import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class UlTableModel extends DefaultTableModel { 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<UlTableModelRecord> rows;
private final List<UlTableModelRecord> removedRows;
public UlTableModel(){
super();
ResourceBundle bundle = ResourceBundle.getBundle("locale"); ResourceBundle bundle = ResourceBundle.getBundle("locale");
COLUMNS = new String[]{ String[] columns = new String[]{
bundle.getString("ulManagerWindow_ColumnNameNumber"), bundle.getString("ulManagerWindow_ColumnNameNumber"),
bundle.getString("ulManagerWindow_ColumnNameTitle"), bundle.getString("ulManagerWindow_ColumnNameTitle"),
bundle.getString("ulManagerWindow_ColumnNamePublisherTitle"), bundle.getString("ulManagerWindow_ColumnNamePublisherTitle"),
@ -37,23 +47,11 @@ public class UlTableModel extends DefaultTableModel {
bundle.getString("ulManagerWindow_ColumnCdDvdFlag"), bundle.getString("ulManagerWindow_ColumnCdDvdFlag"),
"", "",
""}; ""};
super.setColumnIdentifiers(columns);
REMOVE_ME_BUTTON_TEXT = bundle.getString("ulManagerWindow_Row_RemoveRowBtn"); REMOVE_ME_BUTTON_TEXT = bundle.getString("ulManagerWindow_Row_RemoveRowBtn");
OK_STATUS = bundle.getString("Ok"); OK_STATUS = bundle.getString("Ok");
INCONSISTENT_STATUS = bundle.getString("ulManagerWindow_InconsistentFileText"); 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<UlTableModelRecord> rows;
private final List<UlTableModelRecord> removedRows;
public UlTableModel(){
super();
super.setColumnIdentifiers(COLUMNS);
this.rows = new ArrayList<>(); this.rows = new ArrayList<>();
this.removedRows = new ArrayList<>(); this.removedRows = new ArrayList<>();
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -27,7 +27,7 @@ ulManager=Administrador de ul.cfg
ulManagerWindow_ColumnNameNumber=# ulManagerWindow_ColumnNameNumber=#
ulManagerWindow_ColumnNameTitle=T\u00EDtulo ulManagerWindow_ColumnNameTitle=T\u00EDtulo
ulManagerWindow_ColumnNamePublisherTitle=T\u00EDtulo del editor ulManagerWindow_ColumnNamePublisherTitle=T\u00EDtulo del editor
ulManagerWindow_ColumnNameChunksCount=N\u00FAmero de fragmentos ulManagerWindow_ColumnNameChunksCount=N\u00FAm. fragmentos
ulManagerWindow_ColumnCdDvdFlag=CD/DVD ulManagerWindow_ColumnCdDvdFlag=CD/DVD
ulManagerWindow_Row_RemoveRowBtn=Eliminar ulManagerWindow_Row_RemoveRowBtn=Eliminar
ulManagerWindow_SaveBtn=Guardar cambios ulManagerWindow_SaveBtn=Guardar cambios

BIN
tw_icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB