Translations are now automatically downloaded from the Replay Mod API
Localized missing Strings
This commit is contained in:
@@ -3,7 +3,9 @@ package eu.crushedpixel.replaymod;
|
|||||||
import eu.crushedpixel.replaymod.api.client.ApiClient;
|
import eu.crushedpixel.replaymod.api.client.ApiClient;
|
||||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
||||||
import eu.crushedpixel.replaymod.events.*;
|
import eu.crushedpixel.replaymod.events.*;
|
||||||
|
import eu.crushedpixel.replaymod.localization.LocalizedResourcePack;
|
||||||
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
import eu.crushedpixel.replaymod.recording.ConnectionEventHandler;
|
||||||
|
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||||
import eu.crushedpixel.replaymod.registry.FileCopyHandler;
|
import eu.crushedpixel.replaymod.registry.FileCopyHandler;
|
||||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||||
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
import eu.crushedpixel.replaymod.renderer.SafeEntityRenderer;
|
||||||
@@ -23,6 +25,8 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mod(modid = ReplayMod.MODID, version = ReplayMod.VERSION)
|
@Mod(modid = ReplayMod.MODID, version = ReplayMod.VERSION)
|
||||||
public class ReplayMod {
|
public class ReplayMod {
|
||||||
@@ -59,6 +63,16 @@ public class ReplayMod {
|
|||||||
public static int TP_DISTANCE_LIMIT = 128;
|
public static int TP_DISTANCE_LIMIT = 128;
|
||||||
public static FileCopyHandler fileCopyHandler;
|
public static FileCopyHandler fileCopyHandler;
|
||||||
|
|
||||||
|
private static Field defaultResourcePacksField;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
defaultResourcePacksField = Minecraft.class.getDeclaredField(MCPNames.field("field_110449_ao"));
|
||||||
|
defaultResourcePacksField.setAccessible(true);
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The instance of your mod that Forge uses.
|
// The instance of your mod that Forge uses.
|
||||||
@Instance(value = "ReplayModID")
|
@Instance(value = "ReplayModID")
|
||||||
public static ReplayMod instance;
|
public static ReplayMod instance;
|
||||||
@@ -109,6 +123,15 @@ public class ReplayMod {
|
|||||||
//clean up replay_recordings folder
|
//clean up replay_recordings folder
|
||||||
removeTmcprFiles();
|
removeTmcprFiles();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List rps = (List) defaultResourcePacksField.get(mc);
|
||||||
|
rps.add(new LocalizedResourcePack());
|
||||||
|
defaultResourcePacksField.set(mc, rps);
|
||||||
|
mc.refreshResources();
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
boolean auth = false;
|
boolean auth = false;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ public class ApiClient {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTranslation(String languageCode) throws IOException, ApiException {
|
||||||
|
QueryBuilder builder = new QueryBuilder(ApiMethods.get_language);
|
||||||
|
builder.put("language", languageCode);
|
||||||
|
String properties = SimpleApiClient.invokeUrl(builder.toString());
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
public void downloadThumbnail(int file, File target) throws IOException {
|
public void downloadThumbnail(int file, File target) throws IOException {
|
||||||
QueryBuilder builder = new QueryBuilder(ApiMethods.get_thumbnail);
|
QueryBuilder builder = new QueryBuilder(ApiMethods.get_thumbnail);
|
||||||
builder.put("id", file);
|
builder.put("id", file);
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ public class ApiMethods {
|
|||||||
public static final String remove_file = "remove_file";
|
public static final String remove_file = "remove_file";
|
||||||
public static final String rate_file = "rate_file";
|
public static final String rate_file = "rate_file";
|
||||||
public static final String check_auth = "check_auth";
|
public static final String check_auth = "check_auth";
|
||||||
|
public static final String get_language = "get_language";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import eu.crushedpixel.replaymod.video.VideoWriter;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.*;
|
import net.minecraft.client.gui.*;
|
||||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||||
import net.minecraft.client.multiplayer.WorldClient;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||||
@@ -95,22 +95,22 @@ public class GuiEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDraw(DrawScreenEvent e) {
|
public void onDraw(DrawScreenEvent e) {
|
||||||
if(e.gui instanceof GuiMainMenu) {
|
if(e.gui instanceof GuiMainMenu) {
|
||||||
e.gui.drawString(mc.fontRendererObj, "Replay Mod:", 5, 5, Color.WHITE.getRGB());
|
e.gui.drawString(mc.fontRendererObj, I18n.format("replaymod.title")+":", 5, 5, Color.WHITE.getRGB());
|
||||||
if(AuthenticationHandler.isAuthenticated()) {
|
if(AuthenticationHandler.isAuthenticated()) {
|
||||||
e.gui.drawString(mc.fontRendererObj, "LOGGED IN", 5, 15, DARK_GREEN.getRGB());
|
e.gui.drawString(mc.fontRendererObj, I18n.format("replaymod.gui.loggedin").toUpperCase(), 5, 15, DARK_GREEN.getRGB());
|
||||||
} else {
|
} else {
|
||||||
e.gui.drawString(mc.fontRendererObj, "LOGGED OUT", 5, 15, DARK_RED.getRGB());
|
e.gui.drawString(mc.fontRendererObj, I18n.format("replaymod.gui.loggedout").toUpperCase(), 5, 15, DARK_RED.getRGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(replayCount == 0) {
|
if(replayCount == 0) {
|
||||||
if(editorButton.isMouseOver()) {
|
if(editorButton.isMouseOver()) {
|
||||||
Point mouse = MouseUtils.getMousePos();
|
Point mouse = MouseUtils.getMousePos();
|
||||||
e.gui.drawCenteredString(mc.fontRendererObj, "At least one Replay required", (int) mouse.getX(), (int) mouse.getY() + 4, Color.RED.getRGB());
|
e.gui.drawCenteredString(mc.fontRendererObj, I18n.format("replaymod.gui.morereplays"), (int) mouse.getX(), (int) mouse.getY() + 4, Color.RED.getRGB());
|
||||||
}
|
}
|
||||||
} else if(!VersionValidator.isValid) {
|
} else if(!VersionValidator.isValid) {
|
||||||
if(editorButton.isMouseOver()) {
|
if(editorButton.isMouseOver()) {
|
||||||
Point mouse = MouseUtils.getMousePos();
|
Point mouse = MouseUtils.getMousePos();
|
||||||
e.gui.drawCenteredString(mc.fontRendererObj, "Java 1.7 or newer required", (int) mouse.getX(), (int) mouse.getY() + 4, Color.RED.getRGB());
|
e.gui.drawCenteredString(mc.fontRendererObj, I18n.format("replaymod.gui.java"), (int) mouse.getX(), (int) mouse.getY() + 4, Color.RED.getRGB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ public class GuiEventHandler {
|
|||||||
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
||||||
for(GuiButton b : new ArrayList<GuiButton>(event.buttonList)) {
|
for(GuiButton b : new ArrayList<GuiButton>(event.buttonList)) {
|
||||||
if(b.id == 1) {
|
if(b.id == 1) {
|
||||||
b.displayString = "Exit Replay";
|
b.displayString = I18n.format("replaymod.gui.exit");
|
||||||
b.yPosition -= 24 * 2;
|
b.yPosition -= 24 * 2;
|
||||||
b.id = GuiConstants.EXIT_REPLAY_BUTTON;
|
b.id = GuiConstants.EXIT_REPLAY_BUTTON;
|
||||||
} else if(b.id >= 5 && b.id <= 7) {
|
} else if(b.id >= 5 && b.id <= 7) {
|
||||||
@@ -139,27 +139,27 @@ public class GuiEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2 * 24, "Replay Viewer");
|
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||||
rm.width = rm.width / 2 - 2;
|
rm.width = rm.width / 2 - 2;
|
||||||
//rm.enabled = AuthenticationHandler.isAuthenticated();
|
//rm.enabled = AuthenticationHandler.isAuthenticated();
|
||||||
event.buttonList.add(rm);
|
event.buttonList.add(rm);
|
||||||
|
|
||||||
replayCount = ReplayFileIO.getAllReplayFiles().size();
|
replayCount = ReplayFileIO.getAllReplayFiles().size();
|
||||||
|
|
||||||
GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2 * 24, "Replay Editor");
|
GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||||
re.width = re.width / 2 - 2;
|
re.width = re.width / 2 - 2;
|
||||||
re.enabled = VersionValidator.isValid && replayCount > 0;
|
re.enabled = VersionValidator.isValid && replayCount > 0;
|
||||||
event.buttonList.add(re);
|
event.buttonList.add(re);
|
||||||
|
|
||||||
editorButton = re;
|
editorButton = re;
|
||||||
|
|
||||||
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3 * 24, "Replay Center");
|
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||||
rc.enabled = true;
|
rc.enabled = true;
|
||||||
event.buttonList.add(rc);
|
event.buttonList.add(rc);
|
||||||
|
|
||||||
} else if(event.gui instanceof GuiOptions) {
|
} else if(event.gui instanceof GuiOptions) {
|
||||||
event.buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID,
|
event.buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID,
|
||||||
event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, "Replay Mod Settings..."));
|
event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, I18n.format("replaymod.gui.settings.title")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ public class GuiEventHandler {
|
|||||||
ReplayHandler.lastExit = System.currentTimeMillis();
|
ReplayHandler.lastExit = System.currentTimeMillis();
|
||||||
|
|
||||||
mc.theWorld.sendQuittingDisconnectingPacket();
|
mc.theWorld.sendQuittingDisconnectingPacket();
|
||||||
mc.loadWorld((WorldClient) null);
|
mc.loadWorld(null);
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
mc.displayGuiScreen(new GuiMainMenu());
|
||||||
|
|
||||||
ReplayGuiRegistry.show();
|
ReplayGuiRegistry.show();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import net.minecraft.client.gui.GuiChat;
|
|||||||
import net.minecraft.client.gui.ScaledResolution;
|
import net.minecraft.client.gui.ScaledResolution;
|
||||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
@@ -89,7 +90,7 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
mc.displayGuiScreen(null);
|
mc.displayGuiScreen(null);
|
||||||
}
|
}
|
||||||
ReplayHandler.setRealTimelineCursor(0);
|
ReplayHandler.setRealTimelineCursor(0);
|
||||||
speedSlider = new GuiReplaySpeedSlider(1, sliderX, sliderY, "Speed");
|
speedSlider = new GuiReplaySpeedSlider(1, sliderX, sliderY, I18n.format("replaymod.gui.speed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@@ -110,7 +111,7 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderRecordingIndicator(RenderGameOverlayEvent.Text event) {
|
public void renderRecordingIndicator(RenderGameOverlayEvent.Text event) {
|
||||||
if(!ReplayHandler.isInReplay() && ReplayMod.replaySettings.showRecordingIndicator() && ConnectionEventHandler.isRecording()) {
|
if(!ReplayHandler.isInReplay() && ReplayMod.replaySettings.showRecordingIndicator() && ConnectionEventHandler.isRecording()) {
|
||||||
this.drawString(mc.fontRendererObj, "RECORDING", 30, 18 - (mc.fontRendererObj.FONT_HEIGHT / 2), Color.WHITE.getRGB());
|
this.drawString(mc.fontRendererObj, I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (mc.fontRendererObj.FONT_HEIGHT / 2), Color.WHITE.getRGB());
|
||||||
mc.renderEngine.bindTexture(replay_gui);
|
mc.renderEngine.bindTexture(replay_gui);
|
||||||
GlStateManager.resetColor();
|
GlStateManager.resetColor();
|
||||||
GlStateManager.enableAlpha();
|
GlStateManager.enableAlpha();
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package eu.crushedpixel.replaymod.localization;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
|
import net.minecraft.client.resources.data.IMetadataSection;
|
||||||
|
import net.minecraft.client.resources.data.IMetadataSerializer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class LocalizedResourcePack implements IResourcePack {
|
||||||
|
|
||||||
|
private Map<String, String> availableLanguages = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getInputStream(ResourceLocation loc) {
|
||||||
|
if(!loc.getResourcePath().endsWith(".lang")) return null;
|
||||||
|
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
||||||
|
if(availableLanguages.containsKey(langcode)) return new ByteArrayInputStream(availableLanguages.get(langcode).getBytes(Charsets.UTF_8));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean resourceExists(ResourceLocation loc) {
|
||||||
|
if(!(loc.getResourcePath().endsWith(".lang"))) return false;
|
||||||
|
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
||||||
|
boolean downloaded = true;
|
||||||
|
try {
|
||||||
|
String lang = ReplayMod.apiClient.getTranslation(langcode);
|
||||||
|
availableLanguages.put(langcode, lang);
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
downloaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return downloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set getResourceDomains() {
|
||||||
|
return ImmutableSet.of("minecraft", "replaymod");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMetadataSection getPackMetadata(IMetadataSerializer p_135058_1_, String p_135058_2_) throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BufferedImage getPackImage() throws IOException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPackName() {
|
||||||
|
return "ReplayModLocalizationResourcePack";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
replaymod.title=Replay Mod
|
||||||
|
|
||||||
#All of the chat messages
|
#All of the chat messages
|
||||||
replaymod.chat.recordingstarted=Recording started
|
replaymod.chat.recordingstarted=Recording started
|
||||||
replaymod.chat.recordingfailed=Failed to start recording
|
replaymod.chat.recordingfailed=Failed to start recording
|
||||||
@@ -37,6 +39,15 @@ replaymod.gui.add=Add
|
|||||||
replaymod.gui.start=Start
|
replaymod.gui.start=Start
|
||||||
replaymod.gui.end=End
|
replaymod.gui.end=End
|
||||||
replaymod.gui.delete=Delete
|
replaymod.gui.delete=Delete
|
||||||
|
replaymod.gui.recording=Recording
|
||||||
|
replaymod.gui.speed=Speed
|
||||||
|
|
||||||
|
replaymod.gui.exit=Exit Replay
|
||||||
|
replaymod.gui.java=Java 1.7 or newer required
|
||||||
|
replaymod.gui.morereplays=At least one Replay required
|
||||||
|
|
||||||
|
replaymod.gui.loggedin=LOGGED IN
|
||||||
|
replaymod.gui.loggedout=LOGGED OUT
|
||||||
|
|
||||||
replaymod.gui.mainmenu=Main Menu
|
replaymod.gui.mainmenu=Main Menu
|
||||||
replaymod.gui.settings=Settings
|
replaymod.gui.settings=Settings
|
||||||
@@ -90,7 +101,7 @@ replaymod.gui.editor.modify.title=Modify Replay
|
|||||||
|
|
||||||
replaymod.gui.editor.trim.description=Removes the beginning and end of a Replay File, only keeping the Replay between the given timestamps
|
replaymod.gui.editor.trim.description=Removes the beginning and end of a Replay File, only keeping the Replay between the given timestamps
|
||||||
replaymod.gui.editor.connect.description=Connects multiple Replays in the specified order
|
replaymod.gui.editor.connect.description=Connects multiple Replays in the specified order
|
||||||
replaymod.gui.editor.modify.description
|
replaymod.gui.editor.modify.description=Provides several filters to modify Replay Files
|
||||||
|
|
||||||
#Spectate Player GUI
|
#Spectate Player GUI
|
||||||
replaymod.gui.spectate.title=Spectate Player
|
replaymod.gui.spectate.title=Spectate Player
|
||||||
|
|||||||
Reference in New Issue
Block a user