// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java
// public enum Direction {
//     NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST;
// 
//     public static Direction parse(short b) {
//         switch(b) {
//         case 0: return NORTH;
//         case 1: return NORTH_EAST;
//         case 2: return EAST;
//         case 3: return SOUTH_EAST;
//         case 4: return SOUTH;
//         case 5: return SOUTH_WEST;
//         case 6: return WEST;
//         case 7: return NORTH_WEST;
//         default: return NORTH;
//         }
//     }
// 
//     public short toByte() {
//         switch(this) {
//         case NORTH:         return 0;
//         case NORTH_EAST:    return 1;
//         case EAST:          return 2;
//         case SOUTH_EAST:    return 3;
//         case SOUTH:         return 4;
//         case SOUTH_WEST:    return 5;
//         case WEST:          return 6;
//         case NORTH_WEST:    return 7;
//         default:            return 0;
//         }
//     }
// 
//     // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise
//     public static Direction fromAngle(double angle) {
//         double r = 360 / 16.0;
//         if(angle < 45 - r) {
//             return Direction.NORTH_WEST;
//         } else if(angle < 90 - r) {
//             return Direction.NORTH;
//         } else if(angle < 135 - r) {
//             return Direction.NORTH_EAST;
//         } else if(angle < 180 - r) {
//             return Direction.EAST;
//         } else if(angle < 225 - r) {
//             return Direction.SOUTH_EAST;
//         } else if(angle < 270 - r) {
//             return Direction.SOUTH;
//         } else if(angle < 315 - r) {
//             return Direction.SOUTH_WEST;
//         } else if(angle < 360 - r) {
//             return Direction.WEST;
//         } else {
//             return Direction.NORTH_WEST;
//         }
//     }
// 
//     public int getFrameIndex() {
//         switch(this) {
//         case NORTH:         return 3;
//         case NORTH_EAST:    return 2;
//         case EAST:          return 1;
//         case SOUTH_EAST:    return 0;
//         case SOUTH:         return 1;
//         case SOUTH_WEST:    return 2;
//         case WEST:          return 3;
//         case NORTH_WEST:    return 4;
//         default:            return -1;
//         }
//     }
// 
//     public Direction getOpposingDirection() {
//         switch(this) {
//         case NORTH:         return SOUTH;
//         case NORTH_EAST:    return SOUTH_WEST;
//         case EAST:          return WEST;
//         case SOUTH_EAST:    return NORTH_WEST;
//         case SOUTH:         return NORTH;
//         case SOUTH_WEST:    return NORTH_EAST;
//         case WEST:          return EAST;
//         case NORTH_WEST:    return SOUTH_EAST;
//         default:            return SOUTH;
//         }
//     }
// }


import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.Timer;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.solhost.folko.uosl.libuosl.data.SLArt;
import org.solhost.folko.uosl.libuosl.data.SLArt.ArtEntry;
import org.solhost.folko.uosl.libuosl.data.SLArt.MobileAnimation;
import org.solhost.folko.uosl.libuosl.types.Direction;
        add(artInfoPanel, BorderLayout.CENTER);
    }

    private void selectArt(int idx) {
        if(timer != null) {
            animationButton.setText("Start");
            timer.stop();
            timer = null;
        }
        ArtListEntry entry = artList.getModel().getElementAt(idx);
        currentAnimation = art.getAnimationEntry(entry.id, entry.dir, entry.fighting);
        currentFrame = 0;
        artLabel.setText(String.format("0x%04X: %d frames", currentAnimation.id, currentAnimation.frames.size()));
        updateFrame();
    }

    private void updateFrame() {
        int staticID = currentAnimation.frames.get(currentFrame);
        ArtEntry entry = art.getStaticArt(staticID, false);
        entry.mirror(currentAnimation.needMirror);
        imagePanel.setImage(entry.image);
        currentFrame++;
        if(currentFrame == currentAnimation.frames.size()) {
            currentFrame = 0;
        }
    }
}

