ResourceType.java

// <editor-fold defaultstate="collapsed" desc="license">
/*
 * Copyright (c) 2009, Karl H. Beckers
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * * Neither the name of the <ORGANIZATION> nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 **/
// </editor-fold>
package net.jarre_de_the.griffin.file;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author charly4711
 */
public enum ResourceType {

    BMP(1, "bmp", ContentType.BINARY, "Windows BMP file"),
    TGA(3, "tga", ContentType.BINARY, "TGA image format"),
    WAV(4, "wav", ContentType.BINARY, "WAV sound file"),
    PLT(6, "plt", ContentType.BINARY, "Bioware Packed Layered Texture, used for player character skins, allows for multiple color layers"),
    INI(7, "ini", ContentType.INI, "Windows INI file format"),
    TXT(10, "txt", ContentType.TEXT, "Text file"),
    MDL(2002, "mdl", ContentType.MDL, "Aurora model"),
    NSS(2009, "nss", ContentType.TEXT, "NWScript Source"),
    NCS(2010, "ncs", ContentType.BINARY, "NWScript Compiled Script"),
    ARE(2012, "are", ContentType.GFF, "BioWare Aurora Engine Area file. Contains information on what tiles are located in an area, as well as other static area properties that cannot change via scripting. For each .are file in a .mod, there must also be a corresponding .git and .gic file having the same ResRef."),
    SET(2013, "set", ContentType.INI, "BioWare Aurora Engine Tileset"),
    IFO(2014, "ifo", ContentType.GFF, "Module Info File. See the IFO Format document."),
    BIC(2015, "bic", ContentType.GFF, "Character/Creature"),
    WOK(2016, "wok", ContentType.MDL, "Walkmesh"),
    TWODA(2017, "2da", ContentType.TWODA, "2-D Array"), // bioware defines as TEXT
    TXI(2022, "txi", ContentType.TEXT, "Extra Texture Info"),
    GIT(2023, "git", ContentType.GFF, "Game Instance File. Contains information for all object instances in an area, and all area properties that can change via scripting."),
    UTI(2025, "uti", ContentType.GFF, "Item Blueprint"),
    UTC(2027, "utc", ContentType.GFF, "Creature Blueprint"),
    DLG(2029, "dlg", ContentType.GFF, "Conversation File"),
    ITP(2030, "itp", ContentType.GFF, "Tile/Blueprint Palette File"),
    UTT(2032, "utt", ContentType.GFF, "Trigger Blueprint"),
    DDS(2033, "dds", ContentType.BINARY, "Compressed texture file"),
    UTS(2035, "uts", ContentType.GFF, "Sound Blueprint"),
    LTR(2036, "ltr", ContentType.BINARY, "Letter-combo probability info for name generation"),
    GFF(2037, "gff", ContentType.GFF, "Generic File Format. Used when undesirable to create a new file extension for a resource, but the resource is a GFF. (Examples of GFFs include itp, utc, uti, ifo, are, git)"),
    FAC(2038, "fac", ContentType.GFF, "Faction File"),
    UTE(2040, "ute", ContentType.GFF, "Encounter Blueprint"),
    UTD(2042, "utd", ContentType.GFF, "Door Blueprint"),
    UTP(2044, "utp", ContentType.GFF, "Placeable Object Blueprint"),
    DFT(2045, "dft", ContentType.INI, "Default Values file. Used by area properties dialog"),
    GIC(2046, "gic", ContentType.GFF, "Game Instance Comments. Comments on instances are not used by the game, only the toolset, so they are stored in a gic instead of in the git with the other instance properties."),
    GUI(2047, "gui", ContentType.GFF, "Graphical User Interface layout used by game"),
    UTM(2051, "utm", ContentType.GFF, "Store/Merchant Blueprint"),
    DWK(2052, "dwk", ContentType.MDL, "Door walkmesh"),
    PWK(2053, "pwk", ContentType.MDL, "Placeable Object walkmesh"),
    JRL(2056, "jrl", ContentType.GFF, "Journal File"),
    UTW(2058, "utw", ContentType.GFF, "Waypoint Blueprint. See Waypoint GFF document."),
    SSF(2060, "ssf", ContentType.BINARY, "Sound Set File. See Sound Set File Format document"),
    NDB(2064, "ndb", ContentType.BINARY, "Script Debugger File"),
    PTA(2065, "ptm", ContentType.GFF, "Plot Manager file/Plot Instance"),
    PTT(2066, "ptt", ContentType.GFF, "Plot Wizard Blueprint");

    private static final Logger LOGGER = LoggerFactory.getLogger(ResourceType.class);

    private final int id;
    private final String extension;
    private final ContentType contentType;
    private final String description;

    private ResourceType(int resType, String extension, ContentType contentType, String description) {
        this.id = resType;
        this.extension = extension;
        this.contentType = contentType;
        this.description = description;
    }

    public int id() {
        return id;
    }

    public String extension() {
        return extension;
    }

    public ContentType contentType() {
        return contentType;
    }

    public String description() {
        return description;
    }

    public static ResourceType getResourceTypeById(int id) {
        ResourceType r = ResourceType.BMP;
        for (ResourceType rt : ResourceType.values()) {
            if (rt.id() == id) {
                r = rt;
                return r;
            }
        }
        LOGGER.debug("Error finding Resource Type by id: " + id
                + ", keeping default BMP type.");
        return r;
    }
}