Ejemplo n.º 1
0
  private void paint_Confirm(Graphics g) {
    int h = 50;
    Painter.drawDialog(g, 0, gd.screenHeight - h, gd.screenWidth, h, Painter.DIALOG_DEEP);
    g.setColor(Color.black);
    if (gd.player.bag.get(
            gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
            gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
        != null) {
      if (gd.bag_tabIndex == 0) {
        g.drawString(
            "是否要使用物品\""
                + (gd.gameObjectManager.getItem(gd.player.bag.getList(Bag.ITEM)[gd.bag_curIndex])
                    .name)
                + "\"",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);

      } else {
        g.drawString(
            "是否要将装备\""
                + (gd.gameObjectManager.getEquip(gd.player.bag.getList(Bag.EQUIP)[gd.bag_curIndex])
                    .name)
                + "\"穿上",
            gd.screenWidth / 2,
            gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
            Graphics.TOP | Graphics.HCENTER);
      }
    }
  }
Ejemplo n.º 2
0
 private void drawDialog(Graphics g) {
   Painter.drawDialog(
       g,
       0,
       gd.screenHeight - g.getFont().getHeight() * 3 - 20,
       gd.screenWidth,
       g.getFont().getHeight() * 3 + 20,
       Painter.DIALOG_DEEP);
   g.setFont(Const.Font.FONTSMALL_PLAIN);
   // 对话人
   Painter.drawString(
       g, gd.dialog_name + ":", 10, gd.screenHeight - g.getFont().getHeight() * 3 - 10, 0xffffff);
   // 两行对话内容
   Painter.drawString(
       g,
       gd.dialog_content[gd.dialog_index],
       10,
       gd.screenHeight - g.getFont().getHeight() * 2 - 10,
       0xffffff);
   if (gd.dialog_index + 1 < gd.dialog_content.length) {
     Painter.drawString(
         g,
         gd.dialog_content[gd.dialog_index + 1],
         10,
         gd.screenHeight - g.getFont().getHeight() - 10,
         0xffffff);
   }
 }
Ejemplo n.º 3
0
  protected void paint(Graphics g) {
    int width = this.getWidth();

    // Fill in the background White
    g.setColor(0xFFFFFF); // White
    g.fillRect(0, 0, width, this.getHeight());

    int y = yPos;
    y += MARGIN;

    if (this.logo != null) {
      g.drawImage(this.logo, width / 2, y, Graphics.TOP | Graphics.HCENTER);
      y += logo.getHeight() + MARGIN;
    }

    g.setColor(0x0); // Black

    // Write the title "About"
    final Font titleFont =
        Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD | Font.STYLE_UNDERLINED, Font.SIZE_LARGE);

    /*
     * TODO: currently paints ALL the text, even if there is (a lot) more
     * than can fit on the screen. (must do this first time to assess
     * 'height', but shouldn't need to do it for any other repaint
     */
    for (int i = 0; i < TITLES.length; i++) {
      final int basicFontHeight = DEFAULT_SIMPLE_FONT.getHeight();
      final int titleFontHeight = titleFont.getHeight();
      // Write out the 'message' heading
      g.setFont(titleFont);
      final String title = TITLES[i];
      int stringWidth = g.getFont().stringWidth(title);
      g.drawString(title, (width - stringWidth) / 2, y, 0);
      y += titleFontHeight;

      // Write out the 'message' text.
      g.setFont(DEFAULT_SIMPLE_FONT);
      for (int j = 0; j < this.formattedMessages[i].length; j++) {
        final String message = this.formattedMessages[i][j];
        stringWidth = g.getFont().stringWidth(message);
        g.drawString(message, (width - stringWidth) / 2, y, 0);
        y += basicFontHeight;
      }
      y += basicFontHeight;
    }

    // Set the total-Height the first time
    if (firstTime) {
      totalHeight = y + MARGIN;
      firstTime = false;
    }
  }
Ejemplo n.º 4
0
  /**
   * Paint this window. This method should not generally be overridden by subclasses. This method
   * carefully stores the clip, translation, and color before calling into subclasses. The graphics
   * context should be translated such that it is in this window's coordinate space (0,0 is the top
   * left corner of this window).
   *
   * @param g The graphics object to use to paint this window.
   * @param refreshQ The custom queue which holds the set of refresh regions needing to be blitted
   *     to the screen
   */
  public void paint(Graphics g, CGraphicsQ refreshQ) {
    // We reset our dirty flag first. Any layers that become
    // dirty in the duration of this method will then cause it
    // to toggle back to true for the subsequent pass.
    // IMPL NOTE: when layers start to do complex animation, there will
    // likely need to be better atomic handling of the dirty state,
    // and layers becoming dirty and getting painted
    this.dirty = false;

    // Store the clip, translate, font, color
    cX = g.getClipX();
    cY = g.getClipY();
    cW = g.getClipWidth();
    cH = g.getClipHeight();

    tranX = g.getTranslateX();
    tranY = g.getTranslateY();

    font = g.getFont();
    color = g.getColor();

    // We set the basic clip to the size of this window
    g.setClip(bounds[X], bounds[Y], bounds[W], bounds[H]);

    synchronized (layers) {
      sweepAndMarkLayers();
      copyAndCleanDirtyLayers();
    }
    paintLayers(g, refreshQ);

    // We restore the original clip. The original font, color, etc.
    // have already been restored
    g.setClip(cX, cY, cW, cH);
  }
