/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.preui.objects.gui.misc;
import java.util.ArrayList;
import java.util.HashMap;
import transientlibs.objects.general.ImageSlot;
import transientlibs.preui.objects.gui.interfaces.IImage;
/**
*
* @author kibertoad
*/
public class ViewInfo {
//used for multitile creatures
//public ImageSections cutImage = null;
public ArrayList<ImageSlot> staticImages = new ArrayList<ImageSlot>();
public ArrayList<ImageSections> cutImages = new ArrayList<ImageSections>();
//see numpad numbers for directions
public HashMap<String, IImage> images = new HashMap<String, IImage>();
//public HashMap<String, Animation> animations = new HashMap<String, Animation>();
public ViewInfo() {
for (int i = 0; i < 10; i++) {
staticImages.add(new ImageSlot());
cutImages.add(new ImageSections());
}
}
public void addDirectionImage(int direction, IImage setImage) {
staticImages.get(direction).referencedImages = setImage;
//cutImages.get(direction).cutFromImage(setImage);
}
public void addCustomImage(String setKey, IImage setImage) {
images.put(setKey, setImage);
}
public void copyImage(int fromIndex, int toIndex) {
//staticImages.get(toIndex).referencedImages = staticImages.get(fromIndex).referencedImages;
addDirectionImage(toIndex, staticImages.get(fromIndex).referencedImages);
}
public void copyImageIfNull(int fromIndex, int toIndex) {
if (staticImages.get(toIndex).referencedImages == null) {
copyImage(fromIndex, toIndex);
//staticImages.get(toIndex).referencedImages = staticImages.get(fromIndex).referencedImages;
}
}
public void tryFillLeftEmptySlot(int byIndex) {
if (staticImages.get(byIndex).referencedImages == null) {
if (staticImages.get(4).referencedImages != null) {
copyImage(4, byIndex);
} else if (staticImages.get(5).referencedImages != null) {
copyImage(5, byIndex);
} else if (staticImages.get(6).referencedImages != null) {
copyImage(6, byIndex);
}
}
}
public void tryFillRightEmptySlot(int byIndex) {
if (staticImages.get(byIndex).referencedImages == null) {
if (staticImages.get(6).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(6).referencedImages;
copyImage(6, byIndex);
} else if (staticImages.get(5).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(5).referencedImages;
copyImage(5, byIndex);
} else if (staticImages.get(4).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(4).referencedImages;
copyImage(4, byIndex);
}
}
}
public void tryFillCenterEmptySlot(int byIndex) {
if (staticImages.get(byIndex).referencedImages == null) {
if (staticImages.get(5).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(5).referencedImages;
copyImage(5, byIndex);
} else if (staticImages.get(6).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(6).referencedImages;
copyImage(6, byIndex);
} else if (staticImages.get(4).referencedImages != null) {
//staticImages.get(byIndex).referencedImages = staticImages.get(4).referencedImages;
copyImage(4, byIndex);
}
}
}
public void fillEmptySlots() {
tryFillLeftEmptySlot(7);
tryFillLeftEmptySlot(4);
tryFillLeftEmptySlot(1);
tryFillRightEmptySlot(9);
tryFillRightEmptySlot(6);
tryFillRightEmptySlot(3);
tryFillCenterEmptySlot(8);
tryFillCenterEmptySlot(2);
}
public IImage getDirectionImages(int i) {
return staticImages.get(i).referencedImages;
}
}