summaryrefslogtreecommitdiff
path: root/NET/worlds/console/LanguageManager.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/console/LanguageManager.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/console/LanguageManager.java')
-rw-r--r--NET/worlds/console/LanguageManager.java219
1 files changed, 219 insertions, 0 deletions
diff --git a/NET/worlds/console/LanguageManager.java b/NET/worlds/console/LanguageManager.java
new file mode 100644
index 0000000..fe6977d
--- /dev/null
+++ b/NET/worlds/console/LanguageManager.java
@@ -0,0 +1,219 @@
+/* */ package NET.worlds.console;
+/* */
+/* */ import NET.worlds.core.Std;
+/* */ import NET.worlds.network.ProgressDialog;
+/* */ import NET.worlds.network.URL;
+/* */ import java.io.FileOutputStream;
+/* */ import java.io.IOException;
+/* */ import java.io.InputStream;
+/* */ import java.io.PrintStream;
+/* */ import java.util.Enumeration;
+/* */ import java.util.Vector;
+/* */ import java.util.zip.ZipEntry;
+/* */ import java.util.zip.ZipFile;
+/* */
+/* */
+/* */
+/* */
+/* */ public class LanguageManager
+/* */ implements Runnable
+/* */ {
+/* */ private String m_Name;
+/* */ private String m_FinishName;
+/* */ private int m_fSize;
+/* */
+/* */ public static void handle(String name, int fSize, String finishName)
+/* */ {
+/* 27 */ LanguageManager lm = new LanguageManager(name, fSize, finishName);
+/* 28 */ Thread t = new Thread(lm);
+/* 29 */ t.setDaemon(true);
+/* 30 */ t.start();
+/* */ }
+/* */
+/* */
+/* */
+/* */ public LanguageManager(String name, int fSize, String finishName)
+/* */ {
+/* 37 */ this.m_Name = name;
+/* 38 */ this.m_fSize = fSize;
+/* 39 */ this.m_FinishName = finishName;
+/* */ }
+/* */
+/* */ public void run() {
+/* 43 */ String fName = this.m_Name.substring(this.m_Name.lastIndexOf('/') + 1,
+/* 44 */ this.m_Name.length());
+/* */
+/* 46 */ Console.println(Console.message("Downloading-update") + fName);
+/* */
+/* */
+/* */
+/* 50 */ Vector<String> names = new Vector();
+/* 51 */ names.addElement(fName);
+/* 52 */ Vector<URL> urls = new Vector();
+/* 53 */ urls.addElement(URL.make(this.m_Name));
+/* 54 */ int now = Std.getFastTime();
+/* */
+/* 56 */ ProgressDialog progD = new ProgressDialog(this.m_fSize);
+/* */ try
+/* */ {
+/* 59 */ System.out.println("ProgressDialog start, now = " + now);
+/* 60 */ System.out.println("fName = " + fName + ", name = " + this.m_Name);
+/* */
+/* */
+/* 63 */ if (!progD.loadFiles(names, urls)) {
+/* 64 */ System.out.println("Can't load " + fName);
+/* 65 */ return;
+/* */ }
+/* 67 */ now = Std.getFastTime();
+/* 68 */ System.out.println("ProgressDialog end, now = " + now);
+/* */ }
+/* */ catch (IOException e) {
+/* 71 */ System.out.println("Exception " + e.toString() + " loading file " +
+/* 72 */ fName);
+/* */ }
+/* */
+/* 75 */ finishDownload(this.m_FinishName);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public synchronized boolean finishDownload(String localName)
+/* */ {
+/* 98 */ String fType = localName.substring(localName.lastIndexOf('.'),
+/* 99 */ localName.length());
+/* */
+/* 101 */ System.out.println("Finished Downloading " + localName);
+/* 102 */ if (fType.equals(".EXE")) {
+/* 103 */ if (tryToRun(localName)) {
+/* 104 */ System.out.println(Console.message("Loading2") + localName);
+/* */ } else
+/* 106 */ Console.println(
+/* 107 */ Console.message("Loading2") + localName + " " + Console.message("failed"));
+/* 108 */ } else if (fType.equals(".zip"))
+/* */ {
+/* */
+/* */ try
+/* */ {
+/* */
+/* 114 */ langZip = new ZipFile(localName);
+/* */ } catch (IOException e) { ZipFile langZip;
+/* 116 */ System.out.println("Error opening language file " + localName);
+/* 117 */ notify();
+/* 118 */ return false;
+/* */ }
+/* */ ZipFile langZip;
+/* 121 */ System.out.println("Expanding language file.");
+/* */
+/* 123 */ Enumeration<? extends ZipEntry> enums = langZip.entries();
+/* 124 */ while (enums.hasMoreElements()) {
+/* 125 */ ZipEntry ze = (ZipEntry)enums.nextElement();
+/* 126 */ String filename = ze.getName();
+/* */
+/* 128 */ String langFile = filename;
+/* */
+/* 130 */ String[] validExtensions = { ".properties", ".jpg", ".bmp",
+/* 131 */ ".gif" };
+/* */
+/* 133 */ boolean validFile = false;
+/* 134 */ for (int idx = 0; idx < validExtensions.length; idx++) {
+/* 135 */ if (langFile.toString().endsWith(validExtensions[idx])) {
+/* 136 */ validFile = true;
+/* 137 */ break;
+/* */ }
+/* */ }
+/* */
+/* 141 */ if (validFile) {
+/* 142 */ CopyLangFile(langZip, ze, langFile);
+/* 143 */ System.out.println(langFile);
+/* */ }
+/* */ }
+/* */
+/* */ try
+/* */ {
+/* 149 */ langZip.close();
+/* */ }
+/* */ catch (IOException localIOException1) {}
+/* */ }
+/* 153 */ notify();
+/* */
+/* 155 */ new OkCancelDialog(Console.getFrame(), null, Console.message("Alert"),
+/* 156 */ null, Console.message("OK"), Console.message("Change-exit"),
+/* 157 */ true);
+/* */
+/* 159 */ return false;
+/* */ }
+/* */
+/* */ private void CopyLangFile(ZipFile langZip, ZipEntry ze, String langFile)
+/* */ {
+/* */ try
+/* */ {
+/* 166 */ is = langZip.getInputStream(ze);
+/* */ } catch (IOException e) {
+/* */ InputStream is;
+/* */ return;
+/* */ }
+/* */ InputStream is;
+/* */ try {
+/* 173 */ os = new FileOutputStream(langFile);
+/* */ } catch (IOException e) {
+/* */ try { FileOutputStream os;
+/* 176 */ is.close();
+/* */ }
+/* */ catch (IOException localIOException1) {}
+/* */
+/* */ return;
+/* */ }
+/* */ FileOutputStream os;
+/* 183 */ byte[] buffer = new byte['Ѐ'];
+/* */ try
+/* */ {
+/* */ for (;;) {
+/* 187 */ int bytesRead = is.read(buffer);
+/* 188 */ if (bytesRead == -1) {
+/* */ break;
+/* */ }
+/* 191 */ os.write(buffer, 0, bytesRead);
+/* */ }
+/* */ return;
+/* */ }
+/* */ catch (IOException localIOException2)
+/* */ {
+/* */ try
+/* */ {
+/* 199 */ is.close();
+/* 200 */ os.close();
+/* */ }
+/* */ catch (IOException localIOException3) {}
+/* */ }
+/* */ }
+/* */
+/* */ public static boolean tryToRun(String s) {
+/* */ try {
+/* 208 */ Runtime.getRuntime().exec(s);
+/* 209 */ return true;
+/* */ } catch (IOException e) {}
+/* 211 */ return false;
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\LanguageManager.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file