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

📄 matcommand.java

📁 《神州》RPG游戏引擎
💻 JAVA
字号:
import javax.microedition.lcdui.*;

public class MatCommand
{
	public static String COMMAND_CANCEL="取消";
	public static String COMMAND_USE="使用";
	public static String COMMAND_PUTUP="装备";
	public static String COMMAND_PUTDOWN="卸下";
	public static String COMMAND_CHANGE="更换";
	public String[] command;
	//private Graphics g;
	//private Canvas1 canvas;
	private int commandIndex;


	private int x,y;

	public MatCommand()
	{
		//this.canvas = canvas;
		//this.g = this.canvas.g;
        //System.out.println("New CommandList Object");
	}

	public void setPosition(int x,int y)
	{
		this.x = x;
		this.y = y;
	}
    public void setCommand(String[] command)
    {
        this.command = command;
	}
    public int getCommandIndex()
    {
        return commandIndex;
	}
	public void nextCommand()
	{
		if(commandIndex < command.length-1)
		{
			commandIndex++;
		}
	}
	public void prevCommand()
	{
		if(commandIndex > 0)
		{
			commandIndex--;
		}
	}
	public void paint(Graphics g)
	{
    	int w=0,h=0;

        if(command != null)
    	{
			for(int i=0;command!=null && i<command.length;i++)
	    	{
	    		if(w<Style.font.stringWidth(command[i]))
	    		{
	    			w=Style.font.stringWidth(command[i]);
	    		}
	    	}
			h = command.length*Style.font.getHeight();
    	}
    	w = w + 6;
		g.setColor(Style.bgColor);
        g.fillRect(x,y,w,h);  //对话框背景色
        g.setColor(Style.boardColor);
    	g.drawRect(x,y,w,h); //外框
    	for(int i=0;i<command.length;i++)
    	{
    		if(i==commandIndex)
    		{
	    		//画高亮;
	    		g.setColor(Style.highLight);
	    		g.fillRect(x+1,y+commandIndex*Style.font.getHeight()+1,w-1,Style.font.getHeight()-1);
    		}
    		g.setColor(0x000000);
    		g.drawString(command[i],x+3,y+i*Style.font.getHeight(),Style.LT);
    	}

	}
}

⌨️ 快捷键说明

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