⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamesettings.java

📁 j2me游戏都市骑士的代码,是一款横版格斗的游戏.可以学习参考.
💻 JAVA
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2005-11-26 11:41:24
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 

import java.io.*;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;

public class GameSettings
{

    private GameSettings()
    {
    }

    private static void initializeSettings()
    {
        ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
        DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
        try
        {
            byte abyte0[];
            try
            {
                dataoutputstream.writeUTF("Easy*On:On");
                abyte0 = bytearrayoutputstream.toByteArray();
                dataoutputstream.close();
            }
            catch(IOException ioexception)
            {
                System.out.println(ioexception);
                throw new RecordStoreException();
            }
            mySettings.addRecord(abyte0, 0, abyte0.length);
        }
        catch(RecordStoreException recordstoreexception)
        {
            closeSettings();
            System.out.println(recordstoreexception);
        }
    }

    static void openSettings()
    {
        try
        {
            mySettings = RecordStore.openRecordStore("GameSettings", true);
            if(settingsHaveBeenInit)
                return;
            if(mySettings.getNumRecords() == 0)
            {
                initializeSettings();
            } else
            {
                byte abyte0[] = mySettings.getRecord(1);
                if(abyte0 != null)
                    try
                    {
                        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(abyte0);
                        DataInputStream datainputstream = new DataInputStream(bytearrayinputstream);
                        settings = datainputstream.readUTF();
                        datainputstream.close();
                        if(settings.equals(""))
                        {
                            settings = "Easy*On:On";
                            saveSettings(settings);
                        }
                    }
                    catch(IOException ioexception) { }
            }
            settingsHaveBeenInit = true;
        }
        catch(RecordStoreException recordstoreexception)
        {
            System.out.println(recordstoreexception);
        }
    }

    static void closeSettings()
    {
        if(mySettings != null)
        {
            try
            {
                mySettings.closeRecordStore();
            }
            catch(RecordStoreException recordstoreexception) { }
            mySettings = null;
        }
    }

    static void saveSettings(String s)
    {
        try
        {
            byte abyte0[];
            try
            {
                ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
                DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream);
                dataoutputstream.writeUTF(s);
                abyte0 = bytearrayoutputstream.toByteArray();
                dataoutputstream.close();
            }
            catch(IOException ioexception)
            {
                throw new RecordStoreException();
            }
            if(mySettings == null)
            {
                openSettings();
                mySettings.setRecord(1, abyte0, 0, abyte0.length);
                closeSettings();
            } else
            {
                mySettings.setRecord(1, abyte0, 0, abyte0.length);
            }
        }
        catch(RecordStoreException recordstoreexception) { }
        settings = s;
    }

    static String getSettings()
    {
        if(!settingsHaveBeenInit)
        {
            openSettings();
            closeSettings();
        }
        return settings;
    }

    static RecordStore mySettings;
    static boolean settingsHaveBeenInit = false;
    static String settings;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -