import java.io.*; import java.net.*; import java.util.*; import java.net.*; import java.awt.event.*; import java.awt.*; public class menu10 implements Menu , ActionListener{ public Image image; int ofx=150; int ofy=50; 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; myFont font; Image fontje; myListBox scorelist; myListBox highscorelist; // NOT OK Screen Label createlabel; Button Create; Button Again; public boolean isVisible(){return visible;} 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; 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); // font3.gif = 16 // font5.gif = 8 fontje=global.loadImage(global.Server, "images/font5.gif", global.show); font=new myFont(fontje, 8, global.show); makemenu10(); } public void show(Graphics g){ global.showprogressionbar=false; //g.drawString("Hoi", 100,100); if(visible){ global.show.graphics.fillRect(0,0,1024,768); System.out.println("Running Show(Graph) on 10!"); refresh(); showmenu10(g); } } public void makemenu10(){ try{ // l=global.level > 4?global.level-3:0; show(); // 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); scorelist=new myListBox(font, global.show.offscreenboard, global.show, true, 16); scorelist.setBounds( 80 ,10, 400,300); scorelist.setVisible(true); global.show.add(scorelist); highscorelist=new myListBox(font, global.show.offscreenboard, global.show, true, 16); highscorelist.setBounds( 30,320, 550,150); highscorelist.setVisible(true); global.show.add(highscorelist); // Get result .. each line getscores(); gethighscores(); }catch(Exception ma){ System.out.println("Menu creatin error: "+ma.toString()); } } public void show(){ setVisible(true); } public void showmenu10(Graphics g){ if(allready)return; global.showprogressionbar=false; allready=true; setVisible(true); } public void refresh(){ if(highscorelist!=null)highscorelist.clear(); if(scorelist!=null)scorelist.clear(); System.out.println("REFRESHED"); getscores(); gethighscores(); if(scorelist!=null){ scorelist.select(2); scorelist.select(1); } if(highscorelist!=null){ highscorelist.select(2); highscorelist.select(1); } } public void actionPerformed(ActionEvent ae){ //System.out.println("menu10 actionPer: "+ae.toString()); if(ae.toString().toUpperCase().indexOf("PREV") >-1){ refresh(); } if(ae.toString().toUpperCase().indexOf("NEXT") > -1){ allready=false; global.State=global.RUN; // global.showprogressionbar=true; // if(prevbutton!=null){ // prevbutton.setVisible(false); // } if(nextbutton!=null){ nextbutton.setVisible(false); } if(scorelist!=null){ scorelist.setVisible(false); } if(highscorelist!=null){ highscorelist.setVisible(false); } global.drawer=10; // global.show.setVisible(false); // global.show.applet.setVisible(true); global.show.applet.repaint(); global.show.actmenu=0; global.RState=0; // global.State=global.CHANGE; } } public void clearbuttons(){ } public void setVisible(boolean state){ visible=state; if(nextbutton != null) nextbutton.setVisible(state); // if(prevbutton != null) // prevbutton.setVisible(state); if(scorelist!=null)scorelist.setVisible(state); if(highscorelist!=null)highscorelist.setVisible(state); } public void getscores(){ String retval=""; String test=new String(""); Integer I; Integer J; String inputLine; Date d=new Date(); //System.out.println("Retrieving overview2.php"); if(!global.standalone) { try{ URL Url = new URL(global.Server+"overview2.php"+"?usernr="+global.usernr+"&dummy="+d.getTime()); System.out.println("EXECUTING Url opening: "+Url.toString()); URLConnection uc = Url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream())); while ((inputLine = in.readLine()) != null){ // Script is executing .. no output is given! //System.out.println("Line: "+inputLine); StringTokenizer st=new StringTokenizer(inputLine.trim(), "|"); String line=""; while(st.hasMoreTokens()){ String Regel=st.nextToken().trim(); //System.out.println("regel:"+Regel); StringTokenizer st2=new StringTokenizer(Regel,","); while(st2.hasMoreTokens()){ String n=st2.nextToken().trim(); //System.out.println("Co:"+n); int l=12-n.length(); String a=""; for(int i=0; i< l; i++) a+=" "; if(n.length() > 12) n=n.substring(0,12); line+=n+a+" | "; } scorelist.add(line); line=""; } } }catch(Exception ef){ } }else{ // Dummy info scorelist.add("No Score Available"); scorelist.add("Please use on-line version for high-scores to show up!"); } } public void gethighscores(){ String retval=""; String test=new String(""); Integer I; Integer J; String inputLine; Date d=new Date(); //System.out.println("Retrieving overview2.php"); if(!global.standalone) { try{ URL Url = new URL(global.Server+"highscores2.php"+"?usernr="+global.usernr+"&dummy="+d.getTime()); System.out.println("EXECUTING Url opening: "+Url.toString()); URLConnection uc = Url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream())); while ((inputLine = in.readLine()) != null){ // Script is executing .. no output is given! //System.out.println("Line: "+inputLine); StringTokenizer st=new StringTokenizer(inputLine.trim(), "|"); String line=""; while(st.hasMoreTokens()){ String Regel=st.nextToken().trim(); //System.out.println("regel:"+Regel); StringTokenizer st2=new StringTokenizer(Regel,","); while(st2.hasMoreTokens()){ String n=st2.nextToken().trim(); //System.out.println("Co:"+n); int l=12-n.length(); String a=""; for(int i=0; i< l; i++) a+=" "; if(n.length() > 12) n=n.substring(0,12); line+=n+a+" | "; } highscorelist.add(line); line=""; } } }catch(Exception ef){ } }else{ // Dummy info highscorelist.add("No Score Available"); highscorelist.add("Please use on-line version for high-scores to show up!"); } } }