parent
ad5ad80c61
commit
381e58b504
Binary file not shown.
@ -0,0 +1,61 @@ |
|||||||
|
package sig.modules.RabiRace; |
||||||
|
|
||||||
|
import java.awt.Image; |
||||||
|
|
||||||
|
import sig.modules.RabiRaceModule; |
||||||
|
|
||||||
|
public enum Avatar { |
||||||
|
ERINA("Erina","small_erina.png",0), |
||||||
|
RIBBON("Ribbon","small_ribbon.png",1), |
||||||
|
IRISU("Irisu","small_irisu.png",2), |
||||||
|
GREEN_KOTRI("Kotri (Green)","small_green_kotri.png",3), |
||||||
|
BLUE_KOTRI("Kotri (Blue)","small_blue_kotri.png",4), |
||||||
|
RED_KOTRI("Kotri (Red)","small_kotri.png",5), |
||||||
|
ARURAUNE("Aruraune","small_aruraune.png",6), |
||||||
|
ASHURI("Ashuri","small_ashuri.png",7), |
||||||
|
CICINI("Cicini","small_cicini.png",8), |
||||||
|
COCOA("Cocoa","small_cocoa.png",9), |
||||||
|
ILLUSION_ALIUS("Illusion Alius","small_illusion_alius.png",10), |
||||||
|
KEKE_BUNNY("Keke Bunny","small_keke_bunny.png",11), |
||||||
|
LILITH("Lilith","small_lilith.png",12), |
||||||
|
LILLI("Lilli","small_lilli.png",13), |
||||||
|
MIRIAM("Miriam","small_miriam.png",14), |
||||||
|
MIRU("Miru","small_miru.png",15), |
||||||
|
NIEVE("Nieve","small_nieve.png",16), |
||||||
|
NIXIE("Nixie","small_nixie.png",17), |
||||||
|
NOAH("Noah","small_noah.png",18), |
||||||
|
PANDORA("Pandora","small_pandora.png",19), |
||||||
|
SHADOW_PANDORA("Pandora (Shadow)","small_shadow_pandora.png",20), |
||||||
|
PIXIE("Pixie","small_pixie.png",21), |
||||||
|
RITA("Rita","small_rita.png",22), |
||||||
|
SHADOW_RITA("Rita (Shadow)","small_shadow_rita.png",23), |
||||||
|
RUMI("Rumi","small_rumi.png",24), |
||||||
|
SAYA("Saya","small_saya.png",25), |
||||||
|
SEANA("Seana","small_seana.png",26), |
||||||
|
SYARO("Syaro","small_syaro.png",27), |
||||||
|
VANILLA("Vanilla","small_vanilla.png",28), |
||||||
|
; |
||||||
|
|
||||||
|
public String displayName; |
||||||
|
public String fileName; |
||||||
|
public int value; |
||||||
|
|
||||||
|
Avatar(String displayName, String fileName, int value) { |
||||||
|
this.displayName = displayName; |
||||||
|
this.fileName = fileName; |
||||||
|
this.value = value; |
||||||
|
} |
||||||
|
|
||||||
|
public static Avatar getAvatarFromID(int value) { |
||||||
|
for (Avatar a : Avatar.values()) { |
||||||
|
if (a.value == value) { |
||||||
|
return a; |
||||||
|
} |
||||||
|
} |
||||||
|
return ERINA; |
||||||
|
} |
||||||
|
|
||||||
|
public Image getAvatarImage() { |
||||||
|
return RabiRaceModule.image_map.get(fileName); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,156 @@ |
|||||||
|
package sig.modules.RabiRace; |
||||||
|
|
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Image; |
||||||
|
import java.awt.LayoutManager; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.lang.reflect.Field; |
||||||
|
|
||||||
|
import javax.swing.Box; |
||||||
|
import javax.swing.BoxLayout; |
||||||
|
import javax.swing.JFrame; |
||||||
|
import javax.swing.JPanel; |
||||||
|
|
||||||
|
import sig.sigIRC; |
||||||
|
import sig.modules.RabiRaceModule; |
||||||
|
import sig.utils.ReflectUtils; |
||||||
|
|
||||||
|
public class AvatarSelectionWindow extends JFrame{ |
||||||
|
static ImagePanel[] avatars = new ImagePanel[Avatar.values().length]; |
||||||
|
static AvatarSelectionWindow avatarwindow; |
||||||
|
final static int WINDOW_WIDTH = 350; |
||||||
|
final static int COLUMNS = WINDOW_WIDTH/50; |
||||||
|
final static int WINDOW_HEIGHT = ((Avatar.values().length/COLUMNS)+1)*50; |
||||||
|
static boolean mousePressed = false; |
||||||
|
|
||||||
|
public AvatarSelectionWindow() { |
||||||
|
this.setVisible(false); |
||||||
|
this.setTitle("Avatar Selection"); |
||||||
|
this.setIconImage(sigIRC.programIcon); |
||||||
|
avatarwindow = this; |
||||||
|
JPanel panels = new JPanel(); |
||||||
|
JPanel container = new JPanel(); |
||||||
|
panels.setLayout(new BoxLayout(panels,BoxLayout.PAGE_AXIS)); |
||||||
|
container.setLayout(new BoxLayout(container,BoxLayout.LINE_AXIS)); |
||||||
|
container.setSize(WINDOW_WIDTH, 50); |
||||||
|
int i=0; |
||||||
|
panels.add(container); |
||||||
|
for (int k=0;k<avatars.length;k++) { |
||||||
|
ImagePanel j = new ImagePanel(RabiRaceModule.image_map.get(Avatar.values()[i].fileName),i%COLUMNS,i/COLUMNS,Avatar.values()[i].value); |
||||||
|
avatars[k] = j; |
||||||
|
j.setSize(50,50); |
||||||
|
j.setPreferredSize(new Dimension(50,50)); |
||||||
|
container.add(j); |
||||||
|
i++; |
||||||
|
if (i%COLUMNS==0) { |
||||||
|
container = new JPanel(); |
||||||
|
container.setLayout(new BoxLayout(container,BoxLayout.LINE_AXIS)); |
||||||
|
container.setSize(WINDOW_WIDTH, 50); |
||||||
|
panels.add(container); |
||||||
|
} |
||||||
|
} |
||||||
|
while (i%COLUMNS!=0) { |
||||||
|
container.add(Box.createRigidArea(new Dimension(50,50))); |
||||||
|
i++; |
||||||
|
} |
||||||
|
this.add(panels); |
||||||
|
this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT+48); |
||||||
|
this.setResizable(false); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class ImagePanel extends JPanel implements MouseListener{ |
||||||
|
Image img; |
||||||
|
int x,y; |
||||||
|
public boolean selected=false; |
||||||
|
int myID = 0; |
||||||
|
|
||||||
|
public ImagePanel(Image img, int x, int y, int myID) { |
||||||
|
this.img = img; |
||||||
|
this.setSize(50,50); |
||||||
|
this.x=x; |
||||||
|
this.y=y; |
||||||
|
this.myID = myID; |
||||||
|
addMouseListener(this); |
||||||
|
} |
||||||
|
|
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
super.paintComponent(g); |
||||||
|
if (selected) { |
||||||
|
g.setColor(new Color(0,0,64)); |
||||||
|
g.fillRect(0, 0, 50, 50); |
||||||
|
} |
||||||
|
g.drawImage(img, 0, 0, this); |
||||||
|
if (selected) { |
||||||
|
g.setColor(Color.YELLOW); |
||||||
|
for (int i=0;i<2;i++) { |
||||||
|
g.drawRect(i, i, 50-i, 50-i); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public String toString() { |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
sb.append(this.getClass().getName()+"("); |
||||||
|
boolean first=false; |
||||||
|
for (Field f : this.getClass().getDeclaredFields()) { |
||||||
|
if (!first) { |
||||||
|
try { |
||||||
|
sb.append(f.getName()+"="+f.get(this)); |
||||||
|
first=true; |
||||||
|
} catch (IllegalArgumentException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} else { |
||||||
|
try { |
||||||
|
sb.append(","+f.getName()+"="+f.get(this)); |
||||||
|
} catch (IllegalArgumentException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} catch (IllegalAccessException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
sb.append(")"); |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mousePressed(MouseEvent arg0) { |
||||||
|
for (ImagePanel i : AvatarSelectionWindow.avatars) { |
||||||
|
if (i!=null) { |
||||||
|
i.selected = false; |
||||||
|
i.repaint(); |
||||||
|
} |
||||||
|
} |
||||||
|
selected = true; |
||||||
|
AvatarSelectionWindow.mousePressed=true; |
||||||
|
RabiRaceModule.module.myProfile.avatar = Avatar.getAvatarFromID(myID); |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseEntered(MouseEvent e) { |
||||||
|
if (AvatarSelectionWindow.mousePressed) { |
||||||
|
mousePressed(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseExited(MouseEvent e) { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseReleased(MouseEvent e) { |
||||||
|
AvatarSelectionWindow.mousePressed=false; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue