📄 debug.java
字号:
import java.io.*;
import java.util.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.RecordStore;
import javax.microedition.media.*;
public class Debug
{
private static final boolean NEED_PRINT_INFO = true;
private static final boolean NEED_PRINT_EXCEPTION = true;
private static final boolean NEED_ASSERT = true;
private static final boolean NEED_ANALYSE_MEM = true;
public static void Println(String str)
{
if (NEED_PRINT_INFO)
System.out.println(str);
}
public static void Println(int value)
{
if (NEED_PRINT_INFO)
System.out.println(value);
}
public static void PrintException(Exception e)
{
if (NEED_PRINT_EXCEPTION)
e.printStackTrace();
}
public static void Assert(boolean expr, String errorInfo)
{
if (NEED_ASSERT)
{
if (!expr)
{
try
{
throw new Exception(errorInfo);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
private static long s_recordedMem = 0;
public static void Mem(String comment)
{
if (NEED_ANALYSE_MEM)
{
long mem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println(comment + " current: " + mem + " consumed since last: " + (mem - s_recordedMem));
s_recordedMem = mem;
}
}
public static void MarkScreenAndViewport(Graphics g)
{
Donghua.SetClip(g, 0, 0, PINGMUDDD.PINGMUKUAN, PINGMUDDD.PINGMUGAO);
g.setColor(0xFF0000);
g.drawRect(0, 0, PINGMUDDD.PINGMUKUAN-1, PINGMUDDD.PINGMUGAO-1);
g.setColor(0x00FFFF);
g.drawRect(PINGMUDDD.sssCHUANNN_LEFT, PINGMUDDD.sssCHUANNN_TOP, PINGMUDDD.sssCHUANNN_WIDTH-1, PINGMUDDD.sssCHUANNN_HEIGHT-1);
}
public static Image CreateImage(String name)
{
try
{
return Image.createImage(name);
}
catch (Exception e)
{
PrintException(e);
return null;
}
}
public static String GetParamValue(String fileName, String paramName)
{
try
{
InputStreamReader isr = new InputStreamReader(fileName.getClass().getResourceAsStream(fileName));
StringBuffer strbuf = new StringBuffer();
String result = null;
byte b;
while ((b = (byte)isr.read()) != -1)
{
if (b == 13)
{
String str = strbuf.toString();
if (str.startsWith(paramName + "="))
{
result = str.substring(str.indexOf("=") + 1);
break;
}
strbuf.setLength(0);
}
else if (b != 10)
strbuf.append((char)b);
}
strbuf = null;
isr.close();
isr = null;
if (result != null)
return result;
else
throw new Exception("param not found with the specified name " + paramName);
}
catch (Exception e)
{
PrintException(e);
return null;
}
}
public static long s_time1;
public static long s_time2;
public static long s_time3;
public static long s_time4;
public static long s_time5;
public static long s_time6;
public static long s_timeNow;
public static long s_timeJiaoses;
public static boolean ifShowBG = true;
public static boolean ifShowJiaoses = true;
public static boolean ifShowRate = false;
private static long rateTick;
public static final boolean SHOW_TIME_COST = true;
public static final boolean SWITCH_ACTOR_AND_MAP_DRAWING = false;
public static void ShowRate()
{
if (ifShowRate)
{
Xiyou.s_g.setClip(0, 0, PINGMUDDD.PINGMUKUAN, PINGMUDDD.PINGMUGAO);
rateTick = System.currentTimeMillis() - rateTick;
long fps = 1000/rateTick;
Xiyou.s_g.setColor(0, 0, 255);
Xiyou.s_g.drawString("F:" + fps, PINGMUDDD.PINGMUKUAN - 40, PINGMUDDD.PINGMUGAO - 40, 0);
if (SHOW_TIME_COST)
{
Xiyou.s_g.drawString("1:" + s_time1, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 160, 0);
Xiyou.s_g.drawString("2:" + s_time2, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 140, 0);
Xiyou.s_g.drawString("3:" + s_time3, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 120, 0);
Xiyou.s_g.drawString("4:" + s_time4, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 100, 0);
Xiyou.s_g.drawString("5:" + s_time5, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 80, 0);
Xiyou.s_g.drawString("6:" + s_time6, PINGMUDDD.PINGMUKUAN - 80, PINGMUDDD.PINGMUGAO - 60, 0);
}
rateTick = System.currentTimeMillis();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -