diff --git a/scripts/sql/script.sql b/scripts/sql/script.sql index 206f492..2629a00 100644 --- a/scripts/sql/script.sql +++ b/scripts/sql/script.sql @@ -80,7 +80,7 @@ INSERT INTO KF2DATABASE.MAPS(ID, CODE, OFFICIAL, URL_INFO, URL_PHOTO, DOWNLOADED ----------------------------------- -- PROFILES ----------------------------------- -INSERT INTO KF2DATABASE.PROFILES(ID, NAME, ID_LANGUAGE, ID_GAMETYPE, ID_MAP, ID_DIFFICULTY, ID_LENGTH, ID_MAXPLAYERS, SERVER_NAME, WEB_PORT, GAME_PORT, QUERY_PORT) VALUES(1000, 'Default', 1, 1000, 1000, 1000, 1000, 1006, 'Killing Floor 2 Server', 8080, 7777, 27015); +INSERT INTO KF2DATABASE.PROFILES(ID, NAME, ID_LANGUAGE, ID_GAMETYPE, ID_MAP, ID_DIFFICULTY, ID_LENGTH, ID_MAXPLAYERS, SERVER_NAME, WEB_PORT, GAME_PORT, QUERY_PORT, WEB_PAGE) VALUES(1000, 'Default', 1, 1000, 1000, 1000, 1000, 1006, 'Killing Floor 2 Server', 8080, 7777, 27015, true); ----------------------------------- -- PROFILES_MAPS diff --git a/src/main/java/daos/MapDao.java b/src/main/java/daos/MapDao.java index 10dd3d0..50824df 100644 --- a/src/main/java/daos/MapDao.java +++ b/src/main/java/daos/MapDao.java @@ -25,8 +25,8 @@ public static MapDao getInstance() { return instance; } - public List listNotDownloadedMapsAndMods() throws SQLException { - String query="select m from entities.Map m where m.downloaded=false"; + public List listAllMaps() throws SQLException { + String query="select m from entities.Map m"; return list(query, null); } diff --git a/src/main/java/dtos/ProfileDto.java b/src/main/java/dtos/ProfileDto.java index b0dfd16..958609f 100644 --- a/src/main/java/dtos/ProfileDto.java +++ b/src/main/java/dtos/ProfileDto.java @@ -28,10 +28,11 @@ public class ProfileDto { private final String welcomeMessage; private final String customParameters; private final ObservableList mapList; + private final Boolean takeover; public ProfileDto(String name, SelectDto language, GameTypeDto gametype, MapDto map, SelectDto difficulty, SelectDto length, SelectDto maxPlayers, String serverName, String serverPassword, Boolean webPage, String webPassword, Integer webPort, Integer gamePort, Integer queryPort, - String yourClan, String yourWebLink, String urlImageServer, String welcomeMessage, String customParameters, ObservableList mapList) { + String yourClan, String yourWebLink, String urlImageServer, String welcomeMessage, String customParameters, ObservableList mapList, Boolean takeover) { super(); this.name = new SimpleStringProperty(name); this.language = language; @@ -53,6 +54,7 @@ public ProfileDto(String name, SelectDto language, GameTypeDto gametype, MapDto this.welcomeMessage = welcomeMessage; this.customParameters = customParameters; this.mapList = mapList; + this.takeover = takeover; } public StringProperty getNameProperty() { @@ -139,6 +141,10 @@ public ObservableList getMapList() { return mapList; } + public Boolean getTakeover() { + return takeover; + } + @Override public String toString() { return getName(); diff --git a/src/main/java/dtos/factories/ProfileDtoFactory.java b/src/main/java/dtos/factories/ProfileDtoFactory.java index 2df95b2..7a0ce94 100644 --- a/src/main/java/dtos/factories/ProfileDtoFactory.java +++ b/src/main/java/dtos/factories/ProfileDtoFactory.java @@ -47,7 +47,8 @@ public ProfileDto newDto(Profile profile) { profile.getUrlImageServer(), profile.getWelcomeMessage(), profile.getCustomParameters(), - mapDtoFactory.newDtos(profile.getMapList())); + mapDtoFactory.newDtos(profile.getMapList()), + profile.getTakeover()); } public ObservableList newDtos(List profiles) { diff --git a/src/main/java/entities/Profile.java b/src/main/java/entities/Profile.java index d4cc51f..eaee175 100644 --- a/src/main/java/entities/Profile.java +++ b/src/main/java/entities/Profile.java @@ -52,6 +52,9 @@ public class Profile extends CommonEntity { @Column(name="WEB_PASSWORD", length=100) private String webPassword; + @Column(name="TAKEOVER") + private Boolean takeover; + @Column(name="WEB_PORT") private Integer webPort; @@ -90,7 +93,7 @@ public Profile() { } public Profile(String name, Language language, GameType gametype, Map map, Difficulty difficulty, Length length, MaxPlayers maxPlayers, - String serverName, Integer webPort, Integer gamePort, Integer queryPort, List mapList) { + String serverName, Integer webPort, Integer gamePort, Integer queryPort, List mapList, Boolean webPage) { super(); this.name = name; this.language = language; @@ -104,11 +107,12 @@ public Profile(String name, Language language, GameType gametype, Map map, Diffi this.gamePort = gamePort; this.queryPort = queryPort; this.mapList = mapList; + this.webPage = webPage; } public Profile(String name, Language language, GameType gametype, Map map, Difficulty difficulty, Length length, MaxPlayers maxPlayers, String serverName, String serverPassword, Boolean webPage, String webPassword, Integer webPort, Integer gamePort, Integer queryPort, - String yourClan, String yourWebLink, String urlImageServer, String welcomeMessage, String customParameters, List mapList) { + String yourClan, String yourWebLink, String urlImageServer, String welcomeMessage, String customParameters, List mapList, Boolean takeover) { super(); this.name = name; this.language = language; @@ -130,6 +134,7 @@ public Profile(String name, Language language, GameType gametype, Map map, Diffi this.welcomeMessage = welcomeMessage; this.customParameters = customParameters; this.mapList = mapList; + this.takeover = takeover; } @Override @@ -301,4 +306,12 @@ public List getMapList() { public void setMapList(List mapList) { this.mapList = mapList; } + + public Boolean getTakeover() { + return takeover; + } + + public void setTakeover(Boolean takeover) { + this.takeover = takeover; + } } diff --git a/src/main/java/pojos/kf2factory/Kf2Common.java b/src/main/java/pojos/kf2factory/Kf2Common.java index 45ad648..d049a35 100644 --- a/src/main/java/pojos/kf2factory/Kf2Common.java +++ b/src/main/java/pojos/kf2factory/Kf2Common.java @@ -202,14 +202,22 @@ protected void replaceInFileKfEngineIni(String installationFolder, Profile profi pw.println("DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload"); } } - if (StringUtils.isBlank(line) || (!line.contains("[OnlineSubsystemSteamworks.KFWorkshopSteamworks]") && - !line.contains("ServerSubscribedWorkshopItems="))) { - pw.println(line); + if (StringUtils.isNotBlank(line) && line.contains("bUsedForTakeover=")) { + pw.println("bUsedForTakeover=" + (profile.getTakeover()!=null?profile.getTakeover():"FALSE")); + } else { + if (StringUtils.isBlank(line) || (!line.contains("[OnlineSubsystemSteamworks.KFWorkshopSteamworks]") && + !line.contains("ServerSubscribedWorkshopItems="))) { + pw.println(line); + } } } else { - if (StringUtils.isBlank(line) || (!line.contains("DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload") && - !line.contains("[OnlineSubsystemSteamworks.KFWorkshopSteamworks]") && !line.contains("ServerSubscribedWorkshopItems="))) { - pw.println(line); + if (StringUtils.isNotBlank(line) && line.contains("bUsedForTakeover=")) { + pw.println("bUsedForTakeover=" + (profile.getTakeover()!=null?profile.getTakeover():"FALSE")); + } else { + if (StringUtils.isBlank(line) || (!line.contains("DownloadManagers=OnlineSubsystemSteamworks.SteamWorkshopDownload") && + !line.contains("[OnlineSubsystemSteamworks.KFWorkshopSteamworks]") && !line.contains("ServerSubscribedWorkshopItems="))) { + pw.println(line); + } } } } diff --git a/src/main/java/pojos/listener/TimeListener.java b/src/main/java/pojos/listener/TimeListener.java index 07c3be2..8d960ed 100644 --- a/src/main/java/pojos/listener/TimeListener.java +++ b/src/main/java/pojos/listener/TimeListener.java @@ -30,11 +30,11 @@ public TimeListener() { public void run() { logger.info("Starting the process of checking downloaded custom maps and mods."); try { - List notDownloadedMapList = databaseService.listNotDownloadedMapsAndMods(); - if (notDownloadedMapList != null && !notDownloadedMapList.isEmpty()) { + List mapList = databaseService.listAllMaps(); + if (mapList != null && !mapList.isEmpty()) { PropertyService propertyService = new PropertyServiceImpl(); String installationFolder = propertyService.getPropertyValue("properties/config.properties", "prop.config.installationFolder"); - for (Map map : notDownloadedMapList) { + for (Map map : mapList) { try { List kfmFilesPath = Files.walk(Paths.get(installationFolder + "/KFGame/Cache/" + map.getIdWorkShop())) .filter(Files::isRegularFile) diff --git a/src/main/java/services/DatabaseService.java b/src/main/java/services/DatabaseService.java index 145737e..06538a1 100644 --- a/src/main/java/services/DatabaseService.java +++ b/src/main/java/services/DatabaseService.java @@ -7,6 +7,6 @@ import java.util.List; public interface DatabaseService { - List listNotDownloadedMapsAndMods() throws SQLException; + List listAllMaps() throws SQLException; boolean updateMap(Map map) throws SQLException; } diff --git a/src/main/java/services/DatabaseServiceImpl.java b/src/main/java/services/DatabaseServiceImpl.java index f5255ca..e5c328e 100644 --- a/src/main/java/services/DatabaseServiceImpl.java +++ b/src/main/java/services/DatabaseServiceImpl.java @@ -1,13 +1,10 @@ package services; import daos.MapDao; -import daos.ProfileDao; import entities.Map; -import entities.Profile; import java.sql.SQLException; import java.util.List; -import java.util.Optional; public class DatabaseServiceImpl implements DatabaseService { @@ -16,8 +13,8 @@ public DatabaseServiceImpl() { } @Override - public List listNotDownloadedMapsAndMods() throws SQLException { - return MapDao.getInstance().listNotDownloadedMapsAndMods(); + public List listAllMaps() throws SQLException { + return MapDao.getInstance().listAllMaps(); } @Override diff --git a/src/main/java/start/MainApplication.java b/src/main/java/start/MainApplication.java index 075e0ed..a6ca162 100644 --- a/src/main/java/start/MainApplication.java +++ b/src/main/java/start/MainApplication.java @@ -40,7 +40,8 @@ public void start(Stage primaryStage) throws Exception { mainContent.load(); primaryStage.getIcons().add(new Image(getClass().getClassLoader().getResourceAsStream("images/logo.png"))); String applicationTitle = propertyService.getPropertyValue("properties/config.properties", "prop.config.applicationTitle"); - primaryStage.setTitle(applicationTitle); + String applicationVersion = propertyService.getPropertyValue("properties/config.properties", "prop.config.applicationVersion"); + primaryStage.setTitle(applicationTitle + " " + applicationVersion); primaryStage.setScene(scene); primaryStage.setMinWidth(1280); primaryStage.setMinHeight(800); diff --git a/src/main/java/stories/console/ConsoleController.java b/src/main/java/stories/console/ConsoleController.java new file mode 100644 index 0000000..4283046 --- /dev/null +++ b/src/main/java/stories/console/ConsoleController.java @@ -0,0 +1,24 @@ +package stories.console; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.TextArea; +import org.apache.commons.lang3.StringUtils; +import pojos.session.Session; + +import java.net.URL; +import java.util.ResourceBundle; + +public class ConsoleController implements Initializable { + + @FXML private TextArea console; + + public ConsoleController() { + super(); + } + + @Override + public void initialize(URL location, ResourceBundle resources) { + console.setText(StringUtils.isNotBlank(Session.getInstance().getConsole())? Session.getInstance().getConsole(): ""); + } +} diff --git a/src/main/java/stories/maincontent/MainContentController.java b/src/main/java/stories/maincontent/MainContentController.java index 8f0b633..a969304 100644 --- a/src/main/java/stories/maincontent/MainContentController.java +++ b/src/main/java/stories/maincontent/MainContentController.java @@ -9,26 +9,36 @@ import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.geometry.HPos; +import javafx.geometry.Pos; +import javafx.geometry.VPos; +import javafx.scene.Cursor; import javafx.scene.control.*; +import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.GridPane; import javafx.scene.web.WebView; +import javafx.util.Callback; import javafx.util.Duration; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import pojos.kf2factory.Kf2Common; +import pojos.kf2factory.Kf2Factory; import pojos.session.Session; import services.PropertyService; import services.PropertyServiceImpl; import stories.template.TemplateController; import utils.Utils; +import java.io.InputStream; import java.net.URL; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.ResourceBundle; +import java.util.*; import java.util.stream.Collectors; public class MainContentController implements Initializable { @@ -37,6 +47,7 @@ public class MainContentController implements Initializable { private final MainContentFacade facade; private final PropertyService propertyService; private String previousSelectedLanguageCode; + private String installationFolder; @FXML private ComboBox profileSelect; @FXML private ComboBox languageSelect; @@ -55,9 +66,8 @@ public class MainContentController implements Initializable { @FXML private TextField yourWebLink; @FXML private TextField urlImageServer; @FXML private TextArea welcomeMessage; - @FXML private TextField customParameters; + @FXML private TextArea customParameters; @FXML private CheckBox webPage; - @FXML private TextArea console; @FXML private WebView imageWebView; @FXML private Label profileLabel; @FXML private Label languageLabel; @@ -75,7 +85,6 @@ public class MainContentController implements Initializable { @FXML private Label urlImageLabel; @FXML private Label welcomeLabel; @FXML private Label customParametersLabel; - @FXML private Label consoleLabel; @FXML private Button runServer; @FXML private Button joinServer; @FXML private ImageView profileImg; @@ -95,7 +104,6 @@ public class MainContentController implements Initializable { @FXML private ImageView clanImg; @FXML private ImageView webLinkImg; @FXML private ImageView customParametersImg; - @FXML private ImageView consoleImg; @FXML private ImageView thumbnailImg; @FXML private ImageView urlImageServerImg; @FXML private ImageView welcomeImg; @@ -112,6 +120,7 @@ public MainContentController() { public void initialize(URL location, ResourceBundle resources) { try { + installationFolder = propertyService.getPropertyValue("properties/config.properties", "prop.config.installationFolder"); ObservableList profileOptions = facade.listAllProfiles(); profileSelect.setItems(profileOptions); if (!profileOptions.isEmpty()) { @@ -126,7 +135,6 @@ public void initialize(URL location, ResourceBundle resources) { difficultySelect.setItems(facade.listAllDifficulties()); lengthSelect.setItems(facade.listAllLengths()); maxPlayersSelect.setItems(facade.listAllPlayers()); - console.setText(StringUtils.isNotBlank(Session.getInstance().getConsole())? Session.getInstance().getConsole(): ""); if (profileSelect.getValue() != null) { profileOnAction(); @@ -142,6 +150,120 @@ public void initialize(URL location, ResourceBundle resources) { Utils.errorDialog(e.getMessage(), e); } + mapSelect.setCellFactory(new Callback, ListCell>() { + @Override + public ListCell call(ListView p) { + ListCell listCell = new ListCell() { + + private GridPane createMapGridPane(MapDto map) { + Label mapNameLabel = new Label(map.getKey()); + mapNameLabel.setStyle("-fx-padding: 5;"); + Label mapType; + String languageCode = languageSelect.getValue().getKey(); + String officialText; + String customText; + try { + officialText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.label.official"); + customText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.label.custom"); + } catch (Exception e) { + officialText = "OFFICIAL"; + customText = "CUSTOM"; + } + if (map.isOfficial()) { + mapType = new Label(officialText); + mapType.setStyle("-fx-text-fill: plum; -fx-padding: 5;"); + } else { + mapType = new Label(customText); + mapType.setStyle("-fx-text-fill: gold; -fx-padding: 5;"); + } + Image image; + if (facade.isCorrectInstallationFolder(installationFolder) && StringUtils.isNotBlank(map.getUrlPhoto())) { + image = new Image("file:" + installationFolder + "/" + map.getUrlPhoto()); + } else { + InputStream inputStream = getClass().getClassLoader().getResourceAsStream("images/no-photo.png"); + image = new Image(inputStream); + } + ImageView mapPreview = new ImageView(image); + mapPreview.setPreserveRatio(false); + mapPreview.setFitWidth(128); + mapPreview.setFitHeight(64); + GridPane gridpane = new GridPane(); + gridpane.add(mapPreview, 1, 1); + gridpane.add(new Label(), 2, 1); + gridpane.add(mapNameLabel, 2, 2); + gridpane.add(mapType, 2, 3); + GridPane.setRowSpan(mapPreview, 3); + return gridpane; + } + + @Override + protected void updateItem(MapDto map, boolean empty) { + super.updateItem(map, empty); + if (map != null) { + setGraphic(createMapGridPane(map)); + setContentDisplay(ContentDisplay.GRAPHIC_ONLY); + } + } + }; + return listCell; + } + }); + + mapSelect.setButtonCell(new ListCell() { + private GridPane createMapGridPane(MapDto map) { + Label mapNameLabel = new Label(map.getKey()); + mapNameLabel.setStyle("-fx-font-weight: bold;"); + Image image; + if (facade.isCorrectInstallationFolder(installationFolder) && StringUtils.isNotBlank(map.getUrlPhoto())) { + image = new Image("file:" + installationFolder + "/" + map.getUrlPhoto()); + } else { + InputStream inputStream = getClass().getClassLoader().getResourceAsStream("images/no-photo.png"); + image = new Image(inputStream); + } + ImageView mapPreview = new ImageView(image); + mapPreview.setPreserveRatio(false); + mapPreview.setFitWidth(256); + mapPreview.setFitHeight(128); + Label mapType; + String languageCode = languageSelect.getValue().getKey(); + String officialText; + String customText; + try { + officialText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.label.official"); + customText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.label.custom"); + } catch (Exception e) { + officialText = "OFFICIAL"; + customText = "CUSTOM"; + } + if (map.isOfficial()) { + mapType = new Label(officialText); + mapType.setStyle("-fx-text-fill: plum; -fx-padding: 3; -fx-border-color: plum; -fx-border-radius: 5;"); + } else { + mapType = new Label(customText); + mapType.setStyle("-fx-text-fill: gold; -fx-padding: 3; -fx-border-color: gold; -fx-border-radius: 5;"); + } + GridPane gridpane = new GridPane(); + gridpane.add(mapPreview, 1, 1); + gridpane.add(mapType, 1, 2); + gridpane.add(mapNameLabel, 2, 2); + GridPane.setColumnSpan(mapPreview, 2); + GridPane.setHalignment(mapNameLabel, HPos.RIGHT); + gridpane.setAlignment(Pos.CENTER); + gridpane.setHgap(15); + gridpane.setVgap(5); + return gridpane; + } + + @Override + protected void updateItem(MapDto map, boolean empty) { + super.updateItem(map, empty); + if (map != null) { + setGraphic(createMapGridPane(map)); + setContentDisplay(ContentDisplay.GRAPHIC_ONLY); + } + } + }); + serverName.focusedProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue arg0, Boolean oldPropertyValue, Boolean newPropertyValue) { @@ -545,10 +667,6 @@ private void loadLanguageTexts(String languageCode) throws Exception { customParametersLabel.setText(customParametersLabelText); loadTooltip(languageCode, "prop.tooltip.customParameters", customParametersImg, customParametersLabel, customParameters); - String consoleLabelText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties","prop.label.console"); - consoleLabel.setText(consoleLabelText); - loadTooltip(languageCode, "prop.tooltip.console", consoleImg, consoleLabel, console); - String runServerText = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties","prop.label.runServer"); runServer.setText(runServerText); runServer.setTooltip(new Tooltip(propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.tooltip.runServer"))); @@ -580,8 +698,11 @@ private void loadActualProfile(ProfileDto profile) { List mapList = new ArrayList(officialMaps); mapList.addAll(downloadedCustomMaps); mapSelect.setItems(FXCollections.observableArrayList(mapList)); + Optional selectedMapOpt = mapList.stream().filter(m -> m.getKey().equalsIgnoreCase(profile.getMap().getKey())).findFirst(); + if (selectedMapOpt.isPresent()) { + mapSelect.getSelectionModel().select(mapList.indexOf(selectedMapOpt.get())); + } - mapSelect.setValue(profile.getMap()); difficultySelect.setValue(profile.getDifficulty()); difficultySelect.setDisable(gameTypeSelect.getValue() != null ? !gameTypeSelect.getValue().isDifficultyEnabled(): false); lengthSelect.setValue(profile.getLength()); @@ -601,6 +722,7 @@ private void loadActualProfile(ProfileDto profile) { welcomeMessage.setText(profile.getWelcomeMessage()); customParameters.setText(profile.getCustomParameters()); webPage.setSelected(profile.getWebPage() != null ? profile.getWebPage(): false); + takeover.setSelected(profile.getTakeover() != null ? profile.getTakeover(): false); try { if (StringUtils.isNotEmpty(urlImageServer.getText())) { imageWebView.getEngine().load(urlImageServer.getText()); @@ -809,6 +931,27 @@ private void webPageOnAction() { } } + @FXML + private void takeoverOnAction() { + try { + if (profileSelect.getValue() != null) { + String profileName = profileSelect.getValue().getName(); + if (!facade.updateProfileSetTakeover(profileName, takeover.isSelected())) { + logger.warn("The takeover value could not be saved!: " + takeover.isSelected()); + String headerText = propertyService.getPropertyValue("properties/languages/" + languageSelect.getValue().getKey() + ".properties", + "prop.message.profileNotUpdated"); + String contentText = propertyService.getPropertyValue("properties/languages/" + languageSelect.getValue().getKey() + ".properties", + "prop.message.takeoverNotSaved"); + Utils.warningDialog(headerText, contentText); + } + } + } catch (Exception e) { + String headerText = "The takeover value could not be saved!"; + logger.error(headerText, e); + Utils.errorDialog(headerText, e); + } + } + @FXML private void runServerOnAction() { try { @@ -828,12 +971,10 @@ private void runServerOnAction() { selectedProfileNameList = facade.selectProfiles(message, profileSelect.getValue().getName()); } - StringBuffer commands = new StringBuffer(console.getText()); for (String profileName: selectedProfileNameList) { - commands.append(facade.runServer(profileName)).append("\n"); + Session.getInstance().setConsole((StringUtils.isNotBlank(Session.getInstance().getConsole())? Session.getInstance().getConsole() + "\n\n" : "") + + "< " + new Date() + " - Run Server >\n" + facade.runServer(profileName)); } - console.setText(StringUtils.isNotBlank(commands.toString())? commands.toString(): ""); - Session.getInstance().setConsole(console.getText()); } catch (Exception e) { logger.error(e.getMessage(), e); Utils.errorDialog(e.getMessage(), e); @@ -859,11 +1000,8 @@ private void joinServerOnAction() { selectedProfileName = facade.selectProfile(message, profileSelect.getValue().getName()); } if (StringUtils.isNotBlank(selectedProfileName)) { - StringBuffer commands = new StringBuffer(facade.joinServer(selectedProfileName)); - if (StringUtils.isNotBlank(commands)) { - commands.append("\n"); - } - console.setText(StringUtils.isNotBlank(console.getText() + commands.toString())? console.getText() + commands.toString(): ""); + Session.getInstance().setConsole((StringUtils.isNotBlank(Session.getInstance().getConsole())? Session.getInstance().getConsole() + "\n\n": "") + + "< " + new Date() + " - Join Server >\n" + facade.joinServer(selectedProfileName)); } } catch (Exception e) { logger.error(e.getMessage(), e); diff --git a/src/main/java/stories/maincontent/MainContentFacade.java b/src/main/java/stories/maincontent/MainContentFacade.java index c977379..b37446a 100644 --- a/src/main/java/stories/maincontent/MainContentFacade.java +++ b/src/main/java/stories/maincontent/MainContentFacade.java @@ -42,4 +42,6 @@ public interface MainContentFacade { ProfileDto getLastSelectedProfile() throws Exception; List selectProfiles(String message, String actualProfileName) throws SQLException; String selectProfile(String message, String actualProfileName) throws SQLException; + boolean isCorrectInstallationFolder(String installationFolder); + boolean updateProfileSetTakeover(String profileName, boolean isSelected) throws SQLException; } diff --git a/src/main/java/stories/maincontent/MainContentFacadeImpl.java b/src/main/java/stories/maincontent/MainContentFacadeImpl.java index d211dbc..cf03e45 100644 --- a/src/main/java/stories/maincontent/MainContentFacadeImpl.java +++ b/src/main/java/stories/maincontent/MainContentFacadeImpl.java @@ -3,6 +3,7 @@ import daos.*; import dtos.GameTypeDto; import dtos.ProfileDto; +import org.apache.commons.lang3.StringUtils; import pojos.ProfileToDisplay; import dtos.SelectDto; import dtos.factories.*; @@ -15,6 +16,7 @@ import services.PropertyServiceImpl; import utils.Utils; +import java.io.File; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; @@ -371,4 +373,27 @@ public String selectProfile(String message, String actualProfileName) throws SQL } return null; } + + @Override + public boolean isCorrectInstallationFolder(String installationFolder) { + if (StringUtils.isNotBlank(installationFolder)) { + File windowsExecutable = new File(installationFolder + "/Binaries/Win64/KFServer.exe"); + File linuxExecutable = new File(installationFolder + "/Binaries/Win64/KFGameSteamServer.bin.x86_64"); + if (windowsExecutable.exists() && linuxExecutable.exists()) { + return true; + } + } + return false; + } + + @Override + public boolean updateProfileSetTakeover(String profileName, boolean isSelected) throws SQLException { + Optional profileOpt = ProfileDao.getInstance().findByName(profileName); + if (profileOpt.isPresent()) { + Profile profile = profileOpt.get(); + profile.setTakeover(isSelected); + return ProfileDao.getInstance().update(profile); + } + return false; + } } diff --git a/src/main/java/stories/mapsedition/MapsEditionController.java b/src/main/java/stories/mapsedition/MapsEditionController.java index 3c0b1c8..417d09c 100644 --- a/src/main/java/stories/mapsedition/MapsEditionController.java +++ b/src/main/java/stories/mapsedition/MapsEditionController.java @@ -194,8 +194,9 @@ public void handle(MouseEvent event) { GridPane.setColumnSpan(mapPreview, 2); gridpane.add(new CheckBox(), 1, 2); gridpane.add(mapNameLabel, 2, 2); + mapNameLabel.setMinHeight(20); mapNameLabel.setMaxWidth(mapPreview.getFitWidth() - 25); - mapNameLabel.setAlignment(Pos.CENTER); + mapNameLabel.setAlignment(Pos.BOTTOM_CENTER); int rowIndex = 3; if (!map.isDownloaded()) { diff --git a/src/main/java/stories/profilesedition/ProfilesEditionFacadeImpl.java b/src/main/java/stories/profilesedition/ProfilesEditionFacadeImpl.java index 16a6a87..c6e193b 100644 --- a/src/main/java/stories/profilesedition/ProfilesEditionFacadeImpl.java +++ b/src/main/java/stories/profilesedition/ProfilesEditionFacadeImpl.java @@ -73,7 +73,8 @@ public ProfileDto createNewProfile(String profileName) throws Exception { Integer.parseInt(defaultWebPort), Integer.parseInt(defaultGamePort), Integer.parseInt(defaultQueryPort), - officialMaps + officialMaps, + true ); ProfileDao.getInstance().insert(newProfile); return profileDtoFactory.newDto(newProfile); @@ -152,7 +153,8 @@ public ProfileDto cloneSelectedProfile(String profileName, String newProfileName profileToBeClonedOpt.get().getUrlImageServer(), profileToBeClonedOpt.get().getWelcomeMessage(), profileToBeClonedOpt.get().getCustomParameters(), - new ArrayList(profileToBeClonedOpt.get().getMapList()) + new ArrayList(profileToBeClonedOpt.get().getMapList()), + profileToBeClonedOpt.get().getTakeover() ); ProfileDao.getInstance().insert(newProfile); return profileDtoFactory.newDto(newProfile); @@ -200,6 +202,8 @@ public void exportProfilesToFile(List profilesToExportDto, Fil properties.setProperty("exported.profile" + profileIndex + ".welcomeMessage", StringUtils.isNotBlank(profile.getWelcomeMessage())? profile.getWelcomeMessage(): ""); properties.setProperty("exported.profile" + profileIndex + ".customParameters", StringUtils.isNotBlank(profile.getCustomParameters())? profile.getCustomParameters(): ""); properties.setProperty("exported.profile" + profileIndex + ".mapListSize", profile.getMapList()!=null? String.valueOf(profile.getMapList().size()): "0"); + properties.setProperty("exported.profile" + profileIndex + ".takeover", profile.getTakeover()!=null? String.valueOf(profile.getTakeover()): "false"); + if (profile.getMapList() != null && !profile.getMapList().isEmpty()) { int mapIndex = 1; for (Map map: profile.getMapList()) { @@ -500,7 +504,8 @@ private Profile getProfileFromFile(int profileIndex, Properties properties) { properties.getProperty("exported.profile" + profileIndex + ".urlImageServer"), properties.getProperty("exported.profile" + profileIndex + ".welcomeMessage"), properties.getProperty("exported.profile" + profileIndex + ".customParameters"), - new ArrayList() + new ArrayList(), + Boolean.parseBoolean(properties.getProperty("exported.profile" + profileIndex + ".takeover")) ); } catch (SQLException e) { logger.error("Error getting the profile " + profileName + " from file", e); diff --git a/src/main/java/stories/template/TemplateController.java b/src/main/java/stories/template/TemplateController.java index f7ac8da..dfb1c28 100644 --- a/src/main/java/stories/template/TemplateController.java +++ b/src/main/java/stories/template/TemplateController.java @@ -28,9 +28,10 @@ public class TemplateController implements Initializable { private String languageCode; @FXML private Menu mainPage; - @FXML private Menu installUpdateServer; @FXML private Menu webAdmin; @FXML private Menu maps; + @FXML private Menu console; + @FXML private Menu installUpdateServer; @FXML private Menu configuration; @FXML private Menu help; @FXML private MenuItem profiles; @@ -56,15 +57,18 @@ public void initialize(URL location, ResourceBundle resources) { String mainPageTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.mainPage"); mainPage.setGraphic(getLabelWithHandler(mainPageTitle, "/views/mainContent.fxml")); - String installUpdateTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.installUpdateServer"); - installUpdateServer.setGraphic(getLabelWithHandler(installUpdateTitle, "/views/installUpdateServer.fxml")); - String webAdminTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.webAdmin"); webAdmin.setGraphic(getLabelWithHandler(webAdminTitle, "/views/webAdmin.fxml")); String mapsTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.maps"); maps.setGraphic(getLabelWithHandler(mapsTitle, "/views/mapsEdition.fxml")); + String consoleTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.console"); + console.setGraphic(getLabelWithHandler(consoleTitle, "/views/console.fxml")); + + String installUpdateTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.installUpdateServer"); + installUpdateServer.setGraphic(getLabelWithHandler(installUpdateTitle, "/views/installUpdateServer.fxml")); + String configurationTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.configuration"); configuration.setText(configurationTitle); @@ -128,12 +132,15 @@ private void loadNewContent(String title, String fxmlFilePath) { String mainPageTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.mainPage"); mainPage.setDisable(mainPageTitle.equals(title)); - String installUpdateTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.installUpdateServer"); - installUpdateServer.setDisable(installUpdateTitle.equals(title)); - String webAdminTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.webAdmin"); webAdmin.setDisable(webAdminTitle.equals(title)); + String consoleTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.console"); + console.setDisable(consoleTitle.equals(title)); + + String installUpdateTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.installUpdateServer"); + installUpdateServer.setDisable(installUpdateTitle.equals(title)); + String mapsTitle = propertyService.getPropertyValue("properties/languages/" + languageCode + ".properties", "prop.menu.maps"); maps.setDisable(mapsTitle.equals(title)); } catch (Exception e) { diff --git a/src/main/resources/css/custom.css b/src/main/resources/css/custom.css index 2793102..6b899ed 100644 --- a/src/main/resources/css/custom.css +++ b/src/main/resources/css/custom.css @@ -66,7 +66,7 @@ -fx-text-fill: white; } -.combo-box:hover, .combo-box-popup .list-view .list-cell:hover, .text-field:hover, .text-area .content:hover, .button:hover, .check-box:hover { +.combo-box:hover, .combo-box-popup .list-view .list-cell:hover, .text-field:hover, .button:hover, .check-box:hover, #customParameters .content:hover, #welcomeMessage .content:hover { -fx-background-color: #c15d11; -fx-text-fill: white; } diff --git a/src/main/resources/properties/config.properties b/src/main/resources/properties/config.properties index 70bead9..9c3ace4 100644 --- a/src/main/resources/properties/config.properties +++ b/src/main/resources/properties/config.properties @@ -1,6 +1,6 @@ # CONFIG PROPERTIES prop.config.applicationTitle=Simple Killing Floor 2 Server Launcher -prop.config.applicationVersion=2.0.2 final 20191018 +prop.config.applicationVersion=2.0.3 final 20191024 prop.config.applicationMaximized=false prop.config.selectedLanguageCode=en prop.config.urlSteamcmd=https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip diff --git a/src/main/resources/properties/languages/en.properties b/src/main/resources/properties/languages/en.properties index 0cd18ce..d6dc3cc 100644 --- a/src/main/resources/properties/languages/en.properties +++ b/src/main/resources/properties/languages/en.properties @@ -18,6 +18,7 @@ prop.menu.help.about.developed=Developed by prop.menu.help.about.translatedSpanish=Translated to Spanish by prop.menu.help.about.translatedFrench=Translated to French by prop.menu.help.about.version=Version +prop.menu.console=Console # LABELS prop.label.profile=PROFILE @@ -36,7 +37,6 @@ prop.label.webLink=YOUR WEB LINK prop.label.urlImage=URL IMAGE SERVER prop.label.welcome=WELCOME MESSAGE prop.label.customParameters=CUSTOM PARAMETERS -prop.label.console=CONSOLE prop.label.runServer=RUN SERVER prop.label.joinServer=JOIN SERVER prop.label.webAdminMessage=Web page must be enabled and server must be started in order to access WebAdmin page @@ -91,6 +91,8 @@ prop.label.select=Select prop.label.gametype=Game type prop.label.difficultyLowercase=Difficulty prop.label.lengthLowercase=Length +prop.label.official=OFFICIAL +prop.label.custom=CUSTOM # DIFFICULTIES prop.difficulty.0=Normal @@ -225,6 +227,7 @@ prop.message.photoLocation=Photo location prop.message.proceed=Proceed with operation? prop.message.importItems=Next items need to be imported before importing profiles prop.message.selectProfiles=Select profiles to do the operation +prop.message.takeoverNotSaved=The takeover value could not be saved! # TOOLTIPS prop.tooltip.profile=This field indicates the selected profile to be applied. When a profile is selected, all others fields are filled with the profile's specific configuration. It is mandatory diff --git a/src/main/resources/properties/languages/es.properties b/src/main/resources/properties/languages/es.properties index 26859c2..aa9a783 100644 --- a/src/main/resources/properties/languages/es.properties +++ b/src/main/resources/properties/languages/es.properties @@ -18,6 +18,7 @@ prop.menu.help.about.developed=Desarrollado por prop.menu.help.about.translatedSpanish=Traducido al Espa\u00f1ol por prop.menu.help.about.translatedFrench=Traducido al Franc\u00e9s por prop.menu.help.about.version=Versi\u00f3n +prop.menu.console=Consola # ETIQUETAS prop.label.profile=PERFIL @@ -36,7 +37,6 @@ prop.label.webLink=TU ENLACE WEB prop.label.urlImage=URL IMAGEN SERVIDOR prop.label.welcome=MENSAJE BIENVENIDA prop.label.customParameters=PARAMETROS OPCIONALES -prop.label.console=CONSOLA prop.label.runServer=EJECUTAR SERVIDOR prop.label.joinServer=UNIRSE A SERVIDOR prop.label.webAdminMessage=La p\u00e1gina web debe estar habilitada y el servidor iniciado para acceder a la p\u00e1gina de WebAdmin @@ -91,6 +91,8 @@ prop.label.select=Seleccionar prop.label.gametype=Tipo de juego prop.label.difficultyLowercase=Dificultad prop.label.lengthLowercase=Duraci\u00F3n +prop.label.official=OFICIAL +prop.label.custom=PERSONALIZADO # DIFICULTADES prop.difficulty.0=Normal @@ -225,6 +227,7 @@ prop.message.photoLocation=Localizaci\u00f3n foto prop.message.proceed=\u00bfProceder con la operaci\u00f3n? prop.message.importItems=Los siguientes elementos deben ser importados antes de importar perfiles prop.message.selectProfiles=Selecciona perfiles para hacer la operaci\u00f3n +prop.message.takeoverNotSaved=\u00a1El valor de toma de control no pudo ser guardado! # MENSAJES EMERGENTES prop.tooltip.profile=Este campo indica el perfil seleccionado a ser aplicado. Cuando un perfil es seleccionado, los otros campos son rellenados con la configuraci\u00f3n espec\u00edfica del perfil. Es obligatorio diff --git a/src/main/resources/properties/languages/fr.properties b/src/main/resources/properties/languages/fr.properties index 6238370..931d6a9 100644 --- a/src/main/resources/properties/languages/fr.properties +++ b/src/main/resources/properties/languages/fr.properties @@ -18,6 +18,7 @@ prop.menu.help.about.developed=Developp\u00e9 par prop.menu.help.about.translatedSpanish=Traduit en espagnol par prop.menu.help.about.translatedFrench=Traduit en fran\u00e7ais par prop.menu.help.about.version=Version +prop.menu.console=Console # LABELS prop.label.profile=PROFIL @@ -36,7 +37,6 @@ prop.label.webLink=TON LIEN WEB prop.label.urlImage=URL DE L'IMAGE SERVER prop.label.welcome=MESSAGE DE BIENVENUE prop.label.customParameters=PARAMETRES PERSONNALIS\u00c9S -prop.label.console=CONSOLE prop.label.runServer=LANCER LE SERVER prop.label.joinServer=JOINDRE LE SERVER prop.label.webAdminMessage=La page web doit \u00eatre activ\u00e9 et le serveur lanc\u00e9 pour pouvoir acc\u00e9der \u00e0 la page WebAdmin @@ -91,6 +91,8 @@ prop.label.select=S\u00e9lectionner prop.label.gametype=Type de jeu prop.label.difficultyLowercase=Difficult\u00e9 prop.label.lengthLowercase=Longueur +prop.label.official=OFFICIEL +prop.label.custom=DOUANE # DIFFICULTIES prop.difficulty.0=Normal @@ -225,6 +227,7 @@ prop.message.photoLocation=Emplacement photo prop.message.proceed=Proc\u00e9der \u00e0 l'op\u00e9ration? prop.message.importItems=Les \u00e9l\u00e9ments suivants doivent \u00eatre import\u00e9s avant d'importer des profils prop.message.selectProfiles=S\u00e9lectionnez les profils pour effectuer l'op\u00e9ration +prop.message.takeoverNotSaved=La valeur de prise de contr\u00f4le n'a pas pu \u00eatre sauvegard\u00e9e! # TOOLTIPS prop.tooltip.profile=Ce champ indique le profil s\u00e9lectionn\u00e9 \u00e0 appliquer. Lorsqu'un profil est s\u00e9lectionn\u00e9, tous les autres champs sont remplis avec la configuration sp\u00e9cifique du profil. C'est indispensable diff --git a/src/main/resources/views/console.fxml b/src/main/resources/views/console.fxml new file mode 100644 index 0000000..5291c5c --- /dev/null +++ b/src/main/resources/views/console.fxml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/views/mainContent.fxml b/src/main/resources/views/mainContent.fxml index b25e472..3913906 100644 --- a/src/main/resources/views/mainContent.fxml +++ b/src/main/resources/views/mainContent.fxml @@ -23,6 +23,7 @@ + @@ -34,262 +35,293 @@ - - - + - - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/src/main/resources/views/template.fxml b/src/main/resources/views/template.fxml index 7b7e955..7c055bb 100644 --- a/src/main/resources/views/template.fxml +++ b/src/main/resources/views/template.fxml @@ -10,8 +10,9 @@ - + +