Ejemplo n.º 5
0
 public void paint(Graphics g) {
   g.setColor(color);
   String scoreStr = label + score;
   int offset = (g.getFont().stringWidth(scoreStr)) / 2;
   g.drawString(
       scoreStr,
       r.getLocation().getRealX() - offset,
       r.getLocation().getRealY(),
       Graphics.TOP | Graphics.LEFT);
 }
Ejemplo n.º 6
0
  private void paint_Tip(Graphics g) {
    int h = 50;
    Painter.drawDialog(g, 0, gd.screenHeight - h, gd.screenWidth, h, Painter.DIALOG_DEEP);
    g.setColor(Color.black);
    if (gd.bag_tabIndex == 0) {
      g.drawString(
          "使用成功",
          gd.screenWidth / 2,
          gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
          Graphics.TOP | Graphics.HCENTER);

    } else {
      g.drawString(
          "装备成功",
          gd.screenWidth / 2,
          gd.screenHeight - h + (h - g.getFont().getHeight()) / 2,
          Graphics.TOP | Graphics.HCENTER);
    }
  }
Ejemplo n.º 7
0
 private void showStartChoice(Graphics g) {
   g.drawImage(Resource.loadImage(Resource.PIC_ID_CHOICE_BG), 0, 0, 0);
   choiceCursor.show(
       g,
       Resource.POS_SEIGNEUR_CHOICE[choiceIndex][0],
       Resource.POS_SEIGNEUR_CHOICE[choiceIndex][1]);
   String info =
       Resource.STR_SEIGNEUR_NAME[choiceIndex]
           + "  城池X"
           + Resource.NUM_SEIGNEUR_CITYS[choiceIndex]
           + "  武将X"
           + Resource.NUM_SEIGNEUR_GENERALS[choiceIndex];
   g.setColor(0XFFFFFF);
   Font font = g.getFont();
   g.drawString(info, (engine.getScreenWidth() - font.stringWidth(info)) >> 1, 456, 0);
 }
Ejemplo n.º 8
0
 /** 绘图 */
 public void paint(Graphics g) {
   Painter.fillRect(g, 0, 0, gd.screenWidth, gd.screenHeight, 0x000000);
   drawMap(g);
   drawPlayer(g);
   switch (gd.pageIndex) {
     case PAGE_MAP:
       break;
     case PAGE_MENU:
       drawMenu(g);
       break;
     case PAGE_DIALOG:
       drawDialog(g);
       break;
     case PAGE_WAIT:
       Painter.drawString(
           g,
           "等待" + (gd.waitTime - gd.waitIndex) + "秒",
           5,
           gd.screenHeight - g.getFont().getHeight(),
           0xffffff);
       break;
   }
 }
Ejemplo n.º 9
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);
  }
Ejemplo n.º 10
0
  public static final boolean SoundOnOff_paint_big(Graphics g) {
    cCPdrawCleanScreen(g, 0);
    if (!BtnSoundOnOffInited) {
      // #if MODEL != "G12_Review"
      // #if ENABLE_TOUCH=="TRUE"
      cTouch.InitVirtualKeysForLRSK(SCR_W, SCR_H);
      // #endif
      // #endif
      BtnSoundOnOffInited = true;
    }
    int FontHeight = g.getFont().getHeight();
    if (!HasSound) {
      if ((++SoundOnOffPaintCount) > SoundOnOffTotalFrame) {
        FreeAllImage();
        // #if ENABLE_TOUCH=="TRUE"
        cTouch.ClearBtns();
        cTouch.TargetCanvas = null;
        // #endif
        SoundOnOffisFinished = true;
        return true;
      }
    }
    // 读取资源
    // #if SOUNDONOFF=="TRUE"
    Image Img_firstLogo = GetImage(IDX_FIRSTLOGO);
    // #endif
    Image Img_sound = GetImage(IDX_SOUND);
    Image Img_line = GetImage(IDX_LINE);
    Image Img_yes = GetImage(IDX_YES);
    Image Img_no = GetImage(IDX_NO);
    Image Img_cp = GetImage(IDX_CP);

    Image Img_CNM = GetImage(IDX_CNM);
    // #if CHANNEL_NAME=="SHYL"
    Image Img_CPYL = GetImage(IDX_CPYL);
    // #endif
    // 开始绘制
    int height = SCR_H;
    if (HasSound) {
      // 绘制左右软键
      g.drawImage(Img_yes, 0, height, Graphics.LEFT | Graphics.BOTTOM);
      g.drawImage(Img_no, SCR_W, height, Graphics.RIGHT | Graphics.BOTTOM);
      height -= Img_yes.getHeight();
      height -= LINESPACE;
      // 绘制线条
      height -= Img_line.getHeight();
      g.drawImage(Img_line, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
      height -= LINESPACE;

      // 绘制  是否开启声音
      height -= Img_sound.getHeight();
      g.drawImage(Img_sound, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
      height -= LINESPACE;
    }
    // #if CHANNEL_NAME=="SHYL"
    g.drawImage(Img_CPYL, SCR_W >> 1, height >> 1, Graphics.VCENTER | Graphics.HCENTER);
    // #endif
    // #if SOUNDONOFF=="TRUE"
    // #if LOGO=="TRUE"
    // 绘制CNM Logo
    height -= Img_CNM.getHeight();
    g.drawImage(Img_CNM, SCR_W >> 1, height, Graphics.HCENTER | Graphics.TOP);
    height -= LINESPACE;
    // #endif

    // 绘制  游戏 Logo
    // 这正是剩余的高度,将FirstLogo 放到正中
    g.drawImage(Img_firstLogo, SCR_W >> 1, height >> 1, Graphics.HCENTER | Graphics.VCENTER);
    // #endif
    // #if SHOWGAMENAME=="TRUE"
    // 画游戏名字
    // #endif
    return false;
  };
Ejemplo n.º 11
0
  private void paint_Main(Graphics g) {

    int th = 50; // 标题栏高度
    int ih = 80; // 介绍栏高度
    int ch = gd.screenHeight - th - ih; // 中间列表区域高度
    int gap = 10; // 间距
    int cellW = 160, cellH = 30;
    /** 标题 */
    Painter.drawDialog(g, 0, 0, gd.screenWidth, th, Painter.DIALOG_DEEP);
    g.setFont(Const.Font.FONTLARGE_BOLD);
    g.setColor(Const.Color.GREEN);
    g.drawString("背 包", gd.screenWidth / 2, (th - g.getFont().getHeight()) / 2, Const.Anchor.HT);
    /** 列表 */
    // 底框
    Painter.drawDialog(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_DEEP);
    // 选项卡
    Painter.drawTab(g, 0, th, gd.screenWidth, ch, Painter.DIALOG_LIGHT, gd.bag_tabIndex, tabItems);
    // 列表
    gd.bag_showNum = (ch - 5 * gap) / cellH; // 可显示技能数量
    int space = ch - 3 * gap - gd.bag_showNum * cellH; // 总的竖向剩余空间
    space = space / (gd.bag_showNum + 1); // 间距
    g.setColor(Const.Color.BLACK);
    g.setFont(Const.Font.FONTSMALL_PLAIN);
    Painter.drawTable(
        g,
        (gd.screenWidth - cellW) / 2 - gap / 2,
        th + 3 * gap,
        cellW,
        cellH,
        gd.bag_showNum,
        space,
        gd.bag_tabIndex == 0 ? gd.items : gd.equips,
        Const.Color.BLACK,
        gd.bag_topIndex,
        gd.bag_curIndex,
        Const.Anchor.HV,
        Painter.NODIALOG,
        Painter.CELL_DEEP);

    /** 介绍 */
    Painter.drawDialog(g, 0, th + ch, gd.screenWidth, ih, Painter.DIALOG_DEEP);
    if (gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length > 0
        && gd.player.bag.get(
                gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
            != null) {
      Painter.drawWordWrapString(
          g,
          gd.player.bag.get(
                  gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP,
                  gd.player
                      .bag
                      .getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP)[gd.bag_curIndex])
              .intro,
          gap / 2,
          th + ch + gap / 2,
          gd.screenWidth - gap,
          ih - gap,
          Const.Color.WHITE);
    }
    /** 滚动条 */
    Painter.drawScrollbar(
        g,
        Painter.SCROLLBAR_VERTICAL,
        (gd.screenWidth - cellW) / 2 + cellW + gap / 2,
        th + 3 * gap + space,
        th + ch - space,
        gd.bag_topIndex,
        gd.bag_showNum,
        gd.player.bag.getList(gd.bag_tabIndex == 0 ? Bag.ITEM : Bag.EQUIP).length);
  }