import java.util.*; import java.net.*; import java.awt.event.*; import java.awt.*; public class menu9 implements Menu , ActionListener{ public Image image; int ofx=150; int ofy=50; public Image menu9; private boolean visible=true; boolean allready=false; public Global global; public String arg1=new String(""); public String arg2=new String(""); public String method=new String(""); public String retval=new String(""); public String list[]=new String[1010]; int l=5; int IMAGESIZE=150; Image nexthintimage; Image prevhintimage; Image nextimage; Image previmage; // NOT OK Screen Label createlabel; Button Create; Button Again; public boolean isVisible(){return visible;} ImageButton button[]=new ImageButton[10]; ImageButton nextbutton; ImageButton prevbutton; // NOT OK Screen ImageButton Abort; // Button Abort; Color backgroundcolor=new Color(0,60,0); Color menucolor=new Color(0,60,0); Color emailforeground=Color.black; Color passwordforeground=Color.black; Color createlabelcolor=Color.white; Color chattextforegroundcolor=new Color(0,255,0); Color chattextbackgroundcolor=new Color(0,60,0); Color chatforegroundcolor=new Color(0,200,0); Color chatbackgroundcolor=new Color(0,60,0); Color infoforegroundcolor=new Color(0,200,0); Color infobackgroundcolor=new Color(0,0,0); Color fieldlistforegroundcolor=new Color(0,200,0); public void init(Global glbl){ global=glbl; global.showprogressionbar=true; String rst=global.execute("checkbuy.php?usernr="+global.usernr+"&time="+global.show.date.getTime()); if(rst.indexOf(",1") > -1 || global.buy){ global.buy=true; }else global.buy=false; nextimage=global.loadImage(global.Server, "images/nextbutton"+global.Extention, global.show); previmage=global.loadImage(global.Server, "images/prevbutton"+global.Extention, global.show); nexthintimage=global.loadImage(global.Server, "images/nextbutton_2"+global.Extention, global.show); prevhintimage=global.loadImage(global.Server, "images/prevbutton_2"+global.Extention, global.show); makemenu9(); menu9=global.loadImage(global.Server, "images/menu9"+global.Extention, global.show); } public void show(Graphics g){ global.showprogressionbar=false; //g.drawString("Hoi", 100,100); if(visible){ if(menu9 != null){ global.show.graphics.fillRect(0,0,1024,768); showmenu9(g); } } } public void makemenu9(){ try{ l=global.level > 4?global.level-3:0; showlevels(l); // Make buttons to page up / page down levels nextbutton=new ImageButton(nextimage, nexthintimage, "NEXT", global.show, ""); nextbutton.addActionListener(this); nextbutton.setBounds(ofx+(IMAGESIZE*2),ofy+(IMAGESIZE*3), 100,100); nextbutton.setName("NEXT"); nextbutton.setVisible(true); global.show.add(nextbutton); prevbutton=new ImageButton(previmage, prevhintimage, "PREVIOUS", global.show, ""); prevbutton.addActionListener(this); prevbutton.setBounds(ofx+50,ofy+(IMAGESIZE*3), 100,100); prevbutton.setName("PREVIOUS"); prevbutton.setVisible(true); global.show.add(prevbutton); }catch(Exception ma){ System.out.println("Menu creatin error: "+ma.toString()); } } public void showlevels(int l){ Image level[]=new Image[10]; System.out.println("Did you bought?: "+global.buy); for(int i=1; i < 10; i++){ level[i]=global.loadImage(global.Server, "screens/"+(l+i)+"s.jpg", global.show); if(level[i] != null){ Image hint=global.show.createImage(100,100); Graphics gg=hint.getGraphics(); if(global.buy) gg.setColor(Color.white); else if( (l+i) > 25){ gg.setColor(Color.red); }else gg.setColor(Color.white); gg.setFont(new Font( "Terminal", Font.BOLD + Font.ITALIC, 14)); gg.drawString("LEVEL "+(l+i), 10,50); if( !global.buy && (l+i) > 25){ gg.drawString("BUY", 20,10); } gg.setColor(backgroundcolor); button[i]=new ImageButton(level[i], hint, "LEVEL"+i, global.show, ""); if(button[i] != null){ button[i].addActionListener(this); button[i].setBounds( ofx+(((i-1)%3)*IMAGESIZE) , ofy+ ((i < 4 ?0: i>3&&i<7 ?(IMAGESIZE):(IMAGESIZE*2))), IMAGESIZE,IMAGESIZE); button[i].setName("LEVEL"+i); button[i].setVisible(true); global.show.add(button[i]); }else System.out.println("button : "+i+ " is errornous"); }else System.out.println("Level image is null!"); } allready=false; setVisible(true); } public void showmenu9(Graphics g){ if(allready)return; global.showprogressionbar=false; allready=true; setVisible(true); } public void actionPerformed(ActionEvent ae){ //System.out.println("menu9 actionPer: "+ae.toString()); if(ae.toString().toUpperCase().indexOf("LEVEL") > -1){ System.out.println("ae.getActioncommand: "+ae.getActionCommand()); int lv=2; try{ Integer I=new Integer(ae.getActionCommand().substring(5,6)); lv=I.intValue(); }catch(Exception ege){lv=2;} global.showtext=""; // global.level=(l > 9)?(l+lv)-1:l+lv; global.level=l+(lv-1); allready=false; global.showprogressionbar=true; global.drawer=10; for(int i=1; i < 10; i++){ if(button[i]!=null){ button[i].setVisible(false); } } setVisible(false); global.show.setVisible(false); global.show.applet.setVisible(true); global.show.applet.repaint(); global.show.actmenu=0; global.RState=0; global.State=global.CHANGE; } if(ae.toString().indexOf("NEXT") > -1){ System.out.println("l = "+l); clearbuttons(); if(l < 91) l=l+9; showlevels(l); } if(ae.toString().indexOf("PREV") > -1){ clearbuttons(); if(l > 9) l=l-9; else l=0; showlevels(l); } } public void clearbuttons(){ for(int i=1; i < 10; i++){ if(button[i]!=null) global.show.remove( button[i] ); button[i]=null; } } public void setVisible(boolean state){ visible=state; for(int i=1; i < 10; i++){ if(button[i]!=null){ button[i].setVisible(state); } } if(nextbutton != null) nextbutton.setVisible(state); if(prevbutton != null) prevbutton.setVisible(state); } }