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

📄 thaimanager.java

📁 又是一款j2me 游戏
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                return 87;

            case 122: // 'z'
                return 95;

            case 123: // '{'
                return 103;

            case 124: // '|'
                return 110;

            case 125: // '}'
                return 117;

            case 126: // '~'
                return 124;

            case 127: // '\177'
                return 131;

            case 128:
                return 139;

            case 129:
                return 148;

            case 130:
                return 0;

            case 131:
                return 8;

            case 132:
                return 18;

            case 133:
                return 25;

            case 134:
                return 0;

            case 135:
                return 5;

            case 136:
                return 11;

            case 137:
                return 16;

            case 138:
                return 26;

            case 139:
                return 32;

            case 140:
                return 38;

            case 141:
                return 45;

            case 142:
                return 51;

            case 143:
                return 54;

            case 144:
                return 58;

            case 145:
                return 61;

            case 146:
                return 67;

            case 147:
                return 71;

            case 148:
                return 77;

            case 149:
                return 82;

            case 150:
                return 87;

            case 151:
                return 93;

            case 152:
                return 98;

            case 153:
                return 103;

            case 154:
                return 0;

            case 155:
                return 2;

            case 156:
                return 7;

            case 157:
                return 13;

            case 158:
                return 17;

            case 159:
                return 21;

            case 160:
                return 25;

            case 161:
                return 30;

            case 162:
                return 36;

            case 163:
                return 42;

            case 164:
                return 48;

            case 165:
                return 55;

            case 166:
                return 62;

            case 167:
                return 70;

            case 168:
                return 78;

            case 169:
                return 84;

            case 170:
                return 92;

            case 171:
                return 100;

            case 172:
                return 107;
            }
        return -1;
    }

    public int GetFontPosY(int id)
    {
        if(id >= 0 && id <= 25)
            return 0;
        if(id <= 51)
            return 14;
        if(id <= 83)
            return 26;
        if(id <= 89)
            return 38;
        if(id <= 109)
            return 53;
        if(id <= 129)
            return 66;
        if(id <= 133)
            return 79;
        if(id <= 153)
            return 90;
        return id > 172 ? -1 : 104;
    }

    public int GetFontOffsetX(int id)
    {
        if(id == 137)
            return -5;
        if(id == 136)
            return -1;
        if(id >= 153 && id <= 160)
            return -3;
        if(id >= 138 && id <= 141)
            return -6;
        return (id < 142 || id > 143) && id != 135 ? 0 : -5;
    }

    public int GetFontOffsetY(int id, boolean doubleUpper)
    {
        if(id + 71 >= 97 && id + 71 <= 122)
            return 1;
        if(id == 134)
            return -1;
        if(id >= 136 && id <= 137)
            return -2;
        if(id >= 146 && id <= 152)
            return -2;
        if(id >= 138 && id <= 141 || id == 135)
            return -1;
        if(id >= 153 && id <= 160)
            return !doubleUpper ? -3 : -5;
        else
            return 0;
    }

    public int getFontHeight(int id)
    {
        if(id >= 130 && id <= 135)
            return 11;
        return id < 142 || id > 143 ? 13 : 15;
    }

    public void DrawText(Graphics g, int id[], int x, int y)
    {
        int posX = 0;
        int posY = 0;
        int xGap = 1;
        int cursor = x;
        for(int i = 0; i < id.length; i++)
        {
            g.setClip(posX, posY, GetFontWidth(id[i]), 13);
            g.drawImage(thaiFontImg, posX - GetFontPosX(id[i]), posY - GetFontPosY(id[i]), 20);
            cursor += GetFontWidth(id[i]) + xGap;
        }

    }

    private int getID(int id)
    {
        if(id >= 65 && id <= 90)
            id -= 65;
        else
        if(id >= 97 && id <= 122)
            id -= 71;
        else
        if(id >= 33 && id <= 64)
            id += 19;
        else
        if(id >= 91 && id <= 96)
            id -= 7;
        return id;
    }

    public int getID(int id, boolean type)
    {
        if(id == -91)
            id = -92;
        else
        if(id >= -89 && id <= -82)
            id -= 2;
        else
        if(id > -82 && id < -64)
            id -= 3;
        else
        if(id >= -64)
            id -= 7;
        id += 217;
        return id;
    }

    public Position DrawText(Graphics g, String str, Position beginPos, Position endPos, Position currentPos, int minY, boolean wordWarp,
            boolean isLink, boolean isHighLight, boolean isDraw)
    {
        boolean doubleUpper = false;
        boolean type = true;
        int posX = currentPos.getX();
        int posY = currentPos.getY();
        int xGap = 1;
        int cursor = posX;
        int y = posY;
        int str_i[] = new int[str.length()];
        for(int i = 0; i < str.length(); i++)
        {
            Character c = new Character(str.charAt(i));
            str_i[i] = c.hashCode();
        }

        for(int i = 0; i < str_i.length; i++)
        {
            int id = str_i[i];
            if(id == 10)
            {
                if(wordWarp)
                    cursor = beginPos.getX();
                else
                    cursor = currentPos.getX();
            } else
            if(id == 13)
                y += 17;
            else
            if(id == 32)
            {
                if(isDraw)
                    if(isHighLight)
                    {
                        g.setClip(cursor, y, 3, 14);
                        g.setColor(0x90ee90);
                        g.fillRect(cursor, y, 3, 14);
                    } else
                    if(isLink)
                    {
                        g.setColor(255);
                        g.setClip(cursor, y, 3, 13);
                        g.drawLine(cursor, y + 12, 4, y + 12);
                    }
                cursor += 3;
            } else
            {
                if(id >= 33 && id <= 122)
                    id = getID(id);
                else
                if(id >= 3585)
                    id = getID(id - 3712, true);
                if(cursor != beginPos.getX() || cursor != currentPos.getX())
                    posX = cursor + GetFontOffsetX(id);
                else
                    posX = cursor;
                if(posX + GetFontWidth(id) > endPos.getX())
                {
                    y += 17;
                    if(wordWarp)
                        cursor = beginPos.getX();
                    else
                        cursor = currentPos.getX();
                    posX = cursor;
                }
                posY = y + GetFontOffsetY(id, doubleUpper);
                int h = getFontHeight(id);
                if(posY + 17 < endPos.getY() && posY > minY - 10)
                {
                    if((isLink || isHighLight) && isDraw)
                    {
                        g.setClip(posX, y, GetFontWidth(id) + xGap, h + 1);
                        if(isLink)
                        {
                            g.setColor(255);
                            g.drawLine(posX, y + 12, posX + GetFontWidth(id) + xGap, y + 12);
                        }
                        if(isHighLight)
                        {
                            g.setColor(0x90ee90);
                            g.fillRect(posX, y, posX + GetFontWidth(id) + xGap, y + 12);
                        }
                    }
                    if(isDraw)
                    {
                        g.setClip(posX, posY, GetFontWidth(id), h);
                        g.drawImage(thaiFontImg, posX - GetFontPosX(id), posY - GetFontPosY(id), 20);
                    }
                }
                if(id >= 138 && id <= 144 || id == 135)
                    cursor = cursor;
                else
                if(id >= 153 && id <= 160)
                    cursor = cursor;
                else
                if(id >= 142 && id <= 144)
                    cursor = cursor;
                else
                    cursor += GetFontWidth(id) + xGap + GetFontOffsetX(id);
                if(id >= 138 && id <= 141 || id == 135)
                    doubleUpper = true;
                else
                    doubleUpper = false;
            }
        }

        return new Position(cursor, y);
    }

    public Position DrawText(Graphics g, String str, Position beginPos, Position endPos, Position currentPos, int minY, boolean wordWarp,
            boolean isLink, boolean isHighLight)
    {
        return DrawText(g, str, beginPos, endPos, currentPos, minY, wordWarp, isLink, isHighLight, true);
    }

    public Position getNextPos(Graphics g, String str, Position beginPos, Position endPos, Position currentPos, int minY, boolean wordWarp,
            boolean isLink, boolean isHighLight)
    {
        return DrawText(g, str, beginPos, endPos, currentPos, minY, wordWarp, isLink, isHighLight, false);
    }

    public int DrawText(Graphics g, byte str[], int x, int y, int maxX, int maxY, int offset)
    {
        boolean type = true;
        boolean doubleUpper = false;
        int origY = y;
        y -= offset;
        int posX = 0;
        int posY = y;
        int xGap = 1;
        int cursor = x;
        for(int i = 0; i < str.length; i++)
        {
            int id = str[i];
            if(id == 10)
            {
                cursor = x;
                continue;
            }
            if(id == 13)
            {
                y += 17;
                continue;
            }
            if(id == 32)
            {
                cursor += 3;
                continue;
            }
            if(id >= 33 && id <= 122)
            {
                id = getID(id);
            } else
            {
                if(id == -17 || id == -69 || id == -65 || id == -32)
                    continue;
                if(id == -72 && str[i - 1] != -72)
                {
                    type = true;
                    continue;
                }
                if(id == -71 && str[i - 1] != -72)
                {
                    type = false;
                    continue;
                }
                if(id < 0)
                    id = getID(id, type);
            }
            if(cursor != x)
                posX = cursor + GetFontOffsetX(id);
            else
                posX = cursor;
            if(posX + GetFontWidth(id) > maxX)
            {
                y += 17;
                cursor = x;
                posX = cursor;
            }
            posY = y + GetFontOffsetY(id, doubleUpper);
            int h = getFontHeight(id);
            if(posY + 17 < maxY && posY > origY - 5 && isDraw)
            {
                g.setClip(posX, posY, GetFontWidth(id), h);
                g.drawImage(thaiFontImg, posX - GetFontPosX(id), posY - GetFontPosY(id), 20);
            }
            if(id >= 138 && id <= 144 || id == 135)
                cursor = cursor;
            else
            if(id >= 153 && id <= 160)
                cursor = cursor;
            else
            if(id >= 142 && id <= 144)
                cursor = cursor;
            else
            if(id == 137)
                cursor += 4 + xGap;
            else
                cursor += GetFontWidth(id) + xGap;
            if(id >= 138 && id <= 141 || id == 135)
                doubleUpper = true;
            else
                doubleUpper = false;
        }

        return posY;
    }

    public boolean isASCII(String str)
    {
        for(int i = 0; i < str.length(); i++)
        {
            Character c = new Character(str.charAt(i));
            int hash = c.hashCode();
            if(hash > 127)
                return false;
        }

        return true;
    }

    private int xOffset;
    private int yOffset;
    private int cursor;
    private boolean isDraw;
    private Image thaiFontImg;
}

⌨️ 快捷键说明

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