/*
* UFO Saved Game Editor
* Copyright (C) 2010 Christopher Davoren
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.rubikscomplex.ufosge.resources;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import net.rubikscomplex.ufosge.data.Base;
/**
*
* @author Chris Davoren
*/
public class BaseBit {
public static final int NUM_BASEBITS = 54;
public static final int WIDTH = 32;
public static final int HEIGHT = 40;
public static final int INDEX_FLOOR = 0;
public static final int INDEX_HORIZONTAL_CONNECTOR = 7;
public static final int INDEX_VERTICAL_CONNECTOR = 8;
public static final int FACILITIES_OFFSET = 17;
protected static BaseBit[] cache = null;
public BufferedImage image;
protected void BaseBit() {
}
public static BaseBit[] loadBaseBits() throws IOException {
BaseBit[] baseBits = new BaseBit[NUM_BASEBITS];
for(int i = 0; i < NUM_BASEBITS; i++) {
baseBits[i] = new BaseBit();
// baseBits[i].image = ImageIO.read(new File(directory + File.separator + "basebit-" + i + ".png"));
baseBits[i].image = ImageIO.read(ResourceManager.getImageResource("basebit-" + i + ".png"));
}
cache = baseBits;
return baseBits;
}
public static BaseBit getBaseBit(int bitIndex) {
if (cache == null) {
return null;
}
return cache[bitIndex];
}
public static int getInternalImageIndex(int facilityType) {
switch(facilityType) {
case Base.FACILITY_ACCESS_LIFT: return FACILITIES_OFFSET;
case Base.FACILITY_LIVING_QUARTERS: return FACILITIES_OFFSET + 1;
case Base.FACILITY_LABORATORY: return FACILITIES_OFFSET + 2;
case Base.FACILITY_WORKSHOP: return FACILITIES_OFFSET + 3;
case Base.FACILITY_SMALL_RADAR: return FACILITIES_OFFSET + 4;
case Base.FACILITY_LARGE_RADAR: return FACILITIES_OFFSET + 5;
case Base.FACILITY_MISSILE_DEFENSE: return FACILITIES_OFFSET + 6;
case Base.FACILITY_GENERAL_STORES: return FACILITIES_OFFSET + 7;
case Base.FACILITY_ALIEN_CONT: return FACILITIES_OFFSET + 8;
case Base.FACILITY_LASER_DEFENSE: return FACILITIES_OFFSET + 9;
case Base.FACILITY_PLASMA_DEFENSE: return FACILITIES_OFFSET + 10;
case Base.FACILITY_FUSION_DEFENSE: return FACILITIES_OFFSET + 11;
case Base.FACILITY_GRAV_SHIELD: return FACILITIES_OFFSET + 12;
case Base.FACILITY_MIND_SHIELD: return FACILITIES_OFFSET + 13;
case Base.FACILITY_PSIONIC_LAB: return FACILITIES_OFFSET + 14;
case Base.FACILITY_HYPERWAVE: return FACILITIES_OFFSET + 15;
case Base.FACILITY_HANGAR_TL: return -1;
case Base.FACILITY_HANGAR_TR: return -1;
case Base.FACILITY_HANGAR_BL: return -1;
case Base.FACILITY_HANGAR_BR: return -1;
default: return -1;
}
}
public static int getExternalImageIndex(int facilityType) {
switch(facilityType) {
case Base.FACILITY_ACCESS_LIFT: return 2;
case Base.FACILITY_LIVING_QUARTERS: return 1;
case Base.FACILITY_LABORATORY: return 1;
case Base.FACILITY_WORKSHOP: return 1;
case Base.FACILITY_SMALL_RADAR: return 2;
case Base.FACILITY_LARGE_RADAR: return 1;
case Base.FACILITY_MISSILE_DEFENSE: return 2;
case Base.FACILITY_GENERAL_STORES: return 1;
case Base.FACILITY_ALIEN_CONT: return 1;
case Base.FACILITY_LASER_DEFENSE: return 3;
case Base.FACILITY_PLASMA_DEFENSE: return 3;
case Base.FACILITY_FUSION_DEFENSE: return 3;
case Base.FACILITY_GRAV_SHIELD: return 2;
case Base.FACILITY_MIND_SHIELD: return 2;
case Base.FACILITY_PSIONIC_LAB: return 1;
case Base.FACILITY_HYPERWAVE: return 2;
case Base.FACILITY_HANGAR_TL: return 9;
case Base.FACILITY_HANGAR_TR: return 10;
case Base.FACILITY_HANGAR_BL: return 11;
case Base.FACILITY_HANGAR_BR: return 12;
default: return -1;
}
}
public static int getOverlayImageIndex(int facilityType) {
switch(facilityType) {
case Base.FACILITY_ACCESS_LIFT: return 5;
case Base.FACILITY_LIVING_QUARTERS: return 4;
case Base.FACILITY_LABORATORY: return 4;
case Base.FACILITY_WORKSHOP: return 4;
case Base.FACILITY_SMALL_RADAR: return 4;
case Base.FACILITY_LARGE_RADAR: return 4;
case Base.FACILITY_MISSILE_DEFENSE: return 5;
case Base.FACILITY_GENERAL_STORES: return 4;
case Base.FACILITY_ALIEN_CONT: return 4;
case Base.FACILITY_LASER_DEFENSE: return 6;
case Base.FACILITY_PLASMA_DEFENSE: return 6;
case Base.FACILITY_FUSION_DEFENSE: return 6;
case Base.FACILITY_GRAV_SHIELD: return 5;
case Base.FACILITY_MIND_SHIELD: return 5;
case Base.FACILITY_PSIONIC_LAB: return 4;
case Base.FACILITY_HYPERWAVE: return 5;
case Base.FACILITY_HANGAR_TL: return 13;
case Base.FACILITY_HANGAR_TR: return 14;
case Base.FACILITY_HANGAR_BL: return 15;
case Base.FACILITY_HANGAR_BR: return 16;
default: return -1;
}
}
}