Skip to content

Commit

Permalink
Extract PES constants
Browse files Browse the repository at this point in the history
  • Loading branch information
renao committed Mar 11, 2024
1 parent 9d31499 commit f6e9e2c
Show file tree
Hide file tree
Showing 26 changed files with 166 additions and 161 deletions.
2 changes: 1 addition & 1 deletion src/main/java/pes/editor/Ability99Panel.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public boolean verify(JComponent input) {
int v = Integer.parseInt(tf.getText());
return v > 0 && v < 100;
} catch (NumberFormatException exception) {
EditorLogger.Log(exception);
EditorLogger.log(exception);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pes/editor/BackChooserDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public BackChooserDialog(Frame owner) {
bi = ImageIO.read(backURL);
raster[l] = bi.getData();
} catch (IOException exception) {
EditorLogger.Log(exception);
EditorLogger.log(exception);
}
}
flagButton[l].setMargin(new Insets(0, 0, 0, 0));
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pes/editor/CSVFilter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.io.File;

import javax.swing.filechooser.FileFilter;
Expand All @@ -13,7 +15,7 @@ public boolean accept(File f) {
}

var extension = PESUtils.getExtension(f);
return extension != null && extension.equals(PESUtils.csv);
return extension != null && extension.equals(PESConstant.CSV_FILE_EXTENSION);

}

Expand Down
45 changes: 23 additions & 22 deletions src/main/java/pes/editor/Editor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pes.editor;

import pes.editor.constants.OptionFileConstants;
import pes.editor.constants.OptionFileConstant;
import pes.editor.constants.PESConstant;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -263,7 +264,7 @@ public void actionPerformed(ActionEvent a) {
if (of.format == 0) {
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest)
.equals(PESUtils.xps))) {
.equals(PESConstant.XPS_FILE_EXTENSION))) {
dest = new File(dest.getParent()
+ File.separator + dest.getName()
+ ".xps");
Expand All @@ -272,7 +273,7 @@ public void actionPerformed(ActionEvent a) {
if (of.format == 2) {
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest)
.equals(PESUtils.psu))) {
.equals(PESConstant.PSU_FILE_EXTENSION))) {
dest = new File(dest.getParent()
+ File.separator + dest.getName()
+ ".psu");
Expand All @@ -281,7 +282,7 @@ public void actionPerformed(ActionEvent a) {
if (of.format == 3) {
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest)
.equals(PESUtils.max))) {
.equals(PESConstant.MAX_FILE_EXTENSION))) {
dest = new File(dest.getParent()
+ File.separator + dest.getName()
+ ".max");
Expand Down Expand Up @@ -372,7 +373,7 @@ public void actionPerformed(ActionEvent c) {
final boolean create = csvSwitch.create.isSelected();
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest)
.equals(PESUtils.csv))) {
.equals(PESConstant.CSV_FILE_EXTENSION))) {
dest = new File(dest.getParent() + File.separator
+ dest.getName() + ".csv");
}
Expand Down Expand Up @@ -439,7 +440,7 @@ public void actionPerformed(ActionEvent c) {
final boolean updateClassicTeams = csvImportSwitch.updateClassicTeams.isSelected();
if ((PESUtils.getExtension(src) == null)
|| !(PESUtils.getExtension(src)
.equals(PESUtils.csv))) {
.equals(PESConstant.CSV_FILE_EXTENSION))) {
src = new File(src.getParent() + File.separator
+ src.getName() + ".csv");
}
Expand Down Expand Up @@ -470,20 +471,20 @@ public void doIt() {

convertItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[2], of.data,
OptionFileConstants.BLOCKS[2], OptionFileConstants.BLOCK_SIZE[2]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[3], of.data,
OptionFileConstants.BLOCKS[3], OptionFileConstants.BLOCK_SIZE[3]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[4], of.data,
OptionFileConstants.BLOCKS[4], OptionFileConstants.BLOCK_SIZE[4]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[5], of.data,
OptionFileConstants.BLOCKS[5], OptionFileConstants.BLOCK_SIZE[5]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[6], of.data,
OptionFileConstants.BLOCKS[6], OptionFileConstants.BLOCK_SIZE[6]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[7], of.data,
OptionFileConstants.BLOCKS[7], OptionFileConstants.BLOCK_SIZE[7]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[8], of.data,
OptionFileConstants.BLOCKS[8], OptionFileConstants.BLOCK_SIZE[8]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[2], of.data,
OptionFileConstant.BLOCKS[2], OptionFileConstant.BLOCK_SIZE[2]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[3], of.data,
OptionFileConstant.BLOCKS[3], OptionFileConstant.BLOCK_SIZE[3]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[4], of.data,
OptionFileConstant.BLOCKS[4], OptionFileConstant.BLOCK_SIZE[4]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[5], of.data,
OptionFileConstant.BLOCKS[5], OptionFileConstant.BLOCK_SIZE[5]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[6], of.data,
OptionFileConstant.BLOCKS[6], OptionFileConstant.BLOCK_SIZE[6]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[7], of.data,
OptionFileConstant.BLOCKS[7], OptionFileConstant.BLOCK_SIZE[7]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[8], of.data,
OptionFileConstant.BLOCKS[8], OptionFileConstant.BLOCK_SIZE[8]);
System.arraycopy(of2.data, 657116, of.data, 657116, 828);

