Skip to content

Commit c88621d

Browse files
authored
Merge pull request #135 from StenAL/features
2 parents b394176 + 9bb1a0c commit c88621d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+300
-4275
lines changed

client/pom.xml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@
8282
</plugin>
8383

8484
<plugin>
85-
<groupId>com.googlecode.maven-download-plugin</groupId>
85+
<groupId>io.github.download-maven-plugin</groupId>
8686
<artifactId>download-maven-plugin</artifactId>
87-
<version>1.9.0</version>
8887
<executions>
8988
<execution>
9089
<id>download-osx-jre</id>
@@ -169,28 +168,6 @@
169168
</execution>
170169
</executions>
171170
</plugin>
172-
<plugin>
173-
<groupId>de.elnarion.maven</groupId>
174-
<artifactId>plantuml-generator-maven-plugin</artifactId>
175-
<version>2.4.1</version>
176-
<executions>
177-
<execution>
178-
<id>generate-simple-diagram</id>
179-
<goals>
180-
<goal>generate</goal>
181-
</goals>
182-
<phase>generate-test-sources</phase>
183-
<configuration>
184-
<outputFilename>${project.parent.groupId}.${project.artifactId}.pu</outputFilename>
185-
<scanPackages>
186-
<scanPackage>${project.parent.groupId}.${project.artifactId}</scanPackage>
187-
<scanPackage>agolf</scanPackage>
188-
<!--<scanPackage>com.aapeli</scanPackage>-->
189-
</scanPackages>
190-
</configuration>
191-
</execution>
192-
</executions>
193-
</plugin>
194171
<plugin>
195172
<groupId>com.diffplug.spotless</groupId>
196173
<artifactId>spotless-maven-plugin</artifactId>

