-
Notifications
You must be signed in to change notification settings - Fork 0
Create TextPopup and TextImagePopup #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5c5329f
feat: Create TextPopup
mhawryluk 5f1ec26
style: TextPopup revamp
mhawryluk a138e0e
refactor: rename controller to modelview
mhawryluk 68651a9
feat: Close textpopup on button click
mhawryluk 6d6f7db
style: Add button effect on hover
mhawryluk 47dc4cb
style: Change fontsize depending on text length
mhawryluk ffb063b
chore: Replace PointsEarnedPopup with a TextPopup
mhawryluk 2365995
refactor: enable setting button callback from PopupController
mhawryluk c9de7cd
chore: Remove old asset
mhawryluk 7b4dd06
feat: Create a popup for showing an Image and text
mhawryluk 7cc3035
chore: Turn points popup into TextImagePopup
mhawryluk 19b6a62
refactor: Delete parameter module specifications in setButtonOnClick
mhawryluk 0ad5696
refactor
mhawryluk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package io.rpg.view.popups; | ||
|
|
||
| import io.rpg.viewmodel.TextImagePopupViewModel; | ||
| import io.rpg.viewmodel.TextPopupViewModel; | ||
| import javafx.event.EventHandler; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Group; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.paint.Color; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| public class TextImagePopup extends Scene { | ||
|
|
||
| private final TextImagePopupViewModel viewModel; | ||
|
|
||
| public TextImagePopup(String text, Image image, String backgroundPath, String buttonPath) { | ||
| this(text, image); | ||
| viewModel.setBackgroundImage(backgroundPath); | ||
| viewModel.setOkButtonImage(buttonPath); | ||
| } | ||
|
|
||
| public TextImagePopup(String text, Image image) { | ||
| super(new Group(), Color.TRANSPARENT); | ||
|
|
||
| FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(TextPopupViewModel.class.getResource("text-image-popup-view.fxml"))); | ||
| Parent root = null; | ||
|
|
||
| try { | ||
| root = loader.load(); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| this.setRoot(root); | ||
|
|
||
| viewModel = loader.getController(); | ||
| viewModel.setText(text); | ||
| viewModel.setImage(image); | ||
| this.setFill(Color.TRANSPARENT); | ||
| } | ||
|
|
||
| public void setButtonCallback(EventHandler<? super MouseEvent> callback) { | ||
| this.viewModel.setButtonOnClick(callback); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package io.rpg.view.popups; | ||
|
|
||
| import io.rpg.viewmodel.TextPopupViewModel; | ||
| import javafx.event.EventHandler; | ||
| import javafx.fxml.FXMLLoader; | ||
| import javafx.scene.Group; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.paint.Color; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Objects; | ||
|
|
||
| public class TextPopup extends Scene { | ||
|
|
||
| private final TextPopupViewModel viewModel; | ||
|
|
||
| public TextPopup(String text, String backgroundPath, String buttonPath) { | ||
| this(text); | ||
| viewModel.setBackgroundImage(backgroundPath); | ||
| viewModel.setOkButtonImage(buttonPath); | ||
| } | ||
|
|
||
| public TextPopup(String text) { | ||
| super(new Group(), Color.TRANSPARENT); | ||
|
|
||
| FXMLLoader loader = new FXMLLoader(Objects.requireNonNull(TextPopupViewModel.class.getResource("text-popup-view.fxml"))); | ||
| Parent root = null; | ||
|
|
||
| try { | ||
| root = loader.load(); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
| this.setRoot(root); | ||
kkafar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| viewModel = loader.getController(); | ||
| viewModel.setText(text); | ||
| this.setFill(Color.TRANSPARENT); | ||
| } | ||
|
|
||
| public void setButtonCallback(EventHandler<? super MouseEvent> callback) { | ||
| this.viewModel.setButtonOnClick(callback); | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
src/main/java/io/rpg/viewmodel/TextImagePopupViewModel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package io.rpg.viewmodel; | ||
|
|
||
| import javafx.event.EventHandler; | ||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.image.ImageView; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.layout.Pane; | ||
|
|
||
| public class TextImagePopupViewModel { | ||
|
|
||
| @FXML private Label label; | ||
| @FXML private Pane backgroundPane; | ||
| @FXML private ImageView backgroundImage; | ||
| @FXML private Button okButton; | ||
| @FXML private ImageView imageView; | ||
|
|
||
|
|
||
| public void setText(String text) { | ||
| if (text.length() < 40) setTextSize(25); | ||
| else if (text.length() < 120) setTextSize(19); | ||
| else setTextSize(13); | ||
| label.setText(text); | ||
| } | ||
|
|
||
| public void setImage(Image image) { | ||
| imageView.setImage(image); | ||
| } | ||
|
|
||
| public void setTextSize(int size) { | ||
| label.setStyle("-fx-font-family: Monospaced; -fx-text-fill: white; -fx-font-weight: bold; -fx-font-size: " + size); | ||
| } | ||
|
|
||
| public void setBackgroundImage(String url) { | ||
| Image image = new Image(url); | ||
| backgroundImage.setImage(image); | ||
| } | ||
|
|
||
| public void setOkButtonImage(String url) { | ||
| ImageView imageView = new ImageView(url); | ||
| okButton.setGraphic(imageView); | ||
| } | ||
|
|
||
| public void setButtonOnClick(EventHandler<? super MouseEvent> callback) { | ||
| okButton.setOnMouseClicked(callback); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package io.rpg.viewmodel; | ||
|
|
||
| import javafx.event.EventHandler; | ||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.image.Image; | ||
| import javafx.scene.image.ImageView; | ||
| import javafx.scene.input.MouseEvent; | ||
| import javafx.scene.layout.*; | ||
|
|
||
| public class TextPopupViewModel { | ||
|
|
||
| @FXML private Label label; | ||
| @FXML private Pane backgroundPane; | ||
| @FXML private ImageView backgroundImage; | ||
| @FXML private Button okButton; | ||
|
|
||
|
|
||
| public void setText(String text) { | ||
| if (text.length() < 50) setTextSize(25); | ||
| else if (text.length() < 190) setTextSize(19); | ||
| else setTextSize(13); | ||
| label.setText(text); | ||
| } | ||
|
|
||
| public void setTextSize(int size) { | ||
| label.setStyle("-fx-font-family: Monospaced; -fx-text-fill: white; -fx-font-weight: bold; -fx-font-size: " + size); | ||
| } | ||
|
|
||
| public void setBackgroundImage(String url) { | ||
| Image image = new Image(url); | ||
| backgroundImage.setImage(image); | ||
| } | ||
|
|
||
| public void setOkButtonImage(String url) { | ||
| ImageView imageView = new ImageView(url); | ||
| okButton.setGraphic(imageView); | ||
| } | ||
|
|
||
| public void setButtonOnClick(EventHandler<? super MouseEvent> callback) { | ||
| okButton.setOnMouseClicked(callback); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .button:hover { | ||
| -fx-text-fill: white; | ||
| } |
15 changes: 0 additions & 15 deletions
15
src/main/resources/io/rpg/viewmodel/points-earned-view.fxml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.