public OpenPatricianLargeWaxButtonSkin(final OpenPatricianLargeWaxButton button) { super(button); InputStream is = getClass().getResourceAsStream("sealingWaxFlattend_long.png"); Image img = new Image(is); final ImageView imageView = new ImageView(img); final Label label = new Label(); label.textProperty().bind(button.textProperty()); label.idProperty().bind(button.idProperty()); label.getStyleClass().add("OpenPatricianLargeWaxButtonLabeled"); label.onMouseClickedProperty().bind(button.onActionProperty()); imageView.onMouseReleasedProperty().bind(button.onActionProperty()); StackPane stack = new StackPane(); stack.getChildren().addAll(imageView, label); Group group = new Group(stack); group.setManaged(false); button.setPrefHeight(img.getHeight()); button.setPrefWidth(img.getWidth()); getChildren().add(group); }
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.LeaveConvoyDialog.title", new Object[]{}, locale.getCurrentLocal())); String template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.LeaveConvoyDialog.text", new Object[]{ship.getName(), convoy.getName()}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); VBox box = new VBox(text); box.setLayoutX(50); box.setLayoutY(CLOSE_BTN_Y_POS - 500); OpenPatricianLargeWaxButton acceptBtn = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.LeaveConvoyDialog.leave", new Object[]{}, locale.getCurrentLocal())); acceptBtn.getStyleClass().add("actionButton"); acceptBtn.setId("actionButton"); acceptBtn.setLayoutX(BUTTON_X); acceptBtn.setOnAction(createAcceptHandler(ship)); acceptBtn.setLayoutY(UPPER_BUTTON_Y); getContent().addAll(box, acceptBtn); }
protected final void initializeButtons(){ final BooleanBinding hasMorePersons = hasNextPersonBinding(); acceptBtn = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernBaseSideRoomPersonDialog.accept", new Object[]{}, locale.getCurrentLocal())); acceptBtn.getStyleClass().add("actionButton"); acceptBtn.setLayoutX(BUTTON_X); acceptBtn.setOnAction(createAcceptHandler()); OpenPatricianLargeWaxButton nextBtn = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernBaseSideRoomPersonDialog.next", new Object[]{}, locale.getCurrentLocal())); nextBtn.getStyleClass().add("actionButton"); nextBtn.setLayoutX(BUTTON_X); nextBtn.setLayoutY(LOWER_BUTTON_Y); nextBtn.setOnAction(createNextPersonHandler()); nextBtn.visibleProperty().bind(hasMorePersons); acceptBtn.layoutYProperty().bind(new DoubleBinding() { acceptBtn.setDisable(disableAcceptButton.get()); disableAcceptButton.addListener((observableValue, oldValue, newValue) -> acceptBtn.setDisable(newValue)); getContent().addAll(nextBtn, acceptBtn);
/** * Add the action button centered at the bottom. * @param textKey for the label on the button * @param id for the button * @return button */ public OpenPatricianLargeWaxButton addActionButton(String textKey, String id) { OpenPatricianLargeWaxButton button = new OpenPatricianLargeWaxButton(messageSource.getMessage(textKey, new Object[]{}, locale.getCurrentLocal())); button.setId(id); final int actionButtonX = (WIDTH - 124) / 2; button.setLayoutX(actionButtonX); button.setLayoutY(CLOSE_BTN_Y_POS - 24); getContent().add(button); return button; }
final OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(s); action.getStyleClass().add("actionButton"); action.setId("offerShip"); Pane centeredButton = dialogHelper.center(action); box.getChildren().add(centeredButton); action.setOnAction(createAuctionShipAction(box, guild, text, itemNavigator, centerPane, centeredButton));
@PostConstruct private void initializeModelAndDialog() { Table model = createModel(); if (model != null) { setModel(model); } final Optional<ITradingOffice> optOffice = city.getPlayer().findTradingOffice(city.getCity()); Preconditions.checkArgument(optOffice.isPresent(), "Ther must be a trading office present."); final ITradingOffice office = optOffice.get(); HBox box = new HBox(); box.setSpacing(15); box.setLayoutX(2*FRAME_BORDER); box.setLayoutY(CLOSE_BTN_Y_POS); Text label = new Text(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.AutomaticTradingOverviewDialog.office.manager", new Object[]{}, locale.getCurrentLocal())); label.getStyleClass().add("dialogText"); box.getChildren().add(label); OpenPatricianLargeWaxButton hireButton = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.AutomaticTradingOverviewDialog.hire", new Object[]{}, locale.getCurrentLocal())); hireButton.getStyleClass().add("actionButton"); hireButton.textProperty().bind(new HireButtonTextBinding(office)); hireButton.onActionProperty().bind(new HireActionBinding(office)); box.getChildren().add(hireButton); getContent().add(box); } private Table createModel() {
@PostConstruct private void initializeDialog() { loaner = (LoanerState) loanerService.findLoaner(city.getCity()); setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.notice.NoticeBoardFactory.takeLoan", new Object[]{}, locale.getCurrentLocal())); addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.dialogSubheading", "introText"); for (final ILoanProposal proposal : loaner.getLoanProposals()) { int amount = proposal.getAmount(); int payback = (int) (amount * proposal.getInterest()); int duration = proposal.getDurationInWeeks(); String interest = String.format("%.1f", (proposal.getInterest() - 1) * 100); final DecoratedText entry = addDecoratedText("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.loanProposal", "proposal", amount, duration, payback, interest); loans.add(entry); entry.setOnMouseReleased(mouseEvent -> { selectedProposal.setValue(proposal); deactivateAll(); entry.applyStyle(SELECTED_STYLE); }); entry.applyStyle(DEFAULT_NON_SELECTED_STYLE); } final OpenPatricianLargeWaxButton acceptBtn = addActionButton("ch.sahits.game.openpatrician.display.dialog.LoanerTakeLoanDialog.btnLabel", "actionBtn"); acceptBtn.setDisable(true); selectedProposal.addListener((observableValue, oldProposal, newProposal) -> { if (newProposal != null) { acceptBtn.setDisable(false); } }); acceptBtn.setOnAction(createAcceptHandler()); } private void deactivateAll() {
s = messageSource.getMessage(buttonTemplate.getLabelKey(), template.getMessageArgs(), locale.getCurrentLocal()); if (buttonTemplate.isLargeButton()) { OpenPatricianLargeWaxButton btn = new OpenPatricianLargeWaxButton(s); btn.getStyleClass().add("actionButton"); btn.setOnAction((evt) -> { try { buttonTemplate.getAction().run();
@Subscribe public void handleBidLevelChange(AuctionBidLevel change) { currentBidLevel.setValue(change.getNewLevel()); if (!change.getBidder().equals(city.getPlayer())) { auctionBtn.setDisable(false); } // update bid labels int index = dialogHelper.removeById(box, "noBid"); if (index < 0) { index = dialogHelper.removeById(box, "currentBid"); } addCurrentBidInformation(box, change.getAuction(), index); index = dialogHelper.removeById(box, "bidLevel-"+change.getOldLevel()); box.getChildren().remove(index); addBidLevelCountDown(box, change.getAuction(), index); if (change.getNewLevel() == EBidLevel.DONE) { auctionBtn.setVisible(false); clientEventBus.unregister(this); } else { String label = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.AuctionGuildDialog.nextBid", new Object[]{change.getAuction().getCurrentBid() + AuctionEngine.BID_DELTA}, locale.getCurrentLocal()); auctionBtn.setText(label); } }
OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(template); action.getStyleClass().add("actionButton"); action.setId("donateButton"); selectionBox.setLayoutY(CLOSE_BTN_Y_POS - 50); getContent().add(selectionBox); action.setOnAction((e) -> { Treasury treasury = (Treasury) cityHallAccessor.getCityHall(city.getCity()).getTreasury(); final int donations = moneyTransfer.getAmount();
acceptBtn.setDisable(true); selectedDebt.addListener((observableValue, oldDebt, newDebt) -> { if (newDebt != null) { acceptBtn.setDisable(false); acceptBtn.setOnAction(createAcceptHandler());
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.TownInfoNotice.title", new Object[]{}, locale.getCurrentLocal())); ICity town = city.getCity(); IPlayer player = city.getPlayer(); resetContent(town, player); final int actionButtonX = (WIDTH - 124) / 2; final OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.cityhall.TownInfoNotice.petition", new Object[]{}, locale.getCurrentLocal())); action.getStyleClass().add("actionButton"); action.setOnAction(getAction(box, action)); action.setLayoutX(actionButtonX); action.setLayoutY(CLOSE_BTN_Y_POS - 24); action.setDisable(!canPosePetition(town, player)); // should be disabled when the petition cannot be posed getContent().addAll(action); clientServerEventBus.register(this); timerEventBus.register(this); }
OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(template); action.getStyleClass().add("actionButton"); action.setId("withdrawlButton"); selectionBox.getChildren().addAll(moneyTransfer, action); selectionBox.setLayoutX(100); selectionBox.setLayoutY(CLOSE_BTN_Y_POS - 50); getContent().add(selectionBox); action.setOnAction((evt) -> { try { final int withdrawl = moneyTransfer.getAmount();
acceptBtn.setDisable(true); selectedRequest.addListener((observableValue, oldRequest, newRequest) -> { if (newRequest != null) { acceptBtn.setDisable(false); acceptBtn.setOnAction(createAcceptHandlerPage1());
private void initializeDissolveConvoyDialog(IConvoy vessel) { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.ConvoyDialog.dissolveTitle", new Object[]{}, locale.getCurrentLocal())); String template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.ConvoyDialog.areYouSure", new Object[]{vessel.getName()}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); VBox box = new VBox(text); final int actionButtonX = (WIDTH - 124) / 2; String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.ConvoyDialog.dissolve", new Object[]{}, locale.getCurrentLocal()); final OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(s); action.getStyleClass().add("actionButton"); action.setId("dissolve"); ICity city = viewState.getCurrentCityProxy().get().getCity(); action.setOnAction(dissolve(vessel, city)); action.setLayoutX(actionButtonX); action.setLayoutY(CLOSE_BTN_Y_POS - 24); box.setLayoutX(50); box.setLayoutY(CLOSE_BTN_Y_POS - 500); getContent().addAll(box, action); }
auctionBtn = new OpenPatricianLargeWaxButton(s); auctionBtn.getStyleClass().add("actionButton"); auctionBtn.setId("auctionButton"); Pane centeredAuction = dialogHelper.center(auctionBtn); auctionBtn.setOnAction(event -> { try { auctionBtn.setDisable(true); EBidLevel current = currentBidLevel.get(); EBidLevel next = nextAuction.getBiddingPlayer() == null ? EBidLevel.INITIAL : calculateNextBidLevel(current);
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageOne.title", new Object[]{informant.getName()}, locale.getCurrentLocal())); String loadedText = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageOne.dialog", new Object[0], locale.getCurrentLocal()); HashMap<String, Object> parameters = new HashMap<>(); final int price = informant.getPrice(city.getPlayer()); parameters.put("price", price); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, parameters); final OpenPatricianLargeWaxButton acceptButton = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernInformantDialogPageOne.buy", new Object[]{}, locale.getCurrentLocal())); acceptButton.getStyleClass().add("actionButton"); int BUTTON_X = (WIDTH - 124) / 2; acceptButton.setLayoutX(BUTTON_X); int LOWER_BUTTON_Y = CLOSE_BTN_Y_POS - 24; acceptButton.setLayoutY(LOWER_BUTTON_Y); acceptButton.setOnAction(mouseEvent -> { try { city.getPlayer().getCompany().updateCash(-price); clientEventBus.post(new ViewChangeEvent(MainGameView.class, EDialogType.TAVERN_INFORMANT_2)); } catch (RuntimeException e) { logger.error("Failed to accept informant offer", e); } }); getContent().addAll(dt, acceptButton); }
HBox hbox = new HBox(50); String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.ConvoyDialog.createPrivateConvoy", new Object[]{}, locale.getCurrentLocal()); OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(s); action.getStyleClass().add("actionButton"); action.setId("privateConvoy"); action.setOnAction(createPrivateConvoy(vessel)); hbox.getChildren().add(action); s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.sea.ConvoyDialog.createPublicConvoy", new Object[]{}, locale.getCurrentLocal()); action = new OpenPatricianLargeWaxButton(s); action.getStyleClass().add("actionButton"); action.setId("publicConvoy"); action.setOnAction(createPublicConvoy(vessel)); hbox.getChildren().add(action); box.getChildren().add(hbox);
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.JoinGuildDialog.title", new Object[]{}, locale.getCurrentLocal())); IHumanPlayer player = city.getPlayer(); ICity city = this.city.getCity(); int fee = guildService.getEntryFee(player); String template = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.JoinGuildDialog.text", new Object[]{city.getName(), player.getName(), player.getLastName(), fee}, locale.getCurrentLocal()); DecoratedText text = textFactory.createDecoratedText(template, new HashMap<>()); VBox box = new VBox(text); String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.JoinGuildDialog.joinBtn", new Object[]{}, locale.getCurrentLocal()); OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(s); action.getStyleClass().add("actionButton"); action.setId("joinGuild"); final int actionButtonX = (WIDTH - 124) / 2; action.setLayoutX(actionButtonX); action.setLayoutY(CLOSE_BTN_Y_POS - 24); action.setOnAction(joinGuild(player, city, fee)); box.setLayoutX(50); box.setLayoutY(CLOSE_BTN_Y_POS - 500); getContent().addAll(box, action); }
buyBrickBox.getChildren().addAll(text, minusIcon, nbBricks, plusIcon); box.getChildren().add(buyBrickBox); final OpenPatricianLargeWaxButton action = new OpenPatricianLargeWaxButton(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.buy", new Object[]{}, locale.getCurrentLocal())); action.getStyleClass().add("actionButton"); action.setId("action"); action.setOnAction(evt -> { try { if (numberOfBricks.get() > 0) {