package com.lucasdnd.ags.gameplay;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;
import com.lucasdnd.ags.gameplay.market.MarketConsole;
import com.lucasdnd.ags.map.OffsetUtil;
import com.lucasdnd.ags.system.GameSystem;
import com.lucasdnd.ags.system.MainState;
import com.lucasdnd.ags.ui.ConsoleMiniPanel;
import com.lucasdnd.ags.ui.MiniPanel;
public class Console extends Asset {
public Console(int id, MarketConsole placingMarketAsset) throws SlickException {
super(id, placingMarketAsset);
// Mini Panel
float miniPanelHeight = MiniPanel.topBodyMargin + MiniPanel.lineSize*3;
miniPanel = new ConsoleMiniPanel(0f, 0f, 380f, miniPanelHeight, this);
}
/**
* Update
*/
public void update(GameContainer container, StateBasedGame game, int delta, Input input,
boolean leftMouseClicked, boolean leftMouseDown, int mouseX, int mouseY, Business business,
MainState mainState, boolean isShiftDown) throws SlickException {
// Super update
super.update(container, game, delta, input, leftMouseClicked, leftMouseDown, mouseX, mouseY, business, mainState);
// Update the Mini Panel
((ConsoleMiniPanel)miniPanel).update(container, game, delta, mainState, business, leftMouseClicked, leftMouseDown, mouseX, mouseY, isShiftDown);
}
/**
* Render
*/
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
// Draw only the first Sprite
// If the Asset is being moved, we ghost the current image out
if(isBeingMoved) {
animation[facingDirection].getImage(0).draw(
xSpriteOffset + (float)container.getInput().getMouseX() / GameSystem.globalScale,
ySpriteOffset + (float)container.getInput().getMouseY() / GameSystem.globalScale,
new Color(255, 255, 255, 0.5f));
} else {
animation[facingDirection].getImage(0).draw(xPos + OffsetUtil.getPreciseOffset(xOffset) + xSpriteOffset, yPos + OffsetUtil.getPreciseOffset(yOffset) + ySpriteOffset);
}
}
/**
* Consoles are not physically represented (they're attached to Tables). So their Click methods
* do nothing.
*/
@Override
public boolean gotLeftClicked(boolean leftMouseClicked, int mouseX, int mouseY) {
return false;
}
/**
* Consoles are not physically represented (they're attached to Tables). So their Click methods
* do nothing.
*/
@Override
public boolean gotRightClicked(boolean rightMouseClicked, int mouseX, int mouseY) {
return false;
}
public MarketConsole getReferringMarketConsole() {
return (MarketConsole)super.getReferringMarketAsset();
}
}