Class MainFXMLController
java.lang.Object
it.polimi.ingsw.gc14.View.GUI.MainFXMLController
FXML controller for the main game scene.
Renders the board (upper/lower tribe and building card rows), player stats, the player's hand, and action buttons (skip, details).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.HBoxHBox holding the board slot and order cards.private ClientControllerClient controller for fetching game state and sending player actions.private javafx.scene.control.ButtonButton that opens the game details popup.Maps each player's username to their current food-value label in the side panel.Maps each player's username to their ordered list of card-type icon ImageViews.private javafx.scene.control.LabelLabel showing the current round number and game stage.private booleantruewhen the last received event was an error response.private javafx.scene.layout.HBoxHBox holding the lower tribe card row (and lower building stack).private javafx.scene.layout.HBoxRoot HBox containing all main scene elements.private javafx.scene.layout.HBoxHBox displaying the local player's card piles.Maps each player's username to their player-card VBox in the side panel.private javafx.scene.control.ScrollPaneScrollable container holding all player side-panel cards.private javafx.stage.PopupShared popup used for card previews and building selection.private javafx.scene.layout.HBoxHBox insidepopupthat holds the displayed card images.Maps each player's username to their current prestige-value label in the side panel.private javafx.scene.control.ButtonButton that disconnects and closes the client.private javafx.scene.control.ButtonButton that sends a skip-turn command.private javafx.scene.layout.HBoxHBox holding the upper tribe card row (and upper building stack). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddClip(javafx.scene.image.ImageView img) Binds a rounded-rectangle clip toimgso its corners are cropped.private voidaddHoverZoom(javafx.scene.Node node) Scalesnodeto 1.1× on hover and restores on exit; sets a hand cursor.private voidaddShadow(javafx.scene.Node node) Applies a drop-shadow tonodethat intensifies on hover.private javafx.scene.layout.VBoxbuildPlayerCard(Player player) Builds the side-panel card widget forplayerwith totem, stats, and card-type icons.private voidBuilds the full side panel from scratch, creating a player card for each connected player.private javafx.scene.layout.StackPanecreateCard(PlayableCard card, boolean withZoom, boolean withShadow, javafx.scene.layout.Region parent) Creates aStackPanefor a playable card, scaling its height to a fraction ofparent's scene.private javafx.scene.layout.StackPanecreateCardPopup(PlayableCard card, boolean withZoom, boolean withShadow) Creates a fixed-heightStackPanecard widget suitable for use inside the popup.private javafx.scene.layout.StackPanecreateOrder(String num) Creates aStackPanecontaining the order card image for a game ofnumplayers.private javafx.scene.layout.StackPanecreateSlot(Slot slot, boolean withZoom, boolean withShadow) Creates aStackPanefor a board slot, optionally overlaying the occupying player's totem.private voidRenders the top card of the lower building stack with a count badge; clicking opens the selection popup.private voiddrawMyHandList(ArrayList<? extends PlayableCard> cardList) Renders a single card-type pile in the hand area, or an invisible placeholder if the list is empty.private voidRenders the top card of the upper building stack with a count badge; clicking opens the selection popup.private ArrayList<PlayableCard> getPlayerCards(String username, String type) Returns a copy of the named card collection forusername.voidInitializes the scene: loads fonts, sets up the popup, and registers input listeners.private voidCreates and configures the shared card-preview popup container.private javafx.scene.image.ImageReturns a cachedImagefor the given classpathpath, loading it on first access.private voidShows the deck details/rules card in the popup.private voidopenPopup(ArrayList<? extends PlayableCard> cardList) Populates the popup with non-clickable card images and shows it.private voidopenPopupLowerBuilding(ArrayList<BuildingCard> cardList) Populates the popup with clickable lower-building cards; clicking one draws it via the controller.private voidopenPopupUpperBuilding(ArrayList<BuildingCard> cardList) Populates the popup with clickable upper-building cards; clicking one draws it via the controller.voidrender()Incrementally re-renders only the parts of the scene affected by the last network event.private voidSets the full-cover background image on the main HBox container.private voidClears the board area and orchestrates deck, order card, and slot-map rendering.private voidAdds the era-specific deck back image to the board.private voidClears and rebuilds the lower tribe row with click handlers for drawing, then appends the lower building stack.private voidClears and re-renders all seven card-type piles in the local player's hand area.private voidRenders the order card and overlays each player's totem at their proportional position.private voidAdds a clickable slot widget for each entry in the slot-player map.private voidClears and rebuilds the upper tribe row with click handlers for drawing, then appends the upper building stack.voidsetController(ClientController controller) Injects the client controller and wires up the skip-turn button action.voidsetError(boolean error) private voidCenters the popup over the current window and makes it visible.private voidUpdates food/prestige labels, current-player highlight, card-icon opacity, and plays error shake if needed.
-
Field Details
-
playerSide
private javafx.scene.control.ScrollPane playerSideScrollable container holding all player side-panel cards. -
mainHBox
private javafx.scene.layout.HBox mainHBoxRoot HBox containing all main scene elements. -
board
private javafx.scene.layout.HBox boardHBox holding the board slot and order cards. -
upperList
private javafx.scene.layout.HBox upperListHBox holding the upper tribe card row (and upper building stack). -
lowerList
private javafx.scene.layout.HBox lowerListHBox holding the lower tribe card row (and lower building stack). -
myHand
private javafx.scene.layout.HBox myHandHBox displaying the local player's card piles. -
skipBtn
private javafx.scene.control.Button skipBtnButton that sends a skip-turn command. -
detailsBtn
private javafx.scene.control.Button detailsBtnButton that opens the game details popup. -
quitBtn
private javafx.scene.control.Button quitBtnButton that disconnects and closes the client. -
infoText
private javafx.scene.control.Label infoTextLabel showing the current round number and game stage. -
foodLabels
-
prestigeLabels
-
playerCards
-
iconViews
-
popup
private javafx.stage.Popup popupShared popup used for card previews and building selection. -
popupCards
private javafx.scene.layout.HBox popupCardsHBox insidepopupthat holds the displayed card images. -
controller
Client controller for fetching game state and sending player actions. -
isError
private boolean isErrortruewhen the last received event was an error response. -
imageCache
-
-
Constructor Details
-
MainFXMLController
public MainFXMLController()
-
-
Method Details
-
setError
-
loadImage
Returns a cachedImagefor the given classpathpath, loading it on first access. -
setController
Injects the client controller and wires up the skip-turn button action.- Parameters:
controller- the client controller to use.
-
initialize
public void initialize()Initializes the scene: loads fonts, sets up the popup, and registers input listeners. -
render
public void render()Incrementally re-renders only the parts of the scene affected by the last network event. -
addClip
private void addClip(javafx.scene.image.ImageView img) Binds a rounded-rectangle clip toimgso its corners are cropped. -
addHoverZoom
private void addHoverZoom(javafx.scene.Node node) Scalesnodeto 1.1× on hover and restores on exit; sets a hand cursor. -
addShadow
private void addShadow(javafx.scene.Node node) Applies a drop-shadow tonodethat intensifies on hover. -
buildPlayerCard
Builds the side-panel card widget forplayerwith totem, stats, and card-type icons. -
createOrder
Creates aStackPanecontaining the order card image for a game ofnumplayers. -
createSlot
Creates aStackPanefor a board slot, optionally overlaying the occupying player's totem. -
createCard
private javafx.scene.layout.StackPane createCard(PlayableCard card, boolean withZoom, boolean withShadow, javafx.scene.layout.Region parent) Creates aStackPanefor a playable card, scaling its height to a fraction ofparent's scene. -
buildSidePanel
private void buildSidePanel()Builds the full side panel from scratch, creating a player card for each connected player. -
updateSidePanel
private void updateSidePanel()Updates food/prestige labels, current-player highlight, card-icon opacity, and plays error shake if needed. -
drawUpperBuilding
private void drawUpperBuilding()Renders the top card of the upper building stack with a count badge; clicking opens the selection popup. -
drawLowerBuilding
private void drawLowerBuilding()Renders the top card of the lower building stack with a count badge; clicking opens the selection popup. -
drawMyHandList
Renders a single card-type pile in the hand area, or an invisible placeholder if the list is empty. -
getPlayerCards
Returns a copy of the named card collection forusername. -
renderUpper
private void renderUpper()Clears and rebuilds the upper tribe row with click handlers for drawing, then appends the upper building stack. -
renderLower
private void renderLower()Clears and rebuilds the lower tribe row with click handlers for drawing, then appends the lower building stack. -
renderBackground
private void renderBackground()Sets the full-cover background image on the main HBox container. -
renderBoard
private void renderBoard()Clears the board area and orchestrates deck, order card, and slot-map rendering. -
renderDeck
private void renderDeck()Adds the era-specific deck back image to the board. -
renderOrder
private void renderOrder()Renders the order card and overlays each player's totem at their proportional position. -
renderSlotMap
private void renderSlotMap()Adds a clickable slot widget for each entry in the slot-player map. -
renderMyHand
private void renderMyHand()Clears and re-renders all seven card-type piles in the local player's hand area. -
initPopup
private void initPopup()Creates and configures the shared card-preview popup container. -
showPopup
private void showPopup()Centers the popup over the current window and makes it visible. -
openPopup
Populates the popup with non-clickable card images and shows it. -
openPopupUpperBuilding
Populates the popup with clickable upper-building cards; clicking one draws it via the controller. -
openPopupLowerBuilding
Populates the popup with clickable lower-building cards; clicking one draws it via the controller. -
openDetailsPopup
private void openDetailsPopup()Shows the deck details/rules card in the popup. -
createCardPopup
private javafx.scene.layout.StackPane createCardPopup(PlayableCard card, boolean withZoom, boolean withShadow) Creates a fixed-heightStackPanecard widget suitable for use inside the popup.
-