📄 standard.java
字号:
dout = null;
data = null;
}
// Hiscores - lastname / email
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);
byte[] data = null;
dout.writeUTF(" ");
data = bout.toByteArray();
rs.addRecord(data, 0, data.length);
bout = null;
dout = null;
data = null;
}
}
else
{
byte[] barray = rs.getRecord(1); // Record 1 is the continue available
if ((barray != null) && (barray.length == 1)) GMCanvas.options[0] = (barray[0] == bytes[TRUE]);
byte[] barray2 = rs.getRecord(2); // Record 1 is the continue available
if ((barray2 != null) && (barray2.length == 1)) GameEffects.soundOn = (barray2[0] == bytes[TRUE]);
barray2 = rs.getRecord(3); // Record 1 is the continue available
// if ((barray2 != null) && (barray2.length == 1)) GMCanvas.detailHigh = (barray2[0] == bytes[TRUE]);
if (MAX_SCORES != 0)
{
// Get the Hiscores
ByteArrayInputStream bin = null;
DataInputStream din = null;
byte[] data = null;
openRecordStore(buf);
data = rs.getRecord(4);
bin = new ByteArrayInputStream(data);
din = new DataInputStream(bin);
for (int i = 0; i < hsNames.length; i++) hsNames[i] = din.readChar();
for (int i = 0; i < MAX_SCORES; i++) hsScores[i] = din.readInt();
bin = null;
din = null;
data = null;
}
{
ByteArrayInputStream bin = null;
DataInputStream din = null;
byte[] data = null;
openRecordStore(buf);
data = rs.getRecord(5);
bin = new ByteArrayInputStream(data);
din = new DataInputStream(bin);
if (hsLastIn.length() > 0) hsLastIn.delete(0,hsLastIn.length());
hsLastIn.append(DataInputStream.readUTF(din));
data = null;
din = null;
bin = null;
}
}
System.out.println("*No Problem with getSettings");
closeRecordStore();
}
catch (Exception e)
{
for (int i = 0; i < hsNames.length; i++) hsNames[i] = '.';
for (int i = 0; i < MAX_SCORES; i++) hsScores[i] = (MAX_SCORES*1000)-(i*1000);
// hsEmailSize = 0;
hsLastSize = 0;
System.out.println("*** Problem with Standard.getSettings()"+e.getMessage());
}
// hsEmailSize = 25;
// hsLastSize = 25;
//System.out.println("*hsEmailSize "+hsEmailSize);
System.out.println("*hsLastSize "+hsLastSize);
}
public static void setSettings(GMCanvas gm)
{
StringBuffer buf = new StringBuffer("SET");
try
{
openRecordStore(buf);
if (GMCanvas.options[0]) rs.setRecord(1, bytes, TRUE, 1);
else rs.setRecord(1, bytes, FALSE, 1);
if (GameEffects.soundOn) rs.setRecord(2, bytes, TRUE, 1);
else rs.setRecord(2, bytes, FALSE, 1);
// if (gm.detailHigh) rs.setRecord(3, bytes, TRUE, 1);
// else rs.setRecord(3, bytes, FALSE, 1);
rs.setRecord(3, bytes, FALSE, 1);
// Hiscores
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);
byte[] data = null;
for (int i = 0; i < hsNames.length; i++) dout.writeChar(hsNames[i]);
for (int i = 0; i < MAX_SCORES; i++) dout.writeInt(hsScores[i]);
data = bout.toByteArray();
rs.setRecord(4, data, 0, data.length);
bout = null;
dout = null;
data = null;
}
// Hiscores - lastname / email
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);
byte[] data = null;
if (hsLastIn.length() > 0) dout.writeUTF(hsLastIn.toString());
else dout.writeUTF(" ");
data = bout.toByteArray();
rs.setRecord(5, data, 0, data.length);
bout = null;
dout = null;
data = null;
}
//System.out.println("*hsEmailSize "+hsEmailSize);
closeRecordStore();
}
// catch (RecordStoreException e)
// {
//System.out.println("*** Problem with Standard.setSettings()1 "+e.getMessage());
// }
catch (IOException ioe)
{
//System.out.println("*** Problem with Standard.setSettings() IO EXEC "+ioe.getMessage());
}
catch (Exception e)
{
//System.out.println("*** Problem with Standard.setSettings() EXEC "+e.getMessage());
}
}
// -------------------------------------------------------------------------------------------
// Store the game to RMS
// -------------------------------------------------------------------------------------------
public static void setGame(GMCanvas gm)
{
}
// -------------------------------------------------------------------------------------------
// get the game from RMS
// -------------------------------------------------------------------------------------------
public static void getGame(GMCanvas gm)
{
}
/*****************************************************************************************************/
/** **/
/** Online high score stuff - taken out because its rumbleX, but there is an on phone score ;-) **/
/** **/
/*****************************************************************************************************/
public static int NAME_LEN = 5;
public static int MAX_SCORES = 0;
public static char[] hsNames;
public static StringBuffer hsName = new StringBuffer("");
public static StringBuffer hsLastIn = new StringBuffer("");
public static String[] hsSpecChar = {"_@. 0","1","ABC2","DEF3","GHI4","JKL5","MNO6","PQRS7","TUV8","WXYZ9"};
public static int[] hsScores;
public static char hsSelect = 'A';
public static int hsEntered = 0;
public static int hsLastSize = 0;
public static boolean hsSending = false;
public static String hsError = "";
public static int hsSubmit = 0;
public static int enterCount = 0; // Used as pause when entering name for score
public static int enterAnd = 0; // Used as pause when entering name for score
public static int enterScoreStatus = 0; // Used to decide which screen we are on when entering the score
public static int pressedTimer = 0;
public static int pressedCount = 0;
public static int lastPressed = 0;
public static int theKey = 0;
public static void setupHiscore(int ys, int ye, int fh)
{
MAX_SCORES = (ye-ys)/fh;
if (MAX_SCORES >= 10) MAX_SCORES = 10;
else if (MAX_SCORES >= 5) MAX_SCORES = 5;
hsNames = new char[NAME_LEN*MAX_SCORES];
hsScores = new int[MAX_SCORES];
}
public static void drawHiscore(Graphics g, int ys, int fh)
{
int xs = (GMCanvas.VIS_WIDTH-96)>>1,
x1 = xs+1,
x2 = xs+18,
x3 = xs+59;
StringBuffer b;
g.setClip(0, 0, GMCanvas.VIS_WIDTH, GMCanvas.VIS_HEIGHT);
g.setColor(0x00303060);
g.fillRect(xs,ys,96,((fh+1)*MAX_SCORES)+1);
for (int i = 0; i < MAX_SCORES;i++)
{
if ((i&1) != 0)
{
g.setColor(0x005050a0);
g.fillRect(x1,ys+1+(i*(fh+1)),16,fh);
g.fillRect(x2,ys+1+(i*(fh+1)),40,fh);
g.fillRect(x3,ys+1+(i*(fh+1)),36,fh);
}
g.setColor(0x00e0e000);
g.drawString(Integer.toString(i+1),x1+8,ys+1+(i*(fh+1)),Graphics.TOP | Graphics.HCENTER);
b = new StringBuffer("");
for (int j = 0; j < NAME_LEN; j++)
b.append(hsNames[(i*NAME_LEN)+j]);
g.drawString(b.toString(),x1+19,ys+1+(i*(fh+1)),Graphics.TOP | Graphics.LEFT);
b = null;
b = new StringBuffer("");
b.append(hsScores[i]);
g.drawString(b.toString(),x1+78,ys+1+(i*(fh+1)),Graphics.TOP | Graphics.HCENTER);
}
}
public static void drawEnterScore(Graphics g, int ys, int fh)
{
g.setClip(0, 0, GMCanvas.VIS_WIDTH, GMCanvas.VIS_HEIGHT);
int x = GMCanvas.VIS_WIDTH>>1,
y = GMCanvas.VIS_HEIGHT>>1,
c = 0,
fw = GMCanvas.GAME_FONT.stringWidth(" ") + 2,
ss = 0;
y -= (fh>>1);
if ((theKey >= '0' && theKey <= '9'))
{
if (theKey == lastPressed && pressedTimer-- > 0)
{
pressedCount++;
}
else
{
if (lastPressed != 0) hsName.append(" ");
pressedCount = 0;
}
lastPressed = theKey;
pressedTimer = 15;
if (hsSpecChar[theKey - '0'].length() <= pressedCount) pressedCount = 0;
c = (char)hsSpecChar[theKey - '0'].charAt(pressedCount);
hsName.setCharAt(hsName.length()-1,(char)c);
}
else if (theKey != 0 && (GMCanvas.keyStates & GMCanvas.LEFT_PRESSED) != 0 && hsName.length() > 0)
{
hsName.deleteCharAt(hsName.length() - 1);
if (hsName.length() == 0) hsName.append(" ");
else hsName.setCharAt(hsName.length()-1,' ');
lastPressed = 0;
pressedCount = 0;
}
else if (lastPressed != 0 && pressedTimer-- <= 0)
{
hsName.append(" ");
lastPressed = 0;
pressedCount = 0;
}
theKey = 0;
ss = 0;
if (hsName.length() > 0)
{
if (hsName.charAt(hsName.length()-1) == ' ' && hsName.length() > 1)
{
x += GMCanvas.GAME_FONT.stringWidth(hsName.toString().substring(0,hsName.length()-2)) >> 1;
ss = hsName.length()-1;
}
else
{
x += GMCanvas.GAME_FONT.stringWidth(hsName.toString().substring(0,hsName.length()-1)) >> 1;
ss = hsName.length();
}
if ((x+fw) >= GMCanvas.VIS_WIDTH) x = (GMCanvas.VIS_WIDTH - 1)-fw;
}
g.setColor(0x000000F0);
g.fillRect(0, y, GMCanvas.VIS_WIDTH, fh+4);
if ((GMCanvas.tickCount & 15) < 8)
{
g.setColor(0x00000000);
g.drawLine(x,y,x,y+fh+2);
g.setColor(0x00f0f0f0);
g.drawLine(x-1,y-1,x-1,y+fh+1);
}
g.setColor(0x00f0f0f0);
g.drawString(hsName.toString().substring(0,ss),x-2,y+2, Graphics.TOP | Graphics.RIGHT);
}
// Check to see if/where the name needs to be entered in the table and adjust the entries
// Also, update hsLastIn
public static void insertHiscore(int score, boolean bSave)
{
int i = MAX_SCORES-1;
while (true)
{
if (i >=0 && score > hsScores[i])
{
if (i < MAX_SCORES-1)
{
hsScores[i+1] = hsScores[i];
for (int j = 0; j < NAME_LEN; j++)
hsNames[((i+1)*NAME_LEN)+j] = hsNames[(i*NAME_LEN)+j];
if (i == 0) // Top score, so add the name to the table
{
hsScores[i] = score;
for (int j = 0; j < NAME_LEN; j++)
{
if (hsName.length() > j)
hsNames[j] = hsName.toString().charAt(j);
else
hsNames[j] = ' ';
}
}
}
}
else if (i >=0)
{
if (i < MAX_SCORES-1)
{
hsScores[i+1] = score;
for (int j = 0; j < NAME_LEN; j++)
{
if (hsName.length() > j)
hsNames[((i+1)*NAME_LEN)+j] = hsName.toString().charAt(j);
else
hsNames[((i+1)*NAME_LEN)+j] = ' ';
}
}
break;
}
i--;
if (i < 0) break;
}
// Update hsLastIn
if (bSave)
{
if (hsLastIn.length() > 0) hsLastIn.delete(0,hsLastIn.length());
hsLastIn.append(hsName.toString());
}
}
public static boolean checkHiscore(int score)
{
if (score > hsScores[MAX_SCORES-1]) return true;
return false;
}
public static void hsSend(int score)
{
StringBuffer c = new StringBuffer("");
c.append(score);
insertHiscore(score, true);
}
public static void copyLastIn()
{
//if (hsName.length() > 0) System.out.println("*** IN "+(hsName.charAt(0) == ' '));
if (hsLastIn.length() > 0)
{
// Remove leading spaces
for (int i = 0; i < hsLastIn.length(); i++)
{
if (hsLastIn.charAt(0) == ' ') hsLastIn.deleteCharAt(0);
else break;
}
if (hsLastIn.length() <= 0) hsLastIn.append(" ");
if (hsName.length() > 0) hsName.delete(0,hsName.length());
hsName.append(hsLastIn.toString());
}
else if (hsName.length() <= 0) hsName.append(" ");
theKey = 0;
pressedCount = 0;
lastPressed = 0;
//System.out.println("*** OUT "+(hsName.charAt(0) == ' '));
}
// -------------------------------------------------------------------------------------------
// Initial highscore entry
// -------------------------------------------------------------------------------------------
public static void initHighScore()
{
if (enterScoreStatus == 0 || enterScoreStatus == 1)
{
tickerX = GMCanvas.VIS_WIDTH + 8;
if (((GMCanvas.VIS_HEIGHT>>1)-20) > GMCanvas.fontHeight) tickerY = ((((GMCanvas.VIS_HEIGHT>>1)-GMCanvas.fontHeight)-20)>>1)+20;
else tickerY = 4;
tickerStartChar = 0;
tickerEndChar = 0;
tickerBuf = null;
tickerBuf = new StringBuffer("www.rumbleX.com. If you are registered at rumblex.com enter your player-id. If not just enter your nickname. Use 0 to enter symbols.");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -