www.pudn.com > MobiCraft_src.rar > ErrorReport.java


// style: tabs, tabsize=4, style=ANSI 
//+----------------------------------------------------------------------+ 
// Copyright (c) 2006 Company Name 
// Made by Andrew and Zahar 
//+----------------------------------------------------------------------+ 
// Filename: ErrorReport.java 
//+----------------------------------------------------------------------+ 
// Comment: Menu module to take control over paint() and keyPressed(). 
//+----------------------------------------------------------------------+ 
 
package app; 
import app.GameMIDlet; 
 
import java.io.*; 
import javax.microedition.lcdui.*; 
import javax.microedition.lcdui.game.*; 
 
public class ErrorReport implements CommandListener 
{ 
    private GameMIDlet mGameMIDlet; 
    private Command cmdOK; 
    private Command cmdCancel; 
    private Form mForm; 
 
    public ErrorReport(GameMIDlet m) 
    { 
		mGameMIDlet = m; 
		cmdOK = new Command("Ok", Command.OK, 1); 
		cmdCancel = new Command("Cancel", Command.CANCEL, 2); 
    } 
 
    public void ShowError(String sWhere, String sText ) 
    { 
		if (mGameMIDlet!=null) 
		{ 
			if ( mGameMIDlet.mCanvas != null ) 
			{ 
				//mGameMIDlet.mCanvas.PrepareForExit();		 
				mGameMIDlet.mCanvas.setFullScreenMode(false); 
			} 
		} 
		System.gc(); 
		mForm = new Form("-= Error =-"); 
		mForm.append( 
			"Game failed in: \n" +sWhere+"\n"+ 
			"Reason: \n" +sText+"\n"+ 
			"Available memory: \n  " + (Runtime.getRuntime()).freeMemory()+ 
			"\nNow Game will exit."); 
		mForm.addCommand(cmdOK); 
		mForm.setCommandListener(this); 
		Display.getDisplay(mGameMIDlet).setCurrent(mForm); 
    } 
     
    public void commandAction(Command command, Displayable displayable) 
    { 
		if (command == cmdOK) 
		{ 
			Display.getDisplay(mGameMIDlet).setCurrent((Displayable)null); 
			mGameMIDlet.destroyApp(true); 
			mGameMIDlet.notifyDestroyed(); 
			/*Display.getDisplay(mMainCanvas.mMIDlet).setCurrent(mMainCanvas); 
			mMainCanvas.bPaused = false; 
			mMainCanvas = null; 
			mTextBox.removeCommand(cmdOK); 
			cmdOK = null; 
			mForm.setCommandListener(null); 
			mForm = null;*/ 
		} 
    } 
}