コード例 #1
0
  private void showMenu(Graphics g) {
    Image bgImg = Resource.loadImage(Resource.PIC_ID_MAIN_BG);
    g.drawImage(bgImg, 0, 0, 0);
    if (mainMenu == null) {
      initMenuRes();
    }
    mainMenu.show(g);

    if (!Configurations.getInstance().isFavorWayNonsupport()) {
      Image collect = Resource.loadImage(Resource.PIC_ID_COLLECT);
      int sx = 12, sy = 405;
      if (collect != null) {
        g.drawImage(collect, sx, sy, 20);
      }
      if (groupIndex == 1) {
        DrawUtil.drawRect(g, sx, sy, collect.getWidth(), collect.getHeight(), 3, 0XFFFF00);
      }
    }
  }
コード例 #2
0
  private void showRank(Graphics g) {

    Image title = Resource.loadImage(Resource.PIC_ID_RANK_TITLE);
    Image item = Resource.loadImage(Resource.PIC_ID_RANK_ITEM);
    Image foot = Resource.loadImage(Resource.PIC_ID_RANK_FOOT);

    int titleX = (engine.getScreenWidth() - title.getWidth()) >> 1;
    int titleY = 30;
    g.drawImage(title, titleX, titleY, 20);

    Font font = g.getFont();
    int itemX = titleX + ((title.getWidth() - item.getWidth()) >> 1);
    int itemY = titleY + title.getHeight();
    int deltaH = (item.getHeight() - font.getHeight()) >> 1;
    int sx = 0, sy = 0;
    String ss = null;
    int rankX = 43 - 20, idX = 43 + 80, scoresX = 188 + 50, seiX = 309 + 30, timeX = 467 + 10;
    for (int i = 0; i < 11; ++i) {
      g.drawImage(item, itemX, itemY, 20);
      sy = itemY + deltaH;
      itemY += item.getHeight();
      if (i == 0) {
        /*显示表头*/
        rankX += itemX;
        idX += itemX;
        scoresX += itemX;
        seiX += itemX;
        timeX += itemX;

        g.setColor(165, 173, 64);
        g.drawString("游戏排名", rankX, sy, 20);
        g.drawString("用户ID", idX, sy, 20);
        g.drawString("积分", scoresX, sy, 20);
        g.drawString("所用主公", seiX, sy, 20);
        g.drawString("统一时间", timeX, sy, 20);

        /*计算表数据坐标*/
        rankX += font.stringWidth("游戏") - 2;
        idX += ((font.stringWidth("用户ID") - font.stringWidth("0234**98")) >> 1);
        scoresX += ((font.stringWidth("积分") - font.stringWidth("34567")) >> 1);
        seiX += ((font.stringWidth("所用主公") - font.stringWidth("曹操")) >> 1);
        timeX += ((font.stringWidth("统一时间") - font.stringWidth("2012-03-24 23:58")) >> 1);
      } else {
        if (rankingList != null) {
          if (i <= rankingList.length) {
            g.setColor(0XFFFF00);
            g.drawString(Integer.toString(rankingList[i - 1].getRanking()), rankX, sy, 20);
            g.setColor(0XFFFFFF);
            String userId = rankingList[i - 1].getUserId();
            int userIdLen = userId.length();
            g.drawString(
                userId.substring(0, 4) + "**" + userId.substring(userIdLen - 2), idX, sy, 20);
            g.drawString(Integer.toString(rankingList[i - 1].getScores()), scoresX, sy, 20);
            String remark = rankingList[i - 1].getRemark();
            g.drawString(remark.substring(0, remark.indexOf(";")), seiX, sy, 20);
            String time = rankingList[i - 1].getTime();
            g.drawString(time.substring(0, time.length() - 3), timeX, sy, 20);
          }
        }
      }
    }

    int footX = titleX + ((title.getWidth() - foot.getWidth()) >> 1);
    int footY = itemY;
    g.drawImage(foot, footX, footY, 20);
    g.setColor(0XFFFF00);
    if (attainment != null) {
      ss = Integer.toString(attainment.getRanking());
    } else {
      ss = "榜上无名";
    }
    sx = footX + 175 + ((98 - font.stringWidth(ss)) >> 1);
    sy = footY + 9 + ((33 - font.getHeight()) >> 1);
    g.drawString(ss, sx, sy, 20);

    sx = footX + 508;
    sy = footY + 6;
    DrawUtil.drawRect(g, sx, sy, 89, 39, 3);
  }