import java.util.*; import java.net.*; import java.awt.event.*; import java.awt.*; public class menu1 extends Panel implements Menu , ActionListener, FocusListener, Runnable{ public Image image; public Image menu1; private boolean visible=false; public Image img; boolean calculated=false; // time for calculating frames per half second long t1; // time for calculatng frams per 'half secon' Graphics off; int runner=0; 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]; // LoginScreen boolean allready=false; Label emaillabel; TextField email; Label passwordlabel; TextField password; Button MenuOK; Button Ano; Label label; public boolean isVisible(){return visible;} Thread thread; private void SetVisible(boolean o){ } private void none(boolean o){ emaillabel.setVisible(o); email.setVisible(o); passwordlabel.setVisible(o); password.setVisible(o); MenuOK.setVisible(o); Ano.setVisible(o); label.setVisible(o); validate(); } public void init(Global glbl){ global=glbl; System.out.println("Loading menu1 image: images/menu1"+global.Extention); try{ menu1=global.loadImage(global.Server, "images/menu1"+global.Extention, global.show); }catch(Exception e){} System.out.println("before makemenu1"); makemenu1(); allready=false; } public void show(Graphics g){ //g.drawString("Hoi", 100,100); //g.drawImage(image, 30,30,500,500,global.show); off=g; Date d=new Date(); t1=d.getTime(); try{ thread=new Thread(this); thread.start(); }catch(Exception e){ System.out.println("Thread menu1 failed!"); } if(visible) showmenu1(g); } public void run(){ while(true){ update(off); try{ thread.sleep(20); }catch(Exception e){} } } public void update(Graphics g){ try{ if(off!=null && !calculated && global.show != null ){ off.setColor(Color.white); if(menu1!=null) off.drawImage( menu1, 0,0,global.show); Date d2=new Date(); runner++; //System.out.println("Runner: "+ (runner++)); if(d2.getTime()-t1 > 1000){ System.out.println("Runner in 500 miliseconds:"+runner); global.runspeed=runner; // global.nicewalk=(runner>20?true:false); global.nicewalk=(runner>40?true:false); calculated=true; } } }catch(Exception dfdg){ System.out.println("Menu1.update: "+dfdg.toString()); } } public void makemenu1(){ System.out.println("make menu1"); try{ // emaillabel=new Label("E-Mail"); // emaillabel.setForeground(global.show.emailforeground); // emaillabel.setBounds(300,120,200,32); // add(emaillabel); email=new TextField(); email.setFont(global.textfont); email.setBounds(300,150,200,global.CHATLINESIZE); email.setForeground(global.show.emailforeground); email.setName("email"); email.addActionListener(this); global.show.add(email); password=new TextField(); password.setFont(global.textfont); password.setBounds(300,200,200,global.CHATLINESIZE); password.setEchoChar('*'); password.setForeground(global.show.passwordforeground); password.setName("password"); password.addActionListener(this); global.show.add(password); label=new Label(" "); label.setBackground(global.show.backgroundcolor); label.setForeground(Color.white); label.setBounds(300,230,200,20); global.show.add(label); MenuOK=new Button("OK"); MenuOK.addActionListener(this); MenuOK.setBounds(300,250,200,32); MenuOK.setName("MenuOK"); MenuOK.setBackground(Color.white); global.show.add(MenuOK); Ano=new Button("Guest"); Ano.addActionListener(this); Ano.setBounds(300,300,200,32); Ano.setName("Ano"); Ano.setBackground(Color.white); global.show.add(Ano); email.requestFocus(); allready=false; }catch(Exception ma){ System.out.println("Menu creatin error: "+ma.toString()); } } public void showmenu1(Graphics g){ if(allready) return; System.out.println("ShowMneu1"); allready=true; try{ global.show.graphics.setColor(global.show.backgroundcolor); global.show.graphics.fillRect(0,0,1024,768); }catch(Exception e){} try{ global.show.graphics.drawImage(menu1,0,0, global.show); g.drawImage(global.show.offscreen, 0,0, global.show); }catch(Exception gg){ //System.out.println("graphics draw in update:"+gg.toString()); } if(!isVisible()){ System.out.println("Making visible this menu(menu1)"); setVisible(true); } } public void actionPerformed(ActionEvent ae){ if(ae.toString().indexOf("email") > -1) password.requestFocus(); if(ae.toString().indexOf("password") > -1) MenuOK(); if(ae.toString().indexOf("OK") > -1){ MenuOK(); } if(ae.toString().indexOf("Ano") > -1){ Ano(); global.State=global.MENU_OK; } } // Menu public void MenuOK(){ SetVisible(false); // Check input label.setText(" "); setVisible(false); global.Email=email.getText(); global.Password=password.getText(); //System.out.println("Email: "+global.Email+" Pass: "+global.Password); if(global.Email.indexOf("@") > -1 && global.Email.length() > 3){ if(global.Password.length() > 3){ String data="email="+URLEncoder.encode(global.Email)+"&password="+URLEncoder.encode(global.Password); System.out.println("DATA : "+data); String result=global.execute("checkuser.php?"+data+"&time="+global.show.date.getTime()); System.out.println("CHECK USER: "+result); if(result.length() > 0){ if(result.indexOf("-1") == 0){ setVisible(false); global.State=global.MENU_NOTOK; System.out.println("EXECUTE MENU2 "); } else{ if(result.indexOf("-10") == 0){ setVisible(false); global.State=global.MENU_FULL; }else{ setVisible(false); int extran=result.indexOf("!"); // String Room=result.substring(result.indexOf(",")+1, result.indexOf(".")); String Room=result.substring(result.indexOf(",")+1, result.indexOf(".")); String Result=result.substring(0,result.indexOf(",")); // String Level=result.substring(result.indexOf(".")+1,result.indexOf(":")); String Level=result.substring(result.indexOf(".")+1,result.indexOf(":")); String Score="0"; if(result.indexOf("$") > -1){ // Score=result.substring(result.indexOf(":")+1, result.indexOf("$")); Score=result.substring(result.indexOf(":")+1, extran); if(Score.length() < 1)Score="0"; } else{ Score=result.substring(result.indexOf(":")+1, extran); if(Score.length() < 1)Score="0"; } if(extran>0) global.extra=result.substring( extran+1); else global.extra=""; System.out.println("Room: ["+Room+"] Result: ["+Result+"] level: ["+Level+"] Score: ["+Score+"]"); global.score=Integer.parseInt(Score); global.level=Integer.parseInt(Level); label.setText(" "); System.out.println("LEVEL JUMPING: "+global.level); global.usernr=Integer.parseInt(Result); global.room=Integer.parseInt(Room); global.team=global.usernr; if(result.indexOf("$") > -1){ String rst=global.execute("checkbuy.php?usernr="+global.usernr+"&time="+global.show.date.getTime()); if(rst.indexOf(",1") > -1){ global.buy=true; } }else global.buy=false; // write info to history table result=global.execute("history.php?usernr="+global.usernr+"&javaversion="+global.javaversion); global.State=global.MENU_OK; } } }else{ setVisible(false); // Not found //System.out.println("EXECUTING MENU2 IN NOT FOUND"); global.State=global.MENU_NOTOK; } } // password smaill else{ SetVisible(true); setVisible(true); label.setText("Password small"); } } // email else{ setVisible(true); SetVisible(true); label.setText("Email invalid"); } // email } // MenuOK public void Ano(){ String result; label.setText(" "); if(global.isnetwork) result = global.execute("getano.php?time="+global.show.date.getTime()); else result=""; SetVisible(false); setVisible(false); System.out.println("Result of getano: "+result); if(result.length() > 0){ String Room=result.substring(result.indexOf(",")+1, result.indexOf(":")); String Result=result.substring(0,result.indexOf(",")); global.level=0; global.usernr=Integer.parseInt(Result); global.room=Integer.parseInt(Room); global.team=global.usernr; }else{ global.room=1; global.usernr=10000; global.team=global.usernr; } } public void setVisible(boolean state){ // Turn of login -screen visible=state; if( email != null){ email.setVisible(state); password.setVisible(state); //emaillabel.setVisible(state); //passwordlabel.setVisible(state); label.setVisible(state); MenuOK.setVisible(state); Ano.setVisible(state); } this.validate(); global.show.applet.validate(); } public void focusGained(FocusEvent fe){ validate(); repaint(); } public void focusLost(FocusEvent fe){} }