Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@
</plugin>

<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<groupId>io.github.download-maven-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<id>download-osx-jre</id>
Expand Down Expand Up @@ -169,28 +168,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.elnarion.maven</groupId>
<artifactId>plantuml-generator-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>generate-simple-diagram</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<outputFilename>${project.parent.groupId}.${project.artifactId}.pu</outputFilename>
<scanPackages>
<scanPackage>${project.parent.groupId}.${project.artifactId}</scanPackage>
<scanPackage>agolf</scanPackage>
<!--<scanPackage>com.aapeli</scanPackage>-->
</scanPackages>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/src/main/java/agolf/GolfConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private void handlePacket(String cmd) {
this.socketConnection.closeConnection();
}
case "versok" -> {
this.writeData("language\t" + this.gameContainer.params.getLocale());
this.writeData("language\t" + this.gameContainer.params.getLanguage());
this.writeData("logintype\t"
+ (this.gameContainer.synchronizedTrackTestMode.get()
? "ttm"
Expand Down
13 changes: 7 additions & 6 deletions client/src/main/java/agolf/GolfGameFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.awt.Font;
import java.awt.Image;
import org.moparforia.client.Launcher;
import org.moparforia.shared.Locale;
import org.moparforia.shared.Language;

public class GolfGameFrame extends AbstractGameFrame {

Expand All @@ -39,8 +39,9 @@ public class GolfGameFrame extends AbstractGameFrame {
private Image anImage3774;
private boolean verbose = false;

public GolfGameFrame(String server, int port, Locale locale, String username, boolean verbose, boolean norandom) {
super(server, port, locale, username, verbose, norandom);
public GolfGameFrame(
String server, int port, Language language, String username, boolean verbose, boolean norandom) {
super(server, port, language, username, verbose, norandom);
}

public void initGame(Parameters parameters) {
Expand Down Expand Up @@ -240,9 +241,9 @@ protected void trackTestLogin(String username, String password) {
this.gameContainer.connection.writeData("ttlogin\t" + username + "\t" + password);
}

protected void trackTestLogin(String username, String password, Locale locale) {
this.textManager.setLocale(locale);
this.gameContainer.connection.writeData("language\t" + locale);
protected void trackTestLogin(String username, String password, Language language) {
this.textManager.setLanguage(language);
this.gameContainer.connection.writeData("language\t" + language);
this.trackTestLogin(username, password);
}

Expand Down
23 changes: 12 additions & 11 deletions client/src/main/java/agolf/TrackTestLoginPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import org.moparforia.shared.Locale;
import org.moparforia.shared.Language;

class TrackTestLoginPanel extends Panel implements ActionListener, KeyListener, ItemListener {

private GolfGameFrame golfGameFrame;
private int width;
private int height;
private Locale locale;
private Language language;
private TextField textFieldName;
private TextField textFieldPassword;
private Button buttonOk;
Expand All @@ -33,7 +33,7 @@ protected TrackTestLoginPanel(GolfGameFrame golfGameFrame, int width, int height
this.golfGameFrame = golfGameFrame;
this.width = width;
this.height = height;
this.locale = golfGameFrame.param.getLocale();
this.language = golfGameFrame.param.getLanguage();
this.setSize(width, height);
this.create();
}
Expand All @@ -56,7 +56,7 @@ public void actionPerformed(ActionEvent evt) {
String username = this.textFieldName.getText().trim();
String password = this.textFieldPassword.getText().trim();
// String password = '';
this.golfGameFrame.trackTestLogin(username, password, locale);
this.golfGameFrame.trackTestLogin(username, password, language);
}

public void keyPressed(KeyEvent evt) {}
Expand Down Expand Up @@ -86,10 +86,11 @@ private void create() {
this.languageChoicer.setForeground(Color.black);
this.languageChoicer.addItemListener(this);
int selectedLanguageIndex =
switch (locale) {
case EN_US -> 0;
case FI_FI -> 1;
case SV_SE -> 2;
switch (language) {
case Language.ENGLISH -> 0;
case Language.FINNISH -> 1;
case Language.SWEDISH -> 2;
default -> 0;
};
this.languageChoicer.setSelectedIndex(selectedLanguageIndex);
this.add(this.languageChoicer);
Expand Down Expand Up @@ -131,13 +132,13 @@ public void itemStateChanged(ItemEvent e) {
if (e.getSource() == this.languageChoicer) {
switch (this.languageChoicer.getSelectedIndex()) {
case 0:
this.locale = Locale.EN_US;
this.language = Language.ENGLISH;
break;
case 1:
this.locale = Locale.FI_FI;
this.language = Language.FINNISH;
break;
case 2:
this.locale = Locale.SV_SE;
this.language = Language.SWEDISH;
break;
}
}
Expand Down
10 changes: 5 additions & 5 deletions client/src/main/java/agolf/lobby/LobbyChatPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import agolf.GameContainer;
import agolf.GolfGameFrame;
import com.aapeli.multiuser.ChatLobby;
import com.aapeli.multiuser.Languages;
import com.aapeli.multiuser.MultiLanguageChatListener;
import com.aapeli.multiuser.User;
import org.moparforia.shared.Language;

class LobbyChatPanel extends ChatLobby implements MultiLanguageChatListener {

Expand Down Expand Up @@ -36,14 +36,14 @@ protected LobbyChatPanel(GameContainer gameContainer, int width, int height, int
this.disableChatInput(2);
}

this.addChatWithLanguage(Languages.getLanguageId(gameContainer.params.getLocale()));
this.addChatWithLanguage(gameContainer.params.getLanguage());
this.addChatListener(this);
}

public void localUserSay(String var1) {}

public void localUserSay(int var1, String var2) {
this.gameContainer.lobbyPanel.writeData("say\t" + var1 + "\t" + var2);
public void localUserSay(Language language, String var2) {
this.gameContainer.lobbyPanel.writeData("say\t" + language + "\t" + var2);
}

public void localUserSayPrivately(String var1, String var2) {
Expand Down Expand Up @@ -299,7 +299,7 @@ protected boolean handlePacket(String[] args) {
return true;
}
case "say" -> {
this.userSay(Integer.parseInt(args[2]), args[3], args[4]);
this.userSay(Language.fromString(args[2]), args[3], args[4]);
return true;
}
case "sayp" -> {
Expand Down
Binary file modified client/src/main/java/com/aapeli/client/BadWordFilter.java
Binary file not shown.
20 changes: 10 additions & 10 deletions client/src/main/java/com/aapeli/client/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import org.moparforia.shared.Locale;
import org.moparforia.shared.Language;

public final class Parameters {

private static final String LOCALHOST = "127.0.0.1";
private String serverIp;
private Locale locale;
private Language language;
private String username;
private String session;
private String urlRegisterPage;
Expand Down Expand Up @@ -76,8 +76,8 @@ public String getUsername() {
return this.username;
}

public Locale getLocale() {
return this.locale;
public Language getLanguage() {
return this.language;
}

public String getSession() {
Expand Down Expand Up @@ -218,7 +218,7 @@ public void removePlayerList() {

public void destroy() {
this.serverIp = null;
this.locale = null;
this.language = null;
this.session = null;
this.urlRegisterPage = null;
this.urlUserInfoPage = null;
Expand All @@ -232,7 +232,7 @@ public void destroy() {
private void init() {
this.serverIp = this.getParamServer();
this.serverPort = this.getParamPort();
this.locale = this.getParamLocale();
this.language = this.getParamLanguage();
this.session = this.getParameter("session");
this.urlRegisterPage = this.getParameter("registerpage");
this.urlUserInfoPage = this.getParameter("userinfopage");
Expand Down Expand Up @@ -267,11 +267,11 @@ private int getParamPort() {
}
}

private Locale getParamLocale() {
private Language getParamLanguage() {
try {
String locale = this.getParameter("locale");
if (locale != null) {
return Locale.fromString(locale);
String language = this.getParameter("language");
if (language != null) {
return Language.fromString(language);
}

} catch (Exception e) {
Expand Down
18 changes: 9 additions & 9 deletions client/src/main/java/com/aapeli/client/TextManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.moparforia.shared.Locale;
import org.moparforia.shared.Language;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public final class TextManager {

private Locale locale;
private Language language;
private Map<String, String> texts;
private String errorMessage;
private boolean debug;
Expand All @@ -25,12 +25,12 @@ public TextManager(Parameters parameters, boolean debug) {
this.debug = debug;
this.texts = new Hashtable<>();
this.errorMessage = null;
this.locale = parameters.getLocale();
this.language = parameters.getLanguage();
this.loadTexts();
}

public void setLocale(Locale locale) {
this.locale = locale;
public void setLanguage(Language language) {
this.language = language;
this.loadTexts();
}

Expand Down Expand Up @@ -149,12 +149,12 @@ public void destroy() {
this.texts = null;
}

this.locale = null;
this.language = null;
this.errorMessage = null;
}

protected Locale getLocale() {
return this.locale;
protected Language getLanguage() {
return this.language;
}

private String getInternal(String key, String[] arguments) {
Expand Down Expand Up @@ -269,7 +269,7 @@ private String getDate(long timestamp, int mode) {
}

private void loadTexts() {
String resourcePath = "/l10n/" + this.locale + "/AGolf.xml";
String resourcePath = "/l10n/" + this.language + "/AGolf.xml";
try {
InputStream in = this.getClass().getResourceAsStream(resourcePath);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Expand Down
30 changes: 0 additions & 30 deletions client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java

This file was deleted.

Loading