if (!of.isWE() && of2.isWE()) {
Expand Down Expand Up @@ -683,9 +684,9 @@ private File loadSet() {
dir = null;
}
} catch (IOException exception){
EditorLogger.Log(exception);
EditorLogger.log(exception);
} catch (ClassNotFoundException exception) {
EditorLogger.Log(exception);
EditorLogger.log(exception);
}
}
return dir;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pes/editor/EditorLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class EditorLogger {

public static void Log(Exception exception) {
public static void log(Exception exception) {

// TODO: Implement logging.
System.err.println(exception.toString());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pes/editor/EmblemPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
Expand Down Expand Up @@ -288,7 +290,7 @@ private void savePNG(boolean is128, int slot) {
if (returnVal == JFileChooser.APPROVE_OPTION) {
File dest = chooserPNG.getSelectedFile();
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest).equals(PESUtils.png))) {
|| !(PESUtils.getExtension(dest).equals(PESConstant.PNG_FILE_EXTENSION))) {
dest = new File(dest.getParent() + File.separator
+ dest.getName() + ".png");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pes/editor/FormPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
Expand Down Expand Up @@ -830,7 +832,7 @@ private void savePNG() {
if (returnVal == JFileChooser.APPROVE_OPTION) {
File dest = chooserPNG.getSelectedFile();
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest).equals(PESUtils.png))) {
|| !(PESUtils.getExtension(dest).equals(PESConstant.PNG_FILE_EXTENSION))) {
// System.out.println(dest);
dest = new File(dest.getParent() + File.separator
+ dest.getName() + ".png");
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/pes/editor/GIFPNGFilter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.io.File;

import javax.swing.filechooser.FileFilter;
Expand All @@ -14,8 +16,8 @@ public boolean accept(File f) {

String extension = PESUtils.getExtension(f);
if (extension != null) {
if ((extension.equals(PESUtils.png) || extension
.equals(PESUtils.gif))) {
if ((extension.equals(PESConstant.PNG_FILE_EXTENSION) || extension
.equals(PESConstant.GIF_FILE_EXTENSION))) {
return true;
} else {
return false;
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/pes/editor/ImportPanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pes.editor;

import pes.editor.constants.OptionFileConstants;
import pes.editor.constants.OptionFileConstant;

import java.awt.BorderLayout;
import java.awt.GridLayout;
Expand Down Expand Up @@ -70,12 +70,12 @@ public ImportPanel(OptionFile opf, OptionFile opf2, WENShopPanel w,
"Options / PES points / Shop items / Cup gallery / Memorial match data");
optionsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[0], of.data,
OptionFileConstants.BLOCKS[0], OptionFileConstants.BLOCK_SIZE[0]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[1], of.data,
OptionFileConstants.BLOCKS[1], OptionFileConstants.BLOCK_SIZE[1]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[9], of.data,
OptionFileConstants.BLOCKS[9], OptionFileConstants.BLOCK_SIZE[9]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[0], of.data,
OptionFileConstant.BLOCKS[0], OptionFileConstant.BLOCK_SIZE[0]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[1], of.data,
OptionFileConstant.BLOCKS[1], OptionFileConstant.BLOCK_SIZE[1]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[9], of.data,
OptionFileConstant.BLOCKS[9], OptionFileConstant.BLOCK_SIZE[9]);
wenShop.wenPanel.refresh();
wenShop.shopPanel.status.setText("");
optionsButton.setEnabled(false);
Expand Down Expand Up @@ -109,12 +109,12 @@ public void actionPerformed(ActionEvent a) {
playerButton = new JButton("Players / Squads / Formations");
playerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[3], of.data,
OptionFileConstants.BLOCKS[3], OptionFileConstants.BLOCK_SIZE[3]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[4], of.data,
OptionFileConstants.BLOCKS[4], OptionFileConstants.BLOCK_SIZE[4]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[5], of.data,
OptionFileConstants.BLOCKS[5], OptionFileConstants.BLOCK_SIZE[5]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[3], of.data,
OptionFileConstant.BLOCKS[3], OptionFileConstant.BLOCK_SIZE[3]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[4], of.data,
OptionFileConstant.BLOCKS[4], OptionFileConstant.BLOCK_SIZE[4]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[5], of.data,
OptionFileConstant.BLOCKS[5], OptionFileConstant.BLOCK_SIZE[5]);

if (!of.isWE() && of2.isWE()) {
Convert.allPlayers(of, Convert.WE2007_PES6);
Expand Down Expand Up @@ -143,10 +143,10 @@ public void actionPerformed(ActionEvent a) {
allKitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent a) {
Clubs.importData(of, of2);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[7], of.data,
OptionFileConstants.BLOCKS[7], OptionFileConstants.BLOCK_SIZE[7]);
System.arraycopy(of2.data, OptionFileConstants.BLOCKS[8], of.data,
OptionFileConstants.BLOCKS[8], OptionFileConstants.BLOCK_SIZE[8]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[7], of.data,
OptionFileConstant.BLOCKS[7], OptionFileConstant.BLOCK_SIZE[7]);
System.arraycopy(of2.data, OptionFileConstant.BLOCKS[8], of.data,
OptionFileConstant.BLOCKS[8], OptionFileConstant.BLOCK_SIZE[8]);

if (!of.isWE() && of2.isWE()) {
Convert.allKitModel(of);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/pes/editor/InfoPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void refresh(int index1, int index2) {
}

} catch (BadLocationException exception) {
EditorLogger.Log(exception);
EditorLogger.log(exception);
}
ta.setCaretPosition(0);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/pes/editor/KitImportDialog.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.MouseEvent;
Expand Down Expand Up @@ -69,14 +71,14 @@ public void refresh(int i) {
}
} else {
if (i - Clubs.total > 56) {
model.addElement(new KitItem(PESUtils.extraSquad[i - Clubs.total - 57], i));
model.addElement(new KitItem(PESConstant.EXTRA_SQUADS[i - Clubs.total - 57], i));
} else {
model.addElement(new KitItem(Stats.nation[i - Clubs.total], i));
}
for (int n = Clubs.total; n < Clubs.total + 64; n++) {
if (n != i && !Kits.isLic(of2, n)) {
if (n - Clubs.total > 56) {
model.addElement(new KitItem(PESUtils.extraSquad[n - Clubs.total - 57], n));
model.addElement(new KitItem(PESConstant.EXTRA_SQUADS[n - Clubs.total - 57], n));
} else {
model.addElement(new KitItem(Stats.nation[n - Clubs.total], n));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/pes/editor/LogoPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package pes.editor;

import pes.editor.constants.PESConstant;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
Expand Down Expand Up @@ -135,7 +137,7 @@ private void savePNG(int slot) {
if (returnVal == JFileChooser.APPROVE_OPTION) {
File dest = chooserPNG.getSelectedFile();
if ((PESUtils.getExtension(dest) == null)
|| !(PESUtils.getExtension(dest).equals(PESUtils.png))) {
|| !(PESUtils.getExtension(dest).equals(PESConstant.PNG_FILE_EXTENSION))) {
dest = new File(dest.getParent() + File.separator
+ dest.getName() + ".png");
}
Expand Down
Loading

0 comments on commit f6e9e2c

Please sign in to comment.