private DecoratedText initializeDecoratedText(final String template, Map<String, Object> parameters, DecoratedText text) { text.getStylesheets().add(DecoratedText.class.getResource(DecoratedText.class.getSimpleName() + ".css").toExternalForm()); text.getStyleClass().add("decoratedText"); text.setLayoutY(topInset); text.setLayoutX(leftInset); text.setWrappingWidth(wrappingWidth); String[] lines = template.split("\n"); for (int i = 0; i < lines.length; i++) { String curTemplate = lines[i]; if (i == lines.length -1 && template.endsWith("\n") || i < lines.length -1){ curTemplate += "\n"; } text = replaceParameters(text, curTemplate, parameters); } return text; }
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernFugitiveDialog.title", new Object[]{}, locale.getCurrentLocal())); initializeButtons(); IFugitive fugitive = (IFugitive) currentPerson.get(); DecoratedText text = new DecoratedText(); text.setLayoutX(2 * Dialog.FRAME_BORDER); text.setLayoutY(100); text.setWrappingWidth(Dialog.WRAPPING_WIDTH); String loadedText = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernFugitiveDialog.dialog", new Object[0], locale.getCurrentLocal()); HashMap<String, Object> parameters = new HashMap<>(); parameters.put("destination", fugitive.getDestination().getName()); parameters.put("amount", fugitive.getPremium()); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, parameters); getContent().addAll(dt); }
template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.OutriggerNoticeDialog.weeklyRefund", new Object[]{ship.getName(), contract.getWeeklyRefund()}, locale.getCurrentLocal()); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setLayoutY(CLOSE_BTN_Y_POS - 200); getContent().add(text); template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.OutriggerNoticeDialog.noShip", new Object[]{}, locale.getCurrentLocal()); text = textFactory.createDecoratedText(template, new HashMap<>()); text.setLayoutY(CLOSE_BTN_Y_POS - 400); getContent().add(text); } else {
DecoratedText noShip = decoratedTextFactory.createDecoratedText(template, parameters); noShip.setLayoutX(2*FRAME_BORDER); noShip.setLayoutY(300); getContent().add(noShip); } else { DecoratedText selectedShip = decoratedTextFactory.createDecoratedText(template, parameters); selectedShip.setLayoutX(2*FRAME_BORDER); selectedShip.setLayoutY(300); getContent().add(selectedShip); GridPane shipSelectionPane = dialogUtil.createShipSelection3LinesForShips(city.getPlayersShips(), currentShip);
final String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardConstructionListDialogV2.noShipsBuilding", new Object[]{}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(s, new HashMap<>()); text.setLayoutY(100); getContent().addAll(text); } else {
final String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardRepairListDialogV2.noShipsRepairing", new Object[]{}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(s, new HashMap<>()); text.setLayoutY(100); getContent().addAll(text); } else {
DecoratedText noShip = decoratedTextFactory.createDecoratedText(template, new HashMap<>()); noShip.setLayoutX(2*FRAME_BORDER); noShip.setLayoutY(300); getContent().add(noShip); } else {
DecoratedText selectedShip = decoratedTextFactory.createDecoratedText(template, new HashMap<>()); selectedShip.setLayoutX(2 * FRAME_BORDER); selectedShip.setLayoutY(250); getContent().add(selectedShip); DecoratedText noShip = decoratedTextFactory.createDecoratedText(template, new HashMap<>()); noShip.setLayoutX(2*FRAME_BORDER); noShip.setLayoutY(300); getContent().add(noShip); } else {
text.setLayoutY(250); getContent().addAll(text);