Ejemplo n.º 1
0
 private static void main2(String[] args) {
   Config.cmdline(args);
   try {
     javabughack();
   } catch (InterruptedException e) {
     return;
   }
   setupres();
   MainFrame f = new MainFrame(null);
   if (Utils.getprefb("fullscreen", false)) f.setfs();
   f.mt.start();
   try {
     f.mt.join();
   } catch (InterruptedException e) {
     f.g.interrupt();
     return;
   }
   dumplist(Resource.remote().loadwaited(), Config.loadwaited);
   dumplist(Resource.remote().cached(), Config.allused);
   if (ResCache.global != null) {
     try {
       Writer w = new OutputStreamWriter(ResCache.global.store("tmp/allused"), "UTF-8");
       try {
         Resource.dumplist(Resource.remote().used(), w);
       } finally {
         w.close();
       }
     } catch (IOException e) {
     }
   }
   System.exit(0);
 }
Ejemplo n.º 2
0
 public static void setupres() {
   if (ResCache.global != null) Resource.setcache(ResCache.global);
   if (Config.resurl != null) Resource.addurl(Config.resurl);
   if (ResCache.global != null) {
     try {
       Resource.loadlist(Resource.remote(), ResCache.global.fetch("tmp/allused"), -10);
     } catch (IOException e) {
     }
   }
   if (!Config.nopreload) {
     try {
       InputStream pls;
       pls = Resource.class.getResourceAsStream("res-preload");
       if (pls != null) Resource.loadlist(Resource.remote(), pls, -5);
       pls = Resource.class.getResourceAsStream("res-bgload");
       if (pls != null) Resource.loadlist(Resource.remote(), pls, -10);
     } catch (IOException e) {
       throw (new Error(e));
     }
   }
 }
Ejemplo n.º 3
0
  public void uimsg(String msg, Object... args) {
    if (msg == "tabfocus") {
      setfocustab(((Integer) args[0] != 0));
    } else if (msg == "act") {
      canactivate = (Integer) args[0] != 0;
    } else if (msg == "cancel") {
      cancancel = (Integer) args[0] != 0;
    } else if (msg == "autofocus") {
      autofocus = (Integer) args[0] != 0;
    } else if (msg == "focus") {
      Widget w = ui.widgets.get((Integer) args[0]);
      if (w != null) {
        if (w.canfocus) setfocus(w);
      }
    } else if (msg == "curs") {
      if (args.length == 0) cursor = null;
      else cursor = Resource.remote().load((String) args[0], (Integer) args[1]);
    } else if (msg == "tip") {
      int a = 0;
      Object tt = args[a++];
      if (tt instanceof String) {
        tooltip = Text.render((String) tt);
      } else if (tt instanceof Integer) {
        final Indir<Resource> tres = ui.sess.getres((Integer) tt);
        tooltip =
            new Indir<Tex>() {
              Text t = null;

              public Tex get() {
                if (t == null) {
                  Resource.Pagina pag;
                  try {
                    pag = tres.get().layer(Resource.pagina);
                  } catch (Loading e) {
                    return (null);
                  }
                  t = RichText.render(pag.text, 300);
                }
                return (t.tex());
              }
            };
      }
    } else {
      System.err.println("Unhandled widget message: " + msg);
    }
  }
Ejemplo n.º 4
0
 public static Factory gettype2(String name) throws InterruptedException {
   if (name.indexOf('/') < 0) {
     synchronized (types) {
       return (types.get(name));
     }
   } else {
     int ver = -1, p;
     if ((p = name.indexOf(':')) > 0) {
       ver = Integer.parseInt(name.substring(p + 1));
       name = name.substring(0, p);
     }
     Indir<Resource> res = Resource.remote().load(name, ver);
     while (true) {
       try {
         return (res.get().getcode(Factory.class, true));
       } catch (Loading l) {
         l.waitfor();
       }
     }
   }
 }