Example #1
0
  @Override
  protected void onDestroy() {
    final LocalizedStringSet stringSet = raceService.getLocalizedStringSet();
    player.sendMessage(
        Color.LIGHTBLUE,
        stringSet.format(player, "TrackEditor.EndEditingTrackMessage", track.getName()));

    for (MapIcon icon : mapIcons.values()) icon.destroy();
    mapIcons.clear();
  }
Example #2
0
  @Override
  protected void onInit() {

    eventManagerNode.registerHandler(
        PlayerUpdateEvent.class,
        HandlerPriority.NORMAL,
        Attentions.create().object(player),
        (e) -> {
          if (player.getUpdateCount() % 40 == 0) updateMapIcons();
        });

    final LocalizedStringSet stringSet = raceService.getLocalizedStringSet();
    player.sendMessage(
        Color.LIGHTBLUE,
        stringSet.format(player, "TrackEditor.StartEditingTrackMessage", track.getName()));
  }
Example #3
0
  public static WlListDialog create(
      Player player, EventManager eventManager, AbstractDialog parent, RaceServiceImpl service) {
    PlayerStringSet stringSet = service.getLocalizedStringSet().getStringSet(player);
    TrackManagerImpl trackManager = service.getTrackManager();

    return WlListDialog.create(player, eventManager)
        .parentDialog(parent)
        .caption(stringSet.get("Dialog.TrackListMainDialog.Caption"))
        .item(
            stringSet.get("Dialog.TrackListMainDialog.Nearby"),
            (i) -> {
              List<Track> tracks = trackManager.getAllTracks();
              new TrackListDialog(player, eventManager, i.getCurrentDialog(), service, tracks)
                  .show();
            })
        .item(
            stringSet.get("Dialog.TrackListMainDialog.MyFavorites"),
            (i) -> {
              List<Track> tracks = trackManager.getAllTracks();
              new TrackListDialog(player, eventManager, i.getCurrentDialog(), service, tracks)
                  .show();
            })
        .item(
            stringSet.get("Dialog.TrackListMainDialog.MyTracks"),
            (i) -> {
              List<Track> tracks = trackManager.searchTrackByAuthor(player.getName());
              new TrackListDialog(player, eventManager, i.getCurrentDialog(), service, tracks)
                  .show();
            })
        .item(
            stringSet.get("Dialog.TrackListMainDialog.SearchByAuthor"),
            (i) -> {
              String caption = stringSet.get("Dialog.TrackSearchByAuthorDialog.Caption");
              String message = stringSet.get("Dialog.TrackSearchByAuthorDialog.Text");
              WlInputDialog.create(player, eventManager)
                  .parentDialog(i.getCurrentDialog())
                  .caption(caption)
                  .message(message)
                  .onClickOk(
                      (d, text) -> {
                        player.playSound(1083);

                        List<Track> tracks = trackManager.searchTrackByAuthor(text);
                        new TrackListDialog(
                                player, eventManager, i.getCurrentDialog(), service, tracks)
                            .show();
                      })
                  .build()
                  .show();
            })
        .item(
            stringSet.get("Dialog.TrackListMainDialog.SearchByKeyword"),
            (i) -> {
              String caption = stringSet.get("Dialog.TrackSearchByKeywordDialog.Caption");
              String message = stringSet.get("Dialog.TrackSearchByKeywordDialog.Text");
              WlInputDialog.create(player, eventManager)
                  .parentDialog(i.getCurrentDialog())
                  .caption(caption)
                  .message(message)
                  .onClickOk(
                      (d, text) -> {
                        List<Track> tracks = trackManager.searchTrackByName(text);
                        new TrackListDialog(
                                player, eventManager, i.getCurrentDialog(), service, tracks)
                            .show();
                      })
                  .build()
                  .show();
            })
        .onClickOk((d, i) -> player.playSound(1083))
        .build();
  }