public static EMapStartResources fromMapValue(int mapValue) { for (int i = 0; i < EMapStartResources.values().length; i++) { if (EMapStartResources.values()[i].value == mapValue) return EMapStartResources.values()[i]; } System.err.println("wrong value for 'EOriginalMapStartResources' " + Integer.toString(mapValue) + "!"); return EMapStartResources.HIGH_GOODS; }
@Override public String toString() { return Labels.getString("map-start-resources-" + startResources.name()); } }
List<MapDataObject> mapObjects = EMapStartResources.generateStackObjects(startResources); mapObjects.addAll(EMapStartResources.generateMovableObjects(startResources, playerId));
private void readMapInfo() throws MapLoadException { MapResourceInfo filePartOptional = findAndDecryptFilePartSafe(EOriginalMapFilePartType.MAP_INFO); // - file position int pos = filePartOptional.offset; // ---------------------------------- // - read mapType (single / multiplayer map?) int mapType = readBEIntFrom(pos); pos += 4; if (mapType == 1) { isSinglePlayerMap = true; } else if (mapType == 0) { isSinglePlayerMap = false; } else { throw new MapLoadException("wrong value for 'isSinglePlayerMap' " + Integer.toString(mapType) + " in mapfile!"); } // ---------------------------------- // - read Player count int playerCount = readBEIntFrom(pos); pos += 4; mapData.setPlayerCount(playerCount); // ---------------------------------- // - read start resources int startResourcesValue = readBEIntFrom(pos); this.startResources = EMapStartResources.fromMapValue(startResourcesValue); }
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(); }