Пример #1
0
 private void createAvatar() {
   String[] currentPrefs = prefs.getPref(FPref.UI_AVATARS).split(",");
   if (index < currentPrefs.length) {
     setAvatarIndex(Integer.parseInt(currentPrefs[index]));
   } else {
     setAvatarIndex(AvatarSelector.getRandomAvatar(screen.getUsedAvatars()));
   }
   avatarLabel.setCommand(avatarCommand);
 }
Пример #2
0
  /** After view and model have been initialized, control can start. */
  public void initialize() {
    // Preloads skin components (using progress bar).
    FSkin.loadFull(true);

    display = FView.SINGLETON_INSTANCE.getLpnDocument();

    final ForgePreferences prefs = FModel.getPreferences();

    closeAction = CloseAction.valueOf(prefs.getPref(FPref.UI_CLOSE_ACTION));

    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Loading quest...");
    // Preload quest data if present
    final File dirQuests = new File(ForgeConstants.QUEST_SAVE_DIR);
    final String questname = FModel.getQuestPreferences().getPref(QPref.CURRENT_QUEST);
    final File data = new File(dirQuests.getPath(), questname);
    if (data.exists()) {
      FModel.getQuest().load(QuestDataIO.loadData(data));
    }

    // Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout
    final FFrame window = Singletons.getView().getFrame();
    window.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(final ComponentEvent e) {
            sizeChildren();
            window.updateNormalBounds();
            SLayoutIO.saveWindowLayout();
          }

          @Override
          public void componentMoved(final ComponentEvent e) {
            window.updateNormalBounds();
            SLayoutIO.saveWindowLayout();
          }
        });

    FView.SINGLETON_INSTANCE
        .getLpnDocument()
        .addMouseListener(SOverflowUtil.getHideOverflowListener());
    FView.SINGLETON_INSTANCE
        .getLpnDocument()
        .addComponentListener(SResizingUtil.getWindowResizeListener());

    setGlobalKeyboardHandler();

    FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Opening main window...");
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            Singletons.getView().initialize();
          }
        });
  }
Пример #3
0
 @Override
 public void focusLost(final FocusEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     final FTextField nField = (FTextField) source;
     final String newName = nField.getText().trim();
     if (index == 0
         && !StringUtils.isBlank(newName)
         && StringUtils.isAlphanumericSpace(newName)
         && prefs.getPref(FPref.PLAYER_NAME) != newName) {
       prefs.setPref(FPref.PLAYER_NAME, newName);
       prefs.save();
     }
     lobby.firePlayerChangeListener(index);
   }
 }
Пример #4
0
 private static JMenu getMenu_ThemeOptions() {
   final JMenu menu = new JMenu("Theme");
   JRadioButtonMenuItem menuItem;
   final ButtonGroup group = new ButtonGroup();
   final String currentSkin = prefs.getPref(FPref.UI_SKIN);
   for (final String skin : FSkin.getAllSkins()) {
     menuItem = new JRadioButtonMenuItem(skin);
     group.add(menuItem);
     if (skin.equals(currentSkin)) {
       menuItem.setSelected(true);
     }
     menuItem.setActionCommand(skin);
     menuItem.addActionListener(changeSkin);
     menu.add(menuItem);
   }
   return menu;
 }
Пример #5
0
 @Override
 public void handleEvent(FEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     FTextField nField = (FTextField) source;
     String newName = nField.getText().trim();
     if (index == 0
         && !StringUtils.isBlank(newName)
         && StringUtils.isAlphanumericSpace(newName)
         && prefs.getPref(FPref.PLAYER_NAME) != newName) {
       prefs.setPref(FPref.PLAYER_NAME, newName);
       prefs.save();
       if (allowNetworking) {
         screen.firePlayerChangeListener(index);
       }
     }
   }
 }
Пример #6
0
  public static void setPlayerName() {
    String oldPlayerName = prefs.getPref(FPref.PLAYER_NAME);
    String newPlayerName = null;

    if (StringUtils.isBlank(oldPlayerName)) {
      newPlayerName = getVerifiedPlayerName(getPlayerNameUsingFirstTimePrompt(), oldPlayerName);
    } else {
      newPlayerName =
          getVerifiedPlayerName(getPlayerNameUsingStandardPrompt(oldPlayerName), oldPlayerName);
    }

    prefs.setPref(FPref.PLAYER_NAME, newPlayerName);
    prefs.save();

    if (StringUtils.isBlank(oldPlayerName) && newPlayerName != "Human") {
      showThankYouPrompt(newPlayerName);
    }
  }
 private void setPlayerNameButtonText() {
   final FLabel btn = view.getBtnPlayerName();
   final String name = prefs.getPref(FPref.PLAYER_NAME);
   btn.setText(StringUtils.isBlank(name) ? "Human" : name);
 }