class ArtListEntry {
    public int id;
// Path: libuosl/src/org/solhost/folko/uosl/libuosl/types/Direction.java
// public enum Direction {
//     NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST;
// 
//     public static Direction parse(short b) {
//         switch(b) {
//         case 0: return NORTH;
//         case 1: return NORTH_EAST;
//         case 2: return EAST;
//         case 3: return SOUTH_EAST;
//         case 4: return SOUTH;
//         case 5: return SOUTH_WEST;
//         case 6: return WEST;
//         case 7: return NORTH_WEST;
//         default: return NORTH;
//         }
//     }
// 
//     public short toByte() {
//         switch(this) {
//         case NORTH:         return 0;
//         case NORTH_EAST:    return 1;
//         case EAST:          return 2;
//         case SOUTH_EAST:    return 3;
//         case SOUTH:         return 4;
//         case SOUTH_WEST:    return 5;
//         case WEST:          return 6;
//         case NORTH_WEST:    return 7;
//         default:            return 0;
//         }
//     }
// 
//     // angle must be in [0, 360]. 0 is north west and positive angles turn clockwise
//     public static Direction fromAngle(double angle) {
//         double r = 360 / 16.0;
//         if(angle < 45 - r) {
//             return Direction.NORTH_WEST;
//         } else if(angle < 90 - r) {
//             return Direction.NORTH;
//         } else if(angle < 135 - r) {
//             return Direction.NORTH_EAST;
//         } else if(angle < 180 - r) {
//             return Direction.EAST;
//         } else if(angle < 225 - r) {
//             return Direction.SOUTH_EAST;
//         } else if(angle < 270 - r) {
//             return Direction.SOUTH;
//         } else if(angle < 315 - r) {
//             return Direction.SOUTH_WEST;
//         } else if(angle < 360 - r) {
//             return Direction.WEST;
//         } else {
//             return Direction.NORTH_WEST;
//         }
//     }
// 
//     public int getFrameIndex() {
//         switch(this) {
//         case NORTH:         return 3;
//         case NORTH_EAST:    return 2;
//         case EAST:          return 1;
//         case SOUTH_EAST:    return 0;
//         case SOUTH:         return 1;
//         case SOUTH_WEST:    return 2;
//         case WEST:          return 3;
//         case NORTH_WEST:    return 4;
//         default:            return -1;
//         }
//     }
// 
//     public Direction getOpposingDirection() {
//         switch(this) {
//         case NORTH:         return SOUTH;
//         case NORTH_EAST:    return SOUTH_WEST;
//         case EAST:          return WEST;
//         case SOUTH_EAST:    return NORTH_WEST;
//         case SOUTH:         return NORTH;
//         case SOUTH_WEST:    return NORTH_EAST;
//         case WEST:          return EAST;
//         case NORTH_WEST:    return SOUTH_EAST;
//         default:            return SOUTH;
//         }
//     }
// }


// Path: viewsl/src/org/solhost/folko/uosl/viewsl/AnimationView.java
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.Timer;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.solhost.folko.uosl.libuosl.data.SLArt;
import org.solhost.folko.uosl.libuosl.data.SLArt.ArtEntry;
import org.solhost.folko.uosl.libuosl.data.SLArt.MobileAnimation;
import org.solhost.folko.uosl.libuosl.types.Direction;

        add(artInfoPanel, BorderLayout.CENTER);
    }

    private void selectArt(int idx) {
        if(timer != null) {
            animationButton.setText("Start");
            timer.stop();
            timer = null;
        }
        ArtListEntry entry = artList.getModel().getElementAt(idx);
        currentAnimation = art.getAnimationEntry(entry.id, entry.dir, entry.fighting);
        currentFrame = 0;
        artLabel.setText(String.format("0x%04X: %d frames", currentAnimation.id, currentAnimation.frames.size()));
        updateFrame();
    }

    private void updateFrame() {
        int staticID = currentAnimation.frames.get(currentFrame);
        ArtEntry entry = art.getStaticArt(staticID, false);
        entry.mirror(currentAnimation.needMirror);
        imagePanel.setImage(entry.image);
        currentFrame++;
        if(currentFrame == currentAnimation.frames.size()) {
            currentFrame = 0;
        }
    }
}

class ArtListEntry {
    public int id;
    public Direction dir;