📄 login.java
字号:
package poker;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Displayable;
import com.nokia.mid.ui.*;
import java.util.TimerTask;
import java.util.Timer;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Login extends FullCanvas implements CommandListener{
Image BackImage,BarImage,panelBorderImage,panelImage,douImage,diImage,zhuImage;
Image beginImage,setAccountImage,helpImage,exitImage;
Command exitCmd,helpCmd,setAccountCmd,startGameCmd;
ServersList servers;
setAccountInfo setAccountForm;
Timer one;
MyTask oneTask;
int X=52;
int Y=85;
int step[]=new int[11];
static Login _instance;
static synchronized public Login getInstance() {
if (_instance == null) {
_instance = new Login();
}
return _instance;
}
public Login() {
try{
BackImage=Image.createImage("/res/LogoBack.gif");
BarImage=Image.createImage("/res/Logo_buttom_boder.gif");
panelBorderImage=Image.createImage("/res/logo_panel_boder.gif");
panelImage=Image.createImage("/res/logo_panel.gif");
douImage=Image.createImage("/res/logo_dou.gif");
diImage=Image.createImage("/res/logo_di.gif");
zhuImage=Image.createImage("/res/logo_zhu.gif");
beginImage=Image.createImage("/res/b_beginGame.gif");
setAccountImage=Image.createImage("/res/b_setAccount.gif");
helpImage=Image.createImage("/res/b_help.gif");
exitImage=Image.createImage("/res/b_exit.gif");
helpCmd=new Command("help",Command.HELP,1);
startGameCmd=new Command("start game",Command.SCREEN,1);
setAccountCmd=new Command("set Account",Command.SCREEN,2);
exitCmd=new Command("exit me",Command.EXIT,1);
this.addCommand(helpCmd);
this.addCommand(setAccountCmd);
this.addCommand(startGameCmd);
this.addCommand(exitCmd);
this.setCommandListener(this);
clearStep();
}catch(Exception e){
}
}
protected void paint(Graphics g) {
g.drawImage(BackImage,0,0,Graphics.TOP|Graphics.LEFT);
if (step[1]==1){
g.drawImage(douImage,20,10,Graphics.TOP|Graphics.LEFT);
}
if (step[2]==1){
g.drawImage(diImage,70,10,Graphics.TOP|Graphics.LEFT);
}
if (step[3]==1){
g.drawImage(zhuImage,110,20,Graphics.TOP|Graphics.LEFT);
}
if (step[4]==1){
g.drawImage(panelBorderImage,40,71,Graphics.TOP|Graphics.LEFT);
}
if (step[5]==1){
g.drawImage(panelImage,44,75,Graphics.TOP|Graphics.LEFT);
}
if (step[6]==1){
g.drawImage(beginImage,54,87,Graphics.TOP|Graphics.LEFT);
}
if (step[7]==1){
g.drawImage(setAccountImage,54,117,Graphics.TOP|Graphics.LEFT);
}
if (step[8]==1){
g.drawImage(helpImage,54,147,Graphics.TOP|Graphics.LEFT);
}
if (step[9]==1){
g.drawImage(exitImage,54,177,Graphics.TOP|Graphics.LEFT);
}
if (step[10]==1){
g.drawImage(BarImage,X,Y,Graphics.TOP|Graphics.LEFT);
}
}
public String login(String accountID,String password){
//this function only use in serverList when user want's to enter a server.
String result="";
GetServicData.url="http://"+GameInfo.ServerAddress
+"/gameservice/AuthenticationService.asmx/AuthenticationUser?"
+"accountID="+accountID+"&password="+password;
System.out.println("serverice adress:"+GetServicData.url);
GetServicData.kind=4;
GetServicData.connect();
result=GetServicData.url;
System.out.println("login result:"+result);
return result;
}
public void commandAction(Command c, Displayable d) {
}
private void clearStep(){
for (int i=0;i<11;i++){
step[i]=0;
}
}
public void drawFace(){
one=new Timer();
oneTask=new MyTask();
one.schedule(oneTask,1,100);
}
class MyTask extends TimerTask{
int tt=0;
public void run() {
tt=tt+1;
if(tt>10) {
one.cancel();
tt=0;
}
step[tt]=1;
repaint();
}
}
public void keyPressed(int keyCode){
int gameAction=getGameAction(keyCode);
switch (gameAction){
case UP:
if (Y>85) {
Y=Y-30;
repaint();
}
break;
case DOWN:
if (Y<175){
Y=Y+30;
repaint();
}
break;
case FIRE:
if (Y==85){
//begin Game
ServersList servers=ServersList.getInstance();
GameInfo.display.setCurrent(servers.imList);
_instance=null;
}
if (Y==115){
//set account
setAccountForm=new setAccountInfo();
GameInfo.display.setCurrent(setAccountForm);
_instance=null;
}
if (Y==145){
//help
}
if (Y==175){
//exit
GameInfo.midlet.notifyDestroyed();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -