package com.lucasdnd.ags.ui; import org.newdawn.slick.Font; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; import org.newdawn.slick.state.StateBasedGame; import com.lucasdnd.ags.gameplay.Business; import com.lucasdnd.ags.gameplay.market.Market; import com.lucasdnd.ags.system.MainState; public class ViewGamesPanel extends Panel { private ViewGamesList viewGamesList; // The actual list /** * Constructor * @param title * @param xPos * @param yPos * @param width * @param height * @param marketGames * @throws SlickException */ public ViewGamesPanel(String title, float xPos, float yPos, float width, float height, Business business, BuyGamesList buyGamesList, Market market) throws SlickException { // Create the Panel super(title, xPos, yPos, width, height); // Then we create the List from the ListRows. Inside the List constructor, it already creates the Headers so no need to worry about that here. viewGamesList = new ViewGamesList(xPos, yPos, width, height, business, buyGamesList, market); } /** * Update. * @param container * @param game * @param delta * @param business * @param leftMouseClicked * @param mouseX * @param mouseY * @throws SlickException */ public void update(GameContainer container, StateBasedGame game, int delta, MainState mainState, Business business, boolean leftMouseClicked, boolean leftMouseDown, int mouseX, int mouseY, boolean isShiftDown) throws SlickException { // Updates the List viewGamesList.update(container, game, delta, mainState, business, leftMouseClicked, leftMouseDown, mouseX, mouseY, isShiftDown); } public void render(GameContainer container, StateBasedGame game, Graphics g, Font panelFont, Font disabledFont, Font shadowFont) throws SlickException { // Let the Panel render super.render(container, game, g, panelFont, shadowFont); // Render the List, only if the Panel is visible if(visible) { viewGamesList.render(container, game, g, panelFont, disabledFont, shadowFont); } } @Override public void setVisible(boolean visible) { this.visible = visible; viewGamesList.visible = visible; } public ViewGamesList getViewGamesList() { return viewGamesList; } public void setViewGamesList(ViewGamesList viewGamesList) { this.viewGamesList = viewGamesList; } @Override public boolean gotLeftClicked(boolean leftMouseClicked, int mouseX, int mouseY) { if((leftMouseClicked) && (mouseX >= xPos && mouseX <= xPos + width) && (mouseY >= yPos && mouseY <= yPos + height)) return true; return false; } @Override public boolean gotRightClicked(boolean rightMouseClicked, int mouseX, int mouseY) { if((rightMouseClicked) && (mouseX >= xPos && mouseX <= xPos + width) && (mouseY >= yPos && mouseY <= yPos + height)) return true; return false; } }