/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.preui.objects.gui.overlays;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import transientlibs.maps.container.TransientAssembledMap;
import transientlibs.maps.units.GenericUnit;
import transientlibs.maps.utils.coordcalculators.SingleScreenCoordsCalculator;
import transientlibs.preui.agents.rendering.GDXMapDrawAgent;
import transientlibs.preui.agents.rendering.GDXMapDrawAgentFixedCamera;
import transientlibs.processors.misc.ClickProcessor;
import transientlibs.preui.objects.gui.elements.ButtonGroup;
import transientlibs.preui.objects.gui.elements.TextInfo;
import transientlibs.preui.objects.gui.elements.TextMarker;
import transientlibs.preui.objects.gui.misc.RenderList;
import transientlibs.preui.objects.states.IState;
import transientlibs.preui.objects.states.UIHub;
import transientlibs.processors.misc.Detonator;
/**
*
* @author kibertoad
*/
public class MapOverlay extends UIHub {
public TextMarker back;
//public GAMETiledMapState state;
public TextInfo textTag;
//public RenderList elementList = new RenderList();
public ButtonGroup buttons;
public TransientAssembledMap map = null;
public SpriteBatch spritebatch;
public TextInfo mapPosition;
public GDXMapDrawAgentFixedCamera agent;
@Override
public void init(IState toState) {
GUIFile = "map.gui";
super.init(toState);
fillElementList();
agent = new GDXMapDrawAgentFixedCamera(map, toState, 0, 0);
disable();
}
public void init(IState toState, TransientAssembledMap setMap) {
GUIFile = "map.gui";
map = setMap;
init(toState);
//textTag = state.addInfo(350, 620, " ");
fillElementList();
agent = new GDXMapDrawAgentFixedCamera(map, toState, 0, 0);
//map.passTerrainToState(toState);
disable();
}
public void setMap(TransientAssembledMap mapToSet) {
map = mapToSet;
agent.setMap(map);
Detonator.INSTANCE.tileMovementCalculator.setMap(map);
map.recalcObjectPositions();
}
/**
* Has to be called before map is set
*/
public void setMapOffset(int setX, int setY) {
((SingleScreenCoordsCalculator) Detonator.INSTANCE.screenCoordsCalculator).mapOffsetX = setX;
((SingleScreenCoordsCalculator) Detonator.INSTANCE.screenCoordsCalculator).mapOffsetY = setY;
if (map != null) {
map.recalcObjectPositions();
}
agent.setOffset(setX, setY);
}
public void fillElementList() {
}
@Override
public void bindElements() {
mapPosition = getTextInfo("map");
}
public void render() {
if (isEnabled) {
agent.process();
}
}
@Override
public void disable() {
if (isEnabled) {
super.disable();
//elementList.disableList();
}
//textTag.setText(" ");
}
@Override
public void enable() {
super.enable();
map.recalcObjectPositions();
//elementList.enableList();
}
public void recalculateFOV(GenericUnit activeMerc) {
//activeMerc = MerchantsData.instance.roles.get(0).merc;
//int offsetX = (int) ((activeMerc.getMapCoords().getIntX() - agent.FOVGrid.screenWidthInTiles / 2) + 0);
//int offsetY = (int) ((activeMerc.getMapCoords().getIntY() - agent.FOVGrid.screenHeightInTiles / 2) + 0);
int offsetX = ((SingleScreenCoordsCalculator) Detonator.INSTANCE.screenCoordsCalculator).mapOffsetX;
int offsetY = ((SingleScreenCoordsCalculator) Detonator.INSTANCE.screenCoordsCalculator).mapOffsetY;
activeMerc.getFOV().updateFov();
this.agent.FOVGrid.recalculateGrid //(Gdx.graphics.getWidth()-player.getWidth()/2.0f, Gdx.graphics.getHeight()-player.getHeight()/2.0f);
(0, 0);
//(offsetX, offsetY);
}
//Click Processors
public class FocusClickedElement implements ClickProcessor {
public FocusClickedElement() {
}
@Override
public void process() {
}
}
}