Beispiel #1
0
  public void updateScriptControls() {
    boolean idle = true, paused = false;
    final Bot bot = getCurrentBot();

    if (bot != null) {
      final Map<Integer, LoopTask> scriptMap = bot.getScriptHandler().getRunningScripts();
      if (scriptMap.size() > 0) {
        idle = false;
        paused = scriptMap.values().iterator().next().isPaused();
      } else {
        idle = true;
      }
    }

    menuBar.getMenuItem(Messages.RUNSCRIPT).setVisible(idle);
    menuBar.getMenuItem(Messages.STOPSCRIPT).setVisible(!idle);
    menuBar.getMenuItem(Messages.PAUSESCRIPT).setEnabled(!idle);
    menuBar.setPauseScript(paused);
    toolBar.setInputButtonVisible(!idle);
    menuBar.setEnabled(Messages.FORCEINPUT, !idle);

    if (idle) {
      toolBar.setOverrideInput(false);
      menuBar.setOverrideInput(false);
      toolBar.setInputState(Environment.INPUT_KEYBOARD | Environment.INPUT_MOUSE);
      toolBar.setScriptButton(BotToolBar.RUN_SCRIPT);
    } else {
      toolBar.setOverrideInput(bot.overrideInput);
      menuBar.setOverrideInput(bot.overrideInput);
      toolBar.setInputState(bot.inputFlags);
      toolBar.setScriptButton(paused ? BotToolBar.RESUME_SCRIPT : BotToolBar.PAUSE_SCRIPT);
    }

    toolBar.updateInputButton();
    repaint();
  }
Beispiel #2
0
 public Chrome() {
   init();
   pack();
   setTitle(null);
   setLocationRelativeTo(getOwner());
   setMinimumSize(new Dimension((int) (getSize().width * .8), (int) (getSize().height * .8)));
   setResizable(true);
   toolBar.runScriptButton.setEnabled(false);
   menuBar.getMenuItem(Messages.RUNSCRIPT).setEnabled(false);
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           JFrame.setDefaultLookAndFeelDecorated(true);
           JPopupMenu.setDefaultLightWeightPopupEnabled(false);
           ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
           SwingUtilities.updateComponentTreeUI(Chrome.this);
           addBot();
           updateScriptControls();
           ExecutorService pool = Executors.newCachedThreadPool();
           if (Configuration.Twitter.ENABLED) {
             pool.execute(new TwitterUpdates());
           }
           pool.execute(ScriptDeliveryNetwork.getInstance());
           pool.execute(ScriptUserList.getInstance());
           pool.shutdown();
           try {
             pool.awaitTermination(15, TimeUnit.SECONDS);
           } catch (final InterruptedException ignored) {
             log.warning("Unable to complete startup tasks");
           }
           menuBar.getMenuItem(Messages.RUNSCRIPT).setEnabled(true);
           toolBar.runScriptButton.setEnabled(true);
           setVisible(true);
           LoadScreen.quit();
           if (!Preferences.getInstance().hideAds) {
             new Thread(new SplashAd(Chrome.this)).start();
           }
           System.gc();
         }
       });
 }