// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:08
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/commands/GifBuildCommand

package com.macromedia.generator.commands;

import com.macromedia.generator.api.Context;
import com.macromedia.generator.api.Script;
import com.macromedia.generator.app.*;
import java.io.File;
import java.util.Hashtable;
import java.util.Properties;

public class GifBuildCommand extends GenericCommand
{

    public GifBuildCommand()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        Boolean boolean1 = (Boolean)flashenvironment.get("GifInitialized");
        if(boolean1 != null && boolean1.booleanValue())
        {
            logError(flashenvironment, "MultiInit", null);
            return;
        }
        String s = context.apply(properties.getProperty("type", ""));
        String s1 = context.apply(properties.getProperty("loopcount", ""));
        String s2 = context.apply(properties.getProperty("width", ""));
        String s3 = context.apply(properties.getProperty("height", ""));
        String s4 = context.apply(properties.getProperty("dither", ""));
        String s5 = context.apply(properties.getProperty("smooth", ""));
        String s6 = context.apply(properties.getProperty("interlace", ""));
        String s7 = context.apply(properties.getProperty("transparent", ""));
        String s8 = context.apply(properties.getProperty("nogradients", ""));
        String s9 = context.apply(properties.getProperty("dithertype", ""));
        String s10 = context.apply(properties.getProperty("optcolors", ""));
        String s11 = context.apply(properties.getProperty("paletteoptions", ""));
        String s12 = context.apply(properties.getProperty("maxcolors", "64"));
        String s13 = context.apply(properties.getProperty("custompalette", ""));
        String s14 = context.apply(properties.getProperty("xquality", ""));
        Boolean boolean2 = new Boolean(s14.equalsIgnoreCase("false"));
        Boolean boolean3 = new Boolean(s.equalsIgnoreCase("Animated"));
        Boolean boolean4 = new Boolean(s4.equalsIgnoreCase("true"));
        Boolean boolean5 = new Boolean(s5.equalsIgnoreCase("true"));
        Boolean boolean6 = new Boolean(s6.equalsIgnoreCase("true"));
        Boolean boolean7 = new Boolean(s8.equalsIgnoreCase("true"));
        Boolean boolean8 = new Boolean(s10.equalsIgnoreCase("true"));
        Boolean boolean9 = Boolean.FALSE;
        Boolean boolean10 = Boolean.FALSE;
        Integer integer = new Integer(128);
        if(s7.equalsIgnoreCase("false"))
            boolean9 = Boolean.FALSE;
        else
        if(s7.equalsIgnoreCase("true") || s7.equalsIgnoreCase("Transparent"))
        {
            boolean9 = Boolean.TRUE;
            boolean10 = Boolean.TRUE;
        } else
        if(s7.equalsIgnoreCase(getResourceString(flashenvironment, "fast")))
        {
            boolean9 = Boolean.TRUE;
            boolean10 = Boolean.FALSE;
        } else
        {
            try
            {
                integer = new Integer(s7);
                boolean9 = Boolean.TRUE;
                boolean10 = Boolean.TRUE;
                if(integer.intValue() < 0)
                    throw new NumberFormatException();
                if(integer.intValue() > 255)
                    throw new NumberFormatException();
            }
            catch(NumberFormatException _ex)
            {
                logError(flashenvironment, "InvalTransparentValue", null);
                integer = new Integer(128);
            }
        }
        Integer integer1 = new Integer(0);
        Integer integer2 = new Integer(-1);
        Integer integer3 = new Integer(-1);
        Integer integer4 = new Integer(1);
        Integer integer5 = new Integer(0);
        Integer integer6 = new Integer(64);
        try
        {
            integer1 = new Integer(s1);
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalLoopCount", null);
        }
        try
        {
            if(!s12.equalsIgnoreCase("Default"))
                integer6 = new Integer(s12);
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "invalidmacColor", null);
            integer6 = new Integer(64);
        }
        if(!s2.equalsIgnoreCase("default"))
            try
            {
                if(Integer.valueOf(s2).intValue() > 0)
                    integer2 = new Integer(s2);
                else
                    logError(flashenvironment, "InvalWidth", null);
            }
            catch(NumberFormatException _ex)
            {
                logError(flashenvironment, "InvalWidth", null);
            }
        if(!s3.equalsIgnoreCase("default"))
            try
            {
                if(Integer.valueOf(s3).intValue() > 0)
                    integer3 = new Integer(s3);
                else
                    logError(flashenvironment, "InvalHeight", null);
            }
            catch(NumberFormatException _ex)
            {
                logError(flashenvironment, "InvalHeight", null);
            }
        try
        {
            if(s9.equalsIgnoreCase(getResourceString(flashenvironment, "None")) || s9 == "" || s9.equalsIgnoreCase("\u306A\u3057") || s9.equalsIgnoreCase("Kein") || s9.equalsIgnoreCase("Aucun") || s9.equalsIgnoreCase("Ninguna") || s9.equalsIgnoreCase("Nessuno") || s9.equalsIgnoreCase("Ingen") || s9.equalsIgnoreCase("Nenhum"))
                integer4 = new Integer(0);
            else
            if(s9.equalsIgnoreCase(getResourceString(flashenvironment, "Ordered")) || s9.equalsIgnoreCase("\u30C7\u30D5\u30A9\u30EB\u30C8") || s9.equalsIgnoreCase("Geordnet") || s9.equalsIgnoreCase("Ordonn\351") || s9.equalsIgnoreCase("Ordenada") || s9.equalsIgnoreCase("Ordinato") || s9.equalsIgnoreCase("Ordnad") || s9.equalsIgnoreCase("Ordenado"))
                integer4 = new Integer(1);
            else
            if(s9.equalsIgnoreCase(getResourceString(flashenvironment, "Diffusion")) || s9.equalsIgnoreCase("\u62E1\u6563") || s9.equalsIgnoreCase("Diffus") || s9.equalsIgnoreCase("Difusi\363n") || s9.equalsIgnoreCase("Diffusione") || s9.equalsIgnoreCase("Difuso"))
            {
                integer4 = new Integer(2);
            } else
            {
                logError(flashenvironment, "InvalDitherType", null);
                integer4 = new Integer(2);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalDitherType", null);
        }
        try
        {
            if(s11.equalsIgnoreCase(getResourceString(flashenvironment, "Web 216")) || s11.equalsIgnoreCase("Webbs\344kra 216") || s11.equalsIgnoreCase("Web 216 \u8272") || s11 == "")
                integer5 = new Integer(0);
            else
            if(s11.equalsIgnoreCase(getResourceString(flashenvironment, "Adaptive")) || s11.equalsIgnoreCase("\u30A2\u30C0\u30D7\u30C6\u30A3\u30D6") || s11.equalsIgnoreCase("Adaptiv") || s11.equalsIgnoreCase("Adaptable") || s11.equalsIgnoreCase("Adattata") || s11.equalsIgnoreCase("Adaptiva") || s11.equalsIgnoreCase("Adaptativo"))
                integer5 = new Integer(1);
            else
            if(s11.equalsIgnoreCase(getResourceString(flashenvironment, "Web Snap Adaptive")) || s11.equalsIgnoreCase("Web Snap \u30A2\u30C0\u30D7\u30C6\u30A3\u30D6") || s11.equalsIgnoreCase("Adaptive Web Snap") || s11.equalsIgnoreCase("Web Snap adaptiv") || s11.equalsIgnoreCase("Web Snap Adaptable") || s11.equalsIgnoreCase("Adattata Web Snap ") || s11.equalsIgnoreCase("Webbs\344kra adaptiva") || s11.equalsIgnoreCase("Adaptativo Ajustar \340 Web"))
                integer5 = new Integer(2);
            else
            if(s11.equalsIgnoreCase(getResourceString(flashenvironment, "Custom")) || s11.equalsIgnoreCase("\u30AB\u30B9\u30BF\u30E0") || s11.equalsIgnoreCase("Benutzerdefiniert") || s11.equalsIgnoreCase("Personnalis\351e") || s11.equalsIgnoreCase("Personalizada") || s11.equalsIgnoreCase("Personalizzata") || s11.equalsIgnoreCase("Anpassade") || s11.equalsIgnoreCase("Personalizado"))
            {
                integer5 = new Integer(3);
            } else
            {
                logError(flashenvironment, "InvalPaletteType", null);
                integer5 = new Integer(1);
            }
        }
        catch(NumberFormatException _ex)
        {
            logError(flashenvironment, "InvalPaletteType", null);
        }
        if(integer5.intValue() == 3)
        {
            String s15 = _mth0143(flashenvironment, s13);
            if(s15 == null)
            {
                logError(flashenvironment, "InvalPaletteName", s13);
                integer5 = new Integer(1);
                s15 = "";
            }
            s13 = s15;
        }
        flashenvironment.put("GifAnimated", boolean3);
        flashenvironment.put("GifWidth", integer2);
        flashenvironment.put("GifHeight", integer3);
        flashenvironment.put("GifLoopCount", integer1);
        flashenvironment.put("GifDither", boolean4);
        flashenvironment.put("GifDitherType", integer4);
        flashenvironment.put("GifSmooth", boolean5);
        flashenvironment.put("GifInterlace", boolean6);
        flashenvironment.put("GifTransparent", boolean9);
        flashenvironment.put("GifTransparentSmart", boolean10);
        flashenvironment.put("GifTransparentThreshold", integer);
        flashenvironment.put("GifNoGradients", boolean7);
        flashenvironment.put("GifColorOpt", boolean8);
        flashenvironment.put("GifPaletteType", integer5);
        flashenvironment.put("GifPaletteFile", s13);
        flashenvironment.put("GifMaxColors", integer6);
        flashenvironment.put("GifQuality", boolean2);
        boolean _tmp = !s.equalsIgnoreCase("Static") && !s.equalsIgnoreCase("Animated");
        if(!s4.equalsIgnoreCase("true") && !s4.equalsIgnoreCase("false"))
            logError(flashenvironment, "InvalOptFlagsDither", null);
        if(!s5.equalsIgnoreCase("true") && !s5.equalsIgnoreCase("false"))
            logError(flashenvironment, "InvalOptFlagsSmooth", null);
        if(!s6.equalsIgnoreCase("true") && !s6.equalsIgnoreCase("false"))
            logError(flashenvironment, "InvalOptFlagsInterlace", null);
        if(!s8.equalsIgnoreCase("true") && !s8.equalsIgnoreCase("false"))
            logError(flashenvironment, "InvalOptFlagsGradient", null);
        if(boolean3.booleanValue() && boolean6.booleanValue())
            logError(flashenvironment, "WarnInterlaceAnimatedGif", null);
        flashenvironment.put("GifInitialized", new Boolean(true));
    }

    private String _mth0143(FlashEnvironment flashenvironment, String s)
    {
        String s1 = null;
        File file = null;
        file = new File(s);
        if(!file.isAbsolute())
            file = new File(flashenvironment.getDirectory(), file.getPath());
        if(file.exists() && file.isFile())
            s1 = file.getPath();
        return s1;
    }
}