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

📄 imageset.java

📁 手机游戏rpg引擎
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ImageSet.java

package mobileRPG.client;

import java.io.PrintStream;
import javax.microedition.lcdui.*;

// Referenced classes of package mobileRPG.client:
//            Main, ConfigFile

public class ImageSet extends Canvas
    implements Runnable
{

    private Image image[];
    private int imageID[];
    private Display display;
    private Thread thread;
    private String file;
    private Main main;
    private int backgroundcolor;
    private int foregroundcolor;
    private int xSize;
    private int ySize;
    private String message;
    private int progress;

    public ImageSet(Main main, String file)
    {
        backgroundcolor = 0xffffff;
        foregroundcolor = 0;
        this.main = main;
        this.file = file;
        xSize = getWidth();
        ySize = getHeight();
        message = "Loading... 0%";
        progress = 0;
        display = Display.getDisplay(main);
        (thread = new Thread(this)).start();
    }

    public Image getImage(int imageID)
    {
        for(int n = 0; n < this.imageID.length; n++)
            if(this.imageID[n] == imageID)
                return image[n];

        return null;
    }

    public void run()
    {
        loadImages();
        main.loadImagesCompleted();
        display = null;
        main = null;
        file = null;
    }

    public void loadImages()
    {
        message = "Loading... 0%";
        ConfigFile cf = new ConfigFile(file);
        int imageCount = cf.readIntLine();
        image = new Image[imageCount];
        imageID = new int[imageCount];
        imageCount = 0;
        for(; !cf.isClosed(); Thread.yield())
        {
            int index = 0;
            String buffer[] = cf.readArrayLine('|');
            imageID[imageCount] = Integer.valueOf(buffer[0]).intValue();
            try
            {
                image[imageCount] = Image.createImage(buffer[1]);
            }
            catch(Exception e)
            {
                System.err.println("Error Loading ImageSet: " + e.toString());
            }
            imageCount++;
            progress = (imageCount * 100) / imageID.length;
            message = "Loading... " + progress + "%";
            repaint();
        }

        message = "Loading... Complete";
        progress = 100;
        repaint();
    }

    protected void paint(Graphics g)
    {
        g.setColor(backgroundcolor);
        g.fillRect(0, 0, xSize, ySize);
        g.setColor(foregroundcolor);
        g.drawRect(10, 10, xSize - 20, 10);
        g.fillRect(10, 10, ((xSize - 20) * progress) / 100, 10);
        g.drawString(message, 10, 30, 20);
    }

    protected void keyPressed(int i)
    {
    }
}

⌨️ 快捷键说明

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