mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
Faction Raw reader, new locale 'jp_kana' and 'jp', adjusting kana font
Former-commit-id: 3e401ba531be1d3baed7bd280db4ad5619ce252b Former-commit-id: 530d4f8bc7cbc39068485c4fecb81693e569534a
This commit is contained in:
@@ -257,9 +257,7 @@ public class GameFontBase implements Font {
|
||||
+ getWidth(s.substring(0, i))
|
||||
)
|
||||
, Math.round(y)
|
||||
- ((prevInstance == SHEET_KANA) ? 2
|
||||
: (prevInstance == SHEET_CJK_PUNCT) ?
|
||||
1 : 0)
|
||||
- ((prevInstance == SHEET_CJK_PUNCT) ? 1 : 0)
|
||||
, sheetX
|
||||
, sheetY
|
||||
);
|
||||
|
||||
@@ -21,6 +21,14 @@ public class Faction {
|
||||
factionFearful = new HashSet<>();
|
||||
}
|
||||
|
||||
public String getFactionName() {
|
||||
return factionName;
|
||||
}
|
||||
|
||||
public void renewFactionName(String factionName) {
|
||||
this.factionName = factionName;
|
||||
}
|
||||
|
||||
public HashSet<String> getFactionFearful() {
|
||||
return factionFearful;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.Torvald.Terrarum.Actors;
|
||||
|
||||
import com.Torvald.JsonFetcher;
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.Game;
|
||||
import com.Torvald.spriteAnimation.SpriteAnimation;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.lwjgl.Sys;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
*/
|
||||
public class PBFSigrid {
|
||||
|
||||
private static String FACTION_PATH = "./res/raw/";
|
||||
|
||||
public Player build() throws SlickException {
|
||||
Player p = new Player();
|
||||
|
||||
@@ -60,7 +68,36 @@ public class PBFSigrid {
|
||||
|
||||
p.setPosition(4096 * 16, 300 * 16);
|
||||
|
||||
p.assignFaction(loadFactioningData("FactionSigrid.json"));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private Faction loadFactioningData(String filename) {
|
||||
JsonObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = JsonFetcher.readJson(FACTION_PATH + filename);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Faction faction = new Faction(jsonObject.get("factionname").getAsString());
|
||||
|
||||
jsonObject.get("factionamicable").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionAmicable(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionneutral").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionNeutral(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionhostile").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionHostile(jobj.getAsString())
|
||||
);
|
||||
jsonObject.get("factionfearful").getAsJsonArray().forEach(
|
||||
jobj -> faction.addFactionFearful(jobj.getAsString())
|
||||
);
|
||||
|
||||
return faction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,9 @@ public class Player extends ActorWithBody implements Controllable, Pocketed, Fac
|
||||
|
||||
@Override
|
||||
public void update(GameContainer gc, int delta_t) {
|
||||
if (vehicleRiding instanceof Player) throw new RuntimeException("Attempted to 'ride' " +
|
||||
"player object.");
|
||||
|
||||
updatePhysicalInfos();
|
||||
super.update(gc, delta_t);
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ public class CommandDict {
|
||||
dict.put("cat", new CatStdout());
|
||||
dict.put("exportav", new ExportAV());
|
||||
dict.put("gsontest", new GsonTest());
|
||||
dict.put("setgl", new SetGlobalLightLevel());
|
||||
dict.put("getfaction", new GetFactioning());
|
||||
}
|
||||
|
||||
public static ConsoleCommand getCommand(String commandName) {
|
||||
|
||||
55
src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java
Normal file
55
src/com/Torvald/Terrarum/ConsoleCommand/GetFactioning.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Actors.Faction.Faction;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
*/
|
||||
public class GetFactioning implements ConsoleCommand {
|
||||
|
||||
private final String PRINT_INDENTATION = " --> ";
|
||||
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
Echo echo = new Echo();
|
||||
|
||||
if (args.length == 1) { // get all factioning data of player
|
||||
HashSet<Faction> factionSet = Terrarum.game.getPlayer().getAssignedFactions();
|
||||
|
||||
int count = factionSet.size();
|
||||
echo.execute(String.valueOf(count) + Lang.pluralise(" faction", count) + " assigned.");
|
||||
|
||||
for (Faction faction : factionSet) {
|
||||
echo.execute("Faction \"" + faction.getFactionName() + "\"");
|
||||
echo.execute(" Amicable");
|
||||
faction.getFactionAmicable().forEach(
|
||||
s -> echo.execute(PRINT_INDENTATION + s)
|
||||
);
|
||||
|
||||
echo.execute(" Explicit neutral");
|
||||
faction.getFactionNeutral().forEach(
|
||||
s -> echo.execute(PRINT_INDENTATION + s)
|
||||
);
|
||||
|
||||
echo.execute(" Hostile");
|
||||
faction.getFactionHostile().forEach(
|
||||
s -> echo.execute(PRINT_INDENTATION + s)
|
||||
);
|
||||
|
||||
echo.execute(" Fearful");
|
||||
faction.getFactionFearful().forEach(
|
||||
s -> echo.execute(PRINT_INDENTATION + s)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.Torvald.Terrarum.ConsoleCommand;
|
||||
|
||||
import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
*/
|
||||
public class SetGlobalLightLevel implements ConsoleCommand {
|
||||
@Override
|
||||
public void execute(String[] args) {
|
||||
if (args.length == 4) {
|
||||
try {
|
||||
int r = new Integer(args[1]);
|
||||
int g = new Integer(args[2]);
|
||||
int b = new Integer(args[3]);
|
||||
int GL = (r << 16) | (g << 8) | b;
|
||||
|
||||
Terrarum.game.map.setGlobalLight(GL);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
new Echo().execute("Wrong number input.");
|
||||
}
|
||||
}
|
||||
else{
|
||||
printUsage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printUsage() {
|
||||
new Echo().execute("Usage: setgl r g b");
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.Torvald.Terrarum.Terrarum;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,26 @@ public class Lang {
|
||||
private static Properties langFallback;
|
||||
private static final String FALLBACK_LANG_CODE = "en";
|
||||
|
||||
private static final int HANGUL_SYL_START = 0xAC00;
|
||||
|
||||
private static final int[] HANGUL_POST_INDEX_ALPH = { // 0: 는, 가, ... 1: 은, 이, ...
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
private static final int[] HANGUL_POST_RO_INDEX_ALPH = { // 0: 로 1: 으로
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
private static String[] ENGLISH_WORD_NORMAL_PLURAL = {
|
||||
"photo"
|
||||
};
|
||||
|
||||
private static String[] FRENCH_WORD_NORMAL_PLURAL = {
|
||||
"bal"
|
||||
, "banal"
|
||||
, "fatal"
|
||||
, "final"
|
||||
};
|
||||
|
||||
public Lang() throws IOException {
|
||||
lang = new Properties();
|
||||
lang.load(new BufferedReader(new InputStreamReader(new FileInputStream(
|
||||
@@ -23,6 +44,8 @@ public class Lang {
|
||||
langFallback = new Properties();
|
||||
langFallback.load(new BufferedReader(new InputStreamReader(new FileInputStream(
|
||||
"res/locales/" + FALLBACK_LANG_CODE + ".lang"), StandardCharsets.UTF_8)));
|
||||
|
||||
Arrays.sort(ENGLISH_WORD_NORMAL_PLURAL);
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
@@ -32,4 +55,83 @@ public class Lang {
|
||||
);
|
||||
}
|
||||
|
||||
public static String pluraliseLang(String key, int count) {
|
||||
return (count > 1) ? get(key + "_PLURAL") : get(key);
|
||||
}
|
||||
|
||||
public static String pluralise(String word, int count) {
|
||||
if (count < 2) return word;
|
||||
|
||||
switch (Terrarum.gameLocale) {
|
||||
case ("fr"):
|
||||
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
|
||||
return word + "s";
|
||||
}
|
||||
if (word.endsWith("al") || word.endsWith("au") || word.endsWith("eu") || word
|
||||
.endsWith("eau")) {
|
||||
return word.substring(0, word.length() - 2) + "ux";
|
||||
}
|
||||
else if (word.endsWith("ail")) {
|
||||
return word.substring(0, word.length() - 3) + "ux";
|
||||
}
|
||||
else {
|
||||
return word + "s";
|
||||
}
|
||||
case ("en"): default:
|
||||
if (Arrays.binarySearch(ENGLISH_WORD_NORMAL_PLURAL, word) >= 0) {
|
||||
return word + "s";
|
||||
}
|
||||
else if (word.endsWith("f")) { // f -> ves
|
||||
return word.substring(0, word.length() - 2) + "ves";
|
||||
}
|
||||
else if (word.endsWith("o") || word.endsWith("z")) { // o -> oes
|
||||
return word + "es";
|
||||
}
|
||||
else {
|
||||
return word + "s";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String postEunNeun(String word) {
|
||||
char lastChar = getLastChar(word);
|
||||
|
||||
if (isHangul(lastChar)) {
|
||||
int index = lastChar - HANGUL_SYL_START;
|
||||
return (index % 28 == 0) ? word + "는" : word + "은";
|
||||
}
|
||||
else if ((lastChar >= 'A' && lastChar <= 'Z')
|
||||
|| (lastChar >= 'a' && lastChar <= 'z')) {
|
||||
int index = (lastChar - 0x41) % 0x20;
|
||||
return (HANGUL_POST_INDEX_ALPH[index] == 0) ? word + "는" : word + "은";
|
||||
}
|
||||
else {
|
||||
return "은(는)";
|
||||
}
|
||||
}
|
||||
|
||||
public static String postIiGa(String word) {
|
||||
char lastChar = getLastChar(word);
|
||||
|
||||
if (isHangul(lastChar)) {
|
||||
int index = lastChar - HANGUL_SYL_START;
|
||||
return (index % 28 == 0) ? word + "가" : word + "이";
|
||||
}
|
||||
else if ((lastChar >= 'A' && lastChar <= 'Z')
|
||||
|| (lastChar >= 'a' && lastChar <= 'z')) {
|
||||
int index = (lastChar - 0x41) % 0x20;
|
||||
return (HANGUL_POST_INDEX_ALPH[index] == 0) ? word + "가" : word + "이";
|
||||
}
|
||||
else {
|
||||
return "이(가)";
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHangul(char c) {
|
||||
return (c >= 0xAC00 && c <= 0xD7A3);
|
||||
}
|
||||
|
||||
private static char getLastChar(String s) {
|
||||
return s.charAt(s.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.logging.Logger;
|
||||
import com.Torvald.ImageFont.GameFontWhite;
|
||||
import com.Torvald.Terrarum.LangPack.Lang;
|
||||
import org.lwjgl.input.Controllers;
|
||||
import org.lwjgl.opengl.DisplayMode;
|
||||
import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
|
||||
@@ -42,7 +41,7 @@ public class Terrarum extends StateBasedGame {
|
||||
public static String defaultDir;
|
||||
public static String defaultSaveDir;
|
||||
|
||||
public static String gameLocale = "ko";
|
||||
public static String gameLocale = "jp_kana";
|
||||
|
||||
public static Font gameFontWhite;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"17";"TILE_ORE_NATURAL_GOLD" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "17"; "0";"16"
|
||||
"18";"TILE_ORE_NATURAL_SILVER" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "18"; "0";"16"
|
||||
"19";"TILE_ORE_RUTILE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "19"; "0";"16"
|
||||
"20";"TILE_ORE_NATURAL_AURICHALCUM"; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16"
|
||||
"20";"TILE_ORE_AURICHALCUMITE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "20"; "0";"16"
|
||||
"21";"TILE_GEM_RUBY" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "21"; "0";"16"
|
||||
"22";"TILE_GEM_EMERALD" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "22"; "0";"16"
|
||||
"23";"TILE_GEM_SAPPHIRE" ; "32"; "25"; "0"; "N/A"; "1"; "0"; "0"; "23"; "0";"16"
|
||||
@@ -42,5 +42,5 @@
|
||||
|
||||
"36";"TILE_TORCH" ; "0"; "0"; "0"; "N/A"; "0"; "0";"16777215"; "36"; "0";"16"
|
||||
|
||||
"239";"TILE_WATER" ; "16"; "100"; "1"; "2"; "0"; "0";"15464447"; "239"; "0";"16"
|
||||
"239";"TILE_WATER" ; "16"; "100"; "1"; "2"; "0"; "0";"15464447"; "239"; "0";"16"
|
||||
"255";"TILE_LAVA" ; "0"; "100"; "1"; "2"; "0"; "0"; "8397312"; "239"; "0";"16"
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 12.
|
@@ -150,8 +150,8 @@ public class SpriteAnimation {
|
||||
|
||||
flippedImage.startUse();
|
||||
flippedImage.drawEmbedded(
|
||||
FastMath.floor(posX * Terrarum.game.screenZoom)
|
||||
, FastMath.floor(posY * Terrarum.game.screenZoom)
|
||||
Math.round(posX * Terrarum.game.screenZoom)
|
||||
, Math.round(posY * Terrarum.game.screenZoom)
|
||||
, FastMath.floor(width * scale)
|
||||
, FastMath.floor(height * scale)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user