diff --git a/scripts/sql/script.sql b/scripts/sql/script.sql index 63fd278..6c34171 100644 --- a/scripts/sql/script.sql +++ b/scripts/sql/script.sql @@ -96,33 +96,33 @@ INSERT INTO KF2DATABASE.DESCRIPTIONS VALUES (44, 'Shopping Spree', 'Compra compu INSERT INTO KF2DATABASE.DESCRIPTIONS VALUES (45, 'Spillway', 'Desagüe'); INSERT INTO KF2DATABASE.DESCRIPTIONS VALUES (46, 'Steam Fortress', 'Steam Fortress'); -INSERT INTO KF2DATABASE.MAPS VALUES (1, 'KF-BurningParis', 20); -INSERT INTO KF2DATABASE.MAPS VALUES (2, 'KF-Bioticslab', 21); -INSERT INTO KF2DATABASE.MAPS VALUES (3, 'KF-Outpost', 22); -INSERT INTO KF2DATABASE.MAPS VALUES (4, 'KF-VolterManor', 23); -INSERT INTO KF2DATABASE.MAPS VALUES (5, 'KF-Catacombs', 24); -INSERT INTO KF2DATABASE.MAPS VALUES (6, 'KF-EvacuationPoint', 25); -INSERT INTO KF2DATABASE.MAPS VALUES (7, 'KF-Farmhouse', 26); -INSERT INTO KF2DATABASE.MAPS VALUES (8, 'KF-BlackForest', 27); -INSERT INTO KF2DATABASE.MAPS VALUES (9, 'KF-Prison', 28); -INSERT INTO KF2DATABASE.MAPS VALUES (10, 'KF-ContainmentStation', 29); -INSERT INTO KF2DATABASE.MAPS VALUES (11, 'KF-HostileGrounds', 30); -INSERT INTO KF2DATABASE.MAPS VALUES (12, 'KF-InfernalRealm', 31); -INSERT INTO KF2DATABASE.MAPS VALUES (13, 'KF-ZedLanding', 32); -INSERT INTO KF2DATABASE.MAPS VALUES (14, 'KF-Nuked', 33); -INSERT INTO KF2DATABASE.MAPS VALUES (15, 'KF-TheDescent', 34); -INSERT INTO KF2DATABASE.MAPS VALUES (16, 'KF-TragicKingdom', 35); -INSERT INTO KF2DATABASE.MAPS VALUES (17, 'KF-Nightmare', 36); -INSERT INTO KF2DATABASE.MAPS VALUES (18, 'KF-KrampusLair', 37); -INSERT INTO KF2DATABASE.MAPS VALUES (19, 'KF-DieSector', 38); -INSERT INTO KF2DATABASE.MAPS VALUES (20, 'KF-Powercore_Holdout', 39); -INSERT INTO KF2DATABASE.MAPS VALUES (21, 'KF-Airship', 40); -INSERT INTO KF2DATABASE.MAPS VALUES (22, 'KF-Lockdown', 41); -INSERT INTO KF2DATABASE.MAPS VALUES (23, 'KF-MonsterBall', 42); -INSERT INTO KF2DATABASE.MAPS VALUES (24, 'KF-SantasWorkshop', 43); -INSERT INTO KF2DATABASE.MAPS VALUES (25, 'KF-ShoppingSpree', 44); -INSERT INTO KF2DATABASE.MAPS VALUES (26, 'KF-Spillway', 45); -INSERT INTO KF2DATABASE.MAPS VALUES (27, 'KF-SteamFortress', 46); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (1, 'KF-BurningParis', 20, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Burning_Paris'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (2, 'KF-Bioticslab', 21, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Biotics_Lab_(Killing_Floor_2)'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (3, 'KF-Outpost', 22, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Outpost'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (4, 'KF-VolterManor', 23, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Volter_Manor'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (5, 'KF-Catacombs', 24, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Catacombs'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (6, 'KF-EvacuationPoint', 25, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Evacuation_Point'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (7, 'KF-Farmhouse', 26, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Farmhouse'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (8, 'KF-BlackForest', 27, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Black_Forest'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (9, 'KF-Prison', 28, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Prison'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (10, 'KF-ContainmentStation', 29, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Containment_Station'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (11, 'KF-HostileGrounds', 30, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Hostile_Grounds'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (12, 'KF-InfernalRealm', 31, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Infernal_Realm'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (13, 'KF-ZedLanding', 32, TRUE, 'https://wiki.killingfloor2.com/index.php?title=ZED_Landing'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (14, 'KF-Nuked', 33, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Nuked'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (15, 'KF-TheDescent', 34, TRUE, 'https://wiki.killingfloor2.com/index.php?title=The_Descent'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (16, 'KF-TragicKingdom', 35, TRUE, 'https://wiki.killingfloor2.com/index.php?title=The_Tragic_Kingdom'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (17, 'KF-Nightmare', 36, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Nightmare'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (18, 'KF-KrampusLair', 37, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Krampus_Lair'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (19, 'KF-DieSector', 38, TRUE, 'https://wiki.killingfloor2.com/index.php?title=DieSector'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (20, 'KF-Powercore_Holdout', 39, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Powercore'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (21, 'KF-Airship', 40, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Airship'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (22, 'KF-Lockdown', 41, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Lockdown'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (23, 'KF-MonsterBall', 42, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Monster_Ball'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (24, 'KF-SantasWorkshop', 43, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Santa%27s_Workshop'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (25, 'KF-ShoppingSpree', 44, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Shopping_Spree'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (26, 'KF-Spillway', 45, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Spillway'); +INSERT INTO KF2DATABASE.MAPS(ID, CODE, ID_DESCRIPTION, OFFICIAL, URL_INFO) VALUES (27, 'KF-SteamFortress', 46, TRUE, 'https://wiki.killingfloor2.com/index.php?title=Steam_Fortress'); ----------------------------------- diff --git a/src/main/java/constants/Constants.java b/src/main/java/constants/Constants.java index 02fd923..c209efb 100644 --- a/src/main/java/constants/Constants.java +++ b/src/main/java/constants/Constants.java @@ -14,6 +14,7 @@ public class Constants { public static final String MENU_DIFFICULTIES_EDITION = "Difficulties"; public static final String MENU_LENGTH_EDITION = "Length"; public static final String MENU_MAXPLAYERS_EDITION = "Max. players"; + public static final String MENU_MAPS_EDITION = "Maps"; // UTILS public final static String UTILS_AES_ENCRIPTION_KEY = "SimplKillingFloor2ServerLauncher"; diff --git a/src/main/java/dtos/MapDto.java b/src/main/java/dtos/MapDto.java new file mode 100644 index 0000000..3d33f55 --- /dev/null +++ b/src/main/java/dtos/MapDto.java @@ -0,0 +1,37 @@ +package dtos; + +public class MapDto { + + private final String key; + private final String value; + private final Boolean official; + private final String urlInfo; + + public MapDto(String key, String value, Boolean official, String urlInfo) { + this.key = key; + this.value = value; + this.official = official; + this.urlInfo = urlInfo; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + + public Boolean getOfficial() { + return official; + } + + public String getUrlInfo() { + return urlInfo; + } + + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/dtos/ProfileDto.java b/src/main/java/dtos/ProfileDto.java index 968dcdd..dd18b49 100644 --- a/src/main/java/dtos/ProfileDto.java +++ b/src/main/java/dtos/ProfileDto.java @@ -8,7 +8,7 @@ public class ProfileDto { private final StringProperty name; private final SelectDto language; private final SelectDto gametype; - private final SelectDto map; + private final MapDto map; private final SelectDto difficulty; private final SelectDto length; private final SelectDto maxPlayers; @@ -25,7 +25,7 @@ public class ProfileDto { private final String welcomeMessage; private final String customParameters; - public ProfileDto(String name, SelectDto language, SelectDto gametype, SelectDto map, SelectDto difficulty, SelectDto length, SelectDto maxPlayers, + public ProfileDto(String name, SelectDto language, SelectDto 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) { super(); @@ -66,7 +66,7 @@ public SelectDto getGametype() { return gametype; } - public SelectDto getMap() { + public MapDto getMap() { return map; } diff --git a/src/main/java/dtos/factories/MapDtoFactory.java b/src/main/java/dtos/factories/MapDtoFactory.java index d3b2c1d..d09d299 100644 --- a/src/main/java/dtos/factories/MapDtoFactory.java +++ b/src/main/java/dtos/factories/MapDtoFactory.java @@ -1,5 +1,6 @@ package dtos.factories; +import dtos.MapDto; import dtos.SelectDto; import entities.Map; import javafx.collections.FXCollections; @@ -10,12 +11,15 @@ public class MapDtoFactory { - public SelectDto newDto(Map map) { - return new SelectDto(map.getCode(), map.getDescription().getEnglishText()); + public MapDto newDto(Map map) { + return new MapDto(map.getCode(), + map.getDescription().getEnglishText(), + map.getOfficial(), + map.getUrlInfo()); } - public ObservableList newDtos(List maps) { - List dtoList = maps.stream().map(this::newDto).collect(Collectors.toList()); + public ObservableList newDtos(List maps) { + List dtoList = maps.stream().map(this::newDto).collect(Collectors.toList()); return FXCollections.observableArrayList(dtoList); } diff --git a/src/main/java/entities/Map.java b/src/main/java/entities/Map.java index 4192e35..6cfd300 100644 --- a/src/main/java/entities/Map.java +++ b/src/main/java/entities/Map.java @@ -18,14 +18,22 @@ public class Map extends CommonEntity { @JoinColumn(name="ID_DESCRIPTION", referencedColumnName="ID", unique=true, nullable=false) private Description description; + @Column(name="OFFICIAL", nullable=false) + private Boolean official; + + @Column(name="URL_INFO", length=255) + private String urlInfo; + public Map() { super(); } - public Map(String code, Description description) { + public Map(String code, Description description, Boolean official, String urlInfo) { super(); this.code = code; this.description = description; + this.official = official; + this.urlInfo = urlInfo; } @Override @@ -53,4 +61,20 @@ public Description getDescription() { public void setDescription(Description description) { this.description = description; } + + public Boolean getOfficial() { + return official; + } + + public void setOfficial(Boolean official) { + this.official = official; + } + + public String getUrlInfo() { + return urlInfo; + } + + public void setUrlInfo(String urlInfo) { + this.urlInfo = urlInfo; + } } diff --git a/src/main/java/pojos/session/Session.java b/src/main/java/pojos/session/Session.java index 0eb0d04..233a749 100644 --- a/src/main/java/pojos/session/Session.java +++ b/src/main/java/pojos/session/Session.java @@ -1,5 +1,6 @@ package pojos.session; +import dtos.MapDto; import dtos.ProfileDto; public class Session { @@ -8,6 +9,7 @@ public class Session { private ProfileDto actualProfile; private String console; + private MapDto map; /** * Singleton constructor @@ -15,6 +17,7 @@ public class Session { private Session() { super(); console = ""; + map = null; } public static Session getInstance() { @@ -39,4 +42,12 @@ public String getConsole() { public void setConsole(String console) { this.console = console; } + + public MapDto getMap() { + return map; + } + + public void setMap(MapDto map) { + this.map = map; + } } diff --git a/src/main/java/stories/maincontent/MainContentController.java b/src/main/java/stories/maincontent/MainContentController.java index 7bce9be..7c274f7 100644 --- a/src/main/java/stories/maincontent/MainContentController.java +++ b/src/main/java/stories/maincontent/MainContentController.java @@ -1,5 +1,6 @@ package stories.maincontent; +import dtos.MapDto; import dtos.ProfileDto; import dtos.SelectDto; import javafx.beans.value.ChangeListener; @@ -26,7 +27,7 @@ public class MainContentController implements Initializable { @FXML private ComboBox profileSelect; @FXML private ComboBox languageSelect; @FXML private ComboBox gameTypeSelect; - @FXML private ComboBox mapSelect; + @FXML private ComboBox mapSelect; @FXML private ComboBox difficultySelect; @FXML private ComboBox lengthSelect; @FXML private ComboBox maxPlayersSelect; diff --git a/src/main/java/stories/maincontent/MainContentFacade.java b/src/main/java/stories/maincontent/MainContentFacade.java index 2172f7f..c868c8a 100644 --- a/src/main/java/stories/maincontent/MainContentFacade.java +++ b/src/main/java/stories/maincontent/MainContentFacade.java @@ -1,5 +1,6 @@ package stories.maincontent; +import dtos.MapDto; import dtos.ProfileDto; import dtos.SelectDto; import javafx.collections.ObservableList; @@ -11,7 +12,7 @@ public interface MainContentFacade { ObservableList listAllProfiles() throws SQLException; ObservableList listAllLanguages() throws SQLException; ObservableList listAllGameTypes() throws SQLException; - ObservableList listAllMaps() throws SQLException; + ObservableList listAllMaps() throws SQLException; ObservableList listAllDifficulties() throws SQLException; ObservableList listAllLengths() throws SQLException; ObservableList listAllPlayers() throws SQLException; diff --git a/src/main/java/stories/maincontent/MainContentFacadeImpl.java b/src/main/java/stories/maincontent/MainContentFacadeImpl.java index bfe4273..623684b 100644 --- a/src/main/java/stories/maincontent/MainContentFacadeImpl.java +++ b/src/main/java/stories/maincontent/MainContentFacadeImpl.java @@ -1,6 +1,7 @@ package stories.maincontent; import daos.*; +import dtos.MapDto; import dtos.ProfileDto; import dtos.SelectDto; import dtos.factories.*; @@ -52,7 +53,7 @@ public ObservableList listAllGameTypes() throws SQLException { } @Override - public ObservableList listAllMaps() throws SQLException { + public ObservableList listAllMaps() throws SQLException { List maps = MapDao.getInstance().listAll(); return mapDtoFactory.newDtos(maps); } diff --git a/src/main/java/stories/mapsedition/MapsEditionController.java b/src/main/java/stories/mapsedition/MapsEditionController.java new file mode 100644 index 0000000..e7fce3f --- /dev/null +++ b/src/main/java/stories/mapsedition/MapsEditionController.java @@ -0,0 +1,158 @@ +package stories.mapsedition; + +import constants.Constants; +import dtos.MapDto; +import dtos.SelectDto; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.geometry.HPos; +import javafx.scene.Cursor; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Slider; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.GridPane; +import org.apache.commons.lang3.StringUtils; +import pojos.session.Session; +import start.MainApplication; +import utils.Utils; + +import java.net.URL; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.ResourceBundle; + +public class MapsEditionController implements Initializable { + + private final MapsEditionFacade facade; + + @FXML private Slider mapsSlider; + @FXML private ComboBox viewPaneCombo; + @FXML private ScrollPane officialMapsScrollPane; + @FXML private FlowPane officialMapsFlowPane; + @FXML private ScrollPane customMapsScrollPane; + @FXML private FlowPane customMapsFlowPane; + @FXML private Label officialMapsLabel; + @FXML private Label customMapsLabel; + + public MapsEditionController() { + super(); + this.facade = new MapsEditionFacadeImpl(); + } + + @Override + public void initialize(URL location, ResourceBundle resources) { + try { + List viewOptions = new ArrayList(); + viewOptions.add("Official and custom maps"); + viewOptions.add("Only official maps"); + viewOptions.add("Only custom maps"); + ObservableList viewItems = FXCollections.observableArrayList(viewOptions); + viewPaneCombo.setItems(viewItems); + viewPaneCombo.setValue(viewOptions.get(0)); + + String installationFolder = facade.findPropertyValue(Constants.KEY_INSTALLATION_FOLDER); + List maps = facade.listAllMaps(); + for (MapDto map: maps) { + Label mapDescriptionLabel = new Label(map.getValue()); + Image image = new Image("file:" + installationFolder + "/KFGame/Web/images/maps/" + map.getKey() + ".jpg"); + //Image image = new Image("file:src/main/resources/images/photo-borders.png"); + ImageView mapPreview = new ImageView(image); + mapPreview.setPreserveRatio(true); + if (StringUtils.isNotBlank(map.getUrlInfo())) { + mapPreview.setCursor(Cursor.HAND); + mapPreview.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler() { + @Override + public void handle(MouseEvent event) { + Session.getInstance().setMap(map); + loadNewContent("/views/mapWebInfo.fxml"); + event.consume(); + } + }); + } + GridPane gridpane = new GridPane(); + gridpane.add(mapPreview, 1, 1); + gridpane.add(mapDescriptionLabel, 1, 2); + GridPane.setHalignment(mapDescriptionLabel, HPos.CENTER); + if (map.getOfficial()) { + officialMapsFlowPane.getChildren().add(gridpane); + } else { + customMapsFlowPane.getChildren().add(gridpane); + } + } + mapsSliderOnMouseClicked(); + } catch (SQLException e) { + Utils.errorDialog("Error getting map list", "See stacktrace for more details", e); + } + } + + + private void loadNewContent(String fxmlFilePath) { + try { + GridPane templateContent = (GridPane) MainApplication.getTemplate().getNamespace().get("content"); + templateContent.getColumnConstraints().clear(); + templateContent.getRowConstraints().clear(); + templateContent.getChildren().clear(); + FXMLLoader content = new FXMLLoader(getClass().getResource(fxmlFilePath)); + content.setRoot(MainApplication.getTemplate().getNamespace().get("content")); + content.load(); + } catch (Exception e) { + Utils.errorDialog(e.getMessage(), "See stacktrace for more details", e); + } + } + + @FXML + private void mapsSliderOnMouseClicked() { + for (int i = 0; i < officialMapsFlowPane.getChildren().size(); i++) { + GridPane gridPane = (GridPane)officialMapsFlowPane.getChildren().get(i); + ImageView mapPreview = (ImageView) gridPane.getChildren().get(0); + Double width = (mapsSlider.getValue() * 3.84) + 128; + mapPreview.setFitWidth(width); + } + } + + @FXML + private void viewPaneComboOnAction() { + if (viewPaneCombo.getValue().equals(viewPaneCombo.getItems().get(0))) { + GridPane.setRowSpan(officialMapsScrollPane, 1); + officialMapsLabel.setVisible(true); + officialMapsFlowPane.setVisible(true); + officialMapsScrollPane.setVisible(true); + GridPane.setRowIndex(customMapsScrollPane, 4); + GridPane.setRowSpan(customMapsScrollPane, 1); + GridPane.setRowIndex(customMapsLabel, 3); + customMapsLabel.setVisible(true); + customMapsScrollPane.setVisible(true); + customMapsFlowPane.setVisible(true); + } else { + if (viewPaneCombo.getValue().equals(viewPaneCombo.getItems().get(1))) { + GridPane.setRowSpan(officialMapsScrollPane, 3); + officialMapsLabel.setVisible(true); + officialMapsFlowPane.setVisible(true); + officialMapsScrollPane.setVisible(true); + customMapsFlowPane.setVisible(false); + customMapsScrollPane.setVisible(false); + customMapsLabel.setVisible(false); + } else { + officialMapsLabel.setVisible(false); + officialMapsFlowPane.setVisible(false); + officialMapsScrollPane.setVisible(false); + GridPane.setRowIndex(customMapsLabel, 1); + GridPane.setRowIndex(customMapsScrollPane, 2); + GridPane.setRowSpan(customMapsScrollPane, 3); + customMapsLabel.setVisible(true); + customMapsScrollPane.setVisible(true); + customMapsFlowPane.setVisible(true); + } + } + } +} diff --git a/src/main/java/stories/mapsedition/MapsEditionFacade.java b/src/main/java/stories/mapsedition/MapsEditionFacade.java new file mode 100644 index 0000000..8eb9f59 --- /dev/null +++ b/src/main/java/stories/mapsedition/MapsEditionFacade.java @@ -0,0 +1,11 @@ +package stories.mapsedition; + +import dtos.MapDto; + +import java.sql.SQLException; +import java.util.List; + +public interface MapsEditionFacade { + List listAllMaps() throws SQLException; + String findPropertyValue(String key) throws SQLException; +} diff --git a/src/main/java/stories/mapsedition/MapsEditionFacadeImpl.java b/src/main/java/stories/mapsedition/MapsEditionFacadeImpl.java new file mode 100644 index 0000000..80089ce --- /dev/null +++ b/src/main/java/stories/mapsedition/MapsEditionFacadeImpl.java @@ -0,0 +1,39 @@ +package stories.mapsedition; + +import daos.MapDao; +import daos.PropertyDao; +import dtos.MapDto; +import dtos.SelectDto; +import dtos.factories.MapDtoFactory; +import entities.Map; +import entities.Property; + +import java.sql.SQLException; +import java.util.List; +import java.util.Optional; + +public class MapsEditionFacadeImpl implements MapsEditionFacade { + + private final MapDtoFactory mapDtoFactory; + + public MapsEditionFacadeImpl() { + super(); + this.mapDtoFactory = new MapDtoFactory(); + } + + @Override + public List listAllMaps() throws SQLException { + List maps = MapDao.getInstance().listAll(); + return mapDtoFactory.newDtos(maps); + } + + @Override + public String findPropertyValue(String key) throws SQLException { + Optional propertyOpt = PropertyDao.getInstance().findByKey(key); + if (propertyOpt.isPresent()) { + return propertyOpt.get().getValue(); + } else { + return ""; + } + } +} diff --git a/src/main/java/stories/mapwebinfo/MapWebInfoController.java b/src/main/java/stories/mapwebinfo/MapWebInfoController.java new file mode 100644 index 0000000..118ad0b --- /dev/null +++ b/src/main/java/stories/mapwebinfo/MapWebInfoController.java @@ -0,0 +1,50 @@ +package stories.mapwebinfo; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.GridPane; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebView; +import pojos.session.Session; +import start.MainApplication; +import utils.Utils; + +import java.net.URL; +import java.util.ResourceBundle; + +public class MapWebInfoController implements Initializable { + + @FXML private WebView mapInfoWebView; + @FXML private Label mapNameLabel; + @FXML private Button backButton; + + @FXML + @Override + public void initialize(URL location, ResourceBundle resources) { + mapNameLabel.setText(Session.getInstance().getMap().getValue()); + WebEngine webEngine = mapInfoWebView.getEngine(); + webEngine.load(Session.getInstance().getMap().getUrlInfo()); + } + + @FXML + private void backButtonOnAction(){ + loadNewContent("/views/mapsEdition.fxml"); + } + + private void loadNewContent(String fxmlFilePath) { + try { + GridPane templateContent = (GridPane) MainApplication.getTemplate().getNamespace().get("content"); + templateContent.getColumnConstraints().clear(); + templateContent.getRowConstraints().clear(); + templateContent.getChildren().clear(); + FXMLLoader content = new FXMLLoader(getClass().getResource(fxmlFilePath)); + content.setRoot(MainApplication.getTemplate().getNamespace().get("content")); + content.load(); + } catch (Exception e) { + Utils.errorDialog(e.getMessage(), "See stacktrace for more details", e); + } + } +} diff --git a/src/main/java/stories/template/TemplateController.java b/src/main/java/stories/template/TemplateController.java index cc2eebf..7fe4bd8 100644 --- a/src/main/java/stories/template/TemplateController.java +++ b/src/main/java/stories/template/TemplateController.java @@ -80,4 +80,9 @@ private void lengthMenuOnAction() { private void maxPlayersMenuOnAction() { loadNewContent(Constants.MENU_MAXPLAYERS_EDITION, "/views/maxPlayersEdition.fxml"); } + + @FXML + private void mapsMenuOnAction() { + loadNewContent(Constants.MENU_MAPS_EDITION, "/views/mapsEdition.fxml"); + } } diff --git a/src/main/resources/css/custom.css b/src/main/resources/css/custom.css index 18b0760..58ffc80 100644 --- a/src/main/resources/css/custom.css +++ b/src/main/resources/css/custom.css @@ -28,7 +28,7 @@ -fx-font-size: 14; } -#leftPane, #rightPane, #centerGridPanel, #centerGridPane { +#leftPane, #rightPane, #centerPane { -fx-background-color: black; } @@ -135,3 +135,7 @@ -fx-font-weight: bold; -fx-font-size: 34; } + +.scroll-bar:vertical{ + -fx-background-color: #c15d11; +} diff --git a/src/main/resources/views/difficultiesEdition.fxml b/src/main/resources/views/difficultiesEdition.fxml index 3835824..6642175 100644 --- a/src/main/resources/views/difficultiesEdition.fxml +++ b/src/main/resources/views/difficultiesEdition.fxml @@ -1,18 +1,13 @@ - - - - + - - - + - + @@ -24,10 +19,10 @@ - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/views/lengthEdition.fxml b/src/main/resources/views/lengthEdition.fxml index 40628fa..d520739 100644 --- a/src/main/resources/views/lengthEdition.fxml +++ b/src/main/resources/views/lengthEdition.fxml @@ -1,18 +1,13 @@ - - - - + - - - + - + @@ -24,10 +19,10 @@ - - - - + + + +