Fix Localization for game.
This commit is contained in:
@@ -73,8 +73,8 @@ public class BuildingPlacer {
|
|||||||
game.updateUI();
|
game.updateUI();
|
||||||
|
|
||||||
game.setMessageText(tempBuilding.isOverlapping ?
|
game.setMessageText(tempBuilding.isOverlapping ?
|
||||||
"🎨 Здание пересекается с существующими! Это добавляет уникальности! 🎨" :
|
Localization.buildingOverlaps() :
|
||||||
"🌟 Отличное место для строительства! Введите ответ: 🌟");
|
Localization.greatPlace());
|
||||||
game.setMessageColor(tempBuilding.isOverlapping ? com.badlogic.gdx.graphics.Color.ORANGE : com.badlogic.gdx.graphics.Color.GREEN);
|
game.setMessageColor(tempBuilding.isOverlapping ? com.badlogic.gdx.graphics.Color.ORANGE : com.badlogic.gdx.graphics.Color.GREEN);
|
||||||
|
|
||||||
game.setTyping(true);
|
game.setTyping(true);
|
||||||
@@ -85,7 +85,7 @@ public class BuildingPlacer {
|
|||||||
if (game.getCurrentBuilding() != null) {
|
if (game.getCurrentBuilding() != null) {
|
||||||
Rectangle buildingBounds = game.getCurrentBuilding().getBounds();
|
Rectangle buildingBounds = game.getCurrentBuilding().getBounds();
|
||||||
if (buildingBounds.contains(worldX, worldY)) {
|
if (buildingBounds.contains(worldX, worldY)) {
|
||||||
game.setMessageText("🎯 Кликните вне здания для нового строительства. Ctrl+Z или Delete для удаления. 🎯");
|
game.setMessageText(Localization.clickOutside());
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
||||||
} else {
|
} else {
|
||||||
if (!game.isTyping()) {
|
if (!game.isTyping()) {
|
||||||
|
|||||||
@@ -1226,7 +1226,8 @@ public class BuildingRenderer {
|
|||||||
font.setColor(pulseColor);
|
font.setColor(pulseColor);
|
||||||
font.getData().setScale(1.1f * building.getSizeScale());
|
font.getData().setScale(1.1f * building.getSizeScale());
|
||||||
|
|
||||||
glyphLayout.setText(font, building.type);
|
String localizedName = Localization.getBuildingName(building);
|
||||||
|
glyphLayout.setText(font, localizedName);
|
||||||
float textWidth = glyphLayout.width;
|
float textWidth = glyphLayout.width;
|
||||||
|
|
||||||
// Фон с закругленными краями
|
// Фон с закругленными краями
|
||||||
@@ -1241,7 +1242,7 @@ public class BuildingRenderer {
|
|||||||
batch.draw(whitePixel, x - textWidth/2 - 15, y + 10, textWidth + 30, 5); // Низ
|
batch.draw(whitePixel, x - textWidth/2 - 15, y + 10, textWidth + 30, 5); // Низ
|
||||||
|
|
||||||
batch.setColor(Color.WHITE);
|
batch.setColor(Color.WHITE);
|
||||||
font.draw(batch, building.type, x - textWidth/2, y);
|
font.draw(batch, localizedName, x - textWidth/2, y);
|
||||||
font.getData().setScale(1.0f);
|
font.getData().setScale(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1252,9 +1253,8 @@ public class BuildingRenderer {
|
|||||||
font.setColor(Color.YELLOW);
|
font.setColor(Color.YELLOW);
|
||||||
font.getData().setScale(0.9f * building.getSizeScale());
|
font.getData().setScale(0.9f * building.getSizeScale());
|
||||||
|
|
||||||
String cleanType = building.type.replace("✨", "").replace("🏥", "").replace("🎒", "")
|
String localizedName = Localization.getBuildingName(building);
|
||||||
.replace("🎪", "").replace("💰", "").replace("💊", "")
|
String cleanType = localizedName.replaceAll("[✨🏥🎒🎪💰💊🎭🎬🚀🔴🛰️⚡💧🌌🤖🧪🌋🔥🌅☁️💎🌡️🌀]", "").trim();
|
||||||
.replace("🎭", "").replace("🎬", "").trim();
|
|
||||||
String progressText = cleanType + " (" + building.constructionProgress + "/3)";
|
String progressText = cleanType + " (" + building.constructionProgress + "/3)";
|
||||||
glyphLayout.setText(font, progressText);
|
glyphLayout.setText(font, progressText);
|
||||||
float textWidth = glyphLayout.width;
|
float textWidth = glyphLayout.width;
|
||||||
@@ -1274,10 +1274,9 @@ public class BuildingRenderer {
|
|||||||
font.setColor(Color.YELLOW);
|
font.setColor(Color.YELLOW);
|
||||||
font.getData().setScale(1.0f * building.getSizeScale());
|
font.getData().setScale(1.0f * building.getSizeScale());
|
||||||
|
|
||||||
String cleanType = building.type.replace("✨", "").replace("🏥", "").replace("🎒", "")
|
String localizedName = Localization.getBuildingName(building);
|
||||||
.replace("🎪", "").replace("💰", "").replace("💊", "")
|
String cleanType = localizedName.replaceAll("[✨🏥🎒🎪💰💊🎭🎬🚀🔴🛰️⚡💧🌌🤖🧪🌋🔥🌅☁️💎🌡️🌀]", "").trim();
|
||||||
.replace("🎭", "").replace("🎬", "").trim();
|
String prefix = building.constructionProgress == 0 ? Localization.placeFor() : Localization.constructing();
|
||||||
String prefix = building.constructionProgress == 0 ? "Место для: " : "Строится: ";
|
|
||||||
String progressText = prefix + cleanType + " (" + building.constructionProgress + "/3)";
|
String progressText = prefix + cleanType + " (" + building.constructionProgress + "/3)";
|
||||||
glyphLayout.setText(font, progressText);
|
glyphLayout.setText(font, progressText);
|
||||||
float textWidth = glyphLayout.width;
|
float textWidth = glyphLayout.width;
|
||||||
@@ -1291,7 +1290,7 @@ public class BuildingRenderer {
|
|||||||
if (building.isOverlapping) {
|
if (building.isOverlapping) {
|
||||||
font.setColor(Color.RED);
|
font.setColor(Color.RED);
|
||||||
font.getData().setScale(0.8f * building.getSizeScale());
|
font.getData().setScale(0.8f * building.getSizeScale());
|
||||||
String warning = "⚠ Пересечение! ⚠";
|
String warning = Localization.overlapWarning();
|
||||||
glyphLayout.setText(font, warning);
|
glyphLayout.setText(font, warning);
|
||||||
font.draw(batch, warning, x - glyphLayout.width/2, y - 25);
|
font.draw(batch, warning, x - glyphLayout.width/2, y - 25);
|
||||||
font.getData().setScale(1.0f);
|
font.getData().setScale(1.0f);
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class InputHandler {
|
|||||||
game.setSelectedBuildingType(newType);
|
game.setSelectedBuildingType(newType);
|
||||||
game.updateUI();
|
game.updateUI();
|
||||||
|
|
||||||
game.setMessageText("Выбран: " +
|
game.setMessageText(Localization.selected() + ": " +
|
||||||
Building.BUILDING_TYPES_BY_PLANET[game.getCurrentPlanet().ordinal()][newType]);
|
Localization.getBuildingName(game.getCurrentPlanet(), newType));
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,8 @@ public class InputHandler {
|
|||||||
game.setSelectedBuildingType(newType);
|
game.setSelectedBuildingType(newType);
|
||||||
game.updateUI();
|
game.updateUI();
|
||||||
|
|
||||||
game.setMessageText("Выбран: " +
|
game.setMessageText(Localization.selected() + ": " +
|
||||||
Building.BUILDING_TYPES_BY_PLANET[game.getCurrentPlanet().ordinal()][newType]);
|
Localization.getBuildingName(game.getCurrentPlanet(), newType));
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.CYAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,15 +72,15 @@ public class InputHandler {
|
|||||||
game.setCurrentProblem(null);
|
game.setCurrentProblem(null);
|
||||||
game.setTyping(false);
|
game.setTyping(false);
|
||||||
game.getInputText().setLength(0);
|
game.getInputText().setLength(0);
|
||||||
game.setMessageText("Строительство отменено. Выберите новое место.");
|
game.setMessageText(Localization.constructionCancelled());
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
||||||
game.updateUI();
|
game.updateUI();
|
||||||
} else if (game.getBuildings().size > 0) {
|
} else if (game.getBuildings().size > 0) {
|
||||||
game.getBuildings().removeIndex(game.getBuildings().size - 1);
|
game.getBuildings().removeIndex(game.getBuildings().size - 1);
|
||||||
game.setMessageText("Последнее здание удалено.");
|
game.setMessageText(Localization.lastBuildingRemoved());
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.ORANGE);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.ORANGE);
|
||||||
} else {
|
} else {
|
||||||
game.setMessageText("Нет зданий для удаления.");
|
game.setMessageText(Localization.noBuildingsToRemove());
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public class InputHandler {
|
|||||||
game.getInputText().deleteCharAt(game.getInputText().length() - 1);
|
game.getInputText().deleteCharAt(game.getInputText().length() - 1);
|
||||||
} else if (!game.isTyping() && game.getCurrentBuilding() != null && game.getCurrentBuilding().constructionProgress > 0) {
|
} else if (!game.isTyping() && game.getCurrentBuilding() != null && game.getCurrentBuilding().constructionProgress > 0) {
|
||||||
game.getCurrentBuilding().removeBlock();
|
game.getCurrentBuilding().removeBlock();
|
||||||
game.setMessageText("Блок удален! Текущий прогресс: " + game.getCurrentBuilding().constructionProgress + "/3");
|
game.setMessageText(Localization.blockRemoved(game.getCurrentBuilding().constructionProgress));
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
||||||
game.updateUI();
|
game.updateUI();
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public class InputHandler {
|
|||||||
if (game.isTyping()) {
|
if (game.isTyping()) {
|
||||||
game.setTyping(false);
|
game.setTyping(false);
|
||||||
game.getInputText().setLength(0);
|
game.getInputText().setLength(0);
|
||||||
game.setMessageText("Ввод отменен. Можно продолжить строительство.");
|
game.setMessageText(Localization.inputCancelled());
|
||||||
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
game.setMessageColor(com.badlogic.gdx.graphics.Color.YELLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,88 @@ public class Localization {
|
|||||||
return isRu() ? "Отлично! Блок построен!" : "Great! Block built!";
|
return isRu() ? "Отлично! Блок построен!" : "Great! Block built!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String selected() {
|
||||||
|
return isRu() ? "Выбран" : "Selected";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String overlapping() {
|
||||||
|
return isRu() ? "(пересекается!)" : "(overlapping!)";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String colorTheme() {
|
||||||
|
return isRu() ? "Цвет: Тема" : "Color: Theme";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String building() {
|
||||||
|
return isRu() ? "Строим" : "Building";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String planet() {
|
||||||
|
return isRu() ? "Планета" : "Planet";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildingType() {
|
||||||
|
return isRu() ? "Тип здания" : "Building type";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String arrowsToSelect() {
|
||||||
|
return isRu() ? "(←/→ для выбора, кликните для строительства)" : "(←/→ to select, click to build)";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String menu() {
|
||||||
|
return isRu() ? "меню" : "menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String flyingTo() {
|
||||||
|
return isRu() ? "Перелет на" : "Flying to";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String placeFor() {
|
||||||
|
return isRu() ? "Место для: " : "Place for: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String constructing() {
|
||||||
|
return isRu() ? "Строится: " : "Building: ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String overlapWarning() {
|
||||||
|
return isRu() ? "⚠ Пересечение! ⚠" : "⚠ Overlap! ⚠";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildingOverlaps() {
|
||||||
|
return isRu()
|
||||||
|
? "🎨 Здание пересекается с существующими! Это добавляет уникальности! 🎨"
|
||||||
|
: "🎨 Building overlaps with existing ones! This adds uniqueness! 🎨";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String greatPlace() {
|
||||||
|
return isRu()
|
||||||
|
? "🌟 Отличное место для строительства! Введите ответ: 🌟"
|
||||||
|
: "🌟 Great place to build! Enter your answer: 🌟";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String clickOutside() {
|
||||||
|
return isRu()
|
||||||
|
? "🎯 Кликните вне здания для нового строительства. Ctrl+Z или Delete для удаления. 🎯"
|
||||||
|
: "🎯 Click outside building for new construction. Ctrl+Z or Delete to remove. 🎯";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String constructionCancelled() {
|
||||||
|
return isRu()
|
||||||
|
? "Строительство отменено. Выберите новое место."
|
||||||
|
: "Construction cancelled. Select a new place.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String lastBuildingRemoved() {
|
||||||
|
return isRu() ? "Последнее здание удалено." : "Last building removed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String inputCancelled() {
|
||||||
|
return isRu()
|
||||||
|
? "Ввод отменен. Можно продолжить строительство."
|
||||||
|
: "Input cancelled. You can continue building.";
|
||||||
|
}
|
||||||
|
|
||||||
public static String changePlanet() {
|
public static String changePlanet() {
|
||||||
return isRu() ? "↑/↓ - сменить планету" : "↑/↓ - change planet";
|
return isRu() ? "↑/↓ - сменить планету" : "↑/↓ - change planet";
|
||||||
}
|
}
|
||||||
@@ -245,10 +327,6 @@ public class Localization {
|
|||||||
return isRu() ? "Строительство отменено. Выберите новое место." : "Construction canceled. Choose a new location.";
|
return isRu() ? "Строительство отменено. Выберите новое место." : "Construction canceled. Choose a new location.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String lastBuildingRemoved() {
|
|
||||||
return isRu() ? "Последнее здание удалено." : "Last building removed.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String noBuildingsToRemove() {
|
public static String noBuildingsToRemove() {
|
||||||
return isRu() ? "Нет зданий для удаления." : "No buildings to remove.";
|
return isRu() ? "Нет зданий для удаления." : "No buildings to remove.";
|
||||||
}
|
}
|
||||||
@@ -281,6 +359,16 @@ public class Localization {
|
|||||||
return BUILDING_NAMES_EN;
|
return BUILDING_NAMES_EN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Получить локализованное название здания по индексам
|
||||||
|
public static String getBuildingName(Planet planet, int typeIndex) {
|
||||||
|
return getBuildingNames()[planet.ordinal()][typeIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получить локализованное название для Building объекта
|
||||||
|
public static String getBuildingName(Building building) {
|
||||||
|
return getBuildingNames()[building.planetIndex][building.buildingTypeIndex];
|
||||||
|
}
|
||||||
|
|
||||||
private static final String[][] BUILDING_NAMES_EN = {
|
private static final String[][] BUILDING_NAMES_EN = {
|
||||||
// Earth
|
// Earth
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,27 +7,26 @@ public class UIUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Planet planet = game.getCurrentPlanet();
|
Planet planet = game.getCurrentPlanet();
|
||||||
String[] planetBuildings = Building.BUILDING_TYPES_BY_PLANET[planet.ordinal()];
|
|
||||||
|
|
||||||
if (game.getCurrentBuilding() != null && game.getCurrentProblem() != null) {
|
if (game.getCurrentBuilding() != null && game.getCurrentProblem() != null) {
|
||||||
String overlapText = game.getCurrentBuilding().isOverlapping ? " (пересекается!)" : "";
|
String overlapText = game.getCurrentBuilding().isOverlapping ? " " + Localization.overlapping() : "";
|
||||||
String colorInfo = "";
|
String colorInfo = "";
|
||||||
if (game.getCurrentBuilding().isComplete()) {
|
if (game.getCurrentBuilding().isComplete()) {
|
||||||
colorInfo = String.format(" [Цвет: Тема %d]", game.getCurrentBuilding().colorThemeIndex + 1);
|
colorInfo = String.format(" [%s %d]", Localization.colorTheme(), game.getCurrentBuilding().colorThemeIndex + 1);
|
||||||
}
|
}
|
||||||
String fullText = "Строим " + game.getCurrentBuilding().type +
|
String fullText = Localization.building() + " " + Localization.getBuildingName(game.getCurrentBuilding()) +
|
||||||
" (" + game.getCurrentBuilding().constructionProgress + "/3)" + colorInfo +
|
" (" + game.getCurrentBuilding().constructionProgress + "/3)" + colorInfo +
|
||||||
": " + game.getCurrentProblem().getQuestion() + overlapText;
|
": " + game.getCurrentProblem().getQuestion() + overlapText;
|
||||||
game.setProblemText(fullText);
|
game.setProblemText(fullText);
|
||||||
} else {
|
} else {
|
||||||
String planetText = game.isSwitchingPlanets() ?
|
String planetText = game.isSwitchingPlanets() ?
|
||||||
"Перелет на " + game.getTargetPlanet().getName() + "..." :
|
Localization.flyingTo() + " " + Localization.planetName(game.getTargetPlanet()) + "..." :
|
||||||
"Планета: " + planet.getName();
|
Localization.planet() + ": " + Localization.planetName(planet);
|
||||||
|
|
||||||
game.setProblemText(planetText +
|
game.setProblemText(planetText +
|
||||||
" | Тип здания: " + planetBuildings[game.getSelectedBuildingType()] +
|
" | " + Localization.buildingType() + ": " + Localization.getBuildingName(planet, game.getSelectedBuildingType()) +
|
||||||
" (←/→ для выбора, кликните на поле для строительства)" +
|
" " + Localization.arrowsToSelect() +
|
||||||
" | ESC - меню");
|
" | ESC - " + Localization.menu());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user