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.MarketMisc;
import com.lucasdnd.ags.gameplay.market.MarketShelf;
import com.lucasdnd.ags.gameplay.market.MarketTable;
import com.lucasdnd.ags.gameplay.market.MarketTv;
import com.lucasdnd.ags.system.MainState;
public class BuyFurnituresPanel extends Panel {
private BuyFurnituresList buyFurnituresList; // The actual list
public BuyFurnituresPanel(String title, float xPos, float yPos, float width, float height,
Business business, ArrayList<MarketShelf> marketShelves, ArrayList<MarketTable> marketTables,
ArrayList<MarketTv> marketTvs, ArrayList<MarketMisc> marketMiscs) 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.
buyFurnituresList = new BuyFurnituresList(xPos, yPos, width, height, business, marketShelves, marketTables, marketTvs, marketMiscs);
}
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
buyFurnituresList.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) {
buyFurnituresList.render(container, game, g, panelFont, disabledFont, shadowFont);
}
}
@Override
public void setVisible(boolean visible) {
this.visible = visible;
buyFurnituresList.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;
}
}