예제 #1
0
 private void showAvailableSpells(MagicLearnView magicLearnView) {
   List<Spell> availableSpells =
       spellConfiguration.getAvailableSpellsInCircle(circleModel.getSelectedCircle());
   List<Spell> sortedSpells =
       new I18nedIdentificateSorter<Spell>().sortAscending(availableSpells, resources);
   magicLearnView.setAvailableMagic(sortedSpells);
 }
예제 #2
0
  private void addMagicLearnView(final SpellView view) {
    final MagicLearnView magicLearnView = view.addMagicLearnView(properties);
    MagicLearnPresenter learnPresenter = new MagicLearnPresenter(magicLearnView);
    learnPresenter.initPresentation(properties);
    learnPresenter.addChangeListener(
        new MagicViewListener() {
          @Override
          public void removeMagicRequested(Object[] removedSpells) {
            List<Spell> spellList = convertToList(removedSpells);
            spellConfiguration.removeSpells(spellList);
          }

          @Override
          public void addMagicRequested(Object[] addedSpells) {
            List<Spell> spellList = convertToList(addedSpells);
            spellConfiguration.addSpells(spellList);
          }
        });
    circleModel.addSelectionListener(
        newValue -> {
          showAvailableSpells(magicLearnView);
          updateCircleInView(newValue, view);
          learnPresenter.updateButtons();
        });
    spellConfiguration.addChangeListener(() -> refreshSpellListsInView(magicLearnView));
    refreshSpellListsInView(magicLearnView);
    updateCircleInView(circleModel.getSelectedCircle(), view);
    charmsModel.addCharmLearnListener(
        new CharmLearnAdapter() {
          @Override
          public void charmLearned(Charm charm) {
            learnPresenter.updateButtons();
          }

          @Override
          public void charmForgotten(Charm charm) {
            learnPresenter.updateButtons();
          }
        });
  }
예제 #3
0
 private void showLearnedSpells(MagicLearnView magicLearnView) {
   List<Spell> learnedSpells =
       spellConfiguration.getLearnedSpellsInCircles(circleModel.getCircles());
   magicLearnView.setLearnedMagic(learnedSpells);
 }