client/src/main/java/agolf/GolfConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void handlePacket(String cmd) {
9090
this.socketConnection.closeConnection();
9191
}
9292
case "versok" -> {
93-
this.writeData("language\t" + this.gameContainer.params.getLocale());
93+
this.writeData("language\t" + this.gameContainer.params.getLanguage());
9494
this.writeData("logintype\t"
9595
+ (this.gameContainer.synchronizedTrackTestMode.get()
9696
? "ttm"

client/src/main/java/agolf/GolfGameFrame.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.awt.Font;
1313
import java.awt.Image;
1414
import org.moparforia.client.Launcher;
15-
import org.moparforia.shared.Locale;
15+
import org.moparforia.shared.Language;
1616

1717
public class GolfGameFrame extends AbstractGameFrame {
1818

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

42-
public GolfGameFrame(String server, int port, Locale locale, String username, boolean verbose, boolean norandom) {
43-
super(server, port, locale, username, verbose, norandom);
42+
public GolfGameFrame(
43+
String server, int port, Language language, String username, boolean verbose, boolean norandom) {
44+
super(server, port, language, username, verbose, norandom);
4445
}
4546

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

243-
protected void trackTestLogin(String username, String password, Locale locale) {
244-
this.textManager.setLocale(locale);
245-
this.gameContainer.connection.writeData("language\t" + locale);
244+
protected void trackTestLogin(String username, String password, Language language) {
245+
this.textManager.setLanguage(language);
246+
this.gameContainer.connection.writeData("language\t" + language);
246247
this.trackTestLogin(username, password);
247248
}
248249

client/src/main/java/agolf/TrackTestLoginPanel.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import java.awt.event.ItemListener;
1515
import java.awt.event.KeyEvent;
1616
import java.awt.event.KeyListener;
17-
import org.moparforia.shared.Locale;
17+
import org.moparforia.shared.Language;
1818

1919
class TrackTestLoginPanel extends Panel implements ActionListener, KeyListener, ItemListener {
2020

2121
private GolfGameFrame golfGameFrame;
2222
private int width;
2323
private int height;
24-
private Locale locale;
24+
private Language language;
2525
private TextField textFieldName;
2626
private TextField textFieldPassword;
2727
private Button buttonOk;
@@ -33,7 +33,7 @@ protected TrackTestLoginPanel(GolfGameFrame golfGameFrame, int width, int height
3333
this.golfGameFrame = golfGameFrame;
3434
this.width = width;
3535
this.height = height;
36-
this.locale = golfGameFrame.param.getLocale();
36+
this.language = golfGameFrame.param.getLanguage();
3737
this.setSize(width, height);
3838
this.create();
3939
}
@@ -56,7 +56,7 @@ public void actionPerformed(ActionEvent evt) {
5656
String username = this.textFieldName.getText().trim();
5757
String password = this.textFieldPassword.getText().trim();
5858
// String password = '';
59-
this.golfGameFrame.trackTestLogin(username, password, locale);
59+
this.golfGameFrame.trackTestLogin(username, password, language);
6060
}
6161

6262
public void keyPressed(KeyEvent evt) {}
@@ -86,10 +86,11 @@ private void create() {
8686
this.languageChoicer.setForeground(Color.black);
8787
this.languageChoicer.addItemListener(this);
8888
int selectedLanguageIndex =
89-
switch (locale) {
90-
case EN_US -> 0;
91-
case FI_FI -> 1;
92-
case SV_SE -> 2;
89+
switch (language) {
90+
case Language.ENGLISH -> 0;
91+
case Language.FINNISH -> 1;
92+
case Language.SWEDISH -> 2;
93+
default -> 0;
9394
};
9495
this.languageChoicer.setSelectedIndex(selectedLanguageIndex);
9596
this.add(this.languageChoicer);
@@ -131,13 +132,13 @@ public void itemStateChanged(ItemEvent e) {
131132
if (e.getSource() == this.languageChoicer) {
132133
switch (this.languageChoicer.getSelectedIndex()) {
133134
case 0:
134-
this.locale = Locale.EN_US;
135+
this.language = Language.ENGLISH;
135136
break;
136137
case 1:
137-
this.locale = Locale.FI_FI;
138+
this.language = Language.FINNISH;
138139
break;
139140
case 2:
140-
this.locale = Locale.SV_SE;
141+
this.language = Language.SWEDISH;
141142
break;
142143
}
143144
}

client/src/main/java/agolf/lobby/LobbyChatPanel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import agolf.GameContainer;
44
import agolf.GolfGameFrame;
55
import com.aapeli.multiuser.ChatLobby;
6-
import com.aapeli.multiuser.Languages;
76
import com.aapeli.multiuser.MultiLanguageChatListener;
87
import com.aapeli.multiuser.User;
8+
import org.moparforia.shared.Language;
99

1010
class LobbyChatPanel extends ChatLobby implements MultiLanguageChatListener {
1111

@@ -36,14 +36,14 @@ protected LobbyChatPanel(GameContainer gameContainer, int width, int height, int
3636
this.disableChatInput(2);
3737
}
3838

39-
this.addChatWithLanguage(Languages.getLanguageId(gameContainer.params.getLocale()));
39+
this.addChatWithLanguage(gameContainer.params.getLanguage());
4040
this.addChatListener(this);
4141
}
4242

4343
public void localUserSay(String var1) {}
4444

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

4949
public void localUserSayPrivately(String var1, String var2) {
@@ -299,7 +299,7 @@ protected boolean handlePacket(String[] args) {
299299
return true;
300300
}
301301
case "say" -> {
302-
this.userSay(Integer.parseInt(args[2]), args[3], args[4]);
302+
this.userSay(Language.fromString(args[2]), args[3], args[4]);
303303
return true;
304304
}
305305
case "sayp" -> {
-12 Bytes
Binary file not shown.

client/src/main/java/com/aapeli/client/Parameters.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import java.net.URI;
77
import java.net.URISyntaxException;
88
import java.util.Map;
9-
import org.moparforia.shared.Locale;
9+
import org.moparforia.shared.Language;
1010

1111
public final class Parameters {
1212

1313
private static final String LOCALHOST = "127.0.0.1";
1414
private String serverIp;
15-
private Locale locale;
15+
private Language language;
1616
private String username;
1717
private String session;
1818
private String urlRegisterPage;
@@ -76,8 +76,8 @@ public String getUsername() {
7676
return this.username;
7777
}
7878

79-
public Locale getLocale() {
80-
return this.locale;
79+
public Language getLanguage() {
80+
return this.language;
8181
}
8282

8383
public String getSession() {
@@ -218,7 +218,7 @@ public void removePlayerList() {
218218

219219
public void destroy() {
220220
this.serverIp = null;
221-
this.locale = null;
221+
this.language = null;
222222
this.session = null;
223223
this.urlRegisterPage = null;
224224
this.urlUserInfoPage = null;
@@ -232,7 +232,7 @@ public void destroy() {
232232
private void init() {
233233
this.serverIp = this.getParamServer();
234234
this.serverPort = this.getParamPort();
235-
this.locale = this.getParamLocale();
235+
this.language = this.getParamLanguage();
236236
this.session = this.getParameter("session");
237237
this.urlRegisterPage = this.getParameter("registerpage");
238238
this.urlUserInfoPage = this.getParameter("userinfopage");
@@ -267,11 +267,11 @@ private int getParamPort() {
267267
}
268268
}
269269

270-
private Locale getParamLocale() {
270+
private Language getParamLanguage() {
271271
try {
272-
String locale = this.getParameter("locale");
273-
if (locale != null) {
274-
return Locale.fromString(locale);
272+
String language = this.getParameter("language");
273+
if (language != null) {
274+
return Language.fromString(language);
275275
}
276276

277277
} catch (Exception e) {

client/src/main/java/com/aapeli/client/TextManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
import java.util.Map;
1010
import javax.xml.parsers.DocumentBuilder;
1111
import javax.xml.parsers.DocumentBuilderFactory;
12-
import org.moparforia.shared.Locale;
12+
import org.moparforia.shared.Language;
1313
import org.w3c.dom.Document;
1414
import org.w3c.dom.Node;
1515
import org.w3c.dom.NodeList;
1616

1717
public final class TextManager {
1818

19-
private Locale locale;
19+
private Language language;
2020
private Map<String, String> texts;
2121
private String errorMessage;
2222
private boolean debug;
@@ -25,12 +25,12 @@ public TextManager(Parameters parameters, boolean debug) {
2525
this.debug = debug;
2626
this.texts = new Hashtable<>();
2727
this.errorMessage = null;
28-
this.locale = parameters.getLocale();
28+
this.language = parameters.getLanguage();
2929
this.loadTexts();
3030
}
3131

32-
public void setLocale(Locale locale) {
33-
this.locale = locale;
32+
public void setLanguage(Language language) {
33+
this.language = language;
3434
this.loadTexts();
3535
}
3636

@@ -149,12 +149,12 @@ public void destroy() {
149149
this.texts = null;
150150
}
151151

152-
this.locale = null;
152+
this.language = null;
153153
this.errorMessage = null;
154154
}
155155

156-
protected Locale getLocale() {
157-
return this.locale;
156+
protected Language getLanguage() {
157+
return this.language;
158158
}
159159

160160
private String getInternal(String key, String[] arguments) {
@@ -269,7 +269,7 @@ private String getDate(long timestamp, int mode) {
269269
}
270270

271271
private void loadTexts() {
272-
String resourcePath = "/l10n/" + this.locale + "/AGolf.xml";
272+
String resourcePath = "/l10n/" + this.language + "/AGolf.xml";
273273
try {
274274
InputStream in = this.getClass().getResourceAsStream(resourcePath);
275275
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

client/src/main/java/com/aapeli/colorgui/BlinkingButtonThread.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)