@Override public String getMapName() { return gameName + "(" + mapLoader.getMapName() + ")"; }
/** * Order the maps */ protected void sortMaps() { Collections.sort(maps, (mapLoader1, mapLoader2) -> { int nameComp = mapLoader1.getMapName().compareTo(mapLoader2.getMapName()); if (nameComp != 0) { return nameComp; } else { return mapLoader1.toString().compareTo(mapLoader2.toString()); } }); }
/** * Checks if a map matches the search criteria * * @param m * Map * @param search * Criteria * @return true if yes, false if no */ private boolean matchesSearch(MapLoader m, String search) { if (m.getMapName().toLowerCase(Locale.ENGLISH).contains(search)) { return true; } if (m.getDescription().toLowerCase(Locale.ENGLISH).contains(search)) { return true; } return m.getMapId().toLowerCase(Locale.ENGLISH).contains(search); }
/** * Checks if a map matches the search criteria * * @param m * Map * @param search * Criteria * @return true if yes, false if no */ private boolean matchesSearch(MapLoader m, String search) { if (search.isEmpty()) { return true; } if (m.getMapName().toLowerCase(Locale.ENGLISH).contains(search)) { return true; } if (m.getDescription().toLowerCase(Locale.ENGLISH).contains(search)) { return true; } return m.getMapId().toLowerCase(Locale.ENGLISH).contains(search); }
public MapLoader getMapByName(String mapName) { ArrayList<MapLoader> maps = new ArrayList<>(); maps.addAll(getFreshMaps().getItems()); maps.addAll(getSavedMaps().getItems()); for (MapLoader curr : maps) { if (curr.getMapName().equals(mapName)) { return curr; } } return null; }
private void prepareUiFor(MapLoader mapLoader) { this.mapLoader = mapLoader; mapNameLabel.setText(mapLoader.getMapName()); mapImage.setIcon(new ImageIcon(JSettlersSwingUtil.createBufferedImageFrom(mapLoader))); peaceTimeComboBox.removeAllItems(); peaceTimeComboBox.addItem(EPeaceTime.WITHOUT); startResourcesComboBox.removeAllItems(); J8Arrays.stream(EMapStartResources.values()) .map(MapStartResourcesUIWrapper::new) .forEach(startResourcesComboBox::addItem); startResourcesComboBox.setSelectedIndex(EMapStartResources.HIGH_GOODS.value - 1); resetNumberOfPlayersComboBox(); buildPlayerSlots(); updateNumberOfPlayerSlots(); }
@Override public int compareTo(MapLoader other) { MapFileHeader myHeader = this.getFileHeader(); MapFileHeader otherHeader = other.getFileHeader(); if (myHeader.getType() == otherHeader.getType() && myHeader.getType() == MapType.SAVED_SINGLE) { return -this.getCreationDate().compareTo(other.getCreationDate()); // order by date descending } else { return this.getMapName().compareToIgnoreCase(other.getMapName()); // order by name ascending } }
private static void createReplayOfRemainingTasks(MapLoader newSavegame, ReplayStartInformation replayStartInformation, String newReplayFile, IGameClock gameClock) throws IOException { System.out.println("Creating new jsettlers.integration.replay file (" + newReplayFile + ")..."); ReplayStartInformation replayInfo = new ReplayStartInformation(0, newSavegame.getMapName(), newSavegame.getMapId(), replayStartInformation.getPlayerId(), replayStartInformation.getPlayerSettings() ); DataOutputStream dos = new DataOutputStream(ResourceManager.writeUserFile(newReplayFile)); replayInfo.serialize(dos); gameClock.saveRemainingTasks(dos); dos.close(); System.out.println("New jsettlers.integration.replay file successfully created!"); }
@Override public Component getListCellRendererComponent(JList<? extends MapLoader> list, MapLoader value, int index, boolean isSelected, boolean cellHasFocus) { lbName.setText(value.getMapName().trim()); String date = "???"; if (value.getCreationDate() != null) {
@Override public Component getListCellRendererComponent(JList<? extends MapLoader> list, MapLoader value, int index, boolean isSelected, boolean cellHasFocus) { mapNameLabel.setText(value.getMapName()); String date = "???"; if (value.getCreationDate() != null) {