package com.lucasdnd.ags.ui;
import java.util.ArrayList;
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.MarketConsole;
import com.lucasdnd.ags.system.MainState;
public class BuyConsolesPanel extends Panel {
private BuyConsolesList buyConsolesList; // The actual list
public BuyConsolesPanel(String title, float xPos, float yPos, float width, float height, Business business, ArrayList<MarketConsole> marketConsoles) 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.
buyConsolesList = new BuyConsolesList(xPos, yPos, width, height, business, marketConsoles);
}
public void update(GameContainer container, StateBasedGame game, int delta, Business business, MainState mapState,
boolean leftMouseClicked, boolean leftMouseDown, int mouseX, int mouseY) throws SlickException {
// Updates the List
buyConsolesList.update(container, game, delta, business, mapState, leftMouseClicked, leftMouseDown, mouseX, mouseY);
}
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) {
buyConsolesList.render(container, game, g, panelFont, disabledFont, shadowFont);
}
}
@Override
public void setVisible(boolean visible) {
this.visible = visible;
buyConsolesList.visible = visible;
}
@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;
}
public BuyConsolesList getBuyConsolesList() {
return buyConsolesList;
}
public void setBuyConsolesList(BuyConsolesList buyConsolesList) {
this.buyConsolesList = buyConsolesList;